R version 2.8.0 (2008-10-20) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(1593,0,1477.9,0,1733.7,0,1569.7,0,1843.7,0,1950.3,0,1657.5,0,1772.1,0,1568.3,0,1809.8,0,1646.7,0,1808.5,0,1763.9,0,1625.5,0,1538.8,0,1342.4,0,1645.1,0,1619.9,0,1338.1,0,1505.5,0,1529.1,0,1511.9,0,1656.7,0,1694.4,0,1662.3,0,1588.7,0,1483.3,0,1585.6,0,1658.9,0,1584.4,0,1470.6,0,1618.7,0,1407.6,0,1473.9,0,1515.3,0,1485.4,0,1496.1,0,1493.5,0,1298.4,0,1375.3,0,1507.9,0,1455.3,0,1363.3,0,1392.8,0,1348.8,0,1880.3,0,1669.2,0,1543.6,0,1701.2,0,1516.5,0,1466.8,0,1484.1,0,1577.2,0,1684.5,0,1414.7,0,1674.5,0,1598.7,0,1739.1,0,1674.6,0,1671.8,0,1802,0,1526.8,0,1580.9,0,1634.8,0,1610.3,0,1712,0,1678.8,0,1708.1,0,1680.6,0,2056,1,1624,1,2021.4,1,1861.1,1,1750.8,1,1767.5,1,1710.3,1,2151.5,1,2047.9,1,1915.4,1,1984.7,1,1896.5,1,2170.8,1,2139.9,1,2330.5,1,2121.8,1,2226.8,1,1857.9,1,2155.9,1,2341.7,1,2290.2,1,2006.5,1,2111.9,1,1731.3,1,1762.2,1,1863.2,1,1943.5,1,1975.2,1),dim=c(2,97),dimnames=list(c('M','D'),1:97)) > y <- array(NA,dim=c(2,97),dimnames=list(c('M','D'),1:97)) > 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' > #'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 Attaching package: 'zoo' The following object(s) are masked from package:base : 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 M D M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 1593.0 0 1 0 0 0 0 0 0 0 0 0 0 1 2 1477.9 0 0 1 0 0 0 0 0 0 0 0 0 2 3 1733.7 0 0 0 1 0 0 0 0 0 0 0 0 3 4 1569.7 0 0 0 0 1 0 0 0 0 0 0 0 4 5 1843.7 0 0 0 0 0 1 0 0 0 0 0 0 5 6 1950.3 0 0 0 0 0 0 1 0 0 0 0 0 6 7 1657.5 0 0 0 0 0 0 0 1 0 0 0 0 7 8 1772.1 0 0 0 0 0 0 0 0 1 0 0 0 8 9 1568.3 0 0 0 0 0 0 0 0 0 1 0 0 9 10 1809.8 0 0 0 0 0 0 0 0 0 0 1 0 10 11 1646.7 0 0 0 0 0 0 0 0 0 0 0 1 11 12 1808.5 0 0 0 0 0 0 0 0 0 0 0 0 12 13 1763.9 0 1 0 0 0 0 0 0 0 0 0 0 13 14 1625.5 0 0 1 0 0 0 0 0 0 0 0 0 14 15 1538.8 0 0 0 1 0 0 0 0 0 0 0 0 15 16 1342.4 0 0 0 0 1 0 0 0 0 0 0 0 16 17 1645.1 0 0 0 0 0 1 0 0 0 0 0 0 17 18 1619.9 0 0 0 0 0 0 1 0 0 0 0 0 18 19 1338.1 0 0 0 0 0 0 0 1 0 0 0 0 19 20 1505.5 0 0 0 0 0 0 0 0 1 0 0 0 20 21 1529.1 0 0 0 0 0 0 0 0 0 1 0 0 21 22 1511.9 0 0 0 0 0 0 0 0 0 0 1 0 22 23 1656.7 0 0 0 0 0 0 0 0 0 0 0 1 23 24 1694.4 0 0 0 0 0 0 0 0 0 0 0 0 24 25 1662.3 0 1 0 0 0 0 0 0 0 0 0 0 25 26 1588.7 0 0 1 0 0 0 0 0 0 0 0 0 26 27 1483.3 0 0 0 1 0 0 0 0 0 0 0 0 27 28 1585.6 0 0 0 0 1 0 0 0 0 0 0 0 28 29 1658.9 0 0 0 0 0 1 0 0 0 0 0 0 29 30 1584.4 0 0 0 0 0 0 1 0 0 0 0 0 30 31 1470.6 0 0 0 0 0 0 0 1 0 0 0 0 31 32 1618.7 0 0 0 0 0 0 0 0 1 0 0 0 32 33 1407.6 0 0 0 0 0 0 0 0 0 1 0 0 33 34 1473.9 0 0 0 0 0 0 0 0 0 0 1 0 34 35 1515.3 0 0 0 0 0 0 0 0 0 0 0 1 35 36 1485.4 0 0 0 0 0 0 0 0 0 0 0 0 36 37 1496.1 0 1 0 0 0 0 0 0 0 0 0 0 37 38 1493.5 0 0 1 0 0 0 0 0 0 0 0 0 38 39 1298.4 0 0 0 1 0 0 0 0 0 0 0 0 39 40 1375.3 0 0 0 0 1 0 0 0 0 0 0 0 40 41 1507.9 0 0 0 0 0 1 0 0 0 0 0 0 41 42 1455.3 0 0 0 0 0 0 1 0 0 0 0 0 42 43 1363.3 0 0 0 0 0 0 0 1 0 0 0 0 43 44 1392.8 0 0 0 0 0 0 0 0 1 0 0 0 44 45 1348.8 0 0 0 0 0 0 0 0 0 1 0 0 45 46 1880.3 0 0 0 0 0 0 0 0 0 0 1 0 46 47 1669.2 0 0 0 0 0 0 0 0 0 0 0 1 47 48 1543.6 0 0 0 0 0 0 0 0 0 0 0 0 48 49 1701.2 0 1 0 0 0 0 0 0 0 0 0 0 49 50 1516.5 0 0 1 0 0 0 0 0 0 0 0 0 50 51 1466.8 0 0 0 1 0 0 0 0 0 0 0 0 51 52 1484.1 0 0 0 0 1 0 0 0 0 0 0 0 52 53 1577.2 0 0 0 0 0 1 0 0 0 0 0 0 53 54 1684.5 0 0 0 0 0 0 1 0 0 0 0 0 54 55 1414.7 0 0 0 0 0 0 0 1 0 0 0 0 55 56 1674.5 0 0 0 0 0 0 0 0 1 0 0 0 56 57 1598.7 0 0 0 0 0 0 0 0 0 1 0 0 57 58 1739.1 0 0 0 0 0 0 0 0 0 0 1 0 58 59 1674.6 0 0 0 0 0 0 0 0 0 0 0 1 59 60 1671.8 0 0 0 0 0 0 0 0 0 0 0 0 60 61 1802.0 0 1 0 0 0 0 0 0 0 0 0 0 61 62 1526.8 0 0 1 0 0 0 0 0 0 0 0 0 62 63 1580.9 0 0 0 1 0 0 0 0 0 0 0 0 63 64 1634.8 0 0 0 0 1 0 0 0 0 0 0 0 64 65 1610.3 0 0 0 0 0 1 0 0 0 0 0 0 65 66 1712.0 0 0 0 0 0 0 1 0 0 0 0 0 66 67 1678.8 0 0 0 0 0 0 0 1 0 0 0 0 67 68 1708.1 0 0 0 0 0 0 0 0 1 0 0 0 68 69 1680.6 0 0 0 0 0 0 0 0 0 1 0 0 69 70 2056.0 1 0 0 0 0 0 0 0 0 0 1 0 70 71 1624.0 1 0 0 0 0 0 0 0 0 0 0 1 71 72 2021.4 1 0 0 0 0 0 0 0 0 0 0 0 72 73 1861.1 1 1 0 0 0 0 0 0 0 0 0 0 73 74 1750.8 1 0 1 0 0 0 0 0 0 0 0 0 74 75 1767.5 1 0 0 1 0 0 0 0 0 0 0 0 75 76 1710.3 1 0 0 0 1 0 0 0 0 0 0 0 76 77 2151.5 1 0 0 0 0 1 0 0 0 0 0 0 77 78 2047.9 1 0 0 0 0 0 1 0 0 0 0 0 78 79 1915.4 1 0 0 0 0 0 0 1 0 0 0 0 79 80 1984.7 1 0 0 0 0 0 0 0 1 0 0 0 80 81 1896.5 1 0 0 0 0 0 0 0 0 1 0 0 81 82 2170.8 1 0 0 0 0 0 0 0 0 0 1 0 82 83 2139.9 1 0 0 0 0 0 0 0 0 0 0 1 83 84 2330.5 1 0 0 0 0 0 0 0 0 0 0 0 84 85 2121.8 1 1 0 0 0 0 0 0 0 0 0 0 85 86 2226.8 1 0 1 0 0 0 0 0 0 0 0 0 86 87 1857.9 1 0 0 1 0 0 0 0 0 0 0 0 87 88 2155.9 1 0 0 0 1 0 0 0 0 0 0 0 88 89 2341.7 1 0 0 0 0 1 0 0 0 0 0 0 89 90 2290.2 1 0 0 0 0 0 1 0 0 0 0 0 90 91 2006.5 1 0 0 0 0 0 0 1 0 0 0 0 91 92 2111.9 1 0 0 0 0 0 0 0 1 0 0 0 92 93 1731.3 1 0 0 0 0 0 0 0 0 1 0 0 93 94 1762.2 1 0 0 0 0 0 0 0 0 0 1 0 94 95 1863.2 1 0 0 0 0 0 0 0 0 0 0 1 95 96 1943.5 1 0 0 0 0 0 0 0 0 0 0 0 96 97 1975.2 1 1 0 0 0 0 0 0 0 0 0 0 97 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) D M1 M2 M3 M4 1670.0006 404.1463 -21.2192 -112.7545 -172.4847 -155.9649 M5 M6 M7 M8 M9 M10 28.9799 30.1746 -157.1056 -41.5108 -167.2660 -12.2271 M11 t -88.8573 -0.1698 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -349.235 -110.682 -4.357 94.883 280.008 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1670.0006 61.7186 27.058 < 2e-16 *** D 404.1463 53.5655 7.545 5.2e-11 *** M1 -21.2192 71.4226 -0.297 0.7671 M2 -112.7545 73.6270 -1.531 0.1295 M3 -172.4847 73.5921 -2.344 0.0215 * M4 -155.9649 73.5675 -2.120 0.0370 * M5 28.9799 73.5530 0.394 0.6946 M6 30.1746 73.5487 0.410 0.6827 M7 -157.1056 73.5545 -2.136 0.0356 * M8 -41.5108 73.5706 -0.564 0.5741 M9 -167.2660 73.5968 -2.273 0.0256 * M10 -12.2271 73.4522 -0.166 0.8682 M11 -88.8573 73.4369 -1.210 0.2297 t -0.1698 0.8655 -0.196 0.8450 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 146.9 on 83 degrees of freedom Multiple R-squared: 0.6794, Adjusted R-squared: 0.6292 F-statistic: 13.53 on 13 and 83 DF, p-value: 1.665e-15 > 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.746255579 0.50748884 0.2537444 [2,] 0.761073247 0.47785351 0.2389268 [3,] 0.731074087 0.53785183 0.2689259 [4,] 0.650292033 0.69941593 0.3497080 [5,] 0.572626793 0.85474641 0.4273732 [6,] 0.514284946 0.97143011 0.4857151 [7,] 0.485741517 0.97148303 0.5142585 [8,] 0.400483503 0.80096701 0.5995165 [9,] 0.402525045 0.80505009 0.5974750 [10,] 0.421140709 0.84228142 0.5788593 [11,] 0.351439156 0.70287831 0.6485608 [12,] 0.448009964 0.89601993 0.5519900 [13,] 0.375563956 0.75112791 0.6244360 [14,] 0.319236739 0.63847348 0.6807633 [15,] 0.269052519 0.53810504 0.7309475 [16,] 0.234204590 0.46840918 0.7657954 [17,] 0.184612569 0.36922514 0.8153874 [18,] 0.148291810 0.29658362 0.8517082 [19,] 0.112102962 0.22420592 0.8878970 [20,] 0.102472544 0.20494509 0.8975275 [21,] 0.072770848 0.14554170 0.9272292 [22,] 0.055740934 0.11148187 0.9442591 [23,] 0.047986222 0.09597244 0.9520138 [24,] 0.033383077 0.06676615 0.9666169 [25,] 0.023876248 0.04775250 0.9761238 [26,] 0.021083745 0.04216749 0.9789163 [27,] 0.014807687 0.02961537 0.9851923 [28,] 0.012951978 0.02590396 0.9870480 [29,] 0.008930547 0.01786109 0.9910695 [30,] 0.091199103 0.18239821 0.9088009 [31,] 0.107668068 0.21533614 0.8923319 [32,] 0.084209686 0.16841937 0.9157903 [33,] 0.098884749 0.19776950 0.9011153 [34,] 0.080441514 0.16088303 0.9195585 [35,] 0.061839533 0.12367907 0.9381605 [36,] 0.053204915 0.10640983 0.9467951 [37,] 0.045090433 0.09018087 0.9549096 [38,] 0.038621376 0.07724275 0.9613786 [39,] 0.034471238 0.06894248 0.9655288 [40,] 0.033616000 0.06723200 0.9663840 [41,] 0.036264796 0.07252959 0.9637352 [42,] 0.030919785 0.06183957 0.9690802 [43,] 0.027744103 0.05548821 0.9722559 [44,] 0.020711022 0.04142204 0.9792890 [45,] 0.026762271 0.05352454 0.9732377 [46,] 0.019446182 0.03889236 0.9805538 [47,] 0.015828939 0.03165788 0.9841711 [48,] 0.014603741 0.02920748 0.9853963 [49,] 0.017443707 0.03488741 0.9825563 [50,] 0.014842682 0.02968536 0.9851573 [51,] 0.015019917 0.03003983 0.9849801 [52,] 0.012370366 0.02474073 0.9876296 [53,] 0.009789035 0.01957807 0.9902110 [54,] 0.007776930 0.01555386 0.9922231 [55,] 0.013821903 0.02764381 0.9861781 [56,] 0.009319185 0.01863837 0.9906808 [57,] 0.006153965 0.01230793 0.9938460 [58,] 0.017989702 0.03597940 0.9820103 [59,] 0.010899628 0.02179926 0.9891004 [60,] 0.050741232 0.10148246 0.9492588 [61,] 0.076786016 0.15357203 0.9232140 [62,] 0.177573365 0.35514673 0.8224266 [63,] 0.238649859 0.47729972 0.7613501 [64,] 0.632314390 0.73537122 0.3676856 > postscript(file="/var/www/html/rcomp/tmp/1gz3f1227192763.ps",horizontal=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/html/rcomp/tmp/2bms91227192763.ps",horizontal=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/html/rcomp/tmp/3v6bj1227192763.ps",horizontal=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/html/rcomp/tmp/46qrn1227192763.ps",horizontal=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/html/rcomp/tmp/5oyz21227192763.ps",horizontal=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 = 97 Frequency = 1 1 2 3 4 5 6 -55.611621 -79.006541 236.693459 56.343459 145.568459 251.143459 7 8 9 10 11 12 145.793459 144.968459 67.093459 153.724245 67.424245 140.536745 13 14 15 16 17 18 117.325698 70.630777 43.830777 -168.919223 -50.994223 -77.219223 19 20 21 22 23 24 -171.569223 -119.594223 29.930777 -142.138437 79.461563 28.474063 25 26 27 28 29 30 17.763016 35.868095 -9.631905 76.318095 -35.156905 -110.681905 31 32 33 34 35 36 -37.031905 -4.356905 -89.531905 -178.101118 -59.901118 -178.488618 37 38 39 40 41 42 -146.399666 -57.294586 -192.494586 -131.944586 -184.119586 -237.744586 43 44 45 46 47 48 -142.294586 -228.219586 -146.294586 230.336200 96.036200 -118.251300 49 50 51 52 53 54 60.737653 -32.257268 -22.057268 -21.107268 -112.782268 -6.507268 55 56 57 58 59 60 -88.857268 55.517732 105.642732 91.173519 103.473519 11.986019 61 62 63 64 65 66 163.574971 -19.919949 94.080051 131.630051 -77.644949 23.030051 67 68 69 70 71 72 177.280051 91.155051 189.580051 5.964545 -349.235455 -40.522955 73 74 75 76 77 78 -179.434002 -198.028923 -121.428923 -194.978923 61.446077 -43.178923 79 80 81 82 83 84 11.771077 -34.353923 3.371077 122.801864 168.701864 270.614364 85 86 87 88 89 90 83.303316 280.008395 -28.991605 252.658395 253.683395 201.158395 91 92 93 94 95 96 104.908395 94.883395 -159.791605 -283.760818 -105.960818 -114.348318 97 -61.259365 > postscript(file="/var/www/html/rcomp/tmp/6zlwv1227192763.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > dum <- cbind(lag(myerror,k=1),myerror) > dum Time Series: Start = 0 End = 97 Frequency = 1 lag(myerror, k = 1) myerror 0 -55.611621 NA 1 -79.006541 -55.611621 2 236.693459 -79.006541 3 56.343459 236.693459 4 145.568459 56.343459 5 251.143459 145.568459 6 145.793459 251.143459 7 144.968459 145.793459 8 67.093459 144.968459 9 153.724245 67.093459 10 67.424245 153.724245 11 140.536745 67.424245 12 117.325698 140.536745 13 70.630777 117.325698 14 43.830777 70.630777 15 -168.919223 43.830777 16 -50.994223 -168.919223 17 -77.219223 -50.994223 18 -171.569223 -77.219223 19 -119.594223 -171.569223 20 29.930777 -119.594223 21 -142.138437 29.930777 22 79.461563 -142.138437 23 28.474063 79.461563 24 17.763016 28.474063 25 35.868095 17.763016 26 -9.631905 35.868095 27 76.318095 -9.631905 28 -35.156905 76.318095 29 -110.681905 -35.156905 30 -37.031905 -110.681905 31 -4.356905 -37.031905 32 -89.531905 -4.356905 33 -178.101118 -89.531905 34 -59.901118 -178.101118 35 -178.488618 -59.901118 36 -146.399666 -178.488618 37 -57.294586 -146.399666 38 -192.494586 -57.294586 39 -131.944586 -192.494586 40 -184.119586 -131.944586 41 -237.744586 -184.119586 42 -142.294586 -237.744586 43 -228.219586 -142.294586 44 -146.294586 -228.219586 45 230.336200 -146.294586 46 96.036200 230.336200 47 -118.251300 96.036200 48 60.737653 -118.251300 49 -32.257268 60.737653 50 -22.057268 -32.257268 51 -21.107268 -22.057268 52 -112.782268 -21.107268 53 -6.507268 -112.782268 54 -88.857268 -6.507268 55 55.517732 -88.857268 56 105.642732 55.517732 57 91.173519 105.642732 58 103.473519 91.173519 59 11.986019 103.473519 60 163.574971 11.986019 61 -19.919949 163.574971 62 94.080051 -19.919949 63 131.630051 94.080051 64 -77.644949 131.630051 65 23.030051 -77.644949 66 177.280051 23.030051 67 91.155051 177.280051 68 189.580051 91.155051 69 5.964545 189.580051 70 -349.235455 5.964545 71 -40.522955 -349.235455 72 -179.434002 -40.522955 73 -198.028923 -179.434002 74 -121.428923 -198.028923 75 -194.978923 -121.428923 76 61.446077 -194.978923 77 -43.178923 61.446077 78 11.771077 -43.178923 79 -34.353923 11.771077 80 3.371077 -34.353923 81 122.801864 3.371077 82 168.701864 122.801864 83 270.614364 168.701864 84 83.303316 270.614364 85 280.008395 83.303316 86 -28.991605 280.008395 87 252.658395 -28.991605 88 253.683395 252.658395 89 201.158395 253.683395 90 104.908395 201.158395 91 94.883395 104.908395 92 -159.791605 94.883395 93 -283.760818 -159.791605 94 -105.960818 -283.760818 95 -114.348318 -105.960818 96 -61.259365 -114.348318 97 NA -61.259365 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -79.006541 -55.611621 [2,] 236.693459 -79.006541 [3,] 56.343459 236.693459 [4,] 145.568459 56.343459 [5,] 251.143459 145.568459 [6,] 145.793459 251.143459 [7,] 144.968459 145.793459 [8,] 67.093459 144.968459 [9,] 153.724245 67.093459 [10,] 67.424245 153.724245 [11,] 140.536745 67.424245 [12,] 117.325698 140.536745 [13,] 70.630777 117.325698 [14,] 43.830777 70.630777 [15,] -168.919223 43.830777 [16,] -50.994223 -168.919223 [17,] -77.219223 -50.994223 [18,] -171.569223 -77.219223 [19,] -119.594223 -171.569223 [20,] 29.930777 -119.594223 [21,] -142.138437 29.930777 [22,] 79.461563 -142.138437 [23,] 28.474063 79.461563 [24,] 17.763016 28.474063 [25,] 35.868095 17.763016 [26,] -9.631905 35.868095 [27,] 76.318095 -9.631905 [28,] -35.156905 76.318095 [29,] -110.681905 -35.156905 [30,] -37.031905 -110.681905 [31,] -4.356905 -37.031905 [32,] -89.531905 -4.356905 [33,] -178.101118 -89.531905 [34,] -59.901118 -178.101118 [35,] -178.488618 -59.901118 [36,] -146.399666 -178.488618 [37,] -57.294586 -146.399666 [38,] -192.494586 -57.294586 [39,] -131.944586 -192.494586 [40,] -184.119586 -131.944586 [41,] -237.744586 -184.119586 [42,] -142.294586 -237.744586 [43,] -228.219586 -142.294586 [44,] -146.294586 -228.219586 [45,] 230.336200 -146.294586 [46,] 96.036200 230.336200 [47,] -118.251300 96.036200 [48,] 60.737653 -118.251300 [49,] -32.257268 60.737653 [50,] -22.057268 -32.257268 [51,] -21.107268 -22.057268 [52,] -112.782268 -21.107268 [53,] -6.507268 -112.782268 [54,] -88.857268 -6.507268 [55,] 55.517732 -88.857268 [56,] 105.642732 55.517732 [57,] 91.173519 105.642732 [58,] 103.473519 91.173519 [59,] 11.986019 103.473519 [60,] 163.574971 11.986019 [61,] -19.919949 163.574971 [62,] 94.080051 -19.919949 [63,] 131.630051 94.080051 [64,] -77.644949 131.630051 [65,] 23.030051 -77.644949 [66,] 177.280051 23.030051 [67,] 91.155051 177.280051 [68,] 189.580051 91.155051 [69,] 5.964545 189.580051 [70,] -349.235455 5.964545 [71,] -40.522955 -349.235455 [72,] -179.434002 -40.522955 [73,] -198.028923 -179.434002 [74,] -121.428923 -198.028923 [75,] -194.978923 -121.428923 [76,] 61.446077 -194.978923 [77,] -43.178923 61.446077 [78,] 11.771077 -43.178923 [79,] -34.353923 11.771077 [80,] 3.371077 -34.353923 [81,] 122.801864 3.371077 [82,] 168.701864 122.801864 [83,] 270.614364 168.701864 [84,] 83.303316 270.614364 [85,] 280.008395 83.303316 [86,] -28.991605 280.008395 [87,] 252.658395 -28.991605 [88,] 253.683395 252.658395 [89,] 201.158395 253.683395 [90,] 104.908395 201.158395 [91,] 94.883395 104.908395 [92,] -159.791605 94.883395 [93,] -283.760818 -159.791605 [94,] -105.960818 -283.760818 [95,] -114.348318 -105.960818 [96,] -61.259365 -114.348318 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -79.006541 -55.611621 2 236.693459 -79.006541 3 56.343459 236.693459 4 145.568459 56.343459 5 251.143459 145.568459 6 145.793459 251.143459 7 144.968459 145.793459 8 67.093459 144.968459 9 153.724245 67.093459 10 67.424245 153.724245 11 140.536745 67.424245 12 117.325698 140.536745 13 70.630777 117.325698 14 43.830777 70.630777 15 -168.919223 43.830777 16 -50.994223 -168.919223 17 -77.219223 -50.994223 18 -171.569223 -77.219223 19 -119.594223 -171.569223 20 29.930777 -119.594223 21 -142.138437 29.930777 22 79.461563 -142.138437 23 28.474063 79.461563 24 17.763016 28.474063 25 35.868095 17.763016 26 -9.631905 35.868095 27 76.318095 -9.631905 28 -35.156905 76.318095 29 -110.681905 -35.156905 30 -37.031905 -110.681905 31 -4.356905 -37.031905 32 -89.531905 -4.356905 33 -178.101118 -89.531905 34 -59.901118 -178.101118 35 -178.488618 -59.901118 36 -146.399666 -178.488618 37 -57.294586 -146.399666 38 -192.494586 -57.294586 39 -131.944586 -192.494586 40 -184.119586 -131.944586 41 -237.744586 -184.119586 42 -142.294586 -237.744586 43 -228.219586 -142.294586 44 -146.294586 -228.219586 45 230.336200 -146.294586 46 96.036200 230.336200 47 -118.251300 96.036200 48 60.737653 -118.251300 49 -32.257268 60.737653 50 -22.057268 -32.257268 51 -21.107268 -22.057268 52 -112.782268 -21.107268 53 -6.507268 -112.782268 54 -88.857268 -6.507268 55 55.517732 -88.857268 56 105.642732 55.517732 57 91.173519 105.642732 58 103.473519 91.173519 59 11.986019 103.473519 60 163.574971 11.986019 61 -19.919949 163.574971 62 94.080051 -19.919949 63 131.630051 94.080051 64 -77.644949 131.630051 65 23.030051 -77.644949 66 177.280051 23.030051 67 91.155051 177.280051 68 189.580051 91.155051 69 5.964545 189.580051 70 -349.235455 5.964545 71 -40.522955 -349.235455 72 -179.434002 -40.522955 73 -198.028923 -179.434002 74 -121.428923 -198.028923 75 -194.978923 -121.428923 76 61.446077 -194.978923 77 -43.178923 61.446077 78 11.771077 -43.178923 79 -34.353923 11.771077 80 3.371077 -34.353923 81 122.801864 3.371077 82 168.701864 122.801864 83 270.614364 168.701864 84 83.303316 270.614364 85 280.008395 83.303316 86 -28.991605 280.008395 87 252.658395 -28.991605 88 253.683395 252.658395 89 201.158395 253.683395 90 104.908395 201.158395 91 94.883395 104.908395 92 -159.791605 94.883395 93 -283.760818 -159.791605 94 -105.960818 -283.760818 95 -114.348318 -105.960818 96 -61.259365 -114.348318 > 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/html/rcomp/tmp/7nugi1227192763.ps",horizontal=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/html/rcomp/tmp/8ugyb1227192763.ps",horizontal=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/html/rcomp/tmp/9tdep1227192763.ps",horizontal=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/html/rcomp/tmp/10y0f11227192763.ps",horizontal=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/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/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/html/rcomp/tmp/11wcfc1227192763.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/html/rcomp/tmp/12r2wz1227192763.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/html/rcomp/tmp/13b0fo1227192763.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/html/rcomp/tmp/14uwdm1227192763.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/html/rcomp/tmp/15f9zt1227192763.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/html/rcomp/tmp/166uqi1227192763.tab") + } > > system("convert tmp/1gz3f1227192763.ps tmp/1gz3f1227192763.png") > system("convert tmp/2bms91227192763.ps tmp/2bms91227192763.png") > system("convert tmp/3v6bj1227192763.ps tmp/3v6bj1227192763.png") > system("convert tmp/46qrn1227192763.ps tmp/46qrn1227192763.png") > system("convert tmp/5oyz21227192763.ps tmp/5oyz21227192763.png") > system("convert tmp/6zlwv1227192763.ps tmp/6zlwv1227192763.png") > system("convert tmp/7nugi1227192763.ps tmp/7nugi1227192763.png") > system("convert tmp/8ugyb1227192763.ps tmp/8ugyb1227192763.png") > system("convert tmp/9tdep1227192763.ps tmp/9tdep1227192763.png") > system("convert tmp/10y0f11227192763.ps tmp/10y0f11227192763.png") > > > proc.time() user system elapsed 2.876 1.637 4.251