R version 2.9.0 (2009-04-17) Copyright (C) 2009 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(15335.63636 + ,13845.66667 + ,12823.61538 + ,12792 + ,10284.5 + ,11188.5 + ,15335.63636 + ,13845.66667 + ,12823.61538 + ,12792 + ,13633.25 + ,11188.5 + ,15335.63636 + ,13845.66667 + ,12823.61538 + ,12298.46667 + ,13633.25 + ,11188.5 + ,15335.63636 + ,13845.66667 + ,15353.63636 + ,12298.46667 + ,13633.25 + ,11188.5 + ,15335.63636 + ,12696.15385 + ,15353.63636 + ,12298.46667 + ,13633.25 + ,11188.5 + ,12213.93333 + ,12696.15385 + ,15353.63636 + ,12298.46667 + ,13633.25 + ,13683.72727 + ,12213.93333 + ,12696.15385 + ,15353.63636 + ,12298.46667 + ,11214.14286 + ,13683.72727 + ,12213.93333 + ,12696.15385 + ,15353.63636 + ,13950.23077 + ,11214.14286 + ,13683.72727 + ,12213.93333 + ,12696.15385 + ,11179.13333 + ,13950.23077 + ,11214.14286 + ,13683.72727 + ,12213.93333 + ,11801.875 + ,11179.13333 + ,13950.23077 + ,11214.14286 + ,13683.72727 + ,11188.82353 + ,11801.875 + ,11179.13333 + ,13950.23077 + ,11214.14286 + ,16456.27273 + ,11188.82353 + ,11801.875 + ,11179.13333 + ,13950.23077 + ,11110.0625 + ,16456.27273 + ,11188.82353 + ,11801.875 + ,11179.13333 + ,16530.69231 + ,11110.0625 + ,16456.27273 + ,11188.82353 + ,11801.875 + ,10038.41176 + ,16530.69231 + ,11110.0625 + ,16456.27273 + ,11188.82353 + ,11681.25 + ,10038.41176 + ,16530.69231 + ,11110.0625 + ,16456.27273 + ,11148.88235 + ,11681.25 + ,10038.41176 + ,16530.69231 + ,11110.0625 + ,8631 + ,11148.88235 + ,11681.25 + ,10038.41176 + ,16530.69231 + ,9386.444444 + ,8631 + ,11148.88235 + ,11681.25 + ,10038.41176 + ,9764.736842 + ,9386.444444 + ,8631 + ,11148.88235 + ,11681.25 + ,12043.75 + ,9764.736842 + ,9386.444444 + ,8631 + ,11148.88235 + ,12948.06667 + ,12043.75 + ,9764.736842 + ,9386.444444 + ,8631 + ,10987.125 + ,12948.06667 + ,12043.75 + ,9764.736842 + ,9386.444444 + ,11648.3125 + ,10987.125 + ,12948.06667 + ,12043.75 + ,9764.736842 + ,10633.35294 + ,11648.3125 + ,10987.125 + ,12948.06667 + ,12043.75 + ,10219.3 + ,10633.35294 + ,11648.3125 + ,10987.125 + ,12948.06667 + ,9037.6 + ,10219.3 + ,10633.35294 + ,11648.3125 + ,10987.125 + ,10296.31579 + ,9037.6 + ,10219.3 + ,10633.35294 + ,11648.3125 + ,11705.41176 + ,10296.31579 + ,9037.6 + ,10219.3 + ,10633.35294 + ,10681.94444 + ,11705.41176 + ,10296.31579 + ,9037.6 + ,10219.3 + ,9362.947368 + ,10681.94444 + ,11705.41176 + ,10296.31579 + ,9037.6 + ,11306.35294 + ,9362.947368 + ,10681.94444 + ,11705.41176 + ,10296.31579 + ,10984.45 + ,11306.35294 + ,9362.947368 + ,10681.94444 + ,11705.41176 + ,10062.61905 + ,10984.45 + ,11306.35294 + ,9362.947368 + ,10681.94444 + ,8118.583333 + ,10062.61905 + ,10984.45 + ,11306.35294 + ,9362.947368 + ,8867.48 + ,8118.583333 + ,10062.61905 + ,10984.45 + ,11306.35294 + ,8346.72 + ,8867.48 + ,8118.583333 + ,10062.61905 + ,10984.45 + ,8529.307692 + ,8346.72 + ,8867.48 + ,8118.583333 + ,10062.61905 + ,10697.18182 + ,8529.307692 + ,8346.72 + ,8867.48 + ,8118.583333 + ,8591.84 + ,10697.18182 + ,8529.307692 + ,8346.72 + ,8867.48 + ,8695.607143 + ,8591.84 + ,10697.18182 + ,8529.307692 + ,8346.72 + ,8125.571429 + ,8695.607143 + ,8591.84 + ,10697.18182 + ,8529.307692 + ,7009.758621 + ,8125.571429 + ,8695.607143 + ,8591.84 + ,10697.18182 + ,7883.466667 + ,7009.758621 + ,8125.571429 + ,8695.607143 + ,8591.84 + ,7527.645161 + ,7883.466667 + ,7009.758621 + ,8125.571429 + ,8695.607143 + ,6763.758621 + ,7527.645161 + ,7883.466667 + ,7009.758621 + ,8125.571429 + ,6682.333333 + ,6763.758621 + ,7527.645161 + ,7883.466667 + ,7009.758621 + ,7855.681818 + ,6682.333333 + ,6763.758621 + ,7527.645161 + ,7883.466667 + ,6738.88 + ,7855.681818 + ,6682.333333 + ,6763.758621 + ,7527.645161 + ,7895.434783 + ,6738.88 + ,7855.681818 + ,6682.333333 + ,6763.758621 + ,6361.884615 + ,7895.434783 + ,6738.88 + ,7855.681818 + ,6682.333333 + ,6935.956522 + ,6361.884615 + ,7895.434783 + ,6738.88 + ,7855.681818 + ,8344.454545 + ,6935.956522 + ,6361.884615 + ,7895.434783 + ,6738.88 + ,9107.944444 + ,8344.454545 + ,6935.956522 + ,6361.884615 + ,7895.434783) + ,dim=c(5 + ,56) + ,dimnames=list(c('Yt' + ,'Yt-1' + ,'Yt-2' + ,'Yt-3' + ,'Yt-4') + ,1:56)) > y <- array(NA,dim=c(5,56),dimnames=list(c('Yt','Yt-1','Yt-2','Yt-3','Yt-4'),1:56)) > 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 Yt Yt-1 Yt-2 Yt-3 Yt-4 M1 M2 M3 M4 M5 M6 M7 M8 M9 1 15335.636 13845.667 12823.615 12792.000 10284.500 1 0 0 0 0 0 0 0 0 2 11188.500 15335.636 13845.667 12823.615 12792.000 0 1 0 0 0 0 0 0 0 3 13633.250 11188.500 15335.636 13845.667 12823.615 0 0 1 0 0 0 0 0 0 4 12298.467 13633.250 11188.500 15335.636 13845.667 0 0 0 1 0 0 0 0 0 5 15353.636 12298.467 13633.250 11188.500 15335.636 0 0 0 0 1 0 0 0 0 6 12696.154 15353.636 12298.467 13633.250 11188.500 0 0 0 0 0 1 0 0 0 7 12213.933 12696.154 15353.636 12298.467 13633.250 0 0 0 0 0 0 1 0 0 8 13683.727 12213.933 12696.154 15353.636 12298.467 0 0 0 0 0 0 0 1 0 9 11214.143 13683.727 12213.933 12696.154 15353.636 0 0 0 0 0 0 0 0 1 10 13950.231 11214.143 13683.727 12213.933 12696.154 0 0 0 0 0 0 0 0 0 11 11179.133 13950.231 11214.143 13683.727 12213.933 0 0 0 0 0 0 0 0 0 12 11801.875 11179.133 13950.231 11214.143 13683.727 0 0 0 0 0 0 0 0 0 13 11188.824 11801.875 11179.133 13950.231 11214.143 1 0 0 0 0 0 0 0 0 14 16456.273 11188.824 11801.875 11179.133 13950.231 0 1 0 0 0 0 0 0 0 15 11110.062 16456.273 11188.824 11801.875 11179.133 0 0 1 0 0 0 0 0 0 16 16530.692 11110.062 16456.273 11188.824 11801.875 0 0 0 1 0 0 0 0 0 17 10038.412 16530.692 11110.062 16456.273 11188.824 0 0 0 0 1 0 0 0 0 18 11681.250 10038.412 16530.692 11110.062 16456.273 0 0 0 0 0 1 0 0 0 19 11148.882 11681.250 10038.412 16530.692 11110.062 0 0 0 0 0 0 1 0 0 20 8631.000 11148.882 11681.250 10038.412 16530.692 0 0 0 0 0 0 0 1 0 21 9386.444 8631.000 11148.882 11681.250 10038.412 0 0 0 0 0 0 0 0 1 22 9764.737 9386.444 8631.000 11148.882 11681.250 0 0 0 0 0 0 0 0 0 23 12043.750 9764.737 9386.444 8631.000 11148.882 0 0 0 0 0 0 0 0 0 24 12948.067 12043.750 9764.737 9386.444 8631.000 0 0 0 0 0 0 0 0 0 25 10987.125 12948.067 12043.750 9764.737 9386.444 1 0 0 0 0 0 0 0 0 26 11648.312 10987.125 12948.067 12043.750 9764.737 0 1 0 0 0 0 0 0 0 27 10633.353 11648.312 10987.125 12948.067 12043.750 0 0 1 0 0 0 0 0 0 28 10219.300 10633.353 11648.312 10987.125 12948.067 0 0 0 1 0 0 0 0 0 29 9037.600 10219.300 10633.353 11648.312 10987.125 0 0 0 0 1 0 0 0 0 30 10296.316 9037.600 10219.300 10633.353 11648.312 0 0 0 0 0 1 0 0 0 31 11705.412 10296.316 9037.600 10219.300 10633.353 0 0 0 0 0 0 1 0 0 32 10681.944 11705.412 10296.316 9037.600 10219.300 0 0 0 0 0 0 0 1 0 33 9362.947 10681.944 11705.412 10296.316 9037.600 0 0 0 0 0 0 0 0 1 34 11306.353 9362.947 10681.944 11705.412 10296.316 0 0 0 0 0 0 0 0 0 35 10984.450 11306.353 9362.947 10681.944 11705.412 0 0 0 0 0 0 0 0 0 36 10062.619 10984.450 11306.353 9362.947 10681.944 0 0 0 0 0 0 0 0 0 37 8118.583 10062.619 10984.450 11306.353 9362.947 1 0 0 0 0 0 0 0 0 38 8867.480 8118.583 10062.619 10984.450 11306.353 0 1 0 0 0 0 0 0 0 39 8346.720 8867.480 8118.583 10062.619 10984.450 0 0 1 0 0 0 0 0 0 40 8529.308 8346.720 8867.480 8118.583 10062.619 0 0 0 1 0 0 0 0 0 41 10697.182 8529.308 8346.720 8867.480 8118.583 0 0 0 0 1 0 0 0 0 42 8591.840 10697.182 8529.308 8346.720 8867.480 0 0 0 0 0 1 0 0 0 43 8695.607 8591.840 10697.182 8529.308 8346.720 0 0 0 0 0 0 1 0 0 44 8125.571 8695.607 8591.840 10697.182 8529.308 0 0 0 0 0 0 0 1 0 45 7009.759 8125.571 8695.607 8591.840 10697.182 0 0 0 0 0 0 0 0 1 46 7883.467 7009.759 8125.571 8695.607 8591.840 0 0 0 0 0 0 0 0 0 47 7527.645 7883.467 7009.759 8125.571 8695.607 0 0 0 0 0 0 0 0 0 48 6763.759 7527.645 7883.467 7009.759 8125.571 0 0 0 0 0 0 0 0 0 49 6682.333 6763.759 7527.645 7883.467 7009.759 1 0 0 0 0 0 0 0 0 50 7855.682 6682.333 6763.759 7527.645 7883.467 0 1 0 0 0 0 0 0 0 51 6738.880 7855.682 6682.333 6763.759 7527.645 0 0 1 0 0 0 0 0 0 52 7895.435 6738.880 7855.682 6682.333 6763.759 0 0 0 1 0 0 0 0 0 53 6361.885 7895.435 6738.880 7855.682 6682.333 0 0 0 0 1 0 0 0 0 54 6935.957 6361.885 7895.435 6738.880 7855.682 0 0 0 0 0 1 0 0 0 55 8344.455 6935.957 6361.885 7895.435 6738.880 0 0 0 0 0 0 1 0 0 56 9107.944 8344.455 6935.957 6361.885 7895.435 0 0 0 0 0 0 0 1 0 M10 M11 t 1 0 0 1 2 0 0 2 3 0 0 3 4 0 0 4 5 0 0 5 6 0 0 6 7 0 0 7 8 0 0 8 9 0 0 9 10 1 0 10 11 0 1 11 12 0 0 12 13 0 0 13 14 0 0 14 15 0 0 15 16 0 0 16 17 0 0 17 18 0 0 18 19 0 0 19 20 0 0 20 21 0 0 21 22 1 0 22 23 0 1 23 24 0 0 24 25 0 0 25 26 0 0 26 27 0 0 27 28 0 0 28 29 0 0 29 30 0 0 30 31 0 0 31 32 0 0 32 33 0 0 33 34 1 0 34 35 0 1 35 36 0 0 36 37 0 0 37 38 0 0 38 39 0 0 39 40 0 0 40 41 0 0 41 42 0 0 42 43 0 0 43 44 0 0 44 45 0 0 45 46 1 0 46 47 0 1 47 48 0 0 48 49 0 0 49 50 0 0 50 51 0 0 51 52 0 0 52 53 0 0 53 54 0 0 54 55 0 0 55 56 0 0 56 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) `Yt-1` `Yt-2` `Yt-3` `Yt-4` M1 1.742e+04 -7.691e-02 2.898e-01 -2.297e-01 -2.482e-01 -4.827e+02 M2 M3 M4 M5 M6 M7 6.822e+02 -5.279e+01 7.047e+02 4.780e+02 -4.699e+01 6.554e+02 M8 M9 M10 M11 t 6.048e+02 -1.081e+03 5.817e+02 7.386e+02 -1.554e+02 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -3320.8 -706.3 -233.1 613.6 3995.1 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.742e+04 4.247e+03 4.103 0.000201 *** `Yt-1` -7.691e-02 1.591e-01 -0.483 0.631464 `Yt-2` 2.898e-01 1.575e-01 1.840 0.073448 . `Yt-3` -2.297e-01 1.535e-01 -1.497 0.142529 `Yt-4` -2.482e-01 1.544e-01 -1.607 0.116110 M1 -4.827e+02 1.029e+03 -0.469 0.641731 M2 6.822e+02 1.013e+03 0.674 0.504411 M3 -5.279e+01 1.018e+03 -0.052 0.958890 M4 7.047e+02 1.009e+03 0.698 0.489124 M5 4.780e+02 1.029e+03 0.464 0.644911 M6 -4.699e+01 1.007e+03 -0.047 0.963006 M7 6.554e+02 1.037e+03 0.632 0.531116 M8 6.048e+02 1.025e+03 0.590 0.558539 M9 -1.081e+03 1.069e+03 -1.012 0.317895 M10 5.817e+02 1.106e+03 0.526 0.601875 M11 7.386e+02 1.086e+03 0.680 0.500485 t -1.554e+02 3.928e+01 -3.956 0.000312 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1472 on 39 degrees of freedom Multiple R-squared: 0.7502, Adjusted R-squared: 0.6477 F-statistic: 7.32 on 16 and 39 DF, p-value: 2.065e-07 > 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.9761288 0.0477424314 0.0238712157 [2,] 0.9996209 0.0007581933 0.0003790966 [3,] 0.9997378 0.0005244207 0.0002622103 [4,] 0.9991598 0.0016803414 0.0008401707 [5,] 0.9984729 0.0030541181 0.0015270590 [6,] 0.9960450 0.0079100303 0.0039550151 [7,] 0.9913368 0.0173264353 0.0086632177 [8,] 0.9833906 0.0332188574 0.0166094287 [9,] 0.9705725 0.0588549158 0.0294274579 [10,] 0.9739595 0.0520809758 0.0260404879 [11,] 0.9488958 0.1022084844 0.0511042422 [12,] 0.9150547 0.1698905947 0.0849452973 [13,] 0.8729478 0.2541043924 0.1270521962 [14,] 0.7881299 0.4237402273 0.2118701137 [15,] 0.7642062 0.4715876035 0.2357938017 [16,] 0.6853562 0.6292875118 0.3146437559 [17,] 0.6034964 0.7930072604 0.3965036302 > postscript(file="/var/www/html/rcomp/tmp/1pq141258728656.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/2ptuz1258728656.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/34uwm1258728656.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/4fl4n1258728656.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/528d21258728656.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 = 56 Frequency = 1 1 2 3 4 5 6 1387.847648 -3320.767110 -493.740358 -444.965572 1598.609067 -224.526671 7 8 9 10 11 12 -2043.219283 735.921923 508.589086 350.888856 -1277.674971 -969.319199 13 14 15 16 17 18 -77.924396 3995.085600 -422.655351 2471.975738 -614.405013 -281.779535 19 20 21 22 23 24 564.642940 -2409.932092 -1086.431838 -1142.489024 234.882417 1647.419638 25 26 27 28 29 30 8.053491 -135.857437 1132.071568 -379.674914 -1251.791705 647.445250 31 32 33 34 35 36 1601.842220 153.792544 185.016170 1451.993132 1775.046151 602.335836 37 38 39 40 41 42 -562.278138 -296.845916 402.201867 -949.671983 1454.797819 209.960178 43 44 45 46 47 48 -1110.699067 -313.494041 392.826582 -660.392965 -732.253597 -1280.436275 49 50 51 52 53 54 -755.698606 -241.615137 -617.877727 -697.663270 -1187.210167 -351.099223 55 56 987.433191 1833.711665 > postscript(file="/var/www/html/rcomp/tmp/6nmse1258728656.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 = 56 Frequency = 1 lag(myerror, k = 1) myerror 0 1387.847648 NA 1 -3320.767110 1387.847648 2 -493.740358 -3320.767110 3 -444.965572 -493.740358 4 1598.609067 -444.965572 5 -224.526671 1598.609067 6 -2043.219283 -224.526671 7 735.921923 -2043.219283 8 508.589086 735.921923 9 350.888856 508.589086 10 -1277.674971 350.888856 11 -969.319199 -1277.674971 12 -77.924396 -969.319199 13 3995.085600 -77.924396 14 -422.655351 3995.085600 15 2471.975738 -422.655351 16 -614.405013 2471.975738 17 -281.779535 -614.405013 18 564.642940 -281.779535 19 -2409.932092 564.642940 20 -1086.431838 -2409.932092 21 -1142.489024 -1086.431838 22 234.882417 -1142.489024 23 1647.419638 234.882417 24 8.053491 1647.419638 25 -135.857437 8.053491 26 1132.071568 -135.857437 27 -379.674914 1132.071568 28 -1251.791705 -379.674914 29 647.445250 -1251.791705 30 1601.842220 647.445250 31 153.792544 1601.842220 32 185.016170 153.792544 33 1451.993132 185.016170 34 1775.046151 1451.993132 35 602.335836 1775.046151 36 -562.278138 602.335836 37 -296.845916 -562.278138 38 402.201867 -296.845916 39 -949.671983 402.201867 40 1454.797819 -949.671983 41 209.960178 1454.797819 42 -1110.699067 209.960178 43 -313.494041 -1110.699067 44 392.826582 -313.494041 45 -660.392965 392.826582 46 -732.253597 -660.392965 47 -1280.436275 -732.253597 48 -755.698606 -1280.436275 49 -241.615137 -755.698606 50 -617.877727 -241.615137 51 -697.663270 -617.877727 52 -1187.210167 -697.663270 53 -351.099223 -1187.210167 54 987.433191 -351.099223 55 1833.711665 987.433191 56 NA 1833.711665 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -3320.767110 1387.847648 [2,] -493.740358 -3320.767110 [3,] -444.965572 -493.740358 [4,] 1598.609067 -444.965572 [5,] -224.526671 1598.609067 [6,] -2043.219283 -224.526671 [7,] 735.921923 -2043.219283 [8,] 508.589086 735.921923 [9,] 350.888856 508.589086 [10,] -1277.674971 350.888856 [11,] -969.319199 -1277.674971 [12,] -77.924396 -969.319199 [13,] 3995.085600 -77.924396 [14,] -422.655351 3995.085600 [15,] 2471.975738 -422.655351 [16,] -614.405013 2471.975738 [17,] -281.779535 -614.405013 [18,] 564.642940 -281.779535 [19,] -2409.932092 564.642940 [20,] -1086.431838 -2409.932092 [21,] -1142.489024 -1086.431838 [22,] 234.882417 -1142.489024 [23,] 1647.419638 234.882417 [24,] 8.053491 1647.419638 [25,] -135.857437 8.053491 [26,] 1132.071568 -135.857437 [27,] -379.674914 1132.071568 [28,] -1251.791705 -379.674914 [29,] 647.445250 -1251.791705 [30,] 1601.842220 647.445250 [31,] 153.792544 1601.842220 [32,] 185.016170 153.792544 [33,] 1451.993132 185.016170 [34,] 1775.046151 1451.993132 [35,] 602.335836 1775.046151 [36,] -562.278138 602.335836 [37,] -296.845916 -562.278138 [38,] 402.201867 -296.845916 [39,] -949.671983 402.201867 [40,] 1454.797819 -949.671983 [41,] 209.960178 1454.797819 [42,] -1110.699067 209.960178 [43,] -313.494041 -1110.699067 [44,] 392.826582 -313.494041 [45,] -660.392965 392.826582 [46,] -732.253597 -660.392965 [47,] -1280.436275 -732.253597 [48,] -755.698606 -1280.436275 [49,] -241.615137 -755.698606 [50,] -617.877727 -241.615137 [51,] -697.663270 -617.877727 [52,] -1187.210167 -697.663270 [53,] -351.099223 -1187.210167 [54,] 987.433191 -351.099223 [55,] 1833.711665 987.433191 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -3320.767110 1387.847648 2 -493.740358 -3320.767110 3 -444.965572 -493.740358 4 1598.609067 -444.965572 5 -224.526671 1598.609067 6 -2043.219283 -224.526671 7 735.921923 -2043.219283 8 508.589086 735.921923 9 350.888856 508.589086 10 -1277.674971 350.888856 11 -969.319199 -1277.674971 12 -77.924396 -969.319199 13 3995.085600 -77.924396 14 -422.655351 3995.085600 15 2471.975738 -422.655351 16 -614.405013 2471.975738 17 -281.779535 -614.405013 18 564.642940 -281.779535 19 -2409.932092 564.642940 20 -1086.431838 -2409.932092 21 -1142.489024 -1086.431838 22 234.882417 -1142.489024 23 1647.419638 234.882417 24 8.053491 1647.419638 25 -135.857437 8.053491 26 1132.071568 -135.857437 27 -379.674914 1132.071568 28 -1251.791705 -379.674914 29 647.445250 -1251.791705 30 1601.842220 647.445250 31 153.792544 1601.842220 32 185.016170 153.792544 33 1451.993132 185.016170 34 1775.046151 1451.993132 35 602.335836 1775.046151 36 -562.278138 602.335836 37 -296.845916 -562.278138 38 402.201867 -296.845916 39 -949.671983 402.201867 40 1454.797819 -949.671983 41 209.960178 1454.797819 42 -1110.699067 209.960178 43 -313.494041 -1110.699067 44 392.826582 -313.494041 45 -660.392965 392.826582 46 -732.253597 -660.392965 47 -1280.436275 -732.253597 48 -755.698606 -1280.436275 49 -241.615137 -755.698606 50 -617.877727 -241.615137 51 -697.663270 -617.877727 52 -1187.210167 -697.663270 53 -351.099223 -1187.210167 54 987.433191 -351.099223 55 1833.711665 987.433191 > 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/7r0ln1258728656.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/8x1971258728656.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/97vjp1258728656.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/10ik6m1258728656.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/11r2vl1258728656.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/12s3bz1258728656.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/13wd4n1258728656.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/14rs841258728656.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/15oqvs1258728656.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/16zjvd1258728656.tab") + } > > system("convert tmp/1pq141258728656.ps tmp/1pq141258728656.png") > system("convert tmp/2ptuz1258728656.ps tmp/2ptuz1258728656.png") > system("convert tmp/34uwm1258728656.ps tmp/34uwm1258728656.png") > system("convert tmp/4fl4n1258728656.ps tmp/4fl4n1258728656.png") > system("convert tmp/528d21258728656.ps tmp/528d21258728656.png") > system("convert tmp/6nmse1258728656.ps tmp/6nmse1258728656.png") > system("convert tmp/7r0ln1258728656.ps tmp/7r0ln1258728656.png") > system("convert tmp/8x1971258728656.ps tmp/8x1971258728656.png") > system("convert tmp/97vjp1258728656.ps tmp/97vjp1258728656.png") > system("convert tmp/10ik6m1258728656.ps tmp/10ik6m1258728656.png") > > > proc.time() user system elapsed 2.366 1.556 2.775