OLS regression for multiplr Ys, Xs
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
bym
2011-12-15
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 个评论
更多回答(1 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!