Store logistic regression models in an array?

3 次查看(过去 30 天)
I have a for loop that creates a set of binary logistic regression models using the GeneralizedLinearModel.stepwise() function.
I need to store these models but I receive errors when I try to use an array or a structure to store them.
eg)
Output.Model(Model_Num) = GeneralizedLinearModel.stepwise()
"Error using classreg.regr.FitObject/subsref (line 710) Parentheses indexing is not allowed"
OR:
Model{Model_Num} = GeneralizedLinearModel.stepwise()
"Cell contents assignment to a non-cell array object."
OR:
Model(Model_Num) = GeneralizedLinearModel.stepwise()
"The following error occurred converting from GeneralizedLinearModel to double: Error using double Conversion to double from GeneralizedLinearModel is not possible."
But I don't think it works for logistic regression models varying number of parameters.
Is this perhaps not possible, in which case is my only option to use the count variable in the naming of the different models (I have read this is not advised). Thanks!

采纳的回答

Shashank Prasanna
Shashank Prasanna 2013-9-20
编辑:Shashank Prasanna 2013-9-20
mdl = GeneralizedLinearModel.stepwise(....)
Model{1} = mdl;
Model{2} = mdl;
Storing the models in a cell array works perfectly fine for me. Could you share your code so that we can see what's going wrong?
  1 个评论
shane
shane 2013-9-20
Thank you. The problem was that I was assigning the model directly to the array. I needed to store it to mdl first as you did above.

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by