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. Natural language support but running in an English locale 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(22.397 + ,26.105 + ,29.462 + ,27.071 + ,31.514 + ,23.843 + ,22.397 + ,26.105 + ,29.462 + ,27.071 + ,21.705 + ,23.843 + ,22.397 + ,26.105 + ,29.462 + ,18.089 + ,21.705 + ,23.843 + ,22.397 + ,26.105 + ,20.764 + ,18.089 + ,21.705 + ,23.843 + ,22.397 + ,25.316 + ,20.764 + ,18.089 + ,21.705 + ,23.843 + ,17.704 + ,25.316 + ,20.764 + ,18.089 + ,21.705 + ,15.548 + ,17.704 + ,25.316 + ,20.764 + ,18.089 + ,28.029 + ,15.548 + ,17.704 + ,25.316 + ,20.764 + ,29.383 + ,28.029 + ,15.548 + ,17.704 + ,25.316 + ,36.438 + ,29.383 + ,28.029 + ,15.548 + ,17.704 + ,32.034 + ,36.438 + ,29.383 + ,28.029 + ,15.548 + ,22.679 + ,32.034 + ,36.438 + ,29.383 + ,28.029 + ,24.319 + ,22.679 + ,32.034 + ,36.438 + ,29.383 + ,18.004 + ,24.319 + ,22.679 + ,32.034 + ,36.438 + ,17.537 + ,18.004 + ,24.319 + ,22.679 + ,32.034 + ,20.366 + ,17.537 + ,18.004 + ,24.319 + ,22.679 + ,22.782 + ,20.366 + ,17.537 + ,18.004 + ,24.319 + ,19.169 + ,22.782 + ,20.366 + ,17.537 + ,18.004 + ,13.807 + ,19.169 + ,22.782 + ,20.366 + ,17.537 + ,29.743 + ,13.807 + ,19.169 + ,22.782 + ,20.366 + ,25.591 + ,29.743 + ,13.807 + ,19.169 + ,22.782 + ,29.096 + ,25.591 + ,29.743 + ,13.807 + ,19.169 + ,26.482 + ,29.096 + ,25.591 + ,29.743 + ,13.807 + ,22.405 + ,26.482 + ,29.096 + ,25.591 + ,29.743 + ,27.044 + ,22.405 + ,26.482 + ,29.096 + ,25.591 + ,17.970 + ,27.044 + ,22.405 + ,26.482 + ,29.096 + ,18.730 + ,17.970 + ,27.044 + ,22.405 + ,26.482 + ,19.684 + ,18.730 + ,17.970 + ,27.044 + ,22.405 + ,19.785 + ,19.684 + ,18.730 + ,17.970 + ,27.044 + ,18.479 + ,19.785 + ,19.684 + ,18.730 + ,17.970 + ,10.698 + ,18.479 + ,19.785 + ,19.684 + ,18.730 + ,31.956 + ,10.698 + ,18.479 + ,19.785 + ,19.684 + ,29.506 + ,31.956 + ,10.698 + ,18.479 + ,19.785 + ,34.506 + ,29.506 + ,31.956 + ,10.698 + ,18.479 + ,27.165 + ,34.506 + ,29.506 + ,31.956 + ,10.698 + ,26.736 + ,27.165 + ,34.506 + ,29.506 + ,31.956 + ,23.691 + ,26.736 + ,27.165 + ,34.506 + ,29.506 + ,18.157 + ,23.691 + ,26.736 + ,27.165 + ,34.506 + ,17.328 + ,18.157 + ,23.691 + ,26.736 + ,27.165 + ,18.205 + ,17.328 + ,18.157 + ,23.691 + ,26.736 + ,20.995 + ,18.205 + ,17.328 + ,18.157 + ,23.691 + ,17.382 + ,20.995 + ,18.205 + ,17.328 + ,18.157 + ,9.367 + ,17.382 + ,20.995 + ,18.205 + ,17.328 + ,31.124 + ,9.367 + ,17.382 + ,20.995 + ,18.205 + ,26.551 + ,31.124 + ,9.367 + ,17.382 + ,20.995 + ,30.651 + ,26.551 + ,31.124 + ,9.367 + ,17.382 + ,25.859 + ,30.651 + ,26.551 + ,31.124 + ,9.367 + ,25.100 + ,25.859 + ,30.651 + ,26.551 + ,31.124 + ,25.778 + ,25.100 + ,25.859 + ,30.651 + ,26.551 + ,20.418 + ,25.778 + ,25.100 + ,25.859 + ,30.651 + ,18.688 + ,20.418 + ,25.778 + ,25.100 + ,25.859 + ,20.424 + ,18.688 + ,20.418 + ,25.778 + ,25.100 + ,24.776 + ,20.424 + ,18.688 + ,20.418 + ,25.778 + ,19.814 + ,24.776 + ,20.424 + ,18.688 + ,20.418 + ,12.738 + ,19.814 + ,24.776 + ,20.424 + ,18.688 + ,31.566 + ,12.738 + ,19.814 + ,24.776 + ,20.424 + ,30.111 + ,31.566 + ,12.738 + ,19.814 + ,24.776 + ,30.019 + ,30.111 + ,31.566 + ,12.738 + ,19.814 + ,31.934 + ,30.019 + ,30.111 + ,31.566 + ,12.738 + ,25.826 + ,31.934 + ,30.019 + ,30.111 + ,31.566 + ,26.835 + ,25.826 + ,31.934 + ,30.019 + ,30.111 + ,20.205 + ,26.835 + ,25.826 + ,31.934 + ,30.019 + ,17.789 + ,20.205 + ,26.835 + ,25.826 + ,31.934 + ,20.520 + ,17.789 + ,20.205 + ,26.835 + ,25.826 + ,22.518 + ,20.520 + ,17.789 + ,20.205 + ,26.835 + ,15.572 + ,22.518 + ,20.520 + ,17.789 + ,20.205 + ,11.509 + ,15.572 + ,22.518 + ,20.520 + ,17.789 + ,25.447 + ,11.509 + ,15.572 + ,22.518 + ,20.520 + ,24.090 + ,25.447 + ,11.509 + ,15.572 + ,22.518 + ,27.786 + ,24.090 + ,25.447 + ,11.509 + ,15.572 + ,26.195 + ,27.786 + ,24.090 + ,25.447 + ,11.509 + ,20.516 + ,26.195 + ,27.786 + ,24.090 + ,25.447 + ,22.759 + ,20.516 + ,26.195 + ,27.786 + ,24.090 + ,19.028 + ,22.759 + ,20.516 + ,26.195 + ,27.786 + ,16.971 + ,19.028 + ,22.759 + ,20.516 + ,26.195 + ,20.036 + ,16.971 + ,19.028 + ,22.759 + ,20.516 + ,22.485 + ,20.036 + ,16.971 + ,19.028 + ,22.759 + ,18.730 + ,22.485 + ,20.036 + ,16.971 + ,19.028 + ,14.538 + ,18.730 + ,22.485 + ,20.036 + ,16.971) + ,dim=c(5 + ,80) + ,dimnames=list(c('Yt' + ,'Yt_1' + ,'Yt_2' + ,'Yt_3' + ,'Yt_4') + ,1:80)) > y <- array(NA,dim=c(5,80),dimnames=list(c('Yt','Yt_1','Yt_2','Yt_3','Yt_4'),1:80)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par3 = 'No 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 M10 M11 1 22.397 26.105 29.462 27.071 31.514 1 0 0 0 0 0 0 0 0 0 0 2 23.843 22.397 26.105 29.462 27.071 0 1 0 0 0 0 0 0 0 0 0 3 21.705 23.843 22.397 26.105 29.462 0 0 1 0 0 0 0 0 0 0 0 4 18.089 21.705 23.843 22.397 26.105 0 0 0 1 0 0 0 0 0 0 0 5 20.764 18.089 21.705 23.843 22.397 0 0 0 0 1 0 0 0 0 0 0 6 25.316 20.764 18.089 21.705 23.843 0 0 0 0 0 1 0 0 0 0 0 7 17.704 25.316 20.764 18.089 21.705 0 0 0 0 0 0 1 0 0 0 0 8 15.548 17.704 25.316 20.764 18.089 0 0 0 0 0 0 0 1 0 0 0 9 28.029 15.548 17.704 25.316 20.764 0 0 0 0 0 0 0 0 1 0 0 10 29.383 28.029 15.548 17.704 25.316 0 0 0 0 0 0 0 0 0 1 0 11 36.438 29.383 28.029 15.548 17.704 0 0 0 0 0 0 0 0 0 0 1 12 32.034 36.438 29.383 28.029 15.548 0 0 0 0 0 0 0 0 0 0 0 13 22.679 32.034 36.438 29.383 28.029 1 0 0 0 0 0 0 0 0 0 0 14 24.319 22.679 32.034 36.438 29.383 0 1 0 0 0 0 0 0 0 0 0 15 18.004 24.319 22.679 32.034 36.438 0 0 1 0 0 0 0 0 0 0 0 16 17.537 18.004 24.319 22.679 32.034 0 0 0 1 0 0 0 0 0 0 0 17 20.366 17.537 18.004 24.319 22.679 0 0 0 0 1 0 0 0 0 0 0 18 22.782 20.366 17.537 18.004 24.319 0 0 0 0 0 1 0 0 0 0 0 19 19.169 22.782 20.366 17.537 18.004 0 0 0 0 0 0 1 0 0 0 0 20 13.807 19.169 22.782 20.366 17.537 0 0 0 0 0 0 0 1 0 0 0 21 29.743 13.807 19.169 22.782 20.366 0 0 0 0 0 0 0 0 1 0 0 22 25.591 29.743 13.807 19.169 22.782 0 0 0 0 0 0 0 0 0 1 0 23 29.096 25.591 29.743 13.807 19.169 0 0 0 0 0 0 0 0 0 0 1 24 26.482 29.096 25.591 29.743 13.807 0 0 0 0 0 0 0 0 0 0 0 25 22.405 26.482 29.096 25.591 29.743 1 0 0 0 0 0 0 0 0 0 0 26 27.044 22.405 26.482 29.096 25.591 0 1 0 0 0 0 0 0 0 0 0 27 17.970 27.044 22.405 26.482 29.096 0 0 1 0 0 0 0 0 0 0 0 28 18.730 17.970 27.044 22.405 26.482 0 0 0 1 0 0 0 0 0 0 0 29 19.684 18.730 17.970 27.044 22.405 0 0 0 0 1 0 0 0 0 0 0 30 19.785 19.684 18.730 17.970 27.044 0 0 0 0 0 1 0 0 0 0 0 31 18.479 19.785 19.684 18.730 17.970 0 0 0 0 0 0 1 0 0 0 0 32 10.698 18.479 19.785 19.684 18.730 0 0 0 0 0 0 0 1 0 0 0 33 31.956 10.698 18.479 19.785 19.684 0 0 0 0 0 0 0 0 1 0 0 34 29.506 31.956 10.698 18.479 19.785 0 0 0 0 0 0 0 0 0 1 0 35 34.506 29.506 31.956 10.698 18.479 0 0 0 0 0 0 0 0 0 0 1 36 27.165 34.506 29.506 31.956 10.698 0 0 0 0 0 0 0 0 0 0 0 37 26.736 27.165 34.506 29.506 31.956 1 0 0 0 0 0 0 0 0 0 0 38 23.691 26.736 27.165 34.506 29.506 0 1 0 0 0 0 0 0 0 0 0 39 18.157 23.691 26.736 27.165 34.506 0 0 1 0 0 0 0 0 0 0 0 40 17.328 18.157 23.691 26.736 27.165 0 0 0 1 0 0 0 0 0 0 0 41 18.205 17.328 18.157 23.691 26.736 0 0 0 0 1 0 0 0 0 0 0 42 20.995 18.205 17.328 18.157 23.691 0 0 0 0 0 1 0 0 0 0 0 43 17.382 20.995 18.205 17.328 18.157 0 0 0 0 0 0 1 0 0 0 0 44 9.367 17.382 20.995 18.205 17.328 0 0 0 0 0 0 0 1 0 0 0 45 31.124 9.367 17.382 20.995 18.205 0 0 0 0 0 0 0 0 1 0 0 46 26.551 31.124 9.367 17.382 20.995 0 0 0 0 0 0 0 0 0 1 0 47 30.651 26.551 31.124 9.367 17.382 0 0 0 0 0 0 0 0 0 0 1 48 25.859 30.651 26.551 31.124 9.367 0 0 0 0 0 0 0 0 0 0 0 49 25.100 25.859 30.651 26.551 31.124 1 0 0 0 0 0 0 0 0 0 0 50 25.778 25.100 25.859 30.651 26.551 0 1 0 0 0 0 0 0 0 0 0 51 20.418 25.778 25.100 25.859 30.651 0 0 1 0 0 0 0 0 0 0 0 52 18.688 20.418 25.778 25.100 25.859 0 0 0 1 0 0 0 0 0 0 0 53 20.424 18.688 20.418 25.778 25.100 0 0 0 0 1 0 0 0 0 0 0 54 24.776 20.424 18.688 20.418 25.778 0 0 0 0 0 1 0 0 0 0 0 55 19.814 24.776 20.424 18.688 20.418 0 0 0 0 0 0 1 0 0 0 0 56 12.738 19.814 24.776 20.424 18.688 0 0 0 0 0 0 0 1 0 0 0 57 31.566 12.738 19.814 24.776 20.424 0 0 0 0 0 0 0 0 1 0 0 58 30.111 31.566 12.738 19.814 24.776 0 0 0 0 0 0 0 0 0 1 0 59 30.019 30.111 31.566 12.738 19.814 0 0 0 0 0 0 0 0 0 0 1 60 31.934 30.019 30.111 31.566 12.738 0 0 0 0 0 0 0 0 0 0 0 61 25.826 31.934 30.019 30.111 31.566 1 0 0 0 0 0 0 0 0 0 0 62 26.835 25.826 31.934 30.019 30.111 0 1 0 0 0 0 0 0 0 0 0 63 20.205 26.835 25.826 31.934 30.019 0 0 1 0 0 0 0 0 0 0 0 64 17.789 20.205 26.835 25.826 31.934 0 0 0 1 0 0 0 0 0 0 0 65 20.520 17.789 20.205 26.835 25.826 0 0 0 0 1 0 0 0 0 0 0 66 22.518 20.520 17.789 20.205 26.835 0 0 0 0 0 1 0 0 0 0 0 67 15.572 22.518 20.520 17.789 20.205 0 0 0 0 0 0 1 0 0 0 0 68 11.509 15.572 22.518 20.520 17.789 0 0 0 0 0 0 0 1 0 0 0 69 25.447 11.509 15.572 22.518 20.520 0 0 0 0 0 0 0 0 1 0 0 70 24.090 25.447 11.509 15.572 22.518 0 0 0 0 0 0 0 0 0 1 0 71 27.786 24.090 25.447 11.509 15.572 0 0 0 0 0 0 0 0 0 0 1 72 26.195 27.786 24.090 25.447 11.509 0 0 0 0 0 0 0 0 0 0 0 73 20.516 26.195 27.786 24.090 25.447 1 0 0 0 0 0 0 0 0 0 0 74 22.759 20.516 26.195 27.786 24.090 0 1 0 0 0 0 0 0 0 0 0 75 19.028 22.759 20.516 26.195 27.786 0 0 1 0 0 0 0 0 0 0 0 76 16.971 19.028 22.759 20.516 26.195 0 0 0 1 0 0 0 0 0 0 0 77 20.036 16.971 19.028 22.759 20.516 0 0 0 0 1 0 0 0 0 0 0 78 22.485 20.036 16.971 19.028 22.759 0 0 0 0 0 1 0 0 0 0 0 79 18.730 22.485 20.036 16.971 19.028 0 0 0 0 0 0 1 0 0 0 0 80 14.538 18.730 22.485 20.036 16.971 0 0 0 0 0 0 0 1 0 0 0 > 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 12.24062 0.23237 0.33451 0.01905 -0.08467 -3.48049 M2 M3 M4 M5 M6 M7 -0.46704 -4.48331 -5.27301 -1.33981 1.53665 -4.77797 M8 M9 M10 M11 -10.30016 9.78307 5.88076 4.15159 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -3.90057 -1.04918 -0.08109 1.14749 5.04466 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 12.24062 4.41801 2.771 0.00732 ** Yt_1 0.23237 0.12506 1.858 0.06776 . Yt_2 0.33451 0.12748 2.624 0.01085 * Yt_3 0.01905 0.12811 0.149 0.88224 Yt_4 -0.08467 0.12299 -0.688 0.49366 M1 -3.48049 2.45527 -1.418 0.16117 M2 -0.46704 2.33137 -0.200 0.84186 M3 -4.48331 2.82158 -1.589 0.11700 M4 -5.27301 2.78729 -1.892 0.06304 . M5 -1.33981 2.62901 -0.510 0.61207 M6 1.53665 2.88538 0.533 0.59618 M7 -4.77797 2.31827 -2.061 0.04337 * M8 -10.30016 2.21075 -4.659 1.66e-05 *** M9 9.78307 2.84030 3.444 0.00101 ** M10 5.88076 3.14871 1.868 0.06639 . M11 4.15159 2.67719 1.551 0.12590 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 1.897 on 64 degrees of freedom Multiple R-squared: 0.9099, Adjusted R-squared: 0.8887 F-statistic: 43.07 on 15 and 64 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.2263226 0.4526452 0.77367742 [2,] 0.1292987 0.2585974 0.87070131 [3,] 0.0667440 0.1334880 0.93325600 [4,] 0.2316076 0.4632152 0.76839239 [5,] 0.9362684 0.1274631 0.06373157 [6,] 0.9358945 0.1282109 0.06410546 [7,] 0.9007881 0.1984237 0.09921187 [8,] 0.9039383 0.1921233 0.09606165 [9,] 0.9258764 0.1482472 0.07412360 [10,] 0.8919711 0.2160577 0.10802886 [11,] 0.8432265 0.3135471 0.15677354 [12,] 0.9067942 0.1864116 0.09320581 [13,] 0.8724404 0.2551191 0.12755955 [14,] 0.8734750 0.2530501 0.12652503 [15,] 0.8801096 0.2397808 0.11989040 [16,] 0.8556109 0.2887781 0.14438905 [17,] 0.8582929 0.2834143 0.14170714 [18,] 0.9057827 0.1884346 0.09421729 [19,] 0.9314995 0.1370011 0.06850053 [20,] 0.9161892 0.1676215 0.08381076 [21,] 0.9065318 0.1869365 0.09346823 [22,] 0.8669833 0.2660334 0.13301668 [23,] 0.8255496 0.3489009 0.17445045 [24,] 0.7958762 0.4082475 0.20412375 [25,] 0.7406812 0.5186376 0.25931881 [26,] 0.7809342 0.4381315 0.21906576 [27,] 0.8256226 0.3487547 0.17437735 [28,] 0.7693744 0.4612511 0.23062555 [29,] 0.7610622 0.4778756 0.23893778 [30,] 0.8714952 0.2570096 0.12850481 [31,] 0.9311582 0.1376836 0.06884178 [32,] 0.8960216 0.2079568 0.10397838 [33,] 0.8701808 0.2596383 0.12981917 [34,] 0.8347581 0.3304839 0.16524195 [35,] 0.7667062 0.4665876 0.23329380 [36,] 0.7649872 0.4700256 0.23501282 [37,] 0.6889568 0.6220863 0.31104317 [38,] 0.6440807 0.7118386 0.35591929 [39,] 0.7848147 0.4303705 0.21518526 [40,] 0.6945288 0.6109424 0.30547118 [41,] 0.6341371 0.7317257 0.36586287 [42,] 0.8468796 0.3062408 0.15312039 [43,] 0.7216485 0.5567031 0.27835155 > postscript(file="/var/www/html/freestat/rcomp/tmp/12pqz1291111704.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/22pqz1291111704.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/32pqz1291111704.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/4vy7k1291111704.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/5vy7k1291111704.ps",horizontal=F,onefile=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 = 80 Frequency = 1 1 2 3 4 5 6 -0.132118134 -0.136714533 2.912335092 -0.114461427 -0.158725061 2.268002307 7 8 9 10 11 12 -1.094101844 2.161058355 -2.254079391 1.353656879 5.044659039 2.279567055 13 14 15 16 17 18 -3.900569235 -1.646732306 -0.515896068 0.530975944 0.824391825 0.121959293 19 20 21 22 23 24 0.790011762 0.888135135 -0.611000233 -2.496715278 -1.832321877 -0.477941845 25 26 27 28 29 30 -0.211047480 2.817972048 -1.607341289 0.355440948 -0.198576491 -2.884256468 31 32 33 34 35 36 0.998964043 -0.943978025 2.554619018 1.703430402 1.928468183 -2.667118828 37 38 39 40 41 42 2.264305484 -1.541493676 -1.644909076 0.006926484 -0.983739388 -1.149058228 43 44 45 46 47 48 0.158085895 -2.515358843 2.250584661 -0.489640482 -1.029078956 -2.185676617 49 50 51 52 53 54 2.207193122 1.185786818 0.376863111 0.063986846 -0.015393528 1.794998639 55 56 57 58 59 60 1.134727735 -0.901414233 1.211563775 2.113812757 -2.494487243 3.122322343 61 62 63 64 65 66 1.702534472 0.355385085 -0.493874791 -0.638544173 0.402094925 -0.091022978 67 68 69 70 71 72 -2.615593241 -0.467302920 -3.151687830 -2.184544278 -1.617239145 -0.071152109 73 74 75 76 77 78 -1.930298230 -1.034203437 0.972823022 -0.204324622 0.129947717 -0.060622565 79 80 0.627905650 1.778860531 > postscript(file="/var/www/html/freestat/rcomp/tmp/6vy7k1291111704.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > dum <- cbind(lag(myerror,k=1),myerror) > dum Time Series: Start = 0 End = 80 Frequency = 1 lag(myerror, k = 1) myerror 0 -0.132118134 NA 1 -0.136714533 -0.132118134 2 2.912335092 -0.136714533 3 -0.114461427 2.912335092 4 -0.158725061 -0.114461427 5 2.268002307 -0.158725061 6 -1.094101844 2.268002307 7 2.161058355 -1.094101844 8 -2.254079391 2.161058355 9 1.353656879 -2.254079391 10 5.044659039 1.353656879 11 2.279567055 5.044659039 12 -3.900569235 2.279567055 13 -1.646732306 -3.900569235 14 -0.515896068 -1.646732306 15 0.530975944 -0.515896068 16 0.824391825 0.530975944 17 0.121959293 0.824391825 18 0.790011762 0.121959293 19 0.888135135 0.790011762 20 -0.611000233 0.888135135 21 -2.496715278 -0.611000233 22 -1.832321877 -2.496715278 23 -0.477941845 -1.832321877 24 -0.211047480 -0.477941845 25 2.817972048 -0.211047480 26 -1.607341289 2.817972048 27 0.355440948 -1.607341289 28 -0.198576491 0.355440948 29 -2.884256468 -0.198576491 30 0.998964043 -2.884256468 31 -0.943978025 0.998964043 32 2.554619018 -0.943978025 33 1.703430402 2.554619018 34 1.928468183 1.703430402 35 -2.667118828 1.928468183 36 2.264305484 -2.667118828 37 -1.541493676 2.264305484 38 -1.644909076 -1.541493676 39 0.006926484 -1.644909076 40 -0.983739388 0.006926484 41 -1.149058228 -0.983739388 42 0.158085895 -1.149058228 43 -2.515358843 0.158085895 44 2.250584661 -2.515358843 45 -0.489640482 2.250584661 46 -1.029078956 -0.489640482 47 -2.185676617 -1.029078956 48 2.207193122 -2.185676617 49 1.185786818 2.207193122 50 0.376863111 1.185786818 51 0.063986846 0.376863111 52 -0.015393528 0.063986846 53 1.794998639 -0.015393528 54 1.134727735 1.794998639 55 -0.901414233 1.134727735 56 1.211563775 -0.901414233 57 2.113812757 1.211563775 58 -2.494487243 2.113812757 59 3.122322343 -2.494487243 60 1.702534472 3.122322343 61 0.355385085 1.702534472 62 -0.493874791 0.355385085 63 -0.638544173 -0.493874791 64 0.402094925 -0.638544173 65 -0.091022978 0.402094925 66 -2.615593241 -0.091022978 67 -0.467302920 -2.615593241 68 -3.151687830 -0.467302920 69 -2.184544278 -3.151687830 70 -1.617239145 -2.184544278 71 -0.071152109 -1.617239145 72 -1.930298230 -0.071152109 73 -1.034203437 -1.930298230 74 0.972823022 -1.034203437 75 -0.204324622 0.972823022 76 0.129947717 -0.204324622 77 -0.060622565 0.129947717 78 0.627905650 -0.060622565 79 1.778860531 0.627905650 80 NA 1.778860531 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -0.136714533 -0.132118134 [2,] 2.912335092 -0.136714533 [3,] -0.114461427 2.912335092 [4,] -0.158725061 -0.114461427 [5,] 2.268002307 -0.158725061 [6,] -1.094101844 2.268002307 [7,] 2.161058355 -1.094101844 [8,] -2.254079391 2.161058355 [9,] 1.353656879 -2.254079391 [10,] 5.044659039 1.353656879 [11,] 2.279567055 5.044659039 [12,] -3.900569235 2.279567055 [13,] -1.646732306 -3.900569235 [14,] -0.515896068 -1.646732306 [15,] 0.530975944 -0.515896068 [16,] 0.824391825 0.530975944 [17,] 0.121959293 0.824391825 [18,] 0.790011762 0.121959293 [19,] 0.888135135 0.790011762 [20,] -0.611000233 0.888135135 [21,] -2.496715278 -0.611000233 [22,] -1.832321877 -2.496715278 [23,] -0.477941845 -1.832321877 [24,] -0.211047480 -0.477941845 [25,] 2.817972048 -0.211047480 [26,] -1.607341289 2.817972048 [27,] 0.355440948 -1.607341289 [28,] -0.198576491 0.355440948 [29,] -2.884256468 -0.198576491 [30,] 0.998964043 -2.884256468 [31,] -0.943978025 0.998964043 [32,] 2.554619018 -0.943978025 [33,] 1.703430402 2.554619018 [34,] 1.928468183 1.703430402 [35,] -2.667118828 1.928468183 [36,] 2.264305484 -2.667118828 [37,] -1.541493676 2.264305484 [38,] -1.644909076 -1.541493676 [39,] 0.006926484 -1.644909076 [40,] -0.983739388 0.006926484 [41,] -1.149058228 -0.983739388 [42,] 0.158085895 -1.149058228 [43,] -2.515358843 0.158085895 [44,] 2.250584661 -2.515358843 [45,] -0.489640482 2.250584661 [46,] -1.029078956 -0.489640482 [47,] -2.185676617 -1.029078956 [48,] 2.207193122 -2.185676617 [49,] 1.185786818 2.207193122 [50,] 0.376863111 1.185786818 [51,] 0.063986846 0.376863111 [52,] -0.015393528 0.063986846 [53,] 1.794998639 -0.015393528 [54,] 1.134727735 1.794998639 [55,] -0.901414233 1.134727735 [56,] 1.211563775 -0.901414233 [57,] 2.113812757 1.211563775 [58,] -2.494487243 2.113812757 [59,] 3.122322343 -2.494487243 [60,] 1.702534472 3.122322343 [61,] 0.355385085 1.702534472 [62,] -0.493874791 0.355385085 [63,] -0.638544173 -0.493874791 [64,] 0.402094925 -0.638544173 [65,] -0.091022978 0.402094925 [66,] -2.615593241 -0.091022978 [67,] -0.467302920 -2.615593241 [68,] -3.151687830 -0.467302920 [69,] -2.184544278 -3.151687830 [70,] -1.617239145 -2.184544278 [71,] -0.071152109 -1.617239145 [72,] -1.930298230 -0.071152109 [73,] -1.034203437 -1.930298230 [74,] 0.972823022 -1.034203437 [75,] -0.204324622 0.972823022 [76,] 0.129947717 -0.204324622 [77,] -0.060622565 0.129947717 [78,] 0.627905650 -0.060622565 [79,] 1.778860531 0.627905650 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -0.136714533 -0.132118134 2 2.912335092 -0.136714533 3 -0.114461427 2.912335092 4 -0.158725061 -0.114461427 5 2.268002307 -0.158725061 6 -1.094101844 2.268002307 7 2.161058355 -1.094101844 8 -2.254079391 2.161058355 9 1.353656879 -2.254079391 10 5.044659039 1.353656879 11 2.279567055 5.044659039 12 -3.900569235 2.279567055 13 -1.646732306 -3.900569235 14 -0.515896068 -1.646732306 15 0.530975944 -0.515896068 16 0.824391825 0.530975944 17 0.121959293 0.824391825 18 0.790011762 0.121959293 19 0.888135135 0.790011762 20 -0.611000233 0.888135135 21 -2.496715278 -0.611000233 22 -1.832321877 -2.496715278 23 -0.477941845 -1.832321877 24 -0.211047480 -0.477941845 25 2.817972048 -0.211047480 26 -1.607341289 2.817972048 27 0.355440948 -1.607341289 28 -0.198576491 0.355440948 29 -2.884256468 -0.198576491 30 0.998964043 -2.884256468 31 -0.943978025 0.998964043 32 2.554619018 -0.943978025 33 1.703430402 2.554619018 34 1.928468183 1.703430402 35 -2.667118828 1.928468183 36 2.264305484 -2.667118828 37 -1.541493676 2.264305484 38 -1.644909076 -1.541493676 39 0.006926484 -1.644909076 40 -0.983739388 0.006926484 41 -1.149058228 -0.983739388 42 0.158085895 -1.149058228 43 -2.515358843 0.158085895 44 2.250584661 -2.515358843 45 -0.489640482 2.250584661 46 -1.029078956 -0.489640482 47 -2.185676617 -1.029078956 48 2.207193122 -2.185676617 49 1.185786818 2.207193122 50 0.376863111 1.185786818 51 0.063986846 0.376863111 52 -0.015393528 0.063986846 53 1.794998639 -0.015393528 54 1.134727735 1.794998639 55 -0.901414233 1.134727735 56 1.211563775 -0.901414233 57 2.113812757 1.211563775 58 -2.494487243 2.113812757 59 3.122322343 -2.494487243 60 1.702534472 3.122322343 61 0.355385085 1.702534472 62 -0.493874791 0.355385085 63 -0.638544173 -0.493874791 64 0.402094925 -0.638544173 65 -0.091022978 0.402094925 66 -2.615593241 -0.091022978 67 -0.467302920 -2.615593241 68 -3.151687830 -0.467302920 69 -2.184544278 -3.151687830 70 -1.617239145 -2.184544278 71 -0.071152109 -1.617239145 72 -1.930298230 -0.071152109 73 -1.034203437 -1.930298230 74 0.972823022 -1.034203437 75 -0.204324622 0.972823022 76 0.129947717 -0.204324622 77 -0.060622565 0.129947717 78 0.627905650 -0.060622565 79 1.778860531 0.627905650 > 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/freestat/rcomp/tmp/76ppn1291111704.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/8zyoq1291111704.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/9zyoq1291111704.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/10rqnb1291111704.ps",horizontal=F,onefile=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/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/11v8lh1291111704.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/freestat/rcomp/tmp/12yr251291111704.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/freestat/rcomp/tmp/13c00w1291111704.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/freestat/rcomp/tmp/14yjyk1291111704.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/freestat/rcomp/tmp/1512x81291111704.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/freestat/rcomp/tmp/16fbcg1291111704.tab") + } > try(system("convert tmp/12pqz1291111704.ps tmp/12pqz1291111704.png",intern=TRUE)) character(0) > try(system("convert tmp/22pqz1291111704.ps tmp/22pqz1291111704.png",intern=TRUE)) character(0) > try(system("convert tmp/32pqz1291111704.ps tmp/32pqz1291111704.png",intern=TRUE)) character(0) > try(system("convert tmp/4vy7k1291111704.ps tmp/4vy7k1291111704.png",intern=TRUE)) character(0) > try(system("convert tmp/5vy7k1291111704.ps tmp/5vy7k1291111704.png",intern=TRUE)) character(0) > try(system("convert tmp/6vy7k1291111704.ps tmp/6vy7k1291111704.png",intern=TRUE)) character(0) > try(system("convert tmp/76ppn1291111704.ps tmp/76ppn1291111704.png",intern=TRUE)) character(0) > try(system("convert tmp/8zyoq1291111704.ps tmp/8zyoq1291111704.png",intern=TRUE)) character(0) > try(system("convert tmp/9zyoq1291111704.ps tmp/9zyoq1291111704.png",intern=TRUE)) character(0) > try(system("convert tmp/10rqnb1291111704.ps tmp/10rqnb1291111704.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 4.119 2.503 4.484