LinearModel custom class questions
조회 수: 1 (최근 30일)
이전 댓글 표시
I've been having issues with the LinearModel class. I want to create many different linear models on various subsets of predictors and observations. I would like to store all these models but don't want to have to re-store all of the observations used for each model (there are thousands of predictors for every observation).
If I have some data and create a model
ds = dataset({rand(5,1),'predictor'},{rand(5,1),'response'});
mdl = LinearModel.fit(ds);
I would like to be able to say
mdl.Variables = [];
but I get
Error using classreg.regr.FitObject/subsasgn (line 745)
The Variables property for class LinearModel is read-only.
It was suggested that I create my own class that inherits from LinearModel so I can change the permissions and store the model object sans variable info.
classdef customLinearModelClass< LinearModel
properties
end
methods
function clm= customLinearModelClass(linModel)
clm= clm@LinearModel;
end
end
end
but I get,
Error using customLinearModelClass
Class 'LinearModel' is Sealed and may not be used as a superclass.
And I could just copy all of the LinearModel code and create a new class that has the properties that I want but I would like to recreate a real LinearModel class if I want to. best case scenario I could do this.
customModel = magicFunction1(mdl);
mdl2 = magicFunction2(customModel);
where cutomModel does not contain all the Variable information and mdl and mdl2 are the same.
Any suggestions?
댓글 수: 0
답변 (1개)
Leah
2013년 9월 26일
I think in order for you to have all the functionality of the class you need to keep the variable information. Can you just copy out the information you need from the class to a new structure? Like sometimes I'll just take out the coeff, Adjusted Rsq and pvals and ditch the md class
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Model Building and Assessment에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!