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(8587 + ,9743 + ,9084 + ,9081 + ,9700 + ,9731 + ,8587 + ,9743 + ,9084 + ,9081 + ,9563 + ,9731 + ,8587 + ,9743 + ,9084 + ,9998 + ,9563 + ,9731 + ,8587 + ,9743 + ,9437 + ,9998 + ,9563 + ,9731 + ,8587 + ,10038 + ,9437 + ,9998 + ,9563 + ,9731 + ,9918 + ,10038 + ,9437 + ,9998 + ,9563 + ,9252 + ,9918 + ,10038 + ,9437 + ,9998 + ,9737 + ,9252 + ,9918 + ,10038 + ,9437 + ,9035 + ,9737 + ,9252 + ,9918 + ,10038 + ,9133 + ,9035 + ,9737 + ,9252 + ,9918 + ,9487 + ,9133 + ,9035 + ,9737 + ,9252 + ,8700 + ,9487 + ,9133 + ,9035 + ,9737 + ,9627 + ,8700 + ,9487 + ,9133 + ,9035 + ,8947 + ,9627 + ,8700 + ,9487 + ,9133 + ,9283 + ,8947 + ,9627 + ,8700 + ,9487 + ,8829 + ,9283 + ,8947 + ,9627 + ,8700 + ,9947 + ,8829 + ,9283 + ,8947 + ,9627 + ,9628 + ,9947 + ,8829 + ,9283 + ,8947 + ,9318 + ,9628 + ,9947 + ,8829 + ,9283 + ,9605 + ,9318 + ,9628 + ,9947 + ,8829 + ,8640 + ,9605 + ,9318 + ,9628 + ,9947 + ,9214 + ,8640 + ,9605 + ,9318 + ,9628 + ,9567 + ,9214 + ,8640 + ,9605 + ,9318 + ,8547 + ,9567 + ,9214 + ,8640 + ,9605 + ,9185 + ,8547 + ,9567 + ,9214 + ,8640 + ,9470 + ,9185 + ,8547 + ,9567 + ,9214 + ,9123 + ,9470 + ,9185 + ,8547 + ,9567 + ,9278 + ,9123 + ,9470 + ,9185 + ,8547 + ,10170 + ,9278 + ,9123 + ,9470 + ,9185 + ,9434 + ,10170 + ,9278 + ,9123 + ,9470 + ,9655 + ,9434 + ,10170 + ,9278 + ,9123 + ,9429 + ,9655 + ,9434 + ,10170 + ,9278 + ,8739 + ,9429 + ,9655 + ,9434 + ,10170 + ,9552 + ,8739 + ,9429 + ,9655 + ,9434 + ,9687 + ,9552 + ,8739 + ,9429 + ,9655 + ,9019 + ,9687 + ,9552 + ,8739 + ,9429 + ,9672 + ,9019 + ,9687 + ,9552 + ,8739 + ,9206 + ,9672 + ,9019 + ,9687 + ,9552 + ,9069 + ,9206 + ,9672 + ,9019 + ,9687 + ,9788 + ,9069 + ,9206 + ,9672 + ,9019 + ,10312 + ,9788 + ,9069 + ,9206 + ,9672 + ,10105 + ,10312 + ,9788 + ,9069 + ,9206 + ,9863 + ,10105 + ,10312 + ,9788 + ,9069 + ,9656 + ,9863 + ,10105 + ,10312 + ,9788 + ,9295 + ,9656 + ,9863 + ,10105 + ,10312 + ,9946 + ,9295 + ,9656 + ,9863 + ,10105 + ,9701 + ,9946 + ,9295 + ,9656 + ,9863 + ,9049 + ,9701 + ,9946 + ,9295 + ,9656 + ,10190 + ,9049 + ,9701 + ,9946 + ,9295 + ,9706 + ,10190 + ,9049 + ,9701 + ,9946 + ,9765 + ,9706 + ,10190 + ,9049 + ,9701 + ,9893 + ,9765 + ,9706 + ,10190 + ,9049 + ,9994 + ,9893 + ,9765 + ,9706 + ,10190 + ,10433 + ,9994 + ,9893 + ,9765 + ,9706 + ,10073 + ,10433 + ,9994 + ,9893 + ,9765 + ,10112 + ,10073 + ,10433 + ,9994 + ,9893 + ,9266 + ,10112 + ,10073 + ,10433 + ,9994 + ,9820 + ,9266 + ,10112 + ,10073 + ,10433 + ,10097 + ,9820 + ,9266 + ,10112 + ,10073 + ,9115 + ,10097 + ,9820 + ,9266 + ,10112 + ,10411 + ,9115 + ,10097 + ,9820 + ,9266 + ,9678 + ,10411 + ,9115 + ,10097 + ,9820 + ,10408 + ,9678 + ,10411 + ,9115 + ,10097 + ,10153 + ,10408 + ,9678 + ,10411 + ,9115 + ,10368 + ,10153 + ,10408 + ,9678 + ,10411 + ,10581 + ,10368 + ,10153 + ,10408 + ,9678 + ,10597 + ,10581 + ,10368 + ,10153 + ,10408 + ,10680 + ,10597 + ,10581 + ,10368 + ,10153 + ,9738 + ,10680 + ,10597 + ,10581 + ,10368 + ,9556 + ,9738 + ,10680 + ,10597 + ,10581) + ,dim=c(5 + ,71) + ,dimnames=list(c('MontlyBirths' + ,'Y1' + ,'Y2' + ,'Y3' + ,'Y4') + ,1:71)) > y <- array(NA,dim=c(5,71),dimnames=list(c('MontlyBirths','Y1','Y2','Y3','Y4'),1:71)) > 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 MontlyBirths Y1 Y2 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 8587 9743 9084 9081 9700 1 0 0 0 0 0 0 0 0 0 0 1 2 9731 8587 9743 9084 9081 0 1 0 0 0 0 0 0 0 0 0 2 3 9563 9731 8587 9743 9084 0 0 1 0 0 0 0 0 0 0 0 3 4 9998 9563 9731 8587 9743 0 0 0 1 0 0 0 0 0 0 0 4 5 9437 9998 9563 9731 8587 0 0 0 0 1 0 0 0 0 0 0 5 6 10038 9437 9998 9563 9731 0 0 0 0 0 1 0 0 0 0 0 6 7 9918 10038 9437 9998 9563 0 0 0 0 0 0 1 0 0 0 0 7 8 9252 9918 10038 9437 9998 0 0 0 0 0 0 0 1 0 0 0 8 9 9737 9252 9918 10038 9437 0 0 0 0 0 0 0 0 1 0 0 9 10 9035 9737 9252 9918 10038 0 0 0 0 0 0 0 0 0 1 0 10 11 9133 9035 9737 9252 9918 0 0 0 0 0 0 0 0 0 0 1 11 12 9487 9133 9035 9737 9252 0 0 0 0 0 0 0 0 0 0 0 12 13 8700 9487 9133 9035 9737 1 0 0 0 0 0 0 0 0 0 0 13 14 9627 8700 9487 9133 9035 0 1 0 0 0 0 0 0 0 0 0 14 15 8947 9627 8700 9487 9133 0 0 1 0 0 0 0 0 0 0 0 15 16 9283 8947 9627 8700 9487 0 0 0 1 0 0 0 0 0 0 0 16 17 8829 9283 8947 9627 8700 0 0 0 0 1 0 0 0 0 0 0 17 18 9947 8829 9283 8947 9627 0 0 0 0 0 1 0 0 0 0 0 18 19 9628 9947 8829 9283 8947 0 0 0 0 0 0 1 0 0 0 0 19 20 9318 9628 9947 8829 9283 0 0 0 0 0 0 0 1 0 0 0 20 21 9605 9318 9628 9947 8829 0 0 0 0 0 0 0 0 1 0 0 21 22 8640 9605 9318 9628 9947 0 0 0 0 0 0 0 0 0 1 0 22 23 9214 8640 9605 9318 9628 0 0 0 0 0 0 0 0 0 0 1 23 24 9567 9214 8640 9605 9318 0 0 0 0 0 0 0 0 0 0 0 24 25 8547 9567 9214 8640 9605 1 0 0 0 0 0 0 0 0 0 0 25 26 9185 8547 9567 9214 8640 0 1 0 0 0 0 0 0 0 0 0 26 27 9470 9185 8547 9567 9214 0 0 1 0 0 0 0 0 0 0 0 27 28 9123 9470 9185 8547 9567 0 0 0 1 0 0 0 0 0 0 0 28 29 9278 9123 9470 9185 8547 0 0 0 0 1 0 0 0 0 0 0 29 30 10170 9278 9123 9470 9185 0 0 0 0 0 1 0 0 0 0 0 30 31 9434 10170 9278 9123 9470 0 0 0 0 0 0 1 0 0 0 0 31 32 9655 9434 10170 9278 9123 0 0 0 0 0 0 0 1 0 0 0 32 33 9429 9655 9434 10170 9278 0 0 0 0 0 0 0 0 1 0 0 33 34 8739 9429 9655 9434 10170 0 0 0 0 0 0 0 0 0 1 0 34 35 9552 8739 9429 9655 9434 0 0 0 0 0 0 0 0 0 0 1 35 36 9687 9552 8739 9429 9655 0 0 0 0 0 0 0 0 0 0 0 36 37 9019 9687 9552 8739 9429 1 0 0 0 0 0 0 0 0 0 0 37 38 9672 9019 9687 9552 8739 0 1 0 0 0 0 0 0 0 0 0 38 39 9206 9672 9019 9687 9552 0 0 1 0 0 0 0 0 0 0 0 39 40 9069 9206 9672 9019 9687 0 0 0 1 0 0 0 0 0 0 0 40 41 9788 9069 9206 9672 9019 0 0 0 0 1 0 0 0 0 0 0 41 42 10312 9788 9069 9206 9672 0 0 0 0 0 1 0 0 0 0 0 42 43 10105 10312 9788 9069 9206 0 0 0 0 0 0 1 0 0 0 0 43 44 9863 10105 10312 9788 9069 0 0 0 0 0 0 0 1 0 0 0 44 45 9656 9863 10105 10312 9788 0 0 0 0 0 0 0 0 1 0 0 45 46 9295 9656 9863 10105 10312 0 0 0 0 0 0 0 0 0 1 0 46 47 9946 9295 9656 9863 10105 0 0 0 0 0 0 0 0 0 0 1 47 48 9701 9946 9295 9656 9863 0 0 0 0 0 0 0 0 0 0 0 48 49 9049 9701 9946 9295 9656 1 0 0 0 0 0 0 0 0 0 0 49 50 10190 9049 9701 9946 9295 0 1 0 0 0 0 0 0 0 0 0 50 51 9706 10190 9049 9701 9946 0 0 1 0 0 0 0 0 0 0 0 51 52 9765 9706 10190 9049 9701 0 0 0 1 0 0 0 0 0 0 0 52 53 9893 9765 9706 10190 9049 0 0 0 0 1 0 0 0 0 0 0 53 54 9994 9893 9765 9706 10190 0 0 0 0 0 1 0 0 0 0 0 54 55 10433 9994 9893 9765 9706 0 0 0 0 0 0 1 0 0 0 0 55 56 10073 10433 9994 9893 9765 0 0 0 0 0 0 0 1 0 0 0 56 57 10112 10073 10433 9994 9893 0 0 0 0 0 0 0 0 1 0 0 57 58 9266 10112 10073 10433 9994 0 0 0 0 0 0 0 0 0 1 0 58 59 9820 9266 10112 10073 10433 0 0 0 0 0 0 0 0 0 0 1 59 60 10097 9820 9266 10112 10073 0 0 0 0 0 0 0 0 0 0 0 60 61 9115 10097 9820 9266 10112 1 0 0 0 0 0 0 0 0 0 0 61 62 10411 9115 10097 9820 9266 0 1 0 0 0 0 0 0 0 0 0 62 63 9678 10411 9115 10097 9820 0 0 1 0 0 0 0 0 0 0 0 63 64 10408 9678 10411 9115 10097 0 0 0 1 0 0 0 0 0 0 0 64 65 10153 10408 9678 10411 9115 0 0 0 0 1 0 0 0 0 0 0 65 66 10368 10153 10408 9678 10411 0 0 0 0 0 1 0 0 0 0 0 66 67 10581 10368 10153 10408 9678 0 0 0 0 0 0 1 0 0 0 0 67 68 10597 10581 10368 10153 10408 0 0 0 0 0 0 0 1 0 0 0 68 69 10680 10597 10581 10368 10153 0 0 0 0 0 0 0 0 1 0 0 69 70 9738 10680 10597 10581 10368 0 0 0 0 0 0 0 0 0 1 0 70 71 9556 9738 10680 10597 10581 0 0 0 0 0 0 0 0 0 0 1 71 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) Y1 Y2 Y3 Y4 M1 3873.0530 0.1248 0.1649 0.2438 0.0617 -777.0071 M2 M3 M4 M5 M6 M7 184.9309 -260.9220 -1.6281 -194.0146 383.2153 170.9164 M8 M9 M10 M11 t -137.9781 -156.2182 -891.3542 -335.8468 5.5708 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -589.67 -125.36 30.63 145.79 611.40 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3873.0530 1593.6498 2.430 0.018439 * Y1 0.1248 0.1435 0.870 0.388305 Y2 0.1649 0.1364 1.209 0.231842 Y3 0.2438 0.1370 1.780 0.080728 . Y4 0.0617 0.1454 0.424 0.673079 M1 -777.0071 209.2133 -3.714 0.000485 *** M2 184.9309 235.6375 0.785 0.435994 M3 -260.9220 173.8839 -1.501 0.139296 M4 -1.6281 239.6472 -0.007 0.994605 M5 -194.0146 219.0306 -0.886 0.379660 M6 383.2153 190.3282 2.013 0.049063 * M7 170.9164 207.8565 0.822 0.414533 M8 -137.9781 234.7006 -0.588 0.559057 M9 -156.2182 214.4775 -0.728 0.469536 M10 -891.3542 190.6922 -4.674 2.01e-05 *** M11 -335.8468 219.2813 -1.532 0.131464 t 5.5708 2.5409 2.192 0.032678 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 271.2 on 54 degrees of freedom Multiple R-squared: 0.7811, Adjusted R-squared: 0.7162 F-statistic: 12.04 on 16 and 54 DF, p-value: 1.578e-12 > 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.8333408 0.3333185 0.16665924 [2,] 0.7267811 0.5464379 0.27321894 [3,] 0.6275789 0.7448423 0.37242113 [4,] 0.6541686 0.6916628 0.34583140 [5,] 0.6226066 0.7547868 0.37739338 [6,] 0.5452219 0.9095562 0.45477810 [7,] 0.5028409 0.9943183 0.49715913 [8,] 0.7292019 0.5415961 0.27079807 [9,] 0.6900551 0.6198897 0.30994486 [10,] 0.6321827 0.7356346 0.36781729 [11,] 0.8009910 0.3980181 0.19900904 [12,] 0.7845360 0.4309280 0.21546399 [13,] 0.7732045 0.4535909 0.22679545 [14,] 0.7070788 0.5858423 0.29292116 [15,] 0.7030583 0.5938834 0.29694172 [16,] 0.7014823 0.5970353 0.29851766 [17,] 0.6845584 0.6308831 0.31544156 [18,] 0.6780457 0.6439086 0.32195428 [19,] 0.5970055 0.8059890 0.40299450 [20,] 0.5180592 0.9638816 0.48194078 [21,] 0.7352855 0.5294290 0.26471451 [22,] 0.8182628 0.3634745 0.18173723 [23,] 0.8078586 0.3842828 0.19214141 [24,] 0.7940648 0.4118704 0.20593518 [25,] 0.7512177 0.4975647 0.24878233 [26,] 0.6903204 0.6193592 0.30967961 [27,] 0.6069083 0.7861834 0.39309172 [28,] 0.8392603 0.3214793 0.16073967 [29,] 0.7494196 0.5011608 0.25058039 [30,] 0.9240691 0.1518618 0.07593088 [31,] 0.8492059 0.3015882 0.15079411 [32,] 0.7518977 0.4962046 0.24810229 > postscript(file="/var/www/html/rcomp/tmp/1ff401290800775.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/2ff401290800775.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/3ff401290800775.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/48pll1290800775.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/58pll1290800775.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 = 71 Frequency = 1 1 2 3 4 5 6 -41.081269 208.521986 367.754904 611.396727 3.035196 -10.083550 7 8 9 10 11 12 -1.565477 -338.429657 150.261830 219.269341 -66.373787 -27.422962 13 14 15 16 17 18 37.880000 56.669361 -261.355964 -88.158142 -462.603065 182.454235 19 20 21 22 23 24 -34.486336 -95.731591 50.688152 -160.669706 20.655069 68.854422 25 26 27 28 29 30 -100.870090 -441.646805 250.699577 -275.053359 -29.518023 208.702640 31 32 33 34 35 36 -390.469923 62.277355 -284.311544 -128.577440 238.278689 85.601328 37 38 39 40 41 42 220.292264 -188.715315 -268.880843 -565.718585 316.055656 263.403981 43 44 45 46 47 48 141.315178 -24.753540 -326.850288 125.593563 366.482304 -176.284540 49 50 51 52 53 54 -32.823569 126.023597 66.935266 -92.575051 56.741548 -403.169657 55 56 57 58 59 60 224.322895 61.344033 53.049347 -122.151058 30.631862 49.251752 61 62 63 64 65 66 -83.397336 239.147176 -155.152940 410.108410 116.288687 -241.307649 67 68 69 70 71 60.883663 335.293401 357.162503 66.535300 -589.674138 > postscript(file="/var/www/html/rcomp/tmp/68pll1290800775.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 = 71 Frequency = 1 lag(myerror, k = 1) myerror 0 -41.081269 NA 1 208.521986 -41.081269 2 367.754904 208.521986 3 611.396727 367.754904 4 3.035196 611.396727 5 -10.083550 3.035196 6 -1.565477 -10.083550 7 -338.429657 -1.565477 8 150.261830 -338.429657 9 219.269341 150.261830 10 -66.373787 219.269341 11 -27.422962 -66.373787 12 37.880000 -27.422962 13 56.669361 37.880000 14 -261.355964 56.669361 15 -88.158142 -261.355964 16 -462.603065 -88.158142 17 182.454235 -462.603065 18 -34.486336 182.454235 19 -95.731591 -34.486336 20 50.688152 -95.731591 21 -160.669706 50.688152 22 20.655069 -160.669706 23 68.854422 20.655069 24 -100.870090 68.854422 25 -441.646805 -100.870090 26 250.699577 -441.646805 27 -275.053359 250.699577 28 -29.518023 -275.053359 29 208.702640 -29.518023 30 -390.469923 208.702640 31 62.277355 -390.469923 32 -284.311544 62.277355 33 -128.577440 -284.311544 34 238.278689 -128.577440 35 85.601328 238.278689 36 220.292264 85.601328 37 -188.715315 220.292264 38 -268.880843 -188.715315 39 -565.718585 -268.880843 40 316.055656 -565.718585 41 263.403981 316.055656 42 141.315178 263.403981 43 -24.753540 141.315178 44 -326.850288 -24.753540 45 125.593563 -326.850288 46 366.482304 125.593563 47 -176.284540 366.482304 48 -32.823569 -176.284540 49 126.023597 -32.823569 50 66.935266 126.023597 51 -92.575051 66.935266 52 56.741548 -92.575051 53 -403.169657 56.741548 54 224.322895 -403.169657 55 61.344033 224.322895 56 53.049347 61.344033 57 -122.151058 53.049347 58 30.631862 -122.151058 59 49.251752 30.631862 60 -83.397336 49.251752 61 239.147176 -83.397336 62 -155.152940 239.147176 63 410.108410 -155.152940 64 116.288687 410.108410 65 -241.307649 116.288687 66 60.883663 -241.307649 67 335.293401 60.883663 68 357.162503 335.293401 69 66.535300 357.162503 70 -589.674138 66.535300 71 NA -589.674138 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 208.521986 -41.081269 [2,] 367.754904 208.521986 [3,] 611.396727 367.754904 [4,] 3.035196 611.396727 [5,] -10.083550 3.035196 [6,] -1.565477 -10.083550 [7,] -338.429657 -1.565477 [8,] 150.261830 -338.429657 [9,] 219.269341 150.261830 [10,] -66.373787 219.269341 [11,] -27.422962 -66.373787 [12,] 37.880000 -27.422962 [13,] 56.669361 37.880000 [14,] -261.355964 56.669361 [15,] -88.158142 -261.355964 [16,] -462.603065 -88.158142 [17,] 182.454235 -462.603065 [18,] -34.486336 182.454235 [19,] -95.731591 -34.486336 [20,] 50.688152 -95.731591 [21,] -160.669706 50.688152 [22,] 20.655069 -160.669706 [23,] 68.854422 20.655069 [24,] -100.870090 68.854422 [25,] -441.646805 -100.870090 [26,] 250.699577 -441.646805 [27,] -275.053359 250.699577 [28,] -29.518023 -275.053359 [29,] 208.702640 -29.518023 [30,] -390.469923 208.702640 [31,] 62.277355 -390.469923 [32,] -284.311544 62.277355 [33,] -128.577440 -284.311544 [34,] 238.278689 -128.577440 [35,] 85.601328 238.278689 [36,] 220.292264 85.601328 [37,] -188.715315 220.292264 [38,] -268.880843 -188.715315 [39,] -565.718585 -268.880843 [40,] 316.055656 -565.718585 [41,] 263.403981 316.055656 [42,] 141.315178 263.403981 [43,] -24.753540 141.315178 [44,] -326.850288 -24.753540 [45,] 125.593563 -326.850288 [46,] 366.482304 125.593563 [47,] -176.284540 366.482304 [48,] -32.823569 -176.284540 [49,] 126.023597 -32.823569 [50,] 66.935266 126.023597 [51,] -92.575051 66.935266 [52,] 56.741548 -92.575051 [53,] -403.169657 56.741548 [54,] 224.322895 -403.169657 [55,] 61.344033 224.322895 [56,] 53.049347 61.344033 [57,] -122.151058 53.049347 [58,] 30.631862 -122.151058 [59,] 49.251752 30.631862 [60,] -83.397336 49.251752 [61,] 239.147176 -83.397336 [62,] -155.152940 239.147176 [63,] 410.108410 -155.152940 [64,] 116.288687 410.108410 [65,] -241.307649 116.288687 [66,] 60.883663 -241.307649 [67,] 335.293401 60.883663 [68,] 357.162503 335.293401 [69,] 66.535300 357.162503 [70,] -589.674138 66.535300 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 208.521986 -41.081269 2 367.754904 208.521986 3 611.396727 367.754904 4 3.035196 611.396727 5 -10.083550 3.035196 6 -1.565477 -10.083550 7 -338.429657 -1.565477 8 150.261830 -338.429657 9 219.269341 150.261830 10 -66.373787 219.269341 11 -27.422962 -66.373787 12 37.880000 -27.422962 13 56.669361 37.880000 14 -261.355964 56.669361 15 -88.158142 -261.355964 16 -462.603065 -88.158142 17 182.454235 -462.603065 18 -34.486336 182.454235 19 -95.731591 -34.486336 20 50.688152 -95.731591 21 -160.669706 50.688152 22 20.655069 -160.669706 23 68.854422 20.655069 24 -100.870090 68.854422 25 -441.646805 -100.870090 26 250.699577 -441.646805 27 -275.053359 250.699577 28 -29.518023 -275.053359 29 208.702640 -29.518023 30 -390.469923 208.702640 31 62.277355 -390.469923 32 -284.311544 62.277355 33 -128.577440 -284.311544 34 238.278689 -128.577440 35 85.601328 238.278689 36 220.292264 85.601328 37 -188.715315 220.292264 38 -268.880843 -188.715315 39 -565.718585 -268.880843 40 316.055656 -565.718585 41 263.403981 316.055656 42 141.315178 263.403981 43 -24.753540 141.315178 44 -326.850288 -24.753540 45 125.593563 -326.850288 46 366.482304 125.593563 47 -176.284540 366.482304 48 -32.823569 -176.284540 49 126.023597 -32.823569 50 66.935266 126.023597 51 -92.575051 66.935266 52 56.741548 -92.575051 53 -403.169657 56.741548 54 224.322895 -403.169657 55 61.344033 224.322895 56 53.049347 61.344033 57 -122.151058 53.049347 58 30.631862 -122.151058 59 49.251752 30.631862 60 -83.397336 49.251752 61 239.147176 -83.397336 62 -155.152940 239.147176 63 410.108410 -155.152940 64 116.288687 410.108410 65 -241.307649 116.288687 66 60.883663 -241.307649 67 335.293401 60.883663 68 357.162503 335.293401 69 66.535300 357.162503 70 -589.674138 66.535300 > 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/7iylo1290800775.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/8t72r1290800775.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/9t72r1290800775.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/10my1u1290800775.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/11pz001290800775.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/12iqhl1290800775.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/1379wf1290800775.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/14z0dz1290800775.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/153jun1290800775.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/16zbrw1290800775.tab") + } > > try(system("convert tmp/1ff401290800775.ps tmp/1ff401290800775.png",intern=TRUE)) character(0) > try(system("convert tmp/2ff401290800775.ps tmp/2ff401290800775.png",intern=TRUE)) character(0) > try(system("convert tmp/3ff401290800775.ps tmp/3ff401290800775.png",intern=TRUE)) character(0) > try(system("convert tmp/48pll1290800775.ps tmp/48pll1290800775.png",intern=TRUE)) character(0) > try(system("convert tmp/58pll1290800775.ps tmp/58pll1290800775.png",intern=TRUE)) character(0) > try(system("convert tmp/68pll1290800775.ps tmp/68pll1290800775.png",intern=TRUE)) character(0) > try(system("convert tmp/7iylo1290800775.ps tmp/7iylo1290800775.png",intern=TRUE)) character(0) > try(system("convert tmp/8t72r1290800775.ps tmp/8t72r1290800775.png",intern=TRUE)) character(0) > try(system("convert tmp/9t72r1290800775.ps tmp/9t72r1290800775.png",intern=TRUE)) character(0) > try(system("convert tmp/10my1u1290800775.ps tmp/10my1u1290800775.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.554 1.630 6.858