R version 2.8.0 (2008-10-20) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > x <- array(list(7.5,0,7.2,0,6.9,0,6.7,0,6.4,0,6.3,0,6.8,0,7.3,0,7.1,0,7.1,0,6.8,0,6.5,0,6.3,0,6.1,0,6.1,0,6.3,0,6.3,0,6,0,6.2,0,6.4,0,6.8,0,7.5,0,7.5,0,7.6,0,7.6,0,7.4,0,7.3,0,7.1,0,6.9,0,6.8,0,7.5,0,7.6,0,7.8,0,8.0,0,8.1,0,8.2,0,8.3,0,8.2,0,8.0,0,7.9,0,7.6,0,7.6,0,8.2,0,8.3,0,8.4,0,8.4,0,8.4,0,8.6,0,8.9,0,8.8,0,8.3,0,7.5,0,7.2,0,7.5,0,8.8,0,9.3,0,9.3,0,8.7,1,8.2,1,8.3,1,8.5,1,8.6,1,8.6,1,8.2,1,8.1,1,8.0,1,8.6,1,8.7,1,8.8,1,8.5,1,8.4,1,8.5,1,8.7,1,8.7,1,8.6,1,8.5,1,8.3,1,8.1,1,8.2,1,8.1,1,8.1,1,7.9,1,7.9,1,7.9,1,8.0,1,8.0,1,7.9,1,8.0,1,7.7,1,7.2,1,7.5,1,7.3,1,7.0,1,7.0,1,7.0,1,7.2,1,7.3,1,7.1,1,6.8,1,6.6,1,6.2,1,6.2,1,6.8,1,6.9,1,6.8,1),dim=c(2,105),dimnames=list(c('w','d'),1:105)) > y <- array(NA,dim=c(2,105),dimnames=list(c('w','d'),1:105)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par3 = 'Linear Trend' > par2 = 'Do not include Seasonal Dummies' > par1 = '1' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > library(lattice) > library(lmtest) Loading required package: zoo Attaching package: 'zoo' The following object(s) are masked from package:base : as.Date.numeric > n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test > par1 <- as.numeric(par1) > x <- t(y) > k <- length(x[1,]) > n <- length(x[,1]) > x1 <- cbind(x[,par1], x[,1:k!=par1]) > mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1]) > colnames(x1) <- mycolnames #colnames(x)[par1] > x <- x1 > if (par3 == 'First Differences'){ + x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep=''))) + for (i in 1:n-1) { + for (j in 1:k) { + x2[i,j] <- x[i+1,j] - x[i,j] + } + } + x <- x2 + } > if (par2 == 'Include Monthly Dummies'){ + x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep =''))) + for (i in 1:11){ + x2[seq(i,n,12),i] <- 1 + } + x <- cbind(x, x2) + } > if (par2 == 'Include Quarterly Dummies'){ + x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep =''))) + for (i in 1:3){ + x2[seq(i,n,4),i] <- 1 + } + x <- cbind(x, x2) + } > k <- length(x[1,]) > if (par3 == 'Linear Trend'){ + x <- cbind(x, c(1:n)) + colnames(x)[k+1] <- 't' + } > x w d t 1 7.5 0 1 2 7.2 0 2 3 6.9 0 3 4 6.7 0 4 5 6.4 0 5 6 6.3 0 6 7 6.8 0 7 8 7.3 0 8 9 7.1 0 9 10 7.1 0 10 11 6.8 0 11 12 6.5 0 12 13 6.3 0 13 14 6.1 0 14 15 6.1 0 15 16 6.3 0 16 17 6.3 0 17 18 6.0 0 18 19 6.2 0 19 20 6.4 0 20 21 6.8 0 21 22 7.5 0 22 23 7.5 0 23 24 7.6 0 24 25 7.6 0 25 26 7.4 0 26 27 7.3 0 27 28 7.1 0 28 29 6.9 0 29 30 6.8 0 30 31 7.5 0 31 32 7.6 0 32 33 7.8 0 33 34 8.0 0 34 35 8.1 0 35 36 8.2 0 36 37 8.3 0 37 38 8.2 0 38 39 8.0 0 39 40 7.9 0 40 41 7.6 0 41 42 7.6 0 42 43 8.2 0 43 44 8.3 0 44 45 8.4 0 45 46 8.4 0 46 47 8.4 0 47 48 8.6 0 48 49 8.9 0 49 50 8.8 0 50 51 8.3 0 51 52 7.5 0 52 53 7.2 0 53 54 7.5 0 54 55 8.8 0 55 56 9.3 0 56 57 9.3 0 57 58 8.7 1 58 59 8.2 1 59 60 8.3 1 60 61 8.5 1 61 62 8.6 1 62 63 8.6 1 63 64 8.2 1 64 65 8.1 1 65 66 8.0 1 66 67 8.6 1 67 68 8.7 1 68 69 8.8 1 69 70 8.5 1 70 71 8.4 1 71 72 8.5 1 72 73 8.7 1 73 74 8.7 1 74 75 8.6 1 75 76 8.5 1 76 77 8.3 1 77 78 8.1 1 78 79 8.2 1 79 80 8.1 1 80 81 8.1 1 81 82 7.9 1 82 83 7.9 1 83 84 7.9 1 84 85 8.0 1 85 86 8.0 1 86 87 7.9 1 87 88 8.0 1 88 89 7.7 1 89 90 7.2 1 90 91 7.5 1 91 92 7.3 1 92 93 7.0 1 93 94 7.0 1 94 95 7.0 1 95 96 7.2 1 96 97 7.3 1 97 98 7.1 1 98 99 6.8 1 99 100 6.6 1 100 101 6.2 1 101 102 6.2 1 102 103 6.8 1 103 104 6.9 1 104 105 6.8 1 105 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) d t 7.232230 -0.048648 0.008024 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -1.80198 -0.62175 0.08323 0.65857 1.61845 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 7.232230 0.180285 40.115 <2e-16 *** d -0.048648 0.307403 -0.158 0.875 t 0.008024 0.005052 1.588 0.115 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.7931 on 102 degrees of freedom Multiple R-squared: 0.07502, Adjusted R-squared: 0.05689 F-statistic: 4.136 on 2 and 102 DF, p-value: 0.01874 > 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.001123685 2.247370e-03 9.988763e-01 [2,] 0.036842162 7.368432e-02 9.631578e-01 [3,] 0.109322892 2.186458e-01 8.906771e-01 [4,] 0.073578396 1.471568e-01 9.264216e-01 [5,] 0.042430043 8.486009e-02 9.575700e-01 [6,] 0.020602547 4.120509e-02 9.793975e-01 [7,] 0.012026066 2.405213e-02 9.879739e-01 [8,] 0.008250672 1.650134e-02 9.917493e-01 [9,] 0.006757913 1.351583e-02 9.932421e-01 [10,] 0.004668592 9.337183e-03 9.953314e-01 [11,] 0.002745018 5.490037e-03 9.972550e-01 [12,] 0.001728711 3.457422e-03 9.982713e-01 [13,] 0.001443258 2.886515e-03 9.985567e-01 [14,] 0.001220903 2.441807e-03 9.987791e-01 [15,] 0.001468485 2.936970e-03 9.985315e-01 [16,] 0.004424601 8.849201e-03 9.955754e-01 [17,] 0.049418254 9.883651e-02 9.505817e-01 [18,] 0.122949825 2.458997e-01 8.770502e-01 [19,] 0.205780666 4.115613e-01 7.942193e-01 [20,] 0.262645483 5.252910e-01 7.373545e-01 [21,] 0.275818153 5.516363e-01 7.241818e-01 [22,] 0.280238364 5.604767e-01 7.197616e-01 [23,] 0.296370133 5.927403e-01 7.036299e-01 [24,] 0.357042503 7.140850e-01 6.429575e-01 [25,] 0.481356658 9.627133e-01 5.186433e-01 [26,] 0.542548709 9.149026e-01 4.574513e-01 [27,] 0.602714764 7.945705e-01 3.972852e-01 [28,] 0.659785489 6.804290e-01 3.402145e-01 [29,] 0.711294542 5.774109e-01 2.887055e-01 [30,] 0.747594282 5.048114e-01 2.524057e-01 [31,] 0.771175064 4.576499e-01 2.288249e-01 [32,] 0.784584082 4.308318e-01 2.154159e-01 [33,] 0.778395559 4.432089e-01 2.216044e-01 [34,] 0.767920174 4.641597e-01 2.320798e-01 [35,] 0.764951951 4.700961e-01 2.350480e-01 [36,] 0.814207357 3.715853e-01 1.857926e-01 [37,] 0.868159759 2.636805e-01 1.318402e-01 [38,] 0.860491672 2.790167e-01 1.395083e-01 [39,] 0.847351876 3.052962e-01 1.526481e-01 [40,] 0.828909524 3.421810e-01 1.710905e-01 [41,] 0.804276368 3.914473e-01 1.957236e-01 [42,] 0.773567858 4.528643e-01 2.264321e-01 [43,] 0.741940075 5.161199e-01 2.580599e-01 [44,] 0.741784397 5.164312e-01 2.582156e-01 [45,] 0.722028870 5.559423e-01 2.779711e-01 [46,] 0.676108148 6.477837e-01 3.238919e-01 [47,] 0.814039204 3.719216e-01 1.859608e-01 [48,] 0.976506498 4.698700e-02 2.349350e-02 [49,] 0.999244131 1.511737e-03 7.558686e-04 [50,] 0.999302261 1.395477e-03 6.977387e-04 [51,] 0.999303550 1.392899e-03 6.964496e-04 [52,] 0.999206636 1.586728e-03 7.933642e-04 [53,] 0.998822439 2.355123e-03 1.177561e-03 [54,] 0.999435150 1.129700e-03 5.648502e-04 [55,] 0.999649691 7.006174e-04 3.503087e-04 [56,] 0.999627125 7.457508e-04 3.728754e-04 [57,] 0.999503224 9.935512e-04 4.967756e-04 [58,] 0.999314064 1.371872e-03 6.859361e-04 [59,] 0.999715036 5.699270e-04 2.849635e-04 [60,] 0.999953175 9.364969e-05 4.682484e-05 [61,] 0.999999043 1.913278e-06 9.566391e-07 [62,] 0.999998901 2.197054e-06 1.098527e-06 [63,] 0.999998022 3.956814e-06 1.978407e-06 [64,] 0.999995673 8.653923e-06 4.326961e-06 [65,] 0.999994446 1.110727e-05 5.553637e-06 [66,] 0.999994990 1.002018e-05 5.010089e-06 [67,] 0.999992217 1.556515e-05 7.782576e-06 [68,] 0.999983046 3.390783e-05 1.695392e-05 [69,] 0.999966710 6.657979e-05 3.328989e-05 [70,] 0.999935600 1.287999e-04 6.439995e-05 [71,] 0.999879221 2.415572e-04 1.207786e-04 [72,] 0.999793111 4.137770e-04 2.068885e-04 [73,] 0.999747779 5.044420e-04 2.522210e-04 [74,] 0.999587605 8.247904e-04 4.123952e-04 [75,] 0.999383048 1.233905e-03 6.169523e-04 [76,] 0.999029647 1.940706e-03 9.703530e-04 [77,] 0.998823666 2.352668e-03 1.176334e-03 [78,] 0.998414031 3.171939e-03 1.585969e-03 [79,] 0.997674766 4.650469e-03 2.325234e-03 [80,] 0.996374136 7.251727e-03 3.625864e-03 [81,] 0.994919787 1.016043e-02 5.080213e-03 [82,] 0.993166375 1.366725e-02 6.833625e-03 [83,] 0.994792680 1.041464e-02 5.207320e-03 [84,] 0.994200847 1.159831e-02 5.799153e-03 [85,] 0.992766443 1.446711e-02 7.233557e-03 [86,] 0.990299951 1.940010e-02 9.700049e-03 [87,] 0.985296743 2.940651e-02 1.470326e-02 [88,] 0.978748781 4.250244e-02 2.125122e-02 [89,] 0.967079109 6.584178e-02 3.292089e-02 [90,] 0.946416125 1.071677e-01 5.358387e-02 [91,] 0.911977166 1.760457e-01 8.802283e-02 [92,] 0.902713952 1.945721e-01 9.728605e-02 [93,] 0.908971947 1.820561e-01 9.102805e-02 [94,] 0.899194747 2.016105e-01 1.008053e-01 > postscript(file="/var/www/html/rcomp/tmp/1j5ur1227785563.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(x[,1], type='l', main='Actuals and Interpolation', ylab='value of Actuals and Interpolation (dots)', xlab='time or index') > points(x[,1]-mysum$resid) > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/2k2z61227785563.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(mysum$resid, type='b', pch=19, main='Residuals', ylab='value of Residuals', xlab='time or index') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/3b5v71227785563.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > hist(mysum$resid, main='Residual Histogram', xlab='values of Residuals') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/4mvww1227785563.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > densityplot(~mysum$resid,col='black',main='Residual Density Plot', xlab='values of Residuals') > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/5l0tu1227785563.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(mysum$resid, main='Residual Normal Q-Q Plot') > qqline(mysum$resid) > grid() > dev.off() null device 1 > (myerror <- as.ts(mysum$resid)) Time Series: Start = 1 End = 105 Frequency = 1 1 2 3 4 5 6 0.259746810 -0.048276729 -0.356300268 -0.564323807 -0.872347346 -0.980370885 7 8 9 10 11 12 -0.488394424 0.003582037 -0.204441501 -0.212465040 -0.520488579 -0.828512118 13 14 15 16 17 18 -1.036535657 -1.244559196 -1.252582735 -1.060606274 -1.068629813 -1.376653352 19 20 21 22 23 24 -1.184676891 -0.992700430 -0.600723969 0.091252492 0.083228953 0.175205414 25 26 27 28 29 30 0.167181875 -0.040841664 -0.148865203 -0.356888742 -0.564912281 -0.672935820 31 32 33 34 35 36 0.019040641 0.111017102 0.302993563 0.494970024 0.586946486 0.678922947 37 38 39 40 41 42 0.770899408 0.662875869 0.454852330 0.346828791 0.038805252 0.030781713 43 44 45 46 47 48 0.622758174 0.714734635 0.806711096 0.798687557 0.790664018 0.982640479 49 50 51 52 53 54 1.274616940 1.166593401 0.658569862 -0.149453677 -0.457477216 -0.165500755 55 56 57 58 59 60 1.126475706 1.618452167 1.610428628 1.051053166 0.543029627 0.635006088 61 62 63 64 65 66 0.826982549 0.918959010 0.910935471 0.502911932 0.394888393 0.286864854 67 68 69 70 71 72 0.878841315 0.970817776 1.062794237 0.754770698 0.646747159 0.738723620 73 74 75 76 77 78 0.930700081 0.922676542 0.814653003 0.706629464 0.498605925 0.290582386 79 80 81 82 83 84 0.382558847 0.274535308 0.266511769 0.058488231 0.050464692 0.042441153 85 86 87 88 89 90 0.134417614 0.126394075 0.018370536 0.110346997 -0.197676542 -0.705700081 91 92 93 94 95 96 -0.413723620 -0.621747159 -0.929770698 -0.937794237 -0.945817776 -0.753841315 97 98 99 100 101 102 -0.661864854 -0.869888393 -1.177911932 -1.385935471 -1.793959010 -1.801982549 103 104 105 -1.210006088 -1.118029627 -1.226053166 > postscript(file="/var/www/html/rcomp/tmp/6lroo1227785563.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > dum <- cbind(lag(myerror,k=1),myerror) > dum Time Series: Start = 0 End = 105 Frequency = 1 lag(myerror, k = 1) myerror 0 0.259746810 NA 1 -0.048276729 0.259746810 2 -0.356300268 -0.048276729 3 -0.564323807 -0.356300268 4 -0.872347346 -0.564323807 5 -0.980370885 -0.872347346 6 -0.488394424 -0.980370885 7 0.003582037 -0.488394424 8 -0.204441501 0.003582037 9 -0.212465040 -0.204441501 10 -0.520488579 -0.212465040 11 -0.828512118 -0.520488579 12 -1.036535657 -0.828512118 13 -1.244559196 -1.036535657 14 -1.252582735 -1.244559196 15 -1.060606274 -1.252582735 16 -1.068629813 -1.060606274 17 -1.376653352 -1.068629813 18 -1.184676891 -1.376653352 19 -0.992700430 -1.184676891 20 -0.600723969 -0.992700430 21 0.091252492 -0.600723969 22 0.083228953 0.091252492 23 0.175205414 0.083228953 24 0.167181875 0.175205414 25 -0.040841664 0.167181875 26 -0.148865203 -0.040841664 27 -0.356888742 -0.148865203 28 -0.564912281 -0.356888742 29 -0.672935820 -0.564912281 30 0.019040641 -0.672935820 31 0.111017102 0.019040641 32 0.302993563 0.111017102 33 0.494970024 0.302993563 34 0.586946486 0.494970024 35 0.678922947 0.586946486 36 0.770899408 0.678922947 37 0.662875869 0.770899408 38 0.454852330 0.662875869 39 0.346828791 0.454852330 40 0.038805252 0.346828791 41 0.030781713 0.038805252 42 0.622758174 0.030781713 43 0.714734635 0.622758174 44 0.806711096 0.714734635 45 0.798687557 0.806711096 46 0.790664018 0.798687557 47 0.982640479 0.790664018 48 1.274616940 0.982640479 49 1.166593401 1.274616940 50 0.658569862 1.166593401 51 -0.149453677 0.658569862 52 -0.457477216 -0.149453677 53 -0.165500755 -0.457477216 54 1.126475706 -0.165500755 55 1.618452167 1.126475706 56 1.610428628 1.618452167 57 1.051053166 1.610428628 58 0.543029627 1.051053166 59 0.635006088 0.543029627 60 0.826982549 0.635006088 61 0.918959010 0.826982549 62 0.910935471 0.918959010 63 0.502911932 0.910935471 64 0.394888393 0.502911932 65 0.286864854 0.394888393 66 0.878841315 0.286864854 67 0.970817776 0.878841315 68 1.062794237 0.970817776 69 0.754770698 1.062794237 70 0.646747159 0.754770698 71 0.738723620 0.646747159 72 0.930700081 0.738723620 73 0.922676542 0.930700081 74 0.814653003 0.922676542 75 0.706629464 0.814653003 76 0.498605925 0.706629464 77 0.290582386 0.498605925 78 0.382558847 0.290582386 79 0.274535308 0.382558847 80 0.266511769 0.274535308 81 0.058488231 0.266511769 82 0.050464692 0.058488231 83 0.042441153 0.050464692 84 0.134417614 0.042441153 85 0.126394075 0.134417614 86 0.018370536 0.126394075 87 0.110346997 0.018370536 88 -0.197676542 0.110346997 89 -0.705700081 -0.197676542 90 -0.413723620 -0.705700081 91 -0.621747159 -0.413723620 92 -0.929770698 -0.621747159 93 -0.937794237 -0.929770698 94 -0.945817776 -0.937794237 95 -0.753841315 -0.945817776 96 -0.661864854 -0.753841315 97 -0.869888393 -0.661864854 98 -1.177911932 -0.869888393 99 -1.385935471 -1.177911932 100 -1.793959010 -1.385935471 101 -1.801982549 -1.793959010 102 -1.210006088 -1.801982549 103 -1.118029627 -1.210006088 104 -1.226053166 -1.118029627 105 NA -1.226053166 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -0.048276729 0.259746810 [2,] -0.356300268 -0.048276729 [3,] -0.564323807 -0.356300268 [4,] -0.872347346 -0.564323807 [5,] -0.980370885 -0.872347346 [6,] -0.488394424 -0.980370885 [7,] 0.003582037 -0.488394424 [8,] -0.204441501 0.003582037 [9,] -0.212465040 -0.204441501 [10,] -0.520488579 -0.212465040 [11,] -0.828512118 -0.520488579 [12,] -1.036535657 -0.828512118 [13,] -1.244559196 -1.036535657 [14,] -1.252582735 -1.244559196 [15,] -1.060606274 -1.252582735 [16,] -1.068629813 -1.060606274 [17,] -1.376653352 -1.068629813 [18,] -1.184676891 -1.376653352 [19,] -0.992700430 -1.184676891 [20,] -0.600723969 -0.992700430 [21,] 0.091252492 -0.600723969 [22,] 0.083228953 0.091252492 [23,] 0.175205414 0.083228953 [24,] 0.167181875 0.175205414 [25,] -0.040841664 0.167181875 [26,] -0.148865203 -0.040841664 [27,] -0.356888742 -0.148865203 [28,] -0.564912281 -0.356888742 [29,] -0.672935820 -0.564912281 [30,] 0.019040641 -0.672935820 [31,] 0.111017102 0.019040641 [32,] 0.302993563 0.111017102 [33,] 0.494970024 0.302993563 [34,] 0.586946486 0.494970024 [35,] 0.678922947 0.586946486 [36,] 0.770899408 0.678922947 [37,] 0.662875869 0.770899408 [38,] 0.454852330 0.662875869 [39,] 0.346828791 0.454852330 [40,] 0.038805252 0.346828791 [41,] 0.030781713 0.038805252 [42,] 0.622758174 0.030781713 [43,] 0.714734635 0.622758174 [44,] 0.806711096 0.714734635 [45,] 0.798687557 0.806711096 [46,] 0.790664018 0.798687557 [47,] 0.982640479 0.790664018 [48,] 1.274616940 0.982640479 [49,] 1.166593401 1.274616940 [50,] 0.658569862 1.166593401 [51,] -0.149453677 0.658569862 [52,] -0.457477216 -0.149453677 [53,] -0.165500755 -0.457477216 [54,] 1.126475706 -0.165500755 [55,] 1.618452167 1.126475706 [56,] 1.610428628 1.618452167 [57,] 1.051053166 1.610428628 [58,] 0.543029627 1.051053166 [59,] 0.635006088 0.543029627 [60,] 0.826982549 0.635006088 [61,] 0.918959010 0.826982549 [62,] 0.910935471 0.918959010 [63,] 0.502911932 0.910935471 [64,] 0.394888393 0.502911932 [65,] 0.286864854 0.394888393 [66,] 0.878841315 0.286864854 [67,] 0.970817776 0.878841315 [68,] 1.062794237 0.970817776 [69,] 0.754770698 1.062794237 [70,] 0.646747159 0.754770698 [71,] 0.738723620 0.646747159 [72,] 0.930700081 0.738723620 [73,] 0.922676542 0.930700081 [74,] 0.814653003 0.922676542 [75,] 0.706629464 0.814653003 [76,] 0.498605925 0.706629464 [77,] 0.290582386 0.498605925 [78,] 0.382558847 0.290582386 [79,] 0.274535308 0.382558847 [80,] 0.266511769 0.274535308 [81,] 0.058488231 0.266511769 [82,] 0.050464692 0.058488231 [83,] 0.042441153 0.050464692 [84,] 0.134417614 0.042441153 [85,] 0.126394075 0.134417614 [86,] 0.018370536 0.126394075 [87,] 0.110346997 0.018370536 [88,] -0.197676542 0.110346997 [89,] -0.705700081 -0.197676542 [90,] -0.413723620 -0.705700081 [91,] -0.621747159 -0.413723620 [92,] -0.929770698 -0.621747159 [93,] -0.937794237 -0.929770698 [94,] -0.945817776 -0.937794237 [95,] -0.753841315 -0.945817776 [96,] -0.661864854 -0.753841315 [97,] -0.869888393 -0.661864854 [98,] -1.177911932 -0.869888393 [99,] -1.385935471 -1.177911932 [100,] -1.793959010 -1.385935471 [101,] -1.801982549 -1.793959010 [102,] -1.210006088 -1.801982549 [103,] -1.118029627 -1.210006088 [104,] -1.226053166 -1.118029627 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -0.048276729 0.259746810 2 -0.356300268 -0.048276729 3 -0.564323807 -0.356300268 4 -0.872347346 -0.564323807 5 -0.980370885 -0.872347346 6 -0.488394424 -0.980370885 7 0.003582037 -0.488394424 8 -0.204441501 0.003582037 9 -0.212465040 -0.204441501 10 -0.520488579 -0.212465040 11 -0.828512118 -0.520488579 12 -1.036535657 -0.828512118 13 -1.244559196 -1.036535657 14 -1.252582735 -1.244559196 15 -1.060606274 -1.252582735 16 -1.068629813 -1.060606274 17 -1.376653352 -1.068629813 18 -1.184676891 -1.376653352 19 -0.992700430 -1.184676891 20 -0.600723969 -0.992700430 21 0.091252492 -0.600723969 22 0.083228953 0.091252492 23 0.175205414 0.083228953 24 0.167181875 0.175205414 25 -0.040841664 0.167181875 26 -0.148865203 -0.040841664 27 -0.356888742 -0.148865203 28 -0.564912281 -0.356888742 29 -0.672935820 -0.564912281 30 0.019040641 -0.672935820 31 0.111017102 0.019040641 32 0.302993563 0.111017102 33 0.494970024 0.302993563 34 0.586946486 0.494970024 35 0.678922947 0.586946486 36 0.770899408 0.678922947 37 0.662875869 0.770899408 38 0.454852330 0.662875869 39 0.346828791 0.454852330 40 0.038805252 0.346828791 41 0.030781713 0.038805252 42 0.622758174 0.030781713 43 0.714734635 0.622758174 44 0.806711096 0.714734635 45 0.798687557 0.806711096 46 0.790664018 0.798687557 47 0.982640479 0.790664018 48 1.274616940 0.982640479 49 1.166593401 1.274616940 50 0.658569862 1.166593401 51 -0.149453677 0.658569862 52 -0.457477216 -0.149453677 53 -0.165500755 -0.457477216 54 1.126475706 -0.165500755 55 1.618452167 1.126475706 56 1.610428628 1.618452167 57 1.051053166 1.610428628 58 0.543029627 1.051053166 59 0.635006088 0.543029627 60 0.826982549 0.635006088 61 0.918959010 0.826982549 62 0.910935471 0.918959010 63 0.502911932 0.910935471 64 0.394888393 0.502911932 65 0.286864854 0.394888393 66 0.878841315 0.286864854 67 0.970817776 0.878841315 68 1.062794237 0.970817776 69 0.754770698 1.062794237 70 0.646747159 0.754770698 71 0.738723620 0.646747159 72 0.930700081 0.738723620 73 0.922676542 0.930700081 74 0.814653003 0.922676542 75 0.706629464 0.814653003 76 0.498605925 0.706629464 77 0.290582386 0.498605925 78 0.382558847 0.290582386 79 0.274535308 0.382558847 80 0.266511769 0.274535308 81 0.058488231 0.266511769 82 0.050464692 0.058488231 83 0.042441153 0.050464692 84 0.134417614 0.042441153 85 0.126394075 0.134417614 86 0.018370536 0.126394075 87 0.110346997 0.018370536 88 -0.197676542 0.110346997 89 -0.705700081 -0.197676542 90 -0.413723620 -0.705700081 91 -0.621747159 -0.413723620 92 -0.929770698 -0.621747159 93 -0.937794237 -0.929770698 94 -0.945817776 -0.937794237 95 -0.753841315 -0.945817776 96 -0.661864854 -0.753841315 97 -0.869888393 -0.661864854 98 -1.177911932 -0.869888393 99 -1.385935471 -1.177911932 100 -1.793959010 -1.385935471 101 -1.801982549 -1.793959010 102 -1.210006088 -1.801982549 103 -1.118029627 -1.210006088 104 -1.226053166 -1.118029627 > plot(z,main=paste('Residual Lag plot, lowess, and regression line'), ylab='values of Residuals', xlab='lagged values of Residuals') > lines(lowess(z)) > abline(lm(z)) > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/7fxg01227785563.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > acf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Autocorrelation Function') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/8z1xt1227785563.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > pacf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Partial Autocorrelation Function') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/9rzyj1227785563.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0)) > plot(mylm, las = 1, sub='Residual Diagnostics') > par(opar) > dev.off() null device 1 > if (n > n25) { + postscript(file="/var/www/html/rcomp/tmp/10p5951227785563.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) + plot(kp3:nmkm3,gqarr[,2], main='Goldfeld-Quandt test',ylab='2-sided p-value',xlab='breakpoint') + grid() + dev.off() + } null device 1 > > #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a, 'Multiple Linear Regression - Estimated Regression Equation', 1, TRUE) > a<-table.row.end(a) > myeq <- colnames(x)[1] > myeq <- paste(myeq, '[t] = ', sep='') > for (i in 1:k){ + if (mysum$coefficients[i,1] > 0) myeq <- paste(myeq, '+', '') + myeq <- paste(myeq, mysum$coefficients[i,1], sep=' ') + if (rownames(mysum$coefficients)[i] != '(Intercept)') { + myeq <- paste(myeq, rownames(mysum$coefficients)[i], sep='') + if (rownames(mysum$coefficients)[i] != 't') myeq <- paste(myeq, '[t]', sep='') + } + } > myeq <- paste(myeq, ' + e[t]') > a<-table.row.start(a) > a<-table.element(a, myeq) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/11gda71227785563.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,hyperlink('http://www.xycoon.com/ols1.htm','Multiple Linear Regression - Ordinary Least Squares',''), 6, TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Variable',header=TRUE) > a<-table.element(a,'Parameter',header=TRUE) > a<-table.element(a,'S.D.',header=TRUE) > a<-table.element(a,'T-STAT
H0: parameter = 0',header=TRUE) > a<-table.element(a,'2-tail p-value',header=TRUE) > a<-table.element(a,'1-tail p-value',header=TRUE) > a<-table.row.end(a) > for (i in 1:k){ + a<-table.row.start(a) + a<-table.element(a,rownames(mysum$coefficients)[i],header=TRUE) + a<-table.element(a,mysum$coefficients[i,1]) + a<-table.element(a, round(mysum$coefficients[i,2],6)) + a<-table.element(a, round(mysum$coefficients[i,3],4)) + a<-table.element(a, round(mysum$coefficients[i,4],6)) + a<-table.element(a, round(mysum$coefficients[i,4]/2,6)) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/12215b1227785563.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a, 'Multiple Linear Regression - Regression Statistics', 2, TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'Multiple R',1,TRUE) > a<-table.element(a, sqrt(mysum$r.squared)) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'R-squared',1,TRUE) > a<-table.element(a, mysum$r.squared) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'Adjusted R-squared',1,TRUE) > a<-table.element(a, mysum$adj.r.squared) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'F-TEST (value)',1,TRUE) > a<-table.element(a, mysum$fstatistic[1]) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'F-TEST (DF numerator)',1,TRUE) > a<-table.element(a, mysum$fstatistic[2]) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'F-TEST (DF denominator)',1,TRUE) > a<-table.element(a, mysum$fstatistic[3]) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'p-value',1,TRUE) > a<-table.element(a, 1-pf(mysum$fstatistic[1],mysum$fstatistic[2],mysum$fstatistic[3])) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'Multiple Linear Regression - Residual Statistics', 2, TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'Residual Standard Deviation',1,TRUE) > a<-table.element(a, mysum$sigma) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'Sum Squared Residuals',1,TRUE) > a<-table.element(a, sum(myerror*myerror)) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/13438r1227785564.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a, 'Multiple Linear Regression - Actuals, Interpolation, and Residuals', 4, TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'Time or Index', 1, TRUE) > a<-table.element(a, 'Actuals', 1, TRUE) > a<-table.element(a, 'Interpolation
Forecast', 1, TRUE) > a<-table.element(a, 'Residuals
Prediction Error', 1, TRUE) > a<-table.row.end(a) > for (i in 1:n) { + a<-table.row.start(a) + a<-table.element(a,i, 1, TRUE) + a<-table.element(a,x[i]) + a<-table.element(a,x[i]-mysum$resid[i]) + a<-table.element(a,mysum$resid[i]) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/14a0nk1227785564.tab") > if (n > n25) { + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'Goldfeld-Quandt test for Heteroskedasticity',4,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'p-values',header=TRUE) + a<-table.element(a,'Alternative Hypothesis',3,header=TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'breakpoint index',header=TRUE) + a<-table.element(a,'greater',header=TRUE) + a<-table.element(a,'2-sided',header=TRUE) + a<-table.element(a,'less',header=TRUE) + a<-table.row.end(a) + for (mypoint in kp3:nmkm3) { + a<-table.row.start(a) + a<-table.element(a,mypoint,header=TRUE) + a<-table.element(a,gqarr[mypoint-kp3+1,1]) + a<-table.element(a,gqarr[mypoint-kp3+1,2]) + a<-table.element(a,gqarr[mypoint-kp3+1,3]) + a<-table.row.end(a) + } + a<-table.end(a) + table.save(a,file="/var/www/html/rcomp/tmp/153r2k1227785564.tab") + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'Meta Analysis of Goldfeld-Quandt test for Heteroskedasticity',4,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'Description',header=TRUE) + a<-table.element(a,'# significant tests',header=TRUE) + a<-table.element(a,'% significant tests',header=TRUE) + a<-table.element(a,'OK/NOK',header=TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'1% type I error level',header=TRUE) + a<-table.element(a,numsignificant1) + a<-table.element(a,numsignificant1/numgqtests) + if (numsignificant1/numgqtests < 0.01) dum <- 'OK' else dum <- 'NOK' + a<-table.element(a,dum) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'5% type I error level',header=TRUE) + a<-table.element(a,numsignificant5) + a<-table.element(a,numsignificant5/numgqtests) + if (numsignificant5/numgqtests < 0.05) dum <- 'OK' else dum <- 'NOK' + a<-table.element(a,dum) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'10% type I error level',header=TRUE) + a<-table.element(a,numsignificant10) + a<-table.element(a,numsignificant10/numgqtests) + if (numsignificant10/numgqtests < 0.1) dum <- 'OK' else dum <- 'NOK' + a<-table.element(a,dum) + a<-table.row.end(a) + a<-table.end(a) + table.save(a,file="/var/www/html/rcomp/tmp/16oc9f1227785564.tab") + } > > system("convert tmp/1j5ur1227785563.ps tmp/1j5ur1227785563.png") > system("convert tmp/2k2z61227785563.ps tmp/2k2z61227785563.png") > system("convert tmp/3b5v71227785563.ps tmp/3b5v71227785563.png") > system("convert tmp/4mvww1227785563.ps tmp/4mvww1227785563.png") > system("convert tmp/5l0tu1227785563.ps tmp/5l0tu1227785563.png") > system("convert tmp/6lroo1227785563.ps tmp/6lroo1227785563.png") > system("convert tmp/7fxg01227785563.ps tmp/7fxg01227785563.png") > system("convert tmp/8z1xt1227785563.ps tmp/8z1xt1227785563.png") > system("convert tmp/9rzyj1227785563.ps tmp/9rzyj1227785563.png") > system("convert tmp/10p5951227785563.ps tmp/10p5951227785563.png") > > > proc.time() user system elapsed 2.947 1.578 3.588