From: Michael Tiemann <tiemannm_at_web.de>

Date: Mon 29 Aug 2005 - 19:14:44 EST

par(mfrow=c(1,1))

}

#now, the autocorrelations should be consistent with following processes:

#I need to know, wether ts.anr can be explained with ts.mar, so

#according to ar.mle:

mod3<-arima(ts.anr,order=c(2,0,0),xreg=ts.mar,transform.pars=TRUE) fit3 <- gls(ts.anr ~ ts.mar,correlation =

#the puzzling bit is the negative correlation. It ought to be positive,

I think.

#a simple OLS (this is what the people before me have done) yields

test3<-ols(ts.anr~ts.mar)

test3 #with a positive correlation. Why?

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon Aug 29 19:56:27 2005

Date: Mon 29 Aug 2005 - 19:14:44 EST

Dear list,

I am trying to re-analyse something. I do have two time series, one
of which (ts.mar) might help explaining the other (ts.anr). In the
original analysis, no-one seems to have cared about the data being
time-series and they just did OLS. This yielded a strong positive
correlation.

I want to know if this correlation is still as strong when the
autocorrelations are taken into account. There are autocorrelations, so
I model the data with arima() to get the parameters and fit it with
gls(). So far, the code seems to work fine, but what puzzles me is that
I get different sings: the gls-fit yields a strong negative correlation.
This shouldn't be so, so I suspect I am doing something wrong.

Here is my code:

# this is my data

ts.mar<-ts(c(431.3,438,389.7,353.3,354.6,371.8,397.7,438.5,467.9,505.7,574.7,644.7,667.8,616.4,509.6,447,413.1,384.1),start=1980,freq=1)
ts.anr<-ts(c(104.1,102.4,97.9,96.2,95.1,95.1,97.9,101.6,105.9,111.1,117.9,121.3,121.8,114.2,107.6,105.1,101.9,98.6),start=1980,freq=1)

# to find autocorrelations via (p)acf's and mle I do:

fun.tsa.mle<-function(x){

par(mfrow=c(3,1))

acf(x)

pacf(x)

# AR model is estimated

m1<- ar.mle(x)

# An estimation of the unexplained portion of variance

m1.1<-m1$var.pred

# plot the function

plot(x)

# Give a printout

print(m1) print("unexplained portion of variance:") print(m1.1) print("Mean:") print(m1$x.mean)

par(mfrow=c(1,1))

}

#now, the autocorrelations should be consistent with following processes:

fun.tsa.mle(ts.mar) #following DAAG a p=2 AR fun.tsa.mle(ts.anr) #following DAAG a p=2 AR

#I need to know, wether ts.anr can be explained with ts.mar, so

#according to ar.mle:

mod3<-arima(ts.anr,order=c(2,0,0),xreg=ts.mar,transform.pars=TRUE) fit3 <- gls(ts.anr ~ ts.mar,correlation =

corARMA(value=c(mod3$coef[1],mod3$coef[2]),p=2)) summary(fit3) ts.plot(ts.anr,fit3$fitted,col=1:2)

#the puzzling bit is the negative correlation. It ought to be positive,

I think.

#a simple OLS (this is what the people before me have done) yields

test3<-ols(ts.anr~ts.mar)

test3 #with a positive correlation. Why?

Where is the mistake? Up to now, I just thought time-series analyses would correct parameters and estimations, but simply changing signs?

Appreciating your help and suggestions,

Michael.

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon Aug 29 19:56:27 2005

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:39:57 EST
*