Apply quadratic model from regstats to predict unknown values

조회 수: 3 (최근 30일)
Sam Roberson
Sam Roberson 2011년 4월 27일
Here's the setting - you get the quadratic model 'beta' from regstats using:
beta = regstats(Y,[X Z],'purequadtratic','beta');
where Y, X and Z are n by 1 vectors and X and Z are explanatory variables used to predict Y.
I understand how to extract residuals and yhat from regstats. What I want to know is whether there is a function that will allow me to predict values of Y for additional values of X and Z.
I've figured out how to do this manually, but not being particular tuned-in to maths, it took me a while to discover the formula for a quadratic model. Is there a Matlab function for this procedure? What have I missed in the documentation?
Best regards,
Sam
----------------------------- 7.11.0.584 (R2010b) Win 2007 - 64 bit HP xw4600

답변 (2개)

Sam Roberson
Sam Roberson 2011년 11월 8일
Hey Grega,
I'm glad you asked this question, because I now know 2 different solutions. The first solution is the manual solution that I worked out myself, which I won't give here. The second is from a Mathworks workshop I went to, and looks like this:
X = x2fx(predictors,'quadratic');
y = responses;
[Q,R] = qr(X,0);
beta = R\(Q'*y);
yhat = X*beta;
residuals = y - yhat;
where predictors is a p by m vector or row matrix of data and responses is a p by 1 vector. This is all given in the code for regstats. I should have looked there first it seems.
Best,
Sam

grega
grega 2011년 11월 7일
Hey Sam!
I have similar problem with 'interaction' and 'quadratic' models.
Have you figure it out please?
Thank you!

카테고리

Help CenterFile Exchange에서 Resampling Techniques에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by