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(573 + ,122 + ,589 + ,130 + ,17.9 + ,2849.27 + ,567 + ,117 + ,584 + ,127 + ,17.4 + ,2921.44 + ,569 + ,112 + ,573 + ,122 + ,16.7 + ,2981.85 + ,621 + ,113 + ,567 + ,117 + ,16 + ,3080.58 + ,629 + ,149 + ,569 + ,112 + ,16.6 + ,3106.22 + ,628 + ,157 + ,621 + ,113 + ,19.1 + ,3119.31 + ,612 + ,157 + ,629 + ,149 + ,17.8 + ,3061.26 + ,595 + ,147 + ,628 + ,157 + ,17.2 + ,3097.31 + ,597 + ,137 + ,612 + ,157 + ,18.6 + ,3161.69 + ,593 + ,132 + ,595 + ,147 + ,16.3 + ,3257.16 + ,590 + ,125 + ,597 + ,137 + ,15.1 + ,3277.01 + ,580 + ,123 + ,593 + ,132 + ,19.2 + ,3295.32 + ,574 + ,117 + ,590 + ,125 + ,17.7 + ,3363.99 + ,573 + ,114 + ,580 + ,123 + ,19.1 + ,3494.17 + ,573 + ,111 + ,574 + ,117 + ,18 + ,3667.03 + ,620 + ,112 + ,573 + ,114 + ,17.5 + ,3813.06 + ,626 + ,144 + ,573 + ,111 + ,17.8 + ,3917.96 + ,620 + ,150 + ,620 + ,112 + ,21.1 + ,3895.51 + ,588 + ,149 + ,626 + ,144 + ,17.2 + ,3801.06 + ,566 + ,134 + ,620 + ,150 + ,19.4 + ,3570.12 + ,557 + ,123 + ,588 + ,149 + ,19.8 + ,3701.61 + ,561 + ,116 + ,566 + ,134 + ,17.6 + ,3862.27 + ,549 + ,117 + ,557 + ,123 + ,16.2 + ,3970.1 + ,532 + ,111 + ,561 + ,116 + ,19.5 + ,4138.52 + ,526 + ,105 + ,549 + ,117 + ,19.9 + ,4199.75 + ,511 + ,102 + ,532 + ,111 + ,20 + ,4290.89 + ,499 + ,95 + ,526 + ,105 + ,17.3 + ,4443.91 + ,555 + ,93 + ,511 + ,102 + ,18.9 + ,4502.64 + ,565 + ,124 + ,499 + ,95 + ,18.6 + ,4356.98 + ,542 + ,130 + ,555 + ,93 + ,21.4 + ,4591.27 + ,527 + ,124 + ,565 + ,124 + ,18.6 + ,4696.96 + ,510 + ,115 + ,542 + ,130 + ,19.8 + ,4621.4 + ,514 + ,106 + ,527 + ,124 + ,20.8 + ,4562.84 + ,517 + ,105 + ,510 + ,115 + ,19.6 + ,4202.52 + ,508 + ,105 + ,514 + ,106 + ,17.7 + ,4296.49 + ,493 + ,101 + ,517 + ,105 + ,19.8 + ,4435.23 + ,490 + ,95 + ,508 + ,105 + ,22.2 + ,4105.18 + ,469 + ,93 + ,493 + ,101 + ,20.7 + ,4116.68 + ,478 + ,84 + ,490 + ,95 + ,17.9 + ,3844.49 + ,528 + ,87 + ,469 + ,93 + ,20.9 + ,3720.98 + ,534 + ,116 + ,478 + ,84 + ,21.2 + ,3674.4 + ,518 + ,120 + ,528 + ,87 + ,21.4 + ,3857.62 + ,506 + ,117 + ,534 + ,116 + ,23 + ,3801.06 + ,502 + ,109 + ,518 + ,120 + ,21.3 + ,3504.37 + ,516 + ,105 + ,506 + ,117 + ,23.9 + ,3032.6 + ,528 + ,107 + ,502 + ,109 + ,22.4 + ,3047.03 + ,533 + ,109 + ,516 + ,105 + ,18.3 + ,2962.34 + ,536 + ,109 + ,528 + ,107 + ,22.8 + ,2197.82 + ,537 + ,108 + ,533 + ,109 + ,22.3 + ,2014.45 + ,524 + ,107 + ,536 + ,109 + ,17.8 + ,1862.83 + ,536 + ,99 + ,537 + ,108 + ,16.4 + ,1905.41 + ,587 + ,103 + ,524 + ,107 + ,16 + ,1810.99 + ,597 + ,131 + ,536 + ,99 + ,16.4 + ,1670.07 + ,581 + ,137 + ,587 + ,103 + ,17.7 + ,1864.44 + ,564 + ,135 + ,597 + ,131 + ,16.6 + ,2052.02) + ,dim=c(6 + ,55) + ,dimnames=list(c('Y' + ,'X' + ,'Y1' + ,'Y2' + ,'Y3' + ,'Y4') + ,1:55)) > y <- array(NA,dim=c(6,55),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),1:55)) > 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 573 122 589 130 17.9 2849.27 1 0 0 0 0 0 0 0 0 0 0 1 2 567 117 584 127 17.4 2921.44 0 1 0 0 0 0 0 0 0 0 0 2 3 569 112 573 122 16.7 2981.85 0 0 1 0 0 0 0 0 0 0 0 3 4 621 113 567 117 16.0 3080.58 0 0 0 1 0 0 0 0 0 0 0 4 5 629 149 569 112 16.6 3106.22 0 0 0 0 1 0 0 0 0 0 0 5 6 628 157 621 113 19.1 3119.31 0 0 0 0 0 1 0 0 0 0 0 6 7 612 157 629 149 17.8 3061.26 0 0 0 0 0 0 1 0 0 0 0 7 8 595 147 628 157 17.2 3097.31 0 0 0 0 0 0 0 1 0 0 0 8 9 597 137 612 157 18.6 3161.69 0 0 0 0 0 0 0 0 1 0 0 9 10 593 132 595 147 16.3 3257.16 0 0 0 0 0 0 0 0 0 1 0 10 11 590 125 597 137 15.1 3277.01 0 0 0 0 0 0 0 0 0 0 1 11 12 580 123 593 132 19.2 3295.32 0 0 0 0 0 0 0 0 0 0 0 12 13 574 117 590 125 17.7 3363.99 1 0 0 0 0 0 0 0 0 0 0 13 14 573 114 580 123 19.1 3494.17 0 1 0 0 0 0 0 0 0 0 0 14 15 573 111 574 117 18.0 3667.03 0 0 1 0 0 0 0 0 0 0 0 15 16 620 112 573 114 17.5 3813.06 0 0 0 1 0 0 0 0 0 0 0 16 17 626 144 573 111 17.8 3917.96 0 0 0 0 1 0 0 0 0 0 0 17 18 620 150 620 112 21.1 3895.51 0 0 0 0 0 1 0 0 0 0 0 18 19 588 149 626 144 17.2 3801.06 0 0 0 0 0 0 1 0 0 0 0 19 20 566 134 620 150 19.4 3570.12 0 0 0 0 0 0 0 1 0 0 0 20 21 557 123 588 149 19.8 3701.61 0 0 0 0 0 0 0 0 1 0 0 21 22 561 116 566 134 17.6 3862.27 0 0 0 0 0 0 0 0 0 1 0 22 23 549 117 557 123 16.2 3970.10 0 0 0 0 0 0 0 0 0 0 1 23 24 532 111 561 116 19.5 4138.52 0 0 0 0 0 0 0 0 0 0 0 24 25 526 105 549 117 19.9 4199.75 1 0 0 0 0 0 0 0 0 0 0 25 26 511 102 532 111 20.0 4290.89 0 1 0 0 0 0 0 0 0 0 0 26 27 499 95 526 105 17.3 4443.91 0 0 1 0 0 0 0 0 0 0 0 27 28 555 93 511 102 18.9 4502.64 0 0 0 1 0 0 0 0 0 0 0 28 29 565 124 499 95 18.6 4356.98 0 0 0 0 1 0 0 0 0 0 0 29 30 542 130 555 93 21.4 4591.27 0 0 0 0 0 1 0 0 0 0 0 30 31 527 124 565 124 18.6 4696.96 0 0 0 0 0 0 1 0 0 0 0 31 32 510 115 542 130 19.8 4621.40 0 0 0 0 0 0 0 1 0 0 0 32 33 514 106 527 124 20.8 4562.84 0 0 0 0 0 0 0 0 1 0 0 33 34 517 105 510 115 19.6 4202.52 0 0 0 0 0 0 0 0 0 1 0 34 35 508 105 514 106 17.7 4296.49 0 0 0 0 0 0 0 0 0 0 1 35 36 493 101 517 105 19.8 4435.23 0 0 0 0 0 0 0 0 0 0 0 36 37 490 95 508 105 22.2 4105.18 1 0 0 0 0 0 0 0 0 0 0 37 38 469 93 493 101 20.7 4116.68 0 1 0 0 0 0 0 0 0 0 0 38 39 478 84 490 95 17.9 3844.49 0 0 1 0 0 0 0 0 0 0 0 39 40 528 87 469 93 20.9 3720.98 0 0 0 1 0 0 0 0 0 0 0 40 41 534 116 478 84 21.2 3674.40 0 0 0 0 1 0 0 0 0 0 0 41 42 518 120 528 87 21.4 3857.62 0 0 0 0 0 1 0 0 0 0 0 42 43 506 117 534 116 23.0 3801.06 0 0 0 0 0 0 1 0 0 0 0 43 44 502 109 518 120 21.3 3504.37 0 0 0 0 0 0 0 1 0 0 0 44 45 516 105 506 117 23.9 3032.60 0 0 0 0 0 0 0 0 1 0 0 45 46 528 107 502 109 22.4 3047.03 0 0 0 0 0 0 0 0 0 1 0 46 47 533 109 516 105 18.3 2962.34 0 0 0 0 0 0 0 0 0 0 1 47 48 536 109 528 107 22.8 2197.82 0 0 0 0 0 0 0 0 0 0 0 48 49 537 108 533 109 22.3 2014.45 1 0 0 0 0 0 0 0 0 0 0 49 50 524 107 536 109 17.8 1862.83 0 1 0 0 0 0 0 0 0 0 0 50 51 536 99 537 108 16.4 1905.41 0 0 1 0 0 0 0 0 0 0 0 51 52 587 103 524 107 16.0 1810.99 0 0 0 1 0 0 0 0 0 0 0 52 53 597 131 536 99 16.4 1670.07 0 0 0 0 1 0 0 0 0 0 0 53 54 581 137 587 103 17.7 1864.44 0 0 0 0 0 1 0 0 0 0 0 54 55 564 135 597 131 16.6 2052.02 0 0 0 0 0 0 1 0 0 0 0 55 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X Y1 Y2 Y3 Y4 63.241901 1.162320 0.780422 -0.792732 2.103896 -0.008417 M1 M2 M3 M4 M5 M6 2.766982 1.941191 15.869688 71.113325 35.438531 -25.750626 M7 M8 M9 M10 M11 t -19.305463 -9.418760 12.586114 26.781387 19.389018 -0.268120 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -13.9293 -2.9571 -0.6877 3.2710 13.3866 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 63.241901 52.569279 1.203 0.236610 X 1.162320 0.356310 3.262 0.002381 ** Y1 0.780422 0.130898 5.962 7.07e-07 *** Y2 -0.792732 0.390900 -2.028 0.049810 * Y3 2.103896 0.867991 2.424 0.020362 * Y4 -0.008417 0.002094 -4.019 0.000276 *** M1 2.766982 4.622443 0.599 0.553089 M2 1.941191 4.867364 0.399 0.692320 M3 15.869688 6.404088 2.478 0.017898 * M4 71.113325 5.929281 11.994 2.59e-14 *** M5 35.438531 12.032187 2.945 0.005551 ** M6 -25.750626 12.556784 -2.051 0.047426 * M7 -19.305463 8.113687 -2.379 0.022612 * M8 -9.418760 8.462380 -1.113 0.272881 M9 12.586114 8.935126 1.409 0.167299 M10 26.781387 6.758611 3.963 0.000325 *** M11 19.389018 5.787196 3.350 0.001868 ** t -0.268120 0.157730 -1.700 0.097549 . --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 6.41 on 37 degrees of freedom Multiple R-squared: 0.9838, Adjusted R-squared: 0.9763 F-statistic: 131.9 on 17 and 37 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.1985291 0.3970581881 0.8014709059 [2,] 0.7388147 0.5223705290 0.2611852645 [3,] 0.8370923 0.3258154218 0.1629077109 [4,] 0.8017419 0.3965161287 0.1982580643 [5,] 0.7198026 0.5603947473 0.2801973737 [6,] 0.6758136 0.6483728956 0.3241864478 [7,] 0.8403542 0.3192915724 0.1596457862 [8,] 0.8659546 0.2680907821 0.1340453911 [9,] 0.9356586 0.1286828722 0.0643414361 [10,] 0.8843436 0.2313127578 0.1156563789 [11,] 0.9872848 0.0254303312 0.0127151656 [12,] 0.9816604 0.0366792169 0.0183396085 [13,] 0.9997312 0.0005376863 0.0002688432 [14,] 0.9980809 0.0038381347 0.0019190673 > postscript(file="/var/www/html/rcomp/tmp/1z09i1258744278.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/2wvky1258744278.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/300qf1258744278.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/4lm2y1258744278.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/57r221258744278.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 = 55 Frequency = 1 1 2 3 4 5 -4.834528311 -0.745702861 0.007695224 -1.107538717 -5.579191414 6 7 8 9 10 0.640766617 3.005169018 -3.302160412 -1.332533532 -2.465709776 11 12 13 14 15 3.534609358 6.202554451 5.203592071 13.153483346 6.675447151 16 17 18 19 20 -1.779086947 0.843147991 6.307599122 -2.612011866 -13.929251813 21 22 23 24 25 -7.434531234 2.033693470 -1.311340500 -5.876362565 2.430302978 26 27 28 29 30 1.078683065 -9.550830520 0.254516428 13.386583427 -4.338035154 31 32 33 34 35 5.009824761 8.397555524 5.474822666 1.334438895 -5.473002889 36 37 38 39 40 -2.550991464 -1.879508484 -7.672921889 -0.687651256 -1.698008068 41 42 43 44 45 -8.644003104 -3.357515067 -3.583190652 8.833856701 3.292242100 46 47 48 49 50 -0.902422588 3.249734031 2.224799578 -0.919858255 -5.813541661 51 52 53 54 55 3.555339400 4.330117305 -0.006536900 0.747184482 -1.819791261 > postscript(file="/var/www/html/rcomp/tmp/648he1258744278.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 = 55 Frequency = 1 lag(myerror, k = 1) myerror 0 -4.834528311 NA 1 -0.745702861 -4.834528311 2 0.007695224 -0.745702861 3 -1.107538717 0.007695224 4 -5.579191414 -1.107538717 5 0.640766617 -5.579191414 6 3.005169018 0.640766617 7 -3.302160412 3.005169018 8 -1.332533532 -3.302160412 9 -2.465709776 -1.332533532 10 3.534609358 -2.465709776 11 6.202554451 3.534609358 12 5.203592071 6.202554451 13 13.153483346 5.203592071 14 6.675447151 13.153483346 15 -1.779086947 6.675447151 16 0.843147991 -1.779086947 17 6.307599122 0.843147991 18 -2.612011866 6.307599122 19 -13.929251813 -2.612011866 20 -7.434531234 -13.929251813 21 2.033693470 -7.434531234 22 -1.311340500 2.033693470 23 -5.876362565 -1.311340500 24 2.430302978 -5.876362565 25 1.078683065 2.430302978 26 -9.550830520 1.078683065 27 0.254516428 -9.550830520 28 13.386583427 0.254516428 29 -4.338035154 13.386583427 30 5.009824761 -4.338035154 31 8.397555524 5.009824761 32 5.474822666 8.397555524 33 1.334438895 5.474822666 34 -5.473002889 1.334438895 35 -2.550991464 -5.473002889 36 -1.879508484 -2.550991464 37 -7.672921889 -1.879508484 38 -0.687651256 -7.672921889 39 -1.698008068 -0.687651256 40 -8.644003104 -1.698008068 41 -3.357515067 -8.644003104 42 -3.583190652 -3.357515067 43 8.833856701 -3.583190652 44 3.292242100 8.833856701 45 -0.902422588 3.292242100 46 3.249734031 -0.902422588 47 2.224799578 3.249734031 48 -0.919858255 2.224799578 49 -5.813541661 -0.919858255 50 3.555339400 -5.813541661 51 4.330117305 3.555339400 52 -0.006536900 4.330117305 53 0.747184482 -0.006536900 54 -1.819791261 0.747184482 55 NA -1.819791261 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -0.745702861 -4.834528311 [2,] 0.007695224 -0.745702861 [3,] -1.107538717 0.007695224 [4,] -5.579191414 -1.107538717 [5,] 0.640766617 -5.579191414 [6,] 3.005169018 0.640766617 [7,] -3.302160412 3.005169018 [8,] -1.332533532 -3.302160412 [9,] -2.465709776 -1.332533532 [10,] 3.534609358 -2.465709776 [11,] 6.202554451 3.534609358 [12,] 5.203592071 6.202554451 [13,] 13.153483346 5.203592071 [14,] 6.675447151 13.153483346 [15,] -1.779086947 6.675447151 [16,] 0.843147991 -1.779086947 [17,] 6.307599122 0.843147991 [18,] -2.612011866 6.307599122 [19,] -13.929251813 -2.612011866 [20,] -7.434531234 -13.929251813 [21,] 2.033693470 -7.434531234 [22,] -1.311340500 2.033693470 [23,] -5.876362565 -1.311340500 [24,] 2.430302978 -5.876362565 [25,] 1.078683065 2.430302978 [26,] -9.550830520 1.078683065 [27,] 0.254516428 -9.550830520 [28,] 13.386583427 0.254516428 [29,] -4.338035154 13.386583427 [30,] 5.009824761 -4.338035154 [31,] 8.397555524 5.009824761 [32,] 5.474822666 8.397555524 [33,] 1.334438895 5.474822666 [34,] -5.473002889 1.334438895 [35,] -2.550991464 -5.473002889 [36,] -1.879508484 -2.550991464 [37,] -7.672921889 -1.879508484 [38,] -0.687651256 -7.672921889 [39,] -1.698008068 -0.687651256 [40,] -8.644003104 -1.698008068 [41,] -3.357515067 -8.644003104 [42,] -3.583190652 -3.357515067 [43,] 8.833856701 -3.583190652 [44,] 3.292242100 8.833856701 [45,] -0.902422588 3.292242100 [46,] 3.249734031 -0.902422588 [47,] 2.224799578 3.249734031 [48,] -0.919858255 2.224799578 [49,] -5.813541661 -0.919858255 [50,] 3.555339400 -5.813541661 [51,] 4.330117305 3.555339400 [52,] -0.006536900 4.330117305 [53,] 0.747184482 -0.006536900 [54,] -1.819791261 0.747184482 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -0.745702861 -4.834528311 2 0.007695224 -0.745702861 3 -1.107538717 0.007695224 4 -5.579191414 -1.107538717 5 0.640766617 -5.579191414 6 3.005169018 0.640766617 7 -3.302160412 3.005169018 8 -1.332533532 -3.302160412 9 -2.465709776 -1.332533532 10 3.534609358 -2.465709776 11 6.202554451 3.534609358 12 5.203592071 6.202554451 13 13.153483346 5.203592071 14 6.675447151 13.153483346 15 -1.779086947 6.675447151 16 0.843147991 -1.779086947 17 6.307599122 0.843147991 18 -2.612011866 6.307599122 19 -13.929251813 -2.612011866 20 -7.434531234 -13.929251813 21 2.033693470 -7.434531234 22 -1.311340500 2.033693470 23 -5.876362565 -1.311340500 24 2.430302978 -5.876362565 25 1.078683065 2.430302978 26 -9.550830520 1.078683065 27 0.254516428 -9.550830520 28 13.386583427 0.254516428 29 -4.338035154 13.386583427 30 5.009824761 -4.338035154 31 8.397555524 5.009824761 32 5.474822666 8.397555524 33 1.334438895 5.474822666 34 -5.473002889 1.334438895 35 -2.550991464 -5.473002889 36 -1.879508484 -2.550991464 37 -7.672921889 -1.879508484 38 -0.687651256 -7.672921889 39 -1.698008068 -0.687651256 40 -8.644003104 -1.698008068 41 -3.357515067 -8.644003104 42 -3.583190652 -3.357515067 43 8.833856701 -3.583190652 44 3.292242100 8.833856701 45 -0.902422588 3.292242100 46 3.249734031 -0.902422588 47 2.224799578 3.249734031 48 -0.919858255 2.224799578 49 -5.813541661 -0.919858255 50 3.555339400 -5.813541661 51 4.330117305 3.555339400 52 -0.006536900 4.330117305 53 0.747184482 -0.006536900 54 -1.819791261 0.747184482 > 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/7ulgz1258744278.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/816av1258744278.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/9n94e1258744278.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/104lro1258744278.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/117mkf1258744278.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/12h14m1258744278.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/13yuqb1258744278.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/146t9r1258744278.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/15z3ei1258744278.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/16x4nw1258744278.tab") + } > > system("convert tmp/1z09i1258744278.ps tmp/1z09i1258744278.png") > system("convert tmp/2wvky1258744278.ps tmp/2wvky1258744278.png") > system("convert tmp/300qf1258744278.ps tmp/300qf1258744278.png") > system("convert tmp/4lm2y1258744278.ps tmp/4lm2y1258744278.png") > system("convert tmp/57r221258744278.ps tmp/57r221258744278.png") > system("convert tmp/648he1258744278.ps tmp/648he1258744278.png") > system("convert tmp/7ulgz1258744278.ps tmp/7ulgz1258744278.png") > system("convert tmp/816av1258744278.ps tmp/816av1258744278.png") > system("convert tmp/9n94e1258744278.ps tmp/9n94e1258744278.png") > system("convert tmp/104lro1258744278.ps tmp/104lro1258744278.png") > > > proc.time() user system elapsed 2.266 1.511 2.716