Clear Filters
Clear Filters

Store logistic regression models in an array?

3 views (last 30 days)
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!

Accepted Answer

Shashank Prasanna
Shashank Prasanna on 20 Sep 2013
Edited: Shashank Prasanna on 20 Sep 2013
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 Comment
shane
shane on 20 Sep 2013
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.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!