OLS regression for multiplr Ys, Xs
조회 수: 3 (최근 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!