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(254844 + ,281818 + ,258863 + ,264777 + ,267366 + ,267413 + ,254868 + ,287854 + ,254844 + ,258863 + ,264777 + ,267366 + ,277267 + ,316263 + ,254868 + ,254844 + ,258863 + ,264777 + ,285351 + ,325412 + ,277267 + ,254868 + ,254844 + ,258863 + ,286602 + ,326011 + ,285351 + ,277267 + ,254868 + ,254844 + ,283042 + ,328282 + ,286602 + ,285351 + ,277267 + ,254868 + ,276687 + ,317480 + ,283042 + ,286602 + ,285351 + ,277267 + ,277915 + ,317539 + ,276687 + ,283042 + ,286602 + ,285351 + ,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) + ,dim=c(6 + ,63) + ,dimnames=list(c('Y' + ,'X' + ,'Y1' + ,'Y2' + ,'Y3' + ,'Y4') + ,1:63)) > y <- array(NA,dim=c(6,63),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),1:63)) > 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 254844 281818 258863 264777 267366 267413 1 0 0 0 0 0 0 0 0 0 0 2 254868 287854 254844 258863 264777 267366 0 1 0 0 0 0 0 0 0 0 0 3 277267 316263 254868 254844 258863 264777 0 0 1 0 0 0 0 0 0 0 0 4 285351 325412 277267 254868 254844 258863 0 0 0 1 0 0 0 0 0 0 0 5 286602 326011 285351 277267 254868 254844 0 0 0 0 1 0 0 0 0 0 0 6 283042 328282 286602 285351 277267 254868 0 0 0 0 0 1 0 0 0 0 0 7 276687 317480 283042 286602 285351 277267 0 0 0 0 0 0 1 0 0 0 0 8 277915 317539 276687 283042 286602 285351 0 0 0 0 0 0 0 1 0 0 0 9 277128 313737 277915 276687 283042 286602 0 0 0 0 0 0 0 0 1 0 0 10 277103 312276 277128 277915 276687 283042 0 0 0 0 0 0 0 0 0 1 0 11 275037 309391 277103 277128 277915 276687 0 0 0 0 0 0 0 0 0 0 1 12 270150 302950 275037 277103 277128 277915 0 0 0 0 0 0 0 0 0 0 0 13 267140 300316 270150 275037 277103 277128 1 0 0 0 0 0 0 0 0 0 0 14 264993 304035 267140 270150 275037 277103 0 1 0 0 0 0 0 0 0 0 0 15 287259 333476 264993 267140 270150 275037 0 0 1 0 0 0 0 0 0 0 0 16 291186 337698 287259 264993 267140 270150 0 0 0 1 0 0 0 0 0 0 0 17 292300 335932 291186 287259 264993 267140 0 0 0 0 1 0 0 0 0 0 0 18 288186 323931 292300 291186 287259 264993 0 0 0 0 0 1 0 0 0 0 0 19 281477 313927 288186 292300 291186 287259 0 0 0 0 0 0 1 0 0 0 0 20 282656 314485 281477 288186 292300 291186 0 0 0 0 0 0 0 1 0 0 0 21 280190 313218 282656 281477 288186 292300 0 0 0 0 0 0 0 0 1 0 0 22 280408 309664 280190 282656 281477 288186 0 0 0 0 0 0 0 0 0 1 0 23 276836 302963 280408 280190 282656 281477 0 0 0 0 0 0 0 0 0 0 1 24 275216 298989 276836 280408 280190 282656 0 0 0 0 0 0 0 0 0 0 0 25 274352 298423 275216 276836 280408 280190 1 0 0 0 0 0 0 0 0 0 0 26 271311 301631 274352 275216 276836 280408 0 1 0 0 0 0 0 0 0 0 0 27 289802 329765 271311 274352 275216 276836 0 0 1 0 0 0 0 0 0 0 0 28 290726 335083 289802 271311 274352 275216 0 0 0 1 0 0 0 0 0 0 0 29 292300 327616 290726 289802 271311 274352 0 0 0 0 1 0 0 0 0 0 0 30 278506 309119 292300 290726 289802 271311 0 0 0 0 0 1 0 0 0 0 0 31 269826 295916 278506 292300 290726 289802 0 0 0 0 0 0 1 0 0 0 0 32 265861 291413 269826 278506 292300 290726 0 0 0 0 0 0 0 1 0 0 0 33 269034 291542 265861 269826 278506 292300 0 0 0 0 0 0 0 0 1 0 0 34 264176 284678 269034 265861 269826 278506 0 0 0 0 0 0 0 0 0 1 0 35 255198 276475 264176 269034 265861 269826 0 0 0 0 0 0 0 0 0 0 1 36 253353 272566 255198 264176 269034 265861 0 0 0 0 0 0 0 0 0 0 0 37 246057 264981 253353 255198 264176 269034 1 0 0 0 0 0 0 0 0 0 0 38 235372 263290 246057 253353 255198 264176 0 1 0 0 0 0 0 0 0 0 0 39 258556 296806 235372 246057 253353 255198 0 0 1 0 0 0 0 0 0 0 0 40 260993 303598 258556 235372 246057 253353 0 0 0 1 0 0 0 0 0 0 0 41 254663 286994 260993 258556 235372 246057 0 0 0 0 1 0 0 0 0 0 0 42 250643 276427 254663 260993 258556 235372 0 0 0 0 0 1 0 0 0 0 0 43 243422 266424 250643 254663 260993 258556 0 0 0 0 0 0 1 0 0 0 0 44 247105 267153 243422 250643 254663 260993 0 0 0 0 0 0 0 1 0 0 0 45 248541 268381 247105 243422 250643 254663 0 0 0 0 0 0 0 0 1 0 0 46 245039 262522 248541 247105 243422 250643 0 0 0 0 0 0 0 0 0 1 0 47 237080 255542 245039 248541 247105 243422 0 0 0 0 0 0 0 0 0 0 1 48 237085 253158 237080 245039 248541 247105 0 0 0 0 0 0 0 0 0 0 0 49 225554 243803 237085 237080 245039 248541 1 0 0 0 0 0 0 0 0 0 0 50 226839 250741 225554 237085 237080 245039 0 1 0 0 0 0 0 0 0 0 0 51 247934 280445 226839 225554 237085 237080 0 0 1 0 0 0 0 0 0 0 0 52 248333 285257 247934 226839 225554 237085 0 0 0 1 0 0 0 0 0 0 0 53 246969 270976 248333 247934 226839 225554 0 0 0 0 1 0 0 0 0 0 0 54 245098 261076 246969 248333 247934 226839 0 0 0 0 0 1 0 0 0 0 0 55 246263 255603 245098 246969 248333 247934 0 0 0 0 0 0 1 0 0 0 0 56 255765 260376 246263 245098 246969 248333 0 0 0 0 0 0 0 1 0 0 0 57 264319 263903 255765 246263 245098 246969 0 0 0 0 0 0 0 0 1 0 0 58 268347 264291 264319 255765 246263 245098 0 0 0 0 0 0 0 0 0 1 0 59 273046 263276 268347 264319 255765 246263 0 0 0 0 0 0 0 0 0 0 1 60 273963 262572 273046 268347 264319 255765 0 0 0 0 0 0 0 0 0 0 0 61 267430 256167 273963 273046 268347 264319 1 0 0 0 0 0 0 0 0 0 0 62 271993 264221 267430 273963 273046 268347 0 1 0 0 0 0 0 0 0 0 0 63 292710 293860 271993 267430 273963 273046 0 0 1 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 62 62 63 63 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X Y1 Y2 Y3 Y4 7.219e+03 1.685e-01 9.799e-01 1.370e-01 6.995e-02 -4.070e-01 M1 M2 M3 M4 M5 M6 -1.804e+03 1.409e+03 1.883e+04 -8.228e+02 -8.321e+03 -1.461e+04 M7 M8 M9 M10 M11 t -4.584e+03 5.149e+03 5.625e+03 1.211e+03 -3.453e+03 7.237e+01 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -6544 -2441 677 1966 6654 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 7.219e+03 1.355e+04 0.533 0.596779 X 1.686e-01 9.643e-02 1.748 0.087291 . Y1 9.799e-01 1.389e-01 7.052 8.53e-09 *** Y2 1.371e-01 2.027e-01 0.676 0.502368 Y3 6.995e-02 2.084e-01 0.336 0.738733 Y4 -4.070e-01 1.430e-01 -2.847 0.006629 ** M1 -1.804e+03 2.223e+03 -0.812 0.421293 M2 1.409e+03 2.208e+03 0.638 0.526565 M3 1.883e+04 4.107e+03 4.585 3.61e-05 *** M4 -8.228e+02 5.548e+03 -0.148 0.882763 M5 -8.321e+03 4.502e+03 -1.848 0.071177 . M6 -1.461e+04 3.618e+03 -4.037 0.000208 *** M7 -4.584e+03 2.233e+03 -2.052 0.045978 * M8 5.149e+03 2.385e+03 2.159 0.036200 * M9 5.625e+03 2.819e+03 1.995 0.052067 . M10 1.211e+03 2.714e+03 0.446 0.657483 M11 -3.453e+03 2.233e+03 -1.546 0.129022 t 7.237e+01 6.862e+01 1.055 0.297214 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 3447 on 45 degrees of freedom Multiple R-squared: 0.9718, Adjusted R-squared: 0.9611 F-statistic: 91.09 on 17 and 45 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.319239656 0.63847931 0.68076034 [2,] 0.169675827 0.33935165 0.83032417 [3,] 0.089978185 0.17995637 0.91002182 [4,] 0.078036129 0.15607226 0.92196387 [5,] 0.051596261 0.10319252 0.94840374 [6,] 0.024012620 0.04802524 0.97598738 [7,] 0.011043988 0.02208798 0.98895601 [8,] 0.013900603 0.02780121 0.98609940 [9,] 0.007315354 0.01463071 0.99268465 [10,] 0.556400584 0.88719883 0.44359942 [11,] 0.729671652 0.54065670 0.27032835 [12,] 0.824730249 0.35053950 0.17526975 [13,] 0.746839168 0.50632166 0.25316083 [14,] 0.744707249 0.51058550 0.25529275 [15,] 0.774218278 0.45156344 0.22578172 [16,] 0.762960052 0.47407990 0.23703995 [17,] 0.822161892 0.35567622 0.17783811 [18,] 0.988037699 0.02392460 0.01196230 [19,] 0.989658289 0.02068342 0.01034171 [20,] 0.977987682 0.04402464 0.02201232 [21,] 0.941904380 0.11619124 0.05809562 [22,] 0.874895047 0.25020991 0.12510495 > postscript(file="/var/www/html/rcomp/tmp/1s39m1259607208.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/26w2l1259607208.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/3g5621259607208.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/4sok91259607208.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/5e54r1259607208.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 = 63 Frequency = 1 1 2 3 4 5 6 7 2048.2858 2680.0724 2683.1066 4729.8451 676.9812 -941.3230 -3705.1448 8 9 10 11 12 13 14 -2374.7091 -2643.8100 1517.7230 1990.0677 -2754.0450 1164.8515 -1140.9054 15 16 17 18 19 20 21 685.2247 180.6430 1043.4604 1106.3550 -1347.6899 -1409.8127 -3705.6583 22 23 24 25 26 27 28 2502.8590 1963.7294 1610.6989 3631.8629 -1828.0623 -3816.1824 -2507.4480 29 30 31 32 33 34 35 4172.0927 -4489.0994 -279.1436 -2628.6567 6654.1173 -277.7440 -2211.0332 36 37 38 39 40 41 42 704.8434 1088.4428 -6544.0962 1440.8696 821.5561 -3071.6174 802.9009 43 44 45 46 47 48 49 -757.4066 2058.7621 -2175.2115 -3390.7481 -5543.0152 1015.6224 -5291.6480 50 51 52 53 54 55 56 1968.2300 -2356.6704 -3224.5962 -2820.9169 3521.1666 6089.3849 4354.4164 57 58 59 60 61 62 63 1870.5625 -352.0899 3800.2513 -577.1197 -2641.7950 4864.7615 1363.6520 > postscript(file="/var/www/html/rcomp/tmp/6gf0a1259607208.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 = 63 Frequency = 1 lag(myerror, k = 1) myerror 0 2048.2858 NA 1 2680.0724 2048.2858 2 2683.1066 2680.0724 3 4729.8451 2683.1066 4 676.9812 4729.8451 5 -941.3230 676.9812 6 -3705.1448 -941.3230 7 -2374.7091 -3705.1448 8 -2643.8100 -2374.7091 9 1517.7230 -2643.8100 10 1990.0677 1517.7230 11 -2754.0450 1990.0677 12 1164.8515 -2754.0450 13 -1140.9054 1164.8515 14 685.2247 -1140.9054 15 180.6430 685.2247 16 1043.4604 180.6430 17 1106.3550 1043.4604 18 -1347.6899 1106.3550 19 -1409.8127 -1347.6899 20 -3705.6583 -1409.8127 21 2502.8590 -3705.6583 22 1963.7294 2502.8590 23 1610.6989 1963.7294 24 3631.8629 1610.6989 25 -1828.0623 3631.8629 26 -3816.1824 -1828.0623 27 -2507.4480 -3816.1824 28 4172.0927 -2507.4480 29 -4489.0994 4172.0927 30 -279.1436 -4489.0994 31 -2628.6567 -279.1436 32 6654.1173 -2628.6567 33 -277.7440 6654.1173 34 -2211.0332 -277.7440 35 704.8434 -2211.0332 36 1088.4428 704.8434 37 -6544.0962 1088.4428 38 1440.8696 -6544.0962 39 821.5561 1440.8696 40 -3071.6174 821.5561 41 802.9009 -3071.6174 42 -757.4066 802.9009 43 2058.7621 -757.4066 44 -2175.2115 2058.7621 45 -3390.7481 -2175.2115 46 -5543.0152 -3390.7481 47 1015.6224 -5543.0152 48 -5291.6480 1015.6224 49 1968.2300 -5291.6480 50 -2356.6704 1968.2300 51 -3224.5962 -2356.6704 52 -2820.9169 -3224.5962 53 3521.1666 -2820.9169 54 6089.3849 3521.1666 55 4354.4164 6089.3849 56 1870.5625 4354.4164 57 -352.0899 1870.5625 58 3800.2513 -352.0899 59 -577.1197 3800.2513 60 -2641.7950 -577.1197 61 4864.7615 -2641.7950 62 1363.6520 4864.7615 63 NA 1363.6520 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 2680.0724 2048.2858 [2,] 2683.1066 2680.0724 [3,] 4729.8451 2683.1066 [4,] 676.9812 4729.8451 [5,] -941.3230 676.9812 [6,] -3705.1448 -941.3230 [7,] -2374.7091 -3705.1448 [8,] -2643.8100 -2374.7091 [9,] 1517.7230 -2643.8100 [10,] 1990.0677 1517.7230 [11,] -2754.0450 1990.0677 [12,] 1164.8515 -2754.0450 [13,] -1140.9054 1164.8515 [14,] 685.2247 -1140.9054 [15,] 180.6430 685.2247 [16,] 1043.4604 180.6430 [17,] 1106.3550 1043.4604 [18,] -1347.6899 1106.3550 [19,] -1409.8127 -1347.6899 [20,] -3705.6583 -1409.8127 [21,] 2502.8590 -3705.6583 [22,] 1963.7294 2502.8590 [23,] 1610.6989 1963.7294 [24,] 3631.8629 1610.6989 [25,] -1828.0623 3631.8629 [26,] -3816.1824 -1828.0623 [27,] -2507.4480 -3816.1824 [28,] 4172.0927 -2507.4480 [29,] -4489.0994 4172.0927 [30,] -279.1436 -4489.0994 [31,] -2628.6567 -279.1436 [32,] 6654.1173 -2628.6567 [33,] -277.7440 6654.1173 [34,] -2211.0332 -277.7440 [35,] 704.8434 -2211.0332 [36,] 1088.4428 704.8434 [37,] -6544.0962 1088.4428 [38,] 1440.8696 -6544.0962 [39,] 821.5561 1440.8696 [40,] -3071.6174 821.5561 [41,] 802.9009 -3071.6174 [42,] -757.4066 802.9009 [43,] 2058.7621 -757.4066 [44,] -2175.2115 2058.7621 [45,] -3390.7481 -2175.2115 [46,] -5543.0152 -3390.7481 [47,] 1015.6224 -5543.0152 [48,] -5291.6480 1015.6224 [49,] 1968.2300 -5291.6480 [50,] -2356.6704 1968.2300 [51,] -3224.5962 -2356.6704 [52,] -2820.9169 -3224.5962 [53,] 3521.1666 -2820.9169 [54,] 6089.3849 3521.1666 [55,] 4354.4164 6089.3849 [56,] 1870.5625 4354.4164 [57,] -352.0899 1870.5625 [58,] 3800.2513 -352.0899 [59,] -577.1197 3800.2513 [60,] -2641.7950 -577.1197 [61,] 4864.7615 -2641.7950 [62,] 1363.6520 4864.7615 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 2680.0724 2048.2858 2 2683.1066 2680.0724 3 4729.8451 2683.1066 4 676.9812 4729.8451 5 -941.3230 676.9812 6 -3705.1448 -941.3230 7 -2374.7091 -3705.1448 8 -2643.8100 -2374.7091 9 1517.7230 -2643.8100 10 1990.0677 1517.7230 11 -2754.0450 1990.0677 12 1164.8515 -2754.0450 13 -1140.9054 1164.8515 14 685.2247 -1140.9054 15 180.6430 685.2247 16 1043.4604 180.6430 17 1106.3550 1043.4604 18 -1347.6899 1106.3550 19 -1409.8127 -1347.6899 20 -3705.6583 -1409.8127 21 2502.8590 -3705.6583 22 1963.7294 2502.8590 23 1610.6989 1963.7294 24 3631.8629 1610.6989 25 -1828.0623 3631.8629 26 -3816.1824 -1828.0623 27 -2507.4480 -3816.1824 28 4172.0927 -2507.4480 29 -4489.0994 4172.0927 30 -279.1436 -4489.0994 31 -2628.6567 -279.1436 32 6654.1173 -2628.6567 33 -277.7440 6654.1173 34 -2211.0332 -277.7440 35 704.8434 -2211.0332 36 1088.4428 704.8434 37 -6544.0962 1088.4428 38 1440.8696 -6544.0962 39 821.5561 1440.8696 40 -3071.6174 821.5561 41 802.9009 -3071.6174 42 -757.4066 802.9009 43 2058.7621 -757.4066 44 -2175.2115 2058.7621 45 -3390.7481 -2175.2115 46 -5543.0152 -3390.7481 47 1015.6224 -5543.0152 48 -5291.6480 1015.6224 49 1968.2300 -5291.6480 50 -2356.6704 1968.2300 51 -3224.5962 -2356.6704 52 -2820.9169 -3224.5962 53 3521.1666 -2820.9169 54 6089.3849 3521.1666 55 4354.4164 6089.3849 56 1870.5625 4354.4164 57 -352.0899 1870.5625 58 3800.2513 -352.0899 59 -577.1197 3800.2513 60 -2641.7950 -577.1197 61 4864.7615 -2641.7950 62 1363.6520 4864.7615 > 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/7w14i1259607208.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/87c6f1259607208.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/9197d1259607208.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/10hnf91259607208.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/11u4sk1259607209.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/124pd31259607209.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/13xkpg1259607209.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/14l5bn1259607209.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/15ng9h1259607209.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/16yivi1259607209.tab") + } > system("convert tmp/1s39m1259607208.ps tmp/1s39m1259607208.png") > system("convert tmp/26w2l1259607208.ps tmp/26w2l1259607208.png") > system("convert tmp/3g5621259607208.ps tmp/3g5621259607208.png") > system("convert tmp/4sok91259607208.ps tmp/4sok91259607208.png") > system("convert tmp/5e54r1259607208.ps tmp/5e54r1259607208.png") > system("convert tmp/6gf0a1259607208.ps tmp/6gf0a1259607208.png") > system("convert tmp/7w14i1259607208.ps tmp/7w14i1259607208.png") > system("convert tmp/87c6f1259607208.ps tmp/87c6f1259607208.png") > system("convert tmp/9197d1259607208.ps tmp/9197d1259607208.png") > system("convert tmp/10hnf91259607208.ps tmp/10hnf91259607208.png") > > > proc.time() user system elapsed 2.439 1.555 3.476