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(15991.2 + ,0 + ,16704.4 + ,17420.4 + ,17872 + ,17823.2 + ,15583.6 + ,0 + ,15991.2 + ,16704.4 + ,17420.4 + ,17872 + ,19123.5 + ,0 + ,15583.6 + ,15991.2 + ,16704.4 + ,17420.4 + ,17838.7 + ,0 + ,19123.5 + ,15583.6 + ,15991.2 + ,16704.4 + ,17209.4 + ,0 + ,17838.7 + ,19123.5 + ,15583.6 + ,15991.2 + ,18586.5 + ,0 + ,17209.4 + ,17838.7 + ,19123.5 + ,15583.6 + ,16258.1 + ,0 + ,18586.5 + ,17209.4 + ,17838.7 + ,19123.5 + ,15141.6 + ,0 + ,16258.1 + ,18586.5 + ,17209.4 + ,17838.7 + ,19202.1 + ,0 + ,15141.6 + ,16258.1 + ,18586.5 + ,17209.4 + ,17746.5 + ,0 + ,19202.1 + ,15141.6 + ,16258.1 + ,18586.5 + ,19090.1 + ,1 + ,17746.5 + ,19202.1 + ,15141.6 + ,16258.1 + ,18040.3 + ,1 + ,19090.1 + ,17746.5 + ,19202.1 + ,15141.6 + ,17515.5 + ,1 + ,18040.3 + ,19090.1 + ,17746.5 + ,19202.1 + ,17751.8 + ,1 + ,17515.5 + ,18040.3 + ,19090.1 + ,17746.5 + ,21072.4 + ,1 + ,17751.8 + ,17515.5 + ,18040.3 + ,19090.1 + ,17170 + ,1 + ,21072.4 + ,17751.8 + ,17515.5 + ,18040.3 + ,19439.5 + ,1 + ,17170 + ,21072.4 + ,17751.8 + ,17515.5 + ,19795.4 + ,1 + ,19439.5 + ,17170 + ,21072.4 + ,17751.8 + ,17574.9 + ,1 + ,19795.4 + ,19439.5 + ,17170 + ,21072.4 + ,16165.4 + ,1 + ,17574.9 + ,19795.4 + ,19439.5 + ,17170 + ,19464.6 + ,1 + ,16165.4 + ,17574.9 + ,19795.4 + ,19439.5 + ,19932.1 + ,1 + ,19464.6 + ,16165.4 + ,17574.9 + ,19795.4 + ,19961.2 + ,1 + ,19932.1 + ,19464.6 + ,16165.4 + ,17574.9 + ,17343.4 + ,1 + ,19961.2 + ,19932.1 + ,19464.6 + ,16165.4 + ,18924.2 + ,1 + ,17343.4 + ,19961.2 + ,19932.1 + ,19464.6 + ,18574.1 + ,1 + ,18924.2 + ,17343.4 + ,19961.2 + ,19932.1 + ,21350.6 + ,1 + ,18574.1 + ,18924.2 + ,17343.4 + ,19961.2 + ,18594.6 + ,1 + ,21350.6 + ,18574.1 + ,18924.2 + ,17343.4 + ,19832.1 + ,1 + ,18594.6 + ,21350.6 + ,18574.1 + ,18924.2 + ,20844.4 + ,1 + ,19832.1 + ,18594.6 + ,21350.6 + ,18574.1 + ,19640.2 + ,1 + ,20844.4 + ,19832.1 + ,18594.6 + ,21350.6 + ,17735.4 + ,1 + ,19640.2 + ,20844.4 + ,19832.1 + ,18594.6 + ,19813.6 + ,1 + ,17735.4 + ,19640.2 + ,20844.4 + ,19832.1 + ,22160 + ,1 + ,19813.6 + ,17735.4 + ,19640.2 + ,20844.4 + ,20664.3 + ,1 + ,22160 + ,19813.6 + ,17735.4 + ,19640.2 + ,17877.4 + ,1 + ,20664.3 + ,22160 + ,19813.6 + ,17735.4 + ,20906.5 + ,1 + ,17877.4 + ,20664.3 + ,22160 + ,19813.6 + ,21164.1 + ,1 + ,20906.5 + ,17877.4 + ,20664.3 + ,22160 + ,21374.4 + ,1 + ,21164.1 + ,20906.5 + ,17877.4 + ,20664.3 + ,22952.3 + ,1 + ,21374.4 + ,21164.1 + ,20906.5 + ,17877.4 + ,21343.5 + ,1 + ,22952.3 + ,21374.4 + ,21164.1 + ,20906.5 + ,23899.3 + ,1 + ,21343.5 + ,22952.3 + ,21374.4 + ,21164.1 + ,22392.9 + ,1 + ,23899.3 + ,21343.5 + ,22952.3 + ,21374.4 + ,18274.1 + ,1 + ,22392.9 + ,23899.3 + ,21343.5 + ,22952.3 + ,22786.7 + ,1 + ,18274.1 + ,22392.9 + ,23899.3 + ,21343.5 + ,22321.5 + ,1 + ,22786.7 + ,18274.1 + ,22392.9 + ,23899.3 + ,17842.2 + ,1 + ,22321.5 + ,22786.7 + ,18274.1 + ,22392.9 + ,16373.5 + ,1 + ,17842.2 + ,22321.5 + ,22786.7 + ,18274.1 + ,15933.8 + ,0 + ,16373.5 + ,17842.2 + ,22321.5 + ,22786.7 + ,16446.1 + ,0 + ,15933.8 + ,16373.5 + ,17842.2 + ,22321.5 + ,17729 + ,0 + ,16446.1 + ,15933.8 + ,16373.5 + ,17842.2 + ,16643 + ,0 + ,17729 + ,16446.1 + ,15933.8 + ,16373.5 + ,16196.7 + ,0 + ,16643 + ,17729 + ,16446.1 + ,15933.8 + ,18252.1 + ,0 + ,16196.7 + ,16643 + ,17729 + ,16446.1 + ,17570.4 + ,0 + ,18252.1 + ,16196.7 + ,16643 + ,17729 + ,15836.8 + ,0 + ,17570.4 + ,18252.1 + ,16196.7 + ,16643) + ,dim=c(6 + ,56) + ,dimnames=list(c('Y' + ,'X' + ,'Y1' + ,'Y2' + ,'Y3' + ,'Y4') + ,1:56)) > y <- array(NA,dim=c(6,56),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),1:56)) > 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 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 1 15991.2 0 16704.4 17420.4 17872.0 17823.2 1 0 0 0 0 0 0 0 0 0 0 2 15583.6 0 15991.2 16704.4 17420.4 17872.0 0 1 0 0 0 0 0 0 0 0 0 3 19123.5 0 15583.6 15991.2 16704.4 17420.4 0 0 1 0 0 0 0 0 0 0 0 4 17838.7 0 19123.5 15583.6 15991.2 16704.4 0 0 0 1 0 0 0 0 0 0 0 5 17209.4 0 17838.7 19123.5 15583.6 15991.2 0 0 0 0 1 0 0 0 0 0 0 6 18586.5 0 17209.4 17838.7 19123.5 15583.6 0 0 0 0 0 1 0 0 0 0 0 7 16258.1 0 18586.5 17209.4 17838.7 19123.5 0 0 0 0 0 0 1 0 0 0 0 8 15141.6 0 16258.1 18586.5 17209.4 17838.7 0 0 0 0 0 0 0 1 0 0 0 9 19202.1 0 15141.6 16258.1 18586.5 17209.4 0 0 0 0 0 0 0 0 1 0 0 10 17746.5 0 19202.1 15141.6 16258.1 18586.5 0 0 0 0 0 0 0 0 0 1 0 11 19090.1 1 17746.5 19202.1 15141.6 16258.1 0 0 0 0 0 0 0 0 0 0 1 12 18040.3 1 19090.1 17746.5 19202.1 15141.6 0 0 0 0 0 0 0 0 0 0 0 13 17515.5 1 18040.3 19090.1 17746.5 19202.1 1 0 0 0 0 0 0 0 0 0 0 14 17751.8 1 17515.5 18040.3 19090.1 17746.5 0 1 0 0 0 0 0 0 0 0 0 15 21072.4 1 17751.8 17515.5 18040.3 19090.1 0 0 1 0 0 0 0 0 0 0 0 16 17170.0 1 21072.4 17751.8 17515.5 18040.3 0 0 0 1 0 0 0 0 0 0 0 17 19439.5 1 17170.0 21072.4 17751.8 17515.5 0 0 0 0 1 0 0 0 0 0 0 18 19795.4 1 19439.5 17170.0 21072.4 17751.8 0 0 0 0 0 1 0 0 0 0 0 19 17574.9 1 19795.4 19439.5 17170.0 21072.4 0 0 0 0 0 0 1 0 0 0 0 20 16165.4 1 17574.9 19795.4 19439.5 17170.0 0 0 0 0 0 0 0 1 0 0 0 21 19464.6 1 16165.4 17574.9 19795.4 19439.5 0 0 0 0 0 0 0 0 1 0 0 22 19932.1 1 19464.6 16165.4 17574.9 19795.4 0 0 0 0 0 0 0 0 0 1 0 23 19961.2 1 19932.1 19464.6 16165.4 17574.9 0 0 0 0 0 0 0 0 0 0 1 24 17343.4 1 19961.2 19932.1 19464.6 16165.4 0 0 0 0 0 0 0 0 0 0 0 25 18924.2 1 17343.4 19961.2 19932.1 19464.6 1 0 0 0 0 0 0 0 0 0 0 26 18574.1 1 18924.2 17343.4 19961.2 19932.1 0 1 0 0 0 0 0 0 0 0 0 27 21350.6 1 18574.1 18924.2 17343.4 19961.2 0 0 1 0 0 0 0 0 0 0 0 28 18594.6 1 21350.6 18574.1 18924.2 17343.4 0 0 0 1 0 0 0 0 0 0 0 29 19832.1 1 18594.6 21350.6 18574.1 18924.2 0 0 0 0 1 0 0 0 0 0 0 30 20844.4 1 19832.1 18594.6 21350.6 18574.1 0 0 0 0 0 1 0 0 0 0 0 31 19640.2 1 20844.4 19832.1 18594.6 21350.6 0 0 0 0 0 0 1 0 0 0 0 32 17735.4 1 19640.2 20844.4 19832.1 18594.6 0 0 0 0 0 0 0 1 0 0 0 33 19813.6 1 17735.4 19640.2 20844.4 19832.1 0 0 0 0 0 0 0 0 1 0 0 34 22160.0 1 19813.6 17735.4 19640.2 20844.4 0 0 0 0 0 0 0 0 0 1 0 35 20664.3 1 22160.0 19813.6 17735.4 19640.2 0 0 0 0 0 0 0 0 0 0 1 36 17877.4 1 20664.3 22160.0 19813.6 17735.4 0 0 0 0 0 0 0 0 0 0 0 37 20906.5 1 17877.4 20664.3 22160.0 19813.6 1 0 0 0 0 0 0 0 0 0 0 38 21164.1 1 20906.5 17877.4 20664.3 22160.0 0 1 0 0 0 0 0 0 0 0 0 39 21374.4 1 21164.1 20906.5 17877.4 20664.3 0 0 1 0 0 0 0 0 0 0 0 40 22952.3 1 21374.4 21164.1 20906.5 17877.4 0 0 0 1 0 0 0 0 0 0 0 41 21343.5 1 22952.3 21374.4 21164.1 20906.5 0 0 0 0 1 0 0 0 0 0 0 42 23899.3 1 21343.5 22952.3 21374.4 21164.1 0 0 0 0 0 1 0 0 0 0 0 43 22392.9 1 23899.3 21343.5 22952.3 21374.4 0 0 0 0 0 0 1 0 0 0 0 44 18274.1 1 22392.9 23899.3 21343.5 22952.3 0 0 0 0 0 0 0 1 0 0 0 45 22786.7 1 18274.1 22392.9 23899.3 21343.5 0 0 0 0 0 0 0 0 1 0 0 46 22321.5 1 22786.7 18274.1 22392.9 23899.3 0 0 0 0 0 0 0 0 0 1 0 47 17842.2 1 22321.5 22786.7 18274.1 22392.9 0 0 0 0 0 0 0 0 0 0 1 48 16373.5 1 17842.2 22321.5 22786.7 18274.1 0 0 0 0 0 0 0 0 0 0 0 49 15933.8 0 16373.5 17842.2 22321.5 22786.7 1 0 0 0 0 0 0 0 0 0 0 50 16446.1 0 15933.8 16373.5 17842.2 22321.5 0 1 0 0 0 0 0 0 0 0 0 51 17729.0 0 16446.1 15933.8 16373.5 17842.2 0 0 1 0 0 0 0 0 0 0 0 52 16643.0 0 17729.0 16446.1 15933.8 16373.5 0 0 0 1 0 0 0 0 0 0 0 53 16196.7 0 16643.0 17729.0 16446.1 15933.8 0 0 0 0 1 0 0 0 0 0 0 54 18252.1 0 16196.7 16643.0 17729.0 16446.1 0 0 0 0 0 1 0 0 0 0 0 55 17570.4 0 18252.1 16196.7 16643.0 17729.0 0 0 0 0 0 0 1 0 0 0 0 56 15836.8 0 17570.4 18252.1 16196.7 16643.0 0 0 0 0 0 0 0 1 0 0 0 t 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52 53 53 54 54 55 55 56 56 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X Y1 Y2 Y3 Y4 3086.0701 1029.8777 0.3491 0.2444 0.3356 -0.3311 M1 M2 M3 M4 M5 M6 3112.6595 3772.7513 6074.5867 3017.5201 3327.1813 4366.0652 M7 M8 M9 M10 M11 t 3452.4689 1033.4568 5183.7650 5750.9558 3520.3457 8.6493 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -2278.78 -694.07 18.68 703.16 1829.62 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3086.0701 2743.3672 1.125 0.267678 X 1029.8777 530.1116 1.943 0.059482 . Y1 0.3491 0.1542 2.264 0.029398 * Y2 0.2444 0.1580 1.547 0.130167 Y3 0.3356 0.1498 2.240 0.031004 * Y4 -0.3311 0.1584 -2.090 0.043368 * M1 3112.6595 1032.3437 3.015 0.004560 ** M2 3772.7513 1128.1042 3.344 0.001864 ** M3 6074.5867 1043.8123 5.820 1.01e-06 *** M4 3017.5201 915.1617 3.297 0.002124 ** M5 3327.1813 860.2241 3.868 0.000417 *** M6 4366.0652 832.9423 5.242 6.23e-06 *** M7 3452.4689 1027.1517 3.361 0.001779 ** M8 1033.4568 861.2548 1.200 0.237589 M9 5183.7650 1064.6990 4.869 2.00e-05 *** M10 5750.9558 1254.2653 4.585 4.81e-05 *** M11 3520.3457 1065.2627 3.305 0.002081 ** t 8.6493 11.2984 0.766 0.448682 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1119 on 38 degrees of freedom Multiple R-squared: 0.8104, Adjusted R-squared: 0.7256 F-statistic: 9.554 on 17 and 38 DF, p-value: 5.257e-09 > 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.42066495 0.84132990 0.5793350 [2,] 0.26287297 0.52574594 0.7371270 [3,] 0.15147147 0.30294293 0.8485285 [4,] 0.11560091 0.23120183 0.8843991 [5,] 0.05982307 0.11964614 0.9401769 [6,] 0.05893040 0.11786080 0.9410696 [7,] 0.04683915 0.09367830 0.9531609 [8,] 0.06594033 0.13188067 0.9340597 [9,] 0.03762956 0.07525913 0.9623704 [10,] 0.02868472 0.05736944 0.9713153 [11,] 0.04323941 0.08647882 0.9567606 [12,] 0.04700125 0.09400249 0.9529988 [13,] 0.08502063 0.17004125 0.9149794 [14,] 0.16691444 0.33382887 0.8330856 [15,] 0.11695035 0.23390070 0.8830497 > postscript(file="/var/www/html/rcomp/tmp/1cmt71259248140.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/2j14r1259248140.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/341231259248140.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/4pesa1259248140.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/5wfwr1259248140.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 = 56 Frequency = 1 1 2 3 4 5 6 -400.215646 -884.915856 751.801274 1381.467732 -82.019746 -541.589633 7 8 9 10 11 12 -688.788842 867.163058 1056.999634 -881.865629 773.411220 1389.745540 13 14 15 16 17 18 -385.286237 -1310.801033 542.211397 -1700.254105 548.781600 -1017.531006 19 20 21 22 23 24 -602.958204 -967.553503 -160.598545 -213.330632 806.041058 1.775318 25 26 27 28 29 30 303.577241 -482.398213 607.593961 -1380.955308 462.786587 -378.580483 31 32 33 34 35 36 510.487717 -138.724090 -1190.172115 1059.605457 699.324865 44.846497 37 38 39 40 41 42 1191.829000 1683.048531 -807.362886 1743.384846 130.568562 1829.618310 43 44 45 46 47 48 269.222083 -475.570764 293.771026 35.590804 -2278.777143 -1436.367356 49 50 51 52 53 54 -709.904358 995.066570 -1094.243746 -43.643166 -1060.117003 108.082812 55 56 512.037246 714.685298 > postscript(file="/var/www/html/rcomp/tmp/6r5mz1259248140.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 = 56 Frequency = 1 lag(myerror, k = 1) myerror 0 -400.215646 NA 1 -884.915856 -400.215646 2 751.801274 -884.915856 3 1381.467732 751.801274 4 -82.019746 1381.467732 5 -541.589633 -82.019746 6 -688.788842 -541.589633 7 867.163058 -688.788842 8 1056.999634 867.163058 9 -881.865629 1056.999634 10 773.411220 -881.865629 11 1389.745540 773.411220 12 -385.286237 1389.745540 13 -1310.801033 -385.286237 14 542.211397 -1310.801033 15 -1700.254105 542.211397 16 548.781600 -1700.254105 17 -1017.531006 548.781600 18 -602.958204 -1017.531006 19 -967.553503 -602.958204 20 -160.598545 -967.553503 21 -213.330632 -160.598545 22 806.041058 -213.330632 23 1.775318 806.041058 24 303.577241 1.775318 25 -482.398213 303.577241 26 607.593961 -482.398213 27 -1380.955308 607.593961 28 462.786587 -1380.955308 29 -378.580483 462.786587 30 510.487717 -378.580483 31 -138.724090 510.487717 32 -1190.172115 -138.724090 33 1059.605457 -1190.172115 34 699.324865 1059.605457 35 44.846497 699.324865 36 1191.829000 44.846497 37 1683.048531 1191.829000 38 -807.362886 1683.048531 39 1743.384846 -807.362886 40 130.568562 1743.384846 41 1829.618310 130.568562 42 269.222083 1829.618310 43 -475.570764 269.222083 44 293.771026 -475.570764 45 35.590804 293.771026 46 -2278.777143 35.590804 47 -1436.367356 -2278.777143 48 -709.904358 -1436.367356 49 995.066570 -709.904358 50 -1094.243746 995.066570 51 -43.643166 -1094.243746 52 -1060.117003 -43.643166 53 108.082812 -1060.117003 54 512.037246 108.082812 55 714.685298 512.037246 56 NA 714.685298 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -884.915856 -400.215646 [2,] 751.801274 -884.915856 [3,] 1381.467732 751.801274 [4,] -82.019746 1381.467732 [5,] -541.589633 -82.019746 [6,] -688.788842 -541.589633 [7,] 867.163058 -688.788842 [8,] 1056.999634 867.163058 [9,] -881.865629 1056.999634 [10,] 773.411220 -881.865629 [11,] 1389.745540 773.411220 [12,] -385.286237 1389.745540 [13,] -1310.801033 -385.286237 [14,] 542.211397 -1310.801033 [15,] -1700.254105 542.211397 [16,] 548.781600 -1700.254105 [17,] -1017.531006 548.781600 [18,] -602.958204 -1017.531006 [19,] -967.553503 -602.958204 [20,] -160.598545 -967.553503 [21,] -213.330632 -160.598545 [22,] 806.041058 -213.330632 [23,] 1.775318 806.041058 [24,] 303.577241 1.775318 [25,] -482.398213 303.577241 [26,] 607.593961 -482.398213 [27,] -1380.955308 607.593961 [28,] 462.786587 -1380.955308 [29,] -378.580483 462.786587 [30,] 510.487717 -378.580483 [31,] -138.724090 510.487717 [32,] -1190.172115 -138.724090 [33,] 1059.605457 -1190.172115 [34,] 699.324865 1059.605457 [35,] 44.846497 699.324865 [36,] 1191.829000 44.846497 [37,] 1683.048531 1191.829000 [38,] -807.362886 1683.048531 [39,] 1743.384846 -807.362886 [40,] 130.568562 1743.384846 [41,] 1829.618310 130.568562 [42,] 269.222083 1829.618310 [43,] -475.570764 269.222083 [44,] 293.771026 -475.570764 [45,] 35.590804 293.771026 [46,] -2278.777143 35.590804 [47,] -1436.367356 -2278.777143 [48,] -709.904358 -1436.367356 [49,] 995.066570 -709.904358 [50,] -1094.243746 995.066570 [51,] -43.643166 -1094.243746 [52,] -1060.117003 -43.643166 [53,] 108.082812 -1060.117003 [54,] 512.037246 108.082812 [55,] 714.685298 512.037246 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -884.915856 -400.215646 2 751.801274 -884.915856 3 1381.467732 751.801274 4 -82.019746 1381.467732 5 -541.589633 -82.019746 6 -688.788842 -541.589633 7 867.163058 -688.788842 8 1056.999634 867.163058 9 -881.865629 1056.999634 10 773.411220 -881.865629 11 1389.745540 773.411220 12 -385.286237 1389.745540 13 -1310.801033 -385.286237 14 542.211397 -1310.801033 15 -1700.254105 542.211397 16 548.781600 -1700.254105 17 -1017.531006 548.781600 18 -602.958204 -1017.531006 19 -967.553503 -602.958204 20 -160.598545 -967.553503 21 -213.330632 -160.598545 22 806.041058 -213.330632 23 1.775318 806.041058 24 303.577241 1.775318 25 -482.398213 303.577241 26 607.593961 -482.398213 27 -1380.955308 607.593961 28 462.786587 -1380.955308 29 -378.580483 462.786587 30 510.487717 -378.580483 31 -138.724090 510.487717 32 -1190.172115 -138.724090 33 1059.605457 -1190.172115 34 699.324865 1059.605457 35 44.846497 699.324865 36 1191.829000 44.846497 37 1683.048531 1191.829000 38 -807.362886 1683.048531 39 1743.384846 -807.362886 40 130.568562 1743.384846 41 1829.618310 130.568562 42 269.222083 1829.618310 43 -475.570764 269.222083 44 293.771026 -475.570764 45 35.590804 293.771026 46 -2278.777143 35.590804 47 -1436.367356 -2278.777143 48 -709.904358 -1436.367356 49 995.066570 -709.904358 50 -1094.243746 995.066570 51 -43.643166 -1094.243746 52 -1060.117003 -43.643166 53 108.082812 -1060.117003 54 512.037246 108.082812 55 714.685298 512.037246 > 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/7uent1259248140.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/8nxwz1259248140.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/9w4l91259248140.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/10radi1259248140.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/114xm91259248140.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/12ese51259248140.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/13t6x41259248140.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/14nq0b1259248140.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/15epl81259248140.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/16ffsi1259248140.tab") + } > system("convert tmp/1cmt71259248140.ps tmp/1cmt71259248140.png") > system("convert tmp/2j14r1259248140.ps tmp/2j14r1259248140.png") > system("convert tmp/341231259248140.ps tmp/341231259248140.png") > system("convert tmp/4pesa1259248140.ps tmp/4pesa1259248140.png") > system("convert tmp/5wfwr1259248140.ps tmp/5wfwr1259248140.png") > system("convert tmp/6r5mz1259248140.ps tmp/6r5mz1259248140.png") > system("convert tmp/7uent1259248140.ps tmp/7uent1259248140.png") > system("convert tmp/8nxwz1259248140.ps tmp/8nxwz1259248140.png") > system("convert tmp/9w4l91259248140.ps tmp/9w4l91259248140.png") > system("convert tmp/10radi1259248140.ps tmp/10radi1259248140.png") > > > proc.time() user system elapsed 2.381 1.550 3.511