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(65.3,322.4,58.96,321.7,59.17,320.5,62.37,312.8,66.28,309.7,55.62,315.6,55.23,309.7,55.85,304.6,56.75,302.5,50.89,301.5,53.88,298.8,52.95,291.3,55.08,293.6,53.61,294.6,58.78,285.9,61.85,297.6,55.91,301.1,53.32,293.8,46.41,297.7,44.57,292.9,50,292.1,50,287.2,53.36,288.2,46.23,283.8,50.45,299.9,49.07,292.4,45.85,293.3,48.45,300.8,49.96,293.7,46.53,293.1,50.51,294.4,47.58,292.1,48.05,291.9,46.84,282.5,47.67,277.9,49.16,287.5,55.54,289.2,55.82,285.6,58.22,293.2,56.19,290.8,57.77,283.1,63.19,275,54.76,287.8,55.74,287.8,62.54,287.4,61.39,284,69.6,277.8,79.23,277.6,80,304.9,93.68,294,107.63,300.9,100.18,324,97.3,332.9,90.45,341.6,80.64,333.4,80.58,348.2,75.82,344.7,85.59,344.7,89.35,329.3,89.42,323.5,104.73,323.2,95.32,317.4,89.27,330.1,90.44,329.2,86.97,334.9,79.98,315.8,81.22,315.4,87.35,319.6,83.64,317.3,82.22,313.8,94.4,315.8,102.18,311.3),dim=c(2,72),dimnames=list(c('Colombia','USA'),1:72)) > y <- array(NA,dim=c(2,72),dimnames=list(c('Colombia','USA'),1:72)) > 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 = 'Do not include Seasonal Dummies' > par1 = '2' > 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 USA Colombia t 1 322.4 65.30 1 2 321.7 58.96 2 3 320.5 59.17 3 4 312.8 62.37 4 5 309.7 66.28 5 6 315.6 55.62 6 7 309.7 55.23 7 8 304.6 55.85 8 9 302.5 56.75 9 10 301.5 50.89 10 11 298.8 53.88 11 12 291.3 52.95 12 13 293.6 55.08 13 14 294.6 53.61 14 15 285.9 58.78 15 16 297.6 61.85 16 17 301.1 55.91 17 18 293.8 53.32 18 19 297.7 46.41 19 20 292.9 44.57 20 21 292.1 50.00 21 22 287.2 50.00 22 23 288.2 53.36 23 24 283.8 46.23 24 25 299.9 50.45 25 26 292.4 49.07 26 27 293.3 45.85 27 28 300.8 48.45 28 29 293.7 49.96 29 30 293.1 46.53 30 31 294.4 50.51 31 32 292.1 47.58 32 33 291.9 48.05 33 34 282.5 46.84 34 35 277.9 47.67 35 36 287.5 49.16 36 37 289.2 55.54 37 38 285.6 55.82 38 39 293.2 58.22 39 40 290.8 56.19 40 41 283.1 57.77 41 42 275.0 63.19 42 43 287.8 54.76 43 44 287.8 55.74 44 45 287.4 62.54 45 46 284.0 61.39 46 47 277.8 69.60 47 48 277.6 79.23 48 49 304.9 80.00 49 50 294.0 93.68 50 51 300.9 107.63 51 52 324.0 100.18 52 53 332.9 97.30 53 54 341.6 90.45 54 55 333.4 80.64 55 56 348.2 80.58 56 57 344.7 75.82 57 58 344.7 85.59 58 59 329.3 89.35 59 60 323.5 89.42 60 61 323.2 104.73 61 62 317.4 95.32 62 63 330.1 89.27 63 64 329.2 90.44 64 65 334.9 86.97 65 66 315.8 79.98 66 67 315.4 81.22 67 68 319.6 87.35 68 69 317.3 83.64 69 70 313.8 82.22 70 71 315.8 94.40 71 72 311.3 102.18 72 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) Colombia t 255.6220 0.8491 -0.2130 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -35.245 -6.063 0.631 6.046 36.843 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 255.6220 6.7222 38.026 < 2e-16 *** Colombia 0.8491 0.1369 6.201 3.61e-08 *** t -0.2130 0.1182 -1.802 0.0759 . --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 13.82 on 69 degrees of freedom Multiple R-squared: 0.4516, Adjusted R-squared: 0.4357 F-statistic: 28.41 on 2 and 69 DF, p-value: 9.971e-10 > 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,] 3.132188e-03 6.264376e-03 0.996867812 [2,] 5.599568e-04 1.119914e-03 0.999440043 [3,] 1.442859e-04 2.885718e-04 0.999855714 [4,] 1.742854e-05 3.485708e-05 0.999982571 [5,] 2.880858e-06 5.761716e-06 0.999997119 [6,] 3.968895e-07 7.937789e-07 0.999999603 [7,] 3.110966e-07 6.221933e-07 0.999999689 [8,] 1.621830e-07 3.243659e-07 0.999999838 [9,] 2.647971e-07 5.295943e-07 0.999999735 [10,] 4.458270e-08 8.916540e-08 0.999999955 [11,] 6.479162e-06 1.295832e-05 0.999993521 [12,] 7.990671e-05 1.598134e-04 0.999920093 [13,] 4.843498e-05 9.686996e-05 0.999951565 [14,] 8.275880e-05 1.655176e-04 0.999917241 [15,] 4.212452e-05 8.424904e-05 0.999957875 [16,] 2.212763e-05 4.425526e-05 0.999977872 [17,] 8.036013e-06 1.607203e-05 0.999991964 [18,] 3.381572e-06 6.763143e-06 0.999996618 [19,] 1.136017e-06 2.272034e-06 0.999998864 [20,] 1.402065e-05 2.804130e-05 0.999985979 [21,] 1.124013e-05 2.248026e-05 0.999988760 [22,] 1.078262e-05 2.156523e-05 0.999989217 [23,] 4.813905e-05 9.627810e-05 0.999951861 [24,] 3.652349e-05 7.304698e-05 0.999963477 [25,] 2.759084e-05 5.518167e-05 0.999972409 [26,] 2.176509e-05 4.353017e-05 0.999978235 [27,] 1.411840e-05 2.823679e-05 0.999985882 [28,] 8.926122e-06 1.785224e-05 0.999991074 [29,] 4.113027e-06 8.226053e-06 0.999995887 [30,] 2.398089e-06 4.796178e-06 0.999997602 [31,] 1.117347e-06 2.234694e-06 0.999998883 [32,] 4.951960e-07 9.903920e-07 0.999999505 [33,] 1.901509e-07 3.803018e-07 0.999999810 [34,] 1.060618e-07 2.121237e-07 0.999999894 [35,] 4.698371e-08 9.396743e-08 0.999999953 [36,] 1.960569e-08 3.921138e-08 0.999999980 [37,] 3.549716e-08 7.099432e-08 0.999999965 [38,] 1.681997e-08 3.363995e-08 0.999999983 [39,] 7.909352e-09 1.581870e-08 0.999999992 [40,] 3.711997e-09 7.423993e-09 0.999999996 [41,] 2.906624e-09 5.813248e-09 0.999999997 [42,] 4.114933e-08 8.229866e-08 0.999999959 [43,] 1.521695e-05 3.043391e-05 0.999984783 [44,] 9.394644e-04 1.878929e-03 0.999060536 [45,] 5.865270e-02 1.173054e-01 0.941347301 [46,] 3.970024e-01 7.940047e-01 0.602997640 [47,] 7.368227e-01 5.263546e-01 0.263177308 [48,] 8.825340e-01 2.349320e-01 0.117466017 [49,] 9.526327e-01 9.473466e-02 0.047367331 [50,] 9.818761e-01 3.624785e-02 0.018123926 [51,] 9.937232e-01 1.255357e-02 0.006276784 [52,] 9.961325e-01 7.734915e-03 0.003867457 [53,] 9.987756e-01 2.448703e-03 0.001224351 [54,] 9.970468e-01 5.906397e-03 0.002953198 [55,] 9.941677e-01 1.166462e-02 0.005832310 [56,] 9.883062e-01 2.338753e-02 0.011693766 [57,] 9.980856e-01 3.828799e-03 0.001914400 [58,] 9.947013e-01 1.059740e-02 0.005298700 [59,] 9.863646e-01 2.727089e-02 0.013635446 [60,] 9.976500e-01 4.699928e-03 0.002349964 [61,] 9.904113e-01 1.917731e-02 0.009588656 > postscript(file="/var/wessaorg/rcomp/tmp/1zvcg1321550677.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/26uoc1321550677.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/39itk1321550677.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/4k0jy1321550677.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/5sa2p1321550677.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 = 72 Frequency = 1 1 2 3 4 5 6 11.5452591 16.4415446 15.2762724 5.0722130 -1.1347024 14.0296637 7 8 9 10 11 12 8.6738473 3.2604471 0.6093010 4.7980218 -0.2277282 -6.7250345 13 14 15 16 17 18 -6.0205648 -3.5593611 -16.4361333 -7.1298107 1.6268376 -3.2609748 19 20 21 22 23 24 6.7192935 3.6946615 -1.5028748 -6.1898375 -7.8297518 -5.9626831 25 26 27 28 29 30 6.7671828 0.6519682 4.4990842 10.0044804 1.8353876 4.3608131 31 32 33 34 35 36 2.4944613 2.8953404 2.5093042 -5.6502563 -10.7419659 -2.1940768 37 38 39 40 41 42 -5.6982512 -9.3229598 -3.5477451 -4.0110494 -12.8395787 -25.3286240 43 44 45 46 47 48 -5.1577348 -5.7768083 -11.7376017 -13.9481077 -26.9061219 -35.0698478 49 50 51 52 53 54 -8.2106118 -30.5131634 -35.2449700 -5.6061916 5.9522329 20.6815556 55 56 57 58 59 60 21.0241929 36.0881758 36.8428946 28.7602958 10.3807444 4.7343452 61 62 63 64 65 66 -8.3522275 -5.9492274 12.1008211 10.4204200 19.2798092 6.3280049 67 68 69 70 71 72 5.0881672 4.2962660 5.3594374 3.2781865 -4.8507259 -15.7436302 > postscript(file="/var/wessaorg/rcomp/tmp/61dbu1321550677.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 = 72 Frequency = 1 lag(myerror, k = 1) myerror 0 11.5452591 NA 1 16.4415446 11.5452591 2 15.2762724 16.4415446 3 5.0722130 15.2762724 4 -1.1347024 5.0722130 5 14.0296637 -1.1347024 6 8.6738473 14.0296637 7 3.2604471 8.6738473 8 0.6093010 3.2604471 9 4.7980218 0.6093010 10 -0.2277282 4.7980218 11 -6.7250345 -0.2277282 12 -6.0205648 -6.7250345 13 -3.5593611 -6.0205648 14 -16.4361333 -3.5593611 15 -7.1298107 -16.4361333 16 1.6268376 -7.1298107 17 -3.2609748 1.6268376 18 6.7192935 -3.2609748 19 3.6946615 6.7192935 20 -1.5028748 3.6946615 21 -6.1898375 -1.5028748 22 -7.8297518 -6.1898375 23 -5.9626831 -7.8297518 24 6.7671828 -5.9626831 25 0.6519682 6.7671828 26 4.4990842 0.6519682 27 10.0044804 4.4990842 28 1.8353876 10.0044804 29 4.3608131 1.8353876 30 2.4944613 4.3608131 31 2.8953404 2.4944613 32 2.5093042 2.8953404 33 -5.6502563 2.5093042 34 -10.7419659 -5.6502563 35 -2.1940768 -10.7419659 36 -5.6982512 -2.1940768 37 -9.3229598 -5.6982512 38 -3.5477451 -9.3229598 39 -4.0110494 -3.5477451 40 -12.8395787 -4.0110494 41 -25.3286240 -12.8395787 42 -5.1577348 -25.3286240 43 -5.7768083 -5.1577348 44 -11.7376017 -5.7768083 45 -13.9481077 -11.7376017 46 -26.9061219 -13.9481077 47 -35.0698478 -26.9061219 48 -8.2106118 -35.0698478 49 -30.5131634 -8.2106118 50 -35.2449700 -30.5131634 51 -5.6061916 -35.2449700 52 5.9522329 -5.6061916 53 20.6815556 5.9522329 54 21.0241929 20.6815556 55 36.0881758 21.0241929 56 36.8428946 36.0881758 57 28.7602958 36.8428946 58 10.3807444 28.7602958 59 4.7343452 10.3807444 60 -8.3522275 4.7343452 61 -5.9492274 -8.3522275 62 12.1008211 -5.9492274 63 10.4204200 12.1008211 64 19.2798092 10.4204200 65 6.3280049 19.2798092 66 5.0881672 6.3280049 67 4.2962660 5.0881672 68 5.3594374 4.2962660 69 3.2781865 5.3594374 70 -4.8507259 3.2781865 71 -15.7436302 -4.8507259 72 NA -15.7436302 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 16.4415446 11.5452591 [2,] 15.2762724 16.4415446 [3,] 5.0722130 15.2762724 [4,] -1.1347024 5.0722130 [5,] 14.0296637 -1.1347024 [6,] 8.6738473 14.0296637 [7,] 3.2604471 8.6738473 [8,] 0.6093010 3.2604471 [9,] 4.7980218 0.6093010 [10,] -0.2277282 4.7980218 [11,] -6.7250345 -0.2277282 [12,] -6.0205648 -6.7250345 [13,] -3.5593611 -6.0205648 [14,] -16.4361333 -3.5593611 [15,] -7.1298107 -16.4361333 [16,] 1.6268376 -7.1298107 [17,] -3.2609748 1.6268376 [18,] 6.7192935 -3.2609748 [19,] 3.6946615 6.7192935 [20,] -1.5028748 3.6946615 [21,] -6.1898375 -1.5028748 [22,] -7.8297518 -6.1898375 [23,] -5.9626831 -7.8297518 [24,] 6.7671828 -5.9626831 [25,] 0.6519682 6.7671828 [26,] 4.4990842 0.6519682 [27,] 10.0044804 4.4990842 [28,] 1.8353876 10.0044804 [29,] 4.3608131 1.8353876 [30,] 2.4944613 4.3608131 [31,] 2.8953404 2.4944613 [32,] 2.5093042 2.8953404 [33,] -5.6502563 2.5093042 [34,] -10.7419659 -5.6502563 [35,] -2.1940768 -10.7419659 [36,] -5.6982512 -2.1940768 [37,] -9.3229598 -5.6982512 [38,] -3.5477451 -9.3229598 [39,] -4.0110494 -3.5477451 [40,] -12.8395787 -4.0110494 [41,] -25.3286240 -12.8395787 [42,] -5.1577348 -25.3286240 [43,] -5.7768083 -5.1577348 [44,] -11.7376017 -5.7768083 [45,] -13.9481077 -11.7376017 [46,] -26.9061219 -13.9481077 [47,] -35.0698478 -26.9061219 [48,] -8.2106118 -35.0698478 [49,] -30.5131634 -8.2106118 [50,] -35.2449700 -30.5131634 [51,] -5.6061916 -35.2449700 [52,] 5.9522329 -5.6061916 [53,] 20.6815556 5.9522329 [54,] 21.0241929 20.6815556 [55,] 36.0881758 21.0241929 [56,] 36.8428946 36.0881758 [57,] 28.7602958 36.8428946 [58,] 10.3807444 28.7602958 [59,] 4.7343452 10.3807444 [60,] -8.3522275 4.7343452 [61,] -5.9492274 -8.3522275 [62,] 12.1008211 -5.9492274 [63,] 10.4204200 12.1008211 [64,] 19.2798092 10.4204200 [65,] 6.3280049 19.2798092 [66,] 5.0881672 6.3280049 [67,] 4.2962660 5.0881672 [68,] 5.3594374 4.2962660 [69,] 3.2781865 5.3594374 [70,] -4.8507259 3.2781865 [71,] -15.7436302 -4.8507259 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 16.4415446 11.5452591 2 15.2762724 16.4415446 3 5.0722130 15.2762724 4 -1.1347024 5.0722130 5 14.0296637 -1.1347024 6 8.6738473 14.0296637 7 3.2604471 8.6738473 8 0.6093010 3.2604471 9 4.7980218 0.6093010 10 -0.2277282 4.7980218 11 -6.7250345 -0.2277282 12 -6.0205648 -6.7250345 13 -3.5593611 -6.0205648 14 -16.4361333 -3.5593611 15 -7.1298107 -16.4361333 16 1.6268376 -7.1298107 17 -3.2609748 1.6268376 18 6.7192935 -3.2609748 19 3.6946615 6.7192935 20 -1.5028748 3.6946615 21 -6.1898375 -1.5028748 22 -7.8297518 -6.1898375 23 -5.9626831 -7.8297518 24 6.7671828 -5.9626831 25 0.6519682 6.7671828 26 4.4990842 0.6519682 27 10.0044804 4.4990842 28 1.8353876 10.0044804 29 4.3608131 1.8353876 30 2.4944613 4.3608131 31 2.8953404 2.4944613 32 2.5093042 2.8953404 33 -5.6502563 2.5093042 34 -10.7419659 -5.6502563 35 -2.1940768 -10.7419659 36 -5.6982512 -2.1940768 37 -9.3229598 -5.6982512 38 -3.5477451 -9.3229598 39 -4.0110494 -3.5477451 40 -12.8395787 -4.0110494 41 -25.3286240 -12.8395787 42 -5.1577348 -25.3286240 43 -5.7768083 -5.1577348 44 -11.7376017 -5.7768083 45 -13.9481077 -11.7376017 46 -26.9061219 -13.9481077 47 -35.0698478 -26.9061219 48 -8.2106118 -35.0698478 49 -30.5131634 -8.2106118 50 -35.2449700 -30.5131634 51 -5.6061916 -35.2449700 52 5.9522329 -5.6061916 53 20.6815556 5.9522329 54 21.0241929 20.6815556 55 36.0881758 21.0241929 56 36.8428946 36.0881758 57 28.7602958 36.8428946 58 10.3807444 28.7602958 59 4.7343452 10.3807444 60 -8.3522275 4.7343452 61 -5.9492274 -8.3522275 62 12.1008211 -5.9492274 63 10.4204200 12.1008211 64 19.2798092 10.4204200 65 6.3280049 19.2798092 66 5.0881672 6.3280049 67 4.2962660 5.0881672 68 5.3594374 4.2962660 69 3.2781865 5.3594374 70 -4.8507259 3.2781865 71 -15.7436302 -4.8507259 > 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/7lruo1321550677.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/8rnyr1321550677.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/9ja8q1321550677.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/105w3f1321550677.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/11fwz01321550677.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/12wjyp1321550677.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/13u0fv1321550677.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/14dqqz1321550677.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/15hko91321550677.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/168n1r1321550677.tab") + } > > try(system("convert tmp/1zvcg1321550677.ps tmp/1zvcg1321550677.png",intern=TRUE)) character(0) > try(system("convert tmp/26uoc1321550677.ps tmp/26uoc1321550677.png",intern=TRUE)) character(0) > try(system("convert tmp/39itk1321550677.ps tmp/39itk1321550677.png",intern=TRUE)) character(0) > try(system("convert tmp/4k0jy1321550677.ps tmp/4k0jy1321550677.png",intern=TRUE)) character(0) > try(system("convert tmp/5sa2p1321550677.ps tmp/5sa2p1321550677.png",intern=TRUE)) character(0) > try(system("convert tmp/61dbu1321550677.ps tmp/61dbu1321550677.png",intern=TRUE)) character(0) > try(system("convert tmp/7lruo1321550677.ps tmp/7lruo1321550677.png",intern=TRUE)) character(0) > try(system("convert tmp/8rnyr1321550677.ps tmp/8rnyr1321550677.png",intern=TRUE)) character(0) > try(system("convert tmp/9ja8q1321550677.ps tmp/9ja8q1321550677.png",intern=TRUE)) character(0) > try(system("convert tmp/105w3f1321550677.ps tmp/105w3f1321550677.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.171 0.478 3.670