Question

Hi guys so my problem is possibly either a stats or a programming issue. I have two xts time series of mostly overlapping time periods and I'm simply plotting a regression of their log differences:

   logdiff <- merge.xts(diff(log(ts1)),diff(log(ts2)))
   plot(logdiff[,1],logdiff[,2])
   abline(lm(logdiff[,1]~logdiff[,2]),col=2)

which gives me this plot

result

So just on an intuitive level I would rather the regression line fit the wider range of data points even if this result its giving me is technically the correct one on a least squares basis. Is there any inbuilt capability to do this "broader regression" or do i have to resort to manual fudging?

Was it helpful?

Solution

I think you are plotting y as a function of x, but regressing x as a function of y.

Try abline(lm(logdiff[,2]~logdiff[,1]),col=2) -- and yes, using column names instead of indices is a good idea.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top