필터 지우기
필터 지우기

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 CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by