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(621,0,587,0,655,0,517,0,646,0,657,0,382,0,345,0,625,0,654,0,606,0,510,0,614,0,647,0,580,0,614,0,636,0,388,0,356,0,639,0,753,0,611,0,639,0,630,0,586,0,695,0,552,0,619,0,681,0,421,0,307,0,754,0,690,0,644,0,643,0,608,0,651,0,691,0,627,0,634,0,731,0,475,0,337,0,803,0,722,0,590,0,724,0,627,0,696,0,825,0,677,0,656,0,785,0,412,0,352,0,839,0,729,0,696,0,641,0,695,0,638,0,762,0,635,0,721,0,854,0,418,0,367,0,824,0,687,0,601,0,676,0,740,0,691,0,683,0,594,0,729,0,731,0,386,0,331,0,706,0,715,0,657,0,653,0,642,0,643,0,718,0,654,0,632,0,731,0,392,0,344,0,792,0,852,0,649,0,629,0,685,0,617,0,715,0,715,0,629,0,916,0,531,0,357,0,917,0,828,0,708,0,858,0,775,0,785,0,1006,0,789,0,734,0,906,0,532,0,387,0,991,1,841,1,892,1,782,1,813,1,793,1,978,1,775,1,797,1,946,1,594,1,438,1,1022,1,868,1,795,1),dim=c(2,130),dimnames=list(c('Y','X2'),1:130)) > y <- array(NA,dim=c(2,130),dimnames=list(c('Y','X2'),1:130)) > 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 = 'Do not include Seasonal Dummies' > par1 = '1' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > 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 X2 1 621 0 2 587 0 3 655 0 4 517 0 5 646 0 6 657 0 7 382 0 8 345 0 9 625 0 10 654 0 11 606 0 12 510 0 13 614 0 14 647 0 15 580 0 16 614 0 17 636 0 18 388 0 19 356 0 20 639 0 21 753 0 22 611 0 23 639 0 24 630 0 25 586 0 26 695 0 27 552 0 28 619 0 29 681 0 30 421 0 31 307 0 32 754 0 33 690 0 34 644 0 35 643 0 36 608 0 37 651 0 38 691 0 39 627 0 40 634 0 41 731 0 42 475 0 43 337 0 44 803 0 45 722 0 46 590 0 47 724 0 48 627 0 49 696 0 50 825 0 51 677 0 52 656 0 53 785 0 54 412 0 55 352 0 56 839 0 57 729 0 58 696 0 59 641 0 60 695 0 61 638 0 62 762 0 63 635 0 64 721 0 65 854 0 66 418 0 67 367 0 68 824 0 69 687 0 70 601 0 71 676 0 72 740 0 73 691 0 74 683 0 75 594 0 76 729 0 77 731 0 78 386 0 79 331 0 80 706 0 81 715 0 82 657 0 83 653 0 84 642 0 85 643 0 86 718 0 87 654 0 88 632 0 89 731 0 90 392 0 91 344 0 92 792 0 93 852 0 94 649 0 95 629 0 96 685 0 97 617 0 98 715 0 99 715 0 100 629 0 101 916 0 102 531 0 103 357 0 104 917 0 105 828 0 106 708 0 107 858 0 108 775 0 109 785 0 110 1006 0 111 789 0 112 734 0 113 906 0 114 532 0 115 387 0 116 991 1 117 841 1 118 892 1 119 782 1 120 813 1 121 793 1 122 978 1 123 775 1 124 797 1 125 946 1 126 594 1 127 438 1 128 1022 1 129 868 1 130 795 1 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X2 639.9 181.7 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -383.67 -37.70 8.05 81.80 366.05 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 639.95 13.42 47.69 <2e-16 *** X2 181.72 39.50 4.60 1e-05 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 143.9 on 128 degrees of freedom Multiple R-squared: 0.1419, Adjusted R-squared: 0.1352 F-statistic: 21.16 on 1 and 128 DF, p-value: 1.001e-05 > 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.100255008 0.20051002 0.8997450 [2,] 0.047096123 0.09419225 0.9529039 [3,] 0.280284214 0.56056843 0.7197158 [4,] 0.491711927 0.98342385 0.5082881 [5,] 0.399303046 0.79860609 0.6006970 [6,] 0.334887527 0.66977505 0.6651125 [7,] 0.247911145 0.49582229 0.7520889 [8,] 0.190018756 0.38003751 0.8099812 [9,] 0.135707926 0.27141585 0.8642921 [10,] 0.102944217 0.20588843 0.8970558 [11,] 0.067178242 0.13435648 0.9328218 [12,] 0.043959226 0.08791845 0.9560408 [13,] 0.029734602 0.05946920 0.9702654 [14,] 0.060184867 0.12036973 0.9398151 [15,] 0.124320788 0.24864158 0.8756792 [16,] 0.099249154 0.19849831 0.9007508 [17,] 0.132128988 0.26425798 0.8678710 [18,] 0.098974859 0.19794972 0.9010251 [19,] 0.076087505 0.15217501 0.9239125 [20,] 0.056368321 0.11273664 0.9436317 [21,] 0.039354175 0.07870835 0.9606458 [22,] 0.035340877 0.07068175 0.9646591 [23,] 0.025142085 0.05028417 0.9748579 [24,] 0.017237845 0.03447569 0.9827622 [25,] 0.014060750 0.02812150 0.9859393 [26,] 0.020667426 0.04133485 0.9793326 [27,] 0.078817884 0.15763577 0.9211821 [28,] 0.093710944 0.18742189 0.9062891 [29,] 0.083119840 0.16623968 0.9168802 [30,] 0.065513003 0.13102601 0.9344870 [31,] 0.050839753 0.10167951 0.9491602 [32,] 0.037631251 0.07526250 0.9623687 [33,] 0.028811483 0.05762297 0.9711885 [34,] 0.024313953 0.04862791 0.9756860 [35,] 0.017538752 0.03507750 0.9824612 [36,] 0.012561910 0.02512382 0.9874381 [37,] 0.012332524 0.02466505 0.9876675 [38,] 0.012795782 0.02559156 0.9872042 [39,] 0.038714242 0.07742848 0.9612858 [40,] 0.054864559 0.10972912 0.9451354 [41,] 0.050791870 0.10158374 0.9492081 [42,] 0.038989667 0.07797933 0.9610103 [43,] 0.035848134 0.07169627 0.9641519 [44,] 0.026877492 0.05375498 0.9731225 [45,] 0.022190790 0.04438158 0.9778092 [46,] 0.033662203 0.06732441 0.9663378 [47,] 0.026424375 0.05284875 0.9735756 [48,] 0.019874026 0.03974805 0.9801260 [49,] 0.022670258 0.04534052 0.9773297 [50,] 0.035347051 0.07069410 0.9646529 [51,] 0.078675170 0.15735034 0.9213248 [52,] 0.108062584 0.21612517 0.8919374 [53,] 0.097599613 0.19519923 0.9024004 [54,] 0.082102230 0.16420446 0.9178978 [55,] 0.065039391 0.13007878 0.9349606 [56,] 0.053536383 0.10707277 0.9464636 [57,] 0.041414738 0.08282948 0.9585853 [58,] 0.039950245 0.07990049 0.9600498 [59,] 0.030419197 0.06083839 0.9695808 [60,] 0.025528022 0.05105604 0.9744720 [61,] 0.038031543 0.07606309 0.9619685 [62,] 0.055844862 0.11168972 0.9441551 [63,] 0.106998034 0.21399607 0.8930020 [64,] 0.123789667 0.24757933 0.8762103 [65,] 0.102738887 0.20547777 0.8972611 [66,] 0.084232100 0.16846420 0.9157679 [67,] 0.067753348 0.13550670 0.9322467 [68,] 0.059575473 0.11915095 0.9404245 [69,] 0.047656124 0.09531225 0.9523439 [70,] 0.037343226 0.07468645 0.9626568 [71,] 0.029423368 0.05884674 0.9705766 [72,] 0.024388924 0.04877785 0.9756111 [73,] 0.020147869 0.04029574 0.9798521 [74,] 0.039718273 0.07943655 0.9602817 [75,] 0.108240546 0.21648109 0.8917595 [76,] 0.089853780 0.17970756 0.9101462 [77,] 0.074610840 0.14922168 0.9253892 [78,] 0.058806340 0.11761268 0.9411937 [79,] 0.045747566 0.09149513 0.9542524 [80,] 0.035234824 0.07046965 0.9647652 [81,] 0.026784227 0.05356845 0.9732158 [82,] 0.021017642 0.04203528 0.9789824 [83,] 0.015498742 0.03099748 0.9845013 [84,] 0.011422204 0.02284441 0.9885778 [85,] 0.008845025 0.01769005 0.9911550 [86,] 0.021090793 0.04218159 0.9789092 [87,] 0.073636608 0.14727322 0.9263634 [88,] 0.067868373 0.13573675 0.9321316 [89,] 0.076727792 0.15345558 0.9232722 [90,] 0.060898733 0.12179747 0.9391013 [91,] 0.049018850 0.09803770 0.9509812 [92,] 0.037459602 0.07491920 0.9625404 [93,] 0.030432777 0.06086555 0.9695672 [94,] 0.022885493 0.04577099 0.9771145 [95,] 0.016917669 0.03383534 0.9830823 [96,] 0.013124570 0.02624914 0.9868754 [97,] 0.020655146 0.04131029 0.9793449 [98,] 0.022912416 0.04582483 0.9770876 [99,] 0.106112336 0.21222467 0.8938877 [100,] 0.131132763 0.26226553 0.8688672 [101,] 0.119221036 0.23844207 0.8807790 [102,] 0.093552771 0.18710554 0.9064472 [103,] 0.091918963 0.18383793 0.9080810 [104,] 0.072995138 0.14599028 0.9270049 [105,] 0.058275652 0.11655130 0.9417243 [106,] 0.157097318 0.31419464 0.8429027 [107,] 0.147865745 0.29573149 0.8521343 [108,] 0.126576315 0.25315263 0.8734237 [109,] 0.374011003 0.74802201 0.6259890 [110,] 0.336304553 0.67260911 0.6636954 [111,] 0.289407177 0.57881435 0.7105928 [112,] 0.302378143 0.60475629 0.6976219 [113,] 0.237323786 0.47464757 0.7626762 [114,] 0.190852203 0.38170441 0.8091478 [115,] 0.137276512 0.27455302 0.8627235 [116,] 0.091826164 0.18365233 0.9081738 [117,] 0.057464080 0.11492816 0.9425359 [118,] 0.061382195 0.12276439 0.9386178 [119,] 0.034279797 0.06855959 0.9657202 [120,] 0.016944140 0.03388828 0.9830559 [121,] 0.015071171 0.03014234 0.9849288 > postscript(file="/var/www/rcomp/tmp/14hst1293562447.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/24hst1293562447.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/3f89e1293562447.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/4f89e1293562447.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/5f89e1293562447.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 = 130 Frequency = 1 1 2 3 4 5 6 -18.947826 -52.947826 15.052174 -122.947826 6.052174 17.052174 7 8 9 10 11 12 -257.947826 -294.947826 -14.947826 14.052174 -33.947826 -129.947826 13 14 15 16 17 18 -25.947826 7.052174 -59.947826 -25.947826 -3.947826 -251.947826 19 20 21 22 23 24 -283.947826 -0.947826 113.052174 -28.947826 -0.947826 -9.947826 25 26 27 28 29 30 -53.947826 55.052174 -87.947826 -20.947826 41.052174 -218.947826 31 32 33 34 35 36 -332.947826 114.052174 50.052174 4.052174 3.052174 -31.947826 37 38 39 40 41 42 11.052174 51.052174 -12.947826 -5.947826 91.052174 -164.947826 43 44 45 46 47 48 -302.947826 163.052174 82.052174 -49.947826 84.052174 -12.947826 49 50 51 52 53 54 56.052174 185.052174 37.052174 16.052174 145.052174 -227.947826 55 56 57 58 59 60 -287.947826 199.052174 89.052174 56.052174 1.052174 55.052174 61 62 63 64 65 66 -1.947826 122.052174 -4.947826 81.052174 214.052174 -221.947826 67 68 69 70 71 72 -272.947826 184.052174 47.052174 -38.947826 36.052174 100.052174 73 74 75 76 77 78 51.052174 43.052174 -45.947826 89.052174 91.052174 -253.947826 79 80 81 82 83 84 -308.947826 66.052174 75.052174 17.052174 13.052174 2.052174 85 86 87 88 89 90 3.052174 78.052174 14.052174 -7.947826 91.052174 -247.947826 91 92 93 94 95 96 -295.947826 152.052174 212.052174 9.052174 -10.947826 45.052174 97 98 99 100 101 102 -22.947826 75.052174 75.052174 -10.947826 276.052174 -108.947826 103 104 105 106 107 108 -282.947826 277.052174 188.052174 68.052174 218.052174 135.052174 109 110 111 112 113 114 145.052174 366.052174 149.052174 94.052174 266.052174 -107.947826 115 116 117 118 119 120 -252.947826 169.333333 19.333333 70.333333 -39.666667 -8.666667 121 122 123 124 125 126 -28.666667 156.333333 -46.666667 -24.666667 124.333333 -227.666667 127 128 129 130 -383.666667 200.333333 46.333333 -26.666667 > postscript(file="/var/www/rcomp/tmp/6i9tu1293562448.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 = 130 Frequency = 1 lag(myerror, k = 1) myerror 0 -18.947826 NA 1 -52.947826 -18.947826 2 15.052174 -52.947826 3 -122.947826 15.052174 4 6.052174 -122.947826 5 17.052174 6.052174 6 -257.947826 17.052174 7 -294.947826 -257.947826 8 -14.947826 -294.947826 9 14.052174 -14.947826 10 -33.947826 14.052174 11 -129.947826 -33.947826 12 -25.947826 -129.947826 13 7.052174 -25.947826 14 -59.947826 7.052174 15 -25.947826 -59.947826 16 -3.947826 -25.947826 17 -251.947826 -3.947826 18 -283.947826 -251.947826 19 -0.947826 -283.947826 20 113.052174 -0.947826 21 -28.947826 113.052174 22 -0.947826 -28.947826 23 -9.947826 -0.947826 24 -53.947826 -9.947826 25 55.052174 -53.947826 26 -87.947826 55.052174 27 -20.947826 -87.947826 28 41.052174 -20.947826 29 -218.947826 41.052174 30 -332.947826 -218.947826 31 114.052174 -332.947826 32 50.052174 114.052174 33 4.052174 50.052174 34 3.052174 4.052174 35 -31.947826 3.052174 36 11.052174 -31.947826 37 51.052174 11.052174 38 -12.947826 51.052174 39 -5.947826 -12.947826 40 91.052174 -5.947826 41 -164.947826 91.052174 42 -302.947826 -164.947826 43 163.052174 -302.947826 44 82.052174 163.052174 45 -49.947826 82.052174 46 84.052174 -49.947826 47 -12.947826 84.052174 48 56.052174 -12.947826 49 185.052174 56.052174 50 37.052174 185.052174 51 16.052174 37.052174 52 145.052174 16.052174 53 -227.947826 145.052174 54 -287.947826 -227.947826 55 199.052174 -287.947826 56 89.052174 199.052174 57 56.052174 89.052174 58 1.052174 56.052174 59 55.052174 1.052174 60 -1.947826 55.052174 61 122.052174 -1.947826 62 -4.947826 122.052174 63 81.052174 -4.947826 64 214.052174 81.052174 65 -221.947826 214.052174 66 -272.947826 -221.947826 67 184.052174 -272.947826 68 47.052174 184.052174 69 -38.947826 47.052174 70 36.052174 -38.947826 71 100.052174 36.052174 72 51.052174 100.052174 73 43.052174 51.052174 74 -45.947826 43.052174 75 89.052174 -45.947826 76 91.052174 89.052174 77 -253.947826 91.052174 78 -308.947826 -253.947826 79 66.052174 -308.947826 80 75.052174 66.052174 81 17.052174 75.052174 82 13.052174 17.052174 83 2.052174 13.052174 84 3.052174 2.052174 85 78.052174 3.052174 86 14.052174 78.052174 87 -7.947826 14.052174 88 91.052174 -7.947826 89 -247.947826 91.052174 90 -295.947826 -247.947826 91 152.052174 -295.947826 92 212.052174 152.052174 93 9.052174 212.052174 94 -10.947826 9.052174 95 45.052174 -10.947826 96 -22.947826 45.052174 97 75.052174 -22.947826 98 75.052174 75.052174 99 -10.947826 75.052174 100 276.052174 -10.947826 101 -108.947826 276.052174 102 -282.947826 -108.947826 103 277.052174 -282.947826 104 188.052174 277.052174 105 68.052174 188.052174 106 218.052174 68.052174 107 135.052174 218.052174 108 145.052174 135.052174 109 366.052174 145.052174 110 149.052174 366.052174 111 94.052174 149.052174 112 266.052174 94.052174 113 -107.947826 266.052174 114 -252.947826 -107.947826 115 169.333333 -252.947826 116 19.333333 169.333333 117 70.333333 19.333333 118 -39.666667 70.333333 119 -8.666667 -39.666667 120 -28.666667 -8.666667 121 156.333333 -28.666667 122 -46.666667 156.333333 123 -24.666667 -46.666667 124 124.333333 -24.666667 125 -227.666667 124.333333 126 -383.666667 -227.666667 127 200.333333 -383.666667 128 46.333333 200.333333 129 -26.666667 46.333333 130 NA -26.666667 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -52.947826 -18.947826 [2,] 15.052174 -52.947826 [3,] -122.947826 15.052174 [4,] 6.052174 -122.947826 [5,] 17.052174 6.052174 [6,] -257.947826 17.052174 [7,] -294.947826 -257.947826 [8,] -14.947826 -294.947826 [9,] 14.052174 -14.947826 [10,] -33.947826 14.052174 [11,] -129.947826 -33.947826 [12,] -25.947826 -129.947826 [13,] 7.052174 -25.947826 [14,] -59.947826 7.052174 [15,] -25.947826 -59.947826 [16,] -3.947826 -25.947826 [17,] -251.947826 -3.947826 [18,] -283.947826 -251.947826 [19,] -0.947826 -283.947826 [20,] 113.052174 -0.947826 [21,] -28.947826 113.052174 [22,] -0.947826 -28.947826 [23,] -9.947826 -0.947826 [24,] -53.947826 -9.947826 [25,] 55.052174 -53.947826 [26,] -87.947826 55.052174 [27,] -20.947826 -87.947826 [28,] 41.052174 -20.947826 [29,] -218.947826 41.052174 [30,] -332.947826 -218.947826 [31,] 114.052174 -332.947826 [32,] 50.052174 114.052174 [33,] 4.052174 50.052174 [34,] 3.052174 4.052174 [35,] -31.947826 3.052174 [36,] 11.052174 -31.947826 [37,] 51.052174 11.052174 [38,] -12.947826 51.052174 [39,] -5.947826 -12.947826 [40,] 91.052174 -5.947826 [41,] -164.947826 91.052174 [42,] -302.947826 -164.947826 [43,] 163.052174 -302.947826 [44,] 82.052174 163.052174 [45,] -49.947826 82.052174 [46,] 84.052174 -49.947826 [47,] -12.947826 84.052174 [48,] 56.052174 -12.947826 [49,] 185.052174 56.052174 [50,] 37.052174 185.052174 [51,] 16.052174 37.052174 [52,] 145.052174 16.052174 [53,] -227.947826 145.052174 [54,] -287.947826 -227.947826 [55,] 199.052174 -287.947826 [56,] 89.052174 199.052174 [57,] 56.052174 89.052174 [58,] 1.052174 56.052174 [59,] 55.052174 1.052174 [60,] -1.947826 55.052174 [61,] 122.052174 -1.947826 [62,] -4.947826 122.052174 [63,] 81.052174 -4.947826 [64,] 214.052174 81.052174 [65,] -221.947826 214.052174 [66,] -272.947826 -221.947826 [67,] 184.052174 -272.947826 [68,] 47.052174 184.052174 [69,] -38.947826 47.052174 [70,] 36.052174 -38.947826 [71,] 100.052174 36.052174 [72,] 51.052174 100.052174 [73,] 43.052174 51.052174 [74,] -45.947826 43.052174 [75,] 89.052174 -45.947826 [76,] 91.052174 89.052174 [77,] -253.947826 91.052174 [78,] -308.947826 -253.947826 [79,] 66.052174 -308.947826 [80,] 75.052174 66.052174 [81,] 17.052174 75.052174 [82,] 13.052174 17.052174 [83,] 2.052174 13.052174 [84,] 3.052174 2.052174 [85,] 78.052174 3.052174 [86,] 14.052174 78.052174 [87,] -7.947826 14.052174 [88,] 91.052174 -7.947826 [89,] -247.947826 91.052174 [90,] -295.947826 -247.947826 [91,] 152.052174 -295.947826 [92,] 212.052174 152.052174 [93,] 9.052174 212.052174 [94,] -10.947826 9.052174 [95,] 45.052174 -10.947826 [96,] -22.947826 45.052174 [97,] 75.052174 -22.947826 [98,] 75.052174 75.052174 [99,] -10.947826 75.052174 [100,] 276.052174 -10.947826 [101,] -108.947826 276.052174 [102,] -282.947826 -108.947826 [103,] 277.052174 -282.947826 [104,] 188.052174 277.052174 [105,] 68.052174 188.052174 [106,] 218.052174 68.052174 [107,] 135.052174 218.052174 [108,] 145.052174 135.052174 [109,] 366.052174 145.052174 [110,] 149.052174 366.052174 [111,] 94.052174 149.052174 [112,] 266.052174 94.052174 [113,] -107.947826 266.052174 [114,] -252.947826 -107.947826 [115,] 169.333333 -252.947826 [116,] 19.333333 169.333333 [117,] 70.333333 19.333333 [118,] -39.666667 70.333333 [119,] -8.666667 -39.666667 [120,] -28.666667 -8.666667 [121,] 156.333333 -28.666667 [122,] -46.666667 156.333333 [123,] -24.666667 -46.666667 [124,] 124.333333 -24.666667 [125,] -227.666667 124.333333 [126,] -383.666667 -227.666667 [127,] 200.333333 -383.666667 [128,] 46.333333 200.333333 [129,] -26.666667 46.333333 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -52.947826 -18.947826 2 15.052174 -52.947826 3 -122.947826 15.052174 4 6.052174 -122.947826 5 17.052174 6.052174 6 -257.947826 17.052174 7 -294.947826 -257.947826 8 -14.947826 -294.947826 9 14.052174 -14.947826 10 -33.947826 14.052174 11 -129.947826 -33.947826 12 -25.947826 -129.947826 13 7.052174 -25.947826 14 -59.947826 7.052174 15 -25.947826 -59.947826 16 -3.947826 -25.947826 17 -251.947826 -3.947826 18 -283.947826 -251.947826 19 -0.947826 -283.947826 20 113.052174 -0.947826 21 -28.947826 113.052174 22 -0.947826 -28.947826 23 -9.947826 -0.947826 24 -53.947826 -9.947826 25 55.052174 -53.947826 26 -87.947826 55.052174 27 -20.947826 -87.947826 28 41.052174 -20.947826 29 -218.947826 41.052174 30 -332.947826 -218.947826 31 114.052174 -332.947826 32 50.052174 114.052174 33 4.052174 50.052174 34 3.052174 4.052174 35 -31.947826 3.052174 36 11.052174 -31.947826 37 51.052174 11.052174 38 -12.947826 51.052174 39 -5.947826 -12.947826 40 91.052174 -5.947826 41 -164.947826 91.052174 42 -302.947826 -164.947826 43 163.052174 -302.947826 44 82.052174 163.052174 45 -49.947826 82.052174 46 84.052174 -49.947826 47 -12.947826 84.052174 48 56.052174 -12.947826 49 185.052174 56.052174 50 37.052174 185.052174 51 16.052174 37.052174 52 145.052174 16.052174 53 -227.947826 145.052174 54 -287.947826 -227.947826 55 199.052174 -287.947826 56 89.052174 199.052174 57 56.052174 89.052174 58 1.052174 56.052174 59 55.052174 1.052174 60 -1.947826 55.052174 61 122.052174 -1.947826 62 -4.947826 122.052174 63 81.052174 -4.947826 64 214.052174 81.052174 65 -221.947826 214.052174 66 -272.947826 -221.947826 67 184.052174 -272.947826 68 47.052174 184.052174 69 -38.947826 47.052174 70 36.052174 -38.947826 71 100.052174 36.052174 72 51.052174 100.052174 73 43.052174 51.052174 74 -45.947826 43.052174 75 89.052174 -45.947826 76 91.052174 89.052174 77 -253.947826 91.052174 78 -308.947826 -253.947826 79 66.052174 -308.947826 80 75.052174 66.052174 81 17.052174 75.052174 82 13.052174 17.052174 83 2.052174 13.052174 84 3.052174 2.052174 85 78.052174 3.052174 86 14.052174 78.052174 87 -7.947826 14.052174 88 91.052174 -7.947826 89 -247.947826 91.052174 90 -295.947826 -247.947826 91 152.052174 -295.947826 92 212.052174 152.052174 93 9.052174 212.052174 94 -10.947826 9.052174 95 45.052174 -10.947826 96 -22.947826 45.052174 97 75.052174 -22.947826 98 75.052174 75.052174 99 -10.947826 75.052174 100 276.052174 -10.947826 101 -108.947826 276.052174 102 -282.947826 -108.947826 103 277.052174 -282.947826 104 188.052174 277.052174 105 68.052174 188.052174 106 218.052174 68.052174 107 135.052174 218.052174 108 145.052174 135.052174 109 366.052174 145.052174 110 149.052174 366.052174 111 94.052174 149.052174 112 266.052174 94.052174 113 -107.947826 266.052174 114 -252.947826 -107.947826 115 169.333333 -252.947826 116 19.333333 169.333333 117 70.333333 19.333333 118 -39.666667 70.333333 119 -8.666667 -39.666667 120 -28.666667 -8.666667 121 156.333333 -28.666667 122 -46.666667 156.333333 123 -24.666667 -46.666667 124 124.333333 -24.666667 125 -227.666667 124.333333 126 -383.666667 -227.666667 127 200.333333 -383.666667 128 46.333333 200.333333 129 -26.666667 46.333333 > 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/7t0sx1293562448.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/8t0sx1293562448.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/9t0sx1293562448.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/103aai1293562448.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/11pa861293562448.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/12abpt1293562448.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/13o2521293562448.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/149l3q1293562448.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/15v31w1293562448.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/16ymi21293562448.tab") + } > > try(system("convert tmp/14hst1293562447.ps tmp/14hst1293562447.png",intern=TRUE)) character(0) > try(system("convert tmp/24hst1293562447.ps tmp/24hst1293562447.png",intern=TRUE)) character(0) > try(system("convert tmp/3f89e1293562447.ps tmp/3f89e1293562447.png",intern=TRUE)) character(0) > try(system("convert tmp/4f89e1293562447.ps tmp/4f89e1293562447.png",intern=TRUE)) character(0) > try(system("convert tmp/5f89e1293562447.ps tmp/5f89e1293562447.png",intern=TRUE)) character(0) > try(system("convert tmp/6i9tu1293562448.ps tmp/6i9tu1293562448.png",intern=TRUE)) character(0) > try(system("convert tmp/7t0sx1293562448.ps tmp/7t0sx1293562448.png",intern=TRUE)) character(0) > try(system("convert tmp/8t0sx1293562448.ps tmp/8t0sx1293562448.png",intern=TRUE)) character(0) > try(system("convert tmp/9t0sx1293562448.ps tmp/9t0sx1293562448.png",intern=TRUE)) character(0) > try(system("convert tmp/103aai1293562448.ps tmp/103aai1293562448.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 4.02 1.60 5.62