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(20.7 + ,7.8 + ,21.3 + ,22 + ,23.7 + ,25.6 + ,20.4 + ,7.8 + ,20.7 + ,21.3 + ,22 + ,23.7 + ,20.3 + ,7.8 + ,20.4 + ,20.7 + ,21.3 + ,22 + ,20.4 + ,7.5 + ,20.3 + ,20.4 + ,20.7 + ,21.3 + ,19.8 + ,7.5 + ,20.4 + ,20.3 + ,20.4 + ,20.7 + ,19.5 + ,7.1 + ,19.8 + ,20.4 + ,20.3 + ,20.4 + ,23.1 + ,7.5 + ,19.5 + ,19.8 + ,20.4 + ,20.3 + ,23.5 + ,7.5 + ,23.1 + ,19.5 + ,19.8 + ,20.4 + ,23.5 + ,7.6 + ,23.5 + ,23.1 + ,19.5 + ,19.8 + ,22.9 + ,7.7 + ,23.5 + ,23.5 + ,23.1 + ,19.5 + ,21.9 + ,7.7 + ,22.9 + ,23.5 + ,23.5 + ,23.1 + ,21.5 + ,7.9 + ,21.9 + ,22.9 + ,23.5 + ,23.5 + ,20.5 + ,8.1 + ,21.5 + ,21.9 + ,22.9 + ,23.5 + ,20.2 + ,8.2 + ,20.5 + ,21.5 + ,21.9 + ,22.9 + ,19.4 + ,8.2 + ,20.2 + ,20.5 + ,21.5 + ,21.9 + ,19.2 + ,8.2 + ,19.4 + ,20.2 + ,20.5 + ,21.5 + ,18.8 + ,7.9 + ,19.2 + ,19.4 + ,20.2 + ,20.5 + ,18.8 + ,7.3 + ,18.8 + ,19.2 + ,19.4 + ,20.2 + ,22.6 + ,6.9 + ,18.8 + ,18.8 + ,19.2 + ,19.4 + ,23.3 + ,6.6 + ,22.6 + ,18.8 + ,18.8 + ,19.2 + ,23 + ,6.7 + ,23.3 + ,22.6 + ,18.8 + ,18.8 + ,21.4 + ,6.9 + ,23 + ,23.3 + ,22.6 + ,18.8 + ,19.9 + ,7 + ,21.4 + ,23 + ,23.3 + ,22.6 + ,18.8 + ,7.1 + ,19.9 + ,21.4 + ,23 + ,23.3 + ,18.6 + ,7.2 + ,18.8 + ,19.9 + ,21.4 + ,23 + ,18.4 + ,7.1 + ,18.6 + ,18.8 + ,19.9 + ,21.4 + ,18.6 + ,6.9 + ,18.4 + ,18.6 + ,18.8 + ,19.9 + ,19.9 + ,7 + ,18.6 + ,18.4 + ,18.6 + ,18.8 + ,19.2 + ,6.8 + ,19.9 + ,18.6 + ,18.4 + ,18.6 + ,18.4 + ,6.4 + ,19.2 + ,19.9 + ,18.6 + ,18.4 + ,21.1 + ,6.7 + ,18.4 + ,19.2 + ,19.9 + ,18.6 + ,20.5 + ,6.6 + ,21.1 + ,18.4 + ,19.2 + ,19.9 + ,19.1 + ,6.4 + ,20.5 + ,21.1 + ,18.4 + ,19.2 + ,18.1 + ,6.3 + ,19.1 + ,20.5 + ,21.1 + ,18.4 + ,17 + ,6.2 + ,18.1 + ,19.1 + ,20.5 + ,21.1 + ,17.1 + ,6.5 + ,17 + ,18.1 + ,19.1 + ,20.5 + ,17.4 + ,6.8 + ,17.1 + ,17 + ,18.1 + ,19.1 + ,16.8 + ,6.8 + ,17.4 + ,17.1 + ,17 + ,18.1 + ,15.3 + ,6.4 + ,16.8 + ,17.4 + ,17.1 + ,17 + ,14.3 + ,6.1 + ,15.3 + ,16.8 + ,17.4 + ,17.1 + ,13.4 + ,5.8 + ,14.3 + ,15.3 + ,16.8 + ,17.4 + ,15.3 + ,6.1 + ,13.4 + ,14.3 + ,15.3 + ,16.8 + ,22.1 + ,7.2 + ,15.3 + ,13.4 + ,14.3 + ,15.3 + ,23.7 + ,7.3 + ,22.1 + ,15.3 + ,13.4 + ,14.3 + ,22.2 + ,6.9 + ,23.7 + ,22.1 + ,15.3 + ,13.4 + ,19.5 + ,6.1 + ,22.2 + ,23.7 + ,22.1 + ,15.3 + ,16.6 + ,5.8 + ,19.5 + ,22.2 + ,23.7 + ,22.1 + ,17.3 + ,6.2 + ,16.6 + ,19.5 + ,22.2 + ,23.7 + ,19.8 + ,7.1 + ,17.3 + ,16.6 + ,19.5 + ,22.2 + ,21.2 + ,7.7 + ,19.8 + ,17.3 + ,16.6 + ,19.5 + ,21.5 + ,7.9 + ,21.2 + ,19.8 + ,17.3 + ,16.6 + ,20.6 + ,7.7 + ,21.5 + ,21.2 + ,19.8 + ,17.3 + ,19.1 + ,7.4 + ,20.6 + ,21.5 + ,21.2 + ,19.8 + ,19.6 + ,7.5 + ,19.1 + ,20.6 + ,21.5 + ,21.2 + ,23.5 + ,8 + ,19.6 + ,19.1 + ,20.6 + ,21.5 + ,24 + ,8.1 + ,23.5 + ,19.6 + ,19.1 + ,20.6) + ,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 = 'No 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 20.7 7.8 21.3 22.0 23.7 25.6 1 0 0 0 0 0 0 0 0 0 0 2 20.4 7.8 20.7 21.3 22.0 23.7 0 1 0 0 0 0 0 0 0 0 0 3 20.3 7.8 20.4 20.7 21.3 22.0 0 0 1 0 0 0 0 0 0 0 0 4 20.4 7.5 20.3 20.4 20.7 21.3 0 0 0 1 0 0 0 0 0 0 0 5 19.8 7.5 20.4 20.3 20.4 20.7 0 0 0 0 1 0 0 0 0 0 0 6 19.5 7.1 19.8 20.4 20.3 20.4 0 0 0 0 0 1 0 0 0 0 0 7 23.1 7.5 19.5 19.8 20.4 20.3 0 0 0 0 0 0 1 0 0 0 0 8 23.5 7.5 23.1 19.5 19.8 20.4 0 0 0 0 0 0 0 1 0 0 0 9 23.5 7.6 23.5 23.1 19.5 19.8 0 0 0 0 0 0 0 0 1 0 0 10 22.9 7.7 23.5 23.5 23.1 19.5 0 0 0 0 0 0 0 0 0 1 0 11 21.9 7.7 22.9 23.5 23.5 23.1 0 0 0 0 0 0 0 0 0 0 1 12 21.5 7.9 21.9 22.9 23.5 23.5 0 0 0 0 0 0 0 0 0 0 0 13 20.5 8.1 21.5 21.9 22.9 23.5 1 0 0 0 0 0 0 0 0 0 0 14 20.2 8.2 20.5 21.5 21.9 22.9 0 1 0 0 0 0 0 0 0 0 0 15 19.4 8.2 20.2 20.5 21.5 21.9 0 0 1 0 0 0 0 0 0 0 0 16 19.2 8.2 19.4 20.2 20.5 21.5 0 0 0 1 0 0 0 0 0 0 0 17 18.8 7.9 19.2 19.4 20.2 20.5 0 0 0 0 1 0 0 0 0 0 0 18 18.8 7.3 18.8 19.2 19.4 20.2 0 0 0 0 0 1 0 0 0 0 0 19 22.6 6.9 18.8 18.8 19.2 19.4 0 0 0 0 0 0 1 0 0 0 0 20 23.3 6.6 22.6 18.8 18.8 19.2 0 0 0 0 0 0 0 1 0 0 0 21 23.0 6.7 23.3 22.6 18.8 18.8 0 0 0 0 0 0 0 0 1 0 0 22 21.4 6.9 23.0 23.3 22.6 18.8 0 0 0 0 0 0 0 0 0 1 0 23 19.9 7.0 21.4 23.0 23.3 22.6 0 0 0 0 0 0 0 0 0 0 1 24 18.8 7.1 19.9 21.4 23.0 23.3 0 0 0 0 0 0 0 0 0 0 0 25 18.6 7.2 18.8 19.9 21.4 23.0 1 0 0 0 0 0 0 0 0 0 0 26 18.4 7.1 18.6 18.8 19.9 21.4 0 1 0 0 0 0 0 0 0 0 0 27 18.6 6.9 18.4 18.6 18.8 19.9 0 0 1 0 0 0 0 0 0 0 0 28 19.9 7.0 18.6 18.4 18.6 18.8 0 0 0 1 0 0 0 0 0 0 0 29 19.2 6.8 19.9 18.6 18.4 18.6 0 0 0 0 1 0 0 0 0 0 0 30 18.4 6.4 19.2 19.9 18.6 18.4 0 0 0 0 0 1 0 0 0 0 0 31 21.1 6.7 18.4 19.2 19.9 18.6 0 0 0 0 0 0 1 0 0 0 0 32 20.5 6.6 21.1 18.4 19.2 19.9 0 0 0 0 0 0 0 1 0 0 0 33 19.1 6.4 20.5 21.1 18.4 19.2 0 0 0 0 0 0 0 0 1 0 0 34 18.1 6.3 19.1 20.5 21.1 18.4 0 0 0 0 0 0 0 0 0 1 0 35 17.0 6.2 18.1 19.1 20.5 21.1 0 0 0 0 0 0 0 0 0 0 1 36 17.1 6.5 17.0 18.1 19.1 20.5 0 0 0 0 0 0 0 0 0 0 0 37 17.4 6.8 17.1 17.0 18.1 19.1 1 0 0 0 0 0 0 0 0 0 0 38 16.8 6.8 17.4 17.1 17.0 18.1 0 1 0 0 0 0 0 0 0 0 0 39 15.3 6.4 16.8 17.4 17.1 17.0 0 0 1 0 0 0 0 0 0 0 0 40 14.3 6.1 15.3 16.8 17.4 17.1 0 0 0 1 0 0 0 0 0 0 0 41 13.4 5.8 14.3 15.3 16.8 17.4 0 0 0 0 1 0 0 0 0 0 0 42 15.3 6.1 13.4 14.3 15.3 16.8 0 0 0 0 0 1 0 0 0 0 0 43 22.1 7.2 15.3 13.4 14.3 15.3 0 0 0 0 0 0 1 0 0 0 0 44 23.7 7.3 22.1 15.3 13.4 14.3 0 0 0 0 0 0 0 1 0 0 0 45 22.2 6.9 23.7 22.1 15.3 13.4 0 0 0 0 0 0 0 0 1 0 0 46 19.5 6.1 22.2 23.7 22.1 15.3 0 0 0 0 0 0 0 0 0 1 0 47 16.6 5.8 19.5 22.2 23.7 22.1 0 0 0 0 0 0 0 0 0 0 1 48 17.3 6.2 16.6 19.5 22.2 23.7 0 0 0 0 0 0 0 0 0 0 0 49 19.8 7.1 17.3 16.6 19.5 22.2 1 0 0 0 0 0 0 0 0 0 0 50 21.2 7.7 19.8 17.3 16.6 19.5 0 1 0 0 0 0 0 0 0 0 0 51 21.5 7.9 21.2 19.8 17.3 16.6 0 0 1 0 0 0 0 0 0 0 0 52 20.6 7.7 21.5 21.2 19.8 17.3 0 0 0 1 0 0 0 0 0 0 0 53 19.1 7.4 20.6 21.5 21.2 19.8 0 0 0 0 1 0 0 0 0 0 0 54 19.6 7.5 19.1 20.6 21.5 21.2 0 0 0 0 0 1 0 0 0 0 0 55 23.5 8.0 19.6 19.1 20.6 21.5 0 0 0 0 0 0 1 0 0 0 0 56 24.0 8.1 23.5 19.6 19.1 20.6 0 0 0 0 0 0 0 1 0 0 0 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X Y1 Y2 Y3 Y4 1.2179 0.4841 1.4774 -1.0025 0.1429 0.1602 M1 M2 M3 M4 M5 M6 -0.8897 -1.0398 -0.8778 -0.3723 -1.2920 0.1903 M7 M8 M9 M10 M11 3.0410 -2.1655 0.6368 0.3070 -0.6563 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -0.82984 -0.34234 -0.07999 0.38874 1.13490 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.2179 1.0702 1.138 0.26208 X 0.4841 0.2492 1.943 0.05925 . Y1 1.4774 0.1787 8.269 4.16e-10 *** Y2 -1.0025 0.2982 -3.361 0.00175 ** Y3 0.1429 0.2946 0.485 0.63040 Y4 0.1602 0.1512 1.059 0.29598 M1 -0.8897 0.4165 -2.136 0.03899 * M2 -1.0398 0.4332 -2.400 0.02124 * M3 -0.8778 0.4360 -2.014 0.05099 . M4 -0.3723 0.4397 -0.847 0.40228 M5 -1.2920 0.4300 -3.004 0.00463 ** M6 0.1903 0.4228 0.450 0.65516 M7 3.0410 0.4818 6.311 1.91e-07 *** M8 -2.1655 0.7911 -2.737 0.00928 ** M9 0.6368 0.7901 0.806 0.42518 M10 0.3070 0.6900 0.445 0.65882 M11 -0.6563 0.4399 -1.492 0.14373 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.5711 on 39 degrees of freedom Multiple R-squared: 0.9613, Adjusted R-squared: 0.9454 F-statistic: 60.49 on 16 and 39 DF, p-value: < 2.2e-16 > 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.09806775 0.19613550 0.9019323 [2,] 0.07783176 0.15566352 0.9221682 [3,] 0.11066494 0.22132987 0.8893351 [4,] 0.06128819 0.12257639 0.9387118 [5,] 0.06278865 0.12557730 0.9372114 [6,] 0.06321065 0.12642130 0.9367894 [7,] 0.03168406 0.06336813 0.9683159 [8,] 0.01691372 0.03382744 0.9830863 [9,] 0.12510181 0.25020362 0.8748982 [10,] 0.15295961 0.30591923 0.8470404 [11,] 0.11022116 0.22044232 0.8897788 [12,] 0.07331312 0.14662624 0.9266869 [13,] 0.06566723 0.13133447 0.9343328 [14,] 0.05252420 0.10504839 0.9474758 [15,] 0.03985626 0.07971253 0.9601437 [16,] 0.04684591 0.09369183 0.9531541 [17,] 0.58828024 0.82343952 0.4117198 > postscript(file="/var/www/html/rcomp/tmp/1bmwj1261769006.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/2d99m1261769006.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/3knyh1261769006.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/42n9w1261769006.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/578ow1261769006.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 -0.30641472 0.27563014 0.22776322 0.01237855 0.22300202 -0.31655373 7 8 9 10 11 12 0.08252789 0.13925831 0.44548935 0.06159129 0.27749423 -0.06379560 13 14 15 16 17 18 -0.59666792 0.52040935 -0.78345237 -0.40078628 -0.03934583 -0.67829838 19 20 21 22 23 24 0.22035882 0.74707383 0.43566892 -0.32930263 0.43997790 -0.82186088 25 26 27 28 29 30 0.21757446 -0.12056812 0.50674633 0.96165957 -0.38143769 -0.12915512 31 32 33 34 35 36 -0.16269240 -0.40705382 -0.69292387 -0.10538141 -0.46651081 -0.24924370 37 38 39 40 41 42 -0.08806291 -0.56363087 -0.68279816 -0.48726034 -0.31101152 0.59911792 43 44 45 46 47 48 0.68964239 -0.40529619 -0.18823440 0.37309275 -0.25096132 1.13490018 49 50 51 52 53 54 0.77357110 -0.11184049 0.73174098 -0.08599150 0.50879301 0.52488931 55 56 -0.82983670 -0.07398213 > postscript(file="/var/www/html/rcomp/tmp/6lg0w1261769006.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 -0.30641472 NA 1 0.27563014 -0.30641472 2 0.22776322 0.27563014 3 0.01237855 0.22776322 4 0.22300202 0.01237855 5 -0.31655373 0.22300202 6 0.08252789 -0.31655373 7 0.13925831 0.08252789 8 0.44548935 0.13925831 9 0.06159129 0.44548935 10 0.27749423 0.06159129 11 -0.06379560 0.27749423 12 -0.59666792 -0.06379560 13 0.52040935 -0.59666792 14 -0.78345237 0.52040935 15 -0.40078628 -0.78345237 16 -0.03934583 -0.40078628 17 -0.67829838 -0.03934583 18 0.22035882 -0.67829838 19 0.74707383 0.22035882 20 0.43566892 0.74707383 21 -0.32930263 0.43566892 22 0.43997790 -0.32930263 23 -0.82186088 0.43997790 24 0.21757446 -0.82186088 25 -0.12056812 0.21757446 26 0.50674633 -0.12056812 27 0.96165957 0.50674633 28 -0.38143769 0.96165957 29 -0.12915512 -0.38143769 30 -0.16269240 -0.12915512 31 -0.40705382 -0.16269240 32 -0.69292387 -0.40705382 33 -0.10538141 -0.69292387 34 -0.46651081 -0.10538141 35 -0.24924370 -0.46651081 36 -0.08806291 -0.24924370 37 -0.56363087 -0.08806291 38 -0.68279816 -0.56363087 39 -0.48726034 -0.68279816 40 -0.31101152 -0.48726034 41 0.59911792 -0.31101152 42 0.68964239 0.59911792 43 -0.40529619 0.68964239 44 -0.18823440 -0.40529619 45 0.37309275 -0.18823440 46 -0.25096132 0.37309275 47 1.13490018 -0.25096132 48 0.77357110 1.13490018 49 -0.11184049 0.77357110 50 0.73174098 -0.11184049 51 -0.08599150 0.73174098 52 0.50879301 -0.08599150 53 0.52488931 0.50879301 54 -0.82983670 0.52488931 55 -0.07398213 -0.82983670 56 NA -0.07398213 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 0.27563014 -0.30641472 [2,] 0.22776322 0.27563014 [3,] 0.01237855 0.22776322 [4,] 0.22300202 0.01237855 [5,] -0.31655373 0.22300202 [6,] 0.08252789 -0.31655373 [7,] 0.13925831 0.08252789 [8,] 0.44548935 0.13925831 [9,] 0.06159129 0.44548935 [10,] 0.27749423 0.06159129 [11,] -0.06379560 0.27749423 [12,] -0.59666792 -0.06379560 [13,] 0.52040935 -0.59666792 [14,] -0.78345237 0.52040935 [15,] -0.40078628 -0.78345237 [16,] -0.03934583 -0.40078628 [17,] -0.67829838 -0.03934583 [18,] 0.22035882 -0.67829838 [19,] 0.74707383 0.22035882 [20,] 0.43566892 0.74707383 [21,] -0.32930263 0.43566892 [22,] 0.43997790 -0.32930263 [23,] -0.82186088 0.43997790 [24,] 0.21757446 -0.82186088 [25,] -0.12056812 0.21757446 [26,] 0.50674633 -0.12056812 [27,] 0.96165957 0.50674633 [28,] -0.38143769 0.96165957 [29,] -0.12915512 -0.38143769 [30,] -0.16269240 -0.12915512 [31,] -0.40705382 -0.16269240 [32,] -0.69292387 -0.40705382 [33,] -0.10538141 -0.69292387 [34,] -0.46651081 -0.10538141 [35,] -0.24924370 -0.46651081 [36,] -0.08806291 -0.24924370 [37,] -0.56363087 -0.08806291 [38,] -0.68279816 -0.56363087 [39,] -0.48726034 -0.68279816 [40,] -0.31101152 -0.48726034 [41,] 0.59911792 -0.31101152 [42,] 0.68964239 0.59911792 [43,] -0.40529619 0.68964239 [44,] -0.18823440 -0.40529619 [45,] 0.37309275 -0.18823440 [46,] -0.25096132 0.37309275 [47,] 1.13490018 -0.25096132 [48,] 0.77357110 1.13490018 [49,] -0.11184049 0.77357110 [50,] 0.73174098 -0.11184049 [51,] -0.08599150 0.73174098 [52,] 0.50879301 -0.08599150 [53,] 0.52488931 0.50879301 [54,] -0.82983670 0.52488931 [55,] -0.07398213 -0.82983670 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 0.27563014 -0.30641472 2 0.22776322 0.27563014 3 0.01237855 0.22776322 4 0.22300202 0.01237855 5 -0.31655373 0.22300202 6 0.08252789 -0.31655373 7 0.13925831 0.08252789 8 0.44548935 0.13925831 9 0.06159129 0.44548935 10 0.27749423 0.06159129 11 -0.06379560 0.27749423 12 -0.59666792 -0.06379560 13 0.52040935 -0.59666792 14 -0.78345237 0.52040935 15 -0.40078628 -0.78345237 16 -0.03934583 -0.40078628 17 -0.67829838 -0.03934583 18 0.22035882 -0.67829838 19 0.74707383 0.22035882 20 0.43566892 0.74707383 21 -0.32930263 0.43566892 22 0.43997790 -0.32930263 23 -0.82186088 0.43997790 24 0.21757446 -0.82186088 25 -0.12056812 0.21757446 26 0.50674633 -0.12056812 27 0.96165957 0.50674633 28 -0.38143769 0.96165957 29 -0.12915512 -0.38143769 30 -0.16269240 -0.12915512 31 -0.40705382 -0.16269240 32 -0.69292387 -0.40705382 33 -0.10538141 -0.69292387 34 -0.46651081 -0.10538141 35 -0.24924370 -0.46651081 36 -0.08806291 -0.24924370 37 -0.56363087 -0.08806291 38 -0.68279816 -0.56363087 39 -0.48726034 -0.68279816 40 -0.31101152 -0.48726034 41 0.59911792 -0.31101152 42 0.68964239 0.59911792 43 -0.40529619 0.68964239 44 -0.18823440 -0.40529619 45 0.37309275 -0.18823440 46 -0.25096132 0.37309275 47 1.13490018 -0.25096132 48 0.77357110 1.13490018 49 -0.11184049 0.77357110 50 0.73174098 -0.11184049 51 -0.08599150 0.73174098 52 0.50879301 -0.08599150 53 0.52488931 0.50879301 54 -0.82983670 0.52488931 55 -0.07398213 -0.82983670 > 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/7p3t71261769006.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/89n5u1261769006.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/975v11261769006.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/10ggmt1261769006.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/11erat1261769006.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/122wjk1261769007.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/13nk661261769007.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/14p3v01261769007.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/1505pf1261769007.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/16uhw51261769007.tab") + } > > try(system("convert tmp/1bmwj1261769006.ps tmp/1bmwj1261769006.png",intern=TRUE)) character(0) > try(system("convert tmp/2d99m1261769006.ps tmp/2d99m1261769006.png",intern=TRUE)) character(0) > try(system("convert tmp/3knyh1261769006.ps tmp/3knyh1261769006.png",intern=TRUE)) character(0) > try(system("convert tmp/42n9w1261769006.ps tmp/42n9w1261769006.png",intern=TRUE)) character(0) > try(system("convert tmp/578ow1261769006.ps tmp/578ow1261769006.png",intern=TRUE)) character(0) > try(system("convert tmp/6lg0w1261769006.ps tmp/6lg0w1261769006.png",intern=TRUE)) character(0) > try(system("convert tmp/7p3t71261769006.ps tmp/7p3t71261769006.png",intern=TRUE)) character(0) > try(system("convert tmp/89n5u1261769006.ps tmp/89n5u1261769006.png",intern=TRUE)) character(0) > try(system("convert tmp/975v11261769006.ps tmp/975v11261769006.png",intern=TRUE)) character(0) > try(system("convert tmp/10ggmt1261769006.ps tmp/10ggmt1261769006.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.360 1.544 3.040