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(21.3 + ,2533 + ,21.8 + ,19.2 + ,20 + ,20.3 + ,21.5 + ,2058 + ,21.3 + ,21.8 + ,19.2 + ,20 + ,19.5 + ,2160 + ,21.5 + ,21.3 + ,21.8 + ,19.2 + ,19.5 + ,2260 + ,19.5 + ,21.5 + ,21.3 + ,21.8 + ,19.7 + ,2498 + ,19.5 + ,19.5 + ,21.5 + ,21.3 + ,18.7 + ,2695 + ,19.7 + ,19.5 + ,19.5 + ,21.5 + ,19.7 + ,2799 + ,18.7 + ,19.7 + ,19.5 + ,19.5 + ,20 + ,2946 + ,19.7 + ,18.7 + ,19.7 + ,19.5 + ,19.7 + ,2930 + ,20 + ,19.7 + ,18.7 + ,19.7 + ,19.2 + ,2318 + ,19.7 + ,20 + ,19.7 + ,18.7 + ,19.7 + ,2540 + ,19.2 + ,19.7 + ,20 + ,19.7 + ,22 + ,2570 + ,19.7 + ,19.2 + ,19.7 + ,20 + ,21.8 + ,2669 + ,22 + ,19.7 + ,19.2 + ,19.7 + ,22.8 + ,2450 + ,21.8 + ,22 + ,19.7 + ,19.2 + ,21 + ,2842 + ,22.8 + ,21.8 + ,22 + ,19.7 + ,25 + ,3440 + ,21 + ,22.8 + ,21.8 + ,22 + ,23.3 + ,2678 + ,25 + ,21 + ,22.8 + ,21.8 + ,25 + ,2981 + ,23.3 + ,25 + ,21 + ,22.8 + ,26.8 + ,2260 + ,25 + ,23.3 + ,25 + ,21 + ,25.3 + ,2844 + ,26.8 + ,25 + ,23.3 + ,25 + ,26.5 + ,2546 + ,25.3 + ,26.8 + ,25 + ,23.3 + ,27.8 + ,2456 + ,26.5 + ,25.3 + ,26.8 + ,25 + ,22 + ,2295 + ,27.8 + ,26.5 + ,25.3 + ,26.8 + ,22.3 + ,2379 + ,22 + ,27.8 + ,26.5 + ,25.3 + ,28 + ,2479 + ,22.3 + ,22 + ,27.8 + ,26.5 + ,25 + ,2057 + ,28 + ,22.3 + ,22 + ,27.8 + ,27.3 + ,2280 + ,25 + ,28 + ,22.3 + ,22 + ,25.8 + ,2351 + ,27.3 + ,25 + ,28 + ,22.3 + ,27.3 + ,2276 + ,25.8 + ,27.3 + ,25 + ,28 + ,23.5 + ,2548 + ,27.3 + ,25.8 + ,27.3 + ,25 + ,24.5 + ,2311 + ,23.5 + ,27.3 + ,25.8 + ,27.3 + ,18 + ,2201 + ,24.5 + ,23.5 + ,27.3 + ,25.8 + ,21.3 + ,2725 + ,18 + ,24.5 + ,23.5 + ,27.3 + ,21.8 + ,2408 + ,21.3 + ,18 + ,24.5 + ,23.5 + ,20.5 + ,2139 + ,21.8 + ,21.3 + ,18 + ,24.5 + ,22.3 + ,1898 + ,20.5 + ,21.8 + ,21.3 + ,18 + ,18.7 + ,2537 + ,22.3 + ,20.5 + ,21.8 + ,21.3 + ,22.3 + ,2068 + ,18.7 + ,22.3 + ,20.5 + ,21.8 + ,17.7 + ,2063 + ,22.3 + ,18.7 + ,22.3 + ,20.5 + ,19.7 + ,2520 + ,17.7 + ,22.3 + ,18.7 + ,22.3 + ,20.5 + ,2434 + ,19.7 + ,17.7 + ,22.3 + ,18.7 + ,18.5 + ,2190 + ,20.5 + ,19.7 + ,17.7 + ,22.3 + ,10 + ,2794 + ,18.5 + ,20.5 + ,19.7 + ,17.7 + ,14.2 + ,2070 + ,10 + ,18.5 + ,20.5 + ,19.7 + ,15.5 + ,2615 + ,14.2 + ,10 + ,18.5 + ,20.5 + ,16.5 + ,2265 + ,15.5 + ,14.2 + ,10 + ,18.5 + ,20.5 + ,2139 + ,16.5 + ,15.5 + ,14.2 + ,10 + ,15.7 + ,2428 + ,20.5 + ,16.5 + ,15.5 + ,14.2 + ,11.7 + ,2137 + ,15.7 + ,20.5 + ,16.5 + ,15.5 + ,7.5 + ,1823 + ,11.7 + ,15.7 + ,20.5 + ,16.5 + ,3.5 + ,2063 + ,7.5 + ,11.7 + ,15.7 + ,20.5 + ,4.5 + ,1806 + ,3.5 + ,7.5 + ,11.7 + ,15.7 + ,2.2 + ,1758 + ,4.5 + ,3.5 + ,7.5 + ,11.7 + ,5 + ,2243 + ,2.2 + ,4.5 + ,3.5 + ,7.5 + ,2.3 + ,1993 + ,5 + ,2.2 + ,4.5 + ,3.5 + ,6.1 + ,1932 + ,2.3 + ,5 + ,2.2 + ,4.5 + ,3.3 + ,2465 + ,6.1 + ,2.3 + ,5 + ,2.2) + ,dim=c(6 + ,57) + ,dimnames=list(c('Y' + ,'X' + ,'Y1' + ,'Y2' + ,'Y3' + ,'Y4') + ,1:57)) > y <- array(NA,dim=c(6,57),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),1:57)) > 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 t 1 21.3 2533 21.8 19.2 20.0 20.3 1 0 0 0 0 0 0 0 0 0 0 1 2 21.5 2058 21.3 21.8 19.2 20.0 0 1 0 0 0 0 0 0 0 0 0 2 3 19.5 2160 21.5 21.3 21.8 19.2 0 0 1 0 0 0 0 0 0 0 0 3 4 19.5 2260 19.5 21.5 21.3 21.8 0 0 0 1 0 0 0 0 0 0 0 4 5 19.7 2498 19.5 19.5 21.5 21.3 0 0 0 0 1 0 0 0 0 0 0 5 6 18.7 2695 19.7 19.5 19.5 21.5 0 0 0 0 0 1 0 0 0 0 0 6 7 19.7 2799 18.7 19.7 19.5 19.5 0 0 0 0 0 0 1 0 0 0 0 7 8 20.0 2946 19.7 18.7 19.7 19.5 0 0 0 0 0 0 0 1 0 0 0 8 9 19.7 2930 20.0 19.7 18.7 19.7 0 0 0 0 0 0 0 0 1 0 0 9 10 19.2 2318 19.7 20.0 19.7 18.7 0 0 0 0 0 0 0 0 0 1 0 10 11 19.7 2540 19.2 19.7 20.0 19.7 0 0 0 0 0 0 0 0 0 0 1 11 12 22.0 2570 19.7 19.2 19.7 20.0 0 0 0 0 0 0 0 0 0 0 0 12 13 21.8 2669 22.0 19.7 19.2 19.7 1 0 0 0 0 0 0 0 0 0 0 13 14 22.8 2450 21.8 22.0 19.7 19.2 0 1 0 0 0 0 0 0 0 0 0 14 15 21.0 2842 22.8 21.8 22.0 19.7 0 0 1 0 0 0 0 0 0 0 0 15 16 25.0 3440 21.0 22.8 21.8 22.0 0 0 0 1 0 0 0 0 0 0 0 16 17 23.3 2678 25.0 21.0 22.8 21.8 0 0 0 0 1 0 0 0 0 0 0 17 18 25.0 2981 23.3 25.0 21.0 22.8 0 0 0 0 0 1 0 0 0 0 0 18 19 26.8 2260 25.0 23.3 25.0 21.0 0 0 0 0 0 0 1 0 0 0 0 19 20 25.3 2844 26.8 25.0 23.3 25.0 0 0 0 0 0 0 0 1 0 0 0 20 21 26.5 2546 25.3 26.8 25.0 23.3 0 0 0 0 0 0 0 0 1 0 0 21 22 27.8 2456 26.5 25.3 26.8 25.0 0 0 0 0 0 0 0 0 0 1 0 22 23 22.0 2295 27.8 26.5 25.3 26.8 0 0 0 0 0 0 0 0 0 0 1 23 24 22.3 2379 22.0 27.8 26.5 25.3 0 0 0 0 0 0 0 0 0 0 0 24 25 28.0 2479 22.3 22.0 27.8 26.5 1 0 0 0 0 0 0 0 0 0 0 25 26 25.0 2057 28.0 22.3 22.0 27.8 0 1 0 0 0 0 0 0 0 0 0 26 27 27.3 2280 25.0 28.0 22.3 22.0 0 0 1 0 0 0 0 0 0 0 0 27 28 25.8 2351 27.3 25.0 28.0 22.3 0 0 0 1 0 0 0 0 0 0 0 28 29 27.3 2276 25.8 27.3 25.0 28.0 0 0 0 0 1 0 0 0 0 0 0 29 30 23.5 2548 27.3 25.8 27.3 25.0 0 0 0 0 0 1 0 0 0 0 0 30 31 24.5 2311 23.5 27.3 25.8 27.3 0 0 0 0 0 0 1 0 0 0 0 31 32 18.0 2201 24.5 23.5 27.3 25.8 0 0 0 0 0 0 0 1 0 0 0 32 33 21.3 2725 18.0 24.5 23.5 27.3 0 0 0 0 0 0 0 0 1 0 0 33 34 21.8 2408 21.3 18.0 24.5 23.5 0 0 0 0 0 0 0 0 0 1 0 34 35 20.5 2139 21.8 21.3 18.0 24.5 0 0 0 0 0 0 0 0 0 0 1 35 36 22.3 1898 20.5 21.8 21.3 18.0 0 0 0 0 0 0 0 0 0 0 0 36 37 18.7 2537 22.3 20.5 21.8 21.3 1 0 0 0 0 0 0 0 0 0 0 37 38 22.3 2068 18.7 22.3 20.5 21.8 0 1 0 0 0 0 0 0 0 0 0 38 39 17.7 2063 22.3 18.7 22.3 20.5 0 0 1 0 0 0 0 0 0 0 0 39 40 19.7 2520 17.7 22.3 18.7 22.3 0 0 0 1 0 0 0 0 0 0 0 40 41 20.5 2434 19.7 17.7 22.3 18.7 0 0 0 0 1 0 0 0 0 0 0 41 42 18.5 2190 20.5 19.7 17.7 22.3 0 0 0 0 0 1 0 0 0 0 0 42 43 10.0 2794 18.5 20.5 19.7 17.7 0 0 0 0 0 0 1 0 0 0 0 43 44 14.2 2070 10.0 18.5 20.5 19.7 0 0 0 0 0 0 0 1 0 0 0 44 45 15.5 2615 14.2 10.0 18.5 20.5 0 0 0 0 0 0 0 0 1 0 0 45 46 16.5 2265 15.5 14.2 10.0 18.5 0 0 0 0 0 0 0 0 0 1 0 46 47 20.5 2139 16.5 15.5 14.2 10.0 0 0 0 0 0 0 0 0 0 0 1 47 48 15.7 2428 20.5 16.5 15.5 14.2 0 0 0 0 0 0 0 0 0 0 0 48 49 11.7 2137 15.7 20.5 16.5 15.5 1 0 0 0 0 0 0 0 0 0 0 49 50 7.5 1823 11.7 15.7 20.5 16.5 0 1 0 0 0 0 0 0 0 0 0 50 51 3.5 2063 7.5 11.7 15.7 20.5 0 0 1 0 0 0 0 0 0 0 0 51 52 4.5 1806 3.5 7.5 11.7 15.7 0 0 0 1 0 0 0 0 0 0 0 52 53 2.2 1758 4.5 3.5 7.5 11.7 0 0 0 0 1 0 0 0 0 0 0 53 54 5.0 2243 2.2 4.5 3.5 7.5 0 0 0 0 0 1 0 0 0 0 0 54 55 2.3 1993 5.0 2.2 4.5 3.5 0 0 0 0 0 0 1 0 0 0 0 55 56 6.1 1932 2.3 5.0 2.2 4.5 0 0 0 0 0 0 0 1 0 0 0 56 57 3.3 2465 6.1 2.3 5.0 2.2 0 0 0 0 0 0 0 0 1 0 0 57 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X Y1 Y2 Y3 Y4 1.8542278 0.0006048 0.5744850 0.3918863 -0.0635822 -0.0054746 M1 M2 M3 M4 M5 M6 -0.3017605 -0.4171006 -1.9987818 0.3516046 0.3162734 -0.6063672 M7 M8 M9 M10 M11 t -1.5354831 -0.3885013 0.5600185 1.3251348 -0.1559111 -0.0496907 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -7.18410 -1.51021 -0.01465 1.41658 6.67058 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.8542278 5.0740531 0.365 0.71676 X 0.0006048 0.0017560 0.344 0.73237 Y1 0.5744850 0.1640869 3.501 0.00118 ** Y2 0.3918863 0.1897302 2.065 0.04557 * Y3 -0.0635822 0.1929700 -0.329 0.74355 Y4 -0.0054746 0.1673520 -0.033 0.97407 M1 -0.3017605 2.0620446 -0.146 0.88441 M2 -0.4171006 2.1002739 -0.199 0.84361 M3 -1.9987818 2.0431679 -0.978 0.33397 M4 0.3516046 2.1102332 0.167 0.86853 M5 0.3162734 2.1127328 0.150 0.88177 M6 -0.6063672 2.1276731 -0.285 0.77716 M7 -1.5354831 2.0482913 -0.750 0.45797 M8 -0.3885013 2.0799452 -0.187 0.85280 M9 0.5600185 2.2119551 0.253 0.80146 M10 1.3251348 2.2139383 0.599 0.55294 M11 -0.1559111 2.1724501 -0.072 0.94315 t -0.0496907 0.0346648 -1.433 0.15970 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 3.009 on 39 degrees of freedom Multiple R-squared: 0.8706, Adjusted R-squared: 0.8142 F-statistic: 15.43 on 17 and 39 DF, p-value: 2.585e-12 > 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.010573638 0.021147275 0.9894264 [2,] 0.003011653 0.006023307 0.9969883 [3,] 0.011626517 0.023253034 0.9883735 [4,] 0.035969433 0.071938866 0.9640306 [5,] 0.064553861 0.129107723 0.9354461 [6,] 0.031582907 0.063165813 0.9684171 [7,] 0.061010910 0.122021819 0.9389891 [8,] 0.054006583 0.108013167 0.9459934 [9,] 0.027056780 0.054113560 0.9729432 [10,] 0.028747107 0.057494213 0.9712529 [11,] 0.037370218 0.074740436 0.9626298 [12,] 0.152253198 0.304506395 0.8477468 [13,] 0.086878841 0.173757682 0.9131212 [14,] 0.062856831 0.125713661 0.9371432 [15,] 0.128070572 0.256141144 0.8719294 [16,] 0.068592549 0.137185098 0.9314075 > postscript(file="/var/www/html/rcomp/tmp/1tkij1258727926.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/2b1xy1258727926.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/33sf51258727926.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/4w80y1258727926.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/5sf931258727926.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 = 57 Frequency = 1 1 2 3 4 5 6 -0.40001251 -0.53185917 -0.72019936 -2.02834219 -1.09351730 -1.48130349 7 8 9 10 11 12 0.91975970 -0.13632329 -1.95219421 -2.68457886 -0.35875608 1.70814702 13 14 15 16 17 18 0.24902826 0.78912836 0.03627691 2.01595672 -0.66820093 1.12097381 19 20 21 22 23 24 4.26991717 -0.46706376 0.26946066 0.93067158 -4.54382781 -1.51020608 25 26 27 28 29 30 6.67058380 0.33706098 3.61058167 -0.01465239 1.41657920 -1.71968524 31 32 33 34 35 36 1.91489714 -4.61401888 0.57908863 1.24963189 -0.34521026 2.21945624 37 38 39 40 41 42 -1.89034024 3.44118524 -0.07444315 0.36125400 2.16118529 -0.23503605 43 44 45 46 47 48 -7.18410244 2.08521086 2.95216289 0.50427539 5.24779415 -2.41739718 49 50 51 52 53 54 -4.62925931 -4.03551540 -2.85221606 -0.33421614 -1.81604627 2.31505097 55 56 57 0.07952844 3.13219507 -1.84851797 > postscript(file="/var/www/html/rcomp/tmp/6gbfn1258727926.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 = 57 Frequency = 1 lag(myerror, k = 1) myerror 0 -0.40001251 NA 1 -0.53185917 -0.40001251 2 -0.72019936 -0.53185917 3 -2.02834219 -0.72019936 4 -1.09351730 -2.02834219 5 -1.48130349 -1.09351730 6 0.91975970 -1.48130349 7 -0.13632329 0.91975970 8 -1.95219421 -0.13632329 9 -2.68457886 -1.95219421 10 -0.35875608 -2.68457886 11 1.70814702 -0.35875608 12 0.24902826 1.70814702 13 0.78912836 0.24902826 14 0.03627691 0.78912836 15 2.01595672 0.03627691 16 -0.66820093 2.01595672 17 1.12097381 -0.66820093 18 4.26991717 1.12097381 19 -0.46706376 4.26991717 20 0.26946066 -0.46706376 21 0.93067158 0.26946066 22 -4.54382781 0.93067158 23 -1.51020608 -4.54382781 24 6.67058380 -1.51020608 25 0.33706098 6.67058380 26 3.61058167 0.33706098 27 -0.01465239 3.61058167 28 1.41657920 -0.01465239 29 -1.71968524 1.41657920 30 1.91489714 -1.71968524 31 -4.61401888 1.91489714 32 0.57908863 -4.61401888 33 1.24963189 0.57908863 34 -0.34521026 1.24963189 35 2.21945624 -0.34521026 36 -1.89034024 2.21945624 37 3.44118524 -1.89034024 38 -0.07444315 3.44118524 39 0.36125400 -0.07444315 40 2.16118529 0.36125400 41 -0.23503605 2.16118529 42 -7.18410244 -0.23503605 43 2.08521086 -7.18410244 44 2.95216289 2.08521086 45 0.50427539 2.95216289 46 5.24779415 0.50427539 47 -2.41739718 5.24779415 48 -4.62925931 -2.41739718 49 -4.03551540 -4.62925931 50 -2.85221606 -4.03551540 51 -0.33421614 -2.85221606 52 -1.81604627 -0.33421614 53 2.31505097 -1.81604627 54 0.07952844 2.31505097 55 3.13219507 0.07952844 56 -1.84851797 3.13219507 57 NA -1.84851797 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -0.53185917 -0.40001251 [2,] -0.72019936 -0.53185917 [3,] -2.02834219 -0.72019936 [4,] -1.09351730 -2.02834219 [5,] -1.48130349 -1.09351730 [6,] 0.91975970 -1.48130349 [7,] -0.13632329 0.91975970 [8,] -1.95219421 -0.13632329 [9,] -2.68457886 -1.95219421 [10,] -0.35875608 -2.68457886 [11,] 1.70814702 -0.35875608 [12,] 0.24902826 1.70814702 [13,] 0.78912836 0.24902826 [14,] 0.03627691 0.78912836 [15,] 2.01595672 0.03627691 [16,] -0.66820093 2.01595672 [17,] 1.12097381 -0.66820093 [18,] 4.26991717 1.12097381 [19,] -0.46706376 4.26991717 [20,] 0.26946066 -0.46706376 [21,] 0.93067158 0.26946066 [22,] -4.54382781 0.93067158 [23,] -1.51020608 -4.54382781 [24,] 6.67058380 -1.51020608 [25,] 0.33706098 6.67058380 [26,] 3.61058167 0.33706098 [27,] -0.01465239 3.61058167 [28,] 1.41657920 -0.01465239 [29,] -1.71968524 1.41657920 [30,] 1.91489714 -1.71968524 [31,] -4.61401888 1.91489714 [32,] 0.57908863 -4.61401888 [33,] 1.24963189 0.57908863 [34,] -0.34521026 1.24963189 [35,] 2.21945624 -0.34521026 [36,] -1.89034024 2.21945624 [37,] 3.44118524 -1.89034024 [38,] -0.07444315 3.44118524 [39,] 0.36125400 -0.07444315 [40,] 2.16118529 0.36125400 [41,] -0.23503605 2.16118529 [42,] -7.18410244 -0.23503605 [43,] 2.08521086 -7.18410244 [44,] 2.95216289 2.08521086 [45,] 0.50427539 2.95216289 [46,] 5.24779415 0.50427539 [47,] -2.41739718 5.24779415 [48,] -4.62925931 -2.41739718 [49,] -4.03551540 -4.62925931 [50,] -2.85221606 -4.03551540 [51,] -0.33421614 -2.85221606 [52,] -1.81604627 -0.33421614 [53,] 2.31505097 -1.81604627 [54,] 0.07952844 2.31505097 [55,] 3.13219507 0.07952844 [56,] -1.84851797 3.13219507 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -0.53185917 -0.40001251 2 -0.72019936 -0.53185917 3 -2.02834219 -0.72019936 4 -1.09351730 -2.02834219 5 -1.48130349 -1.09351730 6 0.91975970 -1.48130349 7 -0.13632329 0.91975970 8 -1.95219421 -0.13632329 9 -2.68457886 -1.95219421 10 -0.35875608 -2.68457886 11 1.70814702 -0.35875608 12 0.24902826 1.70814702 13 0.78912836 0.24902826 14 0.03627691 0.78912836 15 2.01595672 0.03627691 16 -0.66820093 2.01595672 17 1.12097381 -0.66820093 18 4.26991717 1.12097381 19 -0.46706376 4.26991717 20 0.26946066 -0.46706376 21 0.93067158 0.26946066 22 -4.54382781 0.93067158 23 -1.51020608 -4.54382781 24 6.67058380 -1.51020608 25 0.33706098 6.67058380 26 3.61058167 0.33706098 27 -0.01465239 3.61058167 28 1.41657920 -0.01465239 29 -1.71968524 1.41657920 30 1.91489714 -1.71968524 31 -4.61401888 1.91489714 32 0.57908863 -4.61401888 33 1.24963189 0.57908863 34 -0.34521026 1.24963189 35 2.21945624 -0.34521026 36 -1.89034024 2.21945624 37 3.44118524 -1.89034024 38 -0.07444315 3.44118524 39 0.36125400 -0.07444315 40 2.16118529 0.36125400 41 -0.23503605 2.16118529 42 -7.18410244 -0.23503605 43 2.08521086 -7.18410244 44 2.95216289 2.08521086 45 0.50427539 2.95216289 46 5.24779415 0.50427539 47 -2.41739718 5.24779415 48 -4.62925931 -2.41739718 49 -4.03551540 -4.62925931 50 -2.85221606 -4.03551540 51 -0.33421614 -2.85221606 52 -1.81604627 -0.33421614 53 2.31505097 -1.81604627 54 0.07952844 2.31505097 55 3.13219507 0.07952844 56 -1.84851797 3.13219507 > 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/76ila1258727926.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/8s7hn1258727926.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/9vg9a1258727926.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/10hmo41258727926.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/11yxqn1258727926.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/12p87c1258727926.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/130aw81258727926.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/1411fs1258727926.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/1532sm1258727926.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/16omzz1258727926.tab") + } > > system("convert tmp/1tkij1258727926.ps tmp/1tkij1258727926.png") > system("convert tmp/2b1xy1258727926.ps tmp/2b1xy1258727926.png") > system("convert tmp/33sf51258727926.ps tmp/33sf51258727926.png") > system("convert tmp/4w80y1258727926.ps tmp/4w80y1258727926.png") > system("convert tmp/5sf931258727926.ps tmp/5sf931258727926.png") > system("convert tmp/6gbfn1258727926.ps tmp/6gbfn1258727926.png") > system("convert tmp/76ila1258727926.ps tmp/76ila1258727926.png") > system("convert tmp/8s7hn1258727926.ps tmp/8s7hn1258727926.png") > system("convert tmp/9vg9a1258727926.ps tmp/9vg9a1258727926.png") > system("convert tmp/10hmo41258727926.ps tmp/10hmo41258727926.png") > > > proc.time() user system elapsed 2.416 1.606 3.632