How to do multiple regression where all dependent and independent variables have uncertainties?

4 views (last 30 days)
I have some data that I would like to run multiple regression on. The important thing here is that I would like the multiple regression to take into account the uncertainties in each of the data points -- something that mvregress doesn't do, as far as I can tell. What's more, each measurement in each of the variables has an uncertainty associated with it. For example, each measurement y(i) in the dependent variable y has its own uncertainty sy(i).
y = [y(1) y(2) ... y(n)]; % measured values of y
sy = [sy(1) sy(2) ... sy(n)] % uncertainties in measured values of y
The same goes for each of the independent variables x, w, z, etc.
x = [x(1) x(2) ... x(n)]
sx = [sx(1) sx(2) ... sx(n)]
When doing a single linear regression analysis, the function york_fit is able to handle data that have uncertainties in both the measured x- and y-values. I'd like to use something analogous to that -- just for multiple regression.
Anybody know how to do that? Is there a variant on mvregress that does that? Are there any canned functions that do that?
-Ken

Answers (1)

TED MOSBY
TED MOSBY on 7 May 2025
Hi,
A convenient implementation for this case can be the File‑Exchange package “Total Least Squares with mixed and/or weighted disturbances” (gtls.m / gmtls.m)
Have a look at the examples in the link above.
It lets you give:
  • A – the predictor matrix [x  w  z  ]
  • b – the response vector y
  • W – a block‑diagonal weight or full covariance matrix built from your per‑point uncertainties
A basic implementation can be as below:
n = numel(y);
A = [x(:) w(:) z(:) ones(n,1)];
b = y(:);
Sig = diag([sx(:); sw(:); sz(:); sy(:)].^2);
beta = gtls(A,b,Sig);
Modify this according to your use-case.
Hope this helps!

Community Treasure Hunt

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

Start Hunting!