[R-sig-ME] R Query - MANOVA with random effects

Karthikeyan Chandrasegaran karthikeyanc at ncbs.res.in
Wed Jan 20 14:45:19 CET 2016


Dear Prof.Bolker,

Greetings. I am Karthikeyan C, a graduate student in evolutionary ecology
at the National Centre for Biological Sciences (NCBS), Bangalore, India. I
would like to seek your assistance in performing a MANOVA with random
effects incorporated in the model in R.

A sample data set and R code is copied below. It includes 3 dependent
variables (res1, res2, res3) and 3 independent variables (density, nut,
tment). I want a random effect ('rep' nested within 'block') included in
the model. Based on some of your tutorials available online, I tried using
'lmer' to run the model but could not take it forward.

It will be really helpful if you can assist me in taking this analysis
forward.

Thank you so much for your time.

Yours sincerely,
Karthikeyan Chandrasegaran

*Data set*

block density nut tment rep res1 res2 res3
1 high 10 control 1 0.051 0.07 0.096
1 high 10 control 2 0.08 0.134 0.182
1 high 10 control 3 0.075 0.329 0.417
1 high 10 tment 1 0.332 0.046 0.055
1 high 10 tment 2 0.043 0.078 0.107
1 high 10 tment 3 0.164 0.162 0.22
1 high 15 control 1 0.109 0.1 0.142
1 high 15 control 2 0.068 0.087 0.108
1 high 15 control 3 0.067 0.133 0.175
1 high 15 tment 1 0.108 0.238 0.342
1 high 15 tment 2 0.088 0.09 0.124
1 high 15 tment 3 0.056 0.131 0.172
1 low 10 control 1 0.096 0.154 0.195
1 low 10 control 2 0.024 0.092 0.122
1 low 10 control 3 0.172 0.192 0.259
1 low 10 tment 1 0.069 0.079 0.106
1 low 10 tment 2 0.065 0.15 0.192
1 low 10 tment 3 0.13 0.189 0.266
1 low 15 control 1 0.065 0.088 0.118
1 low 15 control 2 0.06 0.099 0.139
1 low 15 control 3 0.056 0.045 0.063
1 low 15 tment 1 0.08 0.052 0.071
1 low 15 tment 2 0.091 0.138 0.179
1 low 15 tment 3 0.047 0.062 0.08
2 high 10 control 1 0.031 0.132 0.168
2 high 10 control 2 0.061 0.162 0.211
2 high 10 control 3 0.12 0.041 0.067
2 high 10 tment 1 0.053 0.063 0.087
2 high 10 tment 2 0.053 0.083 0.107
2 high 10 tment 3 0.086 0.229 0.33
2 high 15 control 1 0.144 0.179 0.238
2 high 15 control 2 0.043 0.073 0.095
2 high 15 control 3 0.1 0.111 0.15
2 high 15 tment 1 0.097 0.139 0.177
2 high 15 tment 2 0.013 0.121 0.165
2 high 15 tment 3 0.047 0.119 0.16
2 low 10 control 1 0.103 0.208 0.282
2 low 10 control 2 0.036 0.168 0.234
2 low 10 control 3 0.072 0.073 0.101
2 low 10 tment 1 0.126 0.129 0.167
2 low 10 tment 2 0.071 0.153 0.2
2 low 10 tment 3 0.026 0.085 0.112
2 low 15 control 1 0.043 0.128 0.133
2 low 15 control 2 0.044 0.072 0.102
2 low 15 control 3 0.064 0.085 0.109
2 low 15 tment 1 0.113 0.3 0.414
2 low 15 tment 2 0.041 0.06 0.07
2 low 15 tment 3 0.126 0.129 0.167

#--------------------------------------------------------------------

*R Code*

> dat <- read.csv(file="sample.data.csv", na.strings=c("NA",""))
>
> #transforming datatype of entries in the dataset
> dat$nut <- factor(dat$nut)
> dat$block <- factor(dat$block)
> dat$rep <- factor(dat$rep)
>
>
> library(lme4)
>
> mod1 <- lmer(cbind(res1,res2,res3) ~ tment*density*nut+ (1|rep)+
(1|block), data=dat)
Error in v/v.e : non-conformable arrays
>
> mod2 <- lmer(cbind(res1,res2,res3) ~ tment*density*nut + (1|block/rep),
data=dat)
Error: updateMu: Size mismatch

	[[alternative HTML version deleted]]



More information about the R-sig-mixed-models mailing list