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 = '5' > 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 post4 pre post1 post2 post3 1 2.0 1 1 4 0 2 2.0 1 1 0 0 3 1.5 0 1 4 1 4 0.0 0 0 0 0 5 1.0 1 1 0 1 6 2.0 1 1 0 1 7 2.0 1 1 0 1 8 1.0 0 1 0 1 9 2.0 0 1 4 1 10 2.0 1 1 1 0 11 2.0 0 0 4 0 12 0.0 0 1 0 1 13 0.0 0 1 2 1 14 2.0 0 1 0 0 15 0.0 0 0 0 0 16 2.0 1 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2 1 90 0.0 0 0 2 0 91 0.0 1 1 0 0 92 2.0 1 1 0 1 93 0.0 1 1 4 0 94 2.0 0 1 0 1 95 2.0 1 1 0 1 96 2.0 1 1 0 1 97 2.0 1 1 4 1 98 2.0 1 1 4 1 99 0.0 0 0 0 0 100 0.0 0 0 0 0 101 0.0 1 1 2 0 102 2.0 0 0 1 1 103 0.0 0 0 0 0 104 2.0 0 0 2 1 105 0.0 0 1 1 0 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) pre post1 post2 post3 0.17622 0.37104 0.01815 0.15747 0.85594 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -1.40319 -0.53216 -0.05121 0.57866 1.80563 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.17622 0.15169 1.162 0.248122 pre 0.37104 0.15947 2.327 0.022000 * post1 0.01815 0.16661 0.109 0.913459 post2 0.15747 0.04439 3.547 0.000595 *** post3 0.85594 0.15084 5.674 1.36e-07 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.7493 on 100 degrees of freedom Multiple R-squared: 0.3728, Adjusted R-squared: 0.3478 F-statistic: 14.86 on 4 and 100 DF, p-value: 1.452e-09 > 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.2666390 5.332781e-01 7.333610e-01 [2,] 0.2029257 4.058514e-01 7.970743e-01 [3,] 0.1155181 2.310362e-01 8.844819e-01 [4,] 0.2427806 4.855612e-01 7.572194e-01 [5,] 0.2707448 5.414896e-01 7.292552e-01 [6,] 0.4086908 8.173817e-01 5.913092e-01 [7,] 0.6244632 7.510736e-01 3.755368e-01 [8,] 0.5688681 8.622639e-01 4.311319e-01 [9,] 0.5295369 9.409261e-01 4.704631e-01 [10,] 0.4962587 9.925173e-01 5.037413e-01 [11,] 0.5630078 8.739844e-01 4.369922e-01 [12,] 0.7009834 5.980332e-01 2.990166e-01 [13,] 0.6918721 6.162557e-01 3.081279e-01 [14,] 0.6323239 7.353523e-01 3.676761e-01 [15,] 0.8900888 2.198224e-01 1.099112e-01 [16,] 0.8731103 2.537794e-01 1.268897e-01 [17,] 0.8480686 3.038628e-01 1.519314e-01 [18,] 0.8049757 3.900486e-01 1.950243e-01 [19,] 0.8149617 3.700767e-01 1.850383e-01 [20,] 0.8865311 2.269378e-01 1.134689e-01 [21,] 0.8514565 2.970870e-01 1.485435e-01 [22,] 0.9603772 7.924552e-02 3.962276e-02 [23,] 0.9474443 1.051113e-01 5.255567e-02 [24,] 0.9282006 1.435988e-01 7.179941e-02 [25,] 0.9296365 1.407271e-01 7.036355e-02 [26,] 0.9227418 1.545165e-01 7.725824e-02 [27,] 0.9053959 1.892082e-01 9.460408e-02 [28,] 0.8991455 2.017089e-01 1.008545e-01 [29,] 0.9190023 1.619955e-01 8.099774e-02 [30,] 0.9335795 1.328410e-01 6.642050e-02 [31,] 0.9691065 6.178708e-02 3.089354e-02 [32,] 0.9590930 8.181409e-02 4.090704e-02 [33,] 0.9443422 1.113155e-01 5.565777e-02 [34,] 0.9315363 1.369273e-01 6.846365e-02 [35,] 0.9099192 1.801617e-01 9.008083e-02 [36,] 0.9170038 1.659924e-01 8.299620e-02 [37,] 0.9294613 1.410773e-01 7.053867e-02 [38,] 0.9633915 7.321697e-02 3.660849e-02 [39,] 0.9517567 9.648666e-02 4.824333e-02 [40,] 0.9455476 1.089049e-01 5.445243e-02 [41,] 0.9475675 1.048650e-01 5.243248e-02 [42,] 0.9304848 1.390304e-01 6.951520e-02 [43,] 0.9173840 1.652320e-01 8.261600e-02 [44,] 0.9318287 1.363426e-01 6.817128e-02 [45,] 0.9237137 1.525726e-01 7.628630e-02 [46,] 0.9337310 1.325379e-01 6.626897e-02 [47,] 0.9357847 1.284307e-01 6.421533e-02 [48,] 0.9269285 1.461431e-01 7.307154e-02 [49,] 0.9822505 3.549893e-02 1.774946e-02 [50,] 0.9880024 2.399522e-02 1.199761e-02 [51,] 0.9904946 1.901079e-02 9.505397e-03 [52,] 0.9991037 1.792663e-03 8.963314e-04 [53,] 0.9985100 2.979915e-03 1.489957e-03 [54,] 0.9999922 1.552335e-05 7.761675e-06 [55,] 0.9999850 3.004593e-05 1.502297e-05 [56,] 0.9999942 1.150564e-05 5.752818e-06 [57,] 1.0000000 5.143923e-12 2.571962e-12 [58,] 1.0000000 8.575941e-12 4.287971e-12 [59,] 1.0000000 9.433417e-16 4.716708e-16 [60,] 1.0000000 2.543789e-15 1.271894e-15 [61,] 1.0000000 1.168370e-14 5.841848e-15 [62,] 1.0000000 0.000000e+00 0.000000e+00 [63,] 1.0000000 0.000000e+00 0.000000e+00 [64,] 1.0000000 0.000000e+00 0.000000e+00 [65,] 1.0000000 0.000000e+00 0.000000e+00 [66,] 1.0000000 0.000000e+00 0.000000e+00 [67,] 1.0000000 0.000000e+00 0.000000e+00 [68,] 1.0000000 0.000000e+00 0.000000e+00 [69,] 1.0000000 0.000000e+00 0.000000e+00 [70,] 1.0000000 0.000000e+00 0.000000e+00 [71,] 1.0000000 0.000000e+00 0.000000e+00 [72,] 1.0000000 0.000000e+00 0.000000e+00 [73,] 1.0000000 1.242982e-314 6.214912e-315 [74,] 1.0000000 1.071022e-307 5.355108e-308 [75,] 1.0000000 6.735638e-285 3.367819e-285 [76,] 1.0000000 3.838516e-266 1.919258e-266 [77,] 1.0000000 2.999315e-256 1.499658e-256 [78,] 1.0000000 9.820656e-239 4.910328e-239 [79,] 1.0000000 7.997380e-218 3.998690e-218 [80,] 1.0000000 5.291973e-211 2.645987e-211 [81,] 1.0000000 1.072494e-183 5.362468e-184 [82,] 1.0000000 3.366023e-169 1.683011e-169 [83,] 1.0000000 4.730113e-157 2.365057e-157 [84,] 1.0000000 2.771314e-143 1.385657e-143 [85,] 1.0000000 1.740679e-128 8.703397e-129 [86,] 1.0000000 1.587628e-108 7.938141e-109 [87,] 1.0000000 2.507618e-94 1.253809e-94 [88,] 1.0000000 3.267601e-81 1.633800e-81 [89,] 1.0000000 3.026927e-64 1.513463e-64 [90,] 1.0000000 3.232931e-51 1.616466e-51 > postscript(file="/var/fisher/rcomp/tmp/1cvgw1354876438.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/fisher/rcomp/tmp/24nkl1354876438.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/fisher/rcomp/tmp/3u2or1354876438.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/fisher/rcomp/tmp/4m5f31354876438.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/fisher/rcomp/tmp/5us531354876438.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.80472677 1.43459623 -0.18017888 -0.17621604 -0.42134499 0.57865501 7 8 9 10 11 12 0.57865501 -0.05030942 0.31982112 1.27712886 1.19391451 -1.05030942 13 14 15 16 17 18 -1.36524415 1.80563180 -0.17621604 0.57865501 1.27712886 -0.92134499 19 20 21 22 23 24 0.94969058 -1.34709199 0.26372028 -0.72287114 -0.49115077 -0.54725161 25 26 27 28 29 30 0.10625292 -1.40319283 -0.56540377 -0.17621604 1.66631660 -0.42134499 31 32 33 34 35 36 -0.04725161 0.80472677 -0.53215726 -0.33368340 -0.53215726 -0.56540377 37 38 39 40 41 42 0.80472677 -1.20777679 -0.05030942 -0.05121445 -0.42134499 -0.05121445 43 44 45 46 47 48 -0.56540377 -0.92134499 -1.03215726 0.31982112 -0.19436820 0.43459623 49 50 51 52 53 54 -0.05121445 -0.30608549 0.94969058 0.42118764 0.94969058 -0.80608549 55 56 57 58 59 60 -0.19436820 -1.36524415 -0.55030942 -0.82423766 1.19391451 -0.17621604 61 62 63 64 65 66 -1.05030942 -0.05121445 -0.42134499 -1.40319283 0.65290801 0.80563180 67 68 69 70 71 72 0.94969058 -0.17621604 -1.05121445 -0.05121445 -0.50930293 -0.19436820 73 74 75 76 77 78 -0.19436820 -0.82423766 0.57865501 0.59680717 0.81037538 0.26372028 79 80 81 82 83 84 0.59680717 0.26372028 0.96784274 0.33797329 0.33797329 0.59680717 85 86 87 88 89 90 -0.17621604 0.33797329 -0.54725161 -0.05121445 0.65290801 -0.49115077 91 92 93 94 95 96 -0.56540377 0.57865501 -1.19527323 0.94969058 0.57865501 0.57865501 97 98 99 100 101 102 -0.05121445 -0.05121445 -0.17621604 -0.17621604 -0.88033850 0.81037538 103 104 105 -0.17621604 0.65290801 -0.35183557 > postscript(file="/var/fisher/rcomp/tmp/602qe1354876438.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.80472677 NA 1 1.43459623 0.80472677 2 -0.18017888 1.43459623 3 -0.17621604 -0.18017888 4 -0.42134499 -0.17621604 5 0.57865501 -0.42134499 6 0.57865501 0.57865501 7 -0.05030942 0.57865501 8 0.31982112 -0.05030942 9 1.27712886 0.31982112 10 1.19391451 1.27712886 11 -1.05030942 1.19391451 12 -1.36524415 -1.05030942 13 1.80563180 -1.36524415 14 -0.17621604 1.80563180 15 0.57865501 -0.17621604 16 1.27712886 0.57865501 17 -0.92134499 1.27712886 18 0.94969058 -0.92134499 19 -1.34709199 0.94969058 20 0.26372028 -1.34709199 21 -0.72287114 0.26372028 22 -0.49115077 -0.72287114 23 -0.54725161 -0.49115077 24 0.10625292 -0.54725161 25 -1.40319283 0.10625292 26 -0.56540377 -1.40319283 27 -0.17621604 -0.56540377 28 1.66631660 -0.17621604 29 -0.42134499 1.66631660 30 -0.04725161 -0.42134499 31 0.80472677 -0.04725161 32 -0.53215726 0.80472677 33 -0.33368340 -0.53215726 34 -0.53215726 -0.33368340 35 -0.56540377 -0.53215726 36 0.80472677 -0.56540377 37 -1.20777679 0.80472677 38 -0.05030942 -1.20777679 39 -0.05121445 -0.05030942 40 -0.42134499 -0.05121445 41 -0.05121445 -0.42134499 42 -0.56540377 -0.05121445 43 -0.92134499 -0.56540377 44 -1.03215726 -0.92134499 45 0.31982112 -1.03215726 46 -0.19436820 0.31982112 47 0.43459623 -0.19436820 48 -0.05121445 0.43459623 49 -0.30608549 -0.05121445 50 0.94969058 -0.30608549 51 0.42118764 0.94969058 52 0.94969058 0.42118764 53 -0.80608549 0.94969058 54 -0.19436820 -0.80608549 55 -1.36524415 -0.19436820 56 -0.55030942 -1.36524415 57 -0.82423766 -0.55030942 58 1.19391451 -0.82423766 59 -0.17621604 1.19391451 60 -1.05030942 -0.17621604 61 -0.05121445 -1.05030942 62 -0.42134499 -0.05121445 63 -1.40319283 -0.42134499 64 0.65290801 -1.40319283 65 0.80563180 0.65290801 66 0.94969058 0.80563180 67 -0.17621604 0.94969058 68 -1.05121445 -0.17621604 69 -0.05121445 -1.05121445 70 -0.50930293 -0.05121445 71 -0.19436820 -0.50930293 72 -0.19436820 -0.19436820 73 -0.82423766 -0.19436820 74 0.57865501 -0.82423766 75 0.59680717 0.57865501 76 0.81037538 0.59680717 77 0.26372028 0.81037538 78 0.59680717 0.26372028 79 0.26372028 0.59680717 80 0.96784274 0.26372028 81 0.33797329 0.96784274 82 0.33797329 0.33797329 83 0.59680717 0.33797329 84 -0.17621604 0.59680717 85 0.33797329 -0.17621604 86 -0.54725161 0.33797329 87 -0.05121445 -0.54725161 88 0.65290801 -0.05121445 89 -0.49115077 0.65290801 90 -0.56540377 -0.49115077 91 0.57865501 -0.56540377 92 -1.19527323 0.57865501 93 0.94969058 -1.19527323 94 0.57865501 0.94969058 95 0.57865501 0.57865501 96 -0.05121445 0.57865501 97 -0.05121445 -0.05121445 98 -0.17621604 -0.05121445 99 -0.17621604 -0.17621604 100 -0.88033850 -0.17621604 101 0.81037538 -0.88033850 102 -0.17621604 0.81037538 103 0.65290801 -0.17621604 104 -0.35183557 0.65290801 105 NA -0.35183557 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 1.43459623 0.80472677 [2,] -0.18017888 1.43459623 [3,] -0.17621604 -0.18017888 [4,] -0.42134499 -0.17621604 [5,] 0.57865501 -0.42134499 [6,] 0.57865501 0.57865501 [7,] -0.05030942 0.57865501 [8,] 0.31982112 -0.05030942 [9,] 1.27712886 0.31982112 [10,] 1.19391451 1.27712886 [11,] -1.05030942 1.19391451 [12,] -1.36524415 -1.05030942 [13,] 1.80563180 -1.36524415 [14,] -0.17621604 1.80563180 [15,] 0.57865501 -0.17621604 [16,] 1.27712886 0.57865501 [17,] -0.92134499 1.27712886 [18,] 0.94969058 -0.92134499 [19,] -1.34709199 0.94969058 [20,] 0.26372028 -1.34709199 [21,] -0.72287114 0.26372028 [22,] -0.49115077 -0.72287114 [23,] -0.54725161 -0.49115077 [24,] 0.10625292 -0.54725161 [25,] -1.40319283 0.10625292 [26,] -0.56540377 -1.40319283 [27,] -0.17621604 -0.56540377 [28,] 1.66631660 -0.17621604 [29,] -0.42134499 1.66631660 [30,] -0.04725161 -0.42134499 [31,] 0.80472677 -0.04725161 [32,] -0.53215726 0.80472677 [33,] -0.33368340 -0.53215726 [34,] -0.53215726 -0.33368340 [35,] -0.56540377 -0.53215726 [36,] 0.80472677 -0.56540377 [37,] -1.20777679 0.80472677 [38,] -0.05030942 -1.20777679 [39,] -0.05121445 -0.05030942 [40,] -0.42134499 -0.05121445 [41,] -0.05121445 -0.42134499 [42,] -0.56540377 -0.05121445 [43,] -0.92134499 -0.56540377 [44,] -1.03215726 -0.92134499 [45,] 0.31982112 -1.03215726 [46,] -0.19436820 0.31982112 [47,] 0.43459623 -0.19436820 [48,] -0.05121445 0.43459623 [49,] -0.30608549 -0.05121445 [50,] 0.94969058 -0.30608549 [51,] 0.42118764 0.94969058 [52,] 0.94969058 0.42118764 [53,] -0.80608549 0.94969058 [54,] -0.19436820 -0.80608549 [55,] -1.36524415 -0.19436820 [56,] -0.55030942 -1.36524415 [57,] -0.82423766 -0.55030942 [58,] 1.19391451 -0.82423766 [59,] -0.17621604 1.19391451 [60,] -1.05030942 -0.17621604 [61,] -0.05121445 -1.05030942 [62,] -0.42134499 -0.05121445 [63,] -1.40319283 -0.42134499 [64,] 0.65290801 -1.40319283 [65,] 0.80563180 0.65290801 [66,] 0.94969058 0.80563180 [67,] -0.17621604 0.94969058 [68,] -1.05121445 -0.17621604 [69,] -0.05121445 -1.05121445 [70,] -0.50930293 -0.05121445 [71,] -0.19436820 -0.50930293 [72,] -0.19436820 -0.19436820 [73,] -0.82423766 -0.19436820 [74,] 0.57865501 -0.82423766 [75,] 0.59680717 0.57865501 [76,] 0.81037538 0.59680717 [77,] 0.26372028 0.81037538 [78,] 0.59680717 0.26372028 [79,] 0.26372028 0.59680717 [80,] 0.96784274 0.26372028 [81,] 0.33797329 0.96784274 [82,] 0.33797329 0.33797329 [83,] 0.59680717 0.33797329 [84,] -0.17621604 0.59680717 [85,] 0.33797329 -0.17621604 [86,] -0.54725161 0.33797329 [87,] -0.05121445 -0.54725161 [88,] 0.65290801 -0.05121445 [89,] -0.49115077 0.65290801 [90,] -0.56540377 -0.49115077 [91,] 0.57865501 -0.56540377 [92,] -1.19527323 0.57865501 [93,] 0.94969058 -1.19527323 [94,] 0.57865501 0.94969058 [95,] 0.57865501 0.57865501 [96,] -0.05121445 0.57865501 [97,] -0.05121445 -0.05121445 [98,] -0.17621604 -0.05121445 [99,] -0.17621604 -0.17621604 [100,] -0.88033850 -0.17621604 [101,] 0.81037538 -0.88033850 [102,] -0.17621604 0.81037538 [103,] 0.65290801 -0.17621604 [104,] -0.35183557 0.65290801 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 1.43459623 0.80472677 2 -0.18017888 1.43459623 3 -0.17621604 -0.18017888 4 -0.42134499 -0.17621604 5 0.57865501 -0.42134499 6 0.57865501 0.57865501 7 -0.05030942 0.57865501 8 0.31982112 -0.05030942 9 1.27712886 0.31982112 10 1.19391451 1.27712886 11 -1.05030942 1.19391451 12 -1.36524415 -1.05030942 13 1.80563180 -1.36524415 14 -0.17621604 1.80563180 15 0.57865501 -0.17621604 16 1.27712886 0.57865501 17 -0.92134499 1.27712886 18 0.94969058 -0.92134499 19 -1.34709199 0.94969058 20 0.26372028 -1.34709199 21 -0.72287114 0.26372028 22 -0.49115077 -0.72287114 23 -0.54725161 -0.49115077 24 0.10625292 -0.54725161 25 -1.40319283 0.10625292 26 -0.56540377 -1.40319283 27 -0.17621604 -0.56540377 28 1.66631660 -0.17621604 29 -0.42134499 1.66631660 30 -0.04725161 -0.42134499 31 0.80472677 -0.04725161 32 -0.53215726 0.80472677 33 -0.33368340 -0.53215726 34 -0.53215726 -0.33368340 35 -0.56540377 -0.53215726 36 0.80472677 -0.56540377 37 -1.20777679 0.80472677 38 -0.05030942 -1.20777679 39 -0.05121445 -0.05030942 40 -0.42134499 -0.05121445 41 -0.05121445 -0.42134499 42 -0.56540377 -0.05121445 43 -0.92134499 -0.56540377 44 -1.03215726 -0.92134499 45 0.31982112 -1.03215726 46 -0.19436820 0.31982112 47 0.43459623 -0.19436820 48 -0.05121445 0.43459623 49 -0.30608549 -0.05121445 50 0.94969058 -0.30608549 51 0.42118764 0.94969058 52 0.94969058 0.42118764 53 -0.80608549 0.94969058 54 -0.19436820 -0.80608549 55 -1.36524415 -0.19436820 56 -0.55030942 -1.36524415 57 -0.82423766 -0.55030942 58 1.19391451 -0.82423766 59 -0.17621604 1.19391451 60 -1.05030942 -0.17621604 61 -0.05121445 -1.05030942 62 -0.42134499 -0.05121445 63 -1.40319283 -0.42134499 64 0.65290801 -1.40319283 65 0.80563180 0.65290801 66 0.94969058 0.80563180 67 -0.17621604 0.94969058 68 -1.05121445 -0.17621604 69 -0.05121445 -1.05121445 70 -0.50930293 -0.05121445 71 -0.19436820 -0.50930293 72 -0.19436820 -0.19436820 73 -0.82423766 -0.19436820 74 0.57865501 -0.82423766 75 0.59680717 0.57865501 76 0.81037538 0.59680717 77 0.26372028 0.81037538 78 0.59680717 0.26372028 79 0.26372028 0.59680717 80 0.96784274 0.26372028 81 0.33797329 0.96784274 82 0.33797329 0.33797329 83 0.59680717 0.33797329 84 -0.17621604 0.59680717 85 0.33797329 -0.17621604 86 -0.54725161 0.33797329 87 -0.05121445 -0.54725161 88 0.65290801 -0.05121445 89 -0.49115077 0.65290801 90 -0.56540377 -0.49115077 91 0.57865501 -0.56540377 92 -1.19527323 0.57865501 93 0.94969058 -1.19527323 94 0.57865501 0.94969058 95 0.57865501 0.57865501 96 -0.05121445 0.57865501 97 -0.05121445 -0.05121445 98 -0.17621604 -0.05121445 99 -0.17621604 -0.17621604 100 -0.88033850 -0.17621604 101 0.81037538 -0.88033850 102 -0.17621604 0.81037538 103 0.65290801 -0.17621604 104 -0.35183557 0.65290801 > 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/fisher/rcomp/tmp/7i1qk1354876438.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/fisher/rcomp/tmp/8kai41354876438.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/fisher/rcomp/tmp/9w3x91354876438.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/fisher/rcomp/tmp/10zrch1354876438.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/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/11yqfi1354876438.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/fisher/rcomp/tmp/12m1da1354876438.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/fisher/rcomp/tmp/1360241354876438.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/fisher/rcomp/tmp/14b8jg1354876438.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/fisher/rcomp/tmp/15zqt51354876438.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/fisher/rcomp/tmp/16a1ya1354876438.tab") + } > > try(system("convert tmp/1cvgw1354876438.ps tmp/1cvgw1354876438.png",intern=TRUE)) character(0) > try(system("convert tmp/24nkl1354876438.ps tmp/24nkl1354876438.png",intern=TRUE)) character(0) > try(system("convert tmp/3u2or1354876438.ps tmp/3u2or1354876438.png",intern=TRUE)) character(0) > try(system("convert tmp/4m5f31354876438.ps tmp/4m5f31354876438.png",intern=TRUE)) character(0) > try(system("convert tmp/5us531354876438.ps tmp/5us531354876438.png",intern=TRUE)) character(0) > try(system("convert tmp/602qe1354876438.ps tmp/602qe1354876438.png",intern=TRUE)) character(0) > try(system("convert tmp/7i1qk1354876438.ps tmp/7i1qk1354876438.png",intern=TRUE)) character(0) > try(system("convert tmp/8kai41354876438.ps tmp/8kai41354876438.png",intern=TRUE)) character(0) > try(system("convert tmp/9w3x91354876438.ps tmp/9w3x91354876438.png",intern=TRUE)) character(0) > try(system("convert tmp/10zrch1354876438.ps tmp/10zrch1354876438.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 6.863 1.563 8.433