R version 2.9.0 (2009-04-17) Copyright (C) 2009 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(2187 + ,18.8 + ,1855 + ,2218 + ,1852 + ,18.2 + ,2187 + ,1855 + ,1570 + ,18 + ,1852 + ,2187 + ,1851 + ,19 + ,1570 + ,1852 + ,1954 + ,20.7 + ,1851 + ,1570 + ,1828 + ,21.2 + ,1954 + ,1851 + ,2251 + ,20.7 + ,1828 + ,1954 + ,2277 + ,19.6 + ,2251 + ,1828 + ,2085 + ,18.6 + ,2277 + ,2251 + ,2282 + ,18.7 + ,2085 + ,2277 + ,2266 + ,23.8 + ,2282 + ,2085 + ,1878 + ,24.9 + ,2266 + ,2282 + ,2267 + ,24.8 + ,1878 + ,2266 + ,2069 + ,23.8 + ,2267 + ,1878 + ,1746 + ,22.3 + ,2069 + ,2267 + ,2299 + ,21.7 + ,1746 + ,2069 + ,2360 + ,20.7 + ,2299 + ,1746 + ,2214 + ,19.7 + ,2360 + ,2299 + ,2825 + ,18.4 + ,2214 + ,2360 + ,2355 + ,17.4 + ,2825 + ,2214 + ,2333 + ,17 + ,2355 + ,2825 + ,3016 + ,18 + ,2333 + ,2355 + ,2155 + ,23.8 + ,3016 + ,2333 + ,2172 + ,25.5 + ,2155 + ,3016 + ,2150 + ,25.6 + ,2172 + ,2155 + ,2533 + ,23.7 + ,2150 + ,2172 + ,2058 + ,22 + ,2533 + ,2150 + ,2160 + ,21.3 + ,2058 + ,2533 + ,2260 + ,20.7 + ,2160 + ,2058 + ,2498 + ,20.4 + ,2260 + ,2160 + ,2695 + ,20.3 + ,2498 + ,2260 + ,2799 + ,20.4 + ,2695 + ,2498 + ,2946 + ,19.8 + ,2799 + ,2695 + ,2930 + ,19.5 + ,2946 + ,2799 + ,2318 + ,23.1 + ,2930 + ,2946 + ,2540 + ,23.5 + ,2318 + ,2930 + ,2570 + ,23.5 + ,2540 + ,2318 + ,2669 + ,22.9 + ,2570 + ,2540 + ,2450 + ,21.9 + ,2669 + ,2570 + ,2842 + ,21.5 + ,2450 + ,2669 + ,3440 + ,20.5 + ,2842 + ,2450 + ,2678 + ,20.2 + ,3440 + ,2842 + ,2981 + ,19.4 + ,2678 + ,3440 + ,2260 + ,19.2 + ,2981 + ,2678 + ,2844 + ,18.8 + ,2260 + ,2981 + ,2546 + ,18.8 + ,2844 + ,2260 + ,2456 + ,22.6 + ,2546 + ,2844 + ,2295 + ,23.3 + ,2456 + ,2546 + ,2379 + ,23 + ,2295 + ,2456 + ,2479 + ,21.4 + ,2379 + ,2295 + ,2057 + ,19.9 + ,2479 + ,2379 + ,2280 + ,18.8 + ,2057 + ,2479 + ,2351 + ,18.6 + ,2280 + ,2057 + ,2276 + ,18.4 + ,2351 + ,2280 + ,2548 + ,18.6 + ,2276 + ,2351 + ,2311 + ,19.9 + ,2548 + ,2276 + ,2201 + ,19.2 + ,2311 + ,2548 + ,2725 + ,18.4 + ,2201 + ,2311) + ,dim=c(4 + ,58) + ,dimnames=list(c('Y' + ,'X' + ,'Y1' + ,'Y2') + ,1:58)) > y <- array(NA,dim=c(4,58),dimnames=list(c('Y','X','Y1','Y2'),1:58)) > 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 Y X Y1 Y2 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 2187 18.8 1855 2218 1 0 0 0 0 0 0 0 0 0 0 1 2 1852 18.2 2187 1855 0 1 0 0 0 0 0 0 0 0 0 2 3 1570 18.0 1852 2187 0 0 1 0 0 0 0 0 0 0 0 3 4 1851 19.0 1570 1852 0 0 0 1 0 0 0 0 0 0 0 4 5 1954 20.7 1851 1570 0 0 0 0 1 0 0 0 0 0 0 5 6 1828 21.2 1954 1851 0 0 0 0 0 1 0 0 0 0 0 6 7 2251 20.7 1828 1954 0 0 0 0 0 0 1 0 0 0 0 7 8 2277 19.6 2251 1828 0 0 0 0 0 0 0 1 0 0 0 8 9 2085 18.6 2277 2251 0 0 0 0 0 0 0 0 1 0 0 9 10 2282 18.7 2085 2277 0 0 0 0 0 0 0 0 0 1 0 10 11 2266 23.8 2282 2085 0 0 0 0 0 0 0 0 0 0 1 11 12 1878 24.9 2266 2282 0 0 0 0 0 0 0 0 0 0 0 12 13 2267 24.8 1878 2266 1 0 0 0 0 0 0 0 0 0 0 13 14 2069 23.8 2267 1878 0 1 0 0 0 0 0 0 0 0 0 14 15 1746 22.3 2069 2267 0 0 1 0 0 0 0 0 0 0 0 15 16 2299 21.7 1746 2069 0 0 0 1 0 0 0 0 0 0 0 16 17 2360 20.7 2299 1746 0 0 0 0 1 0 0 0 0 0 0 17 18 2214 19.7 2360 2299 0 0 0 0 0 1 0 0 0 0 0 18 19 2825 18.4 2214 2360 0 0 0 0 0 0 1 0 0 0 0 19 20 2355 17.4 2825 2214 0 0 0 0 0 0 0 1 0 0 0 20 21 2333 17.0 2355 2825 0 0 0 0 0 0 0 0 1 0 0 21 22 3016 18.0 2333 2355 0 0 0 0 0 0 0 0 0 1 0 22 23 2155 23.8 3016 2333 0 0 0 0 0 0 0 0 0 0 1 23 24 2172 25.5 2155 3016 0 0 0 0 0 0 0 0 0 0 0 24 25 2150 25.6 2172 2155 1 0 0 0 0 0 0 0 0 0 0 25 26 2533 23.7 2150 2172 0 1 0 0 0 0 0 0 0 0 0 26 27 2058 22.0 2533 2150 0 0 1 0 0 0 0 0 0 0 0 27 28 2160 21.3 2058 2533 0 0 0 1 0 0 0 0 0 0 0 28 29 2260 20.7 2160 2058 0 0 0 0 1 0 0 0 0 0 0 29 30 2498 20.4 2260 2160 0 0 0 0 0 1 0 0 0 0 0 30 31 2695 20.3 2498 2260 0 0 0 0 0 0 1 0 0 0 0 31 32 2799 20.4 2695 2498 0 0 0 0 0 0 0 1 0 0 0 32 33 2946 19.8 2799 2695 0 0 0 0 0 0 0 0 1 0 0 33 34 2930 19.5 2946 2799 0 0 0 0 0 0 0 0 0 1 0 34 35 2318 23.1 2930 2946 0 0 0 0 0 0 0 0 0 0 1 35 36 2540 23.5 2318 2930 0 0 0 0 0 0 0 0 0 0 0 36 37 2570 23.5 2540 2318 1 0 0 0 0 0 0 0 0 0 0 37 38 2669 22.9 2570 2540 0 1 0 0 0 0 0 0 0 0 0 38 39 2450 21.9 2669 2570 0 0 1 0 0 0 0 0 0 0 0 39 40 2842 21.5 2450 2669 0 0 0 1 0 0 0 0 0 0 0 40 41 3440 20.5 2842 2450 0 0 0 0 1 0 0 0 0 0 0 41 42 2678 20.2 3440 2842 0 0 0 0 0 1 0 0 0 0 0 42 43 2981 19.4 2678 3440 0 0 0 0 0 0 1 0 0 0 0 43 44 2260 19.2 2981 2678 0 0 0 0 0 0 0 1 0 0 0 44 45 2844 18.8 2260 2981 0 0 0 0 0 0 0 0 1 0 0 45 46 2546 18.8 2844 2260 0 0 0 0 0 0 0 0 0 1 0 46 47 2456 22.6 2546 2844 0 0 0 0 0 0 0 0 0 0 1 47 48 2295 23.3 2456 2546 0 0 0 0 0 0 0 0 0 0 0 48 49 2379 23.0 2295 2456 1 0 0 0 0 0 0 0 0 0 0 49 50 2479 21.4 2379 2295 0 1 0 0 0 0 0 0 0 0 0 50 51 2057 19.9 2479 2379 0 0 1 0 0 0 0 0 0 0 0 51 52 2280 18.8 2057 2479 0 0 0 1 0 0 0 0 0 0 0 52 53 2351 18.6 2280 2057 0 0 0 0 1 0 0 0 0 0 0 53 54 2276 18.4 2351 2280 0 0 0 0 0 1 0 0 0 0 0 54 55 2548 18.6 2276 2351 0 0 0 0 0 0 1 0 0 0 0 55 56 2311 19.9 2548 2276 0 0 0 0 0 0 0 1 0 0 0 56 57 2201 19.2 2311 2548 0 0 0 0 0 0 0 0 1 0 0 57 58 2725 18.4 2201 2311 0 0 0 0 0 0 0 0 0 1 0 58 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X Y1 Y2 M1 M2 -354.4058 29.7765 0.2907 0.4180 349.1248 399.9198 M3 M4 M5 M6 M7 M8 18.1139 433.0721 677.9641 325.6733 672.4825 384.1044 M9 M10 M11 t 406.5406 707.4416 52.8414 1.9341 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -412.44 -151.23 -28.66 149.70 576.50 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -354.4058 656.4642 -0.540 0.59214 X 29.7765 23.7072 1.256 0.21605 Y1 0.2907 0.1409 2.063 0.04532 * Y2 0.4180 0.1456 2.871 0.00638 ** M1 349.1248 165.3783 2.111 0.04076 * M2 399.9198 184.3405 2.169 0.03576 * M3 18.1139 187.0112 0.097 0.92330 M4 433.0721 185.2055 2.338 0.02421 * M5 677.9641 213.7765 3.171 0.00283 ** M6 325.6733 205.2202 1.587 0.12003 M7 672.4825 197.4077 3.407 0.00146 ** M8 384.1044 224.1885 1.713 0.09403 . M9 406.5406 207.3129 1.961 0.05653 . M10 707.4416 218.7015 3.235 0.00238 ** M11 52.8414 180.6311 0.293 0.77132 t 1.9341 2.3274 0.831 0.41069 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 231.9 on 42 degrees of freedom Multiple R-squared: 0.6798, Adjusted R-squared: 0.5654 F-statistic: 5.943 on 15 and 42 DF, p-value: 2.326e-06 > 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.028805423 0.05761085 0.9711946 [2,] 0.025939630 0.05187926 0.9740604 [3,] 0.049423175 0.09884635 0.9505768 [4,] 0.024667629 0.04933526 0.9753324 [5,] 0.012669780 0.02533956 0.9873302 [6,] 0.007539268 0.01507854 0.9924607 [7,] 0.176084656 0.35216931 0.8239153 [8,] 0.108074654 0.21614931 0.8919253 [9,] 0.067079689 0.13415938 0.9329203 [10,] 0.087255195 0.17451039 0.9127448 [11,] 0.429210506 0.85842101 0.5707895 [12,] 0.368034567 0.73606913 0.6319654 [13,] 0.349266745 0.69853349 0.6507333 [14,] 0.271655285 0.54331057 0.7283447 [15,] 0.380826457 0.76165291 0.6191735 [16,] 0.285140418 0.57028084 0.7148596 [17,] 0.276620582 0.55324116 0.7233794 [18,] 0.192462745 0.38492549 0.8075373 [19,] 0.123598086 0.24719617 0.8764019 [20,] 0.103621128 0.20724226 0.8963789 [21,] 0.091509061 0.18301812 0.9084909 > postscript(file="/var/www/html/rcomp/tmp/1as2j1258742931.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/20z4k1258742931.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/3gbzh1258742931.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/4syx01258742931.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/5xq3j1258742931.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 = 58 Frequency = 1 1 2 3 4 5 6 7 164.23036 -150.43807 -87.97699 -31.64646 -189.92467 -127.84572 -45.11804 8 9 10 11 12 13 14 229.76404 -141.18233 -205.04196 302.73743 -144.79431 15.61432 -156.26623 15 16 17 18 19 20 21 -159.74876 170.88459 -10.93915 -25.66783 292.24960 21.85615 -131.32986 22 23 24 25 26 27 28 421.89206 -148.51788 -166.37480 -187.49697 198.64008 51.97800 -264.05043 29 30 31 32 33 34 35 -224.13761 301.44813 41.69399 272.41433 300.33772 -95.76847 -219.08495 36 37 38 39 40 41 42 226.52469 96.71082 59.34039 208.66810 217.97866 576.49515 -163.90788 43 44 45 46 47 48 49 -214.23031 -412.44219 242.07382 -227.20315 64.86541 84.64442 -89.05853 50 51 52 53 54 55 56 48.72383 -12.92036 -93.16637 -151.49372 15.97330 -74.59524 -111.59232 57 58 -269.89934 106.12153 > postscript(file="/var/www/html/rcomp/tmp/6kui41258742931.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 = 58 Frequency = 1 lag(myerror, k = 1) myerror 0 164.23036 NA 1 -150.43807 164.23036 2 -87.97699 -150.43807 3 -31.64646 -87.97699 4 -189.92467 -31.64646 5 -127.84572 -189.92467 6 -45.11804 -127.84572 7 229.76404 -45.11804 8 -141.18233 229.76404 9 -205.04196 -141.18233 10 302.73743 -205.04196 11 -144.79431 302.73743 12 15.61432 -144.79431 13 -156.26623 15.61432 14 -159.74876 -156.26623 15 170.88459 -159.74876 16 -10.93915 170.88459 17 -25.66783 -10.93915 18 292.24960 -25.66783 19 21.85615 292.24960 20 -131.32986 21.85615 21 421.89206 -131.32986 22 -148.51788 421.89206 23 -166.37480 -148.51788 24 -187.49697 -166.37480 25 198.64008 -187.49697 26 51.97800 198.64008 27 -264.05043 51.97800 28 -224.13761 -264.05043 29 301.44813 -224.13761 30 41.69399 301.44813 31 272.41433 41.69399 32 300.33772 272.41433 33 -95.76847 300.33772 34 -219.08495 -95.76847 35 226.52469 -219.08495 36 96.71082 226.52469 37 59.34039 96.71082 38 208.66810 59.34039 39 217.97866 208.66810 40 576.49515 217.97866 41 -163.90788 576.49515 42 -214.23031 -163.90788 43 -412.44219 -214.23031 44 242.07382 -412.44219 45 -227.20315 242.07382 46 64.86541 -227.20315 47 84.64442 64.86541 48 -89.05853 84.64442 49 48.72383 -89.05853 50 -12.92036 48.72383 51 -93.16637 -12.92036 52 -151.49372 -93.16637 53 15.97330 -151.49372 54 -74.59524 15.97330 55 -111.59232 -74.59524 56 -269.89934 -111.59232 57 106.12153 -269.89934 58 NA 106.12153 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -150.43807 164.23036 [2,] -87.97699 -150.43807 [3,] -31.64646 -87.97699 [4,] -189.92467 -31.64646 [5,] -127.84572 -189.92467 [6,] -45.11804 -127.84572 [7,] 229.76404 -45.11804 [8,] -141.18233 229.76404 [9,] -205.04196 -141.18233 [10,] 302.73743 -205.04196 [11,] -144.79431 302.73743 [12,] 15.61432 -144.79431 [13,] -156.26623 15.61432 [14,] -159.74876 -156.26623 [15,] 170.88459 -159.74876 [16,] -10.93915 170.88459 [17,] -25.66783 -10.93915 [18,] 292.24960 -25.66783 [19,] 21.85615 292.24960 [20,] -131.32986 21.85615 [21,] 421.89206 -131.32986 [22,] -148.51788 421.89206 [23,] -166.37480 -148.51788 [24,] -187.49697 -166.37480 [25,] 198.64008 -187.49697 [26,] 51.97800 198.64008 [27,] -264.05043 51.97800 [28,] -224.13761 -264.05043 [29,] 301.44813 -224.13761 [30,] 41.69399 301.44813 [31,] 272.41433 41.69399 [32,] 300.33772 272.41433 [33,] -95.76847 300.33772 [34,] -219.08495 -95.76847 [35,] 226.52469 -219.08495 [36,] 96.71082 226.52469 [37,] 59.34039 96.71082 [38,] 208.66810 59.34039 [39,] 217.97866 208.66810 [40,] 576.49515 217.97866 [41,] -163.90788 576.49515 [42,] -214.23031 -163.90788 [43,] -412.44219 -214.23031 [44,] 242.07382 -412.44219 [45,] -227.20315 242.07382 [46,] 64.86541 -227.20315 [47,] 84.64442 64.86541 [48,] -89.05853 84.64442 [49,] 48.72383 -89.05853 [50,] -12.92036 48.72383 [51,] -93.16637 -12.92036 [52,] -151.49372 -93.16637 [53,] 15.97330 -151.49372 [54,] -74.59524 15.97330 [55,] -111.59232 -74.59524 [56,] -269.89934 -111.59232 [57,] 106.12153 -269.89934 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -150.43807 164.23036 2 -87.97699 -150.43807 3 -31.64646 -87.97699 4 -189.92467 -31.64646 5 -127.84572 -189.92467 6 -45.11804 -127.84572 7 229.76404 -45.11804 8 -141.18233 229.76404 9 -205.04196 -141.18233 10 302.73743 -205.04196 11 -144.79431 302.73743 12 15.61432 -144.79431 13 -156.26623 15.61432 14 -159.74876 -156.26623 15 170.88459 -159.74876 16 -10.93915 170.88459 17 -25.66783 -10.93915 18 292.24960 -25.66783 19 21.85615 292.24960 20 -131.32986 21.85615 21 421.89206 -131.32986 22 -148.51788 421.89206 23 -166.37480 -148.51788 24 -187.49697 -166.37480 25 198.64008 -187.49697 26 51.97800 198.64008 27 -264.05043 51.97800 28 -224.13761 -264.05043 29 301.44813 -224.13761 30 41.69399 301.44813 31 272.41433 41.69399 32 300.33772 272.41433 33 -95.76847 300.33772 34 -219.08495 -95.76847 35 226.52469 -219.08495 36 96.71082 226.52469 37 59.34039 96.71082 38 208.66810 59.34039 39 217.97866 208.66810 40 576.49515 217.97866 41 -163.90788 576.49515 42 -214.23031 -163.90788 43 -412.44219 -214.23031 44 242.07382 -412.44219 45 -227.20315 242.07382 46 64.86541 -227.20315 47 84.64442 64.86541 48 -89.05853 84.64442 49 48.72383 -89.05853 50 -12.92036 48.72383 51 -93.16637 -12.92036 52 -151.49372 -93.16637 53 15.97330 -151.49372 54 -74.59524 15.97330 55 -111.59232 -74.59524 56 -269.89934 -111.59232 57 106.12153 -269.89934 > 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/7rmq61258742931.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/8qg951258742931.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/94fhe1258742931.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/10lovj1258742931.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/110zdw1258742931.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/12temq1258742931.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/13gspc1258742931.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/14umq81258742931.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/151aok1258742931.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/16f0zz1258742931.tab") + } > system("convert tmp/1as2j1258742931.ps tmp/1as2j1258742931.png") > system("convert tmp/20z4k1258742931.ps tmp/20z4k1258742931.png") > system("convert tmp/3gbzh1258742931.ps tmp/3gbzh1258742931.png") > system("convert tmp/4syx01258742931.ps tmp/4syx01258742931.png") > system("convert tmp/5xq3j1258742931.ps tmp/5xq3j1258742931.png") > system("convert tmp/6kui41258742931.ps tmp/6kui41258742931.png") > system("convert tmp/7rmq61258742931.ps tmp/7rmq61258742931.png") > system("convert tmp/8qg951258742931.ps tmp/8qg951258742931.png") > system("convert tmp/94fhe1258742931.ps tmp/94fhe1258742931.png") > system("convert tmp/10lovj1258742931.ps tmp/10lovj1258742931.png") > > > proc.time() user system elapsed 2.450 1.609 3.841