fitlme "Index exceeds matrix dimensions."
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Bruno Bianchi
le 19 Nov 2015
Commenté : Bruno Bianchi
le 20 Nov 2015
Hi, I'm trying to use the new fitlme bult-in function (R2015a) and it keeps going on an error:
Index exceeds matrix dimensions.
Error in classreg.regr.LinearLikeMixedModel.makeSparseZ (line 1312)
idxr = accumarray(subs,vals(I),[],@(x) {x});
Error in LinearMixedModel/fitStandardLMEModel (line 1225)
Zs = LinearMixedModel.makeSparseZ(Z,q,lev,Gid,N);
Error in LinearMixedModel/fitter (line 822)
model.slme = fitStandardLMEModel(model);
Error in classreg.regr.FitObject/doFit (line 220)
model = fitter(model);
Error in LinearMixedModel.fit (line 2395)
model = doFit(model);
Error in fitlme (line 224)
lme = LinearMixedModel.fit(ds,formula,varargin{:});
Also, running the fnuction takes too long (the error appears after several minutes of wating) and consume a lot of RAM. This is the line I'm running:
lmm1 = fitlme(datos_tabla, 'E1_T1 ~ pred + (1|SUJ)' );
0 commentaires
Réponse acceptée
Gautam Pendse
le 19 Nov 2015
Hi Bruno,
This doesn't look like the intended behavior but it is difficult to say why you are getting that error. Could you post your data that reproduces the problem?
Gautam
3 commentaires
Gautam Pendse
le 20 Nov 2015
Hi Bruno,
Your table is of size 1-by-3 with 3 predictors. Each variable in the table is of size 1-by-N:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/180060/image.png)
The error message can be improved but fitlme expects your table to be of size N-by-3 where each row represents 1 observation. In the code below, I modify your table by transposing variables and then fit the model:
%%Display the original table
test = load('tabla_export.mat');
tabla_export = test.tabla_export;
size(tabla_export)
tabla_export
% Variables in your table are of size 1-by-N. The expectation is that your
% table will have N rows and each row would represent one observation. You
% can do this by just transposing the variables in your table as shown
% below.
%%Transpose 1-by-N variables into N-by-1 variables
E1_T1 = tabla_export.E1_T1;
pred = tabla_export.pred;
SUJ = tabla_export.SUJ;
E1_T1 = E1_T1';
pred = pred';
SUJ = SUJ';
newtbl = table();
newtbl.E1_T1 = E1_T1;
newtbl.pred = pred;
newtbl.SUJ = SUJ;
%%Fit the model
rng(0,'twister')
lme = fitlme(newtbl,'E1_T1 ~ pred + (1|SUJ)','verbose',1,'startmethod','random')
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Dimensionality Reduction and Feature Extraction dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!