Beaulieu.Jake at epamail.epa.gov
2011-Oct-08 17:36 UTC
[R] Accouting for temporal correlation in linear regression
I measured nitrate concentration and primary production (PP) biweekly for 23 months in one headwater stream. I would like to use linear regression to determine if PP is related to nitrate concentration. My dataframe is called "data" and consists of the vectors Rdate, PP, and nitrate. Rdate is the observation date in class "date" and PP is primary production. I first fit a linear model with uncorrelated residuals using gls: M.lm <- gls (PP ~ nitrate, data=data) I then looked for evidence of auto-correlation using acf: acf (residuals ( M.lm, type = 'normalized')) The plot showed a clear pattern, so I reran the gls using an AR-1 auto-correlation structure: M.AR1 <- gls (PP ~ nitrate, correlation = corAR1 (form =~Rdate), data=data) I then compared the AIC values of the M.lm and M.AR1: AIC(M.lm, M.AR1) M.AR1 had a much lower AIC score than M.lm, suggesting that it is the better model. I then inspected a plot of the standardized residuals against the fitted values for M.AR1: plot (M.AR1) This plot shows a pattern of decreasing residual spread with increasing nitrate concentration, a clear indication on non-homogeneity. My questions are: Is the M.AR1 model appropriate for the question I am trying to answer? All examples of AR-1 residual structure I could find are used in the context of testing for a time effect. I am not interested in a time effect. Is is still appropriate to use the AR1 auto-correlation structure? If M.AR1 is OK, should I be worried about non-homogeneity in the residuals? If so, how should I go about dealing with it? Could I add a new variance structure to the model (e.g., varExp). The approach outlined here is drawn from my interpretation of chapters 4 and 6 of Zuur et al. 2009. Mixed effects models and extensions in ecology with R. Thanks, Jake Research Ecologist US EPA [[alternative HTML version deleted]]
Seemingly Similar Threads
- question regarding variance function in gls
- varComb in gls/lme
- Which R function for GLMM with binary response, nested random factors with temporal correlation?
- how to view the syntax of a method which is not a generic method
- GLS - Plotting Graphs with 95% conf interval