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 Center および File ExchangeDimensionality 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