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(357 + ,15.5 + ,358 + ,363 + ,364 + ,363 + ,357 + ,15.1 + ,357 + ,358 + ,363 + ,364 + ,380 + ,15 + ,357 + ,357 + ,358 + ,363 + ,378 + ,12.1 + ,380 + ,357 + ,357 + ,358 + ,376 + ,15.8 + ,378 + ,380 + ,357 + ,357 + ,380 + ,16.9 + ,376 + ,378 + ,380 + ,357 + ,379 + ,15.1 + ,380 + ,376 + ,378 + ,380 + ,384 + ,13.7 + ,379 + ,380 + ,376 + ,378 + ,392 + ,14.8 + ,384 + ,379 + ,380 + ,376 + ,394 + ,14.7 + ,392 + ,384 + ,379 + ,380 + ,392 + ,16 + ,394 + ,392 + ,384 + ,379 + ,396 + ,15.4 + ,392 + ,394 + ,392 + ,384 + ,392 + ,15 + ,396 + ,392 + ,394 + ,392 + ,396 + ,15.5 + ,392 + ,396 + ,392 + ,394 + ,419 + ,15.1 + ,396 + ,392 + ,396 + ,392 + ,421 + ,11.7 + ,419 + ,396 + ,392 + ,396 + ,420 + ,16.3 + ,421 + ,419 + ,396 + ,392 + ,418 + ,16.7 + ,420 + ,421 + ,419 + ,396 + ,410 + ,15 + ,418 + ,420 + ,421 + ,419 + ,418 + ,14.9 + ,410 + ,418 + ,420 + ,421 + ,426 + ,14.6 + ,418 + ,410 + ,418 + ,420 + ,428 + ,15.3 + ,426 + ,418 + ,410 + ,418 + ,430 + ,17.9 + ,428 + ,426 + ,418 + ,410 + ,424 + ,16.4 + ,430 + ,428 + ,426 + ,418 + ,423 + ,15.4 + ,424 + ,430 + ,428 + ,426 + ,427 + ,17.9 + ,423 + ,424 + ,430 + ,428 + ,441 + ,15.9 + ,427 + ,423 + ,424 + ,430 + ,449 + ,13.9 + ,441 + ,427 + ,423 + ,424 + ,452 + ,17.8 + ,449 + ,441 + ,427 + ,423 + ,462 + ,17.9 + ,452 + ,449 + ,441 + ,427 + ,455 + ,17.4 + ,462 + ,452 + ,449 + ,441 + ,461 + ,16.7 + ,455 + ,462 + ,452 + ,449 + ,461 + ,16 + ,461 + ,455 + ,462 + ,452 + ,463 + ,16.6 + ,461 + ,461 + ,455 + ,462 + ,462 + ,19.1 + ,463 + ,461 + ,461 + ,455 + ,456 + ,17.8 + ,462 + ,463 + ,461 + ,461 + ,455 + ,17.2 + ,456 + ,462 + ,463 + ,461 + ,456 + ,18.6 + ,455 + ,456 + ,462 + ,463 + ,472 + ,16.3 + ,456 + ,455 + ,456 + ,462 + ,472 + ,15.1 + ,472 + ,456 + ,455 + ,456 + ,471 + ,19.2 + ,472 + ,472 + ,456 + ,455 + ,465 + ,17.7 + ,471 + ,472 + ,472 + ,456 + ,459 + ,19.1 + ,465 + ,471 + ,472 + ,472 + ,465 + ,18 + ,459 + ,465 + ,471 + ,472 + ,468 + ,17.5 + ,465 + ,459 + ,465 + ,471 + ,467 + ,17.8 + ,468 + ,465 + ,459 + ,465 + ,463 + ,21.1 + ,467 + ,468 + ,465 + ,459 + ,460 + ,17.2 + ,463 + ,467 + ,468 + ,465 + ,462 + ,19.4 + ,460 + ,463 + ,467 + ,468 + ,461 + ,19.8 + ,462 + ,460 + ,463 + ,467 + ,476 + ,17.6 + ,461 + ,462 + ,460 + ,463 + ,476 + ,16.2 + ,476 + ,461 + ,462 + ,460 + ,471 + ,19.5 + ,476 + ,476 + ,461 + ,462 + ,453 + ,19.9 + ,471 + ,476 + ,476 + ,461 + ,443 + ,20 + ,453 + ,471 + ,476 + ,476 + ,442 + ,17.3 + ,443 + ,453 + ,471 + ,476) + ,dim=c(6 + ,56) + ,dimnames=list(c('Y' + ,'X' + ,'Y-1' + ,'Y-2' + ,'Y-3' + ,'Y-4') + ,1:56)) > y <- array(NA,dim=c(6,56),dimnames=list(c('Y','X','Y-1','Y-2','Y-3','Y-4'),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 Y-1 Y-2 Y-3 Y-4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 357 15.5 358 363 364 363 1 0 0 0 0 0 0 0 0 0 0 1 2 357 15.1 357 358 363 364 0 1 0 0 0 0 0 0 0 0 0 2 3 380 15.0 357 357 358 363 0 0 1 0 0 0 0 0 0 0 0 3 4 378 12.1 380 357 357 358 0 0 0 1 0 0 0 0 0 0 0 4 5 376 15.8 378 380 357 357 0 0 0 0 1 0 0 0 0 0 0 5 6 380 16.9 376 378 380 357 0 0 0 0 0 1 0 0 0 0 0 6 7 379 15.1 380 376 378 380 0 0 0 0 0 0 1 0 0 0 0 7 8 384 13.7 379 380 376 378 0 0 0 0 0 0 0 1 0 0 0 8 9 392 14.8 384 379 380 376 0 0 0 0 0 0 0 0 1 0 0 9 10 394 14.7 392 384 379 380 0 0 0 0 0 0 0 0 0 1 0 10 11 392 16.0 394 392 384 379 0 0 0 0 0 0 0 0 0 0 1 11 12 396 15.4 392 394 392 384 0 0 0 0 0 0 0 0 0 0 0 12 13 392 15.0 396 392 394 392 1 0 0 0 0 0 0 0 0 0 0 13 14 396 15.5 392 396 392 394 0 1 0 0 0 0 0 0 0 0 0 14 15 419 15.1 396 392 396 392 0 0 1 0 0 0 0 0 0 0 0 15 16 421 11.7 419 396 392 396 0 0 0 1 0 0 0 0 0 0 0 16 17 420 16.3 421 419 396 392 0 0 0 0 1 0 0 0 0 0 0 17 18 418 16.7 420 421 419 396 0 0 0 0 0 1 0 0 0 0 0 18 19 410 15.0 418 420 421 419 0 0 0 0 0 0 1 0 0 0 0 19 20 418 14.9 410 418 420 421 0 0 0 0 0 0 0 1 0 0 0 20 21 426 14.6 418 410 418 420 0 0 0 0 0 0 0 0 1 0 0 21 22 428 15.3 426 418 410 418 0 0 0 0 0 0 0 0 0 1 0 22 23 430 17.9 428 426 418 410 0 0 0 0 0 0 0 0 0 0 1 23 24 424 16.4 430 428 426 418 0 0 0 0 0 0 0 0 0 0 0 24 25 423 15.4 424 430 428 426 1 0 0 0 0 0 0 0 0 0 0 25 26 427 17.9 423 424 430 428 0 1 0 0 0 0 0 0 0 0 0 26 27 441 15.9 427 423 424 430 0 0 1 0 0 0 0 0 0 0 0 27 28 449 13.9 441 427 423 424 0 0 0 1 0 0 0 0 0 0 0 28 29 452 17.8 449 441 427 423 0 0 0 0 1 0 0 0 0 0 0 29 30 462 17.9 452 449 441 427 0 0 0 0 0 1 0 0 0 0 0 30 31 455 17.4 462 452 449 441 0 0 0 0 0 0 1 0 0 0 0 31 32 461 16.7 455 462 452 449 0 0 0 0 0 0 0 1 0 0 0 32 33 461 16.0 461 455 462 452 0 0 0 0 0 0 0 0 1 0 0 33 34 463 16.6 461 461 455 462 0 0 0 0 0 0 0 0 0 1 0 34 35 462 19.1 463 461 461 455 0 0 0 0 0 0 0 0 0 0 1 35 36 456 17.8 462 463 461 461 0 0 0 0 0 0 0 0 0 0 0 36 37 455 17.2 456 462 463 461 1 0 0 0 0 0 0 0 0 0 0 37 38 456 18.6 455 456 462 463 0 1 0 0 0 0 0 0 0 0 0 38 39 472 16.3 456 455 456 462 0 0 1 0 0 0 0 0 0 0 0 39 40 472 15.1 472 456 455 456 0 0 0 1 0 0 0 0 0 0 0 40 41 471 19.2 472 472 456 455 0 0 0 0 1 0 0 0 0 0 0 41 42 465 17.7 471 472 472 456 0 0 0 0 0 1 0 0 0 0 0 42 43 459 19.1 465 471 472 472 0 0 0 0 0 0 1 0 0 0 0 43 44 465 18.0 459 465 471 472 0 0 0 0 0 0 0 1 0 0 0 44 45 468 17.5 465 459 465 471 0 0 0 0 0 0 0 0 1 0 0 45 46 467 17.8 468 465 459 465 0 0 0 0 0 0 0 0 0 1 0 46 47 463 21.1 467 468 465 459 0 0 0 0 0 0 0 0 0 0 1 47 48 460 17.2 463 467 468 465 0 0 0 0 0 0 0 0 0 0 0 48 49 462 19.4 460 463 467 468 1 0 0 0 0 0 0 0 0 0 0 49 50 461 19.8 462 460 463 467 0 1 0 0 0 0 0 0 0 0 0 50 51 476 17.6 461 462 460 463 0 0 1 0 0 0 0 0 0 0 0 51 52 476 16.2 476 461 462 460 0 0 0 1 0 0 0 0 0 0 0 52 53 471 19.5 476 476 461 462 0 0 0 0 1 0 0 0 0 0 0 53 54 453 19.9 471 476 476 461 0 0 0 0 0 1 0 0 0 0 0 54 55 443 20.0 453 471 476 476 0 0 0 0 0 0 1 0 0 0 0 55 56 442 17.3 443 453 471 476 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 `Y-1` `Y-2` `Y-3` `Y-4` -50.76900 1.50144 1.02890 0.06930 -0.09624 0.07961 M1 M2 M3 M4 M5 M6 1.10543 2.83667 21.76218 8.36985 -0.97677 -0.36604 M7 M8 M9 M10 M11 t -4.34480 9.17821 8.36124 3.49196 -1.56210 -0.41287 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -11.933869 -1.604313 -0.008833 1.514402 10.918391 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -50.76900 27.79173 -1.827 0.0756 . X 1.50144 0.94263 1.593 0.1195 `Y-1` 1.02890 0.15665 6.568 9.50e-08 *** `Y-2` 0.06930 0.22037 0.314 0.7549 `Y-3` -0.09624 0.24688 -0.390 0.6988 `Y-4` 0.07961 0.19973 0.399 0.6924 M1 1.10543 2.91911 0.379 0.7070 M2 2.83667 3.28292 0.864 0.3930 M3 21.76218 3.20982 6.780 4.89e-08 *** M4 8.36985 4.80300 1.743 0.0895 . M5 -0.97677 4.24287 -0.230 0.8192 M6 -0.36604 3.83191 -0.096 0.9244 M7 -4.34480 2.91387 -1.491 0.1442 M8 9.17821 3.15971 2.905 0.0061 ** M9 8.36124 3.40790 2.453 0.0188 * M10 3.49196 3.70108 0.943 0.3514 M11 -1.56210 3.50382 -0.446 0.6583 t -0.41287 0.18090 -2.282 0.0282 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 4.104 on 38 degrees of freedom Multiple R-squared: 0.9902, Adjusted R-squared: 0.9858 F-statistic: 225.7 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.2910247 0.5820494 0.7089753 [2,] 0.2513236 0.5026472 0.7486764 [3,] 0.1413652 0.2827303 0.8586348 [4,] 0.3285211 0.6570421 0.6714789 [5,] 0.2720425 0.5440850 0.7279575 [6,] 0.1688772 0.3377543 0.8311228 [7,] 0.3452781 0.6905562 0.6547219 [8,] 0.2722054 0.5444108 0.7277946 [9,] 0.2350097 0.4700195 0.7649903 [10,] 0.8304528 0.3390944 0.1695472 [11,] 0.7349248 0.5301503 0.2650752 [12,] 0.6779456 0.6441089 0.3220544 [13,] 0.5944120 0.8111760 0.4055880 [14,] 0.4833131 0.9666262 0.5166869 [15,] 0.3185382 0.6370763 0.6814618 > postscript(file="/var/www/html/rcomp/tmp/1aijj1258794512.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/2xfm91258794512.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/3lofh1258794512.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/4g3ot1258794512.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/5mqz01258794512.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 -3.562529952 -3.080783454 1.224430237 -5.979080153 -3.231337152 6 7 8 9 10 3.329135129 3.422913021 -1.866760731 1.180477961 -0.379576348 11 12 13 14 15 -0.915878459 5.126848457 -3.386509258 2.031118109 3.824825908 16 17 18 19 20 0.089663348 -1.005703597 -1.018739169 -1.586048914 1.568292360 21 22 23 24 25 3.458881833 0.293747639 2.651543852 -4.308850691 1.090456174 26 27 28 29 30 1.496438310 -4.796270041 5.711433246 3.878532500 10.918391137 31 32 33 34 35 -1.780717344 -1.678658476 -4.362541185 0.133208832 -0.076561726 36 37 38 39 40 -4.861252995 0.782225941 -0.448928506 -0.965687044 -1.509041969 41 42 43 44 45 0.161646704 -1.294918476 -0.036324998 0.998060178 -0.276818609 46 47 48 49 50 -0.047380123 -1.659103667 4.043255230 5.076357096 0.002155542 51 52 53 54 55 0.712700941 1.687025527 0.196861545 -11.933868620 -0.019821765 56 0.979066669 > postscript(file="/var/www/html/rcomp/tmp/66viq1258794512.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 -3.562529952 NA 1 -3.080783454 -3.562529952 2 1.224430237 -3.080783454 3 -5.979080153 1.224430237 4 -3.231337152 -5.979080153 5 3.329135129 -3.231337152 6 3.422913021 3.329135129 7 -1.866760731 3.422913021 8 1.180477961 -1.866760731 9 -0.379576348 1.180477961 10 -0.915878459 -0.379576348 11 5.126848457 -0.915878459 12 -3.386509258 5.126848457 13 2.031118109 -3.386509258 14 3.824825908 2.031118109 15 0.089663348 3.824825908 16 -1.005703597 0.089663348 17 -1.018739169 -1.005703597 18 -1.586048914 -1.018739169 19 1.568292360 -1.586048914 20 3.458881833 1.568292360 21 0.293747639 3.458881833 22 2.651543852 0.293747639 23 -4.308850691 2.651543852 24 1.090456174 -4.308850691 25 1.496438310 1.090456174 26 -4.796270041 1.496438310 27 5.711433246 -4.796270041 28 3.878532500 5.711433246 29 10.918391137 3.878532500 30 -1.780717344 10.918391137 31 -1.678658476 -1.780717344 32 -4.362541185 -1.678658476 33 0.133208832 -4.362541185 34 -0.076561726 0.133208832 35 -4.861252995 -0.076561726 36 0.782225941 -4.861252995 37 -0.448928506 0.782225941 38 -0.965687044 -0.448928506 39 -1.509041969 -0.965687044 40 0.161646704 -1.509041969 41 -1.294918476 0.161646704 42 -0.036324998 -1.294918476 43 0.998060178 -0.036324998 44 -0.276818609 0.998060178 45 -0.047380123 -0.276818609 46 -1.659103667 -0.047380123 47 4.043255230 -1.659103667 48 5.076357096 4.043255230 49 0.002155542 5.076357096 50 0.712700941 0.002155542 51 1.687025527 0.712700941 52 0.196861545 1.687025527 53 -11.933868620 0.196861545 54 -0.019821765 -11.933868620 55 0.979066669 -0.019821765 56 NA 0.979066669 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -3.080783454 -3.562529952 [2,] 1.224430237 -3.080783454 [3,] -5.979080153 1.224430237 [4,] -3.231337152 -5.979080153 [5,] 3.329135129 -3.231337152 [6,] 3.422913021 3.329135129 [7,] -1.866760731 3.422913021 [8,] 1.180477961 -1.866760731 [9,] -0.379576348 1.180477961 [10,] -0.915878459 -0.379576348 [11,] 5.126848457 -0.915878459 [12,] -3.386509258 5.126848457 [13,] 2.031118109 -3.386509258 [14,] 3.824825908 2.031118109 [15,] 0.089663348 3.824825908 [16,] -1.005703597 0.089663348 [17,] -1.018739169 -1.005703597 [18,] -1.586048914 -1.018739169 [19,] 1.568292360 -1.586048914 [20,] 3.458881833 1.568292360 [21,] 0.293747639 3.458881833 [22,] 2.651543852 0.293747639 [23,] -4.308850691 2.651543852 [24,] 1.090456174 -4.308850691 [25,] 1.496438310 1.090456174 [26,] -4.796270041 1.496438310 [27,] 5.711433246 -4.796270041 [28,] 3.878532500 5.711433246 [29,] 10.918391137 3.878532500 [30,] -1.780717344 10.918391137 [31,] -1.678658476 -1.780717344 [32,] -4.362541185 -1.678658476 [33,] 0.133208832 -4.362541185 [34,] -0.076561726 0.133208832 [35,] -4.861252995 -0.076561726 [36,] 0.782225941 -4.861252995 [37,] -0.448928506 0.782225941 [38,] -0.965687044 -0.448928506 [39,] -1.509041969 -0.965687044 [40,] 0.161646704 -1.509041969 [41,] -1.294918476 0.161646704 [42,] -0.036324998 -1.294918476 [43,] 0.998060178 -0.036324998 [44,] -0.276818609 0.998060178 [45,] -0.047380123 -0.276818609 [46,] -1.659103667 -0.047380123 [47,] 4.043255230 -1.659103667 [48,] 5.076357096 4.043255230 [49,] 0.002155542 5.076357096 [50,] 0.712700941 0.002155542 [51,] 1.687025527 0.712700941 [52,] 0.196861545 1.687025527 [53,] -11.933868620 0.196861545 [54,] -0.019821765 -11.933868620 [55,] 0.979066669 -0.019821765 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -3.080783454 -3.562529952 2 1.224430237 -3.080783454 3 -5.979080153 1.224430237 4 -3.231337152 -5.979080153 5 3.329135129 -3.231337152 6 3.422913021 3.329135129 7 -1.866760731 3.422913021 8 1.180477961 -1.866760731 9 -0.379576348 1.180477961 10 -0.915878459 -0.379576348 11 5.126848457 -0.915878459 12 -3.386509258 5.126848457 13 2.031118109 -3.386509258 14 3.824825908 2.031118109 15 0.089663348 3.824825908 16 -1.005703597 0.089663348 17 -1.018739169 -1.005703597 18 -1.586048914 -1.018739169 19 1.568292360 -1.586048914 20 3.458881833 1.568292360 21 0.293747639 3.458881833 22 2.651543852 0.293747639 23 -4.308850691 2.651543852 24 1.090456174 -4.308850691 25 1.496438310 1.090456174 26 -4.796270041 1.496438310 27 5.711433246 -4.796270041 28 3.878532500 5.711433246 29 10.918391137 3.878532500 30 -1.780717344 10.918391137 31 -1.678658476 -1.780717344 32 -4.362541185 -1.678658476 33 0.133208832 -4.362541185 34 -0.076561726 0.133208832 35 -4.861252995 -0.076561726 36 0.782225941 -4.861252995 37 -0.448928506 0.782225941 38 -0.965687044 -0.448928506 39 -1.509041969 -0.965687044 40 0.161646704 -1.509041969 41 -1.294918476 0.161646704 42 -0.036324998 -1.294918476 43 0.998060178 -0.036324998 44 -0.276818609 0.998060178 45 -0.047380123 -0.276818609 46 -1.659103667 -0.047380123 47 4.043255230 -1.659103667 48 5.076357096 4.043255230 49 0.002155542 5.076357096 50 0.712700941 0.002155542 51 1.687025527 0.712700941 52 0.196861545 1.687025527 53 -11.933868620 0.196861545 54 -0.019821765 -11.933868620 55 0.979066669 -0.019821765 > 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/703y01258794512.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/88y9m1258794512.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/930ym1258794512.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/104kf31258794512.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/119k9y1258794512.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/121x9s1258794512.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/139q6o1258794512.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/144a7n1258794512.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/15pk7i1258794512.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/16zf7x1258794513.tab") + } > > system("convert tmp/1aijj1258794512.ps tmp/1aijj1258794512.png") > system("convert tmp/2xfm91258794512.ps tmp/2xfm91258794512.png") > system("convert tmp/3lofh1258794512.ps tmp/3lofh1258794512.png") > system("convert tmp/4g3ot1258794512.ps tmp/4g3ot1258794512.png") > system("convert tmp/5mqz01258794512.ps tmp/5mqz01258794512.png") > system("convert tmp/66viq1258794512.ps tmp/66viq1258794512.png") > system("convert tmp/703y01258794512.ps tmp/703y01258794512.png") > system("convert tmp/88y9m1258794512.ps tmp/88y9m1258794512.png") > system("convert tmp/930ym1258794512.ps tmp/930ym1258794512.png") > system("convert tmp/104kf31258794512.ps tmp/104kf31258794512.png") > > > proc.time() user system elapsed 2.302 1.498 3.057