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(10723.78 + ,3080.58 + ,10539.51 + ,10673.38 + ,10411.75 + ,10001.60 + ,10682.06 + ,3106.22 + ,10723.78 + ,10539.51 + ,10673.38 + ,10411.75 + ,10283.19 + ,3119.31 + ,10682.06 + ,10723.78 + ,10539.51 + ,10673.38 + ,10377.18 + ,3061.26 + ,10283.19 + ,10682.06 + ,10723.78 + ,10539.51 + ,10486.64 + ,3097.31 + ,10377.18 + ,10283.19 + ,10682.06 + ,10723.78 + ,10545.38 + ,3161.69 + ,10486.64 + ,10377.18 + ,10283.19 + ,10682.06 + ,10554.27 + ,3257.16 + ,10545.38 + ,10486.64 + ,10377.18 + ,10283.19 + ,10532.54 + ,3277.01 + ,10554.27 + ,10545.38 + ,10486.64 + ,10377.18 + ,10324.31 + ,3295.32 + ,10532.54 + ,10554.27 + ,10545.38 + ,10486.64 + ,10695.25 + ,3363.99 + ,10324.31 + ,10532.54 + ,10554.27 + ,10545.38 + ,10827.81 + ,3494.17 + ,10695.25 + ,10324.31 + ,10532.54 + ,10554.27 + ,10872.48 + ,3667.03 + ,10827.81 + ,10695.25 + ,10324.31 + ,10532.54 + ,10971.19 + ,3813.06 + ,10872.48 + ,10827.81 + ,10695.25 + ,10324.31 + ,11145.65 + ,3917.96 + ,10971.19 + ,10872.48 + ,10827.81 + ,10695.25 + ,11234.68 + ,3895.51 + ,11145.65 + ,10971.19 + ,10872.48 + ,10827.81 + ,11333.88 + ,3801.06 + ,11234.68 + ,11145.65 + ,10971.19 + ,10872.48 + ,10997.97 + ,3570.12 + ,11333.88 + ,11234.68 + ,11145.65 + ,10971.19 + ,11036.89 + ,3701.61 + ,10997.97 + ,11333.88 + ,11234.68 + ,11145.65 + ,11257.35 + ,3862.27 + ,11036.89 + ,10997.97 + ,11333.88 + ,11234.68 + ,11533.59 + ,3970.10 + ,11257.35 + ,11036.89 + ,10997.97 + ,11333.88 + ,11963.12 + ,4138.52 + ,11533.59 + ,11257.35 + ,11036.89 + ,10997.97 + ,12185.15 + ,4199.75 + ,11963.12 + ,11533.59 + ,11257.35 + ,11036.89 + ,12377.62 + ,4290.89 + ,12185.15 + ,11963.12 + ,11533.59 + ,11257.35 + ,12512.89 + ,4443.91 + ,12377.62 + ,12185.15 + ,11963.12 + ,11533.59 + ,12631.48 + ,4502.64 + ,12512.89 + ,12377.62 + ,12185.15 + ,11963.12 + ,12268.53 + ,4356.98 + ,12631.48 + ,12512.89 + ,12377.62 + ,12185.15 + ,12754.80 + ,4591.27 + ,12268.53 + ,12631.48 + ,12512.89 + ,12377.62 + ,13407.75 + ,4696.96 + ,12754.80 + ,12268.53 + ,12631.48 + ,12512.89 + ,13480.21 + ,4621.40 + ,13407.75 + ,12754.80 + ,12268.53 + ,12631.48 + ,13673.28 + ,4562.84 + ,13480.21 + ,13407.75 + ,12754.80 + ,12268.53 + ,13239.71 + ,4202.52 + ,13673.28 + ,13480.21 + ,13407.75 + ,12754.80 + ,13557.69 + ,4296.49 + ,13239.71 + ,13673.28 + ,13480.21 + ,13407.75 + ,13901.28 + ,4435.23 + ,13557.69 + ,13239.71 + ,13673.28 + ,13480.21 + ,13200.58 + ,4105.18 + ,13901.28 + ,13557.69 + ,13239.71 + ,13673.28 + ,13406.97 + ,4116.68 + ,13200.58 + ,13901.28 + ,13557.69 + ,13239.71 + ,12538.12 + ,3844.49 + ,13406.97 + ,13200.58 + ,13901.28 + ,13557.69 + ,12419.57 + ,3720.98 + ,12538.12 + ,13406.97 + ,13200.58 + ,13901.28 + ,12193.88 + ,3674.40 + ,12419.57 + ,12538.12 + ,13406.97 + ,13200.58 + ,12656.63 + ,3857.62 + ,12193.88 + ,12419.57 + ,12538.12 + ,13406.97 + ,12812.48 + ,3801.06 + ,12656.63 + ,12193.88 + ,12419.57 + ,12538.12 + ,12056.67 + ,3504.37 + ,12812.48 + ,12656.63 + ,12193.88 + ,12419.57 + ,11322.38 + ,3032.60 + ,12056.67 + ,12812.48 + ,12656.63 + ,12193.88 + ,11530.75 + ,3047.03 + ,11322.38 + ,12056.67 + ,12812.48 + ,12656.63 + ,11114.08 + ,2962.34 + ,11530.75 + ,11322.38 + ,12056.67 + ,12812.48 + ,9181.73 + ,2197.82 + ,11114.08 + ,11530.75 + ,11322.38 + ,12056.67 + ,8614.55 + ,2014.45 + ,9181.73 + ,11114.08 + ,11530.75 + ,11322.38 + ,8595.56 + ,1862.83 + ,8614.55 + ,9181.73 + ,11114.08 + ,11530.75 + ,8396.20 + ,1905.41 + ,8595.56 + ,8614.55 + ,9181.73 + ,11114.08 + ,7690.50 + ,1810.99 + ,8396.20 + ,8595.56 + ,8614.55 + ,9181.73 + ,7235.47 + ,1670.07 + ,7690.50 + ,8396.20 + ,8595.56 + ,8614.55 + ,7992.12 + ,1864.44 + ,7235.47 + ,7690.50 + ,8396.20 + ,8595.56 + ,8398.37 + ,2052.02 + ,7992.12 + ,7235.47 + ,7690.50 + ,8396.20 + ,8593.01 + ,2029.60 + ,8398.37 + ,7992.12 + ,7235.47 + ,7690.50 + ,8679.75 + ,2070.83 + ,8593.01 + ,8398.37 + ,7992.12 + ,7235.47 + ,9374.63 + ,2293.41 + ,8679.75 + ,8593.01 + ,8398.37 + ,7992.12 + ,9634.97 + ,2443.27 + ,9374.63 + ,8679.75 + ,8593.01 + ,8398.37) + ,dim=c(6 + ,56) + ,dimnames=list(c('Y' + ,'X' + ,'Yt-1' + ,'Yt-2' + ,'Yt-3' + ,'Yt-4 ') + ,1:56)) > y <- array(NA,dim=c(6,56),dimnames=list(c('Y','X','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 = '2' > #'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 X Y Yt-1 Yt-2 Yt-3 Yt-4\r\r M1 M2 M3 M4 M5 M6 M7 M8 1 3080.58 10723.78 10539.51 10673.38 10411.75 10001.60 1 0 0 0 0 0 0 0 2 3106.22 10682.06 10723.78 10539.51 10673.38 10411.75 0 1 0 0 0 0 0 0 3 3119.31 10283.19 10682.06 10723.78 10539.51 10673.38 0 0 1 0 0 0 0 0 4 3061.26 10377.18 10283.19 10682.06 10723.78 10539.51 0 0 0 1 0 0 0 0 5 3097.31 10486.64 10377.18 10283.19 10682.06 10723.78 0 0 0 0 1 0 0 0 6 3161.69 10545.38 10486.64 10377.18 10283.19 10682.06 0 0 0 0 0 1 0 0 7 3257.16 10554.27 10545.38 10486.64 10377.18 10283.19 0 0 0 0 0 0 1 0 8 3277.01 10532.54 10554.27 10545.38 10486.64 10377.18 0 0 0 0 0 0 0 1 9 3295.32 10324.31 10532.54 10554.27 10545.38 10486.64 0 0 0 0 0 0 0 0 10 3363.99 10695.25 10324.31 10532.54 10554.27 10545.38 0 0 0 0 0 0 0 0 11 3494.17 10827.81 10695.25 10324.31 10532.54 10554.27 0 0 0 0 0 0 0 0 12 3667.03 10872.48 10827.81 10695.25 10324.31 10532.54 0 0 0 0 0 0 0 0 13 3813.06 10971.19 10872.48 10827.81 10695.25 10324.31 1 0 0 0 0 0 0 0 14 3917.96 11145.65 10971.19 10872.48 10827.81 10695.25 0 1 0 0 0 0 0 0 15 3895.51 11234.68 11145.65 10971.19 10872.48 10827.81 0 0 1 0 0 0 0 0 16 3801.06 11333.88 11234.68 11145.65 10971.19 10872.48 0 0 0 1 0 0 0 0 17 3570.12 10997.97 11333.88 11234.68 11145.65 10971.19 0 0 0 0 1 0 0 0 18 3701.61 11036.89 10997.97 11333.88 11234.68 11145.65 0 0 0 0 0 1 0 0 19 3862.27 11257.35 11036.89 10997.97 11333.88 11234.68 0 0 0 0 0 0 1 0 20 3970.10 11533.59 11257.35 11036.89 10997.97 11333.88 0 0 0 0 0 0 0 1 21 4138.52 11963.12 11533.59 11257.35 11036.89 10997.97 0 0 0 0 0 0 0 0 22 4199.75 12185.15 11963.12 11533.59 11257.35 11036.89 0 0 0 0 0 0 0 0 23 4290.89 12377.62 12185.15 11963.12 11533.59 11257.35 0 0 0 0 0 0 0 0 24 4443.91 12512.89 12377.62 12185.15 11963.12 11533.59 0 0 0 0 0 0 0 0 25 4502.64 12631.48 12512.89 12377.62 12185.15 11963.12 1 0 0 0 0 0 0 0 26 4356.98 12268.53 12631.48 12512.89 12377.62 12185.15 0 1 0 0 0 0 0 0 27 4591.27 12754.80 12268.53 12631.48 12512.89 12377.62 0 0 1 0 0 0 0 0 28 4696.96 13407.75 12754.80 12268.53 12631.48 12512.89 0 0 0 1 0 0 0 0 29 4621.40 13480.21 13407.75 12754.80 12268.53 12631.48 0 0 0 0 1 0 0 0 30 4562.84 13673.28 13480.21 13407.75 12754.80 12268.53 0 0 0 0 0 1 0 0 31 4202.52 13239.71 13673.28 13480.21 13407.75 12754.80 0 0 0 0 0 0 1 0 32 4296.49 13557.69 13239.71 13673.28 13480.21 13407.75 0 0 0 0 0 0 0 1 33 4435.23 13901.28 13557.69 13239.71 13673.28 13480.21 0 0 0 0 0 0 0 0 34 4105.18 13200.58 13901.28 13557.69 13239.71 13673.28 0 0 0 0 0 0 0 0 35 4116.68 13406.97 13200.58 13901.28 13557.69 13239.71 0 0 0 0 0 0 0 0 36 3844.49 12538.12 13406.97 13200.58 13901.28 13557.69 0 0 0 0 0 0 0 0 37 3720.98 12419.57 12538.12 13406.97 13200.58 13901.28 1 0 0 0 0 0 0 0 38 3674.40 12193.88 12419.57 12538.12 13406.97 13200.58 0 1 0 0 0 0 0 0 39 3857.62 12656.63 12193.88 12419.57 12538.12 13406.97 0 0 1 0 0 0 0 0 40 3801.06 12812.48 12656.63 12193.88 12419.57 12538.12 0 0 0 1 0 0 0 0 41 3504.37 12056.67 12812.48 12656.63 12193.88 12419.57 0 0 0 0 1 0 0 0 42 3032.60 11322.38 12056.67 12812.48 12656.63 12193.88 0 0 0 0 0 1 0 0 43 3047.03 11530.75 11322.38 12056.67 12812.48 12656.63 0 0 0 0 0 0 1 0 44 2962.34 11114.08 11530.75 11322.38 12056.67 12812.48 0 0 0 0 0 0 0 1 45 2197.82 9181.73 11114.08 11530.75 11322.38 12056.67 0 0 0 0 0 0 0 0 46 2014.45 8614.55 9181.73 11114.08 11530.75 11322.38 0 0 0 0 0 0 0 0 47 1862.83 8595.56 8614.55 9181.73 11114.08 11530.75 0 0 0 0 0 0 0 0 48 1905.41 8396.20 8595.56 8614.55 9181.73 11114.08 0 0 0 0 0 0 0 0 49 1810.99 7690.50 8396.20 8595.56 8614.55 9181.73 1 0 0 0 0 0 0 0 50 1670.07 7235.47 7690.50 8396.20 8595.56 8614.55 0 1 0 0 0 0 0 0 51 1864.44 7992.12 7235.47 7690.50 8396.20 8595.56 0 0 1 0 0 0 0 0 52 2052.02 8398.37 7992.12 7235.47 7690.50 8396.20 0 0 0 1 0 0 0 0 53 2029.60 8593.01 8398.37 7992.12 7235.47 7690.50 0 0 0 0 1 0 0 0 54 2070.83 8679.75 8593.01 8398.37 7992.12 7235.47 0 0 0 0 0 1 0 0 55 2293.41 9374.63 8679.75 8593.01 8398.37 7992.12 0 0 0 0 0 0 1 0 56 2443.27 9634.97 9374.63 8679.75 8593.01 8398.37 0 0 0 0 0 0 0 1 M9 M10 M11 t 1 0 0 0 1 2 0 0 0 2 3 0 0 0 3 4 0 0 0 4 5 0 0 0 5 6 0 0 0 6 7 0 0 0 7 8 0 0 0 8 9 1 0 0 9 10 0 1 0 10 11 0 0 1 11 12 0 0 0 12 13 0 0 0 13 14 0 0 0 14 15 0 0 0 15 16 0 0 0 16 17 0 0 0 17 18 0 0 0 18 19 0 0 0 19 20 0 0 0 20 21 1 0 0 21 22 0 1 0 22 23 0 0 1 23 24 0 0 0 24 25 0 0 0 25 26 0 0 0 26 27 0 0 0 27 28 0 0 0 28 29 0 0 0 29 30 0 0 0 30 31 0 0 0 31 32 0 0 0 32 33 1 0 0 33 34 0 1 0 34 35 0 0 1 35 36 0 0 0 36 37 0 0 0 37 38 0 0 0 38 39 0 0 0 39 40 0 0 0 40 41 0 0 0 41 42 0 0 0 42 43 0 0 0 43 44 0 0 0 44 45 1 0 0 45 46 0 1 0 46 47 0 0 1 47 48 0 0 0 48 49 0 0 0 49 50 0 0 0 50 51 0 0 0 51 52 0 0 0 52 53 0 0 0 53 54 0 0 0 54 55 0 0 0 55 56 0 0 0 56 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) Y `Yt-1` `Yt-2` `Yt-3` `Yt-4\r\r` -1.000e+03 5.645e-01 -1.231e-02 2.908e-02 -8.278e-02 -6.526e-02 M1 M2 M3 M4 M5 M6 -8.704e+01 -1.315e+00 -3.587e+01 -1.805e+02 -2.338e+02 -2.417e+02 M7 M8 M9 M10 M11 t -2.401e+02 -2.103e+02 -1.036e+02 -1.076e+02 -1.393e+02 -9.139e+00 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -543.26 -122.13 -20.55 153.48 408.28 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.000e+03 2.875e+02 -3.478 0.001281 ** Y 5.645e-01 8.507e-02 6.636 7.68e-08 *** `Yt-1` -1.231e-02 1.345e-01 -0.092 0.927566 `Yt-2` 2.908e-02 1.364e-01 0.213 0.832322 `Yt-3` -8.278e-02 1.357e-01 -0.610 0.545420 `Yt-4\r\r` -6.526e-02 8.822e-02 -0.740 0.464029 M1 -8.704e+01 1.661e+02 -0.524 0.603247 M2 -1.315e+00 1.653e+02 -0.008 0.993695 M3 -3.587e+01 1.678e+02 -0.214 0.831878 M4 -1.805e+02 1.639e+02 -1.101 0.277700 M5 -2.338e+02 1.629e+02 -1.435 0.159446 M6 -2.417e+02 1.722e+02 -1.403 0.168632 M7 -2.401e+02 1.696e+02 -1.416 0.164991 M8 -2.103e+02 1.611e+02 -1.306 0.199548 M9 -1.036e+02 1.688e+02 -0.614 0.543043 M10 -1.076e+02 1.750e+02 -0.615 0.542329 M11 -1.393e+02 1.746e+02 -0.798 0.429902 t -9.139e+00 2.149e+00 -4.253 0.000132 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 236 on 38 degrees of freedom Multiple R-squared: 0.949, Adjusted R-squared: 0.9262 F-statistic: 41.59 on 17 and 38 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.1183703 0.2367407 0.8816297 [2,] 0.4620088 0.9240176 0.5379912 [3,] 0.5563268 0.8873464 0.4436732 [4,] 0.5261045 0.9477910 0.4738955 [5,] 0.4147464 0.8294927 0.5852536 [6,] 0.3185889 0.6371777 0.6814111 [7,] 0.2937545 0.5875091 0.7062455 [8,] 0.3025049 0.6050099 0.6974951 [9,] 0.4428058 0.8856116 0.5571942 [10,] 0.6531269 0.6937461 0.3468731 [11,] 0.8275161 0.3449678 0.1724839 [12,] 0.8295171 0.3409658 0.1704829 [13,] 0.8768439 0.2463122 0.1231561 [14,] 0.8439809 0.3120382 0.1560191 [15,] 0.8093312 0.3813376 0.1906688 > postscript(file="/var/www/html/rcomp/tmp/1bauz1259621705.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/20e231259621705.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/346mt1259621705.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/44u8u1259621705.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/5hhrk1259621705.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 -543.257514 -516.071809 -233.993762 -188.522572 -130.522065 -119.338518 7 8 9 10 11 12 -42.047701 -17.047650 32.742973 -92.234865 13.376572 3.051223 13 14 15 16 17 18 203.350293 168.268573 150.879738 161.296189 201.916956 340.260496 19 20 21 22 23 24 408.281680 319.703300 126.382787 93.432778 144.275087 140.268043 25 26 27 28 29 30 270.707804 281.300329 300.615467 226.640901 144.180800 -7.811041 31 32 33 34 35 36 -29.770955 -98.366330 -213.909160 -163.585332 -248.322619 -88.071833 37 38 39 40 41 42 -100.753511 -101.346049 -193.448145 -238.481659 -84.038130 -114.448628 43 44 45 46 47 48 -154.061234 -52.718057 54.783400 162.387418 90.670960 -55.247433 49 50 51 52 53 54 169.952928 167.848956 -24.053299 39.067141 -131.537560 -98.662310 55 56 -182.401788 -151.571262 > postscript(file="/var/www/html/rcomp/tmp/65b4w1259621705.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 -543.257514 NA 1 -516.071809 -543.257514 2 -233.993762 -516.071809 3 -188.522572 -233.993762 4 -130.522065 -188.522572 5 -119.338518 -130.522065 6 -42.047701 -119.338518 7 -17.047650 -42.047701 8 32.742973 -17.047650 9 -92.234865 32.742973 10 13.376572 -92.234865 11 3.051223 13.376572 12 203.350293 3.051223 13 168.268573 203.350293 14 150.879738 168.268573 15 161.296189 150.879738 16 201.916956 161.296189 17 340.260496 201.916956 18 408.281680 340.260496 19 319.703300 408.281680 20 126.382787 319.703300 21 93.432778 126.382787 22 144.275087 93.432778 23 140.268043 144.275087 24 270.707804 140.268043 25 281.300329 270.707804 26 300.615467 281.300329 27 226.640901 300.615467 28 144.180800 226.640901 29 -7.811041 144.180800 30 -29.770955 -7.811041 31 -98.366330 -29.770955 32 -213.909160 -98.366330 33 -163.585332 -213.909160 34 -248.322619 -163.585332 35 -88.071833 -248.322619 36 -100.753511 -88.071833 37 -101.346049 -100.753511 38 -193.448145 -101.346049 39 -238.481659 -193.448145 40 -84.038130 -238.481659 41 -114.448628 -84.038130 42 -154.061234 -114.448628 43 -52.718057 -154.061234 44 54.783400 -52.718057 45 162.387418 54.783400 46 90.670960 162.387418 47 -55.247433 90.670960 48 169.952928 -55.247433 49 167.848956 169.952928 50 -24.053299 167.848956 51 39.067141 -24.053299 52 -131.537560 39.067141 53 -98.662310 -131.537560 54 -182.401788 -98.662310 55 -151.571262 -182.401788 56 NA -151.571262 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -516.071809 -543.257514 [2,] -233.993762 -516.071809 [3,] -188.522572 -233.993762 [4,] -130.522065 -188.522572 [5,] -119.338518 -130.522065 [6,] -42.047701 -119.338518 [7,] -17.047650 -42.047701 [8,] 32.742973 -17.047650 [9,] -92.234865 32.742973 [10,] 13.376572 -92.234865 [11,] 3.051223 13.376572 [12,] 203.350293 3.051223 [13,] 168.268573 203.350293 [14,] 150.879738 168.268573 [15,] 161.296189 150.879738 [16,] 201.916956 161.296189 [17,] 340.260496 201.916956 [18,] 408.281680 340.260496 [19,] 319.703300 408.281680 [20,] 126.382787 319.703300 [21,] 93.432778 126.382787 [22,] 144.275087 93.432778 [23,] 140.268043 144.275087 [24,] 270.707804 140.268043 [25,] 281.300329 270.707804 [26,] 300.615467 281.300329 [27,] 226.640901 300.615467 [28,] 144.180800 226.640901 [29,] -7.811041 144.180800 [30,] -29.770955 -7.811041 [31,] -98.366330 -29.770955 [32,] -213.909160 -98.366330 [33,] -163.585332 -213.909160 [34,] -248.322619 -163.585332 [35,] -88.071833 -248.322619 [36,] -100.753511 -88.071833 [37,] -101.346049 -100.753511 [38,] -193.448145 -101.346049 [39,] -238.481659 -193.448145 [40,] -84.038130 -238.481659 [41,] -114.448628 -84.038130 [42,] -154.061234 -114.448628 [43,] -52.718057 -154.061234 [44,] 54.783400 -52.718057 [45,] 162.387418 54.783400 [46,] 90.670960 162.387418 [47,] -55.247433 90.670960 [48,] 169.952928 -55.247433 [49,] 167.848956 169.952928 [50,] -24.053299 167.848956 [51,] 39.067141 -24.053299 [52,] -131.537560 39.067141 [53,] -98.662310 -131.537560 [54,] -182.401788 -98.662310 [55,] -151.571262 -182.401788 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -516.071809 -543.257514 2 -233.993762 -516.071809 3 -188.522572 -233.993762 4 -130.522065 -188.522572 5 -119.338518 -130.522065 6 -42.047701 -119.338518 7 -17.047650 -42.047701 8 32.742973 -17.047650 9 -92.234865 32.742973 10 13.376572 -92.234865 11 3.051223 13.376572 12 203.350293 3.051223 13 168.268573 203.350293 14 150.879738 168.268573 15 161.296189 150.879738 16 201.916956 161.296189 17 340.260496 201.916956 18 408.281680 340.260496 19 319.703300 408.281680 20 126.382787 319.703300 21 93.432778 126.382787 22 144.275087 93.432778 23 140.268043 144.275087 24 270.707804 140.268043 25 281.300329 270.707804 26 300.615467 281.300329 27 226.640901 300.615467 28 144.180800 226.640901 29 -7.811041 144.180800 30 -29.770955 -7.811041 31 -98.366330 -29.770955 32 -213.909160 -98.366330 33 -163.585332 -213.909160 34 -248.322619 -163.585332 35 -88.071833 -248.322619 36 -100.753511 -88.071833 37 -101.346049 -100.753511 38 -193.448145 -101.346049 39 -238.481659 -193.448145 40 -84.038130 -238.481659 41 -114.448628 -84.038130 42 -154.061234 -114.448628 43 -52.718057 -154.061234 44 54.783400 -52.718057 45 162.387418 54.783400 46 90.670960 162.387418 47 -55.247433 90.670960 48 169.952928 -55.247433 49 167.848956 169.952928 50 -24.053299 167.848956 51 39.067141 -24.053299 52 -131.537560 39.067141 53 -98.662310 -131.537560 54 -182.401788 -98.662310 55 -151.571262 -182.401788 > 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/7wifz1259621705.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/85vq51259621705.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/9eftc1259621705.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/10e4ok1259621705.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/11adnn1259621705.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/12f8qk1259621705.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/13smwx1259621705.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/14nso01259621705.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/15dtsf1259621705.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/16pjqn1259621705.tab") + } > > system("convert tmp/1bauz1259621705.ps tmp/1bauz1259621705.png") > system("convert tmp/20e231259621705.ps tmp/20e231259621705.png") > system("convert tmp/346mt1259621705.ps tmp/346mt1259621705.png") > system("convert tmp/44u8u1259621705.ps tmp/44u8u1259621705.png") > system("convert tmp/5hhrk1259621705.ps tmp/5hhrk1259621705.png") > system("convert tmp/65b4w1259621705.ps tmp/65b4w1259621705.png") > system("convert tmp/7wifz1259621705.ps tmp/7wifz1259621705.png") > system("convert tmp/85vq51259621705.ps tmp/85vq51259621705.png") > system("convert tmp/9eftc1259621705.ps tmp/9eftc1259621705.png") > system("convert tmp/10e4ok1259621705.ps tmp/10e4ok1259621705.png") > > > proc.time() user system elapsed 2.368 1.636 5.553