R version 2.13.0 (2011-04-13) Copyright (C) 2011 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(112.3 + ,0 + ,117.2 + ,96.8 + ,80 + ,126.1 + ,117.3 + ,0 + ,112.3 + ,117.2 + ,96.8 + ,80 + ,111.1 + ,1 + ,117.3 + ,112.3 + ,117.2 + ,96.8 + ,102.2 + ,1 + ,111.1 + ,117.3 + ,112.3 + ,117.2 + ,104.3 + ,1 + ,102.2 + ,111.1 + ,117.3 + ,112.3 + ,122.9 + ,1 + ,104.3 + ,102.2 + ,111.1 + ,117.3 + ,107.6 + ,1 + ,122.9 + ,104.3 + ,102.2 + ,111.1 + ,121.3 + ,1 + ,107.6 + ,122.9 + ,104.3 + ,102.2 + ,131.5 + ,1 + ,121.3 + ,107.6 + ,122.9 + ,104.3 + ,89 + ,1 + ,131.5 + ,121.3 + ,107.6 + ,122.9 + ,104.4 + ,1 + ,89 + ,131.5 + ,121.3 + ,107.6 + ,128.9 + ,1 + ,104.4 + ,89 + ,131.5 + ,121.3 + ,135.9 + ,1 + ,128.9 + ,104.4 + ,89 + ,131.5 + ,133.3 + ,1 + ,135.9 + ,128.9 + ,104.4 + ,89 + ,121.3 + ,1 + ,133.3 + ,135.9 + ,128.9 + ,104.4 + ,120.5 + ,0 + ,121.3 + ,133.3 + ,135.9 + ,128.9 + ,120.4 + ,0 + ,120.5 + ,121.3 + ,133.3 + ,135.9 + ,137.9 + ,0 + ,120.4 + ,120.5 + ,121.3 + ,133.3 + ,126.1 + ,0 + ,137.9 + ,120.4 + ,120.5 + ,121.3 + ,133.2 + ,0 + ,126.1 + ,137.9 + ,120.4 + ,120.5 + ,151.1 + ,0 + ,133.2 + ,126.1 + ,137.9 + ,120.4 + ,105 + ,0 + ,151.1 + ,133.2 + ,126.1 + ,137.9 + ,119 + ,0 + ,105 + ,151.1 + ,133.2 + ,126.1 + ,140.4 + ,0 + ,119 + ,105 + ,151.1 + ,133.2 + ,156.6 + ,0 + ,140.4 + ,119 + ,105 + ,151.1 + ,137.1 + ,0 + ,156.6 + ,140.4 + ,119 + ,105 + ,122.7 + ,0 + ,137.1 + ,156.6 + ,140.4 + ,119 + ,125.8 + ,0 + ,122.7 + ,137.1 + ,156.6 + ,140.4 + ,139.3 + ,0 + ,125.8 + ,122.7 + ,137.1 + ,156.6 + ,134.9 + ,0 + ,139.3 + ,125.8 + ,122.7 + ,137.1 + ,149.2 + ,0 + ,134.9 + ,139.3 + ,125.8 + ,122.7 + ,132.3 + ,0 + ,149.2 + ,134.9 + ,139.3 + ,125.8 + ,149 + ,0 + ,132.3 + ,149.2 + ,134.9 + ,139.3 + ,117.2 + ,0 + ,149 + ,132.3 + ,149.2 + ,134.9 + ,119.6 + ,0 + ,117.2 + ,149 + ,132.3 + ,149.2 + ,152 + ,0 + ,119.6 + ,117.2 + ,149 + ,132.3 + ,149.4 + ,0 + ,152 + ,119.6 + ,117.2 + ,149 + ,127.3 + ,0 + ,149.4 + ,152 + ,119.6 + ,117.2 + ,114.1 + ,0 + ,127.3 + ,149.4 + ,152 + ,119.6 + ,102.1 + ,0 + ,114.1 + ,127.3 + ,149.4 + ,152 + ,107.7 + ,0 + ,102.1 + ,114.1 + ,127.3 + ,149.4 + ,104.4 + ,0 + ,107.7 + ,102.1 + ,114.1 + ,127.3 + ,102.1 + ,0 + ,104.4 + ,107.7 + ,102.1 + ,114.1 + ,96 + ,1 + ,102.1 + ,104.4 + ,107.7 + ,102.1 + ,109.3 + ,0 + ,96 + ,102.1 + ,104.4 + ,107.7 + ,90 + ,1 + ,109.3 + ,96 + ,102.1 + ,104.4 + ,83.9 + ,1 + ,90 + ,109.3 + ,96 + ,102.1 + ,112 + ,1 + ,83.9 + ,90 + ,109.3 + ,96 + ,114.3 + ,1 + ,112 + ,83.9 + ,90 + ,109.3 + ,103.6 + ,1 + ,114.3 + ,112 + ,83.9 + ,90 + ,91.7 + ,1 + ,103.6 + ,114.3 + ,112 + ,83.9 + ,80.8 + ,1 + ,91.7 + ,103.6 + ,114.3 + ,112 + ,87.2 + ,1 + ,80.8 + ,91.7 + ,103.6 + ,114.3 + ,109.2 + ,1 + ,87.2 + ,80.8 + ,91.7 + ,103.6 + ,102.7 + ,1 + ,109.2 + ,87.2 + ,80.8 + ,91.7 + ,95.1 + ,1 + ,102.7 + ,109.2 + ,87.2 + ,80.8 + ,117.5 + ,1 + ,95.1 + ,102.7 + ,109.2 + ,87.2 + ,85.1 + ,1 + ,117.5 + ,95.1 + ,102.7 + ,109.2 + ,92.1 + ,1 + ,85.1 + ,117.5 + ,95.1 + ,102.7 + ,113.5 + ,1 + ,92.1 + ,85.1 + ,117.5 + ,95.1) + ,dim=c(6 + ,60) + ,dimnames=list(c('X' + ,'Y' + ,'y(t)' + ,'y(t-1)' + ,'y(t-2)' + ,'y(t-3)') + ,1:60)) > y <- array(NA,dim=c(6,60),dimnames=list(c('X','Y','y(t)','y(t-1)','y(t-2)','y(t-3)'),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 = '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 X Y y(t) y(t-1) y(t-2) y(t-3) M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 112.3 0 117.2 96.8 80.0 126.1 1 0 0 0 0 0 0 0 0 0 0 1 2 117.3 0 112.3 117.2 96.8 80.0 0 1 0 0 0 0 0 0 0 0 0 2 3 111.1 1 117.3 112.3 117.2 96.8 0 0 1 0 0 0 0 0 0 0 0 3 4 102.2 1 111.1 117.3 112.3 117.2 0 0 0 1 0 0 0 0 0 0 0 4 5 104.3 1 102.2 111.1 117.3 112.3 0 0 0 0 1 0 0 0 0 0 0 5 6 122.9 1 104.3 102.2 111.1 117.3 0 0 0 0 0 1 0 0 0 0 0 6 7 107.6 1 122.9 104.3 102.2 111.1 0 0 0 0 0 0 1 0 0 0 0 7 8 121.3 1 107.6 122.9 104.3 102.2 0 0 0 0 0 0 0 1 0 0 0 8 9 131.5 1 121.3 107.6 122.9 104.3 0 0 0 0 0 0 0 0 1 0 0 9 10 89.0 1 131.5 121.3 107.6 122.9 0 0 0 0 0 0 0 0 0 1 0 10 11 104.4 1 89.0 131.5 121.3 107.6 0 0 0 0 0 0 0 0 0 0 1 11 12 128.9 1 104.4 89.0 131.5 121.3 0 0 0 0 0 0 0 0 0 0 0 12 13 135.9 1 128.9 104.4 89.0 131.5 1 0 0 0 0 0 0 0 0 0 0 13 14 133.3 1 135.9 128.9 104.4 89.0 0 1 0 0 0 0 0 0 0 0 0 14 15 121.3 1 133.3 135.9 128.9 104.4 0 0 1 0 0 0 0 0 0 0 0 15 16 120.5 0 121.3 133.3 135.9 128.9 0 0 0 1 0 0 0 0 0 0 0 16 17 120.4 0 120.5 121.3 133.3 135.9 0 0 0 0 1 0 0 0 0 0 0 17 18 137.9 0 120.4 120.5 121.3 133.3 0 0 0 0 0 1 0 0 0 0 0 18 19 126.1 0 137.9 120.4 120.5 121.3 0 0 0 0 0 0 1 0 0 0 0 19 20 133.2 0 126.1 137.9 120.4 120.5 0 0 0 0 0 0 0 1 0 0 0 20 21 151.1 0 133.2 126.1 137.9 120.4 0 0 0 0 0 0 0 0 1 0 0 21 22 105.0 0 151.1 133.2 126.1 137.9 0 0 0 0 0 0 0 0 0 1 0 22 23 119.0 0 105.0 151.1 133.2 126.1 0 0 0 0 0 0 0 0 0 0 1 23 24 140.4 0 119.0 105.0 151.1 133.2 0 0 0 0 0 0 0 0 0 0 0 24 25 156.6 0 140.4 119.0 105.0 151.1 1 0 0 0 0 0 0 0 0 0 0 25 26 137.1 0 156.6 140.4 119.0 105.0 0 1 0 0 0 0 0 0 0 0 0 26 27 122.7 0 137.1 156.6 140.4 119.0 0 0 1 0 0 0 0 0 0 0 0 27 28 125.8 0 122.7 137.1 156.6 140.4 0 0 0 1 0 0 0 0 0 0 0 28 29 139.3 0 125.8 122.7 137.1 156.6 0 0 0 0 1 0 0 0 0 0 0 29 30 134.9 0 139.3 125.8 122.7 137.1 0 0 0 0 0 1 0 0 0 0 0 30 31 149.2 0 134.9 139.3 125.8 122.7 0 0 0 0 0 0 1 0 0 0 0 31 32 132.3 0 149.2 134.9 139.3 125.8 0 0 0 0 0 0 0 1 0 0 0 32 33 149.0 0 132.3 149.2 134.9 139.3 0 0 0 0 0 0 0 0 1 0 0 33 34 117.2 0 149.0 132.3 149.2 134.9 0 0 0 0 0 0 0 0 0 1 0 34 35 119.6 0 117.2 149.0 132.3 149.2 0 0 0 0 0 0 0 0 0 0 1 35 36 152.0 0 119.6 117.2 149.0 132.3 0 0 0 0 0 0 0 0 0 0 0 36 37 149.4 0 152.0 119.6 117.2 149.0 1 0 0 0 0 0 0 0 0 0 0 37 38 127.3 0 149.4 152.0 119.6 117.2 0 1 0 0 0 0 0 0 0 0 0 38 39 114.1 0 127.3 149.4 152.0 119.6 0 0 1 0 0 0 0 0 0 0 0 39 40 102.1 0 114.1 127.3 149.4 152.0 0 0 0 1 0 0 0 0 0 0 0 40 41 107.7 0 102.1 114.1 127.3 149.4 0 0 0 0 1 0 0 0 0 0 0 41 42 104.4 0 107.7 102.1 114.1 127.3 0 0 0 0 0 1 0 0 0 0 0 42 43 102.1 0 104.4 107.7 102.1 114.1 0 0 0 0 0 0 1 0 0 0 0 43 44 96.0 1 102.1 104.4 107.7 102.1 0 0 0 0 0 0 0 1 0 0 0 44 45 109.3 0 96.0 102.1 104.4 107.7 0 0 0 0 0 0 0 0 1 0 0 45 46 90.0 1 109.3 96.0 102.1 104.4 0 0 0 0 0 0 0 0 0 1 0 46 47 83.9 1 90.0 109.3 96.0 102.1 0 0 0 0 0 0 0 0 0 0 1 47 48 112.0 1 83.9 90.0 109.3 96.0 0 0 0 0 0 0 0 0 0 0 0 48 49 114.3 1 112.0 83.9 90.0 109.3 1 0 0 0 0 0 0 0 0 0 0 49 50 103.6 1 114.3 112.0 83.9 90.0 0 1 0 0 0 0 0 0 0 0 0 50 51 91.7 1 103.6 114.3 112.0 83.9 0 0 1 0 0 0 0 0 0 0 0 51 52 80.8 1 91.7 103.6 114.3 112.0 0 0 0 1 0 0 0 0 0 0 0 52 53 87.2 1 80.8 91.7 103.6 114.3 0 0 0 0 1 0 0 0 0 0 0 53 54 109.2 1 87.2 80.8 91.7 103.6 0 0 0 0 0 1 0 0 0 0 0 54 55 102.7 1 109.2 87.2 80.8 91.7 0 0 0 0 0 0 1 0 0 0 0 55 56 95.1 1 102.7 109.2 87.2 80.8 0 0 0 0 0 0 0 1 0 0 0 56 57 117.5 1 95.1 102.7 109.2 87.2 0 0 0 0 0 0 0 0 1 0 0 57 58 85.1 1 117.5 95.1 102.7 109.2 0 0 0 0 0 0 0 0 0 1 0 58 59 92.1 1 85.1 117.5 95.1 102.7 0 0 0 0 0 0 0 0 0 0 1 59 60 113.5 1 92.1 85.1 117.5 95.1 0 0 0 0 0 0 0 0 0 0 0 60 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) Y `y(t)` `y(t-1)` `y(t-2)` `y(t-3)` 24.16984 3.12409 0.35411 0.38669 0.31630 -0.07924 M1 M2 M3 M4 M5 M6 4.29883 -22.29685 -39.56917 -35.92971 -20.33786 -6.96633 M7 M8 M9 M10 M11 t -15.93235 -22.99397 -6.55872 -44.28328 -31.40455 -0.09838 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -12.2924 -3.8712 -0.7825 5.4700 15.3720 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 24.16984 18.63898 1.297 0.20180 Y 3.12409 3.77308 0.828 0.41235 `y(t)` 0.35411 0.15350 2.307 0.02606 * `y(t-1)` 0.38669 0.16145 2.395 0.02116 * `y(t-2)` 0.31630 0.15627 2.024 0.04936 * `y(t-3)` -0.07924 0.15790 -0.502 0.61842 M1 4.29883 9.79949 0.439 0.66314 M2 -22.29685 10.74913 -2.074 0.04422 * M3 -39.56917 7.99930 -4.947 1.27e-05 *** M4 -35.92971 5.97498 -6.013 3.80e-07 *** M5 -20.33786 6.11528 -3.326 0.00184 ** M6 -6.96633 6.52299 -1.068 0.29164 M7 -15.93235 7.90012 -2.017 0.05015 . M8 -22.99397 7.83731 -2.934 0.00540 ** M9 -6.55872 6.46951 -1.014 0.31649 M10 -44.28328 7.36444 -6.013 3.80e-07 *** M11 -31.40455 8.39478 -3.741 0.00055 *** t -0.09838 0.06592 -1.492 0.14306 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 7.735 on 42 degrees of freedom Multiple R-squared: 0.8816, Adjusted R-squared: 0.8337 F-statistic: 18.4 on 17 and 42 DF, p-value: 3.198e-14 > 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.025997349 0.051994698 0.9740027 [2,] 0.008086278 0.016172556 0.9919137 [3,] 0.001803604 0.003607208 0.9981964 [4,] 0.002275122 0.004550244 0.9977249 [5,] 0.000865485 0.001730970 0.9991345 [6,] 0.004872591 0.009745182 0.9951274 [7,] 0.114008742 0.228017484 0.8859913 [8,] 0.307805443 0.615610887 0.6921946 [9,] 0.332383313 0.664766626 0.6676167 [10,] 0.291140181 0.582280362 0.7088598 [11,] 0.593927548 0.812144904 0.4060725 [12,] 0.517518877 0.964962246 0.4824811 [13,] 0.704306281 0.591387438 0.2956937 [14,] 0.599772058 0.800455883 0.4002279 [15,] 0.512029590 0.975940819 0.4879704 [16,] 0.744961239 0.510077523 0.2550388 [17,] 0.638956287 0.722087427 0.3610437 [18,] 0.634458321 0.731083359 0.3655417 [19,] 0.527649136 0.944701729 0.4723509 > postscript(file="/var/wessaorg/rcomp/tmp/1z4lo1322332188.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/wessaorg/rcomp/tmp/2txq21322332188.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/wessaorg/rcomp/tmp/3253w1322332188.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/wessaorg/rcomp/tmp/4a2in1322332188.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/wessaorg/rcomp/tmp/5rjkr1322332188.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 -10.3148771 6.2593538 9.3088810 0.2961017 -9.5181154 0.8638286 7 8 9 10 11 12 -10.4464181 7.2696335 -3.5189414 -10.7923562 -2.6129541 -0.5789336 13 14 15 16 17 18 1.8408807 5.7438979 2.7994220 6.5642930 -2.7286468 5.4325110 19 20 21 22 23 24 -4.1590853 7.4806111 5.5493486 -6.6927624 0.7488321 -1.3877752 25 26 27 28 29 30 13.6199147 -1.2785563 -3.3265464 5.4435071 15.3719888 -5.2707478 31 32 33 34 35 36 12.3099424 -4.8167533 -1.5374332 0.2352140 1.1362943 7.0556184 37 38 39 40 41 42 -0.7644455 -11.0571336 -8.1131642 -7.0446752 -0.8004671 -12.2923809 43 44 45 46 47 48 -3.7752220 -6.4709078 -1.8467570 11.6672498 -3.7745955 -2.0477768 49 50 51 52 53 54 -4.3814727 0.3324382 -0.6685924 -5.2592266 -2.3247595 11.2667891 55 56 57 58 59 60 6.0707830 -3.4625834 1.3537830 5.5826548 4.5024232 -3.0411327 > postscript(file="/var/wessaorg/rcomp/tmp/6cj7x1322332188.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 -10.3148771 NA 1 6.2593538 -10.3148771 2 9.3088810 6.2593538 3 0.2961017 9.3088810 4 -9.5181154 0.2961017 5 0.8638286 -9.5181154 6 -10.4464181 0.8638286 7 7.2696335 -10.4464181 8 -3.5189414 7.2696335 9 -10.7923562 -3.5189414 10 -2.6129541 -10.7923562 11 -0.5789336 -2.6129541 12 1.8408807 -0.5789336 13 5.7438979 1.8408807 14 2.7994220 5.7438979 15 6.5642930 2.7994220 16 -2.7286468 6.5642930 17 5.4325110 -2.7286468 18 -4.1590853 5.4325110 19 7.4806111 -4.1590853 20 5.5493486 7.4806111 21 -6.6927624 5.5493486 22 0.7488321 -6.6927624 23 -1.3877752 0.7488321 24 13.6199147 -1.3877752 25 -1.2785563 13.6199147 26 -3.3265464 -1.2785563 27 5.4435071 -3.3265464 28 15.3719888 5.4435071 29 -5.2707478 15.3719888 30 12.3099424 -5.2707478 31 -4.8167533 12.3099424 32 -1.5374332 -4.8167533 33 0.2352140 -1.5374332 34 1.1362943 0.2352140 35 7.0556184 1.1362943 36 -0.7644455 7.0556184 37 -11.0571336 -0.7644455 38 -8.1131642 -11.0571336 39 -7.0446752 -8.1131642 40 -0.8004671 -7.0446752 41 -12.2923809 -0.8004671 42 -3.7752220 -12.2923809 43 -6.4709078 -3.7752220 44 -1.8467570 -6.4709078 45 11.6672498 -1.8467570 46 -3.7745955 11.6672498 47 -2.0477768 -3.7745955 48 -4.3814727 -2.0477768 49 0.3324382 -4.3814727 50 -0.6685924 0.3324382 51 -5.2592266 -0.6685924 52 -2.3247595 -5.2592266 53 11.2667891 -2.3247595 54 6.0707830 11.2667891 55 -3.4625834 6.0707830 56 1.3537830 -3.4625834 57 5.5826548 1.3537830 58 4.5024232 5.5826548 59 -3.0411327 4.5024232 60 NA -3.0411327 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 6.2593538 -10.3148771 [2,] 9.3088810 6.2593538 [3,] 0.2961017 9.3088810 [4,] -9.5181154 0.2961017 [5,] 0.8638286 -9.5181154 [6,] -10.4464181 0.8638286 [7,] 7.2696335 -10.4464181 [8,] -3.5189414 7.2696335 [9,] -10.7923562 -3.5189414 [10,] -2.6129541 -10.7923562 [11,] -0.5789336 -2.6129541 [12,] 1.8408807 -0.5789336 [13,] 5.7438979 1.8408807 [14,] 2.7994220 5.7438979 [15,] 6.5642930 2.7994220 [16,] -2.7286468 6.5642930 [17,] 5.4325110 -2.7286468 [18,] -4.1590853 5.4325110 [19,] 7.4806111 -4.1590853 [20,] 5.5493486 7.4806111 [21,] -6.6927624 5.5493486 [22,] 0.7488321 -6.6927624 [23,] -1.3877752 0.7488321 [24,] 13.6199147 -1.3877752 [25,] -1.2785563 13.6199147 [26,] -3.3265464 -1.2785563 [27,] 5.4435071 -3.3265464 [28,] 15.3719888 5.4435071 [29,] -5.2707478 15.3719888 [30,] 12.3099424 -5.2707478 [31,] -4.8167533 12.3099424 [32,] -1.5374332 -4.8167533 [33,] 0.2352140 -1.5374332 [34,] 1.1362943 0.2352140 [35,] 7.0556184 1.1362943 [36,] -0.7644455 7.0556184 [37,] -11.0571336 -0.7644455 [38,] -8.1131642 -11.0571336 [39,] -7.0446752 -8.1131642 [40,] -0.8004671 -7.0446752 [41,] -12.2923809 -0.8004671 [42,] -3.7752220 -12.2923809 [43,] -6.4709078 -3.7752220 [44,] -1.8467570 -6.4709078 [45,] 11.6672498 -1.8467570 [46,] -3.7745955 11.6672498 [47,] -2.0477768 -3.7745955 [48,] -4.3814727 -2.0477768 [49,] 0.3324382 -4.3814727 [50,] -0.6685924 0.3324382 [51,] -5.2592266 -0.6685924 [52,] -2.3247595 -5.2592266 [53,] 11.2667891 -2.3247595 [54,] 6.0707830 11.2667891 [55,] -3.4625834 6.0707830 [56,] 1.3537830 -3.4625834 [57,] 5.5826548 1.3537830 [58,] 4.5024232 5.5826548 [59,] -3.0411327 4.5024232 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 6.2593538 -10.3148771 2 9.3088810 6.2593538 3 0.2961017 9.3088810 4 -9.5181154 0.2961017 5 0.8638286 -9.5181154 6 -10.4464181 0.8638286 7 7.2696335 -10.4464181 8 -3.5189414 7.2696335 9 -10.7923562 -3.5189414 10 -2.6129541 -10.7923562 11 -0.5789336 -2.6129541 12 1.8408807 -0.5789336 13 5.7438979 1.8408807 14 2.7994220 5.7438979 15 6.5642930 2.7994220 16 -2.7286468 6.5642930 17 5.4325110 -2.7286468 18 -4.1590853 5.4325110 19 7.4806111 -4.1590853 20 5.5493486 7.4806111 21 -6.6927624 5.5493486 22 0.7488321 -6.6927624 23 -1.3877752 0.7488321 24 13.6199147 -1.3877752 25 -1.2785563 13.6199147 26 -3.3265464 -1.2785563 27 5.4435071 -3.3265464 28 15.3719888 5.4435071 29 -5.2707478 15.3719888 30 12.3099424 -5.2707478 31 -4.8167533 12.3099424 32 -1.5374332 -4.8167533 33 0.2352140 -1.5374332 34 1.1362943 0.2352140 35 7.0556184 1.1362943 36 -0.7644455 7.0556184 37 -11.0571336 -0.7644455 38 -8.1131642 -11.0571336 39 -7.0446752 -8.1131642 40 -0.8004671 -7.0446752 41 -12.2923809 -0.8004671 42 -3.7752220 -12.2923809 43 -6.4709078 -3.7752220 44 -1.8467570 -6.4709078 45 11.6672498 -1.8467570 46 -3.7745955 11.6672498 47 -2.0477768 -3.7745955 48 -4.3814727 -2.0477768 49 0.3324382 -4.3814727 50 -0.6685924 0.3324382 51 -5.2592266 -0.6685924 52 -2.3247595 -5.2592266 53 11.2667891 -2.3247595 54 6.0707830 11.2667891 55 -3.4625834 6.0707830 56 1.3537830 -3.4625834 57 5.5826548 1.3537830 58 4.5024232 5.5826548 59 -3.0411327 4.5024232 > 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/wessaorg/rcomp/tmp/7w59k1322332188.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/wessaorg/rcomp/tmp/846v41322332188.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/wessaorg/rcomp/tmp/9agt31322332188.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/wessaorg/rcomp/tmp/10ej6g1322332188.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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/11oacy1322332188.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/wessaorg/rcomp/tmp/12cum41322332188.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/wessaorg/rcomp/tmp/13d7wq1322332188.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/wessaorg/rcomp/tmp/14q3nm1322332188.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/wessaorg/rcomp/tmp/158x6d1322332188.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/wessaorg/rcomp/tmp/1632hd1322332188.tab") + } > > try(system("convert tmp/1z4lo1322332188.ps tmp/1z4lo1322332188.png",intern=TRUE)) character(0) > try(system("convert tmp/2txq21322332188.ps tmp/2txq21322332188.png",intern=TRUE)) character(0) > try(system("convert tmp/3253w1322332188.ps tmp/3253w1322332188.png",intern=TRUE)) character(0) > try(system("convert tmp/4a2in1322332188.ps tmp/4a2in1322332188.png",intern=TRUE)) character(0) > try(system("convert tmp/5rjkr1322332188.ps tmp/5rjkr1322332188.png",intern=TRUE)) character(0) > try(system("convert tmp/6cj7x1322332188.ps tmp/6cj7x1322332188.png",intern=TRUE)) character(0) > try(system("convert tmp/7w59k1322332188.ps tmp/7w59k1322332188.png",intern=TRUE)) character(0) > try(system("convert tmp/846v41322332188.ps tmp/846v41322332188.png",intern=TRUE)) character(0) > try(system("convert tmp/9agt31322332188.ps tmp/9agt31322332188.png",intern=TRUE)) character(0) > try(system("convert tmp/10ej6g1322332188.ps tmp/10ej6g1322332188.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.231 0.491 3.779