1
$\begingroup$

I am new to this website, to r, and to mixed effect models so apologise in advance if I exhibit a degree of ignorance.

I am looking for help of how to fit a model for an experiment that I have done. I am familiar (to an extent) with the lme4 package. So I'd like to use the lmer().

My experimental design: 3 animals were treated in a pilot with a single drug at 4 different doses. Each dose was a treatment block in which the animals were dosed once daily for 5 days. At day zero (the day before dosing started) I collected the baseline data of the response variables in the block. Then, the response variables were collected every 24 hours. Each treatment block was separated by a washout period. The animals were not randomised to treatment; in other words, they all got the first dose in block 1, the second dose in block 2, the third dose in block 3 and the fourth dose in block 4.

I tried the following: model <- lmer(response variable + dose + (day|dose) + (1|animal), data= mydata, REML=FALSE) but I get all kinds of errors.

how should I write the code?

Animal  dose    day RV1 RV2 RV3
1   5   0   5117    447.02  315
1   5   1   5102    397.72  314
1   5   2   5132    443.56  315
1   5   3   5082    442.84  306
1   5   4   5030    408.34  409
2   5   0   4011    364.86  263
2   5   1   4108    248.78  188
2   5   2   4005    333.34  270
2   5   3   3936    369.04  318
2   5   4   3985    355.02  291
3   5   0   3495    411.76  312
3   5   1   3563    599.96  360
3   5   2   3589    260.76  353
3   5   3   3471    412.04  349
3   5   4   3396    413.36  321
1   10  0   5050            311
1   10  1   5050    413.84  292
1   10  2   5078    349.96  249
1   10  3   5115    340.14  266
1   10  4   4996    289.62  227
1   10  5   4972    289.86  167
2   10  0   4120    319.06  291
2   10  1   4170    367.98  276
2   10  2   3927    289.76  253
2   10  3   4015    353.48  224
2   10  4   4060    362.86  295
2   10  5   4070    319.1   271
3   10  0   3702    425.31  293
3   10  1   3705    431.92  193
3   10  2   3638    427.18  269
3   10  3   3630    412.54  271
3   10  4   3651    440.7   304
3   10  5   3563    301.58  269
1   15  0   5316    413.5   313
1   15  1   5302    427.22  359
1   15  2   5191    365.18  271
1   15  3   5214    405.7   347
1   15  4   5101    413.58  340
1   15  5   5087    442.96  308
2   15  0   4259    313.17  295
2   15  1   4280    429.96  352
2   15  2   4124    335.08  285
2   15  3   4069    358.7   295
2   15  4   4049    292.02  264
2   15  5   4064    389.36  287
3   15  0   3850    440.23  340
3   15  1   3872    533.88  302
3   15  2   3736    419.38  341
3   15  3   3789    332.6   300
3   15  4   3676    284.7   299
3   15  5   3630    465.24  370
1   20  0   5284    435.54  362
1   20  1   5127    436.96  307
1   20  2   5112    413.62  297
1   20  3   5085    378.22  319
1   20  4   5117    376.2   159
2   20  0   4296    372.04  308
2   20  1   4228    338.64  266
2   20  2   4149    111.32  183
2   20  3   4062    859.8   291
2   20  4   4125    200.16  299
3   20  0   3932    498.8   
3   20  1   3670    423.18  294
3   20  2   3694    360.56  239
3   20  3   3629    474.64  313
3   20  4   3722    460.94  349
$\endgroup$
  • $\begingroup$ I will try one more time and if it is not clear I will post it as a new question. Again, I apologise for not knowing all the rules of how this work... the 'control' in the first block for each of the animals is dose 5 day 0. For block to for all animals it is dose 10 day 0. For the third block it is dose 15 day 0 and for the fourth it is dose 20 day 0. These control I would like to compare with their respective doses for all other days (which is when they were actually under the pharmacologic effect of the drug). Thanks! $\endgroup$ – user180605 Oct 12 '17 at 7:09
  • $\begingroup$ It is not becoming clearer to me now that you have presented the data: Is RV response variable? If so, why didn't you mention you have three outcomes? The way I interpret your data is that each animal received each treatment every day, with three outcomes. This is not what your question suggests. $\endgroup$ – Frans Rodenburg Oct 12 '17 at 7:17
  • $\begingroup$ The outcomes are independent RVs (response variables) that I would like to model independently of each other (in three seperate models). day and dose are not the same because day 0 in each treatment (dose) block is the baseline for each of the RVs. $\endgroup$ – user180605 Oct 12 '17 at 7:26
1
$\begingroup$

Always Randomize
I hope that washout period is long enough! Even with a washout period, the interpretation of the results will be tricky without randomization. As all animals receive the same treatments on a given day, what is to say that the observed effect is not somehow influenced by other unknown factors of that day (e.g. maybe it was sunnier outside, the temperature was slightly different or the amount of food on that day differed slightly from the others).

Worst case scenario, since this is a pilot study, it will cause you to study a sub-optimal dose of the drug. The implications are more severe if this 'treatment' can somehow negatively affect the animal's well-being.

Contructing the Model
If I understand your question correctly, dose is a fixed effect and is the same as the effect of day, for the reason stated above. This mean you can only model one.

You have to choose whether you think the three animals have a different starting value for the response variable, or a whether they respond differently to the treatment.

  • The former can be modeled as a random intercept:
    model <- lmer(response variable ~ dose + (1|animal))
  • The latter as a random slope:
    model <- lmer(response variable ~ dose + (0 + dose|animal))

It is technically also possible to model both, if you have a theoretical justification for that, I think you don't have enough samples in your pilot study to model that. To model both, just remove the 0 + (which means no intercept) from the latter option.

Comparison with Control
I assume the baseline measurement in each period you refer to is a control group. If you want to make comparisons with this control group, make sure the factor dose has the control as the first level (try: levels(mydata$dose).

If it is not, you can change the order with the R function relevel(mydata$dose, "control") (assuming the name is indeed 'control'). The control will then be in the intercept and all fixed effect coefficients will be differences from this control group.

Errors
As stated above, you probably got an error for including two identical effects (dose, day).

I tried the following: model <- lmer(response variable + dose + (day|dose) + (1|animal), data= mydata, REML=FALSE) but I get all kinds of errors.

Another error will probably come from using a plus sign (+) rather than a tilde (~) (see my proposed model specification).

Finally, you will likely receive a warning for setting REML to FALSE and including two random effect: (day|dose) and (1|animal) (note that this is not correctly specified anyway). See also this question about REML in lme4. I can't tell exactly what other kinds of errors you refer to without a minimal working example.

$\endgroup$
  • $\begingroup$ There is an edit button under your original post so you can add your data. The comments are not meant for this. $\endgroup$ – Frans Rodenburg Oct 12 '17 at 6:46
  • $\begingroup$ I apologise but I can't seem to find the way to get to my original post to look for the edit button... $\endgroup$ – user180605 Oct 12 '17 at 6:49
  • $\begingroup$ It is on the left under your question. I updated my answer to what I think you mean. $\endgroup$ – Frans Rodenburg Oct 12 '17 at 6:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.