R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-pc-linux-gnu (32-bit) 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(9,676,8,642,9,402,9,610,9,294,9,448,10,319,9,548,9,801,9,596,8,923,9,746,9,829,9,125,9,782,9,441,9,162,9,915,10,444,10,209,9,985,9,842,9,429,10,132,9,849,9,172,10,313,9,819,9,955,10,048,10,082,10,541,10,208,10,233,9,439,9,963,10,158,9,225,10,474,9,757,10,490,10,281,10,444,10,640,10,695,10,786,9,832,9,747,10,411,9,511,10,402,9,701,10,540,10,112,10,915,11,183,10,384,10,834,9,886,10,216,10,943,9,867,10,203,10,837,10,573,10,647,11,502,10,656,10,866,10,835,9,945,10,331),dim=c(2,72),dimnames=list(c('Monthyly','births'),1:72)) > y <- array(NA,dim=c(2,72),dimnames=list(c('Monthyly','births'),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 = '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 > 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 Monthyly births M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 9 676 1 0 0 0 0 0 0 0 0 0 0 1 2 8 642 0 1 0 0 0 0 0 0 0 0 0 2 3 9 402 0 0 1 0 0 0 0 0 0 0 0 3 4 9 610 0 0 0 1 0 0 0 0 0 0 0 4 5 9 294 0 0 0 0 1 0 0 0 0 0 0 5 6 9 448 0 0 0 0 0 1 0 0 0 0 0 6 7 10 319 0 0 0 0 0 0 1 0 0 0 0 7 8 9 548 0 0 0 0 0 0 0 1 0 0 0 8 9 9 801 0 0 0 0 0 0 0 0 1 0 0 9 10 9 596 0 0 0 0 0 0 0 0 0 1 0 10 11 8 923 0 0 0 0 0 0 0 0 0 0 1 11 12 9 746 0 0 0 0 0 0 0 0 0 0 0 12 13 9 829 1 0 0 0 0 0 0 0 0 0 0 13 14 9 125 0 1 0 0 0 0 0 0 0 0 0 14 15 9 782 0 0 1 0 0 0 0 0 0 0 0 15 16 9 441 0 0 0 1 0 0 0 0 0 0 0 16 17 9 162 0 0 0 0 1 0 0 0 0 0 0 17 18 9 915 0 0 0 0 0 1 0 0 0 0 0 18 19 10 444 0 0 0 0 0 0 1 0 0 0 0 19 20 10 209 0 0 0 0 0 0 0 1 0 0 0 20 21 9 985 0 0 0 0 0 0 0 0 1 0 0 21 22 9 842 0 0 0 0 0 0 0 0 0 1 0 22 23 9 429 0 0 0 0 0 0 0 0 0 0 1 23 24 10 132 0 0 0 0 0 0 0 0 0 0 0 24 25 9 849 1 0 0 0 0 0 0 0 0 0 0 25 26 9 172 0 1 0 0 0 0 0 0 0 0 0 26 27 10 313 0 0 1 0 0 0 0 0 0 0 0 27 28 9 819 0 0 0 1 0 0 0 0 0 0 0 28 29 9 955 0 0 0 0 1 0 0 0 0 0 0 29 30 10 48 0 0 0 0 0 1 0 0 0 0 0 30 31 10 82 0 0 0 0 0 0 1 0 0 0 0 31 32 10 541 0 0 0 0 0 0 0 1 0 0 0 32 33 10 208 0 0 0 0 0 0 0 0 1 0 0 33 34 10 233 0 0 0 0 0 0 0 0 0 1 0 34 35 9 439 0 0 0 0 0 0 0 0 0 0 1 35 36 9 963 0 0 0 0 0 0 0 0 0 0 0 36 37 10 158 1 0 0 0 0 0 0 0 0 0 0 37 38 9 225 0 1 0 0 0 0 0 0 0 0 0 38 39 10 474 0 0 1 0 0 0 0 0 0 0 0 39 40 9 757 0 0 0 1 0 0 0 0 0 0 0 40 41 10 490 0 0 0 0 1 0 0 0 0 0 0 41 42 10 281 0 0 0 0 0 1 0 0 0 0 0 42 43 10 444 0 0 0 0 0 0 1 0 0 0 0 43 44 10 640 0 0 0 0 0 0 0 1 0 0 0 44 45 10 695 0 0 0 0 0 0 0 0 1 0 0 45 46 10 786 0 0 0 0 0 0 0 0 0 1 0 46 47 9 832 0 0 0 0 0 0 0 0 0 0 1 47 48 9 747 0 0 0 0 0 0 0 0 0 0 0 48 49 10 411 1 0 0 0 0 0 0 0 0 0 0 49 50 9 511 0 1 0 0 0 0 0 0 0 0 0 50 51 10 402 0 0 1 0 0 0 0 0 0 0 0 51 52 9 701 0 0 0 1 0 0 0 0 0 0 0 52 53 10 540 0 0 0 0 1 0 0 0 0 0 0 53 54 10 112 0 0 0 0 0 1 0 0 0 0 0 54 55 10 915 0 0 0 0 0 0 1 0 0 0 0 55 56 11 183 0 0 0 0 0 0 0 1 0 0 0 56 57 10 384 0 0 0 0 0 0 0 0 1 0 0 57 58 10 834 0 0 0 0 0 0 0 0 0 1 0 58 59 9 886 0 0 0 0 0 0 0 0 0 0 1 59 60 10 216 0 0 0 0 0 0 0 0 0 0 0 60 61 10 943 1 0 0 0 0 0 0 0 0 0 0 61 62 9 867 0 1 0 0 0 0 0 0 0 0 0 62 63 10 203 0 0 1 0 0 0 0 0 0 0 0 63 64 10 837 0 0 0 1 0 0 0 0 0 0 0 64 65 10 573 0 0 0 0 1 0 0 0 0 0 0 65 66 10 647 0 0 0 0 0 1 0 0 0 0 0 66 67 11 502 0 0 0 0 0 0 1 0 0 0 0 67 68 10 656 0 0 0 0 0 0 0 1 0 0 0 68 69 10 866 0 0 0 0 0 0 0 0 1 0 0 69 70 10 835 0 0 0 0 0 0 0 0 0 1 0 70 71 9 945 0 0 0 0 0 0 0 0 0 0 1 71 72 10 331 0 0 0 0 0 0 0 0 0 0 0 72 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) births M1 M2 M3 M4 9.22660 -0.00089 0.30184 -0.57881 0.24198 -0.03989 M5 M6 M7 M8 M9 M10 0.10513 0.17069 0.69094 0.51722 0.33868 0.34884 M11 t -0.45342 0.01758 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -0.48644 -0.14829 -0.00496 0.14446 0.46891 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 9.2266026 0.1304840 70.711 < 2e-16 *** births -0.0008900 0.0001199 -7.425 5.65e-10 *** M1 0.3018397 0.1450288 2.081 0.041837 * M2 -0.5788123 0.1443381 -4.010 0.000176 *** M3 0.2419826 0.1441670 1.678 0.098633 . M4 -0.0398859 0.1453526 -0.274 0.784746 M5 0.1051251 0.1436122 0.732 0.467112 M6 0.1706938 0.1440800 1.185 0.240962 M7 0.6909387 0.1436485 4.810 1.11e-05 *** M8 0.5172222 0.1435212 3.604 0.000652 *** M9 0.3386788 0.1442699 2.348 0.022332 * M10 0.3488365 0.1446890 2.411 0.019100 * M11 -0.4534230 0.1456954 -3.112 0.002882 ** t 0.0175820 0.0014347 12.254 < 2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.2481 on 58 degrees of freedom Multiple R-squared: 0.8626, Adjusted R-squared: 0.8318 F-statistic: 28.01 on 13 and 58 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.56813974 0.86372051 0.4318603 [2,] 0.46648563 0.93297126 0.5335144 [3,] 0.32981246 0.65962492 0.6701875 [4,] 0.42862292 0.85724584 0.5713771 [5,] 0.31192986 0.62385973 0.6880701 [6,] 0.23810316 0.47620633 0.7618968 [7,] 0.18730271 0.37460541 0.8126973 [8,] 0.17322041 0.34644081 0.8267796 [9,] 0.18197358 0.36394715 0.8180264 [10,] 0.12656370 0.25312739 0.8734363 [11,] 0.15616135 0.31232269 0.8438387 [12,] 0.10545012 0.21090023 0.8945499 [13,] 0.17456669 0.34913337 0.8254333 [14,] 0.12734312 0.25468624 0.8726569 [15,] 0.37041906 0.74083812 0.6295809 [16,] 0.33781219 0.67562438 0.6621878 [17,] 0.26131697 0.52263394 0.7386830 [18,] 0.20909955 0.41819911 0.7909004 [19,] 0.15604387 0.31208774 0.8439561 [20,] 0.15144112 0.30288225 0.8485589 [21,] 0.11157548 0.22315096 0.8884245 [22,] 0.08728706 0.17457413 0.9127129 [23,] 0.08972965 0.17945930 0.9102703 [24,] 0.08659696 0.17319391 0.9134030 [25,] 0.13645179 0.27290358 0.8635482 [26,] 0.10243116 0.20486232 0.8975688 [27,] 0.12509234 0.25018467 0.8749077 [28,] 0.08594537 0.17189075 0.9140546 [29,] 0.08395682 0.16791364 0.9160432 [30,] 0.09155460 0.18310921 0.9084454 [31,] 0.07472270 0.14944540 0.9252773 [32,] 0.10748299 0.21496597 0.8925170 [33,] 0.07803802 0.15607604 0.9219620 [34,] 0.04928441 0.09856881 0.9507156 [35,] 0.05037952 0.10075905 0.9496205 [36,] 0.28344917 0.56689833 0.7165508 [37,] 0.21159809 0.42319617 0.7884019 [38,] 0.31152124 0.62304248 0.6884788 [39,] 0.23446133 0.46892267 0.7655387 > postscript(file="/var/wessaorg/rcomp/tmp/1moww1322500135.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/wessaorg/rcomp/tmp/2237l1322500135.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/wessaorg/rcomp/tmp/3260i1322500135.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/wessaorg/rcomp/tmp/4gvo51322500135.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/wessaorg/rcomp/tmp/5xf7a1322500135.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 = 72 Frequency = 1 1 2 3 4 5 6 0.055646155 -0.111545433 -0.163533171 0.285882601 -0.157964661 -0.104048492 7 8 9 10 11 12 0.243308779 -0.396736434 -0.010593760 -0.220792737 -0.145070464 0.226386466 13 14 15 16 17 18 -0.019161508 0.217316710 -0.036300604 -0.075519573 -0.486435167 0.100617996 19 20 21 22 23 24 0.143579854 0.090553731 -0.057810026 -0.212826208 0.204262716 0.468914238 25 26 27 28 29 30 -0.212345164 0.048164271 0.335283703 0.049932905 0.008386012 0.117964366 31 32 33 34 35 36 -0.389601017 0.175064135 0.039640400 0.034151789 0.002178609 -0.002442870 37 38 39 40 41 42 -0.038350862 -0.115647899 0.267596401 -0.216234447 0.383530499 0.114360309 43 44 45 46 47 48 -0.278389261 0.052194039 0.262107790 0.315362153 0.140981762 -0.405677162 49 50 51 52 53 54 -0.024154019 -0.072079567 -0.007471402 -0.477061529 0.217048194 -0.247041865 55 56 57 58 59 60 -0.070162593 0.434458886 -0.225680784 0.147099758 -0.021940362 -0.089275649 61 62 63 64 65 66 0.238365399 0.033791918 -0.395574927 0.433000043 0.035435124 0.018147687 67 68 69 70 71 72 0.351264237 -0.355534356 -0.007663620 -0.062994755 -0.180412261 -0.197905024 > postscript(file="/var/wessaorg/rcomp/tmp/6wsay1322500135.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 = 72 Frequency = 1 lag(myerror, k = 1) myerror 0 0.055646155 NA 1 -0.111545433 0.055646155 2 -0.163533171 -0.111545433 3 0.285882601 -0.163533171 4 -0.157964661 0.285882601 5 -0.104048492 -0.157964661 6 0.243308779 -0.104048492 7 -0.396736434 0.243308779 8 -0.010593760 -0.396736434 9 -0.220792737 -0.010593760 10 -0.145070464 -0.220792737 11 0.226386466 -0.145070464 12 -0.019161508 0.226386466 13 0.217316710 -0.019161508 14 -0.036300604 0.217316710 15 -0.075519573 -0.036300604 16 -0.486435167 -0.075519573 17 0.100617996 -0.486435167 18 0.143579854 0.100617996 19 0.090553731 0.143579854 20 -0.057810026 0.090553731 21 -0.212826208 -0.057810026 22 0.204262716 -0.212826208 23 0.468914238 0.204262716 24 -0.212345164 0.468914238 25 0.048164271 -0.212345164 26 0.335283703 0.048164271 27 0.049932905 0.335283703 28 0.008386012 0.049932905 29 0.117964366 0.008386012 30 -0.389601017 0.117964366 31 0.175064135 -0.389601017 32 0.039640400 0.175064135 33 0.034151789 0.039640400 34 0.002178609 0.034151789 35 -0.002442870 0.002178609 36 -0.038350862 -0.002442870 37 -0.115647899 -0.038350862 38 0.267596401 -0.115647899 39 -0.216234447 0.267596401 40 0.383530499 -0.216234447 41 0.114360309 0.383530499 42 -0.278389261 0.114360309 43 0.052194039 -0.278389261 44 0.262107790 0.052194039 45 0.315362153 0.262107790 46 0.140981762 0.315362153 47 -0.405677162 0.140981762 48 -0.024154019 -0.405677162 49 -0.072079567 -0.024154019 50 -0.007471402 -0.072079567 51 -0.477061529 -0.007471402 52 0.217048194 -0.477061529 53 -0.247041865 0.217048194 54 -0.070162593 -0.247041865 55 0.434458886 -0.070162593 56 -0.225680784 0.434458886 57 0.147099758 -0.225680784 58 -0.021940362 0.147099758 59 -0.089275649 -0.021940362 60 0.238365399 -0.089275649 61 0.033791918 0.238365399 62 -0.395574927 0.033791918 63 0.433000043 -0.395574927 64 0.035435124 0.433000043 65 0.018147687 0.035435124 66 0.351264237 0.018147687 67 -0.355534356 0.351264237 68 -0.007663620 -0.355534356 69 -0.062994755 -0.007663620 70 -0.180412261 -0.062994755 71 -0.197905024 -0.180412261 72 NA -0.197905024 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -0.111545433 0.055646155 [2,] -0.163533171 -0.111545433 [3,] 0.285882601 -0.163533171 [4,] -0.157964661 0.285882601 [5,] -0.104048492 -0.157964661 [6,] 0.243308779 -0.104048492 [7,] -0.396736434 0.243308779 [8,] -0.010593760 -0.396736434 [9,] -0.220792737 -0.010593760 [10,] -0.145070464 -0.220792737 [11,] 0.226386466 -0.145070464 [12,] -0.019161508 0.226386466 [13,] 0.217316710 -0.019161508 [14,] -0.036300604 0.217316710 [15,] -0.075519573 -0.036300604 [16,] -0.486435167 -0.075519573 [17,] 0.100617996 -0.486435167 [18,] 0.143579854 0.100617996 [19,] 0.090553731 0.143579854 [20,] -0.057810026 0.090553731 [21,] -0.212826208 -0.057810026 [22,] 0.204262716 -0.212826208 [23,] 0.468914238 0.204262716 [24,] -0.212345164 0.468914238 [25,] 0.048164271 -0.212345164 [26,] 0.335283703 0.048164271 [27,] 0.049932905 0.335283703 [28,] 0.008386012 0.049932905 [29,] 0.117964366 0.008386012 [30,] -0.389601017 0.117964366 [31,] 0.175064135 -0.389601017 [32,] 0.039640400 0.175064135 [33,] 0.034151789 0.039640400 [34,] 0.002178609 0.034151789 [35,] -0.002442870 0.002178609 [36,] -0.038350862 -0.002442870 [37,] -0.115647899 -0.038350862 [38,] 0.267596401 -0.115647899 [39,] -0.216234447 0.267596401 [40,] 0.383530499 -0.216234447 [41,] 0.114360309 0.383530499 [42,] -0.278389261 0.114360309 [43,] 0.052194039 -0.278389261 [44,] 0.262107790 0.052194039 [45,] 0.315362153 0.262107790 [46,] 0.140981762 0.315362153 [47,] -0.405677162 0.140981762 [48,] -0.024154019 -0.405677162 [49,] -0.072079567 -0.024154019 [50,] -0.007471402 -0.072079567 [51,] -0.477061529 -0.007471402 [52,] 0.217048194 -0.477061529 [53,] -0.247041865 0.217048194 [54,] -0.070162593 -0.247041865 [55,] 0.434458886 -0.070162593 [56,] -0.225680784 0.434458886 [57,] 0.147099758 -0.225680784 [58,] -0.021940362 0.147099758 [59,] -0.089275649 -0.021940362 [60,] 0.238365399 -0.089275649 [61,] 0.033791918 0.238365399 [62,] -0.395574927 0.033791918 [63,] 0.433000043 -0.395574927 [64,] 0.035435124 0.433000043 [65,] 0.018147687 0.035435124 [66,] 0.351264237 0.018147687 [67,] -0.355534356 0.351264237 [68,] -0.007663620 -0.355534356 [69,] -0.062994755 -0.007663620 [70,] -0.180412261 -0.062994755 [71,] -0.197905024 -0.180412261 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -0.111545433 0.055646155 2 -0.163533171 -0.111545433 3 0.285882601 -0.163533171 4 -0.157964661 0.285882601 5 -0.104048492 -0.157964661 6 0.243308779 -0.104048492 7 -0.396736434 0.243308779 8 -0.010593760 -0.396736434 9 -0.220792737 -0.010593760 10 -0.145070464 -0.220792737 11 0.226386466 -0.145070464 12 -0.019161508 0.226386466 13 0.217316710 -0.019161508 14 -0.036300604 0.217316710 15 -0.075519573 -0.036300604 16 -0.486435167 -0.075519573 17 0.100617996 -0.486435167 18 0.143579854 0.100617996 19 0.090553731 0.143579854 20 -0.057810026 0.090553731 21 -0.212826208 -0.057810026 22 0.204262716 -0.212826208 23 0.468914238 0.204262716 24 -0.212345164 0.468914238 25 0.048164271 -0.212345164 26 0.335283703 0.048164271 27 0.049932905 0.335283703 28 0.008386012 0.049932905 29 0.117964366 0.008386012 30 -0.389601017 0.117964366 31 0.175064135 -0.389601017 32 0.039640400 0.175064135 33 0.034151789 0.039640400 34 0.002178609 0.034151789 35 -0.002442870 0.002178609 36 -0.038350862 -0.002442870 37 -0.115647899 -0.038350862 38 0.267596401 -0.115647899 39 -0.216234447 0.267596401 40 0.383530499 -0.216234447 41 0.114360309 0.383530499 42 -0.278389261 0.114360309 43 0.052194039 -0.278389261 44 0.262107790 0.052194039 45 0.315362153 0.262107790 46 0.140981762 0.315362153 47 -0.405677162 0.140981762 48 -0.024154019 -0.405677162 49 -0.072079567 -0.024154019 50 -0.007471402 -0.072079567 51 -0.477061529 -0.007471402 52 0.217048194 -0.477061529 53 -0.247041865 0.217048194 54 -0.070162593 -0.247041865 55 0.434458886 -0.070162593 56 -0.225680784 0.434458886 57 0.147099758 -0.225680784 58 -0.021940362 0.147099758 59 -0.089275649 -0.021940362 60 0.238365399 -0.089275649 61 0.033791918 0.238365399 62 -0.395574927 0.033791918 63 0.433000043 -0.395574927 64 0.035435124 0.433000043 65 0.018147687 0.035435124 66 0.351264237 0.018147687 67 -0.355534356 0.351264237 68 -0.007663620 -0.355534356 69 -0.062994755 -0.007663620 70 -0.180412261 -0.062994755 71 -0.197905024 -0.180412261 > 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/wessaorg/rcomp/tmp/75jkm1322500135.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/wessaorg/rcomp/tmp/8am9x1322500135.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/wessaorg/rcomp/tmp/9a5uc1322500135.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/wessaorg/rcomp/tmp/1091yb1322500135.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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/117zuo1322500136.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/wessaorg/rcomp/tmp/12uitr1322500136.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/wessaorg/rcomp/tmp/13x02u1322500136.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/wessaorg/rcomp/tmp/14tdsy1322500136.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/wessaorg/rcomp/tmp/15wdk71322500136.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/wessaorg/rcomp/tmp/16zu591322500136.tab") + } > > try(system("convert tmp/1moww1322500135.ps tmp/1moww1322500135.png",intern=TRUE)) character(0) > try(system("convert tmp/2237l1322500135.ps tmp/2237l1322500135.png",intern=TRUE)) character(0) > try(system("convert tmp/3260i1322500135.ps tmp/3260i1322500135.png",intern=TRUE)) character(0) > try(system("convert tmp/4gvo51322500135.ps tmp/4gvo51322500135.png",intern=TRUE)) character(0) > try(system("convert tmp/5xf7a1322500135.ps tmp/5xf7a1322500135.png",intern=TRUE)) character(0) > try(system("convert tmp/6wsay1322500135.ps tmp/6wsay1322500135.png",intern=TRUE)) character(0) > try(system("convert tmp/75jkm1322500135.ps tmp/75jkm1322500135.png",intern=TRUE)) character(0) > try(system("convert tmp/8am9x1322500135.ps tmp/8am9x1322500135.png",intern=TRUE)) character(0) > try(system("convert tmp/9a5uc1322500135.ps tmp/9a5uc1322500135.png",intern=TRUE)) character(0) > try(system("convert tmp/1091yb1322500135.ps tmp/1091yb1322500135.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.285 0.491 3.800