0
$\begingroup$

I have a number of fish measurements I want to test, for example Condition, HSI, and GSI. These are to be tested against Parasitism (A factor, 0 being non-parasitized and 1 indicating parasitized). I am hoping to see no effect from parasitism.

I did preliminary T-Tests for four lakes (pooled over three years) comparing Parasitized and Non-Parasitized fish for the three metrics. All but one lake yielded no significant difference in Parasitized and Non Parasitized fish.

Overall I want test this as a model, and since I am seeing differences in one of the lakes, I believe this means I would have to treat Lake as a RANDOM effect, and Parasitism as a FIXED effect. Please correct me if I am wrong.

My question is... how do I test for significance (where I can obtain a P-value) by comparing a linear mixed model and a simple linear model?

Can this be done similarly using likelihood ratios? For example: anova(LMM1, LM1)

All help, suggestions and links are much appreciated...

$\endgroup$
3
  • $\begingroup$ What fixed linear model do you have in mind and why do you think you need it? Do you want to find out whether including the random effect for LAKE is warranted? $\endgroup$
    – vkehayas
    Commented Mar 8, 2018 at 15:02
  • $\begingroup$ Yes, I want to see if there is significant differences between lakes with respect to parasitism. So ultimately I want to test lake as an effect or interaction I believe for one model, and then test my metrics with parasitism with lakes not having an effect. $\endgroup$ Commented Mar 8, 2018 at 18:34
  • $\begingroup$ For example: lm1 <- lm(K ~ Parasites) for my linear model and lmer1 <- lmer(K ~ Parasites + (1|Lake)) for my mixed model $\endgroup$ Commented Mar 8, 2018 at 18:35

1 Answer 1

1
$\begingroup$

You can certainly do it, i.e. you won't get an error:

data("mtcars")
library(lme4)

## Loading required package: Matrix

lme1 = lmer('mpg ~ 1 + hp + (1|vs)', data = mtcars)
summary(lme1)

## Linear mixed model fit by REML ['lmerMod']
## Formula: mpg ~ 1 + hp + (1 | vs)
##    Data: mtcars
## 
## REML criterion at convergence: 181.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.4603 -0.6050 -0.2401  0.4277  2.1212 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  vs       (Intercept)  1.379   1.174   
##  Residual             14.577   3.818   
## Number of obs: 32, groups:  vs, 2
## 
## Fixed effects:
##             Estimate Std. Error t value
## (Intercept) 29.33120    2.03135  14.439
## hp          -0.06254    0.01207  -5.183
## 
## Correlation of Fixed Effects:
##    (Intr)
## hp -0.849

lm2 = lm('mpg ~ 1 + hp', data = mtcars)
summary(lm2)

## 
## Call:
## lm(formula = "mpg ~ 1 + hp", data = mtcars)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.7121 -2.1122 -0.8854  1.5819  8.2360 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 30.09886    1.63392  18.421  < 2e-16 ***
## hp          -0.06823    0.01012  -6.742 1.79e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.863 on 30 degrees of freedom
## Multiple R-squared:  0.6024, Adjusted R-squared:  0.5892 
## F-statistic: 45.46 on 1 and 30 DF,  p-value: 1.788e-07

anova(lme1, lm2)

## refitting model(s) with ML (instead of REML)

## Data: mtcars
## Models:
## lm2: "mpg ~ 1 + hp"
## lme1: mpg ~ 1 + hp + (1 | vs)
##      Df    AIC    BIC  logLik deviance Chisq Chi Df Pr(>Chisq)
## lm2   3 181.24 185.64 -87.619   175.24                        
## lme1  4 183.24 189.10 -87.619   175.24     0      1          1

The AIC that is returned by anova is also commonly used to compare nested models.

However, I would urge you to reconsider why you want to test the effect of the random effect for LAKE in the first place. If the variable was part of your experimental design (as it appears to be the case to me), then some would argue that you must include it in your model no matter the difference its inclusion to the model produces (see Testing the significance of random effects for more discussion). If what you are after is to examine the effect in specific lakes, then perhaps the BLUPs are what you are after:

ranef(lme1, condVar = TRUE)

If instead, you initial question was if some lakes are more conductive for parasitism, then I would advise you to include the variable LAKE as a fixed factor and include an interaction with your other variables.


[...] since I am seeing differences in one of the lakes, I believe this means I would have to treat Lake as a RANDOM effect...

No, this is not a valid reason of why you want to select a variable as a random effect. This issue has been discussed elsewhere, for example: What is the difference between fixed effect, random effect and mixed effect models? In my opinion, you treat a variable as a random effect if you care about its influence but the specific instantiations are not important. In your case, if it is true that you want to include the effect of LAKE in the model but you wouldn't expect a difference whether the specific lakes in your sample were {Tanganyika, Victoria} or {Caspian, Baikal}, then I would include the variable LAKE as a random factor regardless of if it contributed anything to the model based on any test or metric.

$\endgroup$
4
  • 1
    $\begingroup$ +1 but this threads looks a duplicate of stats.stackexchange.com/questions/141746 (which does not have a very good answer btw, so you might want to post one there too). $\endgroup$
    – amoeba
    Commented Mar 9, 2018 at 9:31
  • $\begingroup$ @amoeba This even earlier Q&A appears to be very related to the subject as well. For future reference, the leading answer there suggests to bootstrap the likelihood ratio test statistic. $\endgroup$
    – vkehayas
    Commented Mar 12, 2018 at 11:10
  • $\begingroup$ That one is a bit different because the models are not nested, no? It's comparing random effect to fixed effect, not random effect to an absence of random effect. $\endgroup$
    – amoeba
    Commented Mar 12, 2018 at 11:17
  • $\begingroup$ (But the leading answer is indeed about testing the random effect, so does not really answer that question :-) $\endgroup$
    – amoeba
    Commented Mar 12, 2018 at 11:24

Not the answer you're looking for? Browse other questions tagged or ask your own question.