R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-pc-linux-gnu (32-bit) 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(1 + ,1 + ,4 + ,0 + ,2 + ,1 + ,1 + ,0 + ,0 + ,2 + ,0 + ,1 + ,4 + ,1 + ,1.5 + ,0 + ,0 + ,0 + ,0 + ,0 + ,1 + ,1 + ,0 + ,1 + ,1 + ,1 + ,1 + ,0 + ,1 + ,2 + ,1 + ,1 + ,0 + ,1 + ,2 + ,0 + ,1 + ,0 + ,1 + ,1 + ,0 + ,1 + ,4 + ,1 + ,2 + ,1 + ,1 + ,1 + ,0 + ,2 + ,0 + ,0 + ,4 + ,0 + ,2 + ,0 + ,1 + ,0 + ,1 + ,0 + ,0 + ,1 + ,2 + ,1 + ,0 + ,0 + ,1 + ,0 + ,0 + ,2 + ,0 + ,0 + ,0 + ,FALSE + ,FALSE + ,1 + ,1 + ,0 + ,1 + ,2 + ,1 + ,1 + ,1 + ,0 + ,2 + ,1 + ,1 + ,0 + ,1 + ,0.5 + ,0 + ,1 + ,0 + ,1 + ,2 + ,0 + ,0 + ,2 + ,1 + ,0 + ,1 + ,1 + ,2 + ,1 + ,2 + ,1 + ,1 + ,1 + ,0 + ,0 + ,0 + ,0 + ,2 + ,FALSE + ,FALSE + ,1 + ,0 + ,0 + ,FALSE + ,FALSE + ,1 + ,1 + ,3 + ,1 + ,2 + ,1 + ,0 + ,0 + ,1 + ,0 + ,1 + ,1 + ,0 + ,FALSE + ,FALSE + ,0 + ,0 + ,0 + ,FALSE + ,FALSE + ,0 + ,0 + ,1 + ,0 + ,2 + ,1 + ,1 + ,0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:105)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par3 = 'No Linear Trend' > par2 = 'Do not include Seasonal Dummies' > par1 = '1' > library(lattice) > library(lmtest) Loading required package: zoo Attaching package: 'zoo' The following object(s) are masked from 'package:base': as.Date, 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 pre post1 post2 post3 post4 1 1 1 4 0 2.0 2 1 1 0 0 2.0 3 0 1 4 1 1.5 4 0 0 0 0 0.0 5 1 1 0 1 1.0 6 1 1 0 1 2.0 7 1 1 0 1 2.0 8 0 1 0 1 1.0 9 0 1 4 1 2.0 10 1 1 1 0 2.0 11 0 0 4 0 2.0 12 0 1 0 1 0.0 13 0 1 2 1 0.0 14 0 1 0 0 2.0 15 0 0 0 0 0.0 16 1 1 0 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2.0 90 0 0 2 0 0.0 91 1 1 0 0 0.0 92 1 1 0 1 2.0 93 1 1 4 0 0.0 94 0 1 0 1 2.0 95 1 1 0 1 2.0 96 1 1 0 1 2.0 97 1 1 4 1 2.0 98 1 1 4 1 2.0 99 0 0 0 0 0.0 100 0 0 0 0 0.0 101 1 1 2 0 0.0 102 0 0 1 1 2.0 103 0 0 0 0 0.0 104 0 0 2 1 2.0 105 0 1 1 0 0.0 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) post1 post2 post3 post4 0.14340 0.36663 -0.02393 -0.04585 0.13841 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -0.78685 -0.39628 -0.09554 0.35471 0.90245 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.14340 0.09216 1.556 0.1229 post1 0.36663 0.09493 3.862 0.0002 *** post2 -0.02393 0.02867 -0.835 0.4059 post3 -0.04585 0.10583 -0.433 0.6658 post4 0.13841 0.05949 2.327 0.0220 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.4577 on 100 degrees of freedom Multiple R-squared: 0.1985, Adjusted R-squared: 0.1664 F-statistic: 6.191 on 4 and 100 DF, p-value: 0.0001714 > 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.6235076 0.7529849 0.37649244 [2,] 0.5518955 0.8962091 0.44810453 [3,] 0.4165335 0.8330670 0.58346650 [4,] 0.2940744 0.5881488 0.70592560 [5,] 0.2071615 0.4143231 0.79283845 [6,] 0.1476386 0.2952772 0.85236141 [7,] 0.5750424 0.8499152 0.42495758 [8,] 0.4787009 0.9574017 0.52129914 [9,] 0.4076275 0.8152550 0.59237252 [10,] 0.3384677 0.6769355 0.66153226 [11,] 0.4061636 0.8123272 0.59383640 [12,] 0.5463131 0.9073737 0.45368687 [13,] 0.5003447 0.9993105 0.49965527 [14,] 0.4882789 0.9765577 0.51172113 [15,] 0.5057323 0.9885354 0.49426772 [16,] 0.4309332 0.8618664 0.56906680 [17,] 0.5787194 0.8425613 0.42128063 [18,] 0.5905768 0.8188465 0.40942324 [19,] 0.7315197 0.5369607 0.26848034 [20,] 0.7131017 0.5737966 0.28689830 [21,] 0.6814652 0.6370695 0.31853477 [22,] 0.6626539 0.6746921 0.33734606 [23,] 0.6353674 0.7292653 0.36463263 [24,] 0.7072398 0.5855203 0.29276016 [25,] 0.6912110 0.6175780 0.30878899 [26,] 0.6424508 0.7150984 0.35754922 [27,] 0.5957423 0.8085155 0.40425774 [28,] 0.5406174 0.9187651 0.45938256 [29,] 0.5182261 0.9635478 0.48177391 [30,] 0.4898943 0.9797885 0.51010573 [31,] 0.5029959 0.9940082 0.49700408 [32,] 0.5519854 0.8960292 0.44801461 [33,] 0.5513104 0.8973791 0.44868957 [34,] 0.5317890 0.9364220 0.46821100 [35,] 0.5187458 0.9625083 0.48125415 [36,] 0.5125004 0.9749992 0.48749958 [37,] 0.5028156 0.9943689 0.49718443 [38,] 0.4478634 0.8957268 0.55213658 [39,] 0.4918414 0.9836828 0.50815858 [40,] 0.5415953 0.9168093 0.45840467 [41,] 0.5315201 0.9369598 0.46847989 [42,] 0.5154692 0.9690615 0.48453077 [43,] 0.4605029 0.9210059 0.53949706 [44,] 0.5367053 0.9265893 0.46329466 [45,] 0.5074357 0.9851287 0.49256435 [46,] 0.5806067 0.8387866 0.41939328 [47,] 0.5258185 0.9483630 0.47418149 [48,] 0.5498547 0.9002906 0.45014529 [49,] 0.5666997 0.8666006 0.43330029 [50,] 0.6261299 0.7477402 0.37387009 [51,] 0.6187471 0.7625058 0.38125291 [52,] 0.5751587 0.8496825 0.42484126 [53,] 0.5223056 0.9553889 0.47769443 [54,] 0.6955605 0.6088790 0.30443950 [55,] 0.6767721 0.6464558 0.32322788 [56,] 0.6438492 0.7123015 0.35615076 [57,] 0.6708987 0.6582026 0.32910132 [58,] 0.6407419 0.7185163 0.35925813 [59,] 0.6317445 0.7365111 0.36825553 [60,] 0.7438023 0.5123955 0.25619775 [61,] 0.6949489 0.6101021 0.30505106 [62,] 0.6620078 0.6759844 0.33799222 [63,] 0.6294588 0.7410824 0.37054122 [64,] 0.6337663 0.7324674 0.36623368 [65,] 0.6698102 0.6603796 0.33018981 [66,] 0.7294578 0.5410844 0.27054222 [67,] 0.7527264 0.4945471 0.24727356 [68,] 0.7025651 0.5948697 0.29743486 [69,] 0.7716343 0.4567315 0.22836575 [70,] 0.7412796 0.5174408 0.25872041 [71,] 0.6920180 0.6159640 0.30798199 [72,] 0.7919439 0.4161123 0.20805614 [73,] 0.7471613 0.5056773 0.25283866 [74,] 0.7064399 0.5871203 0.29356014 [75,] 0.6526999 0.6946002 0.34730010 [76,] 0.5974651 0.8050699 0.40253493 [77,] 0.7711505 0.4576990 0.22884948 [78,] 0.7079735 0.5840530 0.29202648 [79,] 0.6486861 0.7026279 0.35131395 [80,] 0.9054865 0.1890270 0.09451349 [81,] 0.8639621 0.2720758 0.13603789 [82,] 0.8107283 0.3785433 0.18927167 [83,] 0.7369795 0.5260410 0.26302049 [84,] 0.7165590 0.5668821 0.28344103 [85,] 0.6831917 0.6336165 0.31680827 [86,] 0.5962250 0.8075500 0.40377498 [87,] 0.8106084 0.3787832 0.18939162 [88,] 0.7148171 0.5703659 0.28518293 [89,] 0.8855647 0.2288705 0.11443526 [90,] 0.7645377 0.4709247 0.23546234 > postscript(file="/var/wessaorg/rcomp/tmp/19h061354876959.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/2fcg81354876959.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/32ce01354876959.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/4vggc1354876959.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/529261354876959.ps",horizontal=F,onefile=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 = 105 Frequency = 1 1 2 3 4 5 6 0.30886259 0.21315323 -0.57608183 -0.14339717 0.39741260 0.25900502 7 8 9 10 11 12 0.25900502 -0.60258740 -0.64528562 0.23708057 -0.32450297 -0.46417982 13 14 15 16 17 18 -0.41632514 -0.78684677 -0.14339717 0.25900502 0.23708057 0.46661639 19 20 21 22 23 24 -0.74099498 -0.04969071 0.30685970 0.51389573 -0.09554249 0.85660283 25 26 27 28 29 30 0.33078704 0.90245461 0.48996839 -0.14339717 -0.39628499 0.39741260 31 32 33 34 35 36 0.78739904 0.30886259 -0.16674918 -0.11946983 -0.16674918 0.48996839 37 38 39 40 41 42 0.30886259 -0.44025248 -0.60258740 0.35471438 0.39741260 0.35471438 43 44 45 46 47 48 0.48996839 0.46661639 -0.09754539 -0.64528562 -0.51003161 0.35156081 49 50 51 52 53 54 0.35471438 -0.11689160 -0.74099498 0.28293236 -0.74099498 -0.04768781 55 56 57 58 59 60 -0.51003161 -0.41632514 -0.53338361 -0.41432225 -0.32450297 -0.14339717 61 62 63 64 65 66 -0.46417982 0.35471438 0.39741260 0.90245461 -0.32650587 -0.64843919 67 68 69 70 71 72 -0.74099498 -0.14339717 0.49312196 0.35471438 -0.46217693 -0.51003161 73 74 75 76 77 78 -0.51003161 -0.41432225 0.25900502 0.62563945 -0.35043321 0.30685970 79 80 81 82 83 84 0.62563945 0.30685970 -0.37436055 -0.27865118 -0.27865118 0.62563945 85 86 87 88 89 90 -0.14339717 -0.27865118 0.85660283 0.35471438 -0.32650587 -0.09554249 91 92 93 94 95 96 0.48996839 0.25900502 0.58567775 -0.74099498 0.25900502 0.25900502 97 98 99 100 101 102 0.35471438 0.35471438 -0.14339717 -0.14339717 0.53782307 -0.35043321 103 104 105 -0.14339717 -0.32650587 -0.48610427 > postscript(file="/var/wessaorg/rcomp/tmp/68hvm1354876959.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > dum <- cbind(lag(myerror,k=1),myerror) > dum Time Series: Start = 0 End = 105 Frequency = 1 lag(myerror, k = 1) myerror 0 0.30886259 NA 1 0.21315323 0.30886259 2 -0.57608183 0.21315323 3 -0.14339717 -0.57608183 4 0.39741260 -0.14339717 5 0.25900502 0.39741260 6 0.25900502 0.25900502 7 -0.60258740 0.25900502 8 -0.64528562 -0.60258740 9 0.23708057 -0.64528562 10 -0.32450297 0.23708057 11 -0.46417982 -0.32450297 12 -0.41632514 -0.46417982 13 -0.78684677 -0.41632514 14 -0.14339717 -0.78684677 15 0.25900502 -0.14339717 16 0.23708057 0.25900502 17 0.46661639 0.23708057 18 -0.74099498 0.46661639 19 -0.04969071 -0.74099498 20 0.30685970 -0.04969071 21 0.51389573 0.30685970 22 -0.09554249 0.51389573 23 0.85660283 -0.09554249 24 0.33078704 0.85660283 25 0.90245461 0.33078704 26 0.48996839 0.90245461 27 -0.14339717 0.48996839 28 -0.39628499 -0.14339717 29 0.39741260 -0.39628499 30 0.78739904 0.39741260 31 0.30886259 0.78739904 32 -0.16674918 0.30886259 33 -0.11946983 -0.16674918 34 -0.16674918 -0.11946983 35 0.48996839 -0.16674918 36 0.30886259 0.48996839 37 -0.44025248 0.30886259 38 -0.60258740 -0.44025248 39 0.35471438 -0.60258740 40 0.39741260 0.35471438 41 0.35471438 0.39741260 42 0.48996839 0.35471438 43 0.46661639 0.48996839 44 -0.09754539 0.46661639 45 -0.64528562 -0.09754539 46 -0.51003161 -0.64528562 47 0.35156081 -0.51003161 48 0.35471438 0.35156081 49 -0.11689160 0.35471438 50 -0.74099498 -0.11689160 51 0.28293236 -0.74099498 52 -0.74099498 0.28293236 53 -0.04768781 -0.74099498 54 -0.51003161 -0.04768781 55 -0.41632514 -0.51003161 56 -0.53338361 -0.41632514 57 -0.41432225 -0.53338361 58 -0.32450297 -0.41432225 59 -0.14339717 -0.32450297 60 -0.46417982 -0.14339717 61 0.35471438 -0.46417982 62 0.39741260 0.35471438 63 0.90245461 0.39741260 64 -0.32650587 0.90245461 65 -0.64843919 -0.32650587 66 -0.74099498 -0.64843919 67 -0.14339717 -0.74099498 68 0.49312196 -0.14339717 69 0.35471438 0.49312196 70 -0.46217693 0.35471438 71 -0.51003161 -0.46217693 72 -0.51003161 -0.51003161 73 -0.41432225 -0.51003161 74 0.25900502 -0.41432225 75 0.62563945 0.25900502 76 -0.35043321 0.62563945 77 0.30685970 -0.35043321 78 0.62563945 0.30685970 79 0.30685970 0.62563945 80 -0.37436055 0.30685970 81 -0.27865118 -0.37436055 82 -0.27865118 -0.27865118 83 0.62563945 -0.27865118 84 -0.14339717 0.62563945 85 -0.27865118 -0.14339717 86 0.85660283 -0.27865118 87 0.35471438 0.85660283 88 -0.32650587 0.35471438 89 -0.09554249 -0.32650587 90 0.48996839 -0.09554249 91 0.25900502 0.48996839 92 0.58567775 0.25900502 93 -0.74099498 0.58567775 94 0.25900502 -0.74099498 95 0.25900502 0.25900502 96 0.35471438 0.25900502 97 0.35471438 0.35471438 98 -0.14339717 0.35471438 99 -0.14339717 -0.14339717 100 0.53782307 -0.14339717 101 -0.35043321 0.53782307 102 -0.14339717 -0.35043321 103 -0.32650587 -0.14339717 104 -0.48610427 -0.32650587 105 NA -0.48610427 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 0.21315323 0.30886259 [2,] -0.57608183 0.21315323 [3,] -0.14339717 -0.57608183 [4,] 0.39741260 -0.14339717 [5,] 0.25900502 0.39741260 [6,] 0.25900502 0.25900502 [7,] -0.60258740 0.25900502 [8,] -0.64528562 -0.60258740 [9,] 0.23708057 -0.64528562 [10,] -0.32450297 0.23708057 [11,] -0.46417982 -0.32450297 [12,] -0.41632514 -0.46417982 [13,] -0.78684677 -0.41632514 [14,] -0.14339717 -0.78684677 [15,] 0.25900502 -0.14339717 [16,] 0.23708057 0.25900502 [17,] 0.46661639 0.23708057 [18,] -0.74099498 0.46661639 [19,] -0.04969071 -0.74099498 [20,] 0.30685970 -0.04969071 [21,] 0.51389573 0.30685970 [22,] -0.09554249 0.51389573 [23,] 0.85660283 -0.09554249 [24,] 0.33078704 0.85660283 [25,] 0.90245461 0.33078704 [26,] 0.48996839 0.90245461 [27,] -0.14339717 0.48996839 [28,] -0.39628499 -0.14339717 [29,] 0.39741260 -0.39628499 [30,] 0.78739904 0.39741260 [31,] 0.30886259 0.78739904 [32,] -0.16674918 0.30886259 [33,] -0.11946983 -0.16674918 [34,] -0.16674918 -0.11946983 [35,] 0.48996839 -0.16674918 [36,] 0.30886259 0.48996839 [37,] -0.44025248 0.30886259 [38,] -0.60258740 -0.44025248 [39,] 0.35471438 -0.60258740 [40,] 0.39741260 0.35471438 [41,] 0.35471438 0.39741260 [42,] 0.48996839 0.35471438 [43,] 0.46661639 0.48996839 [44,] -0.09754539 0.46661639 [45,] -0.64528562 -0.09754539 [46,] -0.51003161 -0.64528562 [47,] 0.35156081 -0.51003161 [48,] 0.35471438 0.35156081 [49,] -0.11689160 0.35471438 [50,] -0.74099498 -0.11689160 [51,] 0.28293236 -0.74099498 [52,] -0.74099498 0.28293236 [53,] -0.04768781 -0.74099498 [54,] -0.51003161 -0.04768781 [55,] -0.41632514 -0.51003161 [56,] -0.53338361 -0.41632514 [57,] -0.41432225 -0.53338361 [58,] -0.32450297 -0.41432225 [59,] -0.14339717 -0.32450297 [60,] -0.46417982 -0.14339717 [61,] 0.35471438 -0.46417982 [62,] 0.39741260 0.35471438 [63,] 0.90245461 0.39741260 [64,] -0.32650587 0.90245461 [65,] -0.64843919 -0.32650587 [66,] -0.74099498 -0.64843919 [67,] -0.14339717 -0.74099498 [68,] 0.49312196 -0.14339717 [69,] 0.35471438 0.49312196 [70,] -0.46217693 0.35471438 [71,] -0.51003161 -0.46217693 [72,] -0.51003161 -0.51003161 [73,] -0.41432225 -0.51003161 [74,] 0.25900502 -0.41432225 [75,] 0.62563945 0.25900502 [76,] -0.35043321 0.62563945 [77,] 0.30685970 -0.35043321 [78,] 0.62563945 0.30685970 [79,] 0.30685970 0.62563945 [80,] -0.37436055 0.30685970 [81,] -0.27865118 -0.37436055 [82,] -0.27865118 -0.27865118 [83,] 0.62563945 -0.27865118 [84,] -0.14339717 0.62563945 [85,] -0.27865118 -0.14339717 [86,] 0.85660283 -0.27865118 [87,] 0.35471438 0.85660283 [88,] -0.32650587 0.35471438 [89,] -0.09554249 -0.32650587 [90,] 0.48996839 -0.09554249 [91,] 0.25900502 0.48996839 [92,] 0.58567775 0.25900502 [93,] -0.74099498 0.58567775 [94,] 0.25900502 -0.74099498 [95,] 0.25900502 0.25900502 [96,] 0.35471438 0.25900502 [97,] 0.35471438 0.35471438 [98,] -0.14339717 0.35471438 [99,] -0.14339717 -0.14339717 [100,] 0.53782307 -0.14339717 [101,] -0.35043321 0.53782307 [102,] -0.14339717 -0.35043321 [103,] -0.32650587 -0.14339717 [104,] -0.48610427 -0.32650587 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 0.21315323 0.30886259 2 -0.57608183 0.21315323 3 -0.14339717 -0.57608183 4 0.39741260 -0.14339717 5 0.25900502 0.39741260 6 0.25900502 0.25900502 7 -0.60258740 0.25900502 8 -0.64528562 -0.60258740 9 0.23708057 -0.64528562 10 -0.32450297 0.23708057 11 -0.46417982 -0.32450297 12 -0.41632514 -0.46417982 13 -0.78684677 -0.41632514 14 -0.14339717 -0.78684677 15 0.25900502 -0.14339717 16 0.23708057 0.25900502 17 0.46661639 0.23708057 18 -0.74099498 0.46661639 19 -0.04969071 -0.74099498 20 0.30685970 -0.04969071 21 0.51389573 0.30685970 22 -0.09554249 0.51389573 23 0.85660283 -0.09554249 24 0.33078704 0.85660283 25 0.90245461 0.33078704 26 0.48996839 0.90245461 27 -0.14339717 0.48996839 28 -0.39628499 -0.14339717 29 0.39741260 -0.39628499 30 0.78739904 0.39741260 31 0.30886259 0.78739904 32 -0.16674918 0.30886259 33 -0.11946983 -0.16674918 34 -0.16674918 -0.11946983 35 0.48996839 -0.16674918 36 0.30886259 0.48996839 37 -0.44025248 0.30886259 38 -0.60258740 -0.44025248 39 0.35471438 -0.60258740 40 0.39741260 0.35471438 41 0.35471438 0.39741260 42 0.48996839 0.35471438 43 0.46661639 0.48996839 44 -0.09754539 0.46661639 45 -0.64528562 -0.09754539 46 -0.51003161 -0.64528562 47 0.35156081 -0.51003161 48 0.35471438 0.35156081 49 -0.11689160 0.35471438 50 -0.74099498 -0.11689160 51 0.28293236 -0.74099498 52 -0.74099498 0.28293236 53 -0.04768781 -0.74099498 54 -0.51003161 -0.04768781 55 -0.41632514 -0.51003161 56 -0.53338361 -0.41632514 57 -0.41432225 -0.53338361 58 -0.32450297 -0.41432225 59 -0.14339717 -0.32450297 60 -0.46417982 -0.14339717 61 0.35471438 -0.46417982 62 0.39741260 0.35471438 63 0.90245461 0.39741260 64 -0.32650587 0.90245461 65 -0.64843919 -0.32650587 66 -0.74099498 -0.64843919 67 -0.14339717 -0.74099498 68 0.49312196 -0.14339717 69 0.35471438 0.49312196 70 -0.46217693 0.35471438 71 -0.51003161 -0.46217693 72 -0.51003161 -0.51003161 73 -0.41432225 -0.51003161 74 0.25900502 -0.41432225 75 0.62563945 0.25900502 76 -0.35043321 0.62563945 77 0.30685970 -0.35043321 78 0.62563945 0.30685970 79 0.30685970 0.62563945 80 -0.37436055 0.30685970 81 -0.27865118 -0.37436055 82 -0.27865118 -0.27865118 83 0.62563945 -0.27865118 84 -0.14339717 0.62563945 85 -0.27865118 -0.14339717 86 0.85660283 -0.27865118 87 0.35471438 0.85660283 88 -0.32650587 0.35471438 89 -0.09554249 -0.32650587 90 0.48996839 -0.09554249 91 0.25900502 0.48996839 92 0.58567775 0.25900502 93 -0.74099498 0.58567775 94 0.25900502 -0.74099498 95 0.25900502 0.25900502 96 0.35471438 0.25900502 97 0.35471438 0.35471438 98 -0.14339717 0.35471438 99 -0.14339717 -0.14339717 100 0.53782307 -0.14339717 101 -0.35043321 0.53782307 102 -0.14339717 -0.35043321 103 -0.32650587 -0.14339717 104 -0.48610427 -0.32650587 > 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/wessaorg/rcomp/tmp/7tbrx1354876959.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/82po51354876959.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/9j7391354876959.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/10rjsj1354876959.ps",horizontal=F,onefile=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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/11lmy31354876959.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/wessaorg/rcomp/tmp/12xw6s1354876959.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/wessaorg/rcomp/tmp/138a4q1354876959.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/wessaorg/rcomp/tmp/14qsrv1354876959.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/wessaorg/rcomp/tmp/15fmj41354876959.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/wessaorg/rcomp/tmp/16l1sq1354876959.tab") + } > > try(system("convert tmp/19h061354876959.ps tmp/19h061354876959.png",intern=TRUE)) character(0) > try(system("convert tmp/2fcg81354876959.ps tmp/2fcg81354876959.png",intern=TRUE)) character(0) > try(system("convert tmp/32ce01354876959.ps tmp/32ce01354876959.png",intern=TRUE)) character(0) > try(system("convert tmp/4vggc1354876959.ps tmp/4vggc1354876959.png",intern=TRUE)) character(0) > try(system("convert tmp/529261354876959.ps tmp/529261354876959.png",intern=TRUE)) character(0) > try(system("convert tmp/68hvm1354876959.ps tmp/68hvm1354876959.png",intern=TRUE)) character(0) > try(system("convert tmp/7tbrx1354876959.ps tmp/7tbrx1354876959.png",intern=TRUE)) character(0) > try(system("convert tmp/82po51354876959.ps tmp/82po51354876959.png",intern=TRUE)) character(0) > try(system("convert tmp/9j7391354876959.ps tmp/9j7391354876959.png",intern=TRUE)) character(0) > try(system("convert tmp/10rjsj1354876959.ps tmp/10rjsj1354876959.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 6.434 0.977 7.400