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(109.5 + ,120.1 + ,109.5 + ,110.2 + ,108.8 + ,108.2 + ,116 + ,132.9 + ,109.5 + ,109.5 + ,110.2 + ,108.8 + ,111.2 + ,128.1 + ,116 + ,109.5 + ,109.5 + ,110.2 + ,112.1 + ,129.3 + ,111.2 + ,116 + ,109.5 + ,109.5 + ,114 + ,132.5 + ,112.1 + ,111.2 + ,116 + ,109.5 + ,119.1 + ,131 + ,114 + ,112.1 + ,111.2 + ,116 + ,114.1 + ,124.9 + ,119.1 + ,114 + ,112.1 + ,111.2 + ,115.1 + ,120.8 + ,114.1 + ,119.1 + ,114 + ,112.1 + ,115.4 + ,122 + ,115.1 + ,114.1 + ,119.1 + ,114 + ,110.8 + ,122.1 + ,115.4 + ,115.1 + ,114.1 + ,119.1 + ,116 + ,127.4 + ,110.8 + ,115.4 + ,115.1 + ,114.1 + ,119.2 + ,135.2 + ,116 + ,110.8 + ,115.4 + ,115.1 + ,126.5 + ,137.3 + ,119.2 + ,116 + ,110.8 + ,115.4 + ,127.8 + ,135 + ,126.5 + ,119.2 + ,116 + ,110.8 + ,131.3 + ,136 + ,127.8 + ,126.5 + ,119.2 + ,116 + ,140.3 + ,138.4 + ,131.3 + ,127.8 + ,126.5 + ,119.2 + ,137.3 + ,134.7 + ,140.3 + ,131.3 + ,127.8 + ,126.5 + ,143 + ,138.4 + ,137.3 + ,140.3 + ,131.3 + ,127.8 + ,134.5 + ,133.9 + ,143 + ,137.3 + ,140.3 + ,131.3 + ,139.9 + ,133.6 + ,134.5 + ,143 + ,137.3 + ,140.3 + ,159.3 + ,141.2 + ,139.9 + ,134.5 + ,143 + ,137.3 + ,170.4 + ,151.8 + ,159.3 + ,139.9 + ,134.5 + ,143 + ,175 + ,155.4 + ,170.4 + ,159.3 + ,139.9 + ,134.5 + ,175.8 + ,156.6 + ,175 + ,170.4 + ,159.3 + ,139.9 + ,180.9 + ,161.6 + ,175.8 + ,175 + ,170.4 + ,159.3 + ,180.3 + ,160.7 + ,180.9 + ,175.8 + ,175 + ,170.4 + ,169.6 + ,156 + ,180.3 + ,180.9 + ,175.8 + ,175 + ,172.3 + ,159.5 + ,169.6 + ,180.3 + ,180.9 + ,175.8 + ,184.8 + ,168.7 + ,172.3 + ,169.6 + ,180.3 + ,180.9 + ,177.7 + ,169.9 + ,184.8 + ,172.3 + ,169.6 + ,180.3 + ,184.6 + ,169.9 + ,177.7 + ,184.8 + ,172.3 + ,169.6 + ,211.4 + ,185.9 + ,184.6 + ,177.7 + ,184.8 + ,172.3 + ,215.3 + ,190.8 + ,211.4 + ,184.6 + ,177.7 + ,184.8 + ,215.9 + ,195.8 + ,215.3 + ,211.4 + ,184.6 + ,177.7 + ,244.7 + ,211.9 + ,215.9 + ,215.3 + ,211.4 + ,184.6 + ,259.3 + ,227.1 + ,244.7 + ,215.9 + ,215.3 + ,211.4 + ,289 + ,251.3 + ,259.3 + ,244.7 + ,215.9 + ,215.3 + ,310.9 + ,256.7 + ,289 + ,259.3 + ,244.7 + ,215.9 + ,321 + ,251.9 + ,310.9 + ,289 + ,259.3 + ,244.7 + ,315.1 + ,251.2 + ,321 + ,310.9 + ,289 + ,259.3 + ,333.2 + ,270.3 + ,315.1 + ,321 + ,310.9 + ,289 + ,314.1 + ,267.2 + ,333.2 + ,315.1 + ,321 + ,310.9 + ,284.7 + ,243 + ,314.1 + ,333.2 + ,315.1 + ,321 + ,273.9 + ,229.9 + ,284.7 + ,314.1 + ,333.2 + ,315.1 + ,216 + ,187.2 + ,273.9 + ,284.7 + ,314.1 + ,333.2 + ,196.4 + ,178.2 + ,216 + ,273.9 + ,284.7 + ,314.1 + ,190.9 + ,175.2 + ,196.4 + ,216 + ,273.9 + ,284.7 + ,206.4 + ,192.4 + ,190.9 + ,196.4 + ,216 + ,273.9 + ,196.3 + ,187 + ,206.4 + ,190.9 + ,196.4 + ,216 + ,199.5 + ,184 + ,196.3 + ,206.4 + ,190.9 + ,196.4 + ,198.9 + ,194.1 + ,199.5 + ,196.3 + ,206.4 + ,190.9 + ,214.4 + ,212.7 + ,198.9 + ,199.5 + ,196.3 + ,206.4 + ,214.2 + ,217.5 + ,214.4 + ,198.9 + ,199.5 + ,196.3 + ,187.6 + ,200.5 + ,214.2 + ,214.4 + ,198.9 + ,199.5 + ,180.6 + ,205.9 + ,187.6 + ,214.2 + ,214.4 + ,198.9 + ,172.2 + ,196.5 + ,180.6 + ,187.6 + ,214.2 + ,214.4) + ,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 = 'Linear Trend' > par2 = 'Include Monthly Dummies' > par1 = '1' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > library(lattice) > library(lmtest) Loading required package: zoo Attaching package: 'zoo' The following object(s) are masked from package:base : as.Date.numeric > n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test > par1 <- as.numeric(par1) > x <- t(y) > k <- length(x[1,]) > n <- length(x[,1]) > x1 <- cbind(x[,par1], x[,1:k!=par1]) > mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1]) > colnames(x1) <- mycolnames #colnames(x)[par1] > x <- x1 > if (par3 == 'First Differences'){ + x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep=''))) + for (i in 1:n-1) { + for (j in 1:k) { + x2[i,j] <- x[i+1,j] - x[i,j] + } + } + x <- x2 + } > if (par2 == 'Include Monthly Dummies'){ + x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep =''))) + for (i in 1:11){ + x2[seq(i,n,12),i] <- 1 + } + x <- cbind(x, x2) + } > if (par2 == 'Include Quarterly Dummies'){ + x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep =''))) + for (i in 1:3){ + x2[seq(i,n,4),i] <- 1 + } + x <- cbind(x, x2) + } > k <- length(x[1,]) > if (par3 == 'Linear Trend'){ + x <- cbind(x, c(1:n)) + colnames(x)[k+1] <- 't' + } > x Y X Y1 Y2 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 109.5 120.1 109.5 110.2 108.8 108.2 1 0 0 0 0 0 0 0 0 0 0 1 2 116.0 132.9 109.5 109.5 110.2 108.8 0 1 0 0 0 0 0 0 0 0 0 2 3 111.2 128.1 116.0 109.5 109.5 110.2 0 0 1 0 0 0 0 0 0 0 0 3 4 112.1 129.3 111.2 116.0 109.5 109.5 0 0 0 1 0 0 0 0 0 0 0 4 5 114.0 132.5 112.1 111.2 116.0 109.5 0 0 0 0 1 0 0 0 0 0 0 5 6 119.1 131.0 114.0 112.1 111.2 116.0 0 0 0 0 0 1 0 0 0 0 0 6 7 114.1 124.9 119.1 114.0 112.1 111.2 0 0 0 0 0 0 1 0 0 0 0 7 8 115.1 120.8 114.1 119.1 114.0 112.1 0 0 0 0 0 0 0 1 0 0 0 8 9 115.4 122.0 115.1 114.1 119.1 114.0 0 0 0 0 0 0 0 0 1 0 0 9 10 110.8 122.1 115.4 115.1 114.1 119.1 0 0 0 0 0 0 0 0 0 1 0 10 11 116.0 127.4 110.8 115.4 115.1 114.1 0 0 0 0 0 0 0 0 0 0 1 11 12 119.2 135.2 116.0 110.8 115.4 115.1 0 0 0 0 0 0 0 0 0 0 0 12 13 126.5 137.3 119.2 116.0 110.8 115.4 1 0 0 0 0 0 0 0 0 0 0 13 14 127.8 135.0 126.5 119.2 116.0 110.8 0 1 0 0 0 0 0 0 0 0 0 14 15 131.3 136.0 127.8 126.5 119.2 116.0 0 0 1 0 0 0 0 0 0 0 0 15 16 140.3 138.4 131.3 127.8 126.5 119.2 0 0 0 1 0 0 0 0 0 0 0 16 17 137.3 134.7 140.3 131.3 127.8 126.5 0 0 0 0 1 0 0 0 0 0 0 17 18 143.0 138.4 137.3 140.3 131.3 127.8 0 0 0 0 0 1 0 0 0 0 0 18 19 134.5 133.9 143.0 137.3 140.3 131.3 0 0 0 0 0 0 1 0 0 0 0 19 20 139.9 133.6 134.5 143.0 137.3 140.3 0 0 0 0 0 0 0 1 0 0 0 20 21 159.3 141.2 139.9 134.5 143.0 137.3 0 0 0 0 0 0 0 0 1 0 0 21 22 170.4 151.8 159.3 139.9 134.5 143.0 0 0 0 0 0 0 0 0 0 1 0 22 23 175.0 155.4 170.4 159.3 139.9 134.5 0 0 0 0 0 0 0 0 0 0 1 23 24 175.8 156.6 175.0 170.4 159.3 139.9 0 0 0 0 0 0 0 0 0 0 0 24 25 180.9 161.6 175.8 175.0 170.4 159.3 1 0 0 0 0 0 0 0 0 0 0 25 26 180.3 160.7 180.9 175.8 175.0 170.4 0 1 0 0 0 0 0 0 0 0 0 26 27 169.6 156.0 180.3 180.9 175.8 175.0 0 0 1 0 0 0 0 0 0 0 0 27 28 172.3 159.5 169.6 180.3 180.9 175.8 0 0 0 1 0 0 0 0 0 0 0 28 29 184.8 168.7 172.3 169.6 180.3 180.9 0 0 0 0 1 0 0 0 0 0 0 29 30 177.7 169.9 184.8 172.3 169.6 180.3 0 0 0 0 0 1 0 0 0 0 0 30 31 184.6 169.9 177.7 184.8 172.3 169.6 0 0 0 0 0 0 1 0 0 0 0 31 32 211.4 185.9 184.6 177.7 184.8 172.3 0 0 0 0 0 0 0 1 0 0 0 32 33 215.3 190.8 211.4 184.6 177.7 184.8 0 0 0 0 0 0 0 0 1 0 0 33 34 215.9 195.8 215.3 211.4 184.6 177.7 0 0 0 0 0 0 0 0 0 1 0 34 35 244.7 211.9 215.9 215.3 211.4 184.6 0 0 0 0 0 0 0 0 0 0 1 35 36 259.3 227.1 244.7 215.9 215.3 211.4 0 0 0 0 0 0 0 0 0 0 0 36 37 289.0 251.3 259.3 244.7 215.9 215.3 1 0 0 0 0 0 0 0 0 0 0 37 38 310.9 256.7 289.0 259.3 244.7 215.9 0 1 0 0 0 0 0 0 0 0 0 38 39 321.0 251.9 310.9 289.0 259.3 244.7 0 0 1 0 0 0 0 0 0 0 0 39 40 315.1 251.2 321.0 310.9 289.0 259.3 0 0 0 1 0 0 0 0 0 0 0 40 41 333.2 270.3 315.1 321.0 310.9 289.0 0 0 0 0 1 0 0 0 0 0 0 41 42 314.1 267.2 333.2 315.1 321.0 310.9 0 0 0 0 0 1 0 0 0 0 0 42 43 284.7 243.0 314.1 333.2 315.1 321.0 0 0 0 0 0 0 1 0 0 0 0 43 44 273.9 229.9 284.7 314.1 333.2 315.1 0 0 0 0 0 0 0 1 0 0 0 44 45 216.0 187.2 273.9 284.7 314.1 333.2 0 0 0 0 0 0 0 0 1 0 0 45 46 196.4 178.2 216.0 273.9 284.7 314.1 0 0 0 0 0 0 0 0 0 1 0 46 47 190.9 175.2 196.4 216.0 273.9 284.7 0 0 0 0 0 0 0 0 0 0 1 47 48 206.4 192.4 190.9 196.4 216.0 273.9 0 0 0 0 0 0 0 0 0 0 0 48 49 196.3 187.0 206.4 190.9 196.4 216.0 1 0 0 0 0 0 0 0 0 0 0 49 50 199.5 184.0 196.3 206.4 190.9 196.4 0 1 0 0 0 0 0 0 0 0 0 50 51 198.9 194.1 199.5 196.3 206.4 190.9 0 0 1 0 0 0 0 0 0 0 0 51 52 214.4 212.7 198.9 199.5 196.3 206.4 0 0 0 1 0 0 0 0 0 0 0 52 53 214.2 217.5 214.4 198.9 199.5 196.3 0 0 0 0 1 0 0 0 0 0 0 53 54 187.6 200.5 214.2 214.4 198.9 199.5 0 0 0 0 0 1 0 0 0 0 0 54 55 180.6 205.9 187.6 214.2 214.4 198.9 0 0 0 0 0 0 1 0 0 0 0 55 56 172.2 196.5 180.6 187.6 214.2 214.4 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) X Y1 Y2 Y3 Y4 -28.86918 0.72263 0.68166 0.03575 -0.13674 -0.02591 M1 M2 M3 M4 M5 M6 -4.26080 -2.90302 -6.12901 -3.79239 -4.25183 -13.94083 M7 M8 M9 M10 M11 t -11.82939 -0.02343 -2.79353 -2.46253 5.15904 -0.35171 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -17.0914 -6.7010 0.2651 5.8604 19.2504 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -28.86918 11.62268 -2.484 0.017522 * X 0.72263 0.14173 5.099 9.75e-06 *** Y1 0.68166 0.16193 4.210 0.000151 *** Y2 0.03575 0.19875 0.180 0.858212 Y3 -0.13674 0.20158 -0.678 0.501679 Y4 -0.02591 0.13245 -0.196 0.845976 M1 -4.26080 6.93011 -0.615 0.542335 M2 -2.90302 7.12212 -0.408 0.685850 M3 -6.12901 7.18725 -0.853 0.399135 M4 -3.79239 7.24308 -0.524 0.603605 M5 -4.25183 7.06473 -0.602 0.550856 M6 -13.94083 6.96059 -2.003 0.052368 . M7 -11.82939 7.51535 -1.574 0.123771 M8 -0.02343 7.46608 -0.003 0.997513 M9 -2.79353 7.62899 -0.366 0.716266 M10 -2.46253 7.71703 -0.319 0.751396 M11 5.15904 7.65129 0.674 0.504221 t -0.35171 0.17638 -1.994 0.053365 . --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 10.12 on 38 degrees of freedom Multiple R-squared: 0.982, Adjusted R-squared: 0.9739 F-statistic: 121.8 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.24794256 0.49588513 0.7520574 [2,] 0.15403544 0.30807088 0.8459646 [3,] 0.12807609 0.25615218 0.8719239 [4,] 0.06071250 0.12142500 0.9392875 [5,] 0.05360446 0.10720892 0.9463955 [6,] 0.03692834 0.07385668 0.9630717 [7,] 0.08132111 0.16264223 0.9186789 [8,] 0.10008336 0.20016672 0.8999166 [9,] 0.12534991 0.25069981 0.8746501 [10,] 0.73710023 0.52579955 0.2628998 [11,] 0.67796273 0.64407454 0.3220373 [12,] 0.60709983 0.78580034 0.3929002 [13,] 0.63817023 0.72365955 0.3618298 [14,] 0.73899919 0.52200162 0.2610008 [15,] 0.76569504 0.46860993 0.2343050 > postscript(file="/var/www/html/rcomp/tmp/1znvo1258730546.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/2ad2n1258730546.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/3lc261258730546.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/44q2m1258730546.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/5avg21258730546.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 -4.70802139 -8.23176341 -10.47570164 -9.40628295 -8.56066201 5.84870300 7 8 9 10 11 12 -0.04867734 -4.03101700 -1.23269691 -6.67607541 -9.44373551 -9.68279358 13 14 15 16 17 18 -2.27625855 -4.81895085 0.96126288 4.89081962 -0.51753097 14.78496129 19 20 21 22 23 24 5.32013791 4.89599870 19.25037914 8.27923992 -4.73391074 -0.03017736 25 26 27 28 29 30 7.37976158 3.83552420 0.56483088 6.78406020 12.03909482 4.01667398 31 32 33 34 35 36 13.64190337 14.75505522 -0.92632768 -6.77577818 6.41491447 -2.88417200 37 38 39 40 41 42 3.14186414 3.31981121 7.21840716 -3.38903340 9.14458753 -7.85337090 43 44 45 46 47 48 -9.69778948 0.56029188 -17.09135455 5.17261367 7.76273179 12.59714294 49 50 51 52 53 54 -3.53734577 5.89537885 1.73120072 1.12043653 -12.10548937 -16.79696736 55 56 -9.21557447 -16.18032879 > postscript(file="/var/www/html/rcomp/tmp/62r9i1258730546.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 -4.70802139 NA 1 -8.23176341 -4.70802139 2 -10.47570164 -8.23176341 3 -9.40628295 -10.47570164 4 -8.56066201 -9.40628295 5 5.84870300 -8.56066201 6 -0.04867734 5.84870300 7 -4.03101700 -0.04867734 8 -1.23269691 -4.03101700 9 -6.67607541 -1.23269691 10 -9.44373551 -6.67607541 11 -9.68279358 -9.44373551 12 -2.27625855 -9.68279358 13 -4.81895085 -2.27625855 14 0.96126288 -4.81895085 15 4.89081962 0.96126288 16 -0.51753097 4.89081962 17 14.78496129 -0.51753097 18 5.32013791 14.78496129 19 4.89599870 5.32013791 20 19.25037914 4.89599870 21 8.27923992 19.25037914 22 -4.73391074 8.27923992 23 -0.03017736 -4.73391074 24 7.37976158 -0.03017736 25 3.83552420 7.37976158 26 0.56483088 3.83552420 27 6.78406020 0.56483088 28 12.03909482 6.78406020 29 4.01667398 12.03909482 30 13.64190337 4.01667398 31 14.75505522 13.64190337 32 -0.92632768 14.75505522 33 -6.77577818 -0.92632768 34 6.41491447 -6.77577818 35 -2.88417200 6.41491447 36 3.14186414 -2.88417200 37 3.31981121 3.14186414 38 7.21840716 3.31981121 39 -3.38903340 7.21840716 40 9.14458753 -3.38903340 41 -7.85337090 9.14458753 42 -9.69778948 -7.85337090 43 0.56029188 -9.69778948 44 -17.09135455 0.56029188 45 5.17261367 -17.09135455 46 7.76273179 5.17261367 47 12.59714294 7.76273179 48 -3.53734577 12.59714294 49 5.89537885 -3.53734577 50 1.73120072 5.89537885 51 1.12043653 1.73120072 52 -12.10548937 1.12043653 53 -16.79696736 -12.10548937 54 -9.21557447 -16.79696736 55 -16.18032879 -9.21557447 56 NA -16.18032879 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -8.23176341 -4.70802139 [2,] -10.47570164 -8.23176341 [3,] -9.40628295 -10.47570164 [4,] -8.56066201 -9.40628295 [5,] 5.84870300 -8.56066201 [6,] -0.04867734 5.84870300 [7,] -4.03101700 -0.04867734 [8,] -1.23269691 -4.03101700 [9,] -6.67607541 -1.23269691 [10,] -9.44373551 -6.67607541 [11,] -9.68279358 -9.44373551 [12,] -2.27625855 -9.68279358 [13,] -4.81895085 -2.27625855 [14,] 0.96126288 -4.81895085 [15,] 4.89081962 0.96126288 [16,] -0.51753097 4.89081962 [17,] 14.78496129 -0.51753097 [18,] 5.32013791 14.78496129 [19,] 4.89599870 5.32013791 [20,] 19.25037914 4.89599870 [21,] 8.27923992 19.25037914 [22,] -4.73391074 8.27923992 [23,] -0.03017736 -4.73391074 [24,] 7.37976158 -0.03017736 [25,] 3.83552420 7.37976158 [26,] 0.56483088 3.83552420 [27,] 6.78406020 0.56483088 [28,] 12.03909482 6.78406020 [29,] 4.01667398 12.03909482 [30,] 13.64190337 4.01667398 [31,] 14.75505522 13.64190337 [32,] -0.92632768 14.75505522 [33,] -6.77577818 -0.92632768 [34,] 6.41491447 -6.77577818 [35,] -2.88417200 6.41491447 [36,] 3.14186414 -2.88417200 [37,] 3.31981121 3.14186414 [38,] 7.21840716 3.31981121 [39,] -3.38903340 7.21840716 [40,] 9.14458753 -3.38903340 [41,] -7.85337090 9.14458753 [42,] -9.69778948 -7.85337090 [43,] 0.56029188 -9.69778948 [44,] -17.09135455 0.56029188 [45,] 5.17261367 -17.09135455 [46,] 7.76273179 5.17261367 [47,] 12.59714294 7.76273179 [48,] -3.53734577 12.59714294 [49,] 5.89537885 -3.53734577 [50,] 1.73120072 5.89537885 [51,] 1.12043653 1.73120072 [52,] -12.10548937 1.12043653 [53,] -16.79696736 -12.10548937 [54,] -9.21557447 -16.79696736 [55,] -16.18032879 -9.21557447 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -8.23176341 -4.70802139 2 -10.47570164 -8.23176341 3 -9.40628295 -10.47570164 4 -8.56066201 -9.40628295 5 5.84870300 -8.56066201 6 -0.04867734 5.84870300 7 -4.03101700 -0.04867734 8 -1.23269691 -4.03101700 9 -6.67607541 -1.23269691 10 -9.44373551 -6.67607541 11 -9.68279358 -9.44373551 12 -2.27625855 -9.68279358 13 -4.81895085 -2.27625855 14 0.96126288 -4.81895085 15 4.89081962 0.96126288 16 -0.51753097 4.89081962 17 14.78496129 -0.51753097 18 5.32013791 14.78496129 19 4.89599870 5.32013791 20 19.25037914 4.89599870 21 8.27923992 19.25037914 22 -4.73391074 8.27923992 23 -0.03017736 -4.73391074 24 7.37976158 -0.03017736 25 3.83552420 7.37976158 26 0.56483088 3.83552420 27 6.78406020 0.56483088 28 12.03909482 6.78406020 29 4.01667398 12.03909482 30 13.64190337 4.01667398 31 14.75505522 13.64190337 32 -0.92632768 14.75505522 33 -6.77577818 -0.92632768 34 6.41491447 -6.77577818 35 -2.88417200 6.41491447 36 3.14186414 -2.88417200 37 3.31981121 3.14186414 38 7.21840716 3.31981121 39 -3.38903340 7.21840716 40 9.14458753 -3.38903340 41 -7.85337090 9.14458753 42 -9.69778948 -7.85337090 43 0.56029188 -9.69778948 44 -17.09135455 0.56029188 45 5.17261367 -17.09135455 46 7.76273179 5.17261367 47 12.59714294 7.76273179 48 -3.53734577 12.59714294 49 5.89537885 -3.53734577 50 1.73120072 5.89537885 51 1.12043653 1.73120072 52 -12.10548937 1.12043653 53 -16.79696736 -12.10548937 54 -9.21557447 -16.79696736 55 -16.18032879 -9.21557447 > 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/7ly4d1258730546.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/8s94o1258730546.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/9og1o1258730546.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/10fipx1258730546.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/11ukip1258730546.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/12nxg51258730546.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/138t1m1258730546.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/14qc2o1258730546.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/15dw8d1258730546.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/165y6b1258730546.tab") + } > > system("convert tmp/1znvo1258730546.ps tmp/1znvo1258730546.png") > system("convert tmp/2ad2n1258730546.ps tmp/2ad2n1258730546.png") > system("convert tmp/3lc261258730546.ps tmp/3lc261258730546.png") > system("convert tmp/44q2m1258730546.ps tmp/44q2m1258730546.png") > system("convert tmp/5avg21258730546.ps tmp/5avg21258730546.png") > system("convert tmp/62r9i1258730546.ps tmp/62r9i1258730546.png") > system("convert tmp/7ly4d1258730546.ps tmp/7ly4d1258730546.png") > system("convert tmp/8s94o1258730546.ps tmp/8s94o1258730546.png") > system("convert tmp/9og1o1258730546.ps tmp/9og1o1258730546.png") > system("convert tmp/10fipx1258730546.ps tmp/10fipx1258730546.png") > > > proc.time() user system elapsed 2.382 1.586 2.784