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(101.6 + ,79.8 + ,103.9 + ,110.3 + ,114.1 + ,96.8 + ,94.6 + ,71.9 + ,101.6 + ,103.9 + ,110.3 + ,114.1 + ,95.9 + ,82.9 + ,94.6 + ,101.6 + ,103.9 + ,110.3 + ,104.7 + ,90.1 + ,95.9 + ,94.6 + ,101.6 + ,103.9 + ,102.8 + ,100.7 + ,104.7 + ,95.9 + ,94.6 + ,101.6 + ,98.1 + ,90.7 + ,102.8 + ,104.7 + ,95.9 + ,94.6 + ,113.9 + ,108.8 + ,98.1 + ,102.8 + ,104.7 + ,95.9 + ,80.9 + ,44.1 + ,113.9 + ,98.1 + ,102.8 + ,104.7 + ,95.7 + ,93.6 + ,80.9 + ,113.9 + ,98.1 + ,102.8 + ,113.2 + ,107.4 + ,95.7 + ,80.9 + ,113.9 + ,98.1 + ,105.9 + ,96.5 + ,113.2 + ,95.7 + ,80.9 + ,113.9 + ,108.8 + ,93.6 + ,105.9 + ,113.2 + ,95.7 + ,80.9 + ,102.3 + ,76.5 + ,108.8 + ,105.9 + ,113.2 + ,95.7 + ,99 + ,76.7 + ,102.3 + ,108.8 + ,105.9 + ,113.2 + ,100.7 + ,84 + ,99 + ,102.3 + ,108.8 + ,105.9 + ,115.5 + ,103.3 + ,100.7 + ,99 + ,102.3 + ,108.8 + ,100.7 + ,88.5 + ,115.5 + ,100.7 + ,99 + ,102.3 + ,109.9 + ,99 + ,100.7 + ,115.5 + ,100.7 + ,99 + ,114.6 + ,105.9 + ,109.9 + ,100.7 + ,115.5 + ,100.7 + ,85.4 + ,44.7 + ,114.6 + ,109.9 + ,100.7 + ,115.5 + ,100.5 + ,94 + ,85.4 + ,114.6 + ,109.9 + ,100.7 + ,114.8 + ,107.1 + ,100.5 + ,85.4 + ,114.6 + ,109.9 + ,116.5 + ,104.8 + ,114.8 + ,100.5 + ,85.4 + ,114.6 + ,112.9 + ,102.5 + ,116.5 + ,114.8 + ,100.5 + ,85.4 + ,102 + ,77.7 + ,112.9 + ,116.5 + ,114.8 + ,100.5 + ,106 + ,85.2 + ,102 + ,112.9 + ,116.5 + ,114.8 + ,105.3 + ,91.3 + ,106 + ,102 + ,112.9 + ,116.5 + ,118.8 + ,106.5 + ,105.3 + ,106 + ,102 + ,112.9 + ,106.1 + ,92.4 + ,118.8 + ,105.3 + ,106 + ,102 + ,109.3 + ,97.5 + ,106.1 + ,118.8 + ,105.3 + ,106 + ,117.2 + ,107 + ,109.3 + ,106.1 + ,118.8 + ,105.3 + ,92.5 + ,51.1 + ,117.2 + ,109.3 + ,106.1 + ,118.8 + ,104.2 + ,98.6 + ,92.5 + ,117.2 + ,109.3 + ,106.1 + ,112.5 + ,102.2 + ,104.2 + ,92.5 + ,117.2 + ,109.3 + ,122.4 + ,114.3 + ,112.5 + ,104.2 + ,92.5 + ,117.2 + ,113.3 + ,99.4 + ,122.4 + ,112.5 + ,104.2 + ,92.5 + ,100 + ,72.5 + ,113.3 + ,122.4 + ,112.5 + ,104.2 + ,110.7 + ,92.3 + ,100 + ,113.3 + ,122.4 + ,112.5 + ,112.8 + ,99.4 + ,110.7 + ,100 + ,113.3 + ,122.4 + ,109.8 + ,85.9 + ,112.8 + ,110.7 + ,100 + ,113.3 + ,117.3 + ,109.4 + ,109.8 + ,112.8 + ,110.7 + ,100 + ,109.1 + ,97.6 + ,117.3 + ,109.8 + ,112.8 + ,110.7 + ,115.9 + ,104.7 + ,109.1 + ,117.3 + ,109.8 + ,112.8 + ,96 + ,56.9 + ,115.9 + ,109.1 + ,117.3 + ,109.8 + ,99.8 + ,86.7 + ,96 + ,115.9 + ,109.1 + ,117.3 + ,116.8 + ,108.5 + ,99.8 + ,96 + ,115.9 + ,109.1 + ,115.7 + ,103.4 + ,116.8 + ,99.8 + ,96 + ,115.9 + ,99.4 + ,86.2 + ,115.7 + ,116.8 + ,99.8 + ,96 + ,94.3 + ,71 + ,99.4 + ,115.7 + ,116.8 + ,99.8 + ,91 + ,75.9 + ,94.3 + ,99.4 + ,115.7 + ,116.8 + ,93.2 + ,87.1 + ,91 + ,94.3 + ,99.4 + ,115.7 + ,103.1 + ,102 + ,93.2 + ,91 + ,94.3 + ,99.4 + ,94.1 + ,88.5 + ,103.1 + ,93.2 + ,91 + ,94.3 + ,91.8 + ,87.8 + ,94.1 + ,103.1 + ,93.2 + ,91 + ,102.7 + ,100.8 + ,91.8 + ,94.1 + ,103.1 + ,93.2 + ,82.6 + ,50.6 + ,102.7 + ,91.8 + ,94.1 + ,103.1) + ,dim=c(6 + ,56) + ,dimnames=list(c('Totind' + ,'Bouw' + ,'Yt-1' + ,'Yt-2' + ,'Yt-3' + ,'Yt-4') + ,1:56)) > y <- array(NA,dim=c(6,56),dimnames=list(c('Totind','Bouw','Yt-1','Yt-2','Yt-3','Yt-4'),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 Totind Bouw Yt-1 Yt-2 Yt-3 Yt-4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 101.6 79.8 103.9 110.3 114.1 96.8 1 0 0 0 0 0 0 0 0 0 0 1 2 94.6 71.9 101.6 103.9 110.3 114.1 0 1 0 0 0 0 0 0 0 0 0 2 3 95.9 82.9 94.6 101.6 103.9 110.3 0 0 1 0 0 0 0 0 0 0 0 3 4 104.7 90.1 95.9 94.6 101.6 103.9 0 0 0 1 0 0 0 0 0 0 0 4 5 102.8 100.7 104.7 95.9 94.6 101.6 0 0 0 0 1 0 0 0 0 0 0 5 6 98.1 90.7 102.8 104.7 95.9 94.6 0 0 0 0 0 1 0 0 0 0 0 6 7 113.9 108.8 98.1 102.8 104.7 95.9 0 0 0 0 0 0 1 0 0 0 0 7 8 80.9 44.1 113.9 98.1 102.8 104.7 0 0 0 0 0 0 0 1 0 0 0 8 9 95.7 93.6 80.9 113.9 98.1 102.8 0 0 0 0 0 0 0 0 1 0 0 9 10 113.2 107.4 95.7 80.9 113.9 98.1 0 0 0 0 0 0 0 0 0 1 0 10 11 105.9 96.5 113.2 95.7 80.9 113.9 0 0 0 0 0 0 0 0 0 0 1 11 12 108.8 93.6 105.9 113.2 95.7 80.9 0 0 0 0 0 0 0 0 0 0 0 12 13 102.3 76.5 108.8 105.9 113.2 95.7 1 0 0 0 0 0 0 0 0 0 0 13 14 99.0 76.7 102.3 108.8 105.9 113.2 0 1 0 0 0 0 0 0 0 0 0 14 15 100.7 84.0 99.0 102.3 108.8 105.9 0 0 1 0 0 0 0 0 0 0 0 15 16 115.5 103.3 100.7 99.0 102.3 108.8 0 0 0 1 0 0 0 0 0 0 0 16 17 100.7 88.5 115.5 100.7 99.0 102.3 0 0 0 0 1 0 0 0 0 0 0 17 18 109.9 99.0 100.7 115.5 100.7 99.0 0 0 0 0 0 1 0 0 0 0 0 18 19 114.6 105.9 109.9 100.7 115.5 100.7 0 0 0 0 0 0 1 0 0 0 0 19 20 85.4 44.7 114.6 109.9 100.7 115.5 0 0 0 0 0 0 0 1 0 0 0 20 21 100.5 94.0 85.4 114.6 109.9 100.7 0 0 0 0 0 0 0 0 1 0 0 21 22 114.8 107.1 100.5 85.4 114.6 109.9 0 0 0 0 0 0 0 0 0 1 0 22 23 116.5 104.8 114.8 100.5 85.4 114.6 0 0 0 0 0 0 0 0 0 0 1 23 24 112.9 102.5 116.5 114.8 100.5 85.4 0 0 0 0 0 0 0 0 0 0 0 24 25 102.0 77.7 112.9 116.5 114.8 100.5 1 0 0 0 0 0 0 0 0 0 0 25 26 106.0 85.2 102.0 112.9 116.5 114.8 0 1 0 0 0 0 0 0 0 0 0 26 27 105.3 91.3 106.0 102.0 112.9 116.5 0 0 1 0 0 0 0 0 0 0 0 27 28 118.8 106.5 105.3 106.0 102.0 112.9 0 0 0 1 0 0 0 0 0 0 0 28 29 106.1 92.4 118.8 105.3 106.0 102.0 0 0 0 0 1 0 0 0 0 0 0 29 30 109.3 97.5 106.1 118.8 105.3 106.0 0 0 0 0 0 1 0 0 0 0 0 30 31 117.2 107.0 109.3 106.1 118.8 105.3 0 0 0 0 0 0 1 0 0 0 0 31 32 92.5 51.1 117.2 109.3 106.1 118.8 0 0 0 0 0 0 0 1 0 0 0 32 33 104.2 98.6 92.5 117.2 109.3 106.1 0 0 0 0 0 0 0 0 1 0 0 33 34 112.5 102.2 104.2 92.5 117.2 109.3 0 0 0 0 0 0 0 0 0 1 0 34 35 122.4 114.3 112.5 104.2 92.5 117.2 0 0 0 0 0 0 0 0 0 0 1 35 36 113.3 99.4 122.4 112.5 104.2 92.5 0 0 0 0 0 0 0 0 0 0 0 36 37 100.0 72.5 113.3 122.4 112.5 104.2 1 0 0 0 0 0 0 0 0 0 0 37 38 110.7 92.3 100.0 113.3 122.4 112.5 0 1 0 0 0 0 0 0 0 0 0 38 39 112.8 99.4 110.7 100.0 113.3 122.4 0 0 1 0 0 0 0 0 0 0 0 39 40 109.8 85.9 112.8 110.7 100.0 113.3 0 0 0 1 0 0 0 0 0 0 0 40 41 117.3 109.4 109.8 112.8 110.7 100.0 0 0 0 0 1 0 0 0 0 0 0 41 42 109.1 97.6 117.3 109.8 112.8 110.7 0 0 0 0 0 1 0 0 0 0 0 42 43 115.9 104.7 109.1 117.3 109.8 112.8 0 0 0 0 0 0 1 0 0 0 0 43 44 96.0 56.9 115.9 109.1 117.3 109.8 0 0 0 0 0 0 0 1 0 0 0 44 45 99.8 86.7 96.0 115.9 109.1 117.3 0 0 0 0 0 0 0 0 1 0 0 45 46 116.8 108.5 99.8 96.0 115.9 109.1 0 0 0 0 0 0 0 0 0 1 0 46 47 115.7 103.4 116.8 99.8 96.0 115.9 0 0 0 0 0 0 0 0 0 0 1 47 48 99.4 86.2 115.7 116.8 99.8 96.0 0 0 0 0 0 0 0 0 0 0 0 48 49 94.3 71.0 99.4 115.7 116.8 99.8 1 0 0 0 0 0 0 0 0 0 0 49 50 91.0 75.9 94.3 99.4 115.7 116.8 0 1 0 0 0 0 0 0 0 0 0 50 51 93.2 87.1 91.0 94.3 99.4 115.7 0 0 1 0 0 0 0 0 0 0 0 51 52 103.1 102.0 93.2 91.0 94.3 99.4 0 0 0 1 0 0 0 0 0 0 0 52 53 94.1 88.5 103.1 93.2 91.0 94.3 0 0 0 0 1 0 0 0 0 0 0 53 54 91.8 87.8 94.1 103.1 93.2 91.0 0 0 0 0 0 1 0 0 0 0 0 54 55 102.7 100.8 91.8 94.1 103.1 93.2 0 0 0 0 0 0 1 0 0 0 0 55 56 82.6 50.6 102.7 91.8 94.1 103.1 0 0 0 0 0 0 0 1 0 0 0 56 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) Bouw `Yt-1` `Yt-2` `Yt-3` `Yt-4` -29.51396 0.66562 0.28437 0.28934 0.15726 -0.06413 M1 M2 M3 M4 M5 M6 5.11065 7.13200 5.96647 9.41343 0.97286 0.39130 M7 M8 M9 M10 M11 t 3.03306 14.01947 0.11724 8.83733 8.13094 -0.04215 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -3.78856 -0.85799 -0.03611 0.86488 3.78876 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -29.51396 6.19505 -4.764 2.77e-05 *** Bouw 0.66562 0.04901 13.583 3.67e-16 *** `Yt-1` 0.28437 0.07164 3.969 0.000309 *** `Yt-2` 0.28934 0.05543 5.219 6.68e-06 *** `Yt-3` 0.15726 0.06775 2.321 0.025746 * `Yt-4` -0.06413 0.07538 -0.851 0.400233 M1 5.11065 2.57610 1.984 0.054529 . M2 7.13200 3.66090 1.948 0.058810 . M3 5.96647 3.43576 1.737 0.090564 . M4 9.41343 2.70924 3.475 0.001295 ** M5 0.97286 1.87042 0.520 0.605992 M6 0.39130 1.96699 0.199 0.843375 M7 3.03306 2.39700 1.265 0.213448 M8 14.01947 3.31330 4.231 0.000141 *** M9 0.11724 3.37804 0.035 0.972496 M10 8.83733 3.49659 2.527 0.015771 * M11 8.13094 2.85192 2.851 0.007006 ** t -0.04215 0.01623 -2.597 0.013292 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.764 on 38 degrees of freedom Multiple R-squared: 0.9768, Adjusted R-squared: 0.9665 F-statistic: 94.25 on 17 and 38 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.2676884 0.5353767 0.7323116 [2,] 0.1619965 0.3239931 0.8380035 [3,] 0.1084263 0.2168526 0.8915737 [4,] 0.1517944 0.3035887 0.8482056 [5,] 0.5273558 0.9452883 0.4726442 [6,] 0.6087191 0.7825619 0.3912809 [7,] 0.4848866 0.9697731 0.5151134 [8,] 0.3849730 0.7699460 0.6150270 [9,] 0.2959097 0.5918193 0.7040903 [10,] 0.2610851 0.5221702 0.7389149 [11,] 0.1794410 0.3588820 0.8205590 [12,] 0.1324213 0.2648426 0.8675787 [13,] 0.1447301 0.2894602 0.8552699 [14,] 0.1756549 0.3513098 0.8243451 [15,] 0.1035931 0.2071862 0.8964069 > postscript(file="/var/www/html/rcomp/tmp/1oe741258731166.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/2st7v1258731166.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/3mxu81258731166.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/4qy1e1258731166.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/5cq1d1258731166.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.266051517 0.225969439 -1.169313028 1.040379901 -1.357719649 -1.437079822 7 8 9 10 11 12 0.301426291 -2.847430932 -1.621198763 0.568791197 -1.783365404 3.788756737 13 14 15 16 17 18 3.086926887 0.954177496 0.897782437 1.126107035 0.061520988 2.343723924 19 20 21 22 23 24 -0.701012417 -0.831437698 -0.054186250 0.853910339 1.291201579 -1.472963798 25 26 27 28 29 30 -1.682733910 0.136905195 -0.724202618 -0.221453071 -0.018032624 0.483037305 31 32 33 34 35 36 0.056821312 1.311069987 -1.240893692 -1.232616756 0.007318433 0.357395138 37 38 39 40 41 42 -0.937627931 -0.005520053 1.447683971 1.843529336 -0.105838934 -0.736653842 43 44 45 46 47 48 -0.493914259 -0.454648297 2.916278704 -0.190084780 0.484845393 -2.673188077 49 50 51 52 53 54 -0.200513529 -1.311532077 -0.451950762 -3.788563202 1.420070219 -0.653027565 55 56 0.836679072 2.822446941 > postscript(file="/var/www/html/rcomp/tmp/66phb1258731166.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.266051517 NA 1 0.225969439 -0.266051517 2 -1.169313028 0.225969439 3 1.040379901 -1.169313028 4 -1.357719649 1.040379901 5 -1.437079822 -1.357719649 6 0.301426291 -1.437079822 7 -2.847430932 0.301426291 8 -1.621198763 -2.847430932 9 0.568791197 -1.621198763 10 -1.783365404 0.568791197 11 3.788756737 -1.783365404 12 3.086926887 3.788756737 13 0.954177496 3.086926887 14 0.897782437 0.954177496 15 1.126107035 0.897782437 16 0.061520988 1.126107035 17 2.343723924 0.061520988 18 -0.701012417 2.343723924 19 -0.831437698 -0.701012417 20 -0.054186250 -0.831437698 21 0.853910339 -0.054186250 22 1.291201579 0.853910339 23 -1.472963798 1.291201579 24 -1.682733910 -1.472963798 25 0.136905195 -1.682733910 26 -0.724202618 0.136905195 27 -0.221453071 -0.724202618 28 -0.018032624 -0.221453071 29 0.483037305 -0.018032624 30 0.056821312 0.483037305 31 1.311069987 0.056821312 32 -1.240893692 1.311069987 33 -1.232616756 -1.240893692 34 0.007318433 -1.232616756 35 0.357395138 0.007318433 36 -0.937627931 0.357395138 37 -0.005520053 -0.937627931 38 1.447683971 -0.005520053 39 1.843529336 1.447683971 40 -0.105838934 1.843529336 41 -0.736653842 -0.105838934 42 -0.493914259 -0.736653842 43 -0.454648297 -0.493914259 44 2.916278704 -0.454648297 45 -0.190084780 2.916278704 46 0.484845393 -0.190084780 47 -2.673188077 0.484845393 48 -0.200513529 -2.673188077 49 -1.311532077 -0.200513529 50 -0.451950762 -1.311532077 51 -3.788563202 -0.451950762 52 1.420070219 -3.788563202 53 -0.653027565 1.420070219 54 0.836679072 -0.653027565 55 2.822446941 0.836679072 56 NA 2.822446941 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 0.225969439 -0.266051517 [2,] -1.169313028 0.225969439 [3,] 1.040379901 -1.169313028 [4,] -1.357719649 1.040379901 [5,] -1.437079822 -1.357719649 [6,] 0.301426291 -1.437079822 [7,] -2.847430932 0.301426291 [8,] -1.621198763 -2.847430932 [9,] 0.568791197 -1.621198763 [10,] -1.783365404 0.568791197 [11,] 3.788756737 -1.783365404 [12,] 3.086926887 3.788756737 [13,] 0.954177496 3.086926887 [14,] 0.897782437 0.954177496 [15,] 1.126107035 0.897782437 [16,] 0.061520988 1.126107035 [17,] 2.343723924 0.061520988 [18,] -0.701012417 2.343723924 [19,] -0.831437698 -0.701012417 [20,] -0.054186250 -0.831437698 [21,] 0.853910339 -0.054186250 [22,] 1.291201579 0.853910339 [23,] -1.472963798 1.291201579 [24,] -1.682733910 -1.472963798 [25,] 0.136905195 -1.682733910 [26,] -0.724202618 0.136905195 [27,] -0.221453071 -0.724202618 [28,] -0.018032624 -0.221453071 [29,] 0.483037305 -0.018032624 [30,] 0.056821312 0.483037305 [31,] 1.311069987 0.056821312 [32,] -1.240893692 1.311069987 [33,] -1.232616756 -1.240893692 [34,] 0.007318433 -1.232616756 [35,] 0.357395138 0.007318433 [36,] -0.937627931 0.357395138 [37,] -0.005520053 -0.937627931 [38,] 1.447683971 -0.005520053 [39,] 1.843529336 1.447683971 [40,] -0.105838934 1.843529336 [41,] -0.736653842 -0.105838934 [42,] -0.493914259 -0.736653842 [43,] -0.454648297 -0.493914259 [44,] 2.916278704 -0.454648297 [45,] -0.190084780 2.916278704 [46,] 0.484845393 -0.190084780 [47,] -2.673188077 0.484845393 [48,] -0.200513529 -2.673188077 [49,] -1.311532077 -0.200513529 [50,] -0.451950762 -1.311532077 [51,] -3.788563202 -0.451950762 [52,] 1.420070219 -3.788563202 [53,] -0.653027565 1.420070219 [54,] 0.836679072 -0.653027565 [55,] 2.822446941 0.836679072 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 0.225969439 -0.266051517 2 -1.169313028 0.225969439 3 1.040379901 -1.169313028 4 -1.357719649 1.040379901 5 -1.437079822 -1.357719649 6 0.301426291 -1.437079822 7 -2.847430932 0.301426291 8 -1.621198763 -2.847430932 9 0.568791197 -1.621198763 10 -1.783365404 0.568791197 11 3.788756737 -1.783365404 12 3.086926887 3.788756737 13 0.954177496 3.086926887 14 0.897782437 0.954177496 15 1.126107035 0.897782437 16 0.061520988 1.126107035 17 2.343723924 0.061520988 18 -0.701012417 2.343723924 19 -0.831437698 -0.701012417 20 -0.054186250 -0.831437698 21 0.853910339 -0.054186250 22 1.291201579 0.853910339 23 -1.472963798 1.291201579 24 -1.682733910 -1.472963798 25 0.136905195 -1.682733910 26 -0.724202618 0.136905195 27 -0.221453071 -0.724202618 28 -0.018032624 -0.221453071 29 0.483037305 -0.018032624 30 0.056821312 0.483037305 31 1.311069987 0.056821312 32 -1.240893692 1.311069987 33 -1.232616756 -1.240893692 34 0.007318433 -1.232616756 35 0.357395138 0.007318433 36 -0.937627931 0.357395138 37 -0.005520053 -0.937627931 38 1.447683971 -0.005520053 39 1.843529336 1.447683971 40 -0.105838934 1.843529336 41 -0.736653842 -0.105838934 42 -0.493914259 -0.736653842 43 -0.454648297 -0.493914259 44 2.916278704 -0.454648297 45 -0.190084780 2.916278704 46 0.484845393 -0.190084780 47 -2.673188077 0.484845393 48 -0.200513529 -2.673188077 49 -1.311532077 -0.200513529 50 -0.451950762 -1.311532077 51 -3.788563202 -0.451950762 52 1.420070219 -3.788563202 53 -0.653027565 1.420070219 54 0.836679072 -0.653027565 55 2.822446941 0.836679072 > 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/7re201258731167.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/8tnu51258731167.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/91kpr1258731167.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/10h59o1258731167.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/11ce0k1258731167.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/12fd0r1258731167.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/134ra31258731167.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/14vnq61258731167.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/15umdk1258731167.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/16y4g81258731167.tab") + } > > system("convert tmp/1oe741258731166.ps tmp/1oe741258731166.png") > system("convert tmp/2st7v1258731166.ps tmp/2st7v1258731166.png") > system("convert tmp/3mxu81258731166.ps tmp/3mxu81258731166.png") > system("convert tmp/4qy1e1258731166.ps tmp/4qy1e1258731166.png") > system("convert tmp/5cq1d1258731166.ps tmp/5cq1d1258731166.png") > system("convert tmp/66phb1258731166.ps tmp/66phb1258731166.png") > system("convert tmp/7re201258731167.ps tmp/7re201258731167.png") > system("convert tmp/8tnu51258731167.ps tmp/8tnu51258731167.png") > system("convert tmp/91kpr1258731167.ps tmp/91kpr1258731167.png") > system("convert tmp/10h59o1258731167.ps tmp/10h59o1258731167.png") > > > proc.time() user system elapsed 2.348 1.558 2.935