R version 2.12.0 (2010-10-15) Copyright (C) 2010 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-pc-linux-gnu (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > x <- array(list(151.7,105.2,121.3,105.2,133.0,105.6,119.6,105.6,122.2,106.2,117.4,106.3,106.7,106.4,87.5,106.9,81.0,107.2,110.3,107.3,87.0,107.3,55.7,107.4,146.0,107.55,137.5,107.87,138.5,108.37,135.6,108.38,107.3,107.92,99.0,108.03,91.4,108.14,68.4,108.3,82.6,108.64,98.4,108.66,71.3,109.04,47.6,109.03,130.8,109.03,113.6,109.54,125.7,109.75,113.6,109.83,97.1,109.65,104.4,109.82,91.8,109.95,75.1,110.12,89.2,110.15,110.2,110.2,78.4,109.99,68.4,110.14,122.8,110.14,129.7,110.81,159.1,110.97,139.0,110.99,102.2,109.73,113.6,109.81,81.5,110.02,77.4,110.18,87.6,110.21,101.2,110.25,87.2,110.36,64.9,110.51,133.1,110.64,118.0,110.95,135.9,111.18,125.7,111.19,108.0,111.69,128.3,111.7,84.7,111.83,86.4,111.77,92.2,111.73,95.8,112.01,92.3,111.86,54.3,112.04),dim=c(2,60),dimnames=list(c('Y','X'),1:60)) > y <- array(NA,dim=c(2,60),dimnames=list(c('Y','X'),1:60)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par3 = 'No Linear Trend' > par2 = 'Include Monthly Dummies' > par1 = '1' > library(lattice) > library(lmtest) Loading required package: zoo > n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test > par1 <- as.numeric(par1) > x <- t(y) > k <- length(x[1,]) > n <- length(x[,1]) > x1 <- cbind(x[,par1], x[,1:k!=par1]) > mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1]) > colnames(x1) <- mycolnames #colnames(x)[par1] > x <- x1 > if (par3 == 'First Differences'){ + x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep=''))) + for (i in 1:n-1) { + for (j in 1:k) { + x2[i,j] <- x[i+1,j] - x[i,j] + } + } + x <- x2 + } > if (par2 == 'Include Monthly Dummies'){ + x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep =''))) + for (i in 1:11){ + x2[seq(i,n,12),i] <- 1 + } + x <- cbind(x, x2) + } > if (par2 == 'Include Quarterly Dummies'){ + x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep =''))) + for (i in 1:3){ + x2[seq(i,n,4),i] <- 1 + } + x <- cbind(x, x2) + } > k <- length(x[1,]) > if (par3 == 'Linear Trend'){ + x <- cbind(x, c(1:n)) + colnames(x)[k+1] <- 't' + } > x Y X M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 1 151.7 105.20 1 0 0 0 0 0 0 0 0 0 0 2 121.3 105.20 0 1 0 0 0 0 0 0 0 0 0 3 133.0 105.60 0 0 1 0 0 0 0 0 0 0 0 4 119.6 105.60 0 0 0 1 0 0 0 0 0 0 0 5 122.2 106.20 0 0 0 0 1 0 0 0 0 0 0 6 117.4 106.30 0 0 0 0 0 1 0 0 0 0 0 7 106.7 106.40 0 0 0 0 0 0 1 0 0 0 0 8 87.5 106.90 0 0 0 0 0 0 0 1 0 0 0 9 81.0 107.20 0 0 0 0 0 0 0 0 1 0 0 10 110.3 107.30 0 0 0 0 0 0 0 0 0 1 0 11 87.0 107.30 0 0 0 0 0 0 0 0 0 0 1 12 55.7 107.40 0 0 0 0 0 0 0 0 0 0 0 13 146.0 107.55 1 0 0 0 0 0 0 0 0 0 0 14 137.5 107.87 0 1 0 0 0 0 0 0 0 0 0 15 138.5 108.37 0 0 1 0 0 0 0 0 0 0 0 16 135.6 108.38 0 0 0 1 0 0 0 0 0 0 0 17 107.3 107.92 0 0 0 0 1 0 0 0 0 0 0 18 99.0 108.03 0 0 0 0 0 1 0 0 0 0 0 19 91.4 108.14 0 0 0 0 0 0 1 0 0 0 0 20 68.4 108.30 0 0 0 0 0 0 0 1 0 0 0 21 82.6 108.64 0 0 0 0 0 0 0 0 1 0 0 22 98.4 108.66 0 0 0 0 0 0 0 0 0 1 0 23 71.3 109.04 0 0 0 0 0 0 0 0 0 0 1 24 47.6 109.03 0 0 0 0 0 0 0 0 0 0 0 25 130.8 109.03 1 0 0 0 0 0 0 0 0 0 0 26 113.6 109.54 0 1 0 0 0 0 0 0 0 0 0 27 125.7 109.75 0 0 1 0 0 0 0 0 0 0 0 28 113.6 109.83 0 0 0 1 0 0 0 0 0 0 0 29 97.1 109.65 0 0 0 0 1 0 0 0 0 0 0 30 104.4 109.82 0 0 0 0 0 1 0 0 0 0 0 31 91.8 109.95 0 0 0 0 0 0 1 0 0 0 0 32 75.1 110.12 0 0 0 0 0 0 0 1 0 0 0 33 89.2 110.15 0 0 0 0 0 0 0 0 1 0 0 34 110.2 110.20 0 0 0 0 0 0 0 0 0 1 0 35 78.4 109.99 0 0 0 0 0 0 0 0 0 0 1 36 68.4 110.14 0 0 0 0 0 0 0 0 0 0 0 37 122.8 110.14 1 0 0 0 0 0 0 0 0 0 0 38 129.7 110.81 0 1 0 0 0 0 0 0 0 0 0 39 159.1 110.97 0 0 1 0 0 0 0 0 0 0 0 40 139.0 110.99 0 0 0 1 0 0 0 0 0 0 0 41 102.2 109.73 0 0 0 0 1 0 0 0 0 0 0 42 113.6 109.81 0 0 0 0 0 1 0 0 0 0 0 43 81.5 110.02 0 0 0 0 0 0 1 0 0 0 0 44 77.4 110.18 0 0 0 0 0 0 0 1 0 0 0 45 87.6 110.21 0 0 0 0 0 0 0 0 1 0 0 46 101.2 110.25 0 0 0 0 0 0 0 0 0 1 0 47 87.2 110.36 0 0 0 0 0 0 0 0 0 0 1 48 64.9 110.51 0 0 0 0 0 0 0 0 0 0 0 49 133.1 110.64 1 0 0 0 0 0 0 0 0 0 0 50 118.0 110.95 0 1 0 0 0 0 0 0 0 0 0 51 135.9 111.18 0 0 1 0 0 0 0 0 0 0 0 52 125.7 111.19 0 0 0 1 0 0 0 0 0 0 0 53 108.0 111.69 0 0 0 0 1 0 0 0 0 0 0 54 128.3 111.70 0 0 0 0 0 1 0 0 0 0 0 55 84.7 111.83 0 0 0 0 0 0 1 0 0 0 0 56 86.4 111.77 0 0 0 0 0 0 0 1 0 0 0 57 92.2 111.73 0 0 0 0 0 0 0 0 1 0 0 58 95.8 112.01 0 0 0 0 0 0 0 0 0 1 0 59 92.3 111.86 0 0 0 0 0 0 0 0 0 0 1 60 54.3 112.04 0 0 0 0 0 0 0 0 0 0 0 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X M1 M2 M3 M4 96.9593 -0.3531 78.2367 65.5046 80.0305 68.2990 M5 M6 M7 M8 M9 M10 48.9025 54.1157 32.8437 20.6494 28.2560 44.9506 M11 25.0197 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -13.9291 -6.0134 -0.8792 6.5683 21.2942 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 96.9593 74.9085 1.294 0.201861 X -0.3531 0.6810 -0.519 0.606516 M1 78.2367 6.1222 12.779 < 2e-16 *** M2 65.5046 6.0911 10.754 2.91e-14 *** M3 80.0305 6.0728 13.179 < 2e-16 *** M4 68.2990 6.0716 11.249 6.27e-15 *** M5 48.9025 6.0802 8.043 2.20e-10 *** M6 54.1157 6.0749 8.908 1.17e-11 *** M7 32.8437 6.0684 5.412 2.06e-06 *** M8 20.6494 6.0619 3.406 0.001357 ** M9 28.2560 6.0588 4.664 2.60e-05 *** M10 44.9506 6.0574 7.421 1.89e-09 *** M11 25.0197 6.0571 4.131 0.000147 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 9.576 on 47 degrees of freedom Multiple R-squared: 0.8889, Adjusted R-squared: 0.8606 F-statistic: 31.35 on 12 and 47 DF, p-value: < 2.2e-16 > if (n > n25) { + kp3 <- k + 3 + nmkm3 <- n - k - 3 + gqarr <- array(NA, dim=c(nmkm3-kp3+1,3)) + numgqtests <- 0 + numsignificant1 <- 0 + numsignificant5 <- 0 + numsignificant10 <- 0 + for (mypoint in kp3:nmkm3) { + j <- 0 + numgqtests <- numgqtests + 1 + for (myalt in c('greater', 'two.sided', 'less')) { + j <- j + 1 + gqarr[mypoint-kp3+1,j] <- gqtest(mylm, point=mypoint, alternative=myalt)$p.value + } + if (gqarr[mypoint-kp3+1,2] < 0.01) numsignificant1 <- numsignificant1 + 1 + if (gqarr[mypoint-kp3+1,2] < 0.05) numsignificant5 <- numsignificant5 + 1 + if (gqarr[mypoint-kp3+1,2] < 0.10) numsignificant10 <- numsignificant10 + 1 + } + gqarr + } [,1] [,2] [,3] [1,] 0.4536650 0.90733009 0.54633496 [2,] 0.6967345 0.60653098 0.30326549 [3,] 0.8258687 0.34826256 0.17413128 [4,] 0.8656790 0.26864190 0.13432095 [5,] 0.8872254 0.22554928 0.11277464 [6,] 0.8233846 0.35323083 0.17661541 [7,] 0.7861059 0.42778824 0.21389412 [8,] 0.7754500 0.44910006 0.22455003 [9,] 0.7189500 0.56210000 0.28105000 [10,] 0.7126169 0.57476616 0.28738308 [11,] 0.6548704 0.69025922 0.34512961 [12,] 0.6674448 0.66511043 0.33255522 [13,] 0.6827054 0.63458928 0.31729464 [14,] 0.6389096 0.72218084 0.36109042 [15,] 0.6639101 0.67217973 0.33608987 [16,] 0.6205979 0.75880412 0.37940206 [17,] 0.5522745 0.89545104 0.44772552 [18,] 0.5293132 0.94137363 0.47068681 [19,] 0.5773037 0.84539265 0.42269633 [20,] 0.5390039 0.92199230 0.46099615 [21,] 0.6399876 0.72002471 0.36001236 [22,] 0.6288745 0.74225091 0.37112545 [23,] 0.6396236 0.72075282 0.36037641 [24,] 0.9373300 0.12534005 0.06267002 [25,] 0.9631414 0.07371719 0.03685859 [26,] 0.9245775 0.15084495 0.07542248 [27,] 0.9378450 0.12431007 0.06215503 [28,] 0.8754607 0.24907866 0.12453933 [29,] 0.8457194 0.30856126 0.15428063 > postscript(file="/var/www/rcomp/tmp/1qalk1321900913.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(x[,1], type='l', main='Actuals and Interpolation', ylab='value of Actuals and Interpolation (dots)', xlab='time or index') > points(x[,1]-mysum$resid) > grid() > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/2km0e1321900913.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(mysum$resid, type='b', pch=19, main='Residuals', ylab='value of Residuals', xlab='time or index') > grid() > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/3k39k1321900913.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > hist(mysum$resid, main='Residual Histogram', xlab='values of Residuals') > grid() > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/4shr11321900913.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > densityplot(~mysum$resid,col='black',main='Residual Density Plot', xlab='values of Residuals') > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/5jumq1321900913.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(mysum$resid, main='Residual Normal Q-Q Plot') > qqline(mysum$resid) > grid() > dev.off() null device 1 > (myerror <- as.ts(mysum$resid)) Time Series: Start = 1 End = 60 Frequency = 1 1 2 3 4 5 6 13.6505179 -4.0173059 -6.7019955 -8.3704700 13.8378894 3.8600081 7 8 9 10 11 12 14.4672963 7.6381711 -6.3625073 6.2781989 2.9090182 -3.3359253 13 14 15 16 17 18 8.7803135 13.1254831 -0.2238960 8.6111605 -0.4547708 -13.9291212 19 20 21 22 23 24 -0.2183019 -10.9674826 -4.2540369 -5.1415790 -12.1765800 -10.8603650 25 26 27 28 29 30 -5.8970919 -10.1848324 -12.5366118 -12.8768380 -10.0439000 -7.8970641 31 32 33 34 35 36 0.8208173 -3.6248324 2.8791509 7.2022019 -4.7411307 10.3315810 37 38 39 40 41 42 -13.5051459 6.3636103 21.2941757 12.9327633 -4.9156517 1.2994048 43 44 45 46 47 48 -9.4544654 -1.3036461 1.3003372 -1.7801429 4.1895179 6.9622297 49 50 51 52 53 54 -3.0285936 -5.2869551 -1.8316724 -0.2966158 1.5764331 16.6667723 55 56 57 58 59 60 -5.6153463 8.2577900 6.4370560 -6.5586789 9.8191747 -3.0975204 > postscript(file="/var/www/rcomp/tmp/6hp5t1321900913.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > dum <- cbind(lag(myerror,k=1),myerror) > dum Time Series: Start = 0 End = 60 Frequency = 1 lag(myerror, k = 1) myerror 0 13.6505179 NA 1 -4.0173059 13.6505179 2 -6.7019955 -4.0173059 3 -8.3704700 -6.7019955 4 13.8378894 -8.3704700 5 3.8600081 13.8378894 6 14.4672963 3.8600081 7 7.6381711 14.4672963 8 -6.3625073 7.6381711 9 6.2781989 -6.3625073 10 2.9090182 6.2781989 11 -3.3359253 2.9090182 12 8.7803135 -3.3359253 13 13.1254831 8.7803135 14 -0.2238960 13.1254831 15 8.6111605 -0.2238960 16 -0.4547708 8.6111605 17 -13.9291212 -0.4547708 18 -0.2183019 -13.9291212 19 -10.9674826 -0.2183019 20 -4.2540369 -10.9674826 21 -5.1415790 -4.2540369 22 -12.1765800 -5.1415790 23 -10.8603650 -12.1765800 24 -5.8970919 -10.8603650 25 -10.1848324 -5.8970919 26 -12.5366118 -10.1848324 27 -12.8768380 -12.5366118 28 -10.0439000 -12.8768380 29 -7.8970641 -10.0439000 30 0.8208173 -7.8970641 31 -3.6248324 0.8208173 32 2.8791509 -3.6248324 33 7.2022019 2.8791509 34 -4.7411307 7.2022019 35 10.3315810 -4.7411307 36 -13.5051459 10.3315810 37 6.3636103 -13.5051459 38 21.2941757 6.3636103 39 12.9327633 21.2941757 40 -4.9156517 12.9327633 41 1.2994048 -4.9156517 42 -9.4544654 1.2994048 43 -1.3036461 -9.4544654 44 1.3003372 -1.3036461 45 -1.7801429 1.3003372 46 4.1895179 -1.7801429 47 6.9622297 4.1895179 48 -3.0285936 6.9622297 49 -5.2869551 -3.0285936 50 -1.8316724 -5.2869551 51 -0.2966158 -1.8316724 52 1.5764331 -0.2966158 53 16.6667723 1.5764331 54 -5.6153463 16.6667723 55 8.2577900 -5.6153463 56 6.4370560 8.2577900 57 -6.5586789 6.4370560 58 9.8191747 -6.5586789 59 -3.0975204 9.8191747 60 NA -3.0975204 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -4.0173059 13.6505179 [2,] -6.7019955 -4.0173059 [3,] -8.3704700 -6.7019955 [4,] 13.8378894 -8.3704700 [5,] 3.8600081 13.8378894 [6,] 14.4672963 3.8600081 [7,] 7.6381711 14.4672963 [8,] -6.3625073 7.6381711 [9,] 6.2781989 -6.3625073 [10,] 2.9090182 6.2781989 [11,] -3.3359253 2.9090182 [12,] 8.7803135 -3.3359253 [13,] 13.1254831 8.7803135 [14,] -0.2238960 13.1254831 [15,] 8.6111605 -0.2238960 [16,] -0.4547708 8.6111605 [17,] -13.9291212 -0.4547708 [18,] -0.2183019 -13.9291212 [19,] -10.9674826 -0.2183019 [20,] -4.2540369 -10.9674826 [21,] -5.1415790 -4.2540369 [22,] -12.1765800 -5.1415790 [23,] -10.8603650 -12.1765800 [24,] -5.8970919 -10.8603650 [25,] -10.1848324 -5.8970919 [26,] -12.5366118 -10.1848324 [27,] -12.8768380 -12.5366118 [28,] -10.0439000 -12.8768380 [29,] -7.8970641 -10.0439000 [30,] 0.8208173 -7.8970641 [31,] -3.6248324 0.8208173 [32,] 2.8791509 -3.6248324 [33,] 7.2022019 2.8791509 [34,] -4.7411307 7.2022019 [35,] 10.3315810 -4.7411307 [36,] -13.5051459 10.3315810 [37,] 6.3636103 -13.5051459 [38,] 21.2941757 6.3636103 [39,] 12.9327633 21.2941757 [40,] -4.9156517 12.9327633 [41,] 1.2994048 -4.9156517 [42,] -9.4544654 1.2994048 [43,] -1.3036461 -9.4544654 [44,] 1.3003372 -1.3036461 [45,] -1.7801429 1.3003372 [46,] 4.1895179 -1.7801429 [47,] 6.9622297 4.1895179 [48,] -3.0285936 6.9622297 [49,] -5.2869551 -3.0285936 [50,] -1.8316724 -5.2869551 [51,] -0.2966158 -1.8316724 [52,] 1.5764331 -0.2966158 [53,] 16.6667723 1.5764331 [54,] -5.6153463 16.6667723 [55,] 8.2577900 -5.6153463 [56,] 6.4370560 8.2577900 [57,] -6.5586789 6.4370560 [58,] 9.8191747 -6.5586789 [59,] -3.0975204 9.8191747 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -4.0173059 13.6505179 2 -6.7019955 -4.0173059 3 -8.3704700 -6.7019955 4 13.8378894 -8.3704700 5 3.8600081 13.8378894 6 14.4672963 3.8600081 7 7.6381711 14.4672963 8 -6.3625073 7.6381711 9 6.2781989 -6.3625073 10 2.9090182 6.2781989 11 -3.3359253 2.9090182 12 8.7803135 -3.3359253 13 13.1254831 8.7803135 14 -0.2238960 13.1254831 15 8.6111605 -0.2238960 16 -0.4547708 8.6111605 17 -13.9291212 -0.4547708 18 -0.2183019 -13.9291212 19 -10.9674826 -0.2183019 20 -4.2540369 -10.9674826 21 -5.1415790 -4.2540369 22 -12.1765800 -5.1415790 23 -10.8603650 -12.1765800 24 -5.8970919 -10.8603650 25 -10.1848324 -5.8970919 26 -12.5366118 -10.1848324 27 -12.8768380 -12.5366118 28 -10.0439000 -12.8768380 29 -7.8970641 -10.0439000 30 0.8208173 -7.8970641 31 -3.6248324 0.8208173 32 2.8791509 -3.6248324 33 7.2022019 2.8791509 34 -4.7411307 7.2022019 35 10.3315810 -4.7411307 36 -13.5051459 10.3315810 37 6.3636103 -13.5051459 38 21.2941757 6.3636103 39 12.9327633 21.2941757 40 -4.9156517 12.9327633 41 1.2994048 -4.9156517 42 -9.4544654 1.2994048 43 -1.3036461 -9.4544654 44 1.3003372 -1.3036461 45 -1.7801429 1.3003372 46 4.1895179 -1.7801429 47 6.9622297 4.1895179 48 -3.0285936 6.9622297 49 -5.2869551 -3.0285936 50 -1.8316724 -5.2869551 51 -0.2966158 -1.8316724 52 1.5764331 -0.2966158 53 16.6667723 1.5764331 54 -5.6153463 16.6667723 55 8.2577900 -5.6153463 56 6.4370560 8.2577900 57 -6.5586789 6.4370560 58 9.8191747 -6.5586789 59 -3.0975204 9.8191747 > plot(z,main=paste('Residual Lag plot, lowess, and regression line'), ylab='values of Residuals', xlab='lagged values of Residuals') > lines(lowess(z)) > abline(lm(z)) > grid() > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/75de01321900913.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > acf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Autocorrelation Function') > grid() > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/8hby71321900913.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > pacf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Partial Autocorrelation Function') > grid() > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/9mjs71321900913.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0)) > plot(mylm, las = 1, sub='Residual Diagnostics') > par(opar) > dev.off() null device 1 > if (n > n25) { + postscript(file="/var/www/rcomp/tmp/105tlq1321900913.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) + plot(kp3:nmkm3,gqarr[,2], main='Goldfeld-Quandt test',ylab='2-sided p-value',xlab='breakpoint') + grid() + dev.off() + } null device 1 > > #Note: the /var/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a, 'Multiple Linear Regression - Estimated Regression Equation', 1, TRUE) > a<-table.row.end(a) > myeq <- colnames(x)[1] > myeq <- paste(myeq, '[t] = ', sep='') > for (i in 1:k){ + if (mysum$coefficients[i,1] > 0) myeq <- paste(myeq, '+', '') + myeq <- paste(myeq, mysum$coefficients[i,1], sep=' ') + if (rownames(mysum$coefficients)[i] != '(Intercept)') { + myeq <- paste(myeq, rownames(mysum$coefficients)[i], sep='') + if (rownames(mysum$coefficients)[i] != 't') myeq <- paste(myeq, '[t]', sep='') + } + } > myeq <- paste(myeq, ' + e[t]') > a<-table.row.start(a) > a<-table.element(a, myeq) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/rcomp/tmp/11wuap1321900913.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,hyperlink('http://www.xycoon.com/ols1.htm','Multiple Linear Regression - Ordinary Least Squares',''), 6, TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Variable',header=TRUE) > a<-table.element(a,'Parameter',header=TRUE) > a<-table.element(a,'S.D.',header=TRUE) > a<-table.element(a,'T-STAT
H0: parameter = 0',header=TRUE) > a<-table.element(a,'2-tail p-value',header=TRUE) > a<-table.element(a,'1-tail p-value',header=TRUE) > a<-table.row.end(a) > for (i in 1:k){ + a<-table.row.start(a) + a<-table.element(a,rownames(mysum$coefficients)[i],header=TRUE) + a<-table.element(a,mysum$coefficients[i,1]) + a<-table.element(a, round(mysum$coefficients[i,2],6)) + a<-table.element(a, round(mysum$coefficients[i,3],4)) + a<-table.element(a, round(mysum$coefficients[i,4],6)) + a<-table.element(a, round(mysum$coefficients[i,4]/2,6)) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/www/rcomp/tmp/12c1qv1321900913.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a, 'Multiple Linear Regression - Regression Statistics', 2, TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'Multiple R',1,TRUE) > a<-table.element(a, sqrt(mysum$r.squared)) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'R-squared',1,TRUE) > a<-table.element(a, mysum$r.squared) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'Adjusted R-squared',1,TRUE) > a<-table.element(a, mysum$adj.r.squared) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'F-TEST (value)',1,TRUE) > a<-table.element(a, mysum$fstatistic[1]) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'F-TEST (DF numerator)',1,TRUE) > a<-table.element(a, mysum$fstatistic[2]) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'F-TEST (DF denominator)',1,TRUE) > a<-table.element(a, mysum$fstatistic[3]) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'p-value',1,TRUE) > a<-table.element(a, 1-pf(mysum$fstatistic[1],mysum$fstatistic[2],mysum$fstatistic[3])) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'Multiple Linear Regression - Residual Statistics', 2, TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'Residual Standard Deviation',1,TRUE) > a<-table.element(a, mysum$sigma) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'Sum Squared Residuals',1,TRUE) > a<-table.element(a, sum(myerror*myerror)) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/rcomp/tmp/13vcld1321900913.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a, 'Multiple Linear Regression - Actuals, Interpolation, and Residuals', 4, TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'Time or Index', 1, TRUE) > a<-table.element(a, 'Actuals', 1, TRUE) > a<-table.element(a, 'Interpolation
Forecast', 1, TRUE) > a<-table.element(a, 'Residuals
Prediction Error', 1, TRUE) > a<-table.row.end(a) > for (i in 1:n) { + a<-table.row.start(a) + a<-table.element(a,i, 1, TRUE) + a<-table.element(a,x[i]) + a<-table.element(a,x[i]-mysum$resid[i]) + a<-table.element(a,mysum$resid[i]) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/www/rcomp/tmp/142q781321900913.tab") > if (n > n25) { + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'Goldfeld-Quandt test for Heteroskedasticity',4,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'p-values',header=TRUE) + a<-table.element(a,'Alternative Hypothesis',3,header=TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'breakpoint index',header=TRUE) + a<-table.element(a,'greater',header=TRUE) + a<-table.element(a,'2-sided',header=TRUE) + a<-table.element(a,'less',header=TRUE) + a<-table.row.end(a) + for (mypoint in kp3:nmkm3) { + a<-table.row.start(a) + a<-table.element(a,mypoint,header=TRUE) + a<-table.element(a,gqarr[mypoint-kp3+1,1]) + a<-table.element(a,gqarr[mypoint-kp3+1,2]) + a<-table.element(a,gqarr[mypoint-kp3+1,3]) + a<-table.row.end(a) + } + a<-table.end(a) + table.save(a,file="/var/www/rcomp/tmp/154l8m1321900913.tab") + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'Meta Analysis of Goldfeld-Quandt test for Heteroskedasticity',4,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'Description',header=TRUE) + a<-table.element(a,'# significant tests',header=TRUE) + a<-table.element(a,'% significant tests',header=TRUE) + a<-table.element(a,'OK/NOK',header=TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'1% type I error level',header=TRUE) + a<-table.element(a,numsignificant1) + a<-table.element(a,numsignificant1/numgqtests) + if (numsignificant1/numgqtests < 0.01) dum <- 'OK' else dum <- 'NOK' + a<-table.element(a,dum) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'5% type I error level',header=TRUE) + a<-table.element(a,numsignificant5) + a<-table.element(a,numsignificant5/numgqtests) + if (numsignificant5/numgqtests < 0.05) dum <- 'OK' else dum <- 'NOK' + a<-table.element(a,dum) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'10% type I error level',header=TRUE) + a<-table.element(a,numsignificant10) + a<-table.element(a,numsignificant10/numgqtests) + if (numsignificant10/numgqtests < 0.1) dum <- 'OK' else dum <- 'NOK' + a<-table.element(a,dum) + a<-table.row.end(a) + a<-table.end(a) + table.save(a,file="/var/www/rcomp/tmp/16x6uk1321900913.tab") + } > > try(system("convert tmp/1qalk1321900913.ps tmp/1qalk1321900913.png",intern=TRUE)) character(0) > try(system("convert tmp/2km0e1321900913.ps tmp/2km0e1321900913.png",intern=TRUE)) character(0) > try(system("convert tmp/3k39k1321900913.ps tmp/3k39k1321900913.png",intern=TRUE)) character(0) > try(system("convert tmp/4shr11321900913.ps tmp/4shr11321900913.png",intern=TRUE)) character(0) > try(system("convert tmp/5jumq1321900913.ps tmp/5jumq1321900913.png",intern=TRUE)) character(0) > try(system("convert tmp/6hp5t1321900913.ps tmp/6hp5t1321900913.png",intern=TRUE)) character(0) > try(system("convert tmp/75de01321900913.ps tmp/75de01321900913.png",intern=TRUE)) character(0) > try(system("convert tmp/8hby71321900913.ps tmp/8hby71321900913.png",intern=TRUE)) character(0) > try(system("convert tmp/9mjs71321900913.ps tmp/9mjs71321900913.png",intern=TRUE)) character(0) > try(system("convert tmp/105tlq1321900913.ps tmp/105tlq1321900913.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 4.120 0.390 4.492