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.3 + ,18 + ,13.2 + ,15.7 + ,12.6 + ,12.8 + ,23 + ,20.3 + ,13.2 + ,15.7 + ,8 + ,20 + ,12.8 + ,20.3 + ,13.2 + ,0.9 + ,20 + ,8 + ,12.8 + ,20.3 + ,3.6 + ,15 + ,0.9 + ,8 + ,12.8 + ,14.1 + ,17 + ,3.6 + ,0.9 + ,8 + ,21.7 + ,16 + ,14.1 + ,3.6 + ,0.9 + ,24.5 + ,15 + ,21.7 + ,14.1 + ,3.6 + ,18.9 + ,10 + ,24.5 + ,21.7 + ,14.1 + ,13.9 + ,13 + ,18.9 + ,24.5 + ,21.7 + ,11 + ,10 + ,13.9 + ,18.9 + ,24.5 + ,5.8 + ,19 + ,11 + ,13.9 + ,18.9 + ,15.5 + ,21 + ,5.8 + ,11 + ,13.9 + ,22.4 + ,17 + ,15.5 + ,5.8 + ,11 + ,31.7 + ,16 + ,22.4 + ,15.5 + ,5.8 + ,30.3 + ,17 + ,31.7 + ,22.4 + ,15.5 + ,31.4 + ,14 + ,30.3 + ,31.7 + ,22.4 + ,20.2 + ,18 + ,31.4 + ,30.3 + ,31.7 + ,19.7 + ,17 + ,20.2 + ,31.4 + ,30.3 + ,10.8 + ,14 + ,19.7 + ,20.2 + ,31.4 + ,13.2 + ,15 + ,10.8 + ,19.7 + ,20.2 + ,15.1 + ,16 + ,13.2 + ,10.8 + ,19.7 + ,15.6 + ,11 + ,15.1 + ,13.2 + ,10.8 + ,15.5 + ,15 + ,15.6 + ,15.1 + ,13.2 + ,12.7 + ,13 + ,15.5 + ,15.6 + ,15.1 + ,10.9 + ,17 + ,12.7 + ,15.5 + ,15.6 + ,10 + ,16 + ,10.9 + ,12.7 + ,15.5 + ,9.1 + ,9 + ,10 + ,10.9 + ,12.7 + ,10.3 + ,17 + ,9.1 + ,10 + ,10.9 + ,16.9 + ,15 + ,10.3 + ,9.1 + ,10 + ,22 + ,12 + ,16.9 + ,10.3 + ,9.1 + ,27.6 + ,12 + ,22 + ,16.9 + ,10.3 + ,28.9 + ,12 + ,27.6 + ,22 + ,16.9 + ,31 + ,12 + ,28.9 + ,27.6 + ,22 + ,32.9 + ,4 + ,31 + ,28.9 + ,27.6 + ,38.1 + ,7 + ,32.9 + ,31 + ,28.9 + ,28.8 + ,4 + ,38.1 + ,32.9 + ,31 + ,29 + ,3 + ,28.8 + ,38.1 + ,32.9 + ,21.8 + ,3 + ,29 + ,28.8 + ,38.1 + ,28.8 + ,0 + ,21.8 + ,29 + ,28.8 + ,25.6 + ,5 + ,28.8 + ,21.8 + ,29 + ,28.2 + ,3 + ,25.6 + ,28.8 + ,21.8 + ,20.2 + ,4 + ,28.2 + ,25.6 + ,28.8 + ,17.9 + ,3 + ,20.2 + ,28.2 + ,25.6 + ,16.3 + ,10 + ,17.9 + ,20.2 + ,28.2 + ,13.2 + ,4 + ,16.3 + ,17.9 + ,20.2 + ,8.1 + ,1 + ,13.2 + ,16.3 + ,17.9 + ,4.5 + ,1 + ,8.1 + ,13.2 + ,16.3 + ,-0.1 + ,8 + ,4.5 + ,8.1 + ,13.2 + ,0 + ,5 + ,-0.1 + ,4.5 + ,8.1 + ,2.3 + ,4 + ,0 + ,-0.1 + ,4.5 + ,2.8 + ,0 + ,2.3 + ,0 + ,-0.1 + ,2.9 + ,2 + ,2.8 + ,2.3 + ,0 + ,0.1 + ,7 + ,2.9 + ,2.8 + ,2.3 + ,3.5 + ,6 + ,0.1 + ,2.9 + ,2.8 + ,8.6 + ,9 + ,3.5 + ,0.1 + ,2.9 + ,13.8 + ,10 + ,8.6 + ,3.5 + ,0.1) + ,dim=c(5 + ,57) + ,dimnames=list(c('Y' + ,'X' + ,'Yt-1' + ,'Yt-2' + ,'Yt-3') + ,1:57)) > y <- array(NA,dim=c(5,57),dimnames=list(c('Y','X','Yt-1','Yt-2','Yt-3'),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 Yt-1 Yt-2 Yt-3 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 20.3 18 13.2 15.7 12.6 1 0 0 0 0 0 0 0 0 0 0 1 2 12.8 23 20.3 13.2 15.7 0 1 0 0 0 0 0 0 0 0 0 2 3 8.0 20 12.8 20.3 13.2 0 0 1 0 0 0 0 0 0 0 0 3 4 0.9 20 8.0 12.8 20.3 0 0 0 1 0 0 0 0 0 0 0 4 5 3.6 15 0.9 8.0 12.8 0 0 0 0 1 0 0 0 0 0 0 5 6 14.1 17 3.6 0.9 8.0 0 0 0 0 0 1 0 0 0 0 0 6 7 21.7 16 14.1 3.6 0.9 0 0 0 0 0 0 1 0 0 0 0 7 8 24.5 15 21.7 14.1 3.6 0 0 0 0 0 0 0 1 0 0 0 8 9 18.9 10 24.5 21.7 14.1 0 0 0 0 0 0 0 0 1 0 0 9 10 13.9 13 18.9 24.5 21.7 0 0 0 0 0 0 0 0 0 1 0 10 11 11.0 10 13.9 18.9 24.5 0 0 0 0 0 0 0 0 0 0 1 11 12 5.8 19 11.0 13.9 18.9 0 0 0 0 0 0 0 0 0 0 0 12 13 15.5 21 5.8 11.0 13.9 1 0 0 0 0 0 0 0 0 0 0 13 14 22.4 17 15.5 5.8 11.0 0 1 0 0 0 0 0 0 0 0 0 14 15 31.7 16 22.4 15.5 5.8 0 0 1 0 0 0 0 0 0 0 0 15 16 30.3 17 31.7 22.4 15.5 0 0 0 1 0 0 0 0 0 0 0 16 17 31.4 14 30.3 31.7 22.4 0 0 0 0 1 0 0 0 0 0 0 17 18 20.2 18 31.4 30.3 31.7 0 0 0 0 0 1 0 0 0 0 0 18 19 19.7 17 20.2 31.4 30.3 0 0 0 0 0 0 1 0 0 0 0 19 20 10.8 14 19.7 20.2 31.4 0 0 0 0 0 0 0 1 0 0 0 20 21 13.2 15 10.8 19.7 20.2 0 0 0 0 0 0 0 0 1 0 0 21 22 15.1 16 13.2 10.8 19.7 0 0 0 0 0 0 0 0 0 1 0 22 23 15.6 11 15.1 13.2 10.8 0 0 0 0 0 0 0 0 0 0 1 23 24 15.5 15 15.6 15.1 13.2 0 0 0 0 0 0 0 0 0 0 0 24 25 12.7 13 15.5 15.6 15.1 1 0 0 0 0 0 0 0 0 0 0 25 26 10.9 17 12.7 15.5 15.6 0 1 0 0 0 0 0 0 0 0 0 26 27 10.0 16 10.9 12.7 15.5 0 0 1 0 0 0 0 0 0 0 0 27 28 9.1 9 10.0 10.9 12.7 0 0 0 1 0 0 0 0 0 0 0 28 29 10.3 17 9.1 10.0 10.9 0 0 0 0 1 0 0 0 0 0 0 29 30 16.9 15 10.3 9.1 10.0 0 0 0 0 0 1 0 0 0 0 0 30 31 22.0 12 16.9 10.3 9.1 0 0 0 0 0 0 1 0 0 0 0 31 32 27.6 12 22.0 16.9 10.3 0 0 0 0 0 0 0 1 0 0 0 32 33 28.9 12 27.6 22.0 16.9 0 0 0 0 0 0 0 0 1 0 0 33 34 31.0 12 28.9 27.6 22.0 0 0 0 0 0 0 0 0 0 1 0 34 35 32.9 4 31.0 28.9 27.6 0 0 0 0 0 0 0 0 0 0 1 35 36 38.1 7 32.9 31.0 28.9 0 0 0 0 0 0 0 0 0 0 0 36 37 28.8 4 38.1 32.9 31.0 1 0 0 0 0 0 0 0 0 0 0 37 38 29.0 3 28.8 38.1 32.9 0 1 0 0 0 0 0 0 0 0 0 38 39 21.8 3 29.0 28.8 38.1 0 0 1 0 0 0 0 0 0 0 0 39 40 28.8 0 21.8 29.0 28.8 0 0 0 1 0 0 0 0 0 0 0 40 41 25.6 5 28.8 21.8 29.0 0 0 0 0 1 0 0 0 0 0 0 41 42 28.2 3 25.6 28.8 21.8 0 0 0 0 0 1 0 0 0 0 0 42 43 20.2 4 28.2 25.6 28.8 0 0 0 0 0 0 1 0 0 0 0 43 44 17.9 3 20.2 28.2 25.6 0 0 0 0 0 0 0 1 0 0 0 44 45 16.3 10 17.9 20.2 28.2 0 0 0 0 0 0 0 0 1 0 0 45 46 13.2 4 16.3 17.9 20.2 0 0 0 0 0 0 0 0 0 1 0 46 47 8.1 1 13.2 16.3 17.9 0 0 0 0 0 0 0 0 0 0 1 47 48 4.5 1 8.1 13.2 16.3 0 0 0 0 0 0 0 0 0 0 0 48 49 -0.1 8 4.5 8.1 13.2 1 0 0 0 0 0 0 0 0 0 0 49 50 0.0 5 -0.1 4.5 8.1 0 1 0 0 0 0 0 0 0 0 0 50 51 2.3 4 0.0 -0.1 4.5 0 0 1 0 0 0 0 0 0 0 0 51 52 2.8 0 2.3 0.0 -0.1 0 0 0 1 0 0 0 0 0 0 0 52 53 2.9 2 2.8 2.3 0.0 0 0 0 0 1 0 0 0 0 0 0 53 54 0.1 7 2.9 2.8 2.3 0 0 0 0 0 1 0 0 0 0 0 54 55 3.5 6 0.1 2.9 2.8 0 0 0 0 0 0 1 0 0 0 0 55 56 8.6 9 3.5 0.1 2.9 0 0 0 0 0 0 0 1 0 0 0 56 57 13.8 10 8.6 3.5 0.1 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 `Yt-1` `Yt-2` `Yt-3` M1 4.449860 -0.001978 0.994282 0.147066 -0.382512 0.261350 M2 M3 M4 M5 M6 M7 -0.168477 -0.471951 -0.510605 0.146132 0.886063 1.087922 M8 M9 M10 M11 t 0.032078 0.147371 0.201265 -0.309510 -0.018558 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -8.3172 -3.4512 -0.1450 2.6251 10.6791 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 4.449860 6.102328 0.729 0.4701 X -0.001978 0.228791 -0.009 0.9931 `Yt-1` 0.994282 0.146636 6.781 3.79e-08 *** `Yt-2` 0.147066 0.216018 0.681 0.4999 `Yt-3` -0.382512 0.149498 -2.559 0.0144 * M1 0.261350 3.492971 0.075 0.9407 M2 -0.168477 3.498967 -0.048 0.9618 M3 -0.471951 3.495366 -0.135 0.8933 M4 -0.510605 3.535994 -0.144 0.8859 M5 0.146132 3.498611 0.042 0.9669 M6 0.886063 3.505570 0.253 0.8017 M7 1.087922 3.509969 0.310 0.7582 M8 0.032078 3.519304 0.009 0.9928 M9 0.147371 3.532918 0.042 0.9669 M10 0.201265 3.673779 0.055 0.9566 M11 -0.309510 3.792425 -0.082 0.9354 t -0.018558 0.083933 -0.221 0.8261 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 5.188 on 40 degrees of freedom Multiple R-squared: 0.805, Adjusted R-squared: 0.7271 F-statistic: 10.32 on 16 and 40 DF, p-value: 1.33e-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.4841799 0.9683598 0.51582009 [2,] 0.4067433 0.8134866 0.59325672 [3,] 0.3117678 0.6235355 0.68823223 [4,] 0.6262221 0.7475558 0.37377791 [5,] 0.6127515 0.7744970 0.38724848 [6,] 0.9192124 0.1615752 0.08078759 [7,] 0.9002589 0.1994822 0.09974110 [8,] 0.8806730 0.2386540 0.11932699 [9,] 0.8797371 0.2405259 0.12026293 [10,] 0.9493075 0.1013849 0.05069246 [11,] 0.9081120 0.1837760 0.09188801 [12,] 0.8744643 0.2510715 0.12553575 [13,] 0.8069661 0.3860677 0.19303386 [14,] 0.7110645 0.5778711 0.28893554 [15,] 0.8415181 0.3169637 0.15848186 [16,] 0.7639485 0.4721031 0.23605154 [17,] 0.8540689 0.2918622 0.14593111 [18,] 0.7532625 0.4934751 0.24673755 > postscript(file="/var/www/html/rcomp/tmp/1j7d71258747183.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/24z941258747183.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/3mefc1258747183.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/4wzxn1258747183.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/528jt1258747183.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 5.02913985 -7.51853690 -6.54577305 -4.99717621 1.95123628 8.25736898 7 8 9 10 11 12 2.11921427 -2.07631981 -7.66826374 -4.63437973 -0.14496714 -4.14143426 13 14 15 16 17 18 9.00392955 6.35532351 5.69922602 -2.19279944 0.92669954 -8.31721924 19 20 21 22 23 24 1.43617304 -3.83031503 3.11343840 3.71143637 -0.91557287 -1.15715100 25 26 27 28 29 30 -3.45123137 -1.80498241 -0.22168725 -0.98978253 -0.07344453 4.39618537 31 32 33 34 35 36 2.22394807 3.31588766 0.72571301 2.62505071 4.90144629 8.11571869 37 38 39 40 41 42 -6.07942554 3.77583318 0.05578524 10.67912027 1.02623543 2.29905922 43 44 45 46 47 48 -5.31920183 -0.19893160 2.57608855 -1.70210735 -3.84090628 -2.81713343 49 50 51 52 53 54 -4.50241249 -0.80763738 1.01244904 -2.49936209 -3.83072672 -6.63539433 55 56 57 -0.46013354 2.78967878 1.25302379 > postscript(file="/var/www/html/rcomp/tmp/65nai1258747183.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 5.02913985 NA 1 -7.51853690 5.02913985 2 -6.54577305 -7.51853690 3 -4.99717621 -6.54577305 4 1.95123628 -4.99717621 5 8.25736898 1.95123628 6 2.11921427 8.25736898 7 -2.07631981 2.11921427 8 -7.66826374 -2.07631981 9 -4.63437973 -7.66826374 10 -0.14496714 -4.63437973 11 -4.14143426 -0.14496714 12 9.00392955 -4.14143426 13 6.35532351 9.00392955 14 5.69922602 6.35532351 15 -2.19279944 5.69922602 16 0.92669954 -2.19279944 17 -8.31721924 0.92669954 18 1.43617304 -8.31721924 19 -3.83031503 1.43617304 20 3.11343840 -3.83031503 21 3.71143637 3.11343840 22 -0.91557287 3.71143637 23 -1.15715100 -0.91557287 24 -3.45123137 -1.15715100 25 -1.80498241 -3.45123137 26 -0.22168725 -1.80498241 27 -0.98978253 -0.22168725 28 -0.07344453 -0.98978253 29 4.39618537 -0.07344453 30 2.22394807 4.39618537 31 3.31588766 2.22394807 32 0.72571301 3.31588766 33 2.62505071 0.72571301 34 4.90144629 2.62505071 35 8.11571869 4.90144629 36 -6.07942554 8.11571869 37 3.77583318 -6.07942554 38 0.05578524 3.77583318 39 10.67912027 0.05578524 40 1.02623543 10.67912027 41 2.29905922 1.02623543 42 -5.31920183 2.29905922 43 -0.19893160 -5.31920183 44 2.57608855 -0.19893160 45 -1.70210735 2.57608855 46 -3.84090628 -1.70210735 47 -2.81713343 -3.84090628 48 -4.50241249 -2.81713343 49 -0.80763738 -4.50241249 50 1.01244904 -0.80763738 51 -2.49936209 1.01244904 52 -3.83072672 -2.49936209 53 -6.63539433 -3.83072672 54 -0.46013354 -6.63539433 55 2.78967878 -0.46013354 56 1.25302379 2.78967878 57 NA 1.25302379 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -7.51853690 5.02913985 [2,] -6.54577305 -7.51853690 [3,] -4.99717621 -6.54577305 [4,] 1.95123628 -4.99717621 [5,] 8.25736898 1.95123628 [6,] 2.11921427 8.25736898 [7,] -2.07631981 2.11921427 [8,] -7.66826374 -2.07631981 [9,] -4.63437973 -7.66826374 [10,] -0.14496714 -4.63437973 [11,] -4.14143426 -0.14496714 [12,] 9.00392955 -4.14143426 [13,] 6.35532351 9.00392955 [14,] 5.69922602 6.35532351 [15,] -2.19279944 5.69922602 [16,] 0.92669954 -2.19279944 [17,] -8.31721924 0.92669954 [18,] 1.43617304 -8.31721924 [19,] -3.83031503 1.43617304 [20,] 3.11343840 -3.83031503 [21,] 3.71143637 3.11343840 [22,] -0.91557287 3.71143637 [23,] -1.15715100 -0.91557287 [24,] -3.45123137 -1.15715100 [25,] -1.80498241 -3.45123137 [26,] -0.22168725 -1.80498241 [27,] -0.98978253 -0.22168725 [28,] -0.07344453 -0.98978253 [29,] 4.39618537 -0.07344453 [30,] 2.22394807 4.39618537 [31,] 3.31588766 2.22394807 [32,] 0.72571301 3.31588766 [33,] 2.62505071 0.72571301 [34,] 4.90144629 2.62505071 [35,] 8.11571869 4.90144629 [36,] -6.07942554 8.11571869 [37,] 3.77583318 -6.07942554 [38,] 0.05578524 3.77583318 [39,] 10.67912027 0.05578524 [40,] 1.02623543 10.67912027 [41,] 2.29905922 1.02623543 [42,] -5.31920183 2.29905922 [43,] -0.19893160 -5.31920183 [44,] 2.57608855 -0.19893160 [45,] -1.70210735 2.57608855 [46,] -3.84090628 -1.70210735 [47,] -2.81713343 -3.84090628 [48,] -4.50241249 -2.81713343 [49,] -0.80763738 -4.50241249 [50,] 1.01244904 -0.80763738 [51,] -2.49936209 1.01244904 [52,] -3.83072672 -2.49936209 [53,] -6.63539433 -3.83072672 [54,] -0.46013354 -6.63539433 [55,] 2.78967878 -0.46013354 [56,] 1.25302379 2.78967878 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -7.51853690 5.02913985 2 -6.54577305 -7.51853690 3 -4.99717621 -6.54577305 4 1.95123628 -4.99717621 5 8.25736898 1.95123628 6 2.11921427 8.25736898 7 -2.07631981 2.11921427 8 -7.66826374 -2.07631981 9 -4.63437973 -7.66826374 10 -0.14496714 -4.63437973 11 -4.14143426 -0.14496714 12 9.00392955 -4.14143426 13 6.35532351 9.00392955 14 5.69922602 6.35532351 15 -2.19279944 5.69922602 16 0.92669954 -2.19279944 17 -8.31721924 0.92669954 18 1.43617304 -8.31721924 19 -3.83031503 1.43617304 20 3.11343840 -3.83031503 21 3.71143637 3.11343840 22 -0.91557287 3.71143637 23 -1.15715100 -0.91557287 24 -3.45123137 -1.15715100 25 -1.80498241 -3.45123137 26 -0.22168725 -1.80498241 27 -0.98978253 -0.22168725 28 -0.07344453 -0.98978253 29 4.39618537 -0.07344453 30 2.22394807 4.39618537 31 3.31588766 2.22394807 32 0.72571301 3.31588766 33 2.62505071 0.72571301 34 4.90144629 2.62505071 35 8.11571869 4.90144629 36 -6.07942554 8.11571869 37 3.77583318 -6.07942554 38 0.05578524 3.77583318 39 10.67912027 0.05578524 40 1.02623543 10.67912027 41 2.29905922 1.02623543 42 -5.31920183 2.29905922 43 -0.19893160 -5.31920183 44 2.57608855 -0.19893160 45 -1.70210735 2.57608855 46 -3.84090628 -1.70210735 47 -2.81713343 -3.84090628 48 -4.50241249 -2.81713343 49 -0.80763738 -4.50241249 50 1.01244904 -0.80763738 51 -2.49936209 1.01244904 52 -3.83072672 -2.49936209 53 -6.63539433 -3.83072672 54 -0.46013354 -6.63539433 55 2.78967878 -0.46013354 56 1.25302379 2.78967878 > 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/7o7u21258747183.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/8dpfa1258747183.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/9x8ql1258747183.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/10j5381258747183.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/11s5bu1258747183.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/12okmf1258747183.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/136hw51258747183.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/14q05m1258747183.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/15vy331258747183.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/16x1s01258747183.tab") + } > system("convert tmp/1j7d71258747183.ps tmp/1j7d71258747183.png") > system("convert tmp/24z941258747183.ps tmp/24z941258747183.png") > system("convert tmp/3mefc1258747183.ps tmp/3mefc1258747183.png") > system("convert tmp/4wzxn1258747183.ps tmp/4wzxn1258747183.png") > system("convert tmp/528jt1258747183.ps tmp/528jt1258747183.png") > system("convert tmp/65nai1258747183.ps tmp/65nai1258747183.png") > system("convert tmp/7o7u21258747183.ps tmp/7o7u21258747183.png") > system("convert tmp/8dpfa1258747183.ps tmp/8dpfa1258747183.png") > system("convert tmp/9x8ql1258747183.ps tmp/9x8ql1258747183.png") > system("convert tmp/10j5381258747183.ps tmp/10j5381258747183.png") > > > proc.time() user system elapsed 2.352 1.540 4.132