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(22,0,22,0,20,0,21,0,20,0,21,0,21,0,21,0,19,0,21,0,21,0,22,0,19,0,24,0,22,0,22,0,22,0,24,0,22,0,23,0,24,0,21,0,20,0,22,0,23,0,23,0,22,0,20,0,21,1,21,1,20,1,20,1,17,1,18,1,19,1,19,1,20,1,21,1,20,1,21,1,19,1,22,1,20,1,18,1,16,1,17,1,18,1,19,1,18,1,20,1,21,1,18,1,19,1,19,1,19,1,21,1,19,1,19,1,17,1,16,1,16,1,17,1,16,1,15,1,16,1,16,1,16,1,18,1,19,1,16,1,16,1,16,1),dim=c(2,72),dimnames=list(c('Y','X'),1:72)) > y <- array(NA,dim=c(2,72),dimnames=list(c('Y','X'),1:72)) > 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 Y X M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 1 22 0 1 0 0 0 0 0 0 0 0 0 0 2 22 0 0 1 0 0 0 0 0 0 0 0 0 3 20 0 0 0 1 0 0 0 0 0 0 0 0 4 21 0 0 0 0 1 0 0 0 0 0 0 0 5 20 0 0 0 0 0 1 0 0 0 0 0 0 6 21 0 0 0 0 0 0 1 0 0 0 0 0 7 21 0 0 0 0 0 0 0 1 0 0 0 0 8 21 0 0 0 0 0 0 0 0 1 0 0 0 9 19 0 0 0 0 0 0 0 0 0 1 0 0 10 21 0 0 0 0 0 0 0 0 0 0 1 0 11 21 0 0 0 0 0 0 0 0 0 0 0 1 12 22 0 0 0 0 0 0 0 0 0 0 0 0 13 19 0 1 0 0 0 0 0 0 0 0 0 0 14 24 0 0 1 0 0 0 0 0 0 0 0 0 15 22 0 0 0 1 0 0 0 0 0 0 0 0 16 22 0 0 0 0 1 0 0 0 0 0 0 0 17 22 0 0 0 0 0 1 0 0 0 0 0 0 18 24 0 0 0 0 0 0 1 0 0 0 0 0 19 22 0 0 0 0 0 0 0 1 0 0 0 0 20 23 0 0 0 0 0 0 0 0 1 0 0 0 21 24 0 0 0 0 0 0 0 0 0 1 0 0 22 21 0 0 0 0 0 0 0 0 0 0 1 0 23 20 0 0 0 0 0 0 0 0 0 0 0 1 24 22 0 0 0 0 0 0 0 0 0 0 0 0 25 23 0 1 0 0 0 0 0 0 0 0 0 0 26 23 0 0 1 0 0 0 0 0 0 0 0 0 27 22 0 0 0 1 0 0 0 0 0 0 0 0 28 20 0 0 0 0 1 0 0 0 0 0 0 0 29 21 1 0 0 0 0 1 0 0 0 0 0 0 30 21 1 0 0 0 0 0 1 0 0 0 0 0 31 20 1 0 0 0 0 0 0 1 0 0 0 0 32 20 1 0 0 0 0 0 0 0 1 0 0 0 33 17 1 0 0 0 0 0 0 0 0 1 0 0 34 18 1 0 0 0 0 0 0 0 0 0 1 0 35 19 1 0 0 0 0 0 0 0 0 0 0 1 36 19 1 0 0 0 0 0 0 0 0 0 0 0 37 20 1 1 0 0 0 0 0 0 0 0 0 0 38 21 1 0 1 0 0 0 0 0 0 0 0 0 39 20 1 0 0 1 0 0 0 0 0 0 0 0 40 21 1 0 0 0 1 0 0 0 0 0 0 0 41 19 1 0 0 0 0 1 0 0 0 0 0 0 42 22 1 0 0 0 0 0 1 0 0 0 0 0 43 20 1 0 0 0 0 0 0 1 0 0 0 0 44 18 1 0 0 0 0 0 0 0 1 0 0 0 45 16 1 0 0 0 0 0 0 0 0 1 0 0 46 17 1 0 0 0 0 0 0 0 0 0 1 0 47 18 1 0 0 0 0 0 0 0 0 0 0 1 48 19 1 0 0 0 0 0 0 0 0 0 0 0 49 18 1 1 0 0 0 0 0 0 0 0 0 0 50 20 1 0 1 0 0 0 0 0 0 0 0 0 51 21 1 0 0 1 0 0 0 0 0 0 0 0 52 18 1 0 0 0 1 0 0 0 0 0 0 0 53 19 1 0 0 0 0 1 0 0 0 0 0 0 54 19 1 0 0 0 0 0 1 0 0 0 0 0 55 19 1 0 0 0 0 0 0 1 0 0 0 0 56 21 1 0 0 0 0 0 0 0 1 0 0 0 57 19 1 0 0 0 0 0 0 0 0 1 0 0 58 19 1 0 0 0 0 0 0 0 0 0 1 0 59 17 1 0 0 0 0 0 0 0 0 0 0 1 60 16 1 0 0 0 0 0 0 0 0 0 0 0 61 16 1 1 0 0 0 0 0 0 0 0 0 0 62 17 1 0 1 0 0 0 0 0 0 0 0 0 63 16 1 0 0 1 0 0 0 0 0 0 0 0 64 15 1 0 0 0 1 0 0 0 0 0 0 0 65 16 1 0 0 0 0 1 0 0 0 0 0 0 66 16 1 0 0 0 0 0 1 0 0 0 0 0 67 16 1 0 0 0 0 0 0 1 0 0 0 0 68 18 1 0 0 0 0 0 0 0 1 0 0 0 69 19 1 0 0 0 0 0 0 0 0 1 0 0 70 16 1 0 0 0 0 0 0 0 0 0 1 0 71 16 1 0 0 0 0 0 0 0 0 0 0 1 72 16 1 0 0 0 0 0 0 0 0 0 0 0 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X M1 M2 M3 M4 2.110e+01 -3.150e+00 1.417e-01 1.642e+00 6.417e-01 -2.500e-02 M5 M6 M7 M8 M9 M10 5.000e-01 1.500e+00 6.667e-01 1.167e+00 -1.243e-15 -3.333e-01 M11 -5.000e-01 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -3.4500 -1.1542 0.2583 1.0500 3.0750 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.110e+01 7.444e-01 28.343 < 2e-16 *** X -3.150e+00 4.147e-01 -7.596 2.65e-10 *** M1 1.417e-01 9.799e-01 0.145 0.8855 M2 1.642e+00 9.799e-01 1.675 0.0992 . M3 6.417e-01 9.799e-01 0.655 0.5151 M4 -2.500e-02 9.799e-01 -0.026 0.9797 M5 5.000e-01 9.775e-01 0.512 0.6109 M6 1.500e+00 9.775e-01 1.535 0.1302 M7 6.667e-01 9.775e-01 0.682 0.4979 M8 1.167e+00 9.775e-01 1.194 0.2374 M9 -1.243e-15 9.775e-01 -1.27e-15 1.0000 M10 -3.333e-01 9.775e-01 -0.341 0.7343 M11 -5.000e-01 9.775e-01 -0.512 0.6109 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.693 on 59 degrees of freedom Multiple R-squared: 0.5488, Adjusted R-squared: 0.4571 F-statistic: 5.981 on 12 and 59 DF, p-value: 1.093e-06 > 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.57056470 0.85887060 0.4294353 [2,] 0.49445189 0.98890378 0.5055481 [3,] 0.52903969 0.94192062 0.4709603 [4,] 0.41143857 0.82287713 0.5885614 [5,] 0.35703586 0.71407173 0.6429641 [6,] 0.61990942 0.76018116 0.3800906 [7,] 0.51118270 0.97763460 0.4888173 [8,] 0.42180574 0.84361148 0.5781943 [9,] 0.32741393 0.65482785 0.6725861 [10,] 0.33937812 0.67875625 0.6606219 [11,] 0.25807566 0.51615132 0.7419243 [12,] 0.19870782 0.39741564 0.8012922 [13,] 0.15903946 0.31807891 0.8409605 [14,] 0.13235706 0.26471411 0.8676429 [15,] 0.10609009 0.21218019 0.8939099 [16,] 0.07774296 0.15548593 0.9222570 [17,] 0.05464132 0.10928264 0.9453587 [18,] 0.06567044 0.13134089 0.9343296 [19,] 0.04579346 0.09158693 0.9542065 [20,] 0.03337644 0.06675288 0.9666236 [21,] 0.02517962 0.05035924 0.9748204 [22,] 0.02179098 0.04358196 0.9782090 [23,] 0.01641405 0.03282810 0.9835859 [24,] 0.01085365 0.02170731 0.9891463 [25,] 0.02160935 0.04321869 0.9783907 [26,] 0.01504820 0.03009641 0.9849518 [27,] 0.02914005 0.05828010 0.9708600 [28,] 0.02532249 0.05064497 0.9746775 [29,] 0.02487587 0.04975174 0.9751241 [30,] 0.04361247 0.08722495 0.9563875 [31,] 0.03212408 0.06424815 0.9678759 [32,] 0.02258359 0.04516717 0.9774164 [33,] 0.02564866 0.05129732 0.9743513 [34,] 0.02094911 0.04189822 0.9790509 [35,] 0.02145518 0.04291035 0.9785448 [36,] 0.07841212 0.15682425 0.9215879 [37,] 0.09857899 0.19715799 0.9014210 [38,] 0.12154204 0.24308409 0.8784580 [39,] 0.17648107 0.35296214 0.8235189 [40,] 0.25003128 0.50006256 0.7499687 [41,] 0.41238052 0.82476104 0.5876195 > postscript(file="/var/www/html/rcomp/tmp/162al1258726134.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/20i1k1258726134.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/361md1258726134.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/4k1721258726134.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/5i8iu1258726134.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 = 72 Frequency = 1 1 2 3 4 5 6 0.75833333 -0.74166667 -1.74166667 -0.07500000 -1.60000000 -1.60000000 7 8 9 10 11 12 -0.76666667 -1.26666667 -2.10000000 0.23333333 0.40000000 0.90000000 13 14 15 16 17 18 -2.24166667 1.25833333 0.25833333 0.92500000 0.40000000 1.40000000 19 20 21 22 23 24 0.23333333 0.73333333 2.90000000 0.23333333 -0.60000000 0.90000000 25 26 27 28 29 30 1.75833333 0.25833333 0.25833333 -1.07500000 2.55000000 1.55000000 31 32 33 34 35 36 1.38333333 0.88333333 -0.95000000 0.38333333 1.55000000 1.05000000 37 38 39 40 41 42 1.90833333 1.40833333 1.40833333 3.07500000 0.55000000 2.55000000 43 44 45 46 47 48 1.38333333 -1.11666667 -1.95000000 -0.61666667 0.55000000 1.05000000 49 50 51 52 53 54 -0.09166667 0.40833333 2.40833333 0.07500000 0.55000000 -0.45000000 55 56 57 58 59 60 0.38333333 1.88333333 1.05000000 1.38333333 -0.45000000 -1.95000000 61 62 63 64 65 66 -2.09166667 -2.59166667 -2.59166667 -2.92500000 -2.45000000 -3.45000000 67 68 69 70 71 72 -2.61666667 -1.11666667 1.05000000 -1.61666667 -1.45000000 -1.95000000 > postscript(file="/var/www/html/rcomp/tmp/6sy4m1258726134.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 = 72 Frequency = 1 lag(myerror, k = 1) myerror 0 0.75833333 NA 1 -0.74166667 0.75833333 2 -1.74166667 -0.74166667 3 -0.07500000 -1.74166667 4 -1.60000000 -0.07500000 5 -1.60000000 -1.60000000 6 -0.76666667 -1.60000000 7 -1.26666667 -0.76666667 8 -2.10000000 -1.26666667 9 0.23333333 -2.10000000 10 0.40000000 0.23333333 11 0.90000000 0.40000000 12 -2.24166667 0.90000000 13 1.25833333 -2.24166667 14 0.25833333 1.25833333 15 0.92500000 0.25833333 16 0.40000000 0.92500000 17 1.40000000 0.40000000 18 0.23333333 1.40000000 19 0.73333333 0.23333333 20 2.90000000 0.73333333 21 0.23333333 2.90000000 22 -0.60000000 0.23333333 23 0.90000000 -0.60000000 24 1.75833333 0.90000000 25 0.25833333 1.75833333 26 0.25833333 0.25833333 27 -1.07500000 0.25833333 28 2.55000000 -1.07500000 29 1.55000000 2.55000000 30 1.38333333 1.55000000 31 0.88333333 1.38333333 32 -0.95000000 0.88333333 33 0.38333333 -0.95000000 34 1.55000000 0.38333333 35 1.05000000 1.55000000 36 1.90833333 1.05000000 37 1.40833333 1.90833333 38 1.40833333 1.40833333 39 3.07500000 1.40833333 40 0.55000000 3.07500000 41 2.55000000 0.55000000 42 1.38333333 2.55000000 43 -1.11666667 1.38333333 44 -1.95000000 -1.11666667 45 -0.61666667 -1.95000000 46 0.55000000 -0.61666667 47 1.05000000 0.55000000 48 -0.09166667 1.05000000 49 0.40833333 -0.09166667 50 2.40833333 0.40833333 51 0.07500000 2.40833333 52 0.55000000 0.07500000 53 -0.45000000 0.55000000 54 0.38333333 -0.45000000 55 1.88333333 0.38333333 56 1.05000000 1.88333333 57 1.38333333 1.05000000 58 -0.45000000 1.38333333 59 -1.95000000 -0.45000000 60 -2.09166667 -1.95000000 61 -2.59166667 -2.09166667 62 -2.59166667 -2.59166667 63 -2.92500000 -2.59166667 64 -2.45000000 -2.92500000 65 -3.45000000 -2.45000000 66 -2.61666667 -3.45000000 67 -1.11666667 -2.61666667 68 1.05000000 -1.11666667 69 -1.61666667 1.05000000 70 -1.45000000 -1.61666667 71 -1.95000000 -1.45000000 72 NA -1.95000000 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -0.74166667 0.75833333 [2,] -1.74166667 -0.74166667 [3,] -0.07500000 -1.74166667 [4,] -1.60000000 -0.07500000 [5,] -1.60000000 -1.60000000 [6,] -0.76666667 -1.60000000 [7,] -1.26666667 -0.76666667 [8,] -2.10000000 -1.26666667 [9,] 0.23333333 -2.10000000 [10,] 0.40000000 0.23333333 [11,] 0.90000000 0.40000000 [12,] -2.24166667 0.90000000 [13,] 1.25833333 -2.24166667 [14,] 0.25833333 1.25833333 [15,] 0.92500000 0.25833333 [16,] 0.40000000 0.92500000 [17,] 1.40000000 0.40000000 [18,] 0.23333333 1.40000000 [19,] 0.73333333 0.23333333 [20,] 2.90000000 0.73333333 [21,] 0.23333333 2.90000000 [22,] -0.60000000 0.23333333 [23,] 0.90000000 -0.60000000 [24,] 1.75833333 0.90000000 [25,] 0.25833333 1.75833333 [26,] 0.25833333 0.25833333 [27,] -1.07500000 0.25833333 [28,] 2.55000000 -1.07500000 [29,] 1.55000000 2.55000000 [30,] 1.38333333 1.55000000 [31,] 0.88333333 1.38333333 [32,] -0.95000000 0.88333333 [33,] 0.38333333 -0.95000000 [34,] 1.55000000 0.38333333 [35,] 1.05000000 1.55000000 [36,] 1.90833333 1.05000000 [37,] 1.40833333 1.90833333 [38,] 1.40833333 1.40833333 [39,] 3.07500000 1.40833333 [40,] 0.55000000 3.07500000 [41,] 2.55000000 0.55000000 [42,] 1.38333333 2.55000000 [43,] -1.11666667 1.38333333 [44,] -1.95000000 -1.11666667 [45,] -0.61666667 -1.95000000 [46,] 0.55000000 -0.61666667 [47,] 1.05000000 0.55000000 [48,] -0.09166667 1.05000000 [49,] 0.40833333 -0.09166667 [50,] 2.40833333 0.40833333 [51,] 0.07500000 2.40833333 [52,] 0.55000000 0.07500000 [53,] -0.45000000 0.55000000 [54,] 0.38333333 -0.45000000 [55,] 1.88333333 0.38333333 [56,] 1.05000000 1.88333333 [57,] 1.38333333 1.05000000 [58,] -0.45000000 1.38333333 [59,] -1.95000000 -0.45000000 [60,] -2.09166667 -1.95000000 [61,] -2.59166667 -2.09166667 [62,] -2.59166667 -2.59166667 [63,] -2.92500000 -2.59166667 [64,] -2.45000000 -2.92500000 [65,] -3.45000000 -2.45000000 [66,] -2.61666667 -3.45000000 [67,] -1.11666667 -2.61666667 [68,] 1.05000000 -1.11666667 [69,] -1.61666667 1.05000000 [70,] -1.45000000 -1.61666667 [71,] -1.95000000 -1.45000000 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -0.74166667 0.75833333 2 -1.74166667 -0.74166667 3 -0.07500000 -1.74166667 4 -1.60000000 -0.07500000 5 -1.60000000 -1.60000000 6 -0.76666667 -1.60000000 7 -1.26666667 -0.76666667 8 -2.10000000 -1.26666667 9 0.23333333 -2.10000000 10 0.40000000 0.23333333 11 0.90000000 0.40000000 12 -2.24166667 0.90000000 13 1.25833333 -2.24166667 14 0.25833333 1.25833333 15 0.92500000 0.25833333 16 0.40000000 0.92500000 17 1.40000000 0.40000000 18 0.23333333 1.40000000 19 0.73333333 0.23333333 20 2.90000000 0.73333333 21 0.23333333 2.90000000 22 -0.60000000 0.23333333 23 0.90000000 -0.60000000 24 1.75833333 0.90000000 25 0.25833333 1.75833333 26 0.25833333 0.25833333 27 -1.07500000 0.25833333 28 2.55000000 -1.07500000 29 1.55000000 2.55000000 30 1.38333333 1.55000000 31 0.88333333 1.38333333 32 -0.95000000 0.88333333 33 0.38333333 -0.95000000 34 1.55000000 0.38333333 35 1.05000000 1.55000000 36 1.90833333 1.05000000 37 1.40833333 1.90833333 38 1.40833333 1.40833333 39 3.07500000 1.40833333 40 0.55000000 3.07500000 41 2.55000000 0.55000000 42 1.38333333 2.55000000 43 -1.11666667 1.38333333 44 -1.95000000 -1.11666667 45 -0.61666667 -1.95000000 46 0.55000000 -0.61666667 47 1.05000000 0.55000000 48 -0.09166667 1.05000000 49 0.40833333 -0.09166667 50 2.40833333 0.40833333 51 0.07500000 2.40833333 52 0.55000000 0.07500000 53 -0.45000000 0.55000000 54 0.38333333 -0.45000000 55 1.88333333 0.38333333 56 1.05000000 1.88333333 57 1.38333333 1.05000000 58 -0.45000000 1.38333333 59 -1.95000000 -0.45000000 60 -2.09166667 -1.95000000 61 -2.59166667 -2.09166667 62 -2.59166667 -2.59166667 63 -2.92500000 -2.59166667 64 -2.45000000 -2.92500000 65 -3.45000000 -2.45000000 66 -2.61666667 -3.45000000 67 -1.11666667 -2.61666667 68 1.05000000 -1.11666667 69 -1.61666667 1.05000000 70 -1.45000000 -1.61666667 71 -1.95000000 -1.45000000 > 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/70l4h1258726134.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/8ohdk1258726134.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/9n2lh1258726134.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/10fw081258726134.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/119jyn1258726134.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/127aux1258726134.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/13ntb71258726134.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/14az6m1258726134.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/151doc1258726134.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/16dak91258726134.tab") + } > system("convert tmp/162al1258726134.ps tmp/162al1258726134.png") > system("convert tmp/20i1k1258726134.ps tmp/20i1k1258726134.png") > system("convert tmp/361md1258726134.ps tmp/361md1258726134.png") > system("convert tmp/4k1721258726134.ps tmp/4k1721258726134.png") > system("convert tmp/5i8iu1258726134.ps tmp/5i8iu1258726134.png") > system("convert tmp/6sy4m1258726134.ps tmp/6sy4m1258726134.png") > system("convert tmp/70l4h1258726134.ps tmp/70l4h1258726134.png") > system("convert tmp/8ohdk1258726134.ps tmp/8ohdk1258726134.png") > system("convert tmp/9n2lh1258726134.ps tmp/9n2lh1258726134.png") > system("convert tmp/10fw081258726134.ps tmp/10fw081258726134.png") > > > proc.time() user system elapsed 2.595 1.588 3.132