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(286602 + ,326011 + ,277915 + ,276687 + ,283042 + ,286602 + ,283042 + ,328282 + ,286602 + ,277915 + ,276687 + ,283042 + ,276687 + ,317480 + ,283042 + ,286602 + ,277915 + ,276687 + ,277915 + ,317539 + ,276687 + ,283042 + ,286602 + ,277915 + ,277128 + ,313737 + ,277915 + ,276687 + ,283042 + ,286602 + ,277103 + ,312276 + ,277128 + ,277915 + ,276687 + ,283042 + ,275037 + ,309391 + ,277103 + ,277128 + ,277915 + ,276687 + ,270150 + ,302950 + ,275037 + ,277103 + ,277128 + ,277915 + ,267140 + ,300316 + ,270150 + ,275037 + ,277103 + ,277128 + ,264993 + ,304035 + ,267140 + ,270150 + ,275037 + ,277103 + ,287259 + ,333476 + ,264993 + ,267140 + ,270150 + ,275037 + ,291186 + ,337698 + ,287259 + ,264993 + ,267140 + ,270150 + ,292300 + ,335932 + ,291186 + ,287259 + ,264993 + ,267140 + ,288186 + ,323931 + ,292300 + ,291186 + ,287259 + ,264993 + ,281477 + ,313927 + ,288186 + ,292300 + ,291186 + ,287259 + ,282656 + ,314485 + ,281477 + ,288186 + ,292300 + ,291186 + ,280190 + ,313218 + ,282656 + ,281477 + ,288186 + ,292300 + ,280408 + ,309664 + ,280190 + ,282656 + ,281477 + ,288186 + ,276836 + ,302963 + ,280408 + ,280190 + ,282656 + ,281477 + ,275216 + ,298989 + ,276836 + ,280408 + ,280190 + ,282656 + ,274352 + ,298423 + ,275216 + ,276836 + ,280408 + ,280190 + ,271311 + ,301631 + ,274352 + ,275216 + ,276836 + ,280408 + ,289802 + ,329765 + ,271311 + ,274352 + ,275216 + ,276836 + ,290726 + ,335083 + ,289802 + ,271311 + ,274352 + ,275216 + ,292300 + ,327616 + ,290726 + ,289802 + ,271311 + ,274352 + ,278506 + ,309119 + ,292300 + ,290726 + ,289802 + ,271311 + ,269826 + ,295916 + ,278506 + ,292300 + ,290726 + ,289802 + ,265861 + ,291413 + ,269826 + ,278506 + ,292300 + ,290726 + ,269034 + ,291542 + ,265861 + ,269826 + ,278506 + ,292300 + ,264176 + ,284678 + ,269034 + ,265861 + ,269826 + ,278506 + ,255198 + ,276475 + ,264176 + ,269034 + ,265861 + ,269826 + ,253353 + ,272566 + ,255198 + ,264176 + ,269034 + ,265861 + ,246057 + ,264981 + ,253353 + ,255198 + ,264176 + ,269034 + ,235372 + ,263290 + ,246057 + ,253353 + ,255198 + ,264176 + ,258556 + ,296806 + ,235372 + ,246057 + ,253353 + ,255198 + ,260993 + ,303598 + ,258556 + ,235372 + ,246057 + ,253353 + ,254663 + ,286994 + ,260993 + ,258556 + ,235372 + ,246057 + ,250643 + ,276427 + ,254663 + ,260993 + ,258556 + ,235372 + ,243422 + ,266424 + ,250643 + ,254663 + ,260993 + ,258556 + ,247105 + ,267153 + ,243422 + ,250643 + ,254663 + ,260993 + ,248541 + ,268381 + ,247105 + ,243422 + ,250643 + ,254663 + ,245039 + ,262522 + ,248541 + ,247105 + ,243422 + ,250643 + ,237080 + ,255542 + ,245039 + ,248541 + ,247105 + ,243422 + ,237085 + ,253158 + ,237080 + ,245039 + ,248541 + ,247105 + ,225554 + ,243803 + ,237085 + ,237080 + ,245039 + ,248541 + ,226839 + ,250741 + ,225554 + ,237085 + ,237080 + ,245039 + ,247934 + ,280445 + ,226839 + ,225554 + ,237085 + ,237080 + ,248333 + ,285257 + ,247934 + ,226839 + ,225554 + ,237085 + ,246969 + ,270976 + ,248333 + ,247934 + ,226839 + ,225554 + ,245098 + ,261076 + ,246969 + ,248333 + ,247934 + ,226839 + ,246263 + ,255603 + ,245098 + ,246969 + ,248333 + ,247934 + ,255765 + ,260376 + ,246263 + ,245098 + ,246969 + ,248333 + ,264319 + ,263903 + ,255765 + ,246263 + ,245098 + ,246969 + ,268347 + ,264291 + ,264319 + ,255765 + ,246263 + ,245098 + ,273046 + ,263276 + ,268347 + ,264319 + ,255765 + ,246263 + ,273963 + ,262572 + ,273046 + ,268347 + ,264319 + ,255765 + ,267430 + ,256167 + ,273963 + ,273046 + ,268347 + ,264319 + ,271993 + ,264221 + ,267430 + ,273963 + ,273046 + ,268347 + ,292710 + ,293860 + ,271993 + ,267430 + ,273963 + ,273046 + ,295881 + ,300713 + ,292710 + ,271993 + ,267430 + ,273963 + ,293299 + ,287224 + ,295881 + ,292710 + ,271993 + ,267430) + ,dim=c(6 + ,61) + ,dimnames=list(c('Y' + ,'X' + ,'Y1' + ,'Y2' + ,'Y3' + ,'Y4') + ,1:61)) > y <- array(NA,dim=c(6,61),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),1:61)) > 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 1 286602 326011 277915 276687 283042 286602 1 0 0 0 0 0 0 0 0 0 0 2 283042 328282 286602 277915 276687 283042 0 1 0 0 0 0 0 0 0 0 0 3 276687 317480 283042 286602 277915 276687 0 0 1 0 0 0 0 0 0 0 0 4 277915 317539 276687 283042 286602 277915 0 0 0 1 0 0 0 0 0 0 0 5 277128 313737 277915 276687 283042 286602 0 0 0 0 1 0 0 0 0 0 0 6 277103 312276 277128 277915 276687 283042 0 0 0 0 0 1 0 0 0 0 0 7 275037 309391 277103 277128 277915 276687 0 0 0 0 0 0 1 0 0 0 0 8 270150 302950 275037 277103 277128 277915 0 0 0 0 0 0 0 1 0 0 0 9 267140 300316 270150 275037 277103 277128 0 0 0 0 0 0 0 0 1 0 0 10 264993 304035 267140 270150 275037 277103 0 0 0 0 0 0 0 0 0 1 0 11 287259 333476 264993 267140 270150 275037 0 0 0 0 0 0 0 0 0 0 1 12 291186 337698 287259 264993 267140 270150 0 0 0 0 0 0 0 0 0 0 0 13 292300 335932 291186 287259 264993 267140 1 0 0 0 0 0 0 0 0 0 0 14 288186 323931 292300 291186 287259 264993 0 1 0 0 0 0 0 0 0 0 0 15 281477 313927 288186 292300 291186 287259 0 0 1 0 0 0 0 0 0 0 0 16 282656 314485 281477 288186 292300 291186 0 0 0 1 0 0 0 0 0 0 0 17 280190 313218 282656 281477 288186 292300 0 0 0 0 1 0 0 0 0 0 0 18 280408 309664 280190 282656 281477 288186 0 0 0 0 0 1 0 0 0 0 0 19 276836 302963 280408 280190 282656 281477 0 0 0 0 0 0 1 0 0 0 0 20 275216 298989 276836 280408 280190 282656 0 0 0 0 0 0 0 1 0 0 0 21 274352 298423 275216 276836 280408 280190 0 0 0 0 0 0 0 0 1 0 0 22 271311 301631 274352 275216 276836 280408 0 0 0 0 0 0 0 0 0 1 0 23 289802 329765 271311 274352 275216 276836 0 0 0 0 0 0 0 0 0 0 1 24 290726 335083 289802 271311 274352 275216 0 0 0 0 0 0 0 0 0 0 0 25 292300 327616 290726 289802 271311 274352 1 0 0 0 0 0 0 0 0 0 0 26 278506 309119 292300 290726 289802 271311 0 1 0 0 0 0 0 0 0 0 0 27 269826 295916 278506 292300 290726 289802 0 0 1 0 0 0 0 0 0 0 0 28 265861 291413 269826 278506 292300 290726 0 0 0 1 0 0 0 0 0 0 0 29 269034 291542 265861 269826 278506 292300 0 0 0 0 1 0 0 0 0 0 0 30 264176 284678 269034 265861 269826 278506 0 0 0 0 0 1 0 0 0 0 0 31 255198 276475 264176 269034 265861 269826 0 0 0 0 0 0 1 0 0 0 0 32 253353 272566 255198 264176 269034 265861 0 0 0 0 0 0 0 1 0 0 0 33 246057 264981 253353 255198 264176 269034 0 0 0 0 0 0 0 0 1 0 0 34 235372 263290 246057 253353 255198 264176 0 0 0 0 0 0 0 0 0 1 0 35 258556 296806 235372 246057 253353 255198 0 0 0 0 0 0 0 0 0 0 1 36 260993 303598 258556 235372 246057 253353 0 0 0 0 0 0 0 0 0 0 0 37 254663 286994 260993 258556 235372 246057 1 0 0 0 0 0 0 0 0 0 0 38 250643 276427 254663 260993 258556 235372 0 1 0 0 0 0 0 0 0 0 0 39 243422 266424 250643 254663 260993 258556 0 0 1 0 0 0 0 0 0 0 0 40 247105 267153 243422 250643 254663 260993 0 0 0 1 0 0 0 0 0 0 0 41 248541 268381 247105 243422 250643 254663 0 0 0 0 1 0 0 0 0 0 0 42 245039 262522 248541 247105 243422 250643 0 0 0 0 0 1 0 0 0 0 0 43 237080 255542 245039 248541 247105 243422 0 0 0 0 0 0 1 0 0 0 0 44 237085 253158 237080 245039 248541 247105 0 0 0 0 0 0 0 1 0 0 0 45 225554 243803 237085 237080 245039 248541 0 0 0 0 0 0 0 0 1 0 0 46 226839 250741 225554 237085 237080 245039 0 0 0 0 0 0 0 0 0 1 0 47 247934 280445 226839 225554 237085 237080 0 0 0 0 0 0 0 0 0 0 1 48 248333 285257 247934 226839 225554 237085 0 0 0 0 0 0 0 0 0 0 0 49 246969 270976 248333 247934 226839 225554 1 0 0 0 0 0 0 0 0 0 0 50 245098 261076 246969 248333 247934 226839 0 1 0 0 0 0 0 0 0 0 0 51 246263 255603 245098 246969 248333 247934 0 0 1 0 0 0 0 0 0 0 0 52 255765 260376 246263 245098 246969 248333 0 0 0 1 0 0 0 0 0 0 0 53 264319 263903 255765 246263 245098 246969 0 0 0 0 1 0 0 0 0 0 0 54 268347 264291 264319 255765 246263 245098 0 0 0 0 0 1 0 0 0 0 0 55 273046 263276 268347 264319 255765 246263 0 0 0 0 0 0 1 0 0 0 0 56 273963 262572 273046 268347 264319 255765 0 0 0 0 0 0 0 1 0 0 0 57 267430 256167 273963 273046 268347 264319 0 0 0 0 0 0 0 0 1 0 0 58 271993 264221 267430 273963 273046 268347 0 0 0 0 0 0 0 0 0 1 0 59 292710 293860 271993 267430 273963 273046 0 0 0 0 0 0 0 0 0 0 1 60 295881 300713 292710 271993 267430 273963 0 0 0 0 0 0 0 0 0 0 0 61 293299 287224 295881 292710 271993 267430 1 0 0 0 0 0 0 0 0 0 0 t 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52 53 53 54 54 55 55 56 56 57 57 58 58 59 59 60 60 61 61 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X Y1 Y2 Y3 Y4 -9.472e+04 5.923e-01 8.958e-01 -4.176e-01 2.702e-01 -1.577e-01 M1 M2 M3 M4 M5 M6 1.285e+04 8.052e+03 1.504e+04 1.943e+04 1.811e+04 1.865e+04 M7 M8 M9 M10 M11 t 1.767e+04 2.042e+04 1.757e+04 1.810e+04 2.010e+04 5.201e+02 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -7389.4 -2053.2 -226.4 2380.5 10163.4 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -9.472e+04 3.154e+04 -3.003 0.004436 ** X 5.923e-01 1.673e-01 3.540 0.000977 *** Y1 8.958e-01 1.618e-01 5.537 1.71e-06 *** Y2 -4.176e-01 1.816e-01 -2.300 0.026368 * Y3 2.702e-01 1.524e-01 1.773 0.083382 . Y4 -1.577e-01 1.083e-01 -1.457 0.152496 M1 1.285e+04 4.885e+03 2.631 0.011774 * M2 8.052e+03 5.757e+03 1.399 0.169094 M3 1.504e+04 6.456e+03 2.330 0.024569 * M4 1.943e+04 5.730e+03 3.392 0.001501 ** M5 1.811e+04 5.143e+03 3.521 0.001032 ** M6 1.865e+04 5.874e+03 3.175 0.002770 ** M7 1.767e+04 6.625e+03 2.668 0.010720 * M8 2.042e+04 6.769e+03 3.017 0.004281 ** M9 1.757e+04 7.007e+03 2.508 0.016013 * M10 1.810e+04 6.211e+03 2.914 0.005639 ** M11 2.010e+04 3.930e+03 5.116 6.92e-06 *** t 5.201e+02 1.547e+02 3.362 0.001632 ** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 3686 on 43 degrees of freedom Multiple R-squared: 0.9705, Adjusted R-squared: 0.9588 F-statistic: 83.13 on 17 and 43 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.3029924 0.6059848 0.69700762 [2,] 0.1886025 0.3772050 0.81139751 [3,] 0.1273817 0.2547634 0.87261829 [4,] 0.1454559 0.2909118 0.85454411 [5,] 0.0988623 0.1977246 0.90113770 [6,] 0.5604252 0.8791495 0.43957477 [7,] 0.6840168 0.6319663 0.31598316 [8,] 0.7630174 0.4739651 0.23698256 [9,] 0.8050516 0.3898968 0.19494840 [10,] 0.7171874 0.5656252 0.28281258 [11,] 0.6351433 0.7297134 0.36485668 [12,] 0.5943517 0.8112965 0.40564826 [13,] 0.6706982 0.6586036 0.32930181 [14,] 0.9089812 0.1820376 0.09101882 [15,] 0.9146957 0.1706087 0.08530435 [16,] 0.9197917 0.1604167 0.08020835 [17,] 0.8702267 0.2595466 0.12977329 [18,] 0.8165997 0.3668005 0.18340027 [19,] 0.6859553 0.6280894 0.31404471 [20,] 0.6757538 0.6484924 0.32424622 > postscript(file="/var/www/html/rcomp/tmp/13v2o1259608580.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/2mlnq1259608580.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/39n2h1259608580.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/4dnjs1259608580.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/5fdzi1259608580.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 = 61 Frequency = 1 1 2 3 4 5 6 10163.357054 3424.747501 1439.566378 -226.373383 623.091249 2774.297510 7 8 9 10 11 12 1233.591884 -856.610572 3418.872706 -772.043610 3194.414582 3404.566093 13 14 15 16 17 18 -1922.009189 -359.555114 -2053.202878 -1506.447686 -4985.999604 139.753192 19 20 21 22 23 24 -1607.978042 3.903232 1314.717125 -3580.478715 -2038.020438 -2536.414174 25 26 27 28 29 30 -2332.521671 -7389.448753 -80.153409 -4553.919890 3251.081230 -2931.731863 31 32 33 34 35 36 -1215.363304 521.398545 -237.511345 -3547.264884 2870.049119 -2681.977140 37 38 39 40 41 42 -3314.865645 1943.724440 -2907.776261 2315.645884 -2395.815125 -1921.304401 43 44 45 46 47 48 -3686.393450 325.792654 -5491.609529 2562.051463 -3681.493002 -1793.367393 49 50 51 52 53 54 -1784.536144 2380.531926 3601.566169 3971.095076 3507.642250 1938.985562 55 56 57 58 59 60 5276.142913 5.516142 995.531043 5337.735746 -344.950262 3607.192615 61 -809.424406 > postscript(file="/var/www/html/rcomp/tmp/6fs8d1259608580.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 = 61 Frequency = 1 lag(myerror, k = 1) myerror 0 10163.357054 NA 1 3424.747501 10163.357054 2 1439.566378 3424.747501 3 -226.373383 1439.566378 4 623.091249 -226.373383 5 2774.297510 623.091249 6 1233.591884 2774.297510 7 -856.610572 1233.591884 8 3418.872706 -856.610572 9 -772.043610 3418.872706 10 3194.414582 -772.043610 11 3404.566093 3194.414582 12 -1922.009189 3404.566093 13 -359.555114 -1922.009189 14 -2053.202878 -359.555114 15 -1506.447686 -2053.202878 16 -4985.999604 -1506.447686 17 139.753192 -4985.999604 18 -1607.978042 139.753192 19 3.903232 -1607.978042 20 1314.717125 3.903232 21 -3580.478715 1314.717125 22 -2038.020438 -3580.478715 23 -2536.414174 -2038.020438 24 -2332.521671 -2536.414174 25 -7389.448753 -2332.521671 26 -80.153409 -7389.448753 27 -4553.919890 -80.153409 28 3251.081230 -4553.919890 29 -2931.731863 3251.081230 30 -1215.363304 -2931.731863 31 521.398545 -1215.363304 32 -237.511345 521.398545 33 -3547.264884 -237.511345 34 2870.049119 -3547.264884 35 -2681.977140 2870.049119 36 -3314.865645 -2681.977140 37 1943.724440 -3314.865645 38 -2907.776261 1943.724440 39 2315.645884 -2907.776261 40 -2395.815125 2315.645884 41 -1921.304401 -2395.815125 42 -3686.393450 -1921.304401 43 325.792654 -3686.393450 44 -5491.609529 325.792654 45 2562.051463 -5491.609529 46 -3681.493002 2562.051463 47 -1793.367393 -3681.493002 48 -1784.536144 -1793.367393 49 2380.531926 -1784.536144 50 3601.566169 2380.531926 51 3971.095076 3601.566169 52 3507.642250 3971.095076 53 1938.985562 3507.642250 54 5276.142913 1938.985562 55 5.516142 5276.142913 56 995.531043 5.516142 57 5337.735746 995.531043 58 -344.950262 5337.735746 59 3607.192615 -344.950262 60 -809.424406 3607.192615 61 NA -809.424406 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 3424.747501 10163.357054 [2,] 1439.566378 3424.747501 [3,] -226.373383 1439.566378 [4,] 623.091249 -226.373383 [5,] 2774.297510 623.091249 [6,] 1233.591884 2774.297510 [7,] -856.610572 1233.591884 [8,] 3418.872706 -856.610572 [9,] -772.043610 3418.872706 [10,] 3194.414582 -772.043610 [11,] 3404.566093 3194.414582 [12,] -1922.009189 3404.566093 [13,] -359.555114 -1922.009189 [14,] -2053.202878 -359.555114 [15,] -1506.447686 -2053.202878 [16,] -4985.999604 -1506.447686 [17,] 139.753192 -4985.999604 [18,] -1607.978042 139.753192 [19,] 3.903232 -1607.978042 [20,] 1314.717125 3.903232 [21,] -3580.478715 1314.717125 [22,] -2038.020438 -3580.478715 [23,] -2536.414174 -2038.020438 [24,] -2332.521671 -2536.414174 [25,] -7389.448753 -2332.521671 [26,] -80.153409 -7389.448753 [27,] -4553.919890 -80.153409 [28,] 3251.081230 -4553.919890 [29,] -2931.731863 3251.081230 [30,] -1215.363304 -2931.731863 [31,] 521.398545 -1215.363304 [32,] -237.511345 521.398545 [33,] -3547.264884 -237.511345 [34,] 2870.049119 -3547.264884 [35,] -2681.977140 2870.049119 [36,] -3314.865645 -2681.977140 [37,] 1943.724440 -3314.865645 [38,] -2907.776261 1943.724440 [39,] 2315.645884 -2907.776261 [40,] -2395.815125 2315.645884 [41,] -1921.304401 -2395.815125 [42,] -3686.393450 -1921.304401 [43,] 325.792654 -3686.393450 [44,] -5491.609529 325.792654 [45,] 2562.051463 -5491.609529 [46,] -3681.493002 2562.051463 [47,] -1793.367393 -3681.493002 [48,] -1784.536144 -1793.367393 [49,] 2380.531926 -1784.536144 [50,] 3601.566169 2380.531926 [51,] 3971.095076 3601.566169 [52,] 3507.642250 3971.095076 [53,] 1938.985562 3507.642250 [54,] 5276.142913 1938.985562 [55,] 5.516142 5276.142913 [56,] 995.531043 5.516142 [57,] 5337.735746 995.531043 [58,] -344.950262 5337.735746 [59,] 3607.192615 -344.950262 [60,] -809.424406 3607.192615 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 3424.747501 10163.357054 2 1439.566378 3424.747501 3 -226.373383 1439.566378 4 623.091249 -226.373383 5 2774.297510 623.091249 6 1233.591884 2774.297510 7 -856.610572 1233.591884 8 3418.872706 -856.610572 9 -772.043610 3418.872706 10 3194.414582 -772.043610 11 3404.566093 3194.414582 12 -1922.009189 3404.566093 13 -359.555114 -1922.009189 14 -2053.202878 -359.555114 15 -1506.447686 -2053.202878 16 -4985.999604 -1506.447686 17 139.753192 -4985.999604 18 -1607.978042 139.753192 19 3.903232 -1607.978042 20 1314.717125 3.903232 21 -3580.478715 1314.717125 22 -2038.020438 -3580.478715 23 -2536.414174 -2038.020438 24 -2332.521671 -2536.414174 25 -7389.448753 -2332.521671 26 -80.153409 -7389.448753 27 -4553.919890 -80.153409 28 3251.081230 -4553.919890 29 -2931.731863 3251.081230 30 -1215.363304 -2931.731863 31 521.398545 -1215.363304 32 -237.511345 521.398545 33 -3547.264884 -237.511345 34 2870.049119 -3547.264884 35 -2681.977140 2870.049119 36 -3314.865645 -2681.977140 37 1943.724440 -3314.865645 38 -2907.776261 1943.724440 39 2315.645884 -2907.776261 40 -2395.815125 2315.645884 41 -1921.304401 -2395.815125 42 -3686.393450 -1921.304401 43 325.792654 -3686.393450 44 -5491.609529 325.792654 45 2562.051463 -5491.609529 46 -3681.493002 2562.051463 47 -1793.367393 -3681.493002 48 -1784.536144 -1793.367393 49 2380.531926 -1784.536144 50 3601.566169 2380.531926 51 3971.095076 3601.566169 52 3507.642250 3971.095076 53 1938.985562 3507.642250 54 5276.142913 1938.985562 55 5.516142 5276.142913 56 995.531043 5.516142 57 5337.735746 995.531043 58 -344.950262 5337.735746 59 3607.192615 -344.950262 60 -809.424406 3607.192615 > 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/73giw1259608580.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/8ztpc1259608580.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/9quke1259608580.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/10dm551259608580.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/11p7d61259608580.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/12lly11259608580.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/13qrhd1259608580.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/14kc891259608580.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/15yud91259608580.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/161h2d1259608581.tab") + } > > system("convert tmp/13v2o1259608580.ps tmp/13v2o1259608580.png") > system("convert tmp/2mlnq1259608580.ps tmp/2mlnq1259608580.png") > system("convert tmp/39n2h1259608580.ps tmp/39n2h1259608580.png") > system("convert tmp/4dnjs1259608580.ps tmp/4dnjs1259608580.png") > system("convert tmp/5fdzi1259608580.ps tmp/5fdzi1259608580.png") > system("convert tmp/6fs8d1259608580.ps tmp/6fs8d1259608580.png") > system("convert tmp/73giw1259608580.ps tmp/73giw1259608580.png") > system("convert tmp/8ztpc1259608580.ps tmp/8ztpc1259608580.png") > system("convert tmp/9quke1259608580.ps tmp/9quke1259608580.png") > system("convert tmp/10dm551259608580.ps tmp/10dm551259608580.png") > > > proc.time() user system elapsed 2.458 1.649 3.628