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