How do I use the fitlme to fit a a linear mixed-effects model to my data?

10 vues (au cours des 30 derniers jours)
Jenny
Jenny le 25 Jan 2015
Pretty new to statistics and MATLAB, and having some trouble understanding the proper way to fit a linear-mixed effects model to my data.
The assay is run as follows: experimental animals and control animals are run under a breathing assay. Experimental animals respond to a drug, control animals should not. First baseline measurement (say of respiratory rate) is measured, both under room air (RA) and under high CO2. Then drug is administered, and room air and high CO2 measurements are taken again.
So I have four measurements for each animal: 1) pre-drug RA; 2) pre-drug CO2; 3) post-drug RA; 4) post-drug CO2.
Dataset table consists of:
  • Animal ID number
  • Animal (experimental or control) - 'Exp' or 'Con'
  • Drug administration (pre or post) - 'Pre' or 'Post'
  • Breathing condition ('RA' or 'CO2')
  • Respiration rate
From what I understand, the Animal (exp/con), drug administration (pre/post), and breathing condition (room air/CO2) are the "fixed" conditions while the animal ID is a random condition (i.e. each animal starts with different baselines). Although it's also possible that the breathing condition is a random condition because the animal will breath faster under CO2 condition (different rates). Rate is the response variable.
Here's the code I have right now:
Table = readtable('data.xlsx');
which yields a dataset that looks something like:
MUID Animal CNO Condition Rate
'M7476' Exp Pre RA 178.19
'M7698' Exp Pre RA 161.93
'M7474' Exp Pre RA 182.42
'M7404' Exp Pre RA 178.48
'M7409' Exp Pre RA 231.95
then the remainder of code:
ds = table2dataset(Table);
ds.Animal = nominal(ds.Animal);
ds.CNO = nominal(ds.CNO);
ds.Condition = nominal(ds.Condition);
lme = fitlme(ds, 'Rate - Animal * CNO * Condition + (1|MUID)')
When I run my code I get this error:
Error using classreg.regr.LinearMixedFormula/processFormula (line 267)
The formula string must include both a response and a linear predictor.
Error in classreg.regr.LinearMixedFormula (line 184)
f = processFormula(f,varNames);
Error in LinearMixedModel.fit (line 4103)
model.Formula =
classreg.regr.LinearMixedFormula(formula,ds.Properties.VarNames);
Error in fitlme (line 224)
lme = LinearMixedModel.fit(ds,formula,varargin{:});
But I'm not sure what's wrong with my formula or even if it's correct for the data. Ultimately I'm interested in figuring out if the drug has an effect in experimental animals in either room air or high CO2 breathing conditions.
Thanks! Help much appreciated.

Réponses (2)

Gautam Pendse
Gautam Pendse le 8 Fév 2015
Hi Jenny,
Your formula 'Rate - Animal * CNO * Condition + (1|MUID)' appears to contain a minus sign after Rate. The syntax requires a tilde (~) after the response variable. So try 'Rate ~ Animal * CNO * Condition + (1|MUID)'.
Hope this helps,
Gautam

Luís Lamas
Luís Lamas le 9 Nov 2018
Hi Jenny,
I know it has been a while since you posted this question. but did you ever get an answer?
I am having the same is with a similar dataset so I would love to know how you overcame this.
Thanks
Luis

Catégories

En savoir plus sur Fit Postprocessing 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!

Translated by