필터 지우기
필터 지우기

OLS regression for multiplr Ys, Xs

조회 수: 3 (최근 30일)
Pap
Pap 2011년 12월 15일
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

채택된 답변

bym
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

추가 답변 (1개)

the cyclist
the cyclist 2011년 12월 15일
The function mvregress() in the Statistics Toolbox will do this.

Community Treasure Hunt

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

Start Hunting!

Translated by