Apologies for the formatting in the initial post. Hello list, I'm analyzing data (variable names in brackets) generated by a 4-period [period], 3-treatment [trt] crossover design. The design was strongly balanced (all treatments preceded all others, including itself) and uniform within period (all treatments occurred the same # of times in each of the 4 periods). This produced 18 distinct sequences of treatments (e.g., ABCC, CAAB, etc.), to which a single individual [id] was randomly assigned. Two covariates [cov1, cov2] were also measured on each individual. The response [y] was continuous, and each individual was associated with a pre-study baseline measure [y0]. Because a single individual was assigned to each sequence, I believe that a random effect for each individual will capture individual, baseline, and sequence effects (they're perfectly confounded). The question is simple: does the response differ among treatments? I'm hoping the correct specification is as simple as I think it is, illustrated below with mock data. My specific questions: 1 - Does this model correctly capture treatment, period, and potential carryover effects? As I understand it, in a strongly balanced design such as this, carryover and treatment effects are not confounded, so my assumption is that I don't have to specify any addition variable to capture this effect (e.g., a variable indicating the treatment in the preceding period). I'm happy to be corrected. 2 - Is an interaction between treatment and period prescribed? Because the design is uniform within periods, I believe that period and treatment effects are likewise not confounded. 3 - Does the random effect for each individual captures variation due to individual, sequence, and baseline measurement? Thanks very much for your assistance, Adam Smith Department of Natural Resources Science University of Rhode Island # Download data datURL <- "https://dl.dropboxusercontent.com/u/23278690/xover_test.csv" dat <- repmis::source_data(datURL, sep = ",", header = TRUE) dat <- within(dat, { ? ? ?id = factor(id) ? ? ?trt = factor(trt) ? ? ?period = factor(period) ? ? ?cov1 = factor(cov1) ? ? ?cov2 = factor(cov2) }) require(lme4) # Proposed linear mixed model analysis mod1 <- lmer(y ~ trt + period + cov1 + cov2 + (1|id), data = dat) # Test global treatment effect, for example... mod2 <- update(mod1, . ~ . - trt) anova(mod1, mod2) sessionInfo() R version 3.0.3 (2014-03-06) Platform: x86_64-w64-mingw32/x64 (64-bit) attached base packages:[1] stats graphics grDevices utils datasets methods base other attached packages:[1] car_2.0-19 AICcmodavg_1.35 lme4_1.1-5 Rcpp_0.11.1 Matrix_1.1-3 plyr_1.8.1
Reformat: Assistance with specification of crossover design model
7 messages · Adam Smith, Ben Bolker, Sunil Mundra +1 more
Adam Smith <raptorbio at ...> writes:
Apologies for the formatting in the initial post. Hello list,
I'm analyzing data (variable names in brackets) generated by a 4-period [period], 3-treatment [trt] crossover design. The design was strongly balanced (all treatments preceded all others, including itself) and uniform within period (all treatments occurred the same # of times in each of the 4 periods).
This produced 18 distinct sequences of treatments (e.g., ABCC, CAAB, etc.), to which a single individual [id] was randomly assigned. Two covariates [cov1, cov2] were also measured on each individual.
The response [y] was continuous, and each individual was associated
with a pre-study baseline measure [y0].
Because a single individual was assigned to each sequence, I believe that a random effect for each individual will capture individual, baseline, and sequence effects (they're perfectly confounded).
The question is simple: does the response differ among treatments? I'm hoping the correct specification is as simple as I think it is, illustrated below with mock data. My specific questions:
Thanks for a very clear question. I'm going to take a stab at these, but haven't thought *very* deeply about them; hopefully this will inspire corrections/alternative answers.
1 - Does this model correctly capture treatment, period, and potential carryover effects? As I understand it, in a strongly balanced design such as this, carryover and treatment effects are not confounded, so my assumption is that I don't have to specify any addition variable to capture this effect (e.g., a variable indicating the treatment in the preceding period). I'm happy to be corrected.
I think you're right that the individual-level random effect controls for pre-treatment and sequence/carryover effects. However, I'm not sure it will capture period or treatment-by-period effects (i.e. residuals within the same period might be correlated, and residuals from individuals who received the treatment in the same period might be correlated). One way to see whether you might have missed something would be to draw (e.g.) boxplots of residuals by whatever groupings you might be concerned about.
2 - Is an interaction between treatment and period prescribed? Because the design is uniform within periods, I believe that period and treatment effects are likewise not confounded.
I think so.
3 - Does the random effect for each individual captures variation due to individual, sequence, and baseline measurement?
I think so.
Thanks very much for your assistance, Adam Smith Department of Natural Resources Science University of Rhode Island # Download data datURL <- "https://dl.dropboxusercontent.com/u/23278690/xover_test.csv" dat <- repmis::source_data(datURL, sep = ",", header = TRUE) dat <- within(dat, { ? ? ?id = factor(id) ? ? ?trt = factor(trt) ? ? ?period = factor(period) ? ? ?cov1 = factor(cov1) ? ? ?cov2 = factor(cov2) }) require(lme4) # Proposed linear mixed model analysis mod1 <- lmer(y ~ trt + period + cov1 + cov2 + (1|id), data = dat)
I think you do want trt*period (possibly as a random effect?) In a setting where I had access to some regularization (e.g. blme) I would be tempted to treat period as random -- but I wouldn't do it in this vanilla model, because there aren't enough periods to estimate it reliably. While you don't _need_ to incorporate pre-treatment covariate, carryover effects, etc., it might be interesting -- I think these would be partitioned out of the among-individual variation ...
# Test global treatment effect, for example... mod2 <- update(mod1, . ~ . - trt) anova(mod1, mod2) sessionInfo() R version 3.0.3 (2014-03-06) Platform: x86_64-w64-mingw32/x64 (64-bit)
attached base packages:[1] stats graphics grDevices utils datasets
methods base
other attached packages:[1] car_2.0-19 AICcmodavg_1.35 lme4_1.1-5 Rcpp_0.11.1 Matrix_1.1-3 plyr_1.8.1
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20140608/85b7a5ee/attachment.pl>
On 14-06-07 04:29 PM, Sunil Mundra wrote:
Hello all, I am new to use LME4 for analysing mixed effect model. I am trying to test impact of Deep-snow treatment, sampling round, and sampling depth on fungal richness. In my experiment: I have two block (C and D), each Block has 3 fence group. I have two treatment one is where snow is deep (causing soil warming) and other in control sample, at each fence. Samples are collected 9 times in summer from two different depth (2cm and 5cm). I hope i am able to explain my experiment well... My first question the the model I am using (see below) here, is OK for this question? Z1 <- lmer(Richness ~ Treatment*Round*Depth + (1|Block/Fence/Treatment/Round), REML= FALSE, data = data) Second when i am running this this argument i am getting following error as mention below. Error in lme4::lFormula(formula = Richness ~ Treatment * Round * Depth + : rank of X = 28 < ncol(X) = 36 I tried to google it, but did not manage to find the solution. I also get similar error (col pivoting) when i was trying CCA analysis for community study with similar predictor and random variables. Help in this regards would be highly appreciated....!!! Regards Sunil
This means that you don't have all 36 combinations of Treatment, Round, and Depth in your experimental design (based on the arithmetic it seems that "Round" is your 9 samples). (You probably only have 28 combinations -- were some treatment/depth combinations missed in some rounds?) If you use a recent version of lme4 you should be able to ask lme4 to drop the aliased/unidentifiable columns -- in fact this should happen automatically. However, you have more problems than this (sorry) * you're probably not going to be able to fit block as a random effect (because there are only two levels) * you shouldn't have the same factor included as both a random and a fixed effect I would suggest (I think) Richness ~ Treatment*Depth + (1|(Block:Fence)/Round) possibly Richness ~ Treatment*Depth + (Treatment*Depth|(Block:Fence)) + (1|Block:Fence:Round) to allow for variation in treatment/depth effects across blocks and block/fence combinations
On Sun, Jun 08, 2014 at 01:59:07AM +0530, Sunil Mundra wrote:
Hello all,I am new to use LME4 for analysing mixed effect model.I am trying to test impact of Deep-snow treatment, sampling round, and sampling depth on fungal richness.In my experiment:I have two block (C and D), each Block has 3 fence group.I have two treatment one is where snow is deep (causing soil warming) and other in control sample, at each fence.Samples are collected 9 times in summer from two different depth (2cm and 5cm).I hope i am able to explain my experiment well... My first question the the model I am using (see below) here, is OK for this question? Z1 <- lmer(Richness ~ Treatment*Round*Depth + (1|Block/Fence/Treatment/Round), REML= FALSE, data = data)
You don't need to specify wether your data is nested or crossed, lme4 will figure out that anyway. If you want random intercepts try: Z1 <- lmer(Richness ~ Treatment*Round*Depth + (1|Block) + (1|Fence) + (1|Treatment) + (1|Round), REML= FALSE, data = data) If you want random slopes, I think you need to explain what you want better.
On Sun, Jun 08, 2014 at 10:08:58PM +0200, Hans Ekbrand wrote:
On Sun, Jun 08, 2014 at 01:59:07AM +0530, Sunil Mundra wrote:
Hello all,I am new to use LME4 for analysing mixed effect model.I am trying to test impact of Deep-snow treatment, sampling round, and sampling depth on fungal richness.In my experiment:I have two block (C and D), each Block has 3 fence group.I have two treatment one is where snow is deep (causing soil warming) and other in control sample, at each fence.Samples are collected 9 times in summer from two different depth (2cm and 5cm).I hope i am able to explain my experiment well... My first question the the model I am using (see below) here, is OK for this question? Z1 <- lmer(Richness ~ Treatment*Round*Depth + (1|Block/Fence/Treatment/Round), REML= FALSE, data = data)
[...]
If you want random slopes, I think you need to explain what you want better.
When reading Ben Bolkers suggestion, I realised that my suggestion was not useful, please forget about it.
On 14-06-08 04:08 PM, Hans Ekbrand wrote:
On Sun, Jun 08, 2014 at 01:59:07AM +0530, Sunil Mundra wrote:
Hello all,I am new to use LME4 for analysing mixed effect model.I am trying to test impact of Deep-snow treatment, sampling round, and sampling depth on fungal richness.In my experiment:I have two block (C and D), each Block has 3 fence group.I have two treatment one is where snow is deep (causing soil warming) and other in control sample, at each fence.Samples are collected 9 times in summer from two different depth (2cm and 5cm).I hope i am able to explain my experiment well... My first question the the model I am using (see below) here, is OK for this question? Z1 <- lmer(Richness ~ Treatment*Round*Depth + (1|Block/Fence/Treatment/Round), REML= FALSE, data = data)
You don't need to specify wether your data is nested or crossed, lme4 will figure out that anyway. If you want random intercepts try: Z1 <- lmer(Richness ~ Treatment*Round*Depth + (1|Block) + (1|Fence) + (1|Treatment) + (1|Round), REML= FALSE, data = data)
Minor correction here: lme4 can *only* figure out whether the grouping variables are nested if they are uniquely labeled (e.g. fences within block are labeled b1f1, b1f2, b1f3, b2f1, b2f2, b2f3, ... rather than f1, f2, f3, f1, f2, f3 ...
If you want random slopes, I think you need to explain what you want better.
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models