fitlme "Index exceeds matrix dimensions."

조회 수: 2 (최근 30일)
Bruno Bianchi
Bruno Bianchi 2015년 11월 19일
댓글: Bruno Bianchi 2015년 11월 20일
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)' );

채택된 답변

Gautam Pendse
Gautam Pendse 2015년 11월 19일
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
Gautam Pendse
Gautam Pendse 2015년 11월 20일
Hi Bruno,
Your table is of size 1-by-3 with 3 predictors. Each variable in the table is of size 1-by-N:
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')
Bruno Bianchi
Bruno Bianchi 2015년 11월 20일
That really works! Thank you very much, and I hope the problem to be solve in the future!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dimensionality Reduction and Feature Extraction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by