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(100,0,100,0,100,0,100.1,0,100,0,100,0,99.8,0,100,0,99.9,0,99.2,0,98.7,0,98.7,0,98.9,1,99.2,1,99.8,1,100.5,1,100.1,1,100.5,1,98.4,1,98.6,1,99,1,99.1,1,98.9,1,98.5,1,96.9,1,96.8,1,97,1,97,1,96.9,1,97.1,1,97.2,1,97.9,1,98.9,1,99.2,1,99.5,1,99.3,1,99.9,1,100,1,100.3,1,100.5,1,100.7,1,100.9,1,100.8,1,100.9,1,101,1,100.3,1,100.1,1,99.8,1,99.9,1,99.9,1,100.2,1,99.7,1,100.4,1,100.9,1,101.3,1,101.4,1,101.3,1,100.9,1,100.9,1,100.9,1,101.1,1,101.1,1,101.3,1,101.8,1,102.9,1,103.2,1,103.3,1,104.5,1,105,1,104.9,1,104.9,1,105.4,1,106,1,105.7,1,105.9,1,106.2,1,106.4,1,106.9,1,107.3,1,107.9,1,109.2,1,110.2,1,110.2,1,110.5,1,110.6,1,110.8,1,111.3,1,111.1,1,111.2,1,111.2,1,111.1,1,111.5,1,112.1,1,111.4,1),dim=c(2,94),dimnames=list(c('y','x'),1:94)) > y <- array(NA,dim=c(2,94),dimnames=list(c('y','x'),1:94)) > 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 = 'Include Monthly 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 y x M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 100.0 0 1 0 0 0 0 0 0 0 0 0 0 1 2 100.0 0 0 1 0 0 0 0 0 0 0 0 0 2 3 100.0 0 0 0 1 0 0 0 0 0 0 0 0 3 4 100.1 0 0 0 0 1 0 0 0 0 0 0 0 4 5 100.0 0 0 0 0 0 1 0 0 0 0 0 0 5 6 100.0 0 0 0 0 0 0 1 0 0 0 0 0 6 7 99.8 0 0 0 0 0 0 0 1 0 0 0 0 7 8 100.0 0 0 0 0 0 0 0 0 1 0 0 0 8 9 99.9 0 0 0 0 0 0 0 0 0 1 0 0 9 10 99.2 0 0 0 0 0 0 0 0 0 0 1 0 10 11 98.7 0 0 0 0 0 0 0 0 0 0 0 1 11 12 98.7 0 0 0 0 0 0 0 0 0 0 0 0 12 13 98.9 1 1 0 0 0 0 0 0 0 0 0 0 13 14 99.2 1 0 1 0 0 0 0 0 0 0 0 0 14 15 99.8 1 0 0 1 0 0 0 0 0 0 0 0 15 16 100.5 1 0 0 0 1 0 0 0 0 0 0 0 16 17 100.1 1 0 0 0 0 1 0 0 0 0 0 0 17 18 100.5 1 0 0 0 0 0 1 0 0 0 0 0 18 19 98.4 1 0 0 0 0 0 0 1 0 0 0 0 19 20 98.6 1 0 0 0 0 0 0 0 1 0 0 0 20 21 99.0 1 0 0 0 0 0 0 0 0 1 0 0 21 22 99.1 1 0 0 0 0 0 0 0 0 0 1 0 22 23 98.9 1 0 0 0 0 0 0 0 0 0 0 1 23 24 98.5 1 0 0 0 0 0 0 0 0 0 0 0 24 25 96.9 1 1 0 0 0 0 0 0 0 0 0 0 25 26 96.8 1 0 1 0 0 0 0 0 0 0 0 0 26 27 97.0 1 0 0 1 0 0 0 0 0 0 0 0 27 28 97.0 1 0 0 0 1 0 0 0 0 0 0 0 28 29 96.9 1 0 0 0 0 1 0 0 0 0 0 0 29 30 97.1 1 0 0 0 0 0 1 0 0 0 0 0 30 31 97.2 1 0 0 0 0 0 0 1 0 0 0 0 31 32 97.9 1 0 0 0 0 0 0 0 1 0 0 0 32 33 98.9 1 0 0 0 0 0 0 0 0 1 0 0 33 34 99.2 1 0 0 0 0 0 0 0 0 0 1 0 34 35 99.5 1 0 0 0 0 0 0 0 0 0 0 1 35 36 99.3 1 0 0 0 0 0 0 0 0 0 0 0 36 37 99.9 1 1 0 0 0 0 0 0 0 0 0 0 37 38 100.0 1 0 1 0 0 0 0 0 0 0 0 0 38 39 100.3 1 0 0 1 0 0 0 0 0 0 0 0 39 40 100.5 1 0 0 0 1 0 0 0 0 0 0 0 40 41 100.7 1 0 0 0 0 1 0 0 0 0 0 0 41 42 100.9 1 0 0 0 0 0 1 0 0 0 0 0 42 43 100.8 1 0 0 0 0 0 0 1 0 0 0 0 43 44 100.9 1 0 0 0 0 0 0 0 1 0 0 0 44 45 101.0 1 0 0 0 0 0 0 0 0 1 0 0 45 46 100.3 1 0 0 0 0 0 0 0 0 0 1 0 46 47 100.1 1 0 0 0 0 0 0 0 0 0 0 1 47 48 99.8 1 0 0 0 0 0 0 0 0 0 0 0 48 49 99.9 1 1 0 0 0 0 0 0 0 0 0 0 49 50 99.9 1 0 1 0 0 0 0 0 0 0 0 0 50 51 100.2 1 0 0 1 0 0 0 0 0 0 0 0 51 52 99.7 1 0 0 0 1 0 0 0 0 0 0 0 52 53 100.4 1 0 0 0 0 1 0 0 0 0 0 0 53 54 100.9 1 0 0 0 0 0 1 0 0 0 0 0 54 55 101.3 1 0 0 0 0 0 0 1 0 0 0 0 55 56 101.4 1 0 0 0 0 0 0 0 1 0 0 0 56 57 101.3 1 0 0 0 0 0 0 0 0 1 0 0 57 58 100.9 1 0 0 0 0 0 0 0 0 0 1 0 58 59 100.9 1 0 0 0 0 0 0 0 0 0 0 1 59 60 100.9 1 0 0 0 0 0 0 0 0 0 0 0 60 61 101.1 1 1 0 0 0 0 0 0 0 0 0 0 61 62 101.1 1 0 1 0 0 0 0 0 0 0 0 0 62 63 101.3 1 0 0 1 0 0 0 0 0 0 0 0 63 64 101.8 1 0 0 0 1 0 0 0 0 0 0 0 64 65 102.9 1 0 0 0 0 1 0 0 0 0 0 0 65 66 103.2 1 0 0 0 0 0 1 0 0 0 0 0 66 67 103.3 1 0 0 0 0 0 0 1 0 0 0 0 67 68 104.5 1 0 0 0 0 0 0 0 1 0 0 0 68 69 105.0 1 0 0 0 0 0 0 0 0 1 0 0 69 70 104.9 1 0 0 0 0 0 0 0 0 0 1 0 70 71 104.9 1 0 0 0 0 0 0 0 0 0 0 1 71 72 105.4 1 0 0 0 0 0 0 0 0 0 0 0 72 73 106.0 1 1 0 0 0 0 0 0 0 0 0 0 73 74 105.7 1 0 1 0 0 0 0 0 0 0 0 0 74 75 105.9 1 0 0 1 0 0 0 0 0 0 0 0 75 76 106.2 1 0 0 0 1 0 0 0 0 0 0 0 76 77 106.4 1 0 0 0 0 1 0 0 0 0 0 0 77 78 106.9 1 0 0 0 0 0 1 0 0 0 0 0 78 79 107.3 1 0 0 0 0 0 0 1 0 0 0 0 79 80 107.9 1 0 0 0 0 0 0 0 1 0 0 0 80 81 109.2 1 0 0 0 0 0 0 0 0 1 0 0 81 82 110.2 1 0 0 0 0 0 0 0 0 0 1 0 82 83 110.2 1 0 0 0 0 0 0 0 0 0 0 1 83 84 110.5 1 0 0 0 0 0 0 0 0 0 0 0 84 85 110.6 1 1 0 0 0 0 0 0 0 0 0 0 85 86 110.8 1 0 1 0 0 0 0 0 0 0 0 0 86 87 111.3 1 0 0 1 0 0 0 0 0 0 0 0 87 88 111.1 1 0 0 0 1 0 0 0 0 0 0 0 88 89 111.2 1 0 0 0 0 1 0 0 0 0 0 0 89 90 111.2 1 0 0 0 0 0 1 0 0 0 0 0 90 91 111.1 1 0 0 0 0 0 0 1 0 0 0 0 91 92 111.5 1 0 0 0 0 0 0 0 1 0 0 0 92 93 112.1 1 0 0 0 0 0 0 0 0 1 0 0 93 94 111.4 1 0 0 0 0 0 0 0 0 0 1 0 94 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) x M1 M2 M3 M4 97.9817 -5.0488 0.7372 0.5910 0.7073 0.6736 M5 M6 M7 M8 M9 M10 0.7149 0.8062 0.4475 0.7138 1.0052 0.6840 M11 t 0.1855 0.1712 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -3.1254 -1.3503 -0.1797 1.4648 4.1544 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 97.981732 0.912832 107.338 < 2e-16 *** x -5.048788 0.748778 -6.743 2.20e-09 *** M1 0.737190 1.021858 0.721 0.473 M2 0.590997 1.021411 0.579 0.564 M3 0.707305 1.021047 0.693 0.490 M4 0.673613 1.020767 0.660 0.511 M5 0.714921 1.020571 0.701 0.486 M6 0.806228 1.020458 0.790 0.432 M7 0.447536 1.020430 0.439 0.662 M8 0.713844 1.020485 0.700 0.486 M9 1.005152 1.020624 0.985 0.328 M10 0.683959 1.020848 0.670 0.505 M11 0.185478 1.053875 0.176 0.861 t 0.171192 0.009252 18.504 < 2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.972 on 80 degrees of freedom Multiple R-squared: 0.8236, Adjusted R-squared: 0.7949 F-statistic: 28.73 on 13 and 80 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,] 2.871359e-02 5.742718e-02 0.971286409 [2,] 1.461809e-02 2.923617e-02 0.985381914 [3,] 1.226244e-02 2.452489e-02 0.987737556 [4,] 8.094039e-03 1.618808e-02 0.991905961 [5,] 3.319246e-03 6.638491e-03 0.996680754 [6,] 1.469034e-03 2.938068e-03 0.998530966 [7,] 8.431789e-04 1.686358e-03 0.999156821 [8,] 3.548584e-04 7.097169e-04 0.999645142 [9,] 1.131258e-04 2.262516e-04 0.999886874 [10,] 3.608077e-05 7.216153e-05 0.999963919 [11,] 1.116219e-05 2.232438e-05 0.999988838 [12,] 4.556362e-06 9.112724e-06 0.999995444 [13,] 1.353488e-06 2.706975e-06 0.999998647 [14,] 3.777554e-07 7.555108e-07 0.999999622 [15,] 4.910452e-07 9.820904e-07 0.999999509 [16,] 1.425567e-06 2.851133e-06 0.999998574 [17,] 1.746937e-05 3.493873e-05 0.999982531 [18,] 1.957757e-04 3.915514e-04 0.999804224 [19,] 1.933339e-03 3.866677e-03 0.998066661 [20,] 6.357285e-03 1.271457e-02 0.993642715 [21,] 4.694441e-02 9.388883e-02 0.953055587 [22,] 1.104397e-01 2.208794e-01 0.889560318 [23,] 1.854900e-01 3.709799e-01 0.814510034 [24,] 2.822137e-01 5.644275e-01 0.717786259 [25,] 4.129664e-01 8.259328e-01 0.587033615 [26,] 5.628964e-01 8.742071e-01 0.437103558 [27,] 7.423694e-01 5.152612e-01 0.257630604 [28,] 8.544335e-01 2.911330e-01 0.145566482 [29,] 9.173361e-01 1.653278e-01 0.082663905 [30,] 9.431140e-01 1.137720e-01 0.056885998 [31,] 9.541331e-01 9.173375e-02 0.045866875 [32,] 9.541200e-01 9.176000e-02 0.045879999 [33,] 9.518112e-01 9.637762e-02 0.048188812 [34,] 9.531618e-01 9.367633e-02 0.046838165 [35,] 9.581477e-01 8.370456e-02 0.041852278 [36,] 9.525199e-01 9.496027e-02 0.047480133 [37,] 9.517104e-01 9.657924e-02 0.048289618 [38,] 9.623549e-01 7.529015e-02 0.037645073 [39,] 9.852476e-01 2.950478e-02 0.014752392 [40,] 9.917344e-01 1.653112e-02 0.008265560 [41,] 9.901513e-01 1.969733e-02 0.009848666 [42,] 9.853794e-01 2.924124e-02 0.014620620 [43,] 9.770478e-01 4.590430e-02 0.022952150 [44,] 9.694213e-01 6.115730e-02 0.030578651 [45,] 9.627235e-01 7.455302e-02 0.037276512 [46,] 9.552668e-01 8.946631e-02 0.044733155 [47,] 9.542501e-01 9.149979e-02 0.045749893 [48,] 9.429060e-01 1.141881e-01 0.057094027 [49,] 9.226742e-01 1.546517e-01 0.077325835 [50,] 8.956411e-01 2.087178e-01 0.104358880 [51,] 8.673397e-01 2.653206e-01 0.132660301 [52,] 8.769852e-01 2.460295e-01 0.123014769 [53,] 8.677228e-01 2.645544e-01 0.132277177 [54,] 8.471291e-01 3.057418e-01 0.152870896 [55,] 8.428500e-01 3.143001e-01 0.157150046 [56,] 8.364183e-01 3.271634e-01 0.163581683 [57,] 7.961771e-01 4.076458e-01 0.203822880 [58,] 7.640701e-01 4.718598e-01 0.235929879 [59,] 7.672668e-01 4.654664e-01 0.232733218 [60,] 7.306187e-01 5.387626e-01 0.269381284 [61,] 6.976825e-01 6.046351e-01 0.302317539 > postscript(file="/var/www/html/rcomp/tmp/1u0l91228940300.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/232kv1228940300.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/3r44k1228940300.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/4y14r1228940300.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/5nin01228940300.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 = 94 Frequency = 1 1 2 3 4 5 6 1.10988636 1.08488636 0.79738636 0.75988636 0.44738636 0.18488636 7 8 9 10 11 12 0.17238636 -0.06511364 -0.62761364 -1.17761364 -1.35032468 -1.33603896 13 14 15 16 17 18 3.00436688 3.27936688 3.59186688 4.15436688 3.54186688 3.67936688 19 20 21 22 23 24 1.76686688 1.52936688 1.46686688 1.71686688 1.84415584 1.45844156 25 26 27 28 29 30 -1.04994048 -1.17494048 -1.26244048 -1.39994048 -1.71244048 -1.77494048 31 32 33 34 35 36 -1.48744048 -1.22494048 -0.68744048 -0.23744048 0.38984848 0.20413420 37 38 39 40 41 42 -0.10424784 -0.02924784 -0.01674784 0.04575216 0.03325216 -0.02924784 43 44 45 46 47 48 0.05825216 -0.27924784 -0.64174784 -1.19174784 -1.06445887 -1.35017316 49 50 51 52 53 54 -2.15855519 -2.18355519 -2.17105519 -2.80855519 -2.32105519 -2.08355519 55 56 57 58 59 60 -1.49605519 -1.83355519 -2.39605519 -2.64605519 -2.31876623 -2.30448052 61 62 63 64 65 66 -3.01286255 -3.03786255 -3.12536255 -2.76286255 -1.87536255 -1.83786255 67 68 69 70 71 72 -1.55036255 -0.78786255 -0.75036255 -0.70036255 -0.37307359 0.14121212 73 74 75 76 77 78 -0.16716991 -0.49216991 -0.57966991 -0.41716991 -0.42966991 -0.19216991 79 80 81 82 83 84 0.39533009 0.55783009 1.39533009 2.54533009 2.87261905 3.18690476 85 86 87 88 89 90 2.37852273 2.55352273 2.76602273 2.42852273 2.31602273 2.05352273 91 92 93 94 2.14102273 2.10352273 2.24102273 1.69102273 > postscript(file="/var/www/html/rcomp/tmp/6aa461228940300.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 = 94 Frequency = 1 lag(myerror, k = 1) myerror 0 1.10988636 NA 1 1.08488636 1.10988636 2 0.79738636 1.08488636 3 0.75988636 0.79738636 4 0.44738636 0.75988636 5 0.18488636 0.44738636 6 0.17238636 0.18488636 7 -0.06511364 0.17238636 8 -0.62761364 -0.06511364 9 -1.17761364 -0.62761364 10 -1.35032468 -1.17761364 11 -1.33603896 -1.35032468 12 3.00436688 -1.33603896 13 3.27936688 3.00436688 14 3.59186688 3.27936688 15 4.15436688 3.59186688 16 3.54186688 4.15436688 17 3.67936688 3.54186688 18 1.76686688 3.67936688 19 1.52936688 1.76686688 20 1.46686688 1.52936688 21 1.71686688 1.46686688 22 1.84415584 1.71686688 23 1.45844156 1.84415584 24 -1.04994048 1.45844156 25 -1.17494048 -1.04994048 26 -1.26244048 -1.17494048 27 -1.39994048 -1.26244048 28 -1.71244048 -1.39994048 29 -1.77494048 -1.71244048 30 -1.48744048 -1.77494048 31 -1.22494048 -1.48744048 32 -0.68744048 -1.22494048 33 -0.23744048 -0.68744048 34 0.38984848 -0.23744048 35 0.20413420 0.38984848 36 -0.10424784 0.20413420 37 -0.02924784 -0.10424784 38 -0.01674784 -0.02924784 39 0.04575216 -0.01674784 40 0.03325216 0.04575216 41 -0.02924784 0.03325216 42 0.05825216 -0.02924784 43 -0.27924784 0.05825216 44 -0.64174784 -0.27924784 45 -1.19174784 -0.64174784 46 -1.06445887 -1.19174784 47 -1.35017316 -1.06445887 48 -2.15855519 -1.35017316 49 -2.18355519 -2.15855519 50 -2.17105519 -2.18355519 51 -2.80855519 -2.17105519 52 -2.32105519 -2.80855519 53 -2.08355519 -2.32105519 54 -1.49605519 -2.08355519 55 -1.83355519 -1.49605519 56 -2.39605519 -1.83355519 57 -2.64605519 -2.39605519 58 -2.31876623 -2.64605519 59 -2.30448052 -2.31876623 60 -3.01286255 -2.30448052 61 -3.03786255 -3.01286255 62 -3.12536255 -3.03786255 63 -2.76286255 -3.12536255 64 -1.87536255 -2.76286255 65 -1.83786255 -1.87536255 66 -1.55036255 -1.83786255 67 -0.78786255 -1.55036255 68 -0.75036255 -0.78786255 69 -0.70036255 -0.75036255 70 -0.37307359 -0.70036255 71 0.14121212 -0.37307359 72 -0.16716991 0.14121212 73 -0.49216991 -0.16716991 74 -0.57966991 -0.49216991 75 -0.41716991 -0.57966991 76 -0.42966991 -0.41716991 77 -0.19216991 -0.42966991 78 0.39533009 -0.19216991 79 0.55783009 0.39533009 80 1.39533009 0.55783009 81 2.54533009 1.39533009 82 2.87261905 2.54533009 83 3.18690476 2.87261905 84 2.37852273 3.18690476 85 2.55352273 2.37852273 86 2.76602273 2.55352273 87 2.42852273 2.76602273 88 2.31602273 2.42852273 89 2.05352273 2.31602273 90 2.14102273 2.05352273 91 2.10352273 2.14102273 92 2.24102273 2.10352273 93 1.69102273 2.24102273 94 NA 1.69102273 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 1.08488636 1.10988636 [2,] 0.79738636 1.08488636 [3,] 0.75988636 0.79738636 [4,] 0.44738636 0.75988636 [5,] 0.18488636 0.44738636 [6,] 0.17238636 0.18488636 [7,] -0.06511364 0.17238636 [8,] -0.62761364 -0.06511364 [9,] -1.17761364 -0.62761364 [10,] -1.35032468 -1.17761364 [11,] -1.33603896 -1.35032468 [12,] 3.00436688 -1.33603896 [13,] 3.27936688 3.00436688 [14,] 3.59186688 3.27936688 [15,] 4.15436688 3.59186688 [16,] 3.54186688 4.15436688 [17,] 3.67936688 3.54186688 [18,] 1.76686688 3.67936688 [19,] 1.52936688 1.76686688 [20,] 1.46686688 1.52936688 [21,] 1.71686688 1.46686688 [22,] 1.84415584 1.71686688 [23,] 1.45844156 1.84415584 [24,] -1.04994048 1.45844156 [25,] -1.17494048 -1.04994048 [26,] -1.26244048 -1.17494048 [27,] -1.39994048 -1.26244048 [28,] -1.71244048 -1.39994048 [29,] -1.77494048 -1.71244048 [30,] -1.48744048 -1.77494048 [31,] -1.22494048 -1.48744048 [32,] -0.68744048 -1.22494048 [33,] -0.23744048 -0.68744048 [34,] 0.38984848 -0.23744048 [35,] 0.20413420 0.38984848 [36,] -0.10424784 0.20413420 [37,] -0.02924784 -0.10424784 [38,] -0.01674784 -0.02924784 [39,] 0.04575216 -0.01674784 [40,] 0.03325216 0.04575216 [41,] -0.02924784 0.03325216 [42,] 0.05825216 -0.02924784 [43,] -0.27924784 0.05825216 [44,] -0.64174784 -0.27924784 [45,] -1.19174784 -0.64174784 [46,] -1.06445887 -1.19174784 [47,] -1.35017316 -1.06445887 [48,] -2.15855519 -1.35017316 [49,] -2.18355519 -2.15855519 [50,] -2.17105519 -2.18355519 [51,] -2.80855519 -2.17105519 [52,] -2.32105519 -2.80855519 [53,] -2.08355519 -2.32105519 [54,] -1.49605519 -2.08355519 [55,] -1.83355519 -1.49605519 [56,] -2.39605519 -1.83355519 [57,] -2.64605519 -2.39605519 [58,] -2.31876623 -2.64605519 [59,] -2.30448052 -2.31876623 [60,] -3.01286255 -2.30448052 [61,] -3.03786255 -3.01286255 [62,] -3.12536255 -3.03786255 [63,] -2.76286255 -3.12536255 [64,] -1.87536255 -2.76286255 [65,] -1.83786255 -1.87536255 [66,] -1.55036255 -1.83786255 [67,] -0.78786255 -1.55036255 [68,] -0.75036255 -0.78786255 [69,] -0.70036255 -0.75036255 [70,] -0.37307359 -0.70036255 [71,] 0.14121212 -0.37307359 [72,] -0.16716991 0.14121212 [73,] -0.49216991 -0.16716991 [74,] -0.57966991 -0.49216991 [75,] -0.41716991 -0.57966991 [76,] -0.42966991 -0.41716991 [77,] -0.19216991 -0.42966991 [78,] 0.39533009 -0.19216991 [79,] 0.55783009 0.39533009 [80,] 1.39533009 0.55783009 [81,] 2.54533009 1.39533009 [82,] 2.87261905 2.54533009 [83,] 3.18690476 2.87261905 [84,] 2.37852273 3.18690476 [85,] 2.55352273 2.37852273 [86,] 2.76602273 2.55352273 [87,] 2.42852273 2.76602273 [88,] 2.31602273 2.42852273 [89,] 2.05352273 2.31602273 [90,] 2.14102273 2.05352273 [91,] 2.10352273 2.14102273 [92,] 2.24102273 2.10352273 [93,] 1.69102273 2.24102273 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 1.08488636 1.10988636 2 0.79738636 1.08488636 3 0.75988636 0.79738636 4 0.44738636 0.75988636 5 0.18488636 0.44738636 6 0.17238636 0.18488636 7 -0.06511364 0.17238636 8 -0.62761364 -0.06511364 9 -1.17761364 -0.62761364 10 -1.35032468 -1.17761364 11 -1.33603896 -1.35032468 12 3.00436688 -1.33603896 13 3.27936688 3.00436688 14 3.59186688 3.27936688 15 4.15436688 3.59186688 16 3.54186688 4.15436688 17 3.67936688 3.54186688 18 1.76686688 3.67936688 19 1.52936688 1.76686688 20 1.46686688 1.52936688 21 1.71686688 1.46686688 22 1.84415584 1.71686688 23 1.45844156 1.84415584 24 -1.04994048 1.45844156 25 -1.17494048 -1.04994048 26 -1.26244048 -1.17494048 27 -1.39994048 -1.26244048 28 -1.71244048 -1.39994048 29 -1.77494048 -1.71244048 30 -1.48744048 -1.77494048 31 -1.22494048 -1.48744048 32 -0.68744048 -1.22494048 33 -0.23744048 -0.68744048 34 0.38984848 -0.23744048 35 0.20413420 0.38984848 36 -0.10424784 0.20413420 37 -0.02924784 -0.10424784 38 -0.01674784 -0.02924784 39 0.04575216 -0.01674784 40 0.03325216 0.04575216 41 -0.02924784 0.03325216 42 0.05825216 -0.02924784 43 -0.27924784 0.05825216 44 -0.64174784 -0.27924784 45 -1.19174784 -0.64174784 46 -1.06445887 -1.19174784 47 -1.35017316 -1.06445887 48 -2.15855519 -1.35017316 49 -2.18355519 -2.15855519 50 -2.17105519 -2.18355519 51 -2.80855519 -2.17105519 52 -2.32105519 -2.80855519 53 -2.08355519 -2.32105519 54 -1.49605519 -2.08355519 55 -1.83355519 -1.49605519 56 -2.39605519 -1.83355519 57 -2.64605519 -2.39605519 58 -2.31876623 -2.64605519 59 -2.30448052 -2.31876623 60 -3.01286255 -2.30448052 61 -3.03786255 -3.01286255 62 -3.12536255 -3.03786255 63 -2.76286255 -3.12536255 64 -1.87536255 -2.76286255 65 -1.83786255 -1.87536255 66 -1.55036255 -1.83786255 67 -0.78786255 -1.55036255 68 -0.75036255 -0.78786255 69 -0.70036255 -0.75036255 70 -0.37307359 -0.70036255 71 0.14121212 -0.37307359 72 -0.16716991 0.14121212 73 -0.49216991 -0.16716991 74 -0.57966991 -0.49216991 75 -0.41716991 -0.57966991 76 -0.42966991 -0.41716991 77 -0.19216991 -0.42966991 78 0.39533009 -0.19216991 79 0.55783009 0.39533009 80 1.39533009 0.55783009 81 2.54533009 1.39533009 82 2.87261905 2.54533009 83 3.18690476 2.87261905 84 2.37852273 3.18690476 85 2.55352273 2.37852273 86 2.76602273 2.55352273 87 2.42852273 2.76602273 88 2.31602273 2.42852273 89 2.05352273 2.31602273 90 2.14102273 2.05352273 91 2.10352273 2.14102273 92 2.24102273 2.10352273 93 1.69102273 2.24102273 > 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/77q351228940300.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/8ffe41228940300.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/9s2ed1228940300.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/10sm381228940300.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/11ybdy1228940300.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/125xmu1228940300.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/13lfvc1228940300.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/14vjya1228940300.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/15l0ki1228940300.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/169ch91228940300.tab") + } > > system("convert tmp/1u0l91228940300.ps tmp/1u0l91228940300.png") > system("convert tmp/232kv1228940300.ps tmp/232kv1228940300.png") > system("convert tmp/3r44k1228940300.ps tmp/3r44k1228940300.png") > system("convert tmp/4y14r1228940300.ps tmp/4y14r1228940300.png") > system("convert tmp/5nin01228940300.ps tmp/5nin01228940300.png") > system("convert tmp/6aa461228940300.ps tmp/6aa461228940300.png") > system("convert tmp/77q351228940300.ps tmp/77q351228940300.png") > system("convert tmp/8ffe41228940300.ps tmp/8ffe41228940300.png") > system("convert tmp/9s2ed1228940300.ps tmp/9s2ed1228940300.png") > system("convert tmp/10sm381228940300.ps tmp/10sm381228940300.png") > > > proc.time() user system elapsed 2.896 1.649 5.017