R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-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(9769,9321,9939,9336,10195,9464,10010,10213,9563,9890,9305,9391,9928,8686,9843,9627,10074,9503,10119,10000,9313,9866,9172,9241,9659,8904,9755,9080,9435,8971,10063,9793,9454,9759,8820,9403,9676,8642,9402,9610,9294,9448,10319,9548,9801,9596,8923,9746,9829,9125,9782,9441,9162,9915,10444,10209,9985,9842,9429,10132,9849,9172,10313,9819,9955,10048,10082,10541,10208,10233,9439,9963,10158,9225,10474,9757,10490,10281,10444,10640,10695,10786,9832,9747,10411,9511,10402,9701,10540,10112,10915,11183,10384,10834,9886,10216,10943,9867,10203,10837,10573,10647,11502,10656,10866,10835,9945,10331,10718,9462,10579,10633,10346,10757,11207,11013,11015,10765,10042,10661),dim=c(1,120),dimnames=list(c(''),1:120)) > y <- array(NA,dim=c(1,120),dimnames=list(c(''),1:120)) > 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 Attaching package: 'zoo' The following object(s) are masked from 'package:base': as.Date, as.Date.numeric > 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 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 9769 1 0 0 0 0 0 0 0 0 0 0 1 2 9321 0 1 0 0 0 0 0 0 0 0 0 2 3 9939 0 0 1 0 0 0 0 0 0 0 0 3 4 9336 0 0 0 1 0 0 0 0 0 0 0 4 5 10195 0 0 0 0 1 0 0 0 0 0 0 5 6 9464 0 0 0 0 0 1 0 0 0 0 0 6 7 10010 0 0 0 0 0 0 1 0 0 0 0 7 8 10213 0 0 0 0 0 0 0 1 0 0 0 8 9 9563 0 0 0 0 0 0 0 0 1 0 0 9 10 9890 0 0 0 0 0 0 0 0 0 1 0 10 11 9305 0 0 0 0 0 0 0 0 0 0 1 11 12 9391 0 0 0 0 0 0 0 0 0 0 0 12 13 9928 1 0 0 0 0 0 0 0 0 0 0 13 14 8686 0 1 0 0 0 0 0 0 0 0 0 14 15 9843 0 0 1 0 0 0 0 0 0 0 0 15 16 9627 0 0 0 1 0 0 0 0 0 0 0 16 17 10074 0 0 0 0 1 0 0 0 0 0 0 17 18 9503 0 0 0 0 0 1 0 0 0 0 0 18 19 10119 0 0 0 0 0 0 1 0 0 0 0 19 20 10000 0 0 0 0 0 0 0 1 0 0 0 20 21 9313 0 0 0 0 0 0 0 0 1 0 0 21 22 9866 0 0 0 0 0 0 0 0 0 1 0 22 23 9172 0 0 0 0 0 0 0 0 0 0 1 23 24 9241 0 0 0 0 0 0 0 0 0 0 0 24 25 9659 1 0 0 0 0 0 0 0 0 0 0 25 26 8904 0 1 0 0 0 0 0 0 0 0 0 26 27 9755 0 0 1 0 0 0 0 0 0 0 0 27 28 9080 0 0 0 1 0 0 0 0 0 0 0 28 29 9435 0 0 0 0 1 0 0 0 0 0 0 29 30 8971 0 0 0 0 0 1 0 0 0 0 0 30 31 10063 0 0 0 0 0 0 1 0 0 0 0 31 32 9793 0 0 0 0 0 0 0 1 0 0 0 32 33 9454 0 0 0 0 0 0 0 0 1 0 0 33 34 9759 0 0 0 0 0 0 0 0 0 1 0 34 35 8820 0 0 0 0 0 0 0 0 0 0 1 35 36 9403 0 0 0 0 0 0 0 0 0 0 0 36 37 9676 1 0 0 0 0 0 0 0 0 0 0 37 38 8642 0 1 0 0 0 0 0 0 0 0 0 38 39 9402 0 0 1 0 0 0 0 0 0 0 0 39 40 9610 0 0 0 1 0 0 0 0 0 0 0 40 41 9294 0 0 0 0 1 0 0 0 0 0 0 41 42 9448 0 0 0 0 0 1 0 0 0 0 0 42 43 10319 0 0 0 0 0 0 1 0 0 0 0 43 44 9548 0 0 0 0 0 0 0 1 0 0 0 44 45 9801 0 0 0 0 0 0 0 0 1 0 0 45 46 9596 0 0 0 0 0 0 0 0 0 1 0 46 47 8923 0 0 0 0 0 0 0 0 0 0 1 47 48 9746 0 0 0 0 0 0 0 0 0 0 0 48 49 9829 1 0 0 0 0 0 0 0 0 0 0 49 50 9125 0 1 0 0 0 0 0 0 0 0 0 50 51 9782 0 0 1 0 0 0 0 0 0 0 0 51 52 9441 0 0 0 1 0 0 0 0 0 0 0 52 53 9162 0 0 0 0 1 0 0 0 0 0 0 53 54 9915 0 0 0 0 0 1 0 0 0 0 0 54 55 10444 0 0 0 0 0 0 1 0 0 0 0 55 56 10209 0 0 0 0 0 0 0 1 0 0 0 56 57 9985 0 0 0 0 0 0 0 0 1 0 0 57 58 9842 0 0 0 0 0 0 0 0 0 1 0 58 59 9429 0 0 0 0 0 0 0 0 0 0 1 59 60 10132 0 0 0 0 0 0 0 0 0 0 0 60 61 9849 1 0 0 0 0 0 0 0 0 0 0 61 62 9172 0 1 0 0 0 0 0 0 0 0 0 62 63 10313 0 0 1 0 0 0 0 0 0 0 0 63 64 9819 0 0 0 1 0 0 0 0 0 0 0 64 65 9955 0 0 0 0 1 0 0 0 0 0 0 65 66 10048 0 0 0 0 0 1 0 0 0 0 0 66 67 10082 0 0 0 0 0 0 1 0 0 0 0 67 68 10541 0 0 0 0 0 0 0 1 0 0 0 68 69 10208 0 0 0 0 0 0 0 0 1 0 0 69 70 10233 0 0 0 0 0 0 0 0 0 1 0 70 71 9439 0 0 0 0 0 0 0 0 0 0 1 71 72 9963 0 0 0 0 0 0 0 0 0 0 0 72 73 10158 1 0 0 0 0 0 0 0 0 0 0 73 74 9225 0 1 0 0 0 0 0 0 0 0 0 74 75 10474 0 0 1 0 0 0 0 0 0 0 0 75 76 9757 0 0 0 1 0 0 0 0 0 0 0 76 77 10490 0 0 0 0 1 0 0 0 0 0 0 77 78 10281 0 0 0 0 0 1 0 0 0 0 0 78 79 10444 0 0 0 0 0 0 1 0 0 0 0 79 80 10640 0 0 0 0 0 0 0 1 0 0 0 80 81 10695 0 0 0 0 0 0 0 0 1 0 0 81 82 10786 0 0 0 0 0 0 0 0 0 1 0 82 83 9832 0 0 0 0 0 0 0 0 0 0 1 83 84 9747 0 0 0 0 0 0 0 0 0 0 0 84 85 10411 1 0 0 0 0 0 0 0 0 0 0 85 86 9511 0 1 0 0 0 0 0 0 0 0 0 86 87 10402 0 0 1 0 0 0 0 0 0 0 0 87 88 9701 0 0 0 1 0 0 0 0 0 0 0 88 89 10540 0 0 0 0 1 0 0 0 0 0 0 89 90 10112 0 0 0 0 0 1 0 0 0 0 0 90 91 10915 0 0 0 0 0 0 1 0 0 0 0 91 92 11183 0 0 0 0 0 0 0 1 0 0 0 92 93 10384 0 0 0 0 0 0 0 0 1 0 0 93 94 10834 0 0 0 0 0 0 0 0 0 1 0 94 95 9886 0 0 0 0 0 0 0 0 0 0 1 95 96 10216 0 0 0 0 0 0 0 0 0 0 0 96 97 10943 1 0 0 0 0 0 0 0 0 0 0 97 98 9867 0 1 0 0 0 0 0 0 0 0 0 98 99 10203 0 0 1 0 0 0 0 0 0 0 0 99 100 10837 0 0 0 1 0 0 0 0 0 0 0 100 101 10573 0 0 0 0 1 0 0 0 0 0 0 101 102 10647 0 0 0 0 0 1 0 0 0 0 0 102 103 11502 0 0 0 0 0 0 1 0 0 0 0 103 104 10656 0 0 0 0 0 0 0 1 0 0 0 104 105 10866 0 0 0 0 0 0 0 0 1 0 0 105 106 10835 0 0 0 0 0 0 0 0 0 1 0 106 107 9945 0 0 0 0 0 0 0 0 0 0 1 107 108 10331 0 0 0 0 0 0 0 0 0 0 0 108 109 10718 1 0 0 0 0 0 0 0 0 0 0 109 110 9462 0 1 0 0 0 0 0 0 0 0 0 110 111 10579 0 0 1 0 0 0 0 0 0 0 0 111 112 10633 0 0 0 1 0 0 0 0 0 0 0 112 113 10346 0 0 0 0 1 0 0 0 0 0 0 113 114 10757 0 0 0 0 0 1 0 0 0 0 0 114 115 11207 0 0 0 0 0 0 1 0 0 0 0 115 116 11013 0 0 0 0 0 0 0 1 0 0 0 116 117 11015 0 0 0 0 0 0 0 0 1 0 0 117 118 10765 0 0 0 0 0 0 0 0 0 1 0 118 119 10042 0 0 0 0 0 0 0 0 0 0 1 119 120 10661 0 0 0 0 0 0 0 0 0 0 0 120 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) M1 M2 M3 M4 M5 9152.70 332.63 -580.93 285.70 -10.47 200.77 M6 M7 M8 M9 M10 M11 97.90 682.73 540.77 278.50 379.63 -392.73 t 11.07 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -778.00 -180.08 10.45 169.75 786.20 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 9152.7028 106.5971 85.863 < 2e-16 *** M1 332.6329 132.2155 2.516 0.01336 * M2 -580.9338 132.1670 -4.395 2.61e-05 *** M3 285.6996 132.1231 2.162 0.03282 * M4 -10.4670 132.0838 -0.079 0.93699 M5 200.7664 132.0491 1.520 0.13136 M6 97.8997 132.0191 0.742 0.45998 M7 682.7331 131.9936 5.172 1.09e-06 *** M8 540.7665 131.9728 4.098 8.15e-05 *** M9 278.4999 131.9566 2.111 0.03714 * M10 379.6332 131.9450 2.877 0.00484 ** M11 -392.7334 131.9381 -2.977 0.00360 ** t 11.0666 0.7814 14.163 < 2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 295 on 107 degrees of freedom Multiple R-squared: 0.7758, Adjusted R-squared: 0.7507 F-statistic: 30.86 on 12 and 107 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.71427936 0.57144129 0.28572064 [2,] 0.62743573 0.74512854 0.37256427 [3,] 0.50422804 0.99154393 0.49577196 [4,] 0.40772904 0.81545808 0.59227096 [5,] 0.33245657 0.66491314 0.66754343 [6,] 0.26519542 0.53039084 0.73480458 [7,] 0.19422346 0.38844692 0.80577654 [8,] 0.14633280 0.29266560 0.85366720 [9,] 0.09737182 0.19474364 0.90262818 [10,] 0.06376494 0.12752989 0.93623506 [11,] 0.04352503 0.08705006 0.95647497 [12,] 0.02876026 0.05752053 0.97123974 [13,] 0.03072564 0.06145127 0.96927436 [14,] 0.10761081 0.21522162 0.89238919 [15,] 0.12520529 0.25041058 0.87479471 [16,] 0.11801013 0.23602026 0.88198987 [17,] 0.08602372 0.17204743 0.91397628 [18,] 0.08368378 0.16736757 0.91631622 [19,] 0.06168733 0.12337466 0.93831267 [20,] 0.05209251 0.10418501 0.94790749 [21,] 0.05648991 0.11297981 0.94351009 [22,] 0.04448909 0.08897817 0.95551091 [23,] 0.03126390 0.06252779 0.96873610 [24,] 0.02666552 0.05333104 0.97333448 [25,] 0.07536645 0.15073291 0.92463355 [26,] 0.09542522 0.19085044 0.90457478 [27,] 0.12219936 0.24439872 0.87780064 [28,] 0.18319800 0.36639600 0.81680200 [29,] 0.21668630 0.43337261 0.78331370 [30,] 0.32512957 0.65025915 0.67487043 [31,] 0.29998667 0.59997334 0.70001333 [32,] 0.26106548 0.52213096 0.73893452 [33,] 0.37558312 0.75116625 0.62441688 [34,] 0.35325013 0.70650026 0.64674987 [35,] 0.38699758 0.77399517 0.61300242 [36,] 0.34889174 0.69778347 0.65110826 [37,] 0.31509835 0.63019669 0.68490165 [38,] 0.52000849 0.95998301 0.47999151 [39,] 0.66959224 0.66081551 0.33040776 [40,] 0.68218209 0.63563582 0.31781791 [41,] 0.68665358 0.62669284 0.31334642 [42,] 0.72370854 0.55258292 0.27629146 [43,] 0.72240033 0.55519935 0.27759967 [44,] 0.72076586 0.55846827 0.27923414 [45,] 0.84147554 0.31704893 0.15852446 [46,] 0.82836951 0.34326097 0.17163049 [47,] 0.79923722 0.40152557 0.20076278 [48,] 0.83971939 0.32056123 0.16028061 [49,] 0.82230954 0.35538091 0.17769046 [50,] 0.79701596 0.40596807 0.20298404 [51,] 0.80030648 0.39938704 0.19969352 [52,] 0.84969621 0.30060758 0.15030379 [53,] 0.84856711 0.30286578 0.15143289 [54,] 0.84819676 0.30360648 0.15180324 [55,] 0.83528016 0.32943967 0.16471984 [56,] 0.80402368 0.39195263 0.19597632 [57,] 0.76936636 0.46126728 0.23063364 [58,] 0.74846510 0.50306980 0.25153490 [59,] 0.70234161 0.59531677 0.29765839 [60,] 0.73008293 0.53983414 0.26991707 [61,] 0.72663567 0.54672867 0.27336433 [62,] 0.75830737 0.48338525 0.24169263 [63,] 0.74241838 0.51516324 0.25758162 [64,] 0.78430352 0.43139297 0.21569648 [65,] 0.74984331 0.50031338 0.25015669 [66,] 0.77640810 0.44718380 0.22359190 [67,] 0.79359388 0.41281224 0.20640612 [68,] 0.76523491 0.46953019 0.23476509 [69,] 0.77340665 0.45318671 0.22659335 [70,] 0.74281910 0.51436179 0.25718090 [71,] 0.68382339 0.63235321 0.31617661 [72,] 0.63544685 0.72910630 0.36455315 [73,] 0.89163823 0.21672353 0.10836177 [74,] 0.87624040 0.24751921 0.12375960 [75,] 0.91001570 0.17996860 0.08998430 [76,] 0.92048478 0.15903043 0.07951522 [77,] 0.95588465 0.08823070 0.04411535 [78,] 0.97927869 0.04144262 0.02072131 [79,] 0.96865702 0.06268597 0.03134298 [80,] 0.94834066 0.10331869 0.05165934 [81,] 0.93978929 0.12042141 0.06021071 [82,] 0.92830763 0.14338474 0.07169237 [83,] 0.95301617 0.09396765 0.04698383 [84,] 0.95546620 0.08906760 0.04453380 [85,] 0.95059261 0.09881478 0.04940739 [86,] 0.94732620 0.10534760 0.05267380 [87,] 0.89460795 0.21078410 0.10539205 [88,] 0.95744886 0.08510228 0.04255114 [89,] 0.93443045 0.13113910 0.06556955 > postscript(file="/var/wessaorg/rcomp/tmp/1b6cw1354653195.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/2fu4z1354653195.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/346e21354653195.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/401vb1354653195.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/5v1nd1354653195.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 = 120 Frequency = 1 1 2 3 4 5 6 272.5977273 727.0977273 467.3977273 149.4977273 786.1977273 146.9977273 7 8 9 10 11 12 97.0977273 430.9977273 32.1977273 246.9977273 423.2977273 105.4977273 13 14 15 16 17 18 298.7982323 -40.7017677 238.5982323 307.6982323 532.3982323 53.1982323 19 20 21 22 23 24 73.2982323 85.1982323 -350.6017677 90.1982323 157.4982323 -177.3017677 25 26 27 28 29 30 -103.0012626 44.4987374 17.7987374 -372.1012626 -239.4012626 -611.6012626 31 32 33 34 35 36 -115.5012626 -254.6012626 -342.4012626 -149.6012626 -327.3012626 -148.1012626 37 38 39 40 41 42 -218.8007576 -350.3007576 -468.0007576 25.0992424 -513.2007576 -267.4007576 43 44 45 46 47 48 7.6992424 -632.4007576 -128.2007576 -445.4007576 -357.1007576 62.0992424 49 50 51 52 53 54 -198.6002525 -0.1002525 -220.8002525 -276.7002525 -778.0002525 66.7997475 55 56 57 58 59 60 -0.1002525 -104.2002525 -77.0002525 -332.2002525 16.0997475 315.2997475 61 62 63 64 65 66 -311.3997475 -85.8997475 177.4002525 -31.4997475 -117.7997475 67.0002525 67 68 69 70 71 72 -494.8997475 95.0002525 13.2002525 -73.9997475 -106.6997475 13.5002525 73 74 75 76 77 78 -135.1992424 -165.6992424 205.6007576 -226.2992424 284.4007576 167.2007576 79 80 81 82 83 84 -265.6992424 61.2007576 367.4007576 346.2007576 153.5007576 -335.2992424 85 86 87 88 89 90 -14.9987374 -12.4987374 0.8012626 -415.0987374 201.6012626 -134.5987374 91 92 93 94 95 96 72.5012626 471.4012626 -76.3987374 261.4012626 74.7012626 0.9012626 97 98 99 100 101 102 384.2017677 210.7017677 -330.9982323 588.1017677 101.8017677 267.6017677 103 104 105 106 107 108 526.7017677 -188.3982323 272.8017677 129.6017677 0.9017677 -16.8982323 109 110 111 112 113 114 26.4022727 -327.0977273 -87.7977273 251.3022727 -257.9977273 244.8022727 115 116 117 118 119 120 98.9022727 35.8022727 289.0022727 -73.1977273 -34.8977273 180.3022727 > postscript(file="/var/wessaorg/rcomp/tmp/6dagh1354653195.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 = 120 Frequency = 1 lag(myerror, k = 1) myerror 0 272.5977273 NA 1 727.0977273 272.5977273 2 467.3977273 727.0977273 3 149.4977273 467.3977273 4 786.1977273 149.4977273 5 146.9977273 786.1977273 6 97.0977273 146.9977273 7 430.9977273 97.0977273 8 32.1977273 430.9977273 9 246.9977273 32.1977273 10 423.2977273 246.9977273 11 105.4977273 423.2977273 12 298.7982323 105.4977273 13 -40.7017677 298.7982323 14 238.5982323 -40.7017677 15 307.6982323 238.5982323 16 532.3982323 307.6982323 17 53.1982323 532.3982323 18 73.2982323 53.1982323 19 85.1982323 73.2982323 20 -350.6017677 85.1982323 21 90.1982323 -350.6017677 22 157.4982323 90.1982323 23 -177.3017677 157.4982323 24 -103.0012626 -177.3017677 25 44.4987374 -103.0012626 26 17.7987374 44.4987374 27 -372.1012626 17.7987374 28 -239.4012626 -372.1012626 29 -611.6012626 -239.4012626 30 -115.5012626 -611.6012626 31 -254.6012626 -115.5012626 32 -342.4012626 -254.6012626 33 -149.6012626 -342.4012626 34 -327.3012626 -149.6012626 35 -148.1012626 -327.3012626 36 -218.8007576 -148.1012626 37 -350.3007576 -218.8007576 38 -468.0007576 -350.3007576 39 25.0992424 -468.0007576 40 -513.2007576 25.0992424 41 -267.4007576 -513.2007576 42 7.6992424 -267.4007576 43 -632.4007576 7.6992424 44 -128.2007576 -632.4007576 45 -445.4007576 -128.2007576 46 -357.1007576 -445.4007576 47 62.0992424 -357.1007576 48 -198.6002525 62.0992424 49 -0.1002525 -198.6002525 50 -220.8002525 -0.1002525 51 -276.7002525 -220.8002525 52 -778.0002525 -276.7002525 53 66.7997475 -778.0002525 54 -0.1002525 66.7997475 55 -104.2002525 -0.1002525 56 -77.0002525 -104.2002525 57 -332.2002525 -77.0002525 58 16.0997475 -332.2002525 59 315.2997475 16.0997475 60 -311.3997475 315.2997475 61 -85.8997475 -311.3997475 62 177.4002525 -85.8997475 63 -31.4997475 177.4002525 64 -117.7997475 -31.4997475 65 67.0002525 -117.7997475 66 -494.8997475 67.0002525 67 95.0002525 -494.8997475 68 13.2002525 95.0002525 69 -73.9997475 13.2002525 70 -106.6997475 -73.9997475 71 13.5002525 -106.6997475 72 -135.1992424 13.5002525 73 -165.6992424 -135.1992424 74 205.6007576 -165.6992424 75 -226.2992424 205.6007576 76 284.4007576 -226.2992424 77 167.2007576 284.4007576 78 -265.6992424 167.2007576 79 61.2007576 -265.6992424 80 367.4007576 61.2007576 81 346.2007576 367.4007576 82 153.5007576 346.2007576 83 -335.2992424 153.5007576 84 -14.9987374 -335.2992424 85 -12.4987374 -14.9987374 86 0.8012626 -12.4987374 87 -415.0987374 0.8012626 88 201.6012626 -415.0987374 89 -134.5987374 201.6012626 90 72.5012626 -134.5987374 91 471.4012626 72.5012626 92 -76.3987374 471.4012626 93 261.4012626 -76.3987374 94 74.7012626 261.4012626 95 0.9012626 74.7012626 96 384.2017677 0.9012626 97 210.7017677 384.2017677 98 -330.9982323 210.7017677 99 588.1017677 -330.9982323 100 101.8017677 588.1017677 101 267.6017677 101.8017677 102 526.7017677 267.6017677 103 -188.3982323 526.7017677 104 272.8017677 -188.3982323 105 129.6017677 272.8017677 106 0.9017677 129.6017677 107 -16.8982323 0.9017677 108 26.4022727 -16.8982323 109 -327.0977273 26.4022727 110 -87.7977273 -327.0977273 111 251.3022727 -87.7977273 112 -257.9977273 251.3022727 113 244.8022727 -257.9977273 114 98.9022727 244.8022727 115 35.8022727 98.9022727 116 289.0022727 35.8022727 117 -73.1977273 289.0022727 118 -34.8977273 -73.1977273 119 180.3022727 -34.8977273 120 NA 180.3022727 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 727.0977273 272.5977273 [2,] 467.3977273 727.0977273 [3,] 149.4977273 467.3977273 [4,] 786.1977273 149.4977273 [5,] 146.9977273 786.1977273 [6,] 97.0977273 146.9977273 [7,] 430.9977273 97.0977273 [8,] 32.1977273 430.9977273 [9,] 246.9977273 32.1977273 [10,] 423.2977273 246.9977273 [11,] 105.4977273 423.2977273 [12,] 298.7982323 105.4977273 [13,] -40.7017677 298.7982323 [14,] 238.5982323 -40.7017677 [15,] 307.6982323 238.5982323 [16,] 532.3982323 307.6982323 [17,] 53.1982323 532.3982323 [18,] 73.2982323 53.1982323 [19,] 85.1982323 73.2982323 [20,] -350.6017677 85.1982323 [21,] 90.1982323 -350.6017677 [22,] 157.4982323 90.1982323 [23,] -177.3017677 157.4982323 [24,] -103.0012626 -177.3017677 [25,] 44.4987374 -103.0012626 [26,] 17.7987374 44.4987374 [27,] -372.1012626 17.7987374 [28,] -239.4012626 -372.1012626 [29,] -611.6012626 -239.4012626 [30,] -115.5012626 -611.6012626 [31,] -254.6012626 -115.5012626 [32,] -342.4012626 -254.6012626 [33,] -149.6012626 -342.4012626 [34,] -327.3012626 -149.6012626 [35,] -148.1012626 -327.3012626 [36,] -218.8007576 -148.1012626 [37,] -350.3007576 -218.8007576 [38,] -468.0007576 -350.3007576 [39,] 25.0992424 -468.0007576 [40,] -513.2007576 25.0992424 [41,] -267.4007576 -513.2007576 [42,] 7.6992424 -267.4007576 [43,] -632.4007576 7.6992424 [44,] -128.2007576 -632.4007576 [45,] -445.4007576 -128.2007576 [46,] -357.1007576 -445.4007576 [47,] 62.0992424 -357.1007576 [48,] -198.6002525 62.0992424 [49,] -0.1002525 -198.6002525 [50,] -220.8002525 -0.1002525 [51,] -276.7002525 -220.8002525 [52,] -778.0002525 -276.7002525 [53,] 66.7997475 -778.0002525 [54,] -0.1002525 66.7997475 [55,] -104.2002525 -0.1002525 [56,] -77.0002525 -104.2002525 [57,] -332.2002525 -77.0002525 [58,] 16.0997475 -332.2002525 [59,] 315.2997475 16.0997475 [60,] -311.3997475 315.2997475 [61,] -85.8997475 -311.3997475 [62,] 177.4002525 -85.8997475 [63,] -31.4997475 177.4002525 [64,] -117.7997475 -31.4997475 [65,] 67.0002525 -117.7997475 [66,] -494.8997475 67.0002525 [67,] 95.0002525 -494.8997475 [68,] 13.2002525 95.0002525 [69,] -73.9997475 13.2002525 [70,] -106.6997475 -73.9997475 [71,] 13.5002525 -106.6997475 [72,] -135.1992424 13.5002525 [73,] -165.6992424 -135.1992424 [74,] 205.6007576 -165.6992424 [75,] -226.2992424 205.6007576 [76,] 284.4007576 -226.2992424 [77,] 167.2007576 284.4007576 [78,] -265.6992424 167.2007576 [79,] 61.2007576 -265.6992424 [80,] 367.4007576 61.2007576 [81,] 346.2007576 367.4007576 [82,] 153.5007576 346.2007576 [83,] -335.2992424 153.5007576 [84,] -14.9987374 -335.2992424 [85,] -12.4987374 -14.9987374 [86,] 0.8012626 -12.4987374 [87,] -415.0987374 0.8012626 [88,] 201.6012626 -415.0987374 [89,] -134.5987374 201.6012626 [90,] 72.5012626 -134.5987374 [91,] 471.4012626 72.5012626 [92,] -76.3987374 471.4012626 [93,] 261.4012626 -76.3987374 [94,] 74.7012626 261.4012626 [95,] 0.9012626 74.7012626 [96,] 384.2017677 0.9012626 [97,] 210.7017677 384.2017677 [98,] -330.9982323 210.7017677 [99,] 588.1017677 -330.9982323 [100,] 101.8017677 588.1017677 [101,] 267.6017677 101.8017677 [102,] 526.7017677 267.6017677 [103,] -188.3982323 526.7017677 [104,] 272.8017677 -188.3982323 [105,] 129.6017677 272.8017677 [106,] 0.9017677 129.6017677 [107,] -16.8982323 0.9017677 [108,] 26.4022727 -16.8982323 [109,] -327.0977273 26.4022727 [110,] -87.7977273 -327.0977273 [111,] 251.3022727 -87.7977273 [112,] -257.9977273 251.3022727 [113,] 244.8022727 -257.9977273 [114,] 98.9022727 244.8022727 [115,] 35.8022727 98.9022727 [116,] 289.0022727 35.8022727 [117,] -73.1977273 289.0022727 [118,] -34.8977273 -73.1977273 [119,] 180.3022727 -34.8977273 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 727.0977273 272.5977273 2 467.3977273 727.0977273 3 149.4977273 467.3977273 4 786.1977273 149.4977273 5 146.9977273 786.1977273 6 97.0977273 146.9977273 7 430.9977273 97.0977273 8 32.1977273 430.9977273 9 246.9977273 32.1977273 10 423.2977273 246.9977273 11 105.4977273 423.2977273 12 298.7982323 105.4977273 13 -40.7017677 298.7982323 14 238.5982323 -40.7017677 15 307.6982323 238.5982323 16 532.3982323 307.6982323 17 53.1982323 532.3982323 18 73.2982323 53.1982323 19 85.1982323 73.2982323 20 -350.6017677 85.1982323 21 90.1982323 -350.6017677 22 157.4982323 90.1982323 23 -177.3017677 157.4982323 24 -103.0012626 -177.3017677 25 44.4987374 -103.0012626 26 17.7987374 44.4987374 27 -372.1012626 17.7987374 28 -239.4012626 -372.1012626 29 -611.6012626 -239.4012626 30 -115.5012626 -611.6012626 31 -254.6012626 -115.5012626 32 -342.4012626 -254.6012626 33 -149.6012626 -342.4012626 34 -327.3012626 -149.6012626 35 -148.1012626 -327.3012626 36 -218.8007576 -148.1012626 37 -350.3007576 -218.8007576 38 -468.0007576 -350.3007576 39 25.0992424 -468.0007576 40 -513.2007576 25.0992424 41 -267.4007576 -513.2007576 42 7.6992424 -267.4007576 43 -632.4007576 7.6992424 44 -128.2007576 -632.4007576 45 -445.4007576 -128.2007576 46 -357.1007576 -445.4007576 47 62.0992424 -357.1007576 48 -198.6002525 62.0992424 49 -0.1002525 -198.6002525 50 -220.8002525 -0.1002525 51 -276.7002525 -220.8002525 52 -778.0002525 -276.7002525 53 66.7997475 -778.0002525 54 -0.1002525 66.7997475 55 -104.2002525 -0.1002525 56 -77.0002525 -104.2002525 57 -332.2002525 -77.0002525 58 16.0997475 -332.2002525 59 315.2997475 16.0997475 60 -311.3997475 315.2997475 61 -85.8997475 -311.3997475 62 177.4002525 -85.8997475 63 -31.4997475 177.4002525 64 -117.7997475 -31.4997475 65 67.0002525 -117.7997475 66 -494.8997475 67.0002525 67 95.0002525 -494.8997475 68 13.2002525 95.0002525 69 -73.9997475 13.2002525 70 -106.6997475 -73.9997475 71 13.5002525 -106.6997475 72 -135.1992424 13.5002525 73 -165.6992424 -135.1992424 74 205.6007576 -165.6992424 75 -226.2992424 205.6007576 76 284.4007576 -226.2992424 77 167.2007576 284.4007576 78 -265.6992424 167.2007576 79 61.2007576 -265.6992424 80 367.4007576 61.2007576 81 346.2007576 367.4007576 82 153.5007576 346.2007576 83 -335.2992424 153.5007576 84 -14.9987374 -335.2992424 85 -12.4987374 -14.9987374 86 0.8012626 -12.4987374 87 -415.0987374 0.8012626 88 201.6012626 -415.0987374 89 -134.5987374 201.6012626 90 72.5012626 -134.5987374 91 471.4012626 72.5012626 92 -76.3987374 471.4012626 93 261.4012626 -76.3987374 94 74.7012626 261.4012626 95 0.9012626 74.7012626 96 384.2017677 0.9012626 97 210.7017677 384.2017677 98 -330.9982323 210.7017677 99 588.1017677 -330.9982323 100 101.8017677 588.1017677 101 267.6017677 101.8017677 102 526.7017677 267.6017677 103 -188.3982323 526.7017677 104 272.8017677 -188.3982323 105 129.6017677 272.8017677 106 0.9017677 129.6017677 107 -16.8982323 0.9017677 108 26.4022727 -16.8982323 109 -327.0977273 26.4022727 110 -87.7977273 -327.0977273 111 251.3022727 -87.7977273 112 -257.9977273 251.3022727 113 244.8022727 -257.9977273 114 98.9022727 244.8022727 115 35.8022727 98.9022727 116 289.0022727 35.8022727 117 -73.1977273 289.0022727 118 -34.8977273 -73.1977273 119 180.3022727 -34.8977273 > 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/7sdw21354653195.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/8c96f1354653195.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/9jjf41354653195.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/10p6ko1354653195.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/11yom01354653195.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/12sq6q1354653195.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/13kds91354653195.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/146nti1354653195.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/158ip81354653195.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/16g8151354653195.tab") + } > > try(system("convert tmp/1b6cw1354653195.ps tmp/1b6cw1354653195.png",intern=TRUE)) character(0) > try(system("convert tmp/2fu4z1354653195.ps tmp/2fu4z1354653195.png",intern=TRUE)) character(0) > try(system("convert tmp/346e21354653195.ps tmp/346e21354653195.png",intern=TRUE)) character(0) > try(system("convert tmp/401vb1354653195.ps tmp/401vb1354653195.png",intern=TRUE)) character(0) > try(system("convert tmp/5v1nd1354653195.ps tmp/5v1nd1354653195.png",intern=TRUE)) character(0) > try(system("convert tmp/6dagh1354653195.ps tmp/6dagh1354653195.png",intern=TRUE)) character(0) > try(system("convert tmp/7sdw21354653195.ps tmp/7sdw21354653195.png",intern=TRUE)) character(0) > try(system("convert tmp/8c96f1354653195.ps tmp/8c96f1354653195.png",intern=TRUE)) character(0) > try(system("convert tmp/9jjf41354653195.ps tmp/9jjf41354653195.png",intern=TRUE)) character(0) > try(system("convert tmp/10p6ko1354653195.ps tmp/10p6ko1354653195.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 6.852 0.897 7.764