[R-sig-ME] another gls question

Mark Leeds markleeds2 at gmail.com
Thu May 7 22:17:14 CEST 2015


Hi All. I'm sorry to bother this list again but I was able to extract the
orthogonal residuals
based on what Thierry suggested.  ( Thanks Thierry ).

If I understand correctly, the normalized residuals are the ones that come
out of
the transformed regression with independent error term which means that the
sums of square decomposition should hold when I use them.

Then. since the sums of squares decomposition should hold,  I would expect
to get the same values for r2= 1-(sse/sstot) and R2 = corr(predicted,
actual)^2.

Unfortunately, when I use these residuals, the SSTOT = SSREG + SSTOT
relation still
isn't holding. ( so of course the r^2 = R^2 relation isn't holding ).

 I've dputted the objects needed to run the code and the code below. Could
someone take a look and see if I'm doing anything dumb because,
theoretically, the decomposition should hold. It also could be that I'm
still not understanding the term "normalized" and what it implies about
where those residuals are coming from.

My other thought is that maybe ybar need to be modified by subtracting  the
theta*e_t-1 term
from it  since the residual is e_t now  rather than e_t + theta* e_t-1 ?

Thanks a lot.

#=================================================================

 dput(x)
structure(c(3200L, 3084L, 2864L, 2803L, 2755L, 2696L, 2646L,
2701L, 2654L, 2766L, 2832L, 2964L, 3041L, 3010L, 3018L, 3374L,
3545L, 3441L, 3456L, 3455L, 3503L, 3641L, 3721L, 3828L, 3831L,
3858L, 3925L, 3880L, 3935L, 3895L, 3840L, 3756L, 3669L, 3502L,
3145L, 2812L, 2586L, 2441L, 234L, 234L, 235L, 237L, 238L, 240L,
241L, 242L, 244L, 245L, 246L, 268L, 333L, 335L, 331L, 253L, 243L,
241L, 242L, 237L, 242L, 240L, 233L, 232L, 236L, 245L, 256L, 261L,
265L, 278L, 291L, 290L, 290L, 307L, 313L, 325L, 339L, 338L), .Dim = c(38L,
2L), .Dimnames = list(NULL, c("ewma.ret", "ewma.imbal")))
> dput(y)
c(77.1, 92.9, 98.3, 88.1, 79.4, 91, 100.4, 108.9, 123.6, 157.3,
154.3, 143.9, 147.5, 97.3, 76.6, 72.8, 68.9, 66.7, 55, 55, 55,
54.7, 47.9, 49, 44.4, 40.2, 43.8, 49.5, 50.4, 59.6, 72.4, 70.6,
82, 89.5, 101.3, 116.7, 115.2, 122.9)


gls.est <- gls(y~x, correlation=corARMA(q=1), method='ML')

ybar <- gls.est$coefficients[1]
residualsnorm <- residuals(gls.est, type = "normalized")

gls.est.ssenorm <- sum((residualsnorm)^2)
gls.est.ssreg <-sum((gls.est$fitted - ybar)^2)
gls.est.sstot <- sum((y - ybar)^2)

gls.est.rsquaredA <- 1 - (gls.est.ssenorm/gls.est.sstot)
gls.est.rsquaredB <- cor(y, gls.est$fitted)^2

cat("SSE + SSREG: ", gls.est.ssreg + gls.est.ssenorm, "\n")
cat("SSTOT: ", gls.est.sstot, "\n")

cat("GLS RSQUARED A : ", gls.est.rsquaredA, "\n")
cat("GLS RSQUARED B : ", gls.est.rsquaredB, "\n")

gls.sum <- summary(gls.est)
print(gls.sum)

	[[alternative HTML version deleted]]



More information about the R-sig-mixed-models mailing list