[R-sig-ME] How do I know if the lmer model is right?
Flávio M
flaviomoc at gmail.com
Fri Sep 15 00:45:34 CEST 2017
Dear Members,
Could you check if this analysis is right (compile attached)? I am not
familiarized with temporal variables. I am intent to find the equation to
calculate litter amount throught any value of ndvi. Both variables were
coleted monthly during three years.
I did not find a specific model for time series with two variables.
However, as they were collected every month in the same spots lmer should
works fine, right?
Best regards,
Flavio
-------------- next part --------------
library(readxl)
library(afex)
## Loading required package: lme4
## Loading required package: Matrix
## Loading required package: lsmeans
## Loading required package: estimability
## ************
## Welcome to afex. For support visit: http://afex.singmann.science/
## - Functions for ANOVAs: aov_car(), aov_ez(), and aov_4()
## - Methods for calculating p-values with mixed(): 'KR', 'S', 'LRT', and 'PB'
## - 'afex_aov' and 'mixed' objects can be passed to lsmeans() for follow-up tests
## - Get and set global package options with: afex_options()
## - Set orthogonal sum-to-zero contrasts globally: set_sum_contrasts()
## - For example analyses see: browseVignettes("afex")
## ************
##
## Attaching package: 'afex'
## The following object is masked from 'package:lme4':
##
## lmer
data<-read_excel("ndvi3.xls")
data
## # A tibble: 432 x 6
## month year stage plot ndvi litter
## <dbl> <dbl> <chr> <dbl> <dbl> <dbl>
## 1 4 1 Early 1 0.30864501 -2.45986132
## 2 5 1 Early 1 0.17898780 -3.22690800
## 3 6 1 Early 1 0.00871899 0.07673787
## 4 7 1 Early 1 -0.20991200 -1.25453724
## 5 8 1 Early 1 -0.21325549 -2.76453008
## 6 9 1 Early 1 -0.21593250 -4.44981737
## 7 10 1 Early 1 -0.30416150 -4.19808639
## 8 11 1 Early 1 -0.10118885 -5.47412419
## 9 12 1 Early 1 0.22365620 -3.27540914
## 10 1 1 Early 1 0.31648629 -2.02710415
## # ... with 422 more rows
summary(data)
## month year stage plot
## Min. : 1.00 Min. :1 Length:432 Min. :1.00
## 1st Qu.: 3.75 1st Qu.:1 Class :character 1st Qu.:1.75
## Median : 6.50 Median :2 Mode :character Median :2.50
## Mean : 6.50 Mean :2 Mean :2.50
## 3rd Qu.: 9.25 3rd Qu.:3 3rd Qu.:3.25
## Max. :12.00 Max. :3 Max. :4.00
## ndvi litter
## Min. :-0.30416 Min. :-5.47412
## 1st Qu.:-0.17107 1st Qu.:-3.87032
## Median :-0.01833 Median :-3.00008
## Mean : 0.00433 Mean :-2.97930
## 3rd Qu.: 0.18006 3rd Qu.:-2.24116
## Max. : 0.34047 Max. : 0.07674
m<-mixed(litter~ndvi*stage+(month|plot),data=data)
## Numerical variables NOT centered on 0 (i.e., interpretation of all main effects might be difficult if in interactions): ndvi
## Fitting one lmer() model. [DONE]
## Calculating p-values.
## Note: method with signature 'sparseMatrix#ANY' chosen for function 'kronecker',
## target signature 'dgCMatrix#ngCMatrix'.
## "ANY#sparseMatrix" would also be valid
## [DONE]
anova(m)
## Mixed Model Anova Table (Type 3 tests, KR-method)
##
## Model: litter ~ ndvi * stage + (month | plot)
## Data: data
## num Df den Df F Pr(>F)
## ndvi 1 422.55 55.0619 6.473e-13 ***
## stage 2 419.25 8.1364 0.0003414 ***
## ndvi:stage 2 419.07 19.5316 7.761e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(m)
## Linear mixed model fit by REML ['merModLmerTest']
## Formula: litter ~ ndvi * stage + (month | plot)
## Data: data
##
## REML criterion at convergence: 1348.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.72511 -0.65546 -0.07867 0.71961 2.43766
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## plot (Intercept) 2.12254 1.4569
## month 0.05024 0.2241 -1.00
## Residual 1.27952 1.1312
## Number of obs: 432, groups: plot, 4
##
## Fixed effects:
## Estimate Std. Error t value
## (Intercept) -2.78825 0.09599 -29.046
## ndvi -0.37417 0.44922 -0.833
## stageIntermediate -0.57855 0.14344 -4.033
## stageLate -0.24506 0.13505 -1.815
## ndvi:stageIntermediate -5.53375 0.91168 -6.070
## ndvi:stageLate -2.00674 0.61924 -3.241
##
## Correlation of Fixed Effects:
## (Intr) ndvi stgInt stagLt ndv:sI
## ndvi -0.189
## stagIntrmdt -0.676 0.162
## stageLate -0.708 0.121 0.476
## ndv:stgIntr 0.075 -0.394 0.241 -0.055
## ndvi:stagLt 0.118 -0.627 -0.083 -0.158 0.300
More information about the R-sig-mixed-models
mailing list