R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-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(37,30,47,35,30,43,82,40,47,19,52,136,80,42,54,66,81,63,137,72,107,58,36,52,79,77,54,84,48,96,83,66,61,53,30,74,69,59,42,65,70,100,63,105,82,81,75,102,121,98,76,77,63,37,35,23,40,29,37,51,20,28,13,22,25,13,16,13,16,17,9,17,25,14,8,7,10,7,10,3),dim=c(1,80),dimnames=list(c('casualties'),1:80)) > y <- array(NA,dim=c(1,80),dimnames=list(c('casualties'),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' > 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, 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 casualties M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 1 37 1 0 0 0 0 0 0 0 0 0 0 2 30 0 1 0 0 0 0 0 0 0 0 0 3 47 0 0 1 0 0 0 0 0 0 0 0 4 35 0 0 0 1 0 0 0 0 0 0 0 5 30 0 0 0 0 1 0 0 0 0 0 0 6 43 0 0 0 0 0 1 0 0 0 0 0 7 82 0 0 0 0 0 0 1 0 0 0 0 8 40 0 0 0 0 0 0 0 1 0 0 0 9 47 0 0 0 0 0 0 0 0 1 0 0 10 19 0 0 0 0 0 0 0 0 0 1 0 11 52 0 0 0 0 0 0 0 0 0 0 1 12 136 0 0 0 0 0 0 0 0 0 0 0 13 80 1 0 0 0 0 0 0 0 0 0 0 14 42 0 1 0 0 0 0 0 0 0 0 0 15 54 0 0 1 0 0 0 0 0 0 0 0 16 66 0 0 0 1 0 0 0 0 0 0 0 17 81 0 0 0 0 1 0 0 0 0 0 0 18 63 0 0 0 0 0 1 0 0 0 0 0 19 137 0 0 0 0 0 0 1 0 0 0 0 20 72 0 0 0 0 0 0 0 1 0 0 0 21 107 0 0 0 0 0 0 0 0 1 0 0 22 58 0 0 0 0 0 0 0 0 0 1 0 23 36 0 0 0 0 0 0 0 0 0 0 1 24 52 0 0 0 0 0 0 0 0 0 0 0 25 79 1 0 0 0 0 0 0 0 0 0 0 26 77 0 1 0 0 0 0 0 0 0 0 0 27 54 0 0 1 0 0 0 0 0 0 0 0 28 84 0 0 0 1 0 0 0 0 0 0 0 29 48 0 0 0 0 1 0 0 0 0 0 0 30 96 0 0 0 0 0 1 0 0 0 0 0 31 83 0 0 0 0 0 0 1 0 0 0 0 32 66 0 0 0 0 0 0 0 1 0 0 0 33 61 0 0 0 0 0 0 0 0 1 0 0 34 53 0 0 0 0 0 0 0 0 0 1 0 35 30 0 0 0 0 0 0 0 0 0 0 1 36 74 0 0 0 0 0 0 0 0 0 0 0 37 69 1 0 0 0 0 0 0 0 0 0 0 38 59 0 1 0 0 0 0 0 0 0 0 0 39 42 0 0 1 0 0 0 0 0 0 0 0 40 65 0 0 0 1 0 0 0 0 0 0 0 41 70 0 0 0 0 1 0 0 0 0 0 0 42 100 0 0 0 0 0 1 0 0 0 0 0 43 63 0 0 0 0 0 0 1 0 0 0 0 44 105 0 0 0 0 0 0 0 1 0 0 0 45 82 0 0 0 0 0 0 0 0 1 0 0 46 81 0 0 0 0 0 0 0 0 0 1 0 47 75 0 0 0 0 0 0 0 0 0 0 1 48 102 0 0 0 0 0 0 0 0 0 0 0 49 121 1 0 0 0 0 0 0 0 0 0 0 50 98 0 1 0 0 0 0 0 0 0 0 0 51 76 0 0 1 0 0 0 0 0 0 0 0 52 77 0 0 0 1 0 0 0 0 0 0 0 53 63 0 0 0 0 1 0 0 0 0 0 0 54 37 0 0 0 0 0 1 0 0 0 0 0 55 35 0 0 0 0 0 0 1 0 0 0 0 56 23 0 0 0 0 0 0 0 1 0 0 0 57 40 0 0 0 0 0 0 0 0 1 0 0 58 29 0 0 0 0 0 0 0 0 0 1 0 59 37 0 0 0 0 0 0 0 0 0 0 1 60 51 0 0 0 0 0 0 0 0 0 0 0 61 20 1 0 0 0 0 0 0 0 0 0 0 62 28 0 1 0 0 0 0 0 0 0 0 0 63 13 0 0 1 0 0 0 0 0 0 0 0 64 22 0 0 0 1 0 0 0 0 0 0 0 65 25 0 0 0 0 1 0 0 0 0 0 0 66 13 0 0 0 0 0 1 0 0 0 0 0 67 16 0 0 0 0 0 0 1 0 0 0 0 68 13 0 0 0 0 0 0 0 1 0 0 0 69 16 0 0 0 0 0 0 0 0 1 0 0 70 17 0 0 0 0 0 0 0 0 0 1 0 71 9 0 0 0 0 0 0 0 0 0 0 1 72 17 0 0 0 0 0 0 0 0 0 0 0 73 25 1 0 0 0 0 0 0 0 0 0 0 74 14 0 1 0 0 0 0 0 0 0 0 0 75 8 0 0 1 0 0 0 0 0 0 0 0 76 7 0 0 0 1 0 0 0 0 0 0 0 77 10 0 0 0 0 1 0 0 0 0 0 0 78 7 0 0 0 0 0 1 0 0 0 0 0 79 10 0 0 0 0 0 0 1 0 0 0 0 80 3 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) M1 M2 M3 M4 M5 72.00 -10.43 -22.29 -30.00 -21.14 -25.29 M6 M7 M8 M9 M10 M11 -20.71 -11.14 -26.00 -13.17 -29.17 -32.17 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -55.000 -24.018 0.643 21.393 76.143 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 72.00 13.47 5.345 1.14e-06 *** M1 -10.43 18.36 -0.568 0.5718 M2 -22.29 18.36 -1.214 0.2289 M3 -30.00 18.36 -1.634 0.1068 M4 -21.14 18.36 -1.152 0.2534 M5 -25.29 18.36 -1.377 0.1729 M6 -20.71 18.36 -1.128 0.2631 M7 -11.14 18.36 -0.607 0.5459 M8 -26.00 18.36 -1.416 0.1612 M9 -13.17 19.05 -0.691 0.4918 M10 -29.17 19.05 -1.531 0.1304 M11 -32.17 19.05 -1.689 0.0959 . --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 33 on 68 degrees of freedom Multiple R-squared: 0.08022, Adjusted R-squared: -0.06857 F-statistic: 0.5392 on 11 and 68 DF, p-value: 0.8697 > 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.158475562 0.3169511233 0.8415244384 [2,] 0.123993256 0.2479865115 0.8760067442 [3,] 0.187887423 0.3757748464 0.8121125768 [4,] 0.120393022 0.2407860442 0.8796069779 [5,] 0.219515918 0.4390318363 0.7804840818 [6,] 0.184623973 0.3692479468 0.8153760266 [7,] 0.275707867 0.5514157334 0.7242921333 [8,] 0.250432132 0.5008642630 0.7495678685 [9,] 0.183105851 0.3662117020 0.8168941490 [10,] 0.339723828 0.6794476558 0.6602761721 [11,] 0.278289347 0.5565786938 0.7217106531 [12,] 0.274465690 0.5489313798 0.7255343101 [13,] 0.208286392 0.4165727838 0.7917136081 [14,] 0.197896909 0.3957938172 0.8021030914 [15,] 0.144595597 0.2891911938 0.8554044031 [16,] 0.170231826 0.3404636512 0.8297681744 [17,] 0.163399393 0.3267987862 0.8366006069 [18,] 0.127304042 0.2546080841 0.8726959579 [19,] 0.095349182 0.1906983642 0.9046508179 [20,] 0.068746065 0.1374921300 0.9312539350 [21,] 0.048255663 0.0965113259 0.9517443371 [22,] 0.035270648 0.0705412970 0.9647293515 [23,] 0.022876726 0.0457534518 0.9771232741 [24,] 0.014674879 0.0293497580 0.9853251210 [25,] 0.009121178 0.0182423557 0.9908788222 [26,] 0.005912627 0.0118252532 0.9940873734 [27,] 0.004429385 0.0088587694 0.9955706153 [28,] 0.008795546 0.0175910929 0.9912044536 [29,] 0.010269542 0.0205390841 0.9897304579 [30,] 0.037224671 0.0744493424 0.9627753288 [31,] 0.037100425 0.0742008500 0.9628995750 [32,] 0.053031221 0.1060624418 0.9469687791 [33,] 0.067202204 0.1344044078 0.9327977961 [34,] 0.096783717 0.1935674347 0.9032162826 [35,] 0.406877946 0.8137558911 0.5931220545 [36,] 0.714201260 0.5715974797 0.2857987399 [37,] 0.888107396 0.2237852079 0.1118926039 [38,] 0.979427497 0.0411450061 0.0205725030 [39,] 0.995200177 0.0095996454 0.0047998227 [40,] 0.997141513 0.0057169744 0.0028584872 [41,] 0.998151540 0.0036969203 0.0018484601 [42,] 0.997801094 0.0043978119 0.0021989059 [43,] 0.997934999 0.0041300020 0.0020650010 [44,] 0.996077341 0.0078453173 0.0039226587 [45,] 0.997256499 0.0054870021 0.0027435011 [46,] 0.999689476 0.0006210488 0.0003105244 [47,] 0.999149479 0.0017010411 0.0008505206 [48,] 0.998573344 0.0028533125 0.0014266562 [49,] 0.995214088 0.0095718247 0.0047859124 [50,] 0.992750923 0.0144981542 0.0072490771 [51,] 0.990914548 0.0181709049 0.0090854525 > postscript(file="/var/wessaorg/rcomp/tmp/12ve41352473662.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/2afkw1352473662.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/3al8l1352473662.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/4kjvn1352473662.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/5jqc61352473662.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 -2.457143e+01 -1.971429e+01 5.000000e+00 -1.585714e+01 -1.671429e+01 6 7 8 9 10 -8.285714e+00 2.114286e+01 -6.000000e+00 -1.183333e+01 -2.383333e+01 11 12 13 14 15 1.216667e+01 6.400000e+01 1.842857e+01 -7.714286e+00 1.200000e+01 16 17 18 19 20 1.514286e+01 3.428571e+01 1.171429e+01 7.614286e+01 2.600000e+01 21 22 23 24 25 4.816667e+01 1.516667e+01 -3.833333e+00 -2.000000e+01 1.742857e+01 26 27 28 29 30 2.728571e+01 1.200000e+01 3.314286e+01 1.285714e+00 4.471429e+01 31 32 33 34 35 2.214286e+01 2.000000e+01 2.166667e+00 1.016667e+01 -9.833333e+00 36 37 38 39 40 2.000000e+00 7.428571e+00 9.285714e+00 5.149093e-15 1.414286e+01 41 42 43 44 45 2.328571e+01 4.871429e+01 2.142857e+00 5.900000e+01 2.316667e+01 46 47 48 49 50 3.816667e+01 3.516667e+01 3.000000e+01 5.942857e+01 4.828571e+01 51 52 53 54 55 3.400000e+01 2.614286e+01 1.628571e+01 -1.428571e+01 -2.585714e+01 56 57 58 59 60 -2.300000e+01 -1.883333e+01 -1.383333e+01 -2.833333e+00 -2.100000e+01 61 62 63 64 65 -4.157143e+01 -2.171429e+01 -2.900000e+01 -2.885714e+01 -2.171429e+01 66 67 68 69 70 -3.828571e+01 -4.485714e+01 -3.300000e+01 -4.283333e+01 -2.583333e+01 71 72 73 74 75 -3.083333e+01 -5.500000e+01 -3.657143e+01 -3.571429e+01 -3.400000e+01 76 77 78 79 80 -4.385714e+01 -3.671429e+01 -4.428571e+01 -5.085714e+01 -4.300000e+01 > postscript(file="/var/wessaorg/rcomp/tmp/6lxd91352473662.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 -2.457143e+01 NA 1 -1.971429e+01 -2.457143e+01 2 5.000000e+00 -1.971429e+01 3 -1.585714e+01 5.000000e+00 4 -1.671429e+01 -1.585714e+01 5 -8.285714e+00 -1.671429e+01 6 2.114286e+01 -8.285714e+00 7 -6.000000e+00 2.114286e+01 8 -1.183333e+01 -6.000000e+00 9 -2.383333e+01 -1.183333e+01 10 1.216667e+01 -2.383333e+01 11 6.400000e+01 1.216667e+01 12 1.842857e+01 6.400000e+01 13 -7.714286e+00 1.842857e+01 14 1.200000e+01 -7.714286e+00 15 1.514286e+01 1.200000e+01 16 3.428571e+01 1.514286e+01 17 1.171429e+01 3.428571e+01 18 7.614286e+01 1.171429e+01 19 2.600000e+01 7.614286e+01 20 4.816667e+01 2.600000e+01 21 1.516667e+01 4.816667e+01 22 -3.833333e+00 1.516667e+01 23 -2.000000e+01 -3.833333e+00 24 1.742857e+01 -2.000000e+01 25 2.728571e+01 1.742857e+01 26 1.200000e+01 2.728571e+01 27 3.314286e+01 1.200000e+01 28 1.285714e+00 3.314286e+01 29 4.471429e+01 1.285714e+00 30 2.214286e+01 4.471429e+01 31 2.000000e+01 2.214286e+01 32 2.166667e+00 2.000000e+01 33 1.016667e+01 2.166667e+00 34 -9.833333e+00 1.016667e+01 35 2.000000e+00 -9.833333e+00 36 7.428571e+00 2.000000e+00 37 9.285714e+00 7.428571e+00 38 5.149093e-15 9.285714e+00 39 1.414286e+01 5.149093e-15 40 2.328571e+01 1.414286e+01 41 4.871429e+01 2.328571e+01 42 2.142857e+00 4.871429e+01 43 5.900000e+01 2.142857e+00 44 2.316667e+01 5.900000e+01 45 3.816667e+01 2.316667e+01 46 3.516667e+01 3.816667e+01 47 3.000000e+01 3.516667e+01 48 5.942857e+01 3.000000e+01 49 4.828571e+01 5.942857e+01 50 3.400000e+01 4.828571e+01 51 2.614286e+01 3.400000e+01 52 1.628571e+01 2.614286e+01 53 -1.428571e+01 1.628571e+01 54 -2.585714e+01 -1.428571e+01 55 -2.300000e+01 -2.585714e+01 56 -1.883333e+01 -2.300000e+01 57 -1.383333e+01 -1.883333e+01 58 -2.833333e+00 -1.383333e+01 59 -2.100000e+01 -2.833333e+00 60 -4.157143e+01 -2.100000e+01 61 -2.171429e+01 -4.157143e+01 62 -2.900000e+01 -2.171429e+01 63 -2.885714e+01 -2.900000e+01 64 -2.171429e+01 -2.885714e+01 65 -3.828571e+01 -2.171429e+01 66 -4.485714e+01 -3.828571e+01 67 -3.300000e+01 -4.485714e+01 68 -4.283333e+01 -3.300000e+01 69 -2.583333e+01 -4.283333e+01 70 -3.083333e+01 -2.583333e+01 71 -5.500000e+01 -3.083333e+01 72 -3.657143e+01 -5.500000e+01 73 -3.571429e+01 -3.657143e+01 74 -3.400000e+01 -3.571429e+01 75 -4.385714e+01 -3.400000e+01 76 -3.671429e+01 -4.385714e+01 77 -4.428571e+01 -3.671429e+01 78 -5.085714e+01 -4.428571e+01 79 -4.300000e+01 -5.085714e+01 80 NA -4.300000e+01 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -1.971429e+01 -2.457143e+01 [2,] 5.000000e+00 -1.971429e+01 [3,] -1.585714e+01 5.000000e+00 [4,] -1.671429e+01 -1.585714e+01 [5,] -8.285714e+00 -1.671429e+01 [6,] 2.114286e+01 -8.285714e+00 [7,] -6.000000e+00 2.114286e+01 [8,] -1.183333e+01 -6.000000e+00 [9,] -2.383333e+01 -1.183333e+01 [10,] 1.216667e+01 -2.383333e+01 [11,] 6.400000e+01 1.216667e+01 [12,] 1.842857e+01 6.400000e+01 [13,] -7.714286e+00 1.842857e+01 [14,] 1.200000e+01 -7.714286e+00 [15,] 1.514286e+01 1.200000e+01 [16,] 3.428571e+01 1.514286e+01 [17,] 1.171429e+01 3.428571e+01 [18,] 7.614286e+01 1.171429e+01 [19,] 2.600000e+01 7.614286e+01 [20,] 4.816667e+01 2.600000e+01 [21,] 1.516667e+01 4.816667e+01 [22,] -3.833333e+00 1.516667e+01 [23,] -2.000000e+01 -3.833333e+00 [24,] 1.742857e+01 -2.000000e+01 [25,] 2.728571e+01 1.742857e+01 [26,] 1.200000e+01 2.728571e+01 [27,] 3.314286e+01 1.200000e+01 [28,] 1.285714e+00 3.314286e+01 [29,] 4.471429e+01 1.285714e+00 [30,] 2.214286e+01 4.471429e+01 [31,] 2.000000e+01 2.214286e+01 [32,] 2.166667e+00 2.000000e+01 [33,] 1.016667e+01 2.166667e+00 [34,] -9.833333e+00 1.016667e+01 [35,] 2.000000e+00 -9.833333e+00 [36,] 7.428571e+00 2.000000e+00 [37,] 9.285714e+00 7.428571e+00 [38,] 5.149093e-15 9.285714e+00 [39,] 1.414286e+01 5.149093e-15 [40,] 2.328571e+01 1.414286e+01 [41,] 4.871429e+01 2.328571e+01 [42,] 2.142857e+00 4.871429e+01 [43,] 5.900000e+01 2.142857e+00 [44,] 2.316667e+01 5.900000e+01 [45,] 3.816667e+01 2.316667e+01 [46,] 3.516667e+01 3.816667e+01 [47,] 3.000000e+01 3.516667e+01 [48,] 5.942857e+01 3.000000e+01 [49,] 4.828571e+01 5.942857e+01 [50,] 3.400000e+01 4.828571e+01 [51,] 2.614286e+01 3.400000e+01 [52,] 1.628571e+01 2.614286e+01 [53,] -1.428571e+01 1.628571e+01 [54,] -2.585714e+01 -1.428571e+01 [55,] -2.300000e+01 -2.585714e+01 [56,] -1.883333e+01 -2.300000e+01 [57,] -1.383333e+01 -1.883333e+01 [58,] -2.833333e+00 -1.383333e+01 [59,] -2.100000e+01 -2.833333e+00 [60,] -4.157143e+01 -2.100000e+01 [61,] -2.171429e+01 -4.157143e+01 [62,] -2.900000e+01 -2.171429e+01 [63,] -2.885714e+01 -2.900000e+01 [64,] -2.171429e+01 -2.885714e+01 [65,] -3.828571e+01 -2.171429e+01 [66,] -4.485714e+01 -3.828571e+01 [67,] -3.300000e+01 -4.485714e+01 [68,] -4.283333e+01 -3.300000e+01 [69,] -2.583333e+01 -4.283333e+01 [70,] -3.083333e+01 -2.583333e+01 [71,] -5.500000e+01 -3.083333e+01 [72,] -3.657143e+01 -5.500000e+01 [73,] -3.571429e+01 -3.657143e+01 [74,] -3.400000e+01 -3.571429e+01 [75,] -4.385714e+01 -3.400000e+01 [76,] -3.671429e+01 -4.385714e+01 [77,] -4.428571e+01 -3.671429e+01 [78,] -5.085714e+01 -4.428571e+01 [79,] -4.300000e+01 -5.085714e+01 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -1.971429e+01 -2.457143e+01 2 5.000000e+00 -1.971429e+01 3 -1.585714e+01 5.000000e+00 4 -1.671429e+01 -1.585714e+01 5 -8.285714e+00 -1.671429e+01 6 2.114286e+01 -8.285714e+00 7 -6.000000e+00 2.114286e+01 8 -1.183333e+01 -6.000000e+00 9 -2.383333e+01 -1.183333e+01 10 1.216667e+01 -2.383333e+01 11 6.400000e+01 1.216667e+01 12 1.842857e+01 6.400000e+01 13 -7.714286e+00 1.842857e+01 14 1.200000e+01 -7.714286e+00 15 1.514286e+01 1.200000e+01 16 3.428571e+01 1.514286e+01 17 1.171429e+01 3.428571e+01 18 7.614286e+01 1.171429e+01 19 2.600000e+01 7.614286e+01 20 4.816667e+01 2.600000e+01 21 1.516667e+01 4.816667e+01 22 -3.833333e+00 1.516667e+01 23 -2.000000e+01 -3.833333e+00 24 1.742857e+01 -2.000000e+01 25 2.728571e+01 1.742857e+01 26 1.200000e+01 2.728571e+01 27 3.314286e+01 1.200000e+01 28 1.285714e+00 3.314286e+01 29 4.471429e+01 1.285714e+00 30 2.214286e+01 4.471429e+01 31 2.000000e+01 2.214286e+01 32 2.166667e+00 2.000000e+01 33 1.016667e+01 2.166667e+00 34 -9.833333e+00 1.016667e+01 35 2.000000e+00 -9.833333e+00 36 7.428571e+00 2.000000e+00 37 9.285714e+00 7.428571e+00 38 5.149093e-15 9.285714e+00 39 1.414286e+01 5.149093e-15 40 2.328571e+01 1.414286e+01 41 4.871429e+01 2.328571e+01 42 2.142857e+00 4.871429e+01 43 5.900000e+01 2.142857e+00 44 2.316667e+01 5.900000e+01 45 3.816667e+01 2.316667e+01 46 3.516667e+01 3.816667e+01 47 3.000000e+01 3.516667e+01 48 5.942857e+01 3.000000e+01 49 4.828571e+01 5.942857e+01 50 3.400000e+01 4.828571e+01 51 2.614286e+01 3.400000e+01 52 1.628571e+01 2.614286e+01 53 -1.428571e+01 1.628571e+01 54 -2.585714e+01 -1.428571e+01 55 -2.300000e+01 -2.585714e+01 56 -1.883333e+01 -2.300000e+01 57 -1.383333e+01 -1.883333e+01 58 -2.833333e+00 -1.383333e+01 59 -2.100000e+01 -2.833333e+00 60 -4.157143e+01 -2.100000e+01 61 -2.171429e+01 -4.157143e+01 62 -2.900000e+01 -2.171429e+01 63 -2.885714e+01 -2.900000e+01 64 -2.171429e+01 -2.885714e+01 65 -3.828571e+01 -2.171429e+01 66 -4.485714e+01 -3.828571e+01 67 -3.300000e+01 -4.485714e+01 68 -4.283333e+01 -3.300000e+01 69 -2.583333e+01 -4.283333e+01 70 -3.083333e+01 -2.583333e+01 71 -5.500000e+01 -3.083333e+01 72 -3.657143e+01 -5.500000e+01 73 -3.571429e+01 -3.657143e+01 74 -3.400000e+01 -3.571429e+01 75 -4.385714e+01 -3.400000e+01 76 -3.671429e+01 -4.385714e+01 77 -4.428571e+01 -3.671429e+01 78 -5.085714e+01 -4.428571e+01 79 -4.300000e+01 -5.085714e+01 > 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/707p61352473662.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/8g2sg1352473662.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/93n6u1352473662.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/10nik11352473662.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/113bmr1352473662.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/12qxko1352473662.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/131zvw1352473662.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/14f7df1352473662.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/15akzh1352473662.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/16mnma1352473663.tab") + } > > try(system("convert tmp/12ve41352473662.ps tmp/12ve41352473662.png",intern=TRUE)) character(0) > try(system("convert tmp/2afkw1352473662.ps tmp/2afkw1352473662.png",intern=TRUE)) character(0) > try(system("convert tmp/3al8l1352473662.ps tmp/3al8l1352473662.png",intern=TRUE)) character(0) > try(system("convert tmp/4kjvn1352473662.ps tmp/4kjvn1352473662.png",intern=TRUE)) character(0) > try(system("convert tmp/5jqc61352473662.ps tmp/5jqc61352473662.png",intern=TRUE)) character(0) > try(system("convert tmp/6lxd91352473662.ps tmp/6lxd91352473662.png",intern=TRUE)) character(0) > try(system("convert tmp/707p61352473662.ps tmp/707p61352473662.png",intern=TRUE)) character(0) > try(system("convert tmp/8g2sg1352473662.ps tmp/8g2sg1352473662.png",intern=TRUE)) character(0) > try(system("convert tmp/93n6u1352473662.ps tmp/93n6u1352473662.png",intern=TRUE)) character(0) > try(system("convert tmp/10nik11352473662.ps tmp/10nik11352473662.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 7.868 1.475 9.498