R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-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(2.47459765056973 + ,0 + ,0 + ,0 + ,0 + ,1 + ,0 + ,2.66937384986383 + ,0 + ,0 + ,1 + ,0 + ,0 + ,0 + ,2.53219643698047 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,2.12729820000485 + ,0 + ,0 + ,0 + ,1 + ,0 + ,0 + ,2.49251225238716 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,3.54814625114322 + ,0 + ,0 + ,0 + ,1 + ,0 + ,0 + ,2.56234294012695 + ,0 + ,1 + ,0 + ,0 + ,0 + ,0 + ,2.27428876391807 + ,0 + ,1 + ,0 + ,0 + ,0 + ,0 + ,2.47245764777235 + ,0 + ,0 + ,1 + ,0 + ,0 + ,0 + ,2.48672916316057 + ,0 + ,0 + ,1 + ,0 + ,0 + ,0 + ,3.07929215115082 + ,0 + ,1 + ,0 + ,1 + ,1 + ,0 + ,2.78351754277407 + ,0 + ,0 + ,0 + ,1 + ,1 + ,0 + ,2.98779119898482 + ,0 + ,0 + ,0 + ,0 + ,1 + ,0 + ,1.97583182197991 + ,0 + ,0 + ,0 + ,1 + ,0 + ,0 + ,2.04336369546406 + ,0 + ,0 + ,0 + ,1 + ,0 + ,0 + ,2.29549651734384 + ,0 + ,0 + ,1 + ,1 + ,1 + ,0 + ,2.83196954892865 + ,0 + ,1 + ,1 + ,1 + ,0 + ,0 + ,2.47444975443644 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,2.78303885834621 + ,0 + ,1 + ,0 + ,0 + ,1 + ,0 + ,2.74593257619412 + ,0 + ,0 + ,0 + ,1 + ,1 + ,1 + ,3.49836316440056 + ,0 + ,1 + ,0 + ,1 + ,0 + ,0 + ,2.52313082494381 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,3.14895258191772 + ,0 + ,1 + ,1 + ,1 + ,1 + ,0 + ,2.57018836590400 + ,0 + ,1 + ,1 + ,1 + ,0 + ,0 + ,2.44069333473533 + ,0 + ,1 + ,1 + ,0 + ,0 + ,1 + ,1.64387593543423 + ,0 + ,0 + ,1 + ,0 + ,0 + ,1 + ,2.22891502066970 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,3.14718152275621 + ,0 + ,0 + ,1 + ,1 + ,1 + ,0 + ,2.15748492482097 + ,0 + ,1 + ,0 + ,1 + ,0 + ,0 + ,1.79231165942448 + ,0 + ,0 + ,1 + ,0 + ,0 + ,1 + ,3.19772063333487 + ,0 + ,1 + ,0 + ,1 + ,0 + ,1 + ,2.52565799267401 + ,0 + ,1 + ,0 + ,1 + ,1 + ,0 + ,2.41461356555004 + ,0 + ,0 + ,1 + ,1 + ,0 + ,1 + ,1.78415174126421 + ,0 + ,0 + ,0 + ,1 + ,1 + ,0 + ,2.59655877649185 + ,0 + ,1 + ,1 + ,1 + ,1 + ,0 + ,4.21893310088215 + ,0 + ,0 + ,1 + ,1 + ,1 + ,1 + ,3.04678344720808 + ,0 + ,1 + ,1 + ,1 + ,1 + ,0 + ,2.04219904256902 + ,0 + ,1 + ,0 + ,1 + ,0 + ,0 + ,2.36802611274670 + ,0 + ,1 + ,0 + ,1 + ,1 + ,0 + ,2.93232777308280 + ,1 + ,0 + ,0 + ,0 + ,1 + ,1 + ,2.94785032211007 + ,1 + ,0 + ,1 + ,0 + ,1 + ,0 + ,2.68895063979876 + ,0 + ,1 + ,1 + ,1 + ,0 + ,1 + ,1.62637287532278 + ,0 + ,0 + ,1 + ,1 + ,1 + ,0 + ,1.94236306568157 + ,0 + ,1 + ,0 + ,0 + ,1 + ,0 + ,2.50222477331493 + ,0 + ,1 + ,1 + ,1 + ,1 + ,0 + ,2.94707375793069 + ,1 + ,0 + ,1 + ,1 + ,1 + ,0 + ,3.38756471145924 + ,0 + ,0 + ,1 + ,1 + ,1 + ,0 + ,3.14215136952233 + ,0 + ,1 + ,1 + ,0 + ,1 + ,1 + ,3.09225556163995 + ,0 + ,1 + ,1 + ,1 + ,1 + ,0 + ,2.92094923642281 + ,1 + ,1 + ,1 + ,1 + ,0 + ,1 + ,2.52870017990513 + ,0 + ,1 + ,0 + ,1 + ,1 + ,0 + ,1.72535841198671 + ,0 + ,1 + ,0 + ,0 + ,1 + ,0 + ,2.48068372782042 + ,0 + ,1 + ,0 + ,1 + ,1 + ,1 + ,2.47123175902455 + ,0 + ,1 + ,0 + ,0 + ,1 + ,1 + ,2.56063010837393 + ,0 + ,1 + ,0 + ,1 + ,1 + ,1 + ,2.10217613971670 + ,0 + ,1 + ,1 + ,0 + ,1 + ,0 + ,2.93445335819747 + ,0 + ,1 + ,1 + ,1 + ,1 + ,0 + ,2.86973855770263 + ,1 + ,0 + ,0 + ,1 + ,1 + ,1 + ,2.80048153642513 + ,0 + ,1 + ,1 + ,1 + ,1 + ,0 + ,2.93867731833148 + ,0 + ,1 + ,1 + ,1 + ,1 + ,1 + ,2.36861024734756 + ,0 + ,1 + ,0 + ,1 + ,0 + ,0 + ,2.51157333830042 + ,0 + ,1 + ,1 + ,1 + ,1 + ,0 + ,2.57241126324150 + ,1 + ,1 + ,0 + ,1 + ,0 + ,1 + ,3.41369346535535 + ,1 + ,1 + ,0 + ,1 + ,0 + ,1 + ,2.60512793272701 + ,0 + ,1 + ,1 + ,1 + ,1 + ,1) + ,dim=c(7 + ,65) + ,dimnames=list(c('MRwaarden' + ,'Q1' + ,'Q2' + ,'Q4' + ,'Q5' + ,'Q6' + ,'Q8') + ,1:65)) > y <- array(NA,dim=c(7,65),dimnames=list(c('MRwaarden','Q1','Q2','Q4','Q5','Q6','Q8'),1:65)) > 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 > 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 MRwaarden Q1 Q2 Q4 Q5 Q6 Q8 1 2.474598 0 0 0 0 1 0 2 2.669374 0 0 1 0 0 0 3 2.532196 0 0 0 0 0 0 4 2.127298 0 0 0 1 0 0 5 2.492512 0 0 0 0 0 0 6 3.548146 0 0 0 1 0 0 7 2.562343 0 1 0 0 0 0 8 2.274289 0 1 0 0 0 0 9 2.472458 0 0 1 0 0 0 10 2.486729 0 0 1 0 0 0 11 3.079292 0 1 0 1 1 0 12 2.783518 0 0 0 1 1 0 13 2.987791 0 0 0 0 1 0 14 1.975832 0 0 0 1 0 0 15 2.043364 0 0 0 1 0 0 16 2.295497 0 0 1 1 1 0 17 2.831970 0 1 1 1 0 0 18 2.474450 0 0 0 0 0 0 19 2.783039 0 1 0 0 1 0 20 2.745933 0 0 0 1 1 1 21 3.498363 0 1 0 1 0 0 22 2.523131 0 0 0 0 0 0 23 3.148953 0 1 1 1 1 0 24 2.570188 0 1 1 1 0 0 25 2.440693 0 1 1 0 0 1 26 1.643876 0 0 1 0 0 1 27 2.228915 0 0 0 0 0 0 28 3.147182 0 0 1 1 1 0 29 2.157485 0 1 0 1 0 0 30 1.792312 0 0 1 0 0 1 31 3.197721 0 1 0 1 0 1 32 2.525658 0 1 0 1 1 0 33 2.414614 0 0 1 1 0 1 34 1.784152 0 0 0 1 1 0 35 2.596559 0 1 1 1 1 0 36 4.218933 0 0 1 1 1 1 37 3.046783 0 1 1 1 1 0 38 2.042199 0 1 0 1 0 0 39 2.368026 0 1 0 1 1 0 40 2.932328 1 0 0 0 1 1 41 2.947850 1 0 1 0 1 0 42 2.688951 0 1 1 1 0 1 43 1.626373 0 0 1 1 1 0 44 1.942363 0 1 0 0 1 0 45 2.502225 0 1 1 1 1 0 46 2.947074 1 0 1 1 1 0 47 3.387565 0 0 1 1 1 0 48 3.142151 0 1 1 0 1 1 49 3.092256 0 1 1 1 1 0 50 2.920949 1 1 1 1 0 1 51 2.528700 0 1 0 1 1 0 52 1.725358 0 1 0 0 1 0 53 2.480684 0 1 0 1 1 1 54 2.471232 0 1 0 0 1 1 55 2.560630 0 1 0 1 1 1 56 2.102176 0 1 1 0 1 0 57 2.934453 0 1 1 1 1 0 58 2.869739 1 0 0 1 1 1 59 2.800482 0 1 1 1 1 0 60 2.938677 0 1 1 1 1 1 61 2.368610 0 1 0 1 0 0 62 2.511573 0 1 1 1 1 0 63 2.572411 1 1 0 1 0 1 64 3.413693 1 1 0 1 0 1 65 2.605128 0 1 1 1 1 1 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) Q1 Q2 Q4 Q5 Q6 2.28501 0.31387 0.01887 0.10966 0.21882 0.12381 Q8 0.08738 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -1.1109 -0.2540 -0.0308 0.2472 1.3942 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.28501 0.12952 17.643 <2e-16 *** Q1 0.31387 0.20163 1.557 0.125 Q2 0.01887 0.12344 0.153 0.879 Q4 0.10966 0.11954 0.917 0.363 Q5 0.21882 0.12812 1.708 0.093 . Q6 0.12381 0.12129 1.021 0.312 Q8 0.08738 0.13793 0.634 0.529 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.4708 on 58 degrees of freedom Multiple R-squared: 0.1608, Adjusted R-squared: 0.07401 F-statistic: 1.853 on 6 and 58 DF, p-value: 0.1047 > 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.7882498 0.42350041 0.21175020 [2,] 0.6746604 0.65067917 0.32533958 [3,] 0.5486984 0.90260314 0.45130157 [4,] 0.5224302 0.95513966 0.47756983 [5,] 0.6165754 0.76684915 0.38342457 [6,] 0.5907440 0.81851209 0.40925605 [7,] 0.5779849 0.84403012 0.42201506 [8,] 0.5032574 0.99348527 0.49674263 [9,] 0.4178463 0.83569255 0.58215373 [10,] 0.3524733 0.70494667 0.64752667 [11,] 0.2675890 0.53517810 0.73241095 [12,] 0.4878358 0.97567158 0.51216421 [13,] 0.4663512 0.93270240 0.53364880 [14,] 0.4064754 0.81295072 0.59352464 [15,] 0.3444910 0.68898200 0.65550900 [16,] 0.2784411 0.55688211 0.72155895 [17,] 0.3260288 0.65205756 0.67397122 [18,] 0.2976320 0.59526394 0.70236803 [19,] 0.2991997 0.59839936 0.70080032 [20,] 0.3165194 0.63303887 0.68348057 [21,] 0.3116728 0.62334558 0.68832721 [22,] 0.4374300 0.87486004 0.56256998 [23,] 0.4330299 0.86605977 0.56697011 [24,] 0.4009643 0.80192857 0.59903571 [25,] 0.5701936 0.85961274 0.42980637 [26,] 0.5064784 0.98704319 0.49352160 [27,] 0.9316845 0.13663108 0.06831554 [28,] 0.9163172 0.16736553 0.08368276 [29,] 0.8998608 0.20027833 0.10013917 [30,] 0.8729493 0.25410140 0.12705070 [31,] 0.8320233 0.33595339 0.16797670 [32,] 0.7877010 0.42459803 0.21229901 [33,] 0.7232495 0.55350099 0.27675049 [34,] 0.9776221 0.04475582 0.02237791 [35,] 0.9688171 0.06236588 0.03118294 [36,] 0.9529772 0.09404561 0.04702280 [37,] 0.9267469 0.14650620 0.07325310 [38,] 0.9223602 0.15527957 0.07763978 [39,] 0.9613486 0.07730272 0.03865136 [40,] 0.9604665 0.07906704 0.03953352 [41,] 0.9379464 0.12410720 0.06205360 [42,] 0.8944544 0.21109123 0.10554561 [43,] 0.8760141 0.24797172 0.12398586 [44,] 0.8062697 0.38746061 0.19373030 [45,] 0.7418860 0.51622795 0.25811398 [46,] 0.5763461 0.84730775 0.42365387 > postscript(file="/var/wessaorg/rcomp/tmp/102sv1324129382.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/227pn1324129382.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/31t031324129382.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/4rerx1324129382.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/59i5g1324129382.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 = 65 Frequency = 1 1 2 3 4 5 6 0.06577793 0.27470355 0.24718284 -0.37654022 0.20749866 1.04430783 7 8 9 10 11 12 0.25845603 -0.02959815 0.07778735 0.09205886 0.43277429 0.15587300 13 14 15 16 17 18 0.57897148 -0.52800660 -0.46047472 -0.44180473 0.19960110 0.18943616 19 20 21 22 23 24 0.35534582 0.03090932 0.97565143 0.23811723 0.39277801 -0.06218008 25 26 27 28 29 30 -0.06022900 -0.83817308 -0.05609857 0.40988027 -0.36522681 -0.68973735 31 32 33 34 35 36 0.58763018 -0.12085987 -0.28626027 -0.84349280 -0.15961580 1.39425314 37 38 39 40 41 42 0.29060887 -0.48051270 -0.27849175 0.12225549 0.11550004 -0.03079652 43 44 45 46 47 48 -1.11092838 -0.48532997 -0.25394980 -0.10410134 0.65026346 0.51742291 49 50 51 52 53 54 0.33608099 -0.11267177 -0.11781768 -0.70233463 -0.25321285 -0.04383999 55 56 57 58 59 60 -0.17326647 -0.43517361 0.17827879 -0.15915855 0.04430696 0.09512403 61 62 63 64 65 -0.15410149 -0.24460123 -0.35155304 0.48972916 -0.23842535 > postscript(file="/var/wessaorg/rcomp/tmp/600w91324129382.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 = 65 Frequency = 1 lag(myerror, k = 1) myerror 0 0.06577793 NA 1 0.27470355 0.06577793 2 0.24718284 0.27470355 3 -0.37654022 0.24718284 4 0.20749866 -0.37654022 5 1.04430783 0.20749866 6 0.25845603 1.04430783 7 -0.02959815 0.25845603 8 0.07778735 -0.02959815 9 0.09205886 0.07778735 10 0.43277429 0.09205886 11 0.15587300 0.43277429 12 0.57897148 0.15587300 13 -0.52800660 0.57897148 14 -0.46047472 -0.52800660 15 -0.44180473 -0.46047472 16 0.19960110 -0.44180473 17 0.18943616 0.19960110 18 0.35534582 0.18943616 19 0.03090932 0.35534582 20 0.97565143 0.03090932 21 0.23811723 0.97565143 22 0.39277801 0.23811723 23 -0.06218008 0.39277801 24 -0.06022900 -0.06218008 25 -0.83817308 -0.06022900 26 -0.05609857 -0.83817308 27 0.40988027 -0.05609857 28 -0.36522681 0.40988027 29 -0.68973735 -0.36522681 30 0.58763018 -0.68973735 31 -0.12085987 0.58763018 32 -0.28626027 -0.12085987 33 -0.84349280 -0.28626027 34 -0.15961580 -0.84349280 35 1.39425314 -0.15961580 36 0.29060887 1.39425314 37 -0.48051270 0.29060887 38 -0.27849175 -0.48051270 39 0.12225549 -0.27849175 40 0.11550004 0.12225549 41 -0.03079652 0.11550004 42 -1.11092838 -0.03079652 43 -0.48532997 -1.11092838 44 -0.25394980 -0.48532997 45 -0.10410134 -0.25394980 46 0.65026346 -0.10410134 47 0.51742291 0.65026346 48 0.33608099 0.51742291 49 -0.11267177 0.33608099 50 -0.11781768 -0.11267177 51 -0.70233463 -0.11781768 52 -0.25321285 -0.70233463 53 -0.04383999 -0.25321285 54 -0.17326647 -0.04383999 55 -0.43517361 -0.17326647 56 0.17827879 -0.43517361 57 -0.15915855 0.17827879 58 0.04430696 -0.15915855 59 0.09512403 0.04430696 60 -0.15410149 0.09512403 61 -0.24460123 -0.15410149 62 -0.35155304 -0.24460123 63 0.48972916 -0.35155304 64 -0.23842535 0.48972916 65 NA -0.23842535 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 0.27470355 0.06577793 [2,] 0.24718284 0.27470355 [3,] -0.37654022 0.24718284 [4,] 0.20749866 -0.37654022 [5,] 1.04430783 0.20749866 [6,] 0.25845603 1.04430783 [7,] -0.02959815 0.25845603 [8,] 0.07778735 -0.02959815 [9,] 0.09205886 0.07778735 [10,] 0.43277429 0.09205886 [11,] 0.15587300 0.43277429 [12,] 0.57897148 0.15587300 [13,] -0.52800660 0.57897148 [14,] -0.46047472 -0.52800660 [15,] -0.44180473 -0.46047472 [16,] 0.19960110 -0.44180473 [17,] 0.18943616 0.19960110 [18,] 0.35534582 0.18943616 [19,] 0.03090932 0.35534582 [20,] 0.97565143 0.03090932 [21,] 0.23811723 0.97565143 [22,] 0.39277801 0.23811723 [23,] -0.06218008 0.39277801 [24,] -0.06022900 -0.06218008 [25,] -0.83817308 -0.06022900 [26,] -0.05609857 -0.83817308 [27,] 0.40988027 -0.05609857 [28,] -0.36522681 0.40988027 [29,] -0.68973735 -0.36522681 [30,] 0.58763018 -0.68973735 [31,] -0.12085987 0.58763018 [32,] -0.28626027 -0.12085987 [33,] -0.84349280 -0.28626027 [34,] -0.15961580 -0.84349280 [35,] 1.39425314 -0.15961580 [36,] 0.29060887 1.39425314 [37,] -0.48051270 0.29060887 [38,] -0.27849175 -0.48051270 [39,] 0.12225549 -0.27849175 [40,] 0.11550004 0.12225549 [41,] -0.03079652 0.11550004 [42,] -1.11092838 -0.03079652 [43,] -0.48532997 -1.11092838 [44,] -0.25394980 -0.48532997 [45,] -0.10410134 -0.25394980 [46,] 0.65026346 -0.10410134 [47,] 0.51742291 0.65026346 [48,] 0.33608099 0.51742291 [49,] -0.11267177 0.33608099 [50,] -0.11781768 -0.11267177 [51,] -0.70233463 -0.11781768 [52,] -0.25321285 -0.70233463 [53,] -0.04383999 -0.25321285 [54,] -0.17326647 -0.04383999 [55,] -0.43517361 -0.17326647 [56,] 0.17827879 -0.43517361 [57,] -0.15915855 0.17827879 [58,] 0.04430696 -0.15915855 [59,] 0.09512403 0.04430696 [60,] -0.15410149 0.09512403 [61,] -0.24460123 -0.15410149 [62,] -0.35155304 -0.24460123 [63,] 0.48972916 -0.35155304 [64,] -0.23842535 0.48972916 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 0.27470355 0.06577793 2 0.24718284 0.27470355 3 -0.37654022 0.24718284 4 0.20749866 -0.37654022 5 1.04430783 0.20749866 6 0.25845603 1.04430783 7 -0.02959815 0.25845603 8 0.07778735 -0.02959815 9 0.09205886 0.07778735 10 0.43277429 0.09205886 11 0.15587300 0.43277429 12 0.57897148 0.15587300 13 -0.52800660 0.57897148 14 -0.46047472 -0.52800660 15 -0.44180473 -0.46047472 16 0.19960110 -0.44180473 17 0.18943616 0.19960110 18 0.35534582 0.18943616 19 0.03090932 0.35534582 20 0.97565143 0.03090932 21 0.23811723 0.97565143 22 0.39277801 0.23811723 23 -0.06218008 0.39277801 24 -0.06022900 -0.06218008 25 -0.83817308 -0.06022900 26 -0.05609857 -0.83817308 27 0.40988027 -0.05609857 28 -0.36522681 0.40988027 29 -0.68973735 -0.36522681 30 0.58763018 -0.68973735 31 -0.12085987 0.58763018 32 -0.28626027 -0.12085987 33 -0.84349280 -0.28626027 34 -0.15961580 -0.84349280 35 1.39425314 -0.15961580 36 0.29060887 1.39425314 37 -0.48051270 0.29060887 38 -0.27849175 -0.48051270 39 0.12225549 -0.27849175 40 0.11550004 0.12225549 41 -0.03079652 0.11550004 42 -1.11092838 -0.03079652 43 -0.48532997 -1.11092838 44 -0.25394980 -0.48532997 45 -0.10410134 -0.25394980 46 0.65026346 -0.10410134 47 0.51742291 0.65026346 48 0.33608099 0.51742291 49 -0.11267177 0.33608099 50 -0.11781768 -0.11267177 51 -0.70233463 -0.11781768 52 -0.25321285 -0.70233463 53 -0.04383999 -0.25321285 54 -0.17326647 -0.04383999 55 -0.43517361 -0.17326647 56 0.17827879 -0.43517361 57 -0.15915855 0.17827879 58 0.04430696 -0.15915855 59 0.09512403 0.04430696 60 -0.15410149 0.09512403 61 -0.24460123 -0.15410149 62 -0.35155304 -0.24460123 63 0.48972916 -0.35155304 64 -0.23842535 0.48972916 > 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/7a58c1324129382.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/8ivfi1324129382.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/9x8d01324129382.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/10g3oi1324129382.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/11woln1324129382.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/123dkc1324129382.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/13vqtw1324129382.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/14rp511324129382.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/15vdee1324129382.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/168ux61324129382.tab") + } > > try(system("convert tmp/102sv1324129382.ps tmp/102sv1324129382.png",intern=TRUE)) character(0) > try(system("convert tmp/227pn1324129382.ps tmp/227pn1324129382.png",intern=TRUE)) character(0) > try(system("convert tmp/31t031324129382.ps tmp/31t031324129382.png",intern=TRUE)) character(0) > try(system("convert tmp/4rerx1324129382.ps tmp/4rerx1324129382.png",intern=TRUE)) character(0) > try(system("convert tmp/59i5g1324129382.ps tmp/59i5g1324129382.png",intern=TRUE)) character(0) > try(system("convert tmp/600w91324129382.ps tmp/600w91324129382.png",intern=TRUE)) character(0) > try(system("convert tmp/7a58c1324129382.ps tmp/7a58c1324129382.png",intern=TRUE)) character(0) > try(system("convert tmp/8ivfi1324129382.ps tmp/8ivfi1324129382.png",intern=TRUE)) character(0) > try(system("convert tmp/9x8d01324129382.ps tmp/9x8d01324129382.png",intern=TRUE)) character(0) > try(system("convert tmp/10g3oi1324129382.ps tmp/10g3oi1324129382.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.262 0.568 3.917