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(106.2 + ,431 + ,436 + ,460 + ,467 + ,81 + ,484 + ,431 + ,448 + ,460 + ,94.7 + ,510 + ,484 + ,443 + ,448 + ,101 + ,513 + ,510 + ,436 + ,443 + ,109.4 + ,503 + ,513 + ,431 + ,436 + ,102.3 + ,471 + ,503 + ,484 + ,431 + ,90.7 + ,471 + ,471 + ,510 + ,484 + ,96.2 + ,476 + ,471 + ,513 + ,510 + ,96.1 + ,475 + ,476 + ,503 + ,513 + ,106 + ,470 + ,475 + ,471 + ,503 + ,103.1 + ,461 + ,470 + ,471 + ,471 + ,102 + ,455 + ,461 + ,476 + ,471 + ,104.7 + ,456 + ,455 + ,475 + ,476 + ,86 + ,517 + ,456 + ,470 + ,475 + ,92.1 + ,525 + ,517 + ,461 + ,470 + ,106.9 + ,523 + ,525 + ,455 + ,461 + ,112.6 + ,519 + ,523 + ,456 + ,455 + ,101.7 + ,509 + ,519 + ,517 + ,456 + ,92 + ,512 + ,509 + ,525 + ,517 + ,97.4 + ,519 + ,512 + ,523 + ,525 + ,97 + ,517 + ,519 + ,519 + ,523 + ,105.4 + ,510 + ,517 + ,509 + ,519 + ,102.7 + ,509 + ,510 + ,512 + ,509 + ,98.1 + ,501 + ,509 + ,519 + ,512 + ,104.5 + ,507 + ,501 + ,517 + ,519 + ,87.4 + ,569 + ,507 + ,510 + ,517 + ,89.9 + ,580 + ,569 + ,509 + ,510 + ,109.8 + ,578 + ,580 + ,501 + ,509 + ,111.7 + ,565 + ,578 + ,507 + ,501 + ,98.6 + ,547 + ,565 + ,569 + ,507 + ,96.9 + ,555 + ,547 + ,580 + ,569 + ,95.1 + ,562 + ,555 + ,578 + ,580 + ,97 + ,561 + ,562 + ,565 + ,578 + ,112.7 + ,555 + ,561 + ,547 + ,565 + ,102.9 + ,544 + ,555 + ,555 + ,547 + ,97.4 + ,537 + ,544 + ,562 + ,555 + ,111.4 + ,543 + ,537 + ,561 + ,562 + ,87.4 + ,594 + ,543 + ,555 + ,561 + ,96.8 + ,611 + ,594 + ,544 + ,555 + ,114.1 + ,613 + ,611 + ,537 + ,544 + ,110.3 + ,611 + ,613 + ,543 + ,537 + ,103.9 + ,594 + ,611 + ,594 + ,543 + ,101.6 + ,595 + ,594 + ,611 + ,594 + ,94.6 + ,591 + ,595 + ,613 + ,611 + ,95.9 + ,589 + ,591 + ,611 + ,613 + ,104.7 + ,584 + ,589 + ,594 + ,611 + ,102.8 + ,573 + ,584 + ,595 + ,594 + ,98.1 + ,567 + ,573 + ,591 + ,595 + ,113.9 + ,569 + ,567 + ,589 + ,591 + ,80.9 + ,621 + ,569 + ,584 + ,589 + ,95.7 + ,629 + ,621 + ,573 + ,584 + ,113.2 + ,628 + ,629 + ,567 + ,573 + ,105.9 + ,612 + ,628 + ,569 + ,567 + ,108.8 + ,595 + ,612 + ,621 + ,569 + ,102.3 + ,597 + ,595 + ,629 + ,621 + ,99 + ,593 + ,597 + ,628 + ,629 + ,100.7 + ,590 + ,593 + ,612 + ,628 + ,115.5 + ,580 + ,590 + ,595 + ,612 + ,100.7 + ,574 + ,580 + ,597 + ,595 + ,109.9 + ,573 + ,574 + ,593 + ,597 + ,114.6 + ,573 + ,573 + ,590 + ,593 + ,85.4 + ,620 + ,573 + ,580 + ,590 + ,100.5 + ,626 + ,620 + ,574 + ,580 + ,114.8 + ,620 + ,626 + ,573 + ,574 + ,116.5 + ,588 + ,620 + ,573 + ,573 + ,112.9 + ,566 + ,588 + ,620 + ,573 + ,102 + ,557 + ,566 + ,626 + ,620) + ,dim=c(5 + ,67) + ,dimnames=list(c('X' + ,'Y' + ,'Y(t-1)' + ,'Y(t-4)' + ,'Y(t-5)') + ,1:67)) > y <- array(NA,dim=c(5,67),dimnames=list(c('X','Y','Y(t-1)','Y(t-4)','Y(t-5)'),1:67)) > 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 = '2' > #'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(t-1) Y(t-4) Y(t-5) M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 431 106.2 436 460 467 1 0 0 0 0 0 0 0 0 0 0 1 2 484 81.0 431 448 460 0 1 0 0 0 0 0 0 0 0 0 2 3 510 94.7 484 443 448 0 0 1 0 0 0 0 0 0 0 0 3 4 513 101.0 510 436 443 0 0 0 1 0 0 0 0 0 0 0 4 5 503 109.4 513 431 436 0 0 0 0 1 0 0 0 0 0 0 5 6 471 102.3 503 484 431 0 0 0 0 0 1 0 0 0 0 0 6 7 471 90.7 471 510 484 0 0 0 0 0 0 1 0 0 0 0 7 8 476 96.2 471 513 510 0 0 0 0 0 0 0 1 0 0 0 8 9 475 96.1 476 503 513 0 0 0 0 0 0 0 0 1 0 0 9 10 470 106.0 475 471 503 0 0 0 0 0 0 0 0 0 1 0 10 11 461 103.1 470 471 471 0 0 0 0 0 0 0 0 0 0 1 11 12 455 102.0 461 476 471 0 0 0 0 0 0 0 0 0 0 0 12 13 456 104.7 455 475 476 1 0 0 0 0 0 0 0 0 0 0 13 14 517 86.0 456 470 475 0 1 0 0 0 0 0 0 0 0 0 14 15 525 92.1 517 461 470 0 0 1 0 0 0 0 0 0 0 0 15 16 523 106.9 525 455 461 0 0 0 1 0 0 0 0 0 0 0 16 17 519 112.6 523 456 455 0 0 0 0 1 0 0 0 0 0 0 17 18 509 101.7 519 517 456 0 0 0 0 0 1 0 0 0 0 0 18 19 512 92.0 509 525 517 0 0 0 0 0 0 1 0 0 0 0 19 20 519 97.4 512 523 525 0 0 0 0 0 0 0 1 0 0 0 20 21 517 97.0 519 519 523 0 0 0 0 0 0 0 0 1 0 0 21 22 510 105.4 517 509 519 0 0 0 0 0 0 0 0 0 1 0 22 23 509 102.7 510 512 509 0 0 0 0 0 0 0 0 0 0 1 23 24 501 98.1 509 519 512 0 0 0 0 0 0 0 0 0 0 0 24 25 507 104.5 501 517 519 1 0 0 0 0 0 0 0 0 0 0 25 26 569 87.4 507 510 517 0 1 0 0 0 0 0 0 0 0 0 26 27 580 89.9 569 509 510 0 0 1 0 0 0 0 0 0 0 0 27 28 578 109.8 580 501 509 0 0 0 1 0 0 0 0 0 0 0 28 29 565 111.7 578 507 501 0 0 0 0 1 0 0 0 0 0 0 29 30 547 98.6 565 569 507 0 0 0 0 0 1 0 0 0 0 0 30 31 555 96.9 547 580 569 0 0 0 0 0 0 1 0 0 0 0 31 32 562 95.1 555 578 580 0 0 0 0 0 0 0 1 0 0 0 32 33 561 97.0 562 565 578 0 0 0 0 0 0 0 0 1 0 0 33 34 555 112.7 561 547 565 0 0 0 0 0 0 0 0 0 1 0 34 35 544 102.9 555 555 547 0 0 0 0 0 0 0 0 0 0 1 35 36 537 97.4 544 562 555 0 0 0 0 0 0 0 0 0 0 0 36 37 543 111.4 537 561 562 1 0 0 0 0 0 0 0 0 0 0 37 38 594 87.4 543 555 561 0 1 0 0 0 0 0 0 0 0 0 38 39 611 96.8 594 544 555 0 0 1 0 0 0 0 0 0 0 0 39 40 613 114.1 611 537 544 0 0 0 1 0 0 0 0 0 0 0 40 41 611 110.3 613 543 537 0 0 0 0 1 0 0 0 0 0 0 41 42 594 103.9 611 594 543 0 0 0 0 0 1 0 0 0 0 0 42 43 595 101.6 594 611 594 0 0 0 0 0 0 1 0 0 0 0 43 44 591 94.6 595 613 611 0 0 0 0 0 0 0 1 0 0 0 44 45 589 95.9 591 611 613 0 0 0 0 0 0 0 0 1 0 0 45 46 584 104.7 589 594 611 0 0 0 0 0 0 0 0 0 1 0 46 47 573 102.8 584 595 594 0 0 0 0 0 0 0 0 0 0 1 47 48 567 98.1 573 591 595 0 0 0 0 0 0 0 0 0 0 0 48 49 569 113.9 567 589 591 1 0 0 0 0 0 0 0 0 0 0 49 50 621 80.9 569 584 589 0 1 0 0 0 0 0 0 0 0 0 50 51 629 95.7 621 573 584 0 0 1 0 0 0 0 0 0 0 0 51 52 628 113.2 629 567 573 0 0 0 1 0 0 0 0 0 0 0 52 53 612 105.9 628 569 567 0 0 0 0 1 0 0 0 0 0 0 53 54 595 108.8 612 621 569 0 0 0 0 0 1 0 0 0 0 0 54 55 597 102.3 595 629 621 0 0 0 0 0 0 1 0 0 0 0 55 56 593 99.0 597 628 629 0 0 0 0 0 0 0 1 0 0 0 56 57 590 100.7 593 612 628 0 0 0 0 0 0 0 0 1 0 0 57 58 580 115.5 590 595 612 0 0 0 0 0 0 0 0 0 1 0 58 59 574 100.7 580 597 595 0 0 0 0 0 0 0 0 0 0 1 59 60 573 109.9 574 593 597 0 0 0 0 0 0 0 0 0 0 0 60 61 573 114.6 573 590 593 1 0 0 0 0 0 0 0 0 0 0 61 62 620 85.4 573 580 590 0 1 0 0 0 0 0 0 0 0 0 62 63 626 100.5 620 574 580 0 0 1 0 0 0 0 0 0 0 0 63 64 620 114.8 626 573 574 0 0 0 1 0 0 0 0 0 0 0 64 65 588 116.5 620 573 573 0 0 0 0 1 0 0 0 0 0 0 65 66 566 112.9 588 620 573 0 0 0 0 0 1 0 0 0 0 0 66 67 557 102.0 566 626 620 0 0 0 0 0 0 1 0 0 0 0 67 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X `Y(t-1)` `Y(t-4)` `Y(t-5)` M1 -99.756682 0.382756 1.023540 0.104099 0.005104 4.041204 M2 M3 M4 M5 M6 M7 67.323331 21.702405 3.103729 -8.800759 -17.756279 4.463578 M8 M9 M10 M11 t 4.869827 1.888165 -4.805750 -2.918548 -0.470059 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -15.2473 -2.5617 -0.2233 2.5754 9.9149 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -99.756682 41.611218 -2.397 0.02029 * X 0.382756 0.240011 1.595 0.11707 `Y(t-1)` 1.023540 0.074896 13.666 < 2e-16 *** `Y(t-4)` 0.104099 0.174031 0.598 0.55243 `Y(t-5)` 0.005104 0.159946 0.032 0.97467 M1 4.041204 3.873252 1.043 0.30180 M2 67.323331 5.603693 12.014 2.36e-16 *** M3 21.702405 6.548458 3.314 0.00172 ** M4 3.103729 7.725819 0.402 0.68959 M5 -8.800759 7.692180 -1.144 0.25802 M6 -17.756279 9.010969 -1.971 0.05433 . M7 4.463578 4.085768 1.092 0.27986 M8 4.869827 4.134005 1.178 0.24438 M9 1.888165 4.263069 0.443 0.65974 M10 -4.805750 5.161882 -0.931 0.35632 M11 -2.918548 3.500481 -0.834 0.40838 t -0.470059 0.172063 -2.732 0.00868 ** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 5.381 on 50 degrees of freedom Multiple R-squared: 0.9915, Adjusted R-squared: 0.9888 F-statistic: 363.9 on 16 and 50 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.9910311 0.01793782 0.00896891 [2,] 0.9804807 0.03903852 0.01951926 [3,] 0.9799652 0.04006960 0.02003480 [4,] 0.9631254 0.07374920 0.03687460 [5,] 0.9472837 0.10543251 0.05271625 [6,] 0.9137580 0.17248393 0.08624196 [7,] 0.8902891 0.21942175 0.10971087 [8,] 0.8726307 0.25473863 0.12736931 [9,] 0.8655235 0.26895300 0.13447650 [10,] 0.8574054 0.28518930 0.14259465 [11,] 0.7978452 0.40430956 0.20215478 [12,] 0.7410274 0.51794523 0.25897262 [13,] 0.7158319 0.56833619 0.28416810 [14,] 0.6308183 0.73836346 0.36918173 [15,] 0.5428664 0.91426719 0.45713359 [16,] 0.5341598 0.93168042 0.46584021 [17,] 0.5321923 0.93561530 0.46780765 [18,] 0.4328330 0.86566608 0.56716696 [19,] 0.4626849 0.92536975 0.53731512 [20,] 0.3693018 0.73860366 0.63069817 [21,] 0.2869743 0.57394868 0.71302566 [22,] 0.8020598 0.39588040 0.19794020 [23,] 0.7217725 0.55645496 0.27822748 [24,] 0.6093160 0.78136793 0.39068397 [25,] 0.5428563 0.91428735 0.45714368 [26,] 0.4349576 0.86991516 0.56504242 [27,] 0.2987467 0.59749342 0.70125329 [28,] 0.3335033 0.66700666 0.66649667 > postscript(file="/var/www/html/rcomp/tmp/1xgyk1260894021.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/2gkbj1260894021.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/3y2o81260894021.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/40eum1260894021.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/53a9d1260894021.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 = 67 Frequency = 1 1 2 3 4 5 6 -9.99598625 -3.75998290 9.42136337 3.22090672 -0.13409022 -15.24727185 7 8 9 10 11 12 -2.78092245 -0.26728067 -1.86930629 0.91113872 -3.11497164 -2.45106211 13 14 15 16 17 18 0.16417071 5.01169930 -4.70566455 -0.81950541 7.34694075 8.68357180 19 20 21 22 23 24 2.73774981 4.83142053 -0.30193148 -0.24461865 5.27520705 -3.13307022 25 26 27 28 29 30 5.20693624 5.53765692 -1.64790969 -2.61706320 -2.50643113 0.75450383 31 32 33 34 35 36 4.61755383 4.33405360 0.25725474 -1.62435924 -4.89016696 -1.74408380 37 38 39 40 41 42 2.55933797 -5.57812858 2.89011722 0.72183260 9.91490865 1.49752668 43 44 45 46 47 48 -3.00175661 -5.57716703 -0.33087782 2.29181760 -4.29771315 0.72298580 49 50 51 52 53 54 -0.52584636 -0.22334315 -3.85062416 0.01230256 0.02693712 2.29580543 55 56 57 58 59 60 1.33588479 -3.32102643 2.24486085 -1.33397843 7.02764470 6.60523034 61 62 63 64 65 66 2.59138769 -0.98790159 -2.10728220 -0.51847327 -14.64826516 2.01586411 67 -2.90850937 > postscript(file="/var/www/html/rcomp/tmp/679qg1260894021.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 = 67 Frequency = 1 lag(myerror, k = 1) myerror 0 -9.99598625 NA 1 -3.75998290 -9.99598625 2 9.42136337 -3.75998290 3 3.22090672 9.42136337 4 -0.13409022 3.22090672 5 -15.24727185 -0.13409022 6 -2.78092245 -15.24727185 7 -0.26728067 -2.78092245 8 -1.86930629 -0.26728067 9 0.91113872 -1.86930629 10 -3.11497164 0.91113872 11 -2.45106211 -3.11497164 12 0.16417071 -2.45106211 13 5.01169930 0.16417071 14 -4.70566455 5.01169930 15 -0.81950541 -4.70566455 16 7.34694075 -0.81950541 17 8.68357180 7.34694075 18 2.73774981 8.68357180 19 4.83142053 2.73774981 20 -0.30193148 4.83142053 21 -0.24461865 -0.30193148 22 5.27520705 -0.24461865 23 -3.13307022 5.27520705 24 5.20693624 -3.13307022 25 5.53765692 5.20693624 26 -1.64790969 5.53765692 27 -2.61706320 -1.64790969 28 -2.50643113 -2.61706320 29 0.75450383 -2.50643113 30 4.61755383 0.75450383 31 4.33405360 4.61755383 32 0.25725474 4.33405360 33 -1.62435924 0.25725474 34 -4.89016696 -1.62435924 35 -1.74408380 -4.89016696 36 2.55933797 -1.74408380 37 -5.57812858 2.55933797 38 2.89011722 -5.57812858 39 0.72183260 2.89011722 40 9.91490865 0.72183260 41 1.49752668 9.91490865 42 -3.00175661 1.49752668 43 -5.57716703 -3.00175661 44 -0.33087782 -5.57716703 45 2.29181760 -0.33087782 46 -4.29771315 2.29181760 47 0.72298580 -4.29771315 48 -0.52584636 0.72298580 49 -0.22334315 -0.52584636 50 -3.85062416 -0.22334315 51 0.01230256 -3.85062416 52 0.02693712 0.01230256 53 2.29580543 0.02693712 54 1.33588479 2.29580543 55 -3.32102643 1.33588479 56 2.24486085 -3.32102643 57 -1.33397843 2.24486085 58 7.02764470 -1.33397843 59 6.60523034 7.02764470 60 2.59138769 6.60523034 61 -0.98790159 2.59138769 62 -2.10728220 -0.98790159 63 -0.51847327 -2.10728220 64 -14.64826516 -0.51847327 65 2.01586411 -14.64826516 66 -2.90850937 2.01586411 67 NA -2.90850937 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -3.75998290 -9.99598625 [2,] 9.42136337 -3.75998290 [3,] 3.22090672 9.42136337 [4,] -0.13409022 3.22090672 [5,] -15.24727185 -0.13409022 [6,] -2.78092245 -15.24727185 [7,] -0.26728067 -2.78092245 [8,] -1.86930629 -0.26728067 [9,] 0.91113872 -1.86930629 [10,] -3.11497164 0.91113872 [11,] -2.45106211 -3.11497164 [12,] 0.16417071 -2.45106211 [13,] 5.01169930 0.16417071 [14,] -4.70566455 5.01169930 [15,] -0.81950541 -4.70566455 [16,] 7.34694075 -0.81950541 [17,] 8.68357180 7.34694075 [18,] 2.73774981 8.68357180 [19,] 4.83142053 2.73774981 [20,] -0.30193148 4.83142053 [21,] -0.24461865 -0.30193148 [22,] 5.27520705 -0.24461865 [23,] -3.13307022 5.27520705 [24,] 5.20693624 -3.13307022 [25,] 5.53765692 5.20693624 [26,] -1.64790969 5.53765692 [27,] -2.61706320 -1.64790969 [28,] -2.50643113 -2.61706320 [29,] 0.75450383 -2.50643113 [30,] 4.61755383 0.75450383 [31,] 4.33405360 4.61755383 [32,] 0.25725474 4.33405360 [33,] -1.62435924 0.25725474 [34,] -4.89016696 -1.62435924 [35,] -1.74408380 -4.89016696 [36,] 2.55933797 -1.74408380 [37,] -5.57812858 2.55933797 [38,] 2.89011722 -5.57812858 [39,] 0.72183260 2.89011722 [40,] 9.91490865 0.72183260 [41,] 1.49752668 9.91490865 [42,] -3.00175661 1.49752668 [43,] -5.57716703 -3.00175661 [44,] -0.33087782 -5.57716703 [45,] 2.29181760 -0.33087782 [46,] -4.29771315 2.29181760 [47,] 0.72298580 -4.29771315 [48,] -0.52584636 0.72298580 [49,] -0.22334315 -0.52584636 [50,] -3.85062416 -0.22334315 [51,] 0.01230256 -3.85062416 [52,] 0.02693712 0.01230256 [53,] 2.29580543 0.02693712 [54,] 1.33588479 2.29580543 [55,] -3.32102643 1.33588479 [56,] 2.24486085 -3.32102643 [57,] -1.33397843 2.24486085 [58,] 7.02764470 -1.33397843 [59,] 6.60523034 7.02764470 [60,] 2.59138769 6.60523034 [61,] -0.98790159 2.59138769 [62,] -2.10728220 -0.98790159 [63,] -0.51847327 -2.10728220 [64,] -14.64826516 -0.51847327 [65,] 2.01586411 -14.64826516 [66,] -2.90850937 2.01586411 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -3.75998290 -9.99598625 2 9.42136337 -3.75998290 3 3.22090672 9.42136337 4 -0.13409022 3.22090672 5 -15.24727185 -0.13409022 6 -2.78092245 -15.24727185 7 -0.26728067 -2.78092245 8 -1.86930629 -0.26728067 9 0.91113872 -1.86930629 10 -3.11497164 0.91113872 11 -2.45106211 -3.11497164 12 0.16417071 -2.45106211 13 5.01169930 0.16417071 14 -4.70566455 5.01169930 15 -0.81950541 -4.70566455 16 7.34694075 -0.81950541 17 8.68357180 7.34694075 18 2.73774981 8.68357180 19 4.83142053 2.73774981 20 -0.30193148 4.83142053 21 -0.24461865 -0.30193148 22 5.27520705 -0.24461865 23 -3.13307022 5.27520705 24 5.20693624 -3.13307022 25 5.53765692 5.20693624 26 -1.64790969 5.53765692 27 -2.61706320 -1.64790969 28 -2.50643113 -2.61706320 29 0.75450383 -2.50643113 30 4.61755383 0.75450383 31 4.33405360 4.61755383 32 0.25725474 4.33405360 33 -1.62435924 0.25725474 34 -4.89016696 -1.62435924 35 -1.74408380 -4.89016696 36 2.55933797 -1.74408380 37 -5.57812858 2.55933797 38 2.89011722 -5.57812858 39 0.72183260 2.89011722 40 9.91490865 0.72183260 41 1.49752668 9.91490865 42 -3.00175661 1.49752668 43 -5.57716703 -3.00175661 44 -0.33087782 -5.57716703 45 2.29181760 -0.33087782 46 -4.29771315 2.29181760 47 0.72298580 -4.29771315 48 -0.52584636 0.72298580 49 -0.22334315 -0.52584636 50 -3.85062416 -0.22334315 51 0.01230256 -3.85062416 52 0.02693712 0.01230256 53 2.29580543 0.02693712 54 1.33588479 2.29580543 55 -3.32102643 1.33588479 56 2.24486085 -3.32102643 57 -1.33397843 2.24486085 58 7.02764470 -1.33397843 59 6.60523034 7.02764470 60 2.59138769 6.60523034 61 -0.98790159 2.59138769 62 -2.10728220 -0.98790159 63 -0.51847327 -2.10728220 64 -14.64826516 -0.51847327 65 2.01586411 -14.64826516 66 -2.90850937 2.01586411 > 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/7r4js1260894021.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/8z8ob1260894021.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/9297g1260894021.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/10twcr1260894021.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/115qka1260894021.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/12ff731260894021.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/13pbrh1260894021.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/14kzz81260894021.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/15r22h1260894021.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/160eij1260894021.tab") + } > > try(system("convert tmp/1xgyk1260894021.ps tmp/1xgyk1260894021.png",intern=TRUE)) character(0) > try(system("convert tmp/2gkbj1260894021.ps tmp/2gkbj1260894021.png",intern=TRUE)) character(0) > try(system("convert tmp/3y2o81260894021.ps tmp/3y2o81260894021.png",intern=TRUE)) character(0) > try(system("convert tmp/40eum1260894021.ps tmp/40eum1260894021.png",intern=TRUE)) character(0) > try(system("convert tmp/53a9d1260894021.ps tmp/53a9d1260894021.png",intern=TRUE)) character(0) > try(system("convert tmp/679qg1260894021.ps tmp/679qg1260894021.png",intern=TRUE)) character(0) > try(system("convert tmp/7r4js1260894021.ps tmp/7r4js1260894021.png",intern=TRUE)) character(0) > try(system("convert tmp/8z8ob1260894021.ps tmp/8z8ob1260894021.png",intern=TRUE)) character(0) > try(system("convert tmp/9297g1260894021.ps tmp/9297g1260894021.png",intern=TRUE)) character(0) > try(system("convert tmp/10twcr1260894021.ps tmp/10twcr1260894021.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.532 1.588 3.328