Title: | Temporal Contributions on Trends using Mixed Models |
---|---|
Description: | Method to estimate the effect of the trend in predictor variables on the observed trend of the response variable using mixed models with temporal autocorrelation. See Fernández-Martínez et al. (2017 and 2019) <doi:10.1038/s41598-017-08755-8> <doi:10.1038/s41558-018-0367-7>. |
Authors: | Marcos Fernández-Martínez, Joan Maspons |
Maintainer: | Marcos Fernández-Martínez <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.1.0.9000 |
Built: | 2024-11-05 02:40:07 UTC |
Source: | https://github.com/burriach/tempcont |
When using temporal data, linear models provide parameter estimates that help to understand how, for instance, interannual variability in a response variable is affected by a predictor. However, if the response variable and the predictors present trends, things get a bit more tricky. This methodology is aimed at estimating the effect of the trend in the predictors on the observed trend of the response variable. To do so, our package first calculates the observed trend of the response (slope estimate ± standard error of the slope) in the data data using GLMMs with random slopes and temporal autocorrelation structure (ARMA, p = 1, q = 0). Then it calculates the trend predicted by the model provided by the user and the trend predicted by the same model but maintaining the predictor of interest constant (i.e., using the median values per grouping level, while all other predictors change according to the observations). The difference between the temporal predictions for the whole model and the temporal predictions of the model when one variable is controlled is the average temporal contribution of that predictor to the trend in the response variable. The difference between all individual temporal contributions and the observed trend (should be calculated separately) should considered to be unknown contributions. Finally, the package also calculates the average sensitivities of the response variable to predictor changes by dividing the temporal contributions by the trends of the predictor variables. All errors are calculated using the error-propagation method. See Fernández-Martínez et al., 2017 and 2019 for further information on the methodology.
temp.cont(model, driver, random, timevar="year", plot=TRUE)
temp.cont(model, driver, random, timevar="year", plot=TRUE)
model |
Fitted "lme" model. I must be a mixed model with gaussian distribution, and it is advisable to control for temporal autocorrelation at lag 1 (e.g., corCAR1()) |
driver |
Driver of interest. It must be a continous variable. |
random |
Grouping factor. |
plot |
if |
timevar |
name of the time variable. |
A data.frame with the following variables for each driver variable. Row names correspon to the the name of the variable.
mod.slope |
Trend of the response variable predicted by the model. |
mod.slope.se |
Standard error of mod.slope. |
mod.slope.t |
t-value of mod.slope |
mod.slope.p |
P-value of mod.slope |
temp.contr |
Temporal contribution of the predictor |
temp.contr.se |
Standard error of temp.contr |
temp.contr.t |
t-value of temp.contr |
temp.contr.p |
P-value of temp.contr |
pred.trend |
Trend of the predictor |
pred.trend.se |
Standard error of pred.trend |
pred.trend.t |
t-value of pred.trend |
pred.trend.p |
P-value of pred.trend |
sensit |
Trend sensitivity of the response variable to the predictor |
sensit.se |
Standard error of sensit |
sensit.t |
t-value of sensit |
sensit.p |
P-value of sensit |
Marcos Fernández-Martínez, Joan Maspons
Fernández-Martínez et al., 2017. "Atmospheric deposition, CO2, and change in the land carbon sink". Scientific Reports 7:9632.
Fernández-Martínez et al., 2019. "Global trends in carbon sinks and their relationships with CO2 and temperature". Nature Climate Change 9:73–79.
library (nlme) data(tempcont_data) mod <- lme(trolls ~ bushes + temperature + rainfall + drought + gremlins + orcs + warlocks, data=tempcont_data, random=~1|cave, correlation=corCAR1(form=~year|cave), method="ML") summary(mod) temp.cont(model = mod, driver="temperature", random="cave") # Warning: long runtime (> 20 seconds) temp.cont(model = mod, random="cave")
library (nlme) data(tempcont_data) mod <- lme(trolls ~ bushes + temperature + rainfall + drought + gremlins + orcs + warlocks, data=tempcont_data, random=~1|cave, correlation=corCAR1(form=~year|cave), method="ML") summary(mod) temp.cont(model = mod, driver="temperature", random="cave") # Warning: long runtime (> 20 seconds) temp.cont(model = mod, random="cave")
temp.cont
examples
Data from field work in the Middle-earth.
data("tempcont_data")
data("tempcont_data")
A data frame with 400 observations on the following 10 variables.
cave
a factor vector
year
a numeric vector with a temporal variable
trolls
a numeric vector
bushes
a numeric vector
temperature
a numeric vector
rainfall
a numeric vector
drought
a numeric vector
gremlins
a numeric vector
orcs
a numeric vector
warlocks
a numeric vector
data(tempcont_data) str(tempcont_data)
data(tempcont_data) str(tempcont_data)