[R-sig-eco] how to perform 5 level nested anova

Kingsford Jones kingsfordjones at gmail.com
Wed Feb 11 03:27:47 CET 2009


Hi Mao,

Note there's also the r-sig-mixed-models list, which focuses on
lme4-related questions.

Also, although I'm a big fan of lmer, for models with nested random
terms the tools in the nlme package have certain advantages (e.g.
maturity, many helper functions, and excellent documentation in the
form of Pinheiro and Bates
(2000))

You could do something like:

library(nlme)
f1 <- lme(SeedL~1, data=seed, random=~1|SpecN/PopN/TreeN, na.action=na.omit)


best,

Kingsford Jones


On Tue, Feb 10, 2009 at 6:52 PM, Christian Parker <cparker at pdx.edu> wrote:
> You just need to make sure that your factors are read as factors and not
> numbers. The easiest way to do that is to specify the column types right
> when you read in your data
> Try this:
>
> seedL<-read.delim("SeedL.txt.txt",colClasses=c("factor","factor","factor","factor","numeric","numeric"))
> cmod<-lmer(SeedL~1+(1|SpecN)+(1|SpecN:PopN)+(1|SpecN:PopN:TreeN),data=seedL)
>
>
>
> Mao Jianfeng wrote:
>> Hello.
>>
>> I am new to R. And, I want to perform a multiple nested anova on a large
>> datasets (with 9448 observations).
>>
>> I tried the function ("lmer()" in package "lme4"). But, I failed. Can anyone
>> help me?
>>
>> my dataset("SeedL.txt") was attached. Data are not sorted by factors. This
>> data are unequal sample sizes.
>>
>> In this dataset, "SpecN" "PopN"  "TreeN" "ConeN" "SeedN" were 5 factors (as
>> Explanatory), with "PopN" nested within "SpecN"; "TreeN" nested within
>> "PopN"; "ConeN" nested within "TreeN" and "SeedN" nested within "ConeN".
>>
>> "SeedL" is a dependent variate (as Response).
>>
>> The model I have ever used in R is:
>>
>> cmod<-lmer(SeedL~1+(1|SpecN)+(1|SpecN:PopN)+(1|SpecN:PopN:TreeN),
>> data=seedL)
>>
>> What I got in R is:
>>
>> error: length(f1) == length(f2) is not TRUE
>> In addition: Warning messages:
>> 1: In SpecN:PopN : 数值表达式一共有9447元素: 只用了第一个 (In Enlish: there are 9447
>> elements in the expression, but only the first one has been used.)
>> 2: In SpecN:PopN : 数值表达式一共有9447元素: 只用了第一个
>> 3: In SpecN:PopN : 数值表达式一共有9447元素: 只用了第一个
>> 4: In SpecN:PopN : 数值表达式一共有9447元素: 只用了第一个
>> 5: In SpecN:PopN:TreeN : 数值表达式一共有6元素: 只用了第一个
>> 6: In SpecN:PopN:TreeN : 数值表达式一共有9447元素: 只用了第一个
>>
>> I an longing for helps in R usage or statistical technology.
>>
>> Thanks a lot in advance.
>>
>> Mao J-F
>> State Key Lab of Systematics and Evolutionary Botany
>> Institute of Botany
>> Chinese Academy of Sciences
>> Beijing, China
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> R-sig-ecology mailing list
>> R-sig-ecology at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>



More information about the R-sig-ecology mailing list