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(98.5,0,97.0,0,103.3,0,99.6,0,100.1,0,102.9,0,95.9,0,94.5,0,107.4,0,116.0,0,102.8,0,99.8,0,109.6,0,103.0,0,111.6,0,106.3,0,97.9,0,108.8,0,103.9,0,101.2,0,122.9,0,123.9,0,111.7,0,120.9,0,99.6,0,103.3,0,119.4,0,106.5,0,101.9,0,124.6,0,106.5,0,107.8,0,127.4,0,120.1,0,118.5,0,127.7,0,107.7,0,104.5,0,118.8,0,110.3,0,109.6,0,119.1,0,96.5,0,106.7,0,126.3,0,116.2,0,118.8,0,115.2,0,110.0,0,111.4,0,129.6,0,108.1,0,117.8,0,122.9,0,100.6,0,111.8,0,127.0,0,128.6,0,124.8,0,118.5,0,114.7,0,112.6,0,128.7,0,111.0,0,115.8,0,126.0,0,111.1,1,113.2,1,120.1,1,130.6,1,124.0,1,119.4,1,116.7,1,116.5,1,119.6,1,126.5,1,111.3,1,123.5,1,114.2,1,103.7,1,129.5,1),dim=c(2,81),dimnames=list(c('Y','X'),1:81)) > y <- array(NA,dim=c(2,81),dimnames=list(c('Y','X'),1:81)) > 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 98.5 0 1 0 0 0 0 0 0 0 0 0 0 1 2 97.0 0 0 1 0 0 0 0 0 0 0 0 0 2 3 103.3 0 0 0 1 0 0 0 0 0 0 0 0 3 4 99.6 0 0 0 0 1 0 0 0 0 0 0 0 4 5 100.1 0 0 0 0 0 1 0 0 0 0 0 0 5 6 102.9 0 0 0 0 0 0 1 0 0 0 0 0 6 7 95.9 0 0 0 0 0 0 0 1 0 0 0 0 7 8 94.5 0 0 0 0 0 0 0 0 1 0 0 0 8 9 107.4 0 0 0 0 0 0 0 0 0 1 0 0 9 10 116.0 0 0 0 0 0 0 0 0 0 0 1 0 10 11 102.8 0 0 0 0 0 0 0 0 0 0 0 1 11 12 99.8 0 0 0 0 0 0 0 0 0 0 0 0 12 13 109.6 0 1 0 0 0 0 0 0 0 0 0 0 13 14 103.0 0 0 1 0 0 0 0 0 0 0 0 0 14 15 111.6 0 0 0 1 0 0 0 0 0 0 0 0 15 16 106.3 0 0 0 0 1 0 0 0 0 0 0 0 16 17 97.9 0 0 0 0 0 1 0 0 0 0 0 0 17 18 108.8 0 0 0 0 0 0 1 0 0 0 0 0 18 19 103.9 0 0 0 0 0 0 0 1 0 0 0 0 19 20 101.2 0 0 0 0 0 0 0 0 1 0 0 0 20 21 122.9 0 0 0 0 0 0 0 0 0 1 0 0 21 22 123.9 0 0 0 0 0 0 0 0 0 0 1 0 22 23 111.7 0 0 0 0 0 0 0 0 0 0 0 1 23 24 120.9 0 0 0 0 0 0 0 0 0 0 0 0 24 25 99.6 0 1 0 0 0 0 0 0 0 0 0 0 25 26 103.3 0 0 1 0 0 0 0 0 0 0 0 0 26 27 119.4 0 0 0 1 0 0 0 0 0 0 0 0 27 28 106.5 0 0 0 0 1 0 0 0 0 0 0 0 28 29 101.9 0 0 0 0 0 1 0 0 0 0 0 0 29 30 124.6 0 0 0 0 0 0 1 0 0 0 0 0 30 31 106.5 0 0 0 0 0 0 0 1 0 0 0 0 31 32 107.8 0 0 0 0 0 0 0 0 1 0 0 0 32 33 127.4 0 0 0 0 0 0 0 0 0 1 0 0 33 34 120.1 0 0 0 0 0 0 0 0 0 0 1 0 34 35 118.5 0 0 0 0 0 0 0 0 0 0 0 1 35 36 127.7 0 0 0 0 0 0 0 0 0 0 0 0 36 37 107.7 0 1 0 0 0 0 0 0 0 0 0 0 37 38 104.5 0 0 1 0 0 0 0 0 0 0 0 0 38 39 118.8 0 0 0 1 0 0 0 0 0 0 0 0 39 40 110.3 0 0 0 0 1 0 0 0 0 0 0 0 40 41 109.6 0 0 0 0 0 1 0 0 0 0 0 0 41 42 119.1 0 0 0 0 0 0 1 0 0 0 0 0 42 43 96.5 0 0 0 0 0 0 0 1 0 0 0 0 43 44 106.7 0 0 0 0 0 0 0 0 1 0 0 0 44 45 126.3 0 0 0 0 0 0 0 0 0 1 0 0 45 46 116.2 0 0 0 0 0 0 0 0 0 0 1 0 46 47 118.8 0 0 0 0 0 0 0 0 0 0 0 1 47 48 115.2 0 0 0 0 0 0 0 0 0 0 0 0 48 49 110.0 0 1 0 0 0 0 0 0 0 0 0 0 49 50 111.4 0 0 1 0 0 0 0 0 0 0 0 0 50 51 129.6 0 0 0 1 0 0 0 0 0 0 0 0 51 52 108.1 0 0 0 0 1 0 0 0 0 0 0 0 52 53 117.8 0 0 0 0 0 1 0 0 0 0 0 0 53 54 122.9 0 0 0 0 0 0 1 0 0 0 0 0 54 55 100.6 0 0 0 0 0 0 0 1 0 0 0 0 55 56 111.8 0 0 0 0 0 0 0 0 1 0 0 0 56 57 127.0 0 0 0 0 0 0 0 0 0 1 0 0 57 58 128.6 0 0 0 0 0 0 0 0 0 0 1 0 58 59 124.8 0 0 0 0 0 0 0 0 0 0 0 1 59 60 118.5 0 0 0 0 0 0 0 0 0 0 0 0 60 61 114.7 0 1 0 0 0 0 0 0 0 0 0 0 61 62 112.6 0 0 1 0 0 0 0 0 0 0 0 0 62 63 128.7 0 0 0 1 0 0 0 0 0 0 0 0 63 64 111.0 0 0 0 0 1 0 0 0 0 0 0 0 64 65 115.8 0 0 0 0 0 1 0 0 0 0 0 0 65 66 126.0 0 0 0 0 0 0 1 0 0 0 0 0 66 67 111.1 1 0 0 0 0 0 0 1 0 0 0 0 67 68 113.2 1 0 0 0 0 0 0 0 1 0 0 0 68 69 120.1 1 0 0 0 0 0 0 0 0 1 0 0 69 70 130.6 1 0 0 0 0 0 0 0 0 0 1 0 70 71 124.0 1 0 0 0 0 0 0 0 0 0 0 1 71 72 119.4 1 0 0 0 0 0 0 0 0 0 0 0 72 73 116.7 1 1 0 0 0 0 0 0 0 0 0 0 73 74 116.5 1 0 1 0 0 0 0 0 0 0 0 0 74 75 119.6 1 0 0 1 0 0 0 0 0 0 0 0 75 76 126.5 1 0 0 0 1 0 0 0 0 0 0 0 76 77 111.3 1 0 0 0 0 1 0 0 0 0 0 0 77 78 123.5 1 0 0 0 0 0 1 0 0 0 0 0 78 79 114.2 1 0 0 0 0 0 0 1 0 0 0 0 79 80 103.7 1 0 0 0 0 0 0 0 1 0 0 0 80 81 129.5 1 0 0 0 0 0 0 0 0 1 0 0 81 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X M1 M2 M3 M4 105.8928 -3.8627 -7.5053 -8.9974 2.5391 -6.6959 M5 M6 M7 M8 M9 M10 -8.9594 1.2485 -12.6346 -11.4553 5.6526 6.2056 M11 t 0.1278 0.2778 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -9.42639 -2.95181 -0.00895 2.75637 11.80637 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 105.89277 2.34302 45.195 < 2e-16 *** X -3.86265 1.95062 -1.980 0.051788 . M1 -7.50534 2.77892 -2.701 0.008751 ** M2 -8.99743 2.77761 -3.239 0.001866 ** M3 2.53906 2.77666 0.914 0.363772 M4 -6.69589 2.77609 -2.412 0.018612 * M5 -8.95940 2.77590 -3.228 0.001934 ** M6 1.24851 2.77607 0.450 0.654350 M7 -12.63463 2.78376 -4.539 2.41e-05 *** M8 -11.45529 2.78252 -4.117 0.000108 *** M9 5.65262 2.78164 2.032 0.046109 * M10 6.20560 2.88118 2.154 0.034854 * M11 0.12780 2.88064 0.044 0.964745 t 0.27780 0.03217 8.635 1.73e-12 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 4.989 on 67 degrees of freedom Multiple R-squared: 0.7823, Adjusted R-squared: 0.7401 F-statistic: 18.52 on 13 and 67 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.44319796 0.8863959 0.5568020 [2,] 0.29363771 0.5872754 0.7063623 [3,] 0.18437873 0.3687575 0.8156213 [4,] 0.10173705 0.2034741 0.8982630 [5,] 0.19305481 0.3861096 0.8069452 [6,] 0.12495096 0.2499019 0.8750490 [7,] 0.07946266 0.1589253 0.9205373 [8,] 0.30330298 0.6066060 0.6966970 [9,] 0.74168446 0.5166311 0.2583155 [10,] 0.71419004 0.5716199 0.2858100 [11,] 0.64716844 0.7056631 0.3528316 [12,] 0.60744292 0.7851142 0.3925571 [13,] 0.60764551 0.7847090 0.3923545 [14,] 0.69769919 0.6046016 0.3023008 [15,] 0.64726418 0.7054716 0.3527358 [16,] 0.58027637 0.8394473 0.4197236 [17,] 0.55604490 0.8879102 0.4439551 [18,] 0.56817285 0.8636543 0.4318271 [19,] 0.49748023 0.9949605 0.5025198 [20,] 0.72210490 0.5557902 0.2778951 [21,] 0.70124958 0.5975008 0.2987504 [22,] 0.70338029 0.5932394 0.2966197 [23,] 0.64573752 0.7085250 0.3542625 [24,] 0.58715831 0.8256834 0.4128417 [25,] 0.50926725 0.9814655 0.4907327 [26,] 0.43945391 0.8789078 0.5605461 [27,] 0.65196340 0.6960732 0.3480366 [28,] 0.58462596 0.8307481 0.4153740 [29,] 0.53651445 0.9269711 0.4634855 [30,] 0.69604659 0.6079068 0.3039534 [31,] 0.63489035 0.7302193 0.3651097 [32,] 0.60993895 0.7801221 0.3900610 [33,] 0.55505676 0.8898865 0.4449432 [34,] 0.47575927 0.9515185 0.5242407 [35,] 0.49601599 0.9920320 0.5039840 [36,] 0.56080162 0.8783968 0.4391984 [37,] 0.54243790 0.9151242 0.4575621 [38,] 0.45150483 0.9030097 0.5484952 [39,] 0.61884568 0.7623086 0.3811543 [40,] 0.54717903 0.9056419 0.4528210 [41,] 0.46962286 0.9392457 0.5303771 [42,] 0.37083737 0.7416747 0.6291626 [43,] 0.28171029 0.5634206 0.7182897 [44,] 0.20895458 0.4179092 0.7910454 [45,] 0.13640529 0.2728106 0.8635947 [46,] 0.08715357 0.1743071 0.9128464 [47,] 0.09543354 0.1908671 0.9045665 [48,] 0.31043580 0.6208716 0.6895642 > postscript(file="/var/www/html/rcomp/tmp/1lqo11229434956.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/2ommg1229434956.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/30vuj1229434956.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/4sbdq1229434956.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/59bd81229434956.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 = 81 Frequency = 1 1 2 3 4 5 6 -0.165232358 -0.450946644 -5.965232358 -0.708089501 1.777624785 -5.908089501 7 8 9 10 11 12 0.697246127 -2.159896730 -6.645611015 1.123608721 -6.276391279 -9.426391279 13 14 15 16 17 18 7.601147447 2.215433161 -0.998852553 2.658290304 -3.755995410 -3.341709696 19 20 21 22 23 24 5.363625932 1.206483075 5.520768789 5.689988526 -0.710011474 8.339988526 25 26 27 28 29 30 -5.732472748 -0.818187034 3.467527252 -0.475329891 -3.089615605 9.124670109 31 32 33 34 35 36 4.630005737 4.472862880 6.687148594 -1.443631670 2.756368330 11.806368330 37 38 39 40 41 42 -0.966092943 -2.951807229 -0.466092943 -0.008950086 1.276764200 0.291049914 43 44 45 46 47 48 -8.703614458 0.039242685 2.253528399 -8.677251865 -0.277251865 -4.027251865 49 50 51 52 53 54 -1.999713138 0.614572576 7.000286862 -5.542570281 6.143144005 0.757429719 55 56 57 58 59 60 -7.937234653 1.805622490 -0.380091796 0.389127940 2.389127940 -4.060872060 61 62 63 64 65 66 -0.633333333 -1.519047619 2.766666667 -5.976190476 0.809523810 0.523809524 67 68 69 70 71 72 3.091795754 3.734652897 -6.751061388 2.918158348 2.118158348 -2.631841652 73 74 75 76 77 78 1.895697074 2.909982788 -5.804302926 10.052839931 -3.161445783 -1.447160069 79 80 81 2.858175559 -9.098967298 -0.684681583 > postscript(file="/var/www/html/rcomp/tmp/66wpg1229434956.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 = 81 Frequency = 1 lag(myerror, k = 1) myerror 0 -0.165232358 NA 1 -0.450946644 -0.165232358 2 -5.965232358 -0.450946644 3 -0.708089501 -5.965232358 4 1.777624785 -0.708089501 5 -5.908089501 1.777624785 6 0.697246127 -5.908089501 7 -2.159896730 0.697246127 8 -6.645611015 -2.159896730 9 1.123608721 -6.645611015 10 -6.276391279 1.123608721 11 -9.426391279 -6.276391279 12 7.601147447 -9.426391279 13 2.215433161 7.601147447 14 -0.998852553 2.215433161 15 2.658290304 -0.998852553 16 -3.755995410 2.658290304 17 -3.341709696 -3.755995410 18 5.363625932 -3.341709696 19 1.206483075 5.363625932 20 5.520768789 1.206483075 21 5.689988526 5.520768789 22 -0.710011474 5.689988526 23 8.339988526 -0.710011474 24 -5.732472748 8.339988526 25 -0.818187034 -5.732472748 26 3.467527252 -0.818187034 27 -0.475329891 3.467527252 28 -3.089615605 -0.475329891 29 9.124670109 -3.089615605 30 4.630005737 9.124670109 31 4.472862880 4.630005737 32 6.687148594 4.472862880 33 -1.443631670 6.687148594 34 2.756368330 -1.443631670 35 11.806368330 2.756368330 36 -0.966092943 11.806368330 37 -2.951807229 -0.966092943 38 -0.466092943 -2.951807229 39 -0.008950086 -0.466092943 40 1.276764200 -0.008950086 41 0.291049914 1.276764200 42 -8.703614458 0.291049914 43 0.039242685 -8.703614458 44 2.253528399 0.039242685 45 -8.677251865 2.253528399 46 -0.277251865 -8.677251865 47 -4.027251865 -0.277251865 48 -1.999713138 -4.027251865 49 0.614572576 -1.999713138 50 7.000286862 0.614572576 51 -5.542570281 7.000286862 52 6.143144005 -5.542570281 53 0.757429719 6.143144005 54 -7.937234653 0.757429719 55 1.805622490 -7.937234653 56 -0.380091796 1.805622490 57 0.389127940 -0.380091796 58 2.389127940 0.389127940 59 -4.060872060 2.389127940 60 -0.633333333 -4.060872060 61 -1.519047619 -0.633333333 62 2.766666667 -1.519047619 63 -5.976190476 2.766666667 64 0.809523810 -5.976190476 65 0.523809524 0.809523810 66 3.091795754 0.523809524 67 3.734652897 3.091795754 68 -6.751061388 3.734652897 69 2.918158348 -6.751061388 70 2.118158348 2.918158348 71 -2.631841652 2.118158348 72 1.895697074 -2.631841652 73 2.909982788 1.895697074 74 -5.804302926 2.909982788 75 10.052839931 -5.804302926 76 -3.161445783 10.052839931 77 -1.447160069 -3.161445783 78 2.858175559 -1.447160069 79 -9.098967298 2.858175559 80 -0.684681583 -9.098967298 81 NA -0.684681583 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -0.450946644 -0.165232358 [2,] -5.965232358 -0.450946644 [3,] -0.708089501 -5.965232358 [4,] 1.777624785 -0.708089501 [5,] -5.908089501 1.777624785 [6,] 0.697246127 -5.908089501 [7,] -2.159896730 0.697246127 [8,] -6.645611015 -2.159896730 [9,] 1.123608721 -6.645611015 [10,] -6.276391279 1.123608721 [11,] -9.426391279 -6.276391279 [12,] 7.601147447 -9.426391279 [13,] 2.215433161 7.601147447 [14,] -0.998852553 2.215433161 [15,] 2.658290304 -0.998852553 [16,] -3.755995410 2.658290304 [17,] -3.341709696 -3.755995410 [18,] 5.363625932 -3.341709696 [19,] 1.206483075 5.363625932 [20,] 5.520768789 1.206483075 [21,] 5.689988526 5.520768789 [22,] -0.710011474 5.689988526 [23,] 8.339988526 -0.710011474 [24,] -5.732472748 8.339988526 [25,] -0.818187034 -5.732472748 [26,] 3.467527252 -0.818187034 [27,] -0.475329891 3.467527252 [28,] -3.089615605 -0.475329891 [29,] 9.124670109 -3.089615605 [30,] 4.630005737 9.124670109 [31,] 4.472862880 4.630005737 [32,] 6.687148594 4.472862880 [33,] -1.443631670 6.687148594 [34,] 2.756368330 -1.443631670 [35,] 11.806368330 2.756368330 [36,] -0.966092943 11.806368330 [37,] -2.951807229 -0.966092943 [38,] -0.466092943 -2.951807229 [39,] -0.008950086 -0.466092943 [40,] 1.276764200 -0.008950086 [41,] 0.291049914 1.276764200 [42,] -8.703614458 0.291049914 [43,] 0.039242685 -8.703614458 [44,] 2.253528399 0.039242685 [45,] -8.677251865 2.253528399 [46,] -0.277251865 -8.677251865 [47,] -4.027251865 -0.277251865 [48,] -1.999713138 -4.027251865 [49,] 0.614572576 -1.999713138 [50,] 7.000286862 0.614572576 [51,] -5.542570281 7.000286862 [52,] 6.143144005 -5.542570281 [53,] 0.757429719 6.143144005 [54,] -7.937234653 0.757429719 [55,] 1.805622490 -7.937234653 [56,] -0.380091796 1.805622490 [57,] 0.389127940 -0.380091796 [58,] 2.389127940 0.389127940 [59,] -4.060872060 2.389127940 [60,] -0.633333333 -4.060872060 [61,] -1.519047619 -0.633333333 [62,] 2.766666667 -1.519047619 [63,] -5.976190476 2.766666667 [64,] 0.809523810 -5.976190476 [65,] 0.523809524 0.809523810 [66,] 3.091795754 0.523809524 [67,] 3.734652897 3.091795754 [68,] -6.751061388 3.734652897 [69,] 2.918158348 -6.751061388 [70,] 2.118158348 2.918158348 [71,] -2.631841652 2.118158348 [72,] 1.895697074 -2.631841652 [73,] 2.909982788 1.895697074 [74,] -5.804302926 2.909982788 [75,] 10.052839931 -5.804302926 [76,] -3.161445783 10.052839931 [77,] -1.447160069 -3.161445783 [78,] 2.858175559 -1.447160069 [79,] -9.098967298 2.858175559 [80,] -0.684681583 -9.098967298 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -0.450946644 -0.165232358 2 -5.965232358 -0.450946644 3 -0.708089501 -5.965232358 4 1.777624785 -0.708089501 5 -5.908089501 1.777624785 6 0.697246127 -5.908089501 7 -2.159896730 0.697246127 8 -6.645611015 -2.159896730 9 1.123608721 -6.645611015 10 -6.276391279 1.123608721 11 -9.426391279 -6.276391279 12 7.601147447 -9.426391279 13 2.215433161 7.601147447 14 -0.998852553 2.215433161 15 2.658290304 -0.998852553 16 -3.755995410 2.658290304 17 -3.341709696 -3.755995410 18 5.363625932 -3.341709696 19 1.206483075 5.363625932 20 5.520768789 1.206483075 21 5.689988526 5.520768789 22 -0.710011474 5.689988526 23 8.339988526 -0.710011474 24 -5.732472748 8.339988526 25 -0.818187034 -5.732472748 26 3.467527252 -0.818187034 27 -0.475329891 3.467527252 28 -3.089615605 -0.475329891 29 9.124670109 -3.089615605 30 4.630005737 9.124670109 31 4.472862880 4.630005737 32 6.687148594 4.472862880 33 -1.443631670 6.687148594 34 2.756368330 -1.443631670 35 11.806368330 2.756368330 36 -0.966092943 11.806368330 37 -2.951807229 -0.966092943 38 -0.466092943 -2.951807229 39 -0.008950086 -0.466092943 40 1.276764200 -0.008950086 41 0.291049914 1.276764200 42 -8.703614458 0.291049914 43 0.039242685 -8.703614458 44 2.253528399 0.039242685 45 -8.677251865 2.253528399 46 -0.277251865 -8.677251865 47 -4.027251865 -0.277251865 48 -1.999713138 -4.027251865 49 0.614572576 -1.999713138 50 7.000286862 0.614572576 51 -5.542570281 7.000286862 52 6.143144005 -5.542570281 53 0.757429719 6.143144005 54 -7.937234653 0.757429719 55 1.805622490 -7.937234653 56 -0.380091796 1.805622490 57 0.389127940 -0.380091796 58 2.389127940 0.389127940 59 -4.060872060 2.389127940 60 -0.633333333 -4.060872060 61 -1.519047619 -0.633333333 62 2.766666667 -1.519047619 63 -5.976190476 2.766666667 64 0.809523810 -5.976190476 65 0.523809524 0.809523810 66 3.091795754 0.523809524 67 3.734652897 3.091795754 68 -6.751061388 3.734652897 69 2.918158348 -6.751061388 70 2.118158348 2.918158348 71 -2.631841652 2.118158348 72 1.895697074 -2.631841652 73 2.909982788 1.895697074 74 -5.804302926 2.909982788 75 10.052839931 -5.804302926 76 -3.161445783 10.052839931 77 -1.447160069 -3.161445783 78 2.858175559 -1.447160069 79 -9.098967298 2.858175559 80 -0.684681583 -9.098967298 > 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/7qimu1229434956.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/83n2x1229434956.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/9v9dn1229434956.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/10bh0o1229434956.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/11gd7y1229434956.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/12cycy1229434957.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/132ycl1229434957.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/14xckv1229434957.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/157kk91229434957.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/16lzi01229434957.tab") + } > > system("convert tmp/1lqo11229434956.ps tmp/1lqo11229434956.png") > system("convert tmp/2ommg1229434956.ps tmp/2ommg1229434956.png") > system("convert tmp/30vuj1229434956.ps tmp/30vuj1229434956.png") > system("convert tmp/4sbdq1229434956.ps tmp/4sbdq1229434956.png") > system("convert tmp/59bd81229434956.ps tmp/59bd81229434956.png") > system("convert tmp/66wpg1229434956.ps tmp/66wpg1229434956.png") > system("convert tmp/7qimu1229434956.ps tmp/7qimu1229434956.png") > system("convert tmp/83n2x1229434956.ps tmp/83n2x1229434956.png") > system("convert tmp/9v9dn1229434956.ps tmp/9v9dn1229434956.png") > system("convert tmp/10bh0o1229434956.ps tmp/10bh0o1229434956.png") > > > proc.time() user system elapsed 2.707 1.591 3.163