2
$\begingroup$
  1. Am I correct in understanding that the effects of flood.level and plant.species are significant predictors of Inv.Simpson (my measure of diversity)?
  2. Is it also correct to say that the effect of different survey years on diversity is not important, as despite significance in the GLM, the F statistic for year is not significant? My data was obtained in the same place over 4 years, so would this lack of significance be reflective of the fact I'm surveying the same population?

Please note that year is categoric data and the others are numerical. I assume the years are being compared to 2015, as this has not been included in the output.

Sample of my code:

    model <- glm(Inv.Simpson ~ Year + Flood.level + Plant.species + Cloud.cover + Temperature + Humidity, data = glm_data)

    summary(model)

    anova(model, test="F")

The Results:

Coefficients:
                Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.195763   0.190682   6.271 3.17e-09 ***
Year.2016       0.465883   0.154722   3.011 0.003023 ** 
Year.2017       0.558740   0.153930   3.630 0.000381 ***
Year.2018       0.530750   0.164418   3.228 0.001510 ** 
Flood.level     0.207919   0.026946   7.716 1.19e-12 ***
Plant.species   0.095005   0.034442   2.758 0.006480 ** 
Cloud.cover    -0.001114   0.001197  -0.931 0.353234    
Temperature    -0.005615   0.028958  -0.194 0.846488    
Humidity       -0.009183   0.005453  -1.684 0.094102 .  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for gaussian family taken to be 0.3408132)

    Null deviance: 81.790  on 169  degrees of freedom
Residual deviance: 54.871  on 161  degrees of freedom
  (23 observations deleted due to missingness)
AIC: 310.2

Number of Fisher Scoring iterations: 2

> 
Analysis of Deviance Table

Model: gaussian, link: identity

Response: Inv.Simpson

Terms added sequentially (first to last)


               Df Deviance Resid. Df Resid. Dev       F    Pr(>F)    
NULL                             169     81.790                      
Year            3   0.7427       166     81.047  0.7264  0.537656    
Flood.level     1  22.3051       165     58.742 65.4468 1.367e-13 ***
Plant.species   1   2.3712       164     56.371  6.9574  0.009166 ** 
Cloud.cover     1   0.4186       163     55.952  1.2281  0.269421    
Temperature     1   0.1146       162     55.838  0.3362  0.562867    
Humidity        1   0.9666       161     54.871  2.8362  0.094102 .  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
$\endgroup$
2
  • $\begingroup$ Why did you tag this lme4-nlme and refer to lme4 in the title? You don't appear to use the package. In fact, you appear to be doing simple linear OLS regression. $\endgroup$
    – Roland
    Commented Mar 18, 2019 at 15:45
  • $\begingroup$ I've only been learning R for a few days, and was incorrectly told that I needed the lme4 package to use the "glm" function. Following your comment I have removed lme4 from the tag and title and researched the difference between lmer and glm functions. $\endgroup$ Commented Mar 18, 2019 at 17:19

2 Answers 2

4
$\begingroup$

Regarding 1. Yes, that is correct.

Regarding 2. No. First "important" and "significant" are not the same. Second, in the ANOVA it is adding terms sequentially. Thus, year is not significant by itself. But, from the main output, year clearly is sig. after adding the other variables. From those results, it looks like the three years after 2015 were all higher than 2015, but not much different from each other. This may also be part of the reason why the year effect in the ANOVA was not sig - that is looking at year as a whole, not specific years.

$\endgroup$
0
$\begingroup$

First, what you did was a linear regression. You can certainly use glm for linear regression but you don't have to. Function lm can do what you want as well.

The ANOVA you did is a sequential partition of the sum of square. It is also often referred to as type I sum of square. If you data is not balanced, the hypothesis being tested by a type I sum of square is weighted mean by sample size is equal across categories. If you want to test if the response variable is the same in three years, you should use a type III sum of square. In R, this can be implemented using function "Anova" in package car by specifying type=3. One thing to note when using Anova for type III sum of square is that you need to specify the contrast as the sum of zero constrains. R by default uses one level as the reference. To change the default contrast, you can use options(contrasts=c("contr.sum","contribution.poly")). You can also use the contrasts argument inside lm or glm to change the contrast coding for any particular factor.

If your data is balanced, using type I or III sum of square does not matter. It will give you the same results.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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