#### Tiefbohrdaten mit Korrelation Vorlesung 18.6.2015 ####################### ################################################################################ # Einlesen der Daten und kurze Kontrolle tiefb = read.table("http://www.stat.uni-muenchen.de/~abender/unterlagen/limo14/tiefb.txt", header = TRUE) head(tiefb) erg0 <- lm(LN_CATR ~ H2O + C + MGO + CR + TH_COND,data=tiefb) summary(erg0) #### Modell mit Autokorrelation ########################## library(nlme) ergar <- gls(LN_CATR ~ H2O + C + MGO + CR + TH_COND,corr= corAR1(form = ~ 1), data=tiefb) summary(ergar) res<-residuals(ergar) plot(tiefb$DEPTH,res) plot(res[1:386],res[2:387]) cor(res[1:386],res[2:387]) resn<-residuals(ergar,type="normalized") plot(tiefb$DEPTH,resn) plot(resn[1:386],resn[2:387]) cor(resn[1:386],resn[2:387]) ### ganz korrekt: ### Ganz korrektes Vorgehen ergarc <- gls(LN_CATR ~ H2O + C + MGO + CR + TH_COND,corr= corCAR1(form = ~ DEPTH), data=tiefb) summary(ergarc) #### Korrelation abhängig vom Abstand mit CorCAR Depth ist die Abstandsvariable summary(ergarc) ### Da einige Beobachtungen mehr als 1 m auseinanderliegen, # wird rho etwas höher gschaetzt