Predict response given new input data | GLME
2 views (last 30 days)
Show older comments
I am trying to fit a model between a dependent variable (Y) and two predictor variables (X, Z) using GLME.
First I divided the data into training (80%) and validation (20%). I've fitted a GLME model to the training data:
X = Xtr % Validation portion of data (442x1);
Z = Ztr % Validation portion of data (442x1);
Y = Ytr % Validation portion of data (442x1);
trTable = table(Y,X,Z);
mdl_glme = fitglme(trTable,'Y ~ X + (1 | Z) + (-1 + X | Z)')'
Now I want to test this model on new (validation) data. This is where I run into problems. If I try:
X = Xval % Validation portion of data (110x1);
Z = Zval % Validation portion of data (110x1);
Y = Yval % Validation portion of data (110x1);
valTable = table(Y,X,Z);
ypred = predict(mdl_glme,valTable)
I get the following error:
Error using categorical (line 434)
Unable to create default category names. Specify category names using the CATEGORYNAMES
input argument.
Error in nominal (line 152)
b = b@categorical(a,args{:},'Ordinal',false);
Error in classreg.regr.LinearLikeMixedModel/makeInteractionVar (line 806)
G = nominal(ds.(interactionVars{1}));
Error in classreg.regr.LinearLikeMixedModel/extractGroupingInfo (line 205)
model.makeInteractionVar(ds,interactionVars);
Error in GeneralizedLinearMixedModel/predict (line 539)
ginfo = extractGroupingInfo(model,ds);
Though if I inspect trTable and valTable the only difference I can see is the number of rows:
442×3 table (trTable)
Y X Z
_________ _________ ________
1.2107 1.2011 0.098847
110×3 table (valTable)
Y X Z
_________ _________ ______
1.6064 1.6024 1.6024
I would be very grateful for any feedback and/or advice.
Regards J
2 Comments
the cyclist
on 11 Oct 2018
Can you upload your dataset, or a minimal subset that exhibits the problem?
(Sometimes trying to find the minimal subset that causes the problem will actually help identify the cause.)
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!