Error using fitrm function classreg.regr.FormulaProcessor>parseStr
Show older comments
I have a dataset with 20 individuals (SubjectID 1-20). These individuals were separated in three groups (n=6, n=6, and n=8) and each group was testet(measured) at a specific time point (T1, T5, T10). Each measurement consisted of 4 consecutive time points (Minute 0, 5, 15, 60, time after exposure). So I have a total of 20 subject with 4 individual measurements and divided into three groups. Using fitrm I want to fit a repeated measurement model with my readout parameter x to look at interaction of T1,T2,T3 with time after exposure. I defined the modelspec as:
modelspec = 'X ~ Timepoint * TimeafterExp + (1|SubjectID)';
Data is a 80x4 table with the variables SubjectID, Timepoint, TimeafterExp, X.
When I run the following code:
rm=fitrm(data, modelspec);
I get the following error:
Error using classreg.regr.FormulaProcessor>parseStr
Unable to understand the character vector or string scalar 'X ~ Timepoint * TimeafterExp + (1|SubjectID)'.
Error in classreg.regr.FormulaProcessor (line 374)
[f.str,f.tree] = parseStr(f,modelSpec);
Error in classreg.regr.MultivariateLinearFormula (line 46)
f = f@classreg.regr.FormulaProcessor(varargin{:});
Error in RepeatedMeasuresModel.fit (line 1314)
formula = classreg.regr.MultivariateLinearFormula(model,varNames);
Error in fitrm (line 77)
s = RepeatedMeasuresModel.fit(ds,model,varargin{:});
Error in untitled2 (line 25)
rm=fitrm(data, modelspec);
I appreciate your help!
2 Comments
the cyclist
on 31 Jan 2024
Can you upload the data? You can use the paper clip icon in the INSERT section of the toolbar.
David Obert
on 31 Jan 2024
Accepted Answer
More Answers (1)
Harald
on 31 Jan 2024
Hi,
I am not an expert here but will give it a try.
In the "More About" section of the documentation of fitrm, there is a section on Wilkinson Notation and it does not go into the use of |. Thus I suppose it is not supported for this type of model.
https://www.mathworks.com/help/stats/wilkinson-notation.html states that the | syntax is supported by random-effects and mixed-effects models. For example, fitlme is such a model and thus in its documentation refers to the | syntax. Also, the following works:
mdl=fitlme(data, modelspec);
Does this provide you the intended type of model?
Best wishes,
Harald
Categories
Find more on Repeated Measures and MANOVA in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!