LinearModel.stepwise Matlab R2011a

3 次查看(过去 30 天)
Hi there
I am trying to perform a stepwise regression. The code i tired is the following :
mdl = LinearModel.stepwise(X,y,modelspec,'VarNames', {labx1,labx2,labx3,labx4,laby});
and i got te following error message :
??? Undefined variable "LinearModel" or class
"LinearModel.stepwise".
it is weird because i used the exact same code as the one described here :
I am afraid this is because i have an older release of Matlab. I use R2011a with Statistics Toolbox 7.5. I have been trying to read the "documentation for older releases" but the website would accept neither my License number nor my activation key so i can't access the documentation. This is a student license.
What can I do ? Thank you very much Laurie

采纳的回答

the cyclist
the cyclist 2012-4-4
You are correct to guess that the problem is that you have an older release. However, you still have some options in R2011a. There are two functions for stepwise regression: stepwise() and stepwisefit(). One of them uses an interactive UI, and the other does not.

更多回答(1 个)

laurie
laurie 2012-4-4
Hi cyclist :)
Thank you ! that is exactly what i was looking for. Do you know if stepwisefit() automatically includes interactions ? or do i have to add those regressors manually ? apparently yes but this seems surprising ?
  2 个评论
the cyclist
the cyclist 2012-4-4
I would check "doc stepwisefit" to be 100% certain, but I'm pretty sure you have to add interactions terms separately.
For future reference, your "answer" here would have been better placed as a comment on my answer. Also, please consider accepting my answer, which might help future users with a similar question.
laurie
laurie 2012-4-4
okay thank you :)
ps : i found that X=x2xf(X,'interaction') allows one to add the interactions in X so you don't have to construct them manually. you also have to delete the "constant" column that x2xf adds as the first column of X and that stepwisefit() doesn't need.

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by