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(86.0 + ,88.4 + ,90.7 + ,95.3 + ,100.0 + ,94.7 + ,86.0 + ,86.0 + ,88.4 + ,90.7 + ,95.3 + ,110.6 + ,95.3 + ,86.0 + ,86.0 + ,88.4 + ,90.7 + ,71.3 + ,95.3 + ,95.3 + ,86.0 + ,86.0 + ,88.4 + ,104.1 + ,88.4 + ,95.3 + ,95.3 + ,86.0 + ,86.0 + ,112.3 + ,86.0 + ,88.4 + ,95.3 + ,95.3 + ,86.0 + ,110.2 + ,81.4 + ,86.0 + ,88.4 + ,95.3 + ,95.3 + ,112.9 + ,83.7 + ,81.4 + ,86.0 + ,88.4 + ,95.3 + ,95.1 + ,95.3 + ,83.7 + ,81.4 + ,86.0 + ,88.4 + ,103.1 + ,88.4 + ,95.3 + ,83.7 + ,81.4 + ,86.0 + ,101.9 + ,86.0 + ,88.4 + ,95.3 + ,83.7 + ,81.4 + ,100.4 + ,83.7 + ,86.0 + ,88.4 + ,95.3 + ,83.7 + ,106.9 + ,76.7 + ,83.7 + ,86.0 + ,88.4 + ,95.3 + ,100.7 + ,79.1 + ,76.7 + ,83.7 + ,86.0 + ,88.4 + ,114.3 + ,86.0 + ,79.1 + ,76.7 + ,83.7 + ,86.0 + ,73.3 + ,86.0 + ,86.0 + ,79.1 + ,76.7 + ,83.7 + ,105.9 + ,79.1 + ,86.0 + ,86.0 + ,79.1 + ,76.7 + ,113.9 + ,76.7 + ,79.1 + ,86.0 + ,86.0 + ,79.1 + ,112.1 + ,69.8 + ,76.7 + ,79.1 + ,86.0 + ,86.0 + ,117.5 + ,69.8 + ,69.8 + ,76.7 + ,79.1 + ,86.0 + ,97.5 + ,76.7 + ,69.8 + ,69.8 + ,76.7 + ,79.1 + ,112.3 + ,69.8 + ,76.7 + ,69.8 + ,69.8 + ,76.7 + ,106.9 + ,67.4 + ,69.8 + ,76.7 + ,69.8 + ,69.8 + ,120.9 + ,65.1 + ,67.4 + ,69.8 + ,76.7 + ,69.8 + ,92.7 + ,58.1 + ,65.1 + ,67.4 + ,69.8 + ,76.7 + ,110.9 + ,60.5 + ,58.1 + ,65.1 + ,67.4 + ,69.8 + ,116.5 + ,65.1 + ,60.5 + ,58.1 + ,65.1 + ,67.4 + ,77.1 + ,62.8 + ,65.1 + ,60.5 + ,58.1 + ,65.1 + ,113.1 + ,55.8 + ,62.8 + ,65.1 + ,60.5 + ,58.1 + ,115.9 + ,51.2 + ,55.8 + ,62.8 + ,65.1 + ,60.5 + ,123.5 + ,48.8 + ,51.2 + ,55.8 + ,62.8 + ,65.1 + ,123.6 + ,48.8 + ,48.8 + ,51.2 + ,55.8 + ,62.8 + ,101.5 + ,53.5 + ,48.8 + ,48.8 + ,51.2 + ,55.8 + ,121.0 + ,48.8 + ,53.5 + ,48.8 + ,48.8 + ,51.2 + ,112.2 + ,46.5 + ,48.8 + ,53.5 + ,48.8 + ,48.8 + ,126.0 + ,44.2 + ,46.5 + ,48.8 + ,53.5 + ,48.8 + ,101.8 + ,39.5 + ,44.2 + ,46.5 + ,48.8 + ,53.5 + ,117.9 + ,41.9 + ,39.5 + ,44.2 + ,46.5 + ,48.8 + ,122.2 + ,48.8 + ,41.9 + ,39.5 + ,44.2 + ,46.5 + ,82.7 + ,46.5 + ,48.8 + ,41.9 + ,39.5 + ,44.2 + ,120.5 + ,41.9 + ,46.5 + ,48.8 + ,41.9 + ,39.5 + ,120.3 + ,39.5 + ,41.9 + ,46.5 + ,48.8 + ,41.9 + ,134.2 + ,37.2 + ,39.5 + ,41.9 + ,46.5 + ,48.8 + ,128.2 + ,37.2 + ,37.2 + ,39.5 + ,41.9 + ,46.5 + ,100.5 + ,41.9 + ,37.2 + ,37.2 + ,39.5 + ,41.9 + ,126.0 + ,39.5 + ,41.9 + ,37.2 + ,37.2 + ,39.5 + ,122.9 + ,39.5 + ,39.5 + ,41.9 + ,37.2 + ,37.2 + ,106.1 + ,34.9 + ,39.5 + ,39.5 + ,41.9 + ,37.2 + ,130.4 + ,34.9 + ,34.9 + ,39.5 + ,39.5 + ,41.9 + ,121.3 + ,34.9 + ,34.9 + ,34.9 + ,39.5 + ,39.5 + ,126.1 + ,41.9 + ,34.9 + ,34.9 + ,34.9 + ,39.5 + ,88.7 + ,41.9 + ,41.9 + ,34.9 + ,34.9 + ,34.9 + ,118.7 + ,39.5 + ,41.9 + ,41.9 + ,34.9 + ,34.9 + ,129.3 + ,39.5 + ,39.5 + ,41.9 + ,41.9 + ,34.9 + ,136.2 + ,41.9 + ,39.5 + ,39.5 + ,41.9 + ,41.9 + ,123.0 + ,46.5 + ,41.9 + ,39.5 + ,39.5 + ,41.9 + ,103.5) + ,dim=c(6 + ,56) + ,dimnames=list(c('Werkloosheid(Y(t))' + ,'Y(t-1)' + ,'Y(t-2)' + ,'Y(t-3)' + ,'Y(t-4)' + ,'Productie') + ,1:56)) > y <- array(NA,dim=c(6,56),dimnames=list(c('Werkloosheid(Y(t))','Y(t-1)','Y(t-2)','Y(t-3)','Y(t-4)','Productie'),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 Werkloosheid(Y(t)) Y(t-1) Y(t-2) Y(t-3) Y(t-4) Productie M1 M2 M3 M4 M5 M6 1 86.0 88.4 90.7 95.3 100.0 94.7 1 0 0 0 0 0 2 86.0 86.0 88.4 90.7 95.3 110.6 0 1 0 0 0 0 3 95.3 86.0 86.0 88.4 90.7 71.3 0 0 1 0 0 0 4 95.3 95.3 86.0 86.0 88.4 104.1 0 0 0 1 0 0 5 88.4 95.3 95.3 86.0 86.0 112.3 0 0 0 0 1 0 6 86.0 88.4 95.3 95.3 86.0 110.2 0 0 0 0 0 1 7 81.4 86.0 88.4 95.3 95.3 112.9 0 0 0 0 0 0 8 83.7 81.4 86.0 88.4 95.3 95.1 0 0 0 0 0 0 9 95.3 83.7 81.4 86.0 88.4 103.1 0 0 0 0 0 0 10 88.4 95.3 83.7 81.4 86.0 101.9 0 0 0 0 0 0 11 86.0 88.4 95.3 83.7 81.4 100.4 0 0 0 0 0 0 12 83.7 86.0 88.4 95.3 83.7 106.9 0 0 0 0 0 0 13 76.7 83.7 86.0 88.4 95.3 100.7 1 0 0 0 0 0 14 79.1 76.7 83.7 86.0 88.4 114.3 0 1 0 0 0 0 15 86.0 79.1 76.7 83.7 86.0 73.3 0 0 1 0 0 0 16 86.0 86.0 79.1 76.7 83.7 105.9 0 0 0 1 0 0 17 79.1 86.0 86.0 79.1 76.7 113.9 0 0 0 0 1 0 18 76.7 79.1 86.0 86.0 79.1 112.1 0 0 0 0 0 1 19 69.8 76.7 79.1 86.0 86.0 117.5 0 0 0 0 0 0 20 69.8 69.8 76.7 79.1 86.0 97.5 0 0 0 0 0 0 21 76.7 69.8 69.8 76.7 79.1 112.3 0 0 0 0 0 0 22 69.8 76.7 69.8 69.8 76.7 106.9 0 0 0 0 0 0 23 67.4 69.8 76.7 69.8 69.8 120.9 0 0 0 0 0 0 24 65.1 67.4 69.8 76.7 69.8 92.7 0 0 0 0 0 0 25 58.1 65.1 67.4 69.8 76.7 110.9 1 0 0 0 0 0 26 60.5 58.1 65.1 67.4 69.8 116.5 0 1 0 0 0 0 27 65.1 60.5 58.1 65.1 67.4 77.1 0 0 1 0 0 0 28 62.8 65.1 60.5 58.1 65.1 113.1 0 0 0 1 0 0 29 55.8 62.8 65.1 60.5 58.1 115.9 0 0 0 0 1 0 30 51.2 55.8 62.8 65.1 60.5 123.5 0 0 0 0 0 1 31 48.8 51.2 55.8 62.8 65.1 123.6 0 0 0 0 0 0 32 48.8 48.8 51.2 55.8 62.8 101.5 0 0 0 0 0 0 33 53.5 48.8 48.8 51.2 55.8 121.0 0 0 0 0 0 0 34 48.8 53.5 48.8 48.8 51.2 112.2 0 0 0 0 0 0 35 46.5 48.8 53.5 48.8 48.8 126.0 0 0 0 0 0 0 36 44.2 46.5 48.8 53.5 48.8 101.8 0 0 0 0 0 0 37 39.5 44.2 46.5 48.8 53.5 117.9 1 0 0 0 0 0 38 41.9 39.5 44.2 46.5 48.8 122.2 0 1 0 0 0 0 39 48.8 41.9 39.5 44.2 46.5 82.7 0 0 1 0 0 0 40 46.5 48.8 41.9 39.5 44.2 120.5 0 0 0 1 0 0 41 41.9 46.5 48.8 41.9 39.5 120.3 0 0 0 0 1 0 42 39.5 41.9 46.5 48.8 41.9 134.2 0 0 0 0 0 1 43 37.2 39.5 41.9 46.5 48.8 128.2 0 0 0 0 0 0 44 37.2 37.2 39.5 41.9 46.5 100.5 0 0 0 0 0 0 45 41.9 37.2 37.2 39.5 41.9 126.0 0 0 0 0 0 0 46 39.5 41.9 37.2 37.2 39.5 122.9 0 0 0 0 0 0 47 39.5 39.5 41.9 37.2 37.2 106.1 0 0 0 0 0 0 48 34.9 39.5 39.5 41.9 37.2 130.4 0 0 0 0 0 0 49 34.9 34.9 39.5 39.5 41.9 121.3 1 0 0 0 0 0 50 34.9 34.9 34.9 39.5 39.5 126.1 0 1 0 0 0 0 51 41.9 34.9 34.9 34.9 39.5 88.7 0 0 1 0 0 0 52 41.9 41.9 34.9 34.9 34.9 118.7 0 0 0 1 0 0 53 39.5 41.9 41.9 34.9 34.9 129.3 0 0 0 0 1 0 54 39.5 39.5 41.9 41.9 34.9 136.2 0 0 0 0 0 1 55 41.9 39.5 39.5 41.9 41.9 123.0 0 0 0 0 0 0 56 46.5 41.9 39.5 39.5 41.9 103.5 0 0 0 0 0 0 M7 M8 M9 M10 M11 t 1 0 0 0 0 0 1 2 0 0 0 0 0 2 3 0 0 0 0 0 3 4 0 0 0 0 0 4 5 0 0 0 0 0 5 6 0 0 0 0 0 6 7 1 0 0 0 0 7 8 0 1 0 0 0 8 9 0 0 1 0 0 9 10 0 0 0 1 0 10 11 0 0 0 0 1 11 12 0 0 0 0 0 12 13 0 0 0 0 0 13 14 0 0 0 0 0 14 15 0 0 0 0 0 15 16 0 0 0 0 0 16 17 0 0 0 0 0 17 18 0 0 0 0 0 18 19 1 0 0 0 0 19 20 0 1 0 0 0 20 21 0 0 1 0 0 21 22 0 0 0 1 0 22 23 0 0 0 0 1 23 24 0 0 0 0 0 24 25 0 0 0 0 0 25 26 0 0 0 0 0 26 27 0 0 0 0 0 27 28 0 0 0 0 0 28 29 0 0 0 0 0 29 30 0 0 0 0 0 30 31 1 0 0 0 0 31 32 0 1 0 0 0 32 33 0 0 1 0 0 33 34 0 0 0 1 0 34 35 0 0 0 0 1 35 36 0 0 0 0 0 36 37 0 0 0 0 0 37 38 0 0 0 0 0 38 39 0 0 0 0 0 39 40 0 0 0 0 0 40 41 0 0 0 0 0 41 42 0 0 0 0 0 42 43 1 0 0 0 0 43 44 0 1 0 0 0 44 45 0 0 1 0 0 45 46 0 0 0 1 0 46 47 0 0 0 0 1 47 48 0 0 0 0 0 48 49 0 0 0 0 0 49 50 0 0 0 0 0 50 51 0 0 0 0 0 51 52 0 0 0 0 0 52 53 0 0 0 0 0 53 54 0 0 0 0 0 54 55 1 0 0 0 0 55 56 0 1 0 0 0 56 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) `Y(t-1)` `Y(t-2)` `Y(t-3)` `Y(t-4)` Productie 2.85104 0.97613 0.23637 0.13459 -0.34198 -0.08643 M1 M2 M3 M4 M5 M6 2.57043 8.04528 10.68526 5.13454 -2.36139 0.84038 M7 M8 M9 M10 M11 t 3.94041 7.08999 13.92405 0.82638 1.18104 0.06482 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -3.7986 -1.1514 -0.1193 0.8659 4.5657 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.85104 10.30659 0.277 0.783569 `Y(t-1)` 0.97613 0.15188 6.427 1.48e-07 *** `Y(t-2)` 0.23637 0.21716 1.088 0.283264 `Y(t-3)` 0.13459 0.21623 0.622 0.537359 `Y(t-4)` -0.34198 0.17316 -1.975 0.055580 . Productie -0.08643 0.05589 -1.546 0.130315 M1 2.57043 2.40670 1.068 0.292246 M2 8.04528 2.08431 3.860 0.000427 *** M3 10.68526 2.78216 3.841 0.000452 *** M4 5.13454 2.87356 1.787 0.081945 . M5 -2.36139 2.51338 -0.940 0.353395 M6 0.84038 1.79216 0.469 0.641807 M7 3.94041 2.04567 1.926 0.061582 . M8 7.08999 2.59709 2.730 0.009546 ** M9 13.92405 2.23946 6.218 2.86e-07 *** M10 0.82638 2.85157 0.290 0.773547 M11 1.18104 2.56328 0.461 0.647601 t 0.06482 0.09596 0.676 0.503428 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 2.034 on 38 degrees of freedom Multiple R-squared: 0.9928, Adjusted R-squared: 0.9895 F-statistic: 307.1 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.5114034 0.9771933 0.4885966 [2,] 0.3446576 0.6893152 0.6553424 [3,] 0.8419105 0.3161791 0.1580895 [4,] 0.7492497 0.5015007 0.2507503 [5,] 0.7078822 0.5842355 0.2921178 [6,] 0.6452810 0.7094380 0.3547190 [7,] 0.5790096 0.8419807 0.4209904 [8,] 0.4957606 0.9915213 0.5042394 [9,] 0.4320840 0.8641679 0.5679160 [10,] 0.4922701 0.9845402 0.5077299 [11,] 0.5825693 0.8348615 0.4174307 [12,] 0.4477621 0.8955242 0.5522379 [13,] 0.4017423 0.8034845 0.5982577 [14,] 0.4101919 0.8203838 0.5898081 [15,] 0.3035973 0.6071946 0.6964027 > postscript(file="/var/www/html/rcomp/tmp/1pbec1261307442.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/2iu6r1261307442.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/33xv91261307442.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/4h3so1261307442.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/5jbu61261307442.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 2.34109291 0.07379422 2.57618167 1.35535253 -0.42378791 -0.78830498 7 8 9 10 11 12 -1.16580167 2.36756532 4.56567254 -1.47352560 -2.31186704 0.26501594 13 14 15 16 17 18 -2.19808862 1.17756651 0.62995296 1.78639652 -1.33886567 -0.53368783 19 20 21 22 23 24 -3.79857582 -0.51025325 0.36428979 -0.59689280 0.53831596 -0.03775771 25 26 27 28 29 30 -1.99934340 0.68489959 -2.02443153 -0.62904389 -1.51498848 -1.14658230 31 32 33 34 35 36 1.32460636 -0.21422279 -1.93521390 -0.20078326 0.92855695 0.37667698 37 38 39 40 41 42 -0.53849403 0.52718888 -0.40022884 -1.40393212 0.09374744 0.55436925 43 44 45 46 47 48 0.67014212 -2.29331735 -2.99474843 2.27120167 0.84499413 -0.60393522 49 50 51 52 53 54 2.39483315 -2.46344920 -0.78147425 -1.10877305 3.18389462 1.91420586 55 56 2.96962901 0.65022807 > postscript(file="/var/www/html/rcomp/tmp/6jxa81261307442.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 2.34109291 NA 1 0.07379422 2.34109291 2 2.57618167 0.07379422 3 1.35535253 2.57618167 4 -0.42378791 1.35535253 5 -0.78830498 -0.42378791 6 -1.16580167 -0.78830498 7 2.36756532 -1.16580167 8 4.56567254 2.36756532 9 -1.47352560 4.56567254 10 -2.31186704 -1.47352560 11 0.26501594 -2.31186704 12 -2.19808862 0.26501594 13 1.17756651 -2.19808862 14 0.62995296 1.17756651 15 1.78639652 0.62995296 16 -1.33886567 1.78639652 17 -0.53368783 -1.33886567 18 -3.79857582 -0.53368783 19 -0.51025325 -3.79857582 20 0.36428979 -0.51025325 21 -0.59689280 0.36428979 22 0.53831596 -0.59689280 23 -0.03775771 0.53831596 24 -1.99934340 -0.03775771 25 0.68489959 -1.99934340 26 -2.02443153 0.68489959 27 -0.62904389 -2.02443153 28 -1.51498848 -0.62904389 29 -1.14658230 -1.51498848 30 1.32460636 -1.14658230 31 -0.21422279 1.32460636 32 -1.93521390 -0.21422279 33 -0.20078326 -1.93521390 34 0.92855695 -0.20078326 35 0.37667698 0.92855695 36 -0.53849403 0.37667698 37 0.52718888 -0.53849403 38 -0.40022884 0.52718888 39 -1.40393212 -0.40022884 40 0.09374744 -1.40393212 41 0.55436925 0.09374744 42 0.67014212 0.55436925 43 -2.29331735 0.67014212 44 -2.99474843 -2.29331735 45 2.27120167 -2.99474843 46 0.84499413 2.27120167 47 -0.60393522 0.84499413 48 2.39483315 -0.60393522 49 -2.46344920 2.39483315 50 -0.78147425 -2.46344920 51 -1.10877305 -0.78147425 52 3.18389462 -1.10877305 53 1.91420586 3.18389462 54 2.96962901 1.91420586 55 0.65022807 2.96962901 56 NA 0.65022807 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 0.07379422 2.34109291 [2,] 2.57618167 0.07379422 [3,] 1.35535253 2.57618167 [4,] -0.42378791 1.35535253 [5,] -0.78830498 -0.42378791 [6,] -1.16580167 -0.78830498 [7,] 2.36756532 -1.16580167 [8,] 4.56567254 2.36756532 [9,] -1.47352560 4.56567254 [10,] -2.31186704 -1.47352560 [11,] 0.26501594 -2.31186704 [12,] -2.19808862 0.26501594 [13,] 1.17756651 -2.19808862 [14,] 0.62995296 1.17756651 [15,] 1.78639652 0.62995296 [16,] -1.33886567 1.78639652 [17,] -0.53368783 -1.33886567 [18,] -3.79857582 -0.53368783 [19,] -0.51025325 -3.79857582 [20,] 0.36428979 -0.51025325 [21,] -0.59689280 0.36428979 [22,] 0.53831596 -0.59689280 [23,] -0.03775771 0.53831596 [24,] -1.99934340 -0.03775771 [25,] 0.68489959 -1.99934340 [26,] -2.02443153 0.68489959 [27,] -0.62904389 -2.02443153 [28,] -1.51498848 -0.62904389 [29,] -1.14658230 -1.51498848 [30,] 1.32460636 -1.14658230 [31,] -0.21422279 1.32460636 [32,] -1.93521390 -0.21422279 [33,] -0.20078326 -1.93521390 [34,] 0.92855695 -0.20078326 [35,] 0.37667698 0.92855695 [36,] -0.53849403 0.37667698 [37,] 0.52718888 -0.53849403 [38,] -0.40022884 0.52718888 [39,] -1.40393212 -0.40022884 [40,] 0.09374744 -1.40393212 [41,] 0.55436925 0.09374744 [42,] 0.67014212 0.55436925 [43,] -2.29331735 0.67014212 [44,] -2.99474843 -2.29331735 [45,] 2.27120167 -2.99474843 [46,] 0.84499413 2.27120167 [47,] -0.60393522 0.84499413 [48,] 2.39483315 -0.60393522 [49,] -2.46344920 2.39483315 [50,] -0.78147425 -2.46344920 [51,] -1.10877305 -0.78147425 [52,] 3.18389462 -1.10877305 [53,] 1.91420586 3.18389462 [54,] 2.96962901 1.91420586 [55,] 0.65022807 2.96962901 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 0.07379422 2.34109291 2 2.57618167 0.07379422 3 1.35535253 2.57618167 4 -0.42378791 1.35535253 5 -0.78830498 -0.42378791 6 -1.16580167 -0.78830498 7 2.36756532 -1.16580167 8 4.56567254 2.36756532 9 -1.47352560 4.56567254 10 -2.31186704 -1.47352560 11 0.26501594 -2.31186704 12 -2.19808862 0.26501594 13 1.17756651 -2.19808862 14 0.62995296 1.17756651 15 1.78639652 0.62995296 16 -1.33886567 1.78639652 17 -0.53368783 -1.33886567 18 -3.79857582 -0.53368783 19 -0.51025325 -3.79857582 20 0.36428979 -0.51025325 21 -0.59689280 0.36428979 22 0.53831596 -0.59689280 23 -0.03775771 0.53831596 24 -1.99934340 -0.03775771 25 0.68489959 -1.99934340 26 -2.02443153 0.68489959 27 -0.62904389 -2.02443153 28 -1.51498848 -0.62904389 29 -1.14658230 -1.51498848 30 1.32460636 -1.14658230 31 -0.21422279 1.32460636 32 -1.93521390 -0.21422279 33 -0.20078326 -1.93521390 34 0.92855695 -0.20078326 35 0.37667698 0.92855695 36 -0.53849403 0.37667698 37 0.52718888 -0.53849403 38 -0.40022884 0.52718888 39 -1.40393212 -0.40022884 40 0.09374744 -1.40393212 41 0.55436925 0.09374744 42 0.67014212 0.55436925 43 -2.29331735 0.67014212 44 -2.99474843 -2.29331735 45 2.27120167 -2.99474843 46 0.84499413 2.27120167 47 -0.60393522 0.84499413 48 2.39483315 -0.60393522 49 -2.46344920 2.39483315 50 -0.78147425 -2.46344920 51 -1.10877305 -0.78147425 52 3.18389462 -1.10877305 53 1.91420586 3.18389462 54 2.96962901 1.91420586 55 0.65022807 2.96962901 > 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/7dd761261307442.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/8idq81261307442.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/92o9i1261307442.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/10n41y1261307442.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/11362w1261307442.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/1297b81261307442.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/13ky9r1261307442.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/14u7n51261307442.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/15ppqf1261307442.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/16bx7v1261307442.tab") + } > > try(system("convert tmp/1pbec1261307442.ps tmp/1pbec1261307442.png",intern=TRUE)) character(0) > try(system("convert tmp/2iu6r1261307442.ps tmp/2iu6r1261307442.png",intern=TRUE)) character(0) > try(system("convert tmp/33xv91261307442.ps tmp/33xv91261307442.png",intern=TRUE)) character(0) > try(system("convert tmp/4h3so1261307442.ps tmp/4h3so1261307442.png",intern=TRUE)) character(0) > try(system("convert tmp/5jbu61261307442.ps tmp/5jbu61261307442.png",intern=TRUE)) character(0) > try(system("convert tmp/6jxa81261307442.ps tmp/6jxa81261307442.png",intern=TRUE)) character(0) > try(system("convert tmp/7dd761261307442.ps tmp/7dd761261307442.png",intern=TRUE)) character(0) > try(system("convert tmp/8idq81261307442.ps tmp/8idq81261307442.png",intern=TRUE)) character(0) > try(system("convert tmp/92o9i1261307442.ps tmp/92o9i1261307442.png",intern=TRUE)) character(0) > try(system("convert tmp/10n41y1261307442.ps tmp/10n41y1261307442.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.305 1.532 3.728