フィルターのクリア

Error in Variables Regression

6 ビュー (過去 30 日間)
Fabrice Lambert
Fabrice Lambert 2023 年 9 月 1 日
編集済み: Fabrice Lambert 2023 年 9 月 4 日
Hi. I'd like to perform a multilinear Error-in-Variables Regression, i.e. I have uncertainty in the predictors as well as in the dependent variable. This is sometimes also named Total Least Squares Regression. To my surprise, this is not part of the standard matlab functions as far as I can tell. Does anyone know if I missed something or if this (rather basic functionality I would say) is indeed not included with Matlab?

採用された回答

Torsten
Torsten 2023 年 9 月 2 日
編集済み: Torsten 2023 年 9 月 2 日
Linear Total Least Squares Regression means minimizing the sum of distances of projections of your data on a linear subspace. This is usually accomplished by using "svd".
If you don't want to adapt "svd" according to your need, you can try the followig package:
  3 件のコメント
Torsten
Torsten 2023 年 9 月 2 日
Fabrice Lambert
Fabrice Lambert 2023 年 9 月 4 日
編集済み: Fabrice Lambert 2023 年 9 月 4 日
Thanks.
I modified his code to make it a bit more flexible in terms of dimensions in case anyone's interested.
function [Crit_TLS, ThetaEstimTLS] = tls(Pred,Crit,Predstd,Critstd)
%tls Total Least Squares Regression
% Pred: Predictors in column form
% Crit: Criterions in column form
% Predstd: standard deviation of Predictors, horizontal vector
% Critstd: standard deviation of Criterions, horizontal vector.
% Modified from Antonio Sala Piqueras, Universitat Politècnica de València.
if size(Pred,1) ~= size(Crit,1)
error('X and Y must have the same number of rows')
end
Crit_N = size(Crit,2);
Pred_N = size(Pred,2);
Crit_std = diag(Critstd);
Pred_std = diag(Predstd);
Crit_scaled = (Crit-mean(Crit)) / Crit_std; % scale to mean zero (data) and unit variance (noise)
Pred_scaled = (Pred-mean(Pred)) / Pred_std; % scale to mean zero (data) and unit variance (noise)
Data_scaled=[Crit_scaled Pred_scaled];
[N,~]=size(Data_scaled);
[~,~,V]=svd(Data_scaled / sqrt(N-1),'econ'); %TLS and SVD are the same with the proposed scaling.
Model_scaled = V(:,Pred_N+1:end);
ModPred_sc = Model_scaled(end-Pred_N+1:end,:);
ModCrit_sc = Model_scaled(1:Crit_N,:);
ModCrit = Crit_std \ ModCrit_sc;
ModPred = Pred_std \ ModPred_sc;
ThetaEstimTLS = -ModPred / ModCrit;
Crit_TLS = Pred * ThetaEstimTLS;
end

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by