[R-sig-ME] F and P values for random factors

Mahendra Dia diamahendra at gmail.com
Sat Feb 6 06:04:11 CET 2016


Hi Dan, Tom, Ben and Alex.

Thank you for your response. Earlier I was not aware that my attachments
will not go through via r-sig-mixed-models at r-project.org.

I will apply example that Alex showed in his email.
Just FYI I am copying text from the previous attachment along with original
attachment. At least few of you can see my data and question. I wish I
could have webpage where I could put my question and data.

Once again I thank you for the help and guidance.

#################################################################################################
#################################################################################################

I have a RCBD experiment with 4 factors:

   -  ·         Genotype or cultigen (CLT);
   - ·         Location (LC);
   - ·         Year (YR); and
   - ·         Blocks or Replication (RP) within location and year.

The levels of my treatments/factors are

·         Cultigen = 10;

·         Location = 5

·         Year = 2

·         Rep = 4

The response *Rijkr* of the genotype *i* in the location *j*, year *k* and
block *r *is modelled as:

*Rijkr = m + CLTi + LCj + YRk + RPr (LCj YRk) + CLTi *LCj + CLTi *YRk +
LCj*YRk + CLTi*LCj*YRk + eijkr*

*NOTE: **Dependent or response variable in this example is MKMGHA. *



I want to compute ANOVA (analysis of variable) while considering all the
factors as random factors in R.



Below is the part of R code I used while using glm function to compute
ANOVA. But I don’t know how to get the *F* ratio and *p* values.

*#ANOVA using GLM , all factors are considered as random*



*  #convert numeric predictor variable into factors*

  tempa2a <- tempa2

  tempa2a$YR <- as.factor(tempa2a$YR)

  tempa2a$RP <- as.factor(tempa2a$RP)

*  #Get structure of data *

*  #(character vs. numeric vs. matrix vs. vector vs. factor)*

  str(tempa2a)



tempa3 <- glm(MKMGHA ~ LC + YR + LC:YR + RP %in% (LC:YR) + CLT + CLT:LC +

                CLT:YR + CLT:LC:YR, family = gaussian , data= tempa2a )



anova1 <- anova(tempa3)

*#convert anova into data frame*

anova2 <- as.data.frame(anova1)

*#convert rownames into column*

anova2$sov <- rownames(anova2)

*# drop rownames*

rownames(anova2) <- NULL





After gleaning online literature it looks like I need to use lme function
nlme4 package. But I don’t know how to compute the *F* ratio and *p* values
as I never used this function/package earlier.



#################################################################################################
#################################################################################################
Sincerely,
M-

On Fri, Feb 5, 2016 at 7:16 PM, Philippi, Tom <tom_philippi at nps.gov> wrote:

> A perhaps more comprehensive answer is available in the draft
> r-sig-mixed-models FAQ:
> http://glmm.wikidot.com/faq
>
> Tom 2
>
>
> On Fri, Feb 5, 2016 at 4:05 PM, Alex Fine <abfine at gmail.com> wrote:
>
>> Hi Mahendra,
>>
>> You can assess the significance of both fixed and random factors using
>> likelihood ratio tests.  Say you want to test the significance of
>> predictor
>> A in a model with predictors A and B and random slopes for A.  You can do:
>>
>> full_model = lmer(y ~ A + B)
>> model_without_A = lmer(y ~ B)
>> anova(full_model, model_without_A)
>>
>> The anova() function in this case will return a chi-squared score (df =
>> number of predic) and a p-value.  The same procedure can be used for
>> random
>> effects, e.g.:
>>
>> full_model_2 = lmer(y ~ A + B + (1+A | random_thing)
>> model_without_random_slope_for_A = lmer(y ~ A + B + (1 | random_thing)
>> anova(full_model, model_without_random_slope_for_A)
>>
>> This works because the log-likelihoods of nested models, in the limit,
>> approximate a chi-squared distribution.
>>
>> See:  https://en.wikipedia.org/wiki/Likelihood-ratio_test
>>
>> Or maybe that wasn't what you were asking at all.
>>
>> Also I think you forgot to attach the file.
>>
>> Hope that helps!
>> Alex
>>
>>
>> On Thu, Feb 4, 2016 at 8:32 PM, Mahendra Dia <diamahendra at gmail.com>
>> wrote:
>>
>> > Hi.
>> >
>> > I am reaching you out to learn how to compute F ratio and P values for
>> my
>> > experiment where all the factors are treated as random factors.
>> > Please see the attached file where I explained my treatments and sample
>> > data.
>> >
>> > I thank you in advance.
>> >
>> > Sincerely,
>> > Mahendra-
>> > _______________________________________________
>> > R-sig-mixed-models at r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>> >
>>
>>
>>
>> --
>> Alex Fine
>> Ph. (336) 302-3251
>> web:  abfine.github.io/
>>
>>         [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-mixed-models at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>>
>
>


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