OLS regression for multiplr Ys, Xs
3 views (last 30 days)
Show older comments
Hi all,
I need to regress multiple Ys on Xs and Zs so the model to look like:
Yij = aj+ bj*Xij+ kj*Zij
for i=1...n and j=1....256
Is there any code to do so?
Thanks in advance
Panos
0 Comments
Accepted Answer
bym
on 15 Dec 2011
This example regresses 3 curves 'at once'. I'm sure you can adapt it to your situation
clc;clear;close all
x = sort(rand(20,1)); % independent variable
X = [ones(20,1),x,x.^2]; % vandermonde matrix
y = X*[1 2 3;2 2 3;3 3 5 ]; % dependant variable; arbitrary coefficients
y = y+rand(20,3)*.5; % add noise
coeff = X\y; % get coefficients
yhat = X*coeff; % get predictions
plot(x,yhat);hold on;
plot(x,y,'.') %plot
0 Comments
More Answers (1)
the cyclist
on 15 Dec 2011
The function mvregress() in the Statistics Toolbox will do this.
0 Comments
See Also
Categories
Find more on Linear and Nonlinear Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!