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(0 + ,20 + ,5 + ,28 + ,3 + ,-2 + ,23 + ,6 + ,24 + ,1 + ,-4 + ,27 + ,6 + ,24 + ,0 + ,-6 + ,23 + ,6 + ,28 + ,1 + ,-2 + ,21 + ,5 + ,22 + ,1 + ,1 + ,18 + ,6 + ,24 + ,3 + ,7 + ,16 + ,6 + ,23 + ,5 + ,2 + ,11 + ,6 + ,22 + ,5 + ,2 + ,14 + ,4 + ,25 + ,4 + ,13 + ,-3 + ,6 + ,23 + ,11 + ,7 + ,2 + ,5 + ,21 + ,8 + ,-1 + ,26 + ,4 + ,21 + ,-1 + ,1 + ,11 + ,6 + ,19 + ,4 + ,0 + ,11 + ,4 + ,21 + ,4 + ,0 + ,11 + ,6 + ,23 + ,4 + ,5 + ,3 + ,6 + ,16 + ,6 + ,3 + ,8 + ,5 + ,22 + ,6 + ,6 + ,8 + ,5 + ,20 + ,6 + ,7 + ,7 + ,4 + ,19 + ,6 + ,-6 + ,3 + ,3 + ,20 + ,4 + ,-8 + ,4 + ,2 + ,14 + ,1 + ,-5 + ,-7 + ,4 + ,19 + ,6 + ,-14 + ,0 + ,1 + ,15 + ,0 + ,-13 + ,-5 + ,2 + ,14 + ,2 + ,-15 + ,5 + ,-1 + ,13 + ,-2 + ,-14 + ,-1 + ,2 + ,11 + ,0 + ,-10 + ,-4 + ,0 + ,11 + ,1 + ,-14 + ,4 + ,-1 + ,9 + ,-3 + ,-18 + ,7 + ,0 + ,12 + ,-3 + ,-22 + ,6 + ,-3 + ,9 + ,-5 + ,-24 + ,13 + ,-2 + ,11 + ,-7 + ,-17 + ,20 + ,-1 + ,9 + ,-7 + ,-16 + ,21 + ,1 + ,14 + ,-5 + ,-17 + ,37 + ,-5 + ,8 + ,-13 + ,-22 + ,52 + ,-2 + ,13 + ,-16 + ,-25 + ,59 + ,-4 + ,8 + ,-20 + ,-18 + ,66 + ,-1 + ,15 + ,-18 + ,-23 + ,73 + ,-1 + ,12 + ,-21 + ,-20 + ,71 + ,-3 + ,14 + ,-20 + ,-9 + ,69 + ,0 + ,13 + ,-16 + ,-4 + ,63 + ,2 + ,11 + ,-14 + ,0 + ,68 + ,2 + ,16 + ,-12 + ,3 + ,58 + ,0 + ,14 + ,-10 + ,14 + ,50 + ,3 + ,19 + ,-3 + ,13 + ,50 + ,3 + ,18 + ,-4 + ,12 + ,50 + ,4 + ,16 + ,-4 + ,16 + ,47 + ,5 + ,20 + ,-1 + ,7 + ,60 + ,3 + ,17 + ,-8 + ,2 + ,62 + ,2 + ,17 + ,-10 + ,1 + ,63 + ,1 + ,18 + ,-11 + ,7 + ,56 + ,3 + ,20 + ,-7 + ,10 + ,38 + ,3 + ,17 + ,-2 + ,3 + ,45 + ,1 + ,16 + ,-6 + ,2 + ,39 + ,3 + ,16 + ,-4 + ,12 + ,26 + ,3 + ,12 + ,0 + ,14 + ,25 + ,4 + ,15 + ,2 + ,11 + ,19 + ,2 + ,13 + ,2 + ,13 + ,14 + ,5 + ,17 + ,5 + ,17 + ,6 + ,4 + ,19 + ,8 + ,14 + ,4 + ,3 + ,21 + ,8 + ,7 + ,5 + ,1 + ,19 + ,5 + ,16 + ,-3 + ,4 + ,20 + ,10 + ,5 + ,-5 + ,1 + ,14 + ,6 + ,5 + ,0 + ,1 + ,18 + ,6 + ,15 + ,-6 + ,3 + ,14 + ,9 + ,9 + ,4 + ,1 + ,15 + ,5 + ,4 + ,-3 + ,1 + ,11 + ,5 + ,-9 + ,14 + ,2 + ,6 + ,-4 + ,-14 + ,16 + ,0 + ,11 + ,-5 + ,-4 + ,17 + ,3 + ,13 + ,-1 + ,-19 + ,25 + ,0 + ,14 + ,-8 + ,-10 + ,25 + ,-4 + ,7 + ,-8 + ,-22 + ,30 + ,-2 + ,1 + ,-13 + ,-25 + ,51 + ,-4 + ,8 + ,-18 + ,-8 + ,31 + ,-1 + ,8 + ,-8 + ,-8 + ,31 + ,-1 + ,7 + ,-8 + ,-8 + ,25 + ,0 + ,11 + ,-6 + ,-2 + ,35 + ,2 + ,13 + ,-5 + ,-6 + ,39 + ,0 + ,1 + ,-11 + ,-10 + ,48 + ,-1 + ,4 + ,-14 + ,-11 + ,41 + ,0 + ,4 + ,-12 + ,-14 + ,47 + ,-2 + ,10 + ,-13 + ,-25 + ,61 + ,-1 + ,8 + ,-19) + ,dim=c(5 + ,83) + ,dimnames=list(c('X_1' + ,'X_2' + ,'X_3' + ,'X_4' + ,'Y_1') + ,1:83)) > y <- array(NA,dim=c(5,83),dimnames=list(c('X_1','X_2','X_3','X_4','Y_1'),1:83)) > 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 Y_1 X_1 X_2 X_3 X_4 1 3 0 20 5 28 2 1 -2 23 6 24 3 0 -4 27 6 24 4 1 -6 23 6 28 5 1 -2 21 5 22 6 3 1 18 6 24 7 5 7 16 6 23 8 5 2 11 6 22 9 4 2 14 4 25 10 11 13 -3 6 23 11 8 7 2 5 21 12 -1 -1 26 4 21 13 4 1 11 6 19 14 4 0 11 4 21 15 4 0 11 6 23 16 6 5 3 6 16 17 6 3 8 5 22 18 6 6 8 5 20 19 6 7 7 4 19 20 4 -6 3 3 20 21 1 -8 4 2 14 22 6 -5 -7 4 19 23 0 -14 0 1 15 24 2 -13 -5 2 14 25 -2 -15 5 -1 13 26 0 -14 -1 2 11 27 1 -10 -4 0 11 28 -3 -14 4 -1 9 29 -3 -18 7 0 12 30 -5 -22 6 -3 9 31 -7 -24 13 -2 11 32 -7 -17 20 -1 9 33 -5 -16 21 1 14 34 -13 -17 37 -5 8 35 -16 -22 52 -2 13 36 -20 -25 59 -4 8 37 -18 -18 66 -1 15 38 -21 -23 73 -1 12 39 -20 -20 71 -3 14 40 -16 -9 69 0 13 41 -14 -4 63 2 11 42 -12 0 68 2 16 43 -10 3 58 0 14 44 -3 14 50 3 19 45 -4 13 50 3 18 46 -4 12 50 4 16 47 -1 16 47 5 20 48 -8 7 60 3 17 49 -10 2 62 2 17 50 -11 1 63 1 18 51 -7 7 56 3 20 52 -2 10 38 3 17 53 -6 3 45 1 16 54 -4 2 39 3 16 55 0 12 26 3 12 56 2 14 25 4 15 57 2 11 19 2 13 58 5 13 14 5 17 59 8 17 6 4 19 60 8 14 4 3 21 61 5 7 5 1 19 62 10 16 -3 4 20 63 6 5 -5 1 14 64 6 5 0 1 18 65 9 15 -6 3 14 66 5 9 4 1 15 67 5 4 -3 1 11 68 -4 -9 14 2 6 69 -5 -14 16 0 11 70 -1 -4 17 3 13 71 -8 -19 25 0 14 72 -8 -10 25 -4 7 73 -13 -22 30 -2 1 74 -18 -25 51 -4 8 75 -8 -8 31 -1 8 76 -8 -8 31 -1 7 77 -6 -8 25 0 11 78 -5 -2 35 2 13 79 -11 -6 39 0 1 80 -14 -10 48 -1 4 81 -12 -11 41 0 4 82 -13 -14 47 -2 10 83 -19 -25 61 -1 8 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X_1 X_2 X_3 X_4 0.02247 0.24521 -0.24591 0.29777 0.23450 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -0.7246 -0.2520 -0.0159 0.2396 0.6304 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.022473 0.144220 0.156 0.877 X_1 0.245211 0.004431 55.341 <2e-16 *** X_2 -0.245906 0.001714 -143.453 <2e-16 *** X_3 0.297769 0.026167 11.380 <2e-16 *** X_4 0.234501 0.010393 22.564 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.3317 on 78 degrees of freedom Multiple R-squared: 0.9984, Adjusted R-squared: 0.9983 F-statistic: 1.232e+04 on 4 and 78 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.36447969 0.7289594 0.6355203 [2,] 0.21244051 0.4248810 0.7875595 [3,] 0.12246683 0.2449337 0.8775332 [4,] 0.09223472 0.1844694 0.9077653 [5,] 0.16987175 0.3397435 0.8301283 [6,] 0.10562907 0.2112581 0.8943709 [7,] 0.15744269 0.3148854 0.8425573 [8,] 0.41777784 0.8355557 0.5822222 [9,] 0.39397844 0.7879569 0.6060216 [10,] 0.47481126 0.9496225 0.5251887 [11,] 0.41631955 0.8326391 0.5836804 [12,] 0.35117112 0.7023422 0.6488289 [13,] 0.32279159 0.6455832 0.6772084 [14,] 0.42531307 0.8506261 0.5746869 [15,] 0.46666010 0.9333202 0.5333399 [16,] 0.55589950 0.8882010 0.4441005 [17,] 0.48169021 0.9633804 0.5183098 [18,] 0.41125083 0.8225017 0.5887492 [19,] 0.33996144 0.6799229 0.6600386 [20,] 0.31094906 0.6218981 0.6890509 [21,] 0.34160099 0.6832020 0.6583990 [22,] 0.36778401 0.7355680 0.6322160 [23,] 0.53543240 0.9291352 0.4645676 [24,] 0.47304187 0.9460837 0.5269581 [25,] 0.43861016 0.8772203 0.5613898 [26,] 0.54810037 0.9037993 0.4518996 [27,] 0.54153047 0.9169391 0.4584695 [28,] 0.49720823 0.9944165 0.5027918 [29,] 0.43188805 0.8637761 0.5681119 [30,] 0.50411127 0.9917775 0.4958887 [31,] 0.47868668 0.9573734 0.5213133 [32,] 0.42954351 0.8590870 0.5704565 [33,] 0.37864602 0.7572920 0.6213540 [34,] 0.61994024 0.7601195 0.3800598 [35,] 0.64508131 0.7098374 0.3549187 [36,] 0.59111580 0.8177684 0.4088842 [37,] 0.61209577 0.7758085 0.3879042 [38,] 0.55931289 0.8813742 0.4406871 [39,] 0.55664853 0.8867029 0.4433515 [40,] 0.59408647 0.8118271 0.4059135 [41,] 0.53787792 0.9242442 0.4621221 [42,] 0.48536496 0.9707299 0.5146350 [43,] 0.48820853 0.9764171 0.5117915 [44,] 0.67529741 0.6494052 0.3247026 [45,] 0.61929990 0.7614002 0.3807001 [46,] 0.56040643 0.8791871 0.4395936 [47,] 0.61001351 0.7799730 0.3899865 [48,] 0.61375341 0.7724932 0.3862466 [49,] 0.55273220 0.8945356 0.4472678 [50,] 0.56459371 0.8708126 0.4354063 [51,] 0.51904930 0.9619014 0.4809507 [52,] 0.51180898 0.9763820 0.4881910 [53,] 0.47618259 0.9523652 0.5238174 [54,] 0.43838547 0.8767709 0.5616145 [55,] 0.55955014 0.8808997 0.4404499 [56,] 0.47801481 0.9560296 0.5219852 [57,] 0.43170114 0.8634023 0.5682989 [58,] 0.42194452 0.8438890 0.5780555 [59,] 0.35755265 0.7151053 0.6424473 [60,] 0.44818828 0.8963766 0.5518117 [61,] 0.38722420 0.7744484 0.6127758 [62,] 0.30547805 0.6109561 0.6945219 [63,] 0.29228850 0.5845770 0.7077115 [64,] 0.41523339 0.8304668 0.5847666 [65,] 0.41785238 0.8357048 0.5821476 [66,] 0.40802170 0.8160434 0.5919783 [67,] 0.28463750 0.5692750 0.7153625 [68,] 0.18149772 0.3629954 0.8185023 > postscript(file="/var/wessaorg/rcomp/tmp/1vne31355341318.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/2y9h91355341318.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/39b8b1355341318.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/4th991355341318.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/50ob11355341318.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 = 83 Frequency = 1 1 2 3 4 5 6 -0.159234918 -0.290858995 0.183187289 -0.248018092 -0.015899092 -0.256022557 7 8 9 10 11 12 0.015398416 0.246427361 -0.123820109 -0.128081480 0.339487957 -0.499310747 13 14 15 16 17 18 0.195142342 0.566889885 -0.497650998 -0.049446659 0.561267608 0.294635742 19 20 21 22 23 24 0.335788905 0.603181907 0.044286986 -0.164356208 -0.404799916 0.057191287 25 26 27 28 29 30 0.134481700 -0.010470277 -0.133495021 -0.418630823 0.298659607 0.630410728 31 32 33 34 35 36 0.075402971 0.251497238 0.484147237 -0.142524881 -0.293693557 -0.068673818 37 38 39 40 41 42 -0.598628757 0.052272929 -0.048636915 0.103419226 -0.724609157 0.351568558 43 44 45 46 47 48 0.221416562 0.491030388 -0.029257008 0.387187531 0.432850273 0.135571305 49 50 51 52 53 54 0.151209358 -0.294405299 -0.551555716 -0.009991938 0.257868705 0.432106432 55 56 57 58 59 60 -0.278779186 -0.016380698 0.308359248 -0.242905413 -0.362231106 -0.289641713 61 62 63 64 65 66 -0.262715063 -0.564673652 -0.058844925 0.232679637 -0.352403442 -0.061039001 67 68 69 70 71 72 0.381681783 -0.375433453 -0.234532091 0.196949489 -0.498825812 0.126856789 73 74 75 76 77 78 0.110391711 -0.035920726 -0.015939806 0.218561382 -0.492647807 0.430601456 79 80 81 82 83 -0.195376658 -0.407112541 -0.181011424 0.218589374 0.529830151 > postscript(file="/var/wessaorg/rcomp/tmp/6w1ad1355341318.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 = 83 Frequency = 1 lag(myerror, k = 1) myerror 0 -0.159234918 NA 1 -0.290858995 -0.159234918 2 0.183187289 -0.290858995 3 -0.248018092 0.183187289 4 -0.015899092 -0.248018092 5 -0.256022557 -0.015899092 6 0.015398416 -0.256022557 7 0.246427361 0.015398416 8 -0.123820109 0.246427361 9 -0.128081480 -0.123820109 10 0.339487957 -0.128081480 11 -0.499310747 0.339487957 12 0.195142342 -0.499310747 13 0.566889885 0.195142342 14 -0.497650998 0.566889885 15 -0.049446659 -0.497650998 16 0.561267608 -0.049446659 17 0.294635742 0.561267608 18 0.335788905 0.294635742 19 0.603181907 0.335788905 20 0.044286986 0.603181907 21 -0.164356208 0.044286986 22 -0.404799916 -0.164356208 23 0.057191287 -0.404799916 24 0.134481700 0.057191287 25 -0.010470277 0.134481700 26 -0.133495021 -0.010470277 27 -0.418630823 -0.133495021 28 0.298659607 -0.418630823 29 0.630410728 0.298659607 30 0.075402971 0.630410728 31 0.251497238 0.075402971 32 0.484147237 0.251497238 33 -0.142524881 0.484147237 34 -0.293693557 -0.142524881 35 -0.068673818 -0.293693557 36 -0.598628757 -0.068673818 37 0.052272929 -0.598628757 38 -0.048636915 0.052272929 39 0.103419226 -0.048636915 40 -0.724609157 0.103419226 41 0.351568558 -0.724609157 42 0.221416562 0.351568558 43 0.491030388 0.221416562 44 -0.029257008 0.491030388 45 0.387187531 -0.029257008 46 0.432850273 0.387187531 47 0.135571305 0.432850273 48 0.151209358 0.135571305 49 -0.294405299 0.151209358 50 -0.551555716 -0.294405299 51 -0.009991938 -0.551555716 52 0.257868705 -0.009991938 53 0.432106432 0.257868705 54 -0.278779186 0.432106432 55 -0.016380698 -0.278779186 56 0.308359248 -0.016380698 57 -0.242905413 0.308359248 58 -0.362231106 -0.242905413 59 -0.289641713 -0.362231106 60 -0.262715063 -0.289641713 61 -0.564673652 -0.262715063 62 -0.058844925 -0.564673652 63 0.232679637 -0.058844925 64 -0.352403442 0.232679637 65 -0.061039001 -0.352403442 66 0.381681783 -0.061039001 67 -0.375433453 0.381681783 68 -0.234532091 -0.375433453 69 0.196949489 -0.234532091 70 -0.498825812 0.196949489 71 0.126856789 -0.498825812 72 0.110391711 0.126856789 73 -0.035920726 0.110391711 74 -0.015939806 -0.035920726 75 0.218561382 -0.015939806 76 -0.492647807 0.218561382 77 0.430601456 -0.492647807 78 -0.195376658 0.430601456 79 -0.407112541 -0.195376658 80 -0.181011424 -0.407112541 81 0.218589374 -0.181011424 82 0.529830151 0.218589374 83 NA 0.529830151 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -0.290858995 -0.159234918 [2,] 0.183187289 -0.290858995 [3,] -0.248018092 0.183187289 [4,] -0.015899092 -0.248018092 [5,] -0.256022557 -0.015899092 [6,] 0.015398416 -0.256022557 [7,] 0.246427361 0.015398416 [8,] -0.123820109 0.246427361 [9,] -0.128081480 -0.123820109 [10,] 0.339487957 -0.128081480 [11,] -0.499310747 0.339487957 [12,] 0.195142342 -0.499310747 [13,] 0.566889885 0.195142342 [14,] -0.497650998 0.566889885 [15,] -0.049446659 -0.497650998 [16,] 0.561267608 -0.049446659 [17,] 0.294635742 0.561267608 [18,] 0.335788905 0.294635742 [19,] 0.603181907 0.335788905 [20,] 0.044286986 0.603181907 [21,] -0.164356208 0.044286986 [22,] -0.404799916 -0.164356208 [23,] 0.057191287 -0.404799916 [24,] 0.134481700 0.057191287 [25,] -0.010470277 0.134481700 [26,] -0.133495021 -0.010470277 [27,] -0.418630823 -0.133495021 [28,] 0.298659607 -0.418630823 [29,] 0.630410728 0.298659607 [30,] 0.075402971 0.630410728 [31,] 0.251497238 0.075402971 [32,] 0.484147237 0.251497238 [33,] -0.142524881 0.484147237 [34,] -0.293693557 -0.142524881 [35,] -0.068673818 -0.293693557 [36,] -0.598628757 -0.068673818 [37,] 0.052272929 -0.598628757 [38,] -0.048636915 0.052272929 [39,] 0.103419226 -0.048636915 [40,] -0.724609157 0.103419226 [41,] 0.351568558 -0.724609157 [42,] 0.221416562 0.351568558 [43,] 0.491030388 0.221416562 [44,] -0.029257008 0.491030388 [45,] 0.387187531 -0.029257008 [46,] 0.432850273 0.387187531 [47,] 0.135571305 0.432850273 [48,] 0.151209358 0.135571305 [49,] -0.294405299 0.151209358 [50,] -0.551555716 -0.294405299 [51,] -0.009991938 -0.551555716 [52,] 0.257868705 -0.009991938 [53,] 0.432106432 0.257868705 [54,] -0.278779186 0.432106432 [55,] -0.016380698 -0.278779186 [56,] 0.308359248 -0.016380698 [57,] -0.242905413 0.308359248 [58,] -0.362231106 -0.242905413 [59,] -0.289641713 -0.362231106 [60,] -0.262715063 -0.289641713 [61,] -0.564673652 -0.262715063 [62,] -0.058844925 -0.564673652 [63,] 0.232679637 -0.058844925 [64,] -0.352403442 0.232679637 [65,] -0.061039001 -0.352403442 [66,] 0.381681783 -0.061039001 [67,] -0.375433453 0.381681783 [68,] -0.234532091 -0.375433453 [69,] 0.196949489 -0.234532091 [70,] -0.498825812 0.196949489 [71,] 0.126856789 -0.498825812 [72,] 0.110391711 0.126856789 [73,] -0.035920726 0.110391711 [74,] -0.015939806 -0.035920726 [75,] 0.218561382 -0.015939806 [76,] -0.492647807 0.218561382 [77,] 0.430601456 -0.492647807 [78,] -0.195376658 0.430601456 [79,] -0.407112541 -0.195376658 [80,] -0.181011424 -0.407112541 [81,] 0.218589374 -0.181011424 [82,] 0.529830151 0.218589374 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -0.290858995 -0.159234918 2 0.183187289 -0.290858995 3 -0.248018092 0.183187289 4 -0.015899092 -0.248018092 5 -0.256022557 -0.015899092 6 0.015398416 -0.256022557 7 0.246427361 0.015398416 8 -0.123820109 0.246427361 9 -0.128081480 -0.123820109 10 0.339487957 -0.128081480 11 -0.499310747 0.339487957 12 0.195142342 -0.499310747 13 0.566889885 0.195142342 14 -0.497650998 0.566889885 15 -0.049446659 -0.497650998 16 0.561267608 -0.049446659 17 0.294635742 0.561267608 18 0.335788905 0.294635742 19 0.603181907 0.335788905 20 0.044286986 0.603181907 21 -0.164356208 0.044286986 22 -0.404799916 -0.164356208 23 0.057191287 -0.404799916 24 0.134481700 0.057191287 25 -0.010470277 0.134481700 26 -0.133495021 -0.010470277 27 -0.418630823 -0.133495021 28 0.298659607 -0.418630823 29 0.630410728 0.298659607 30 0.075402971 0.630410728 31 0.251497238 0.075402971 32 0.484147237 0.251497238 33 -0.142524881 0.484147237 34 -0.293693557 -0.142524881 35 -0.068673818 -0.293693557 36 -0.598628757 -0.068673818 37 0.052272929 -0.598628757 38 -0.048636915 0.052272929 39 0.103419226 -0.048636915 40 -0.724609157 0.103419226 41 0.351568558 -0.724609157 42 0.221416562 0.351568558 43 0.491030388 0.221416562 44 -0.029257008 0.491030388 45 0.387187531 -0.029257008 46 0.432850273 0.387187531 47 0.135571305 0.432850273 48 0.151209358 0.135571305 49 -0.294405299 0.151209358 50 -0.551555716 -0.294405299 51 -0.009991938 -0.551555716 52 0.257868705 -0.009991938 53 0.432106432 0.257868705 54 -0.278779186 0.432106432 55 -0.016380698 -0.278779186 56 0.308359248 -0.016380698 57 -0.242905413 0.308359248 58 -0.362231106 -0.242905413 59 -0.289641713 -0.362231106 60 -0.262715063 -0.289641713 61 -0.564673652 -0.262715063 62 -0.058844925 -0.564673652 63 0.232679637 -0.058844925 64 -0.352403442 0.232679637 65 -0.061039001 -0.352403442 66 0.381681783 -0.061039001 67 -0.375433453 0.381681783 68 -0.234532091 -0.375433453 69 0.196949489 -0.234532091 70 -0.498825812 0.196949489 71 0.126856789 -0.498825812 72 0.110391711 0.126856789 73 -0.035920726 0.110391711 74 -0.015939806 -0.035920726 75 0.218561382 -0.015939806 76 -0.492647807 0.218561382 77 0.430601456 -0.492647807 78 -0.195376658 0.430601456 79 -0.407112541 -0.195376658 80 -0.181011424 -0.407112541 81 0.218589374 -0.181011424 82 0.529830151 0.218589374 > 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/7szjw1355341318.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/83zlx1355341318.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/9ejdl1355341318.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/102s201355341318.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/117a861355341318.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/12jnga1355341318.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/13qiqy1355341318.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/14ywbv1355341318.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/15r7sl1355341318.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/16oj1e1355341319.tab") + } > > try(system("convert tmp/1vne31355341318.ps tmp/1vne31355341318.png",intern=TRUE)) character(0) > try(system("convert tmp/2y9h91355341318.ps tmp/2y9h91355341318.png",intern=TRUE)) character(0) > try(system("convert tmp/39b8b1355341318.ps tmp/39b8b1355341318.png",intern=TRUE)) character(0) > try(system("convert tmp/4th991355341318.ps tmp/4th991355341318.png",intern=TRUE)) character(0) > try(system("convert tmp/50ob11355341318.ps tmp/50ob11355341318.png",intern=TRUE)) character(0) > try(system("convert tmp/6w1ad1355341318.ps tmp/6w1ad1355341318.png",intern=TRUE)) character(0) > try(system("convert tmp/7szjw1355341318.ps tmp/7szjw1355341318.png",intern=TRUE)) character(0) > try(system("convert tmp/83zlx1355341318.ps tmp/83zlx1355341318.png",intern=TRUE)) character(0) > try(system("convert tmp/9ejdl1355341318.ps tmp/9ejdl1355341318.png",intern=TRUE)) character(0) > try(system("convert tmp/102s201355341318.ps tmp/102s201355341318.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 6.820 1.178 8.237