R version 2.12.1 (2010-12-16) Copyright (C) 2010 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(0 + ,210907 + ,0 + ,2 + ,0 + ,179321 + ,4 + ,0 + ,149061 + ,0 + ,0 + ,0 + ,237213 + ,1 + ,0 + ,0 + ,173326 + ,-4 + ,0 + ,133131 + ,1 + ,4 + ,0 + ,258873 + ,4 + ,0 + ,324799 + ,1 + ,0 + ,0 + ,230964 + ,0 + ,-1 + ,0 + ,236785 + ,1 + ,0 + ,0 + ,344297 + ,1 + ,1 + ,0 + ,174724 + ,1 + ,0 + ,0 + ,174415 + ,1 + ,3 + ,0 + ,223632 + ,1 + ,-1 + ,0 + ,294424 + ,0 + ,4 + ,0 + ,325107 + ,1 + ,3 + ,0 + ,106408 + ,0 + ,1 + ,0 + ,96560 + ,0 + ,0 + ,0 + ,265769 + ,1 + ,-2 + ,0 + ,269651 + ,-3 + ,0 + ,149112 + ,0 + ,-4 + ,0 + ,152871 + ,0 + ,2 + ,0 + ,362301 + ,1 + ,2 + ,0 + ,183167 + ,0 + ,-4 + ,0 + ,277965 + ,3 + ,0 + ,218946 + ,1 + ,2 + ,0 + ,244052 + ,1 + ,2 + ,0 + ,341570 + ,1 + ,0 + ,0 + ,233328 + ,5 + ,0 + ,206161 + ,-2 + ,0 + ,311473 + ,0 + ,0 + ,207176 + ,-2 + ,0 + ,196553 + ,1 + ,-3 + ,0 + ,143246 + ,0 + ,2 + ,0 + ,182192 + ,2 + ,0 + ,194979 + ,2 + ,0 + ,167488 + ,0 + ,0 + ,143756 + ,0 + ,4 + ,0 + ,275541 + ,4 + ,0 + ,152299 + ,1 + ,2 + ,0 + ,193339 + ,1 + ,2 + ,0 + ,130585 + ,0 + ,-4 + ,0 + ,112611 + ,1 + ,3 + ,0 + ,148446 + ,1 + ,3 + ,0 + ,182079 + ,0 + ,2 + ,0 + ,243060 + ,1 + ,-1 + ,0 + ,162765 + ,1 + ,-3 + ,0 + ,85574 + ,1 + ,0 + ,0 + ,225060 + ,0 + ,1 + ,0 + ,133328 + ,1 + ,-3 + ,0 + ,100750 + ,1 + ,3 + ,0 + ,101523 + ,1 + ,0 + ,0 + ,243511 + ,1 + ,0 + ,0 + ,152474 + ,1 + ,0 + ,0 + ,132487 + ,1 + ,3 + ,0 + ,317394 + ,0 + ,-3 + ,0 + ,244749 + ,1 + ,0 + ,0 + ,184510 + ,-4 + ,0 + ,128423 + ,0 + ,2 + ,0 + ,97839 + ,0 + ,-1 + ,1 + ,172494 + ,3 + ,1 + ,229242 + ,1 + ,2 + ,1 + ,351619 + ,5 + ,1 + ,324598 + ,0 + ,2 + ,1 + ,195838 + ,0 + ,-2 + ,1 + ,254488 + ,0 + ,0 + ,1 + ,199476 + ,3 + ,1 + ,92499 + ,1 + ,-2 + ,1 + ,224330 + ,0 + ,0 + ,1 + ,181633 + ,1 + ,6 + ,1 + ,271856 + ,1 + ,-3 + ,1 + ,95227 + ,1 + ,3 + ,1 + ,98146 + ,0 + ,0 + ,1 + ,118612 + ,0 + ,-2 + ,1 + ,65475 + ,1 + ,1 + ,1 + ,108446 + ,0 + ,0 + ,1 + ,121848 + ,0 + ,2 + ,1 + ,76302 + ,1 + ,2 + ,1 + ,98104 + ,0 + ,-3 + ,1 + ,30989 + ,1 + ,-2 + ,1 + ,31774 + ,0 + ,1 + ,1 + ,150580 + ,1 + ,-4 + ,1 + ,54157 + ,0 + ,1 + ,59382 + ,0 + ,1 + ,1 + ,84105 + ,0 + ,0) + ,dim=c(4 + ,85) + ,dimnames=list(c('pop' + ,'time_in_rfc' + ,'gender' + ,'total_tests') + ,1:85)) > y <- array(NA,dim=c(4,85),dimnames=list(c('pop','time_in_rfc','gender','total_tests'),1:85)) > 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 = 'Do not include Seasonal Dummies' > par1 = '4' > 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 total_tests pop time_in_rfc gender 1 2 0 210907 0 2 0 0 179321 4 3 0 149061 0 0 4 0 237213 1 0 5 133131 173326 -4 0 6 258873 1 4 0 7 1 4 0 324799 8 0 0 0 230964 9 1 -1 0 236785 10 1 0 0 344297 11 1 1 0 174724 12 1 0 0 174415 13 1 3 0 223632 14 0 -1 0 294424 15 1 4 0 325107 16 0 3 0 106408 17 0 1 0 96560 18 1 0 0 265769 19 -3 -2 0 269651 20 -4 0 149112 0 21 2 0 152871 0 22 2 0 362301 1 23 -4 0 183167 0 24 0 0 277965 3 25 0 218946 1 2 26 0 244052 1 2 27 0 341570 1 0 28 206161 233328 5 0 29 0 -2 0 311473 30 0 0 207176 -2 31 0 196553 1 -3 32 0 143246 0 2 33 194979 182192 2 0 34 0 2 0 167488 35 4 0 143756 0 36 0 0 275541 4 37 0 152299 1 2 38 0 193339 1 2 39 0 130585 0 -4 40 0 112611 1 3 41 0 148446 1 3 42 0 182079 0 2 43 0 243060 1 -1 44 0 162765 1 -3 45 0 85574 1 0 46 0 225060 0 1 47 0 133328 1 -3 48 0 100750 1 3 49 0 101523 1 0 50 0 243511 1 0 51 0 152474 1 0 52 0 132487 1 3 53 0 317394 0 -3 54 0 244749 1 0 55 128423 184510 -4 0 56 97839 0 2 0 57 172494 0 -1 1 58 1 3 1 229242 59 5 2 1 351619 60 2 1 324598 0 61 -2 1 195838 0 62 0 1 254488 0 63 1 1 199476 3 64 1 92499 1 -2 65 1 224330 0 0 66 1 181633 1 6 67 1 271856 1 -3 68 1 95227 1 3 69 1 98146 0 0 70 1 118612 0 -2 71 1 65475 1 1 72 1 108446 0 0 73 1 121848 0 2 74 1 76302 1 2 75 1 98104 0 -3 76 1 30989 1 -2 77 1 31774 0 1 78 1 150580 1 -4 79 59382 54157 0 1 80 84105 0 1 1 81 210907 0 0 0 82 179321 0 2 0 83 0 4 0 149061 84 1 0 0 237213 85 -4 0 0 173326 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) pop time_in_rfc gender 62776.3486 -0.2311 -0.2601 -0.2430 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -55615 -28474 -11836 8900 197301 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 6.278e+04 1.320e+04 4.756 8.48e-06 *** pop -2.311e-01 8.271e-02 -2.794 0.006498 ** time_in_rfc -2.601e-01 8.235e-02 -3.159 0.002227 ** gender -2.430e-01 7.047e-02 -3.449 0.000896 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 53390 on 81 degrees of freedom Multiple R-squared: 0.1552, Adjusted R-squared: 0.1239 F-statistic: 4.961 on 3 and 81 DF, p-value: 0.003272 > 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.86668447 0.26663106 0.13331553 [2,] 0.85033286 0.29933427 0.14966714 [3,] 0.78930882 0.42138236 0.21069118 [4,] 0.75951751 0.48096499 0.24048249 [5,] 0.82449441 0.35101117 0.17550559 [6,] 0.83676433 0.32647133 0.16323567 [7,] 0.78075745 0.43848510 0.21924255 [8,] 0.71278623 0.57442753 0.28721377 [9,] 0.66032061 0.67935879 0.33967939 [10,] 0.76526000 0.46948001 0.23474000 [11,] 0.80576843 0.38846314 0.19423157 [12,] 0.74298175 0.51403649 0.25701825 [13,] 0.67265999 0.65468002 0.32734001 [14,] 0.61103288 0.77793424 0.38896712 [15,] 0.54176956 0.91646088 0.45823044 [16,] 0.57594654 0.84810693 0.42405346 [17,] 0.50920045 0.98159909 0.49079955 [18,] 0.43920687 0.87841373 0.56079313 [19,] 0.38321924 0.76643848 0.61678076 [20,] 0.31867381 0.63734762 0.68132619 [21,] 0.26131886 0.52263772 0.73868114 [22,] 0.88460287 0.23079426 0.11539713 [23,] 0.85135536 0.29728928 0.14864464 [24,] 0.81016562 0.37966877 0.18983438 [25,] 0.78693575 0.42612850 0.21306425 [26,] 0.77074372 0.45851256 0.22925628 [27,] 0.98518179 0.02963642 0.01481821 [28,] 0.97985970 0.04028061 0.02014030 [29,] 0.97384559 0.05230882 0.02615441 [30,] 0.96275376 0.07449248 0.03724624 [31,] 0.95691552 0.08616896 0.04308448 [32,] 0.94671241 0.10657518 0.05328759 [33,] 0.93826956 0.12346089 0.06173044 [34,] 0.92965503 0.14068995 0.07034497 [35,] 0.91454105 0.17091791 0.08545895 [36,] 0.89311863 0.21376273 0.10688137 [37,] 0.86596025 0.26807950 0.13403975 [38,] 0.83697017 0.32605966 0.16302983 [39,] 0.82105212 0.35789576 0.17894788 [40,] 0.78047815 0.43904369 0.21952185 [41,] 0.74479984 0.51040031 0.25520016 [42,] 0.71594733 0.56810534 0.28405267 [43,] 0.68503561 0.62992877 0.31496439 [44,] 0.62961035 0.74077930 0.37038965 [45,] 0.57723021 0.84553958 0.42276979 [46,] 0.52901173 0.94197654 0.47098827 [47,] 0.48987231 0.97974462 0.51012769 [48,] 0.43285977 0.86571954 0.56714023 [49,] 0.73767163 0.52465673 0.26232837 [50,] 0.69629949 0.60740101 0.30370051 [51,] 0.84381658 0.31236685 0.15618342 [52,] 0.79717155 0.40565690 0.20282845 [53,] 0.76910588 0.46178823 0.23089412 [54,] 0.72390766 0.55218467 0.27609234 [55,] 0.66043614 0.67912771 0.33956386 [56,] 0.59153335 0.81693329 0.40846665 [57,] 0.54547097 0.90905807 0.45452903 [58,] 0.50900822 0.98198357 0.49099178 [59,] 0.47868183 0.95736365 0.52131817 [60,] 0.40518213 0.81036426 0.59481787 [61,] 0.56549955 0.86900089 0.43450045 [62,] 0.49301114 0.98602228 0.50698886 [63,] 0.41398536 0.82797073 0.58601464 [64,] 0.33889171 0.67778341 0.66110829 [65,] 0.31115196 0.62230392 0.68884804 [66,] 0.23518099 0.47036197 0.76481901 [67,] 0.17547670 0.35095341 0.82452330 [68,] 0.13928967 0.27857933 0.86071033 [69,] 0.08852656 0.17705311 0.91147344 [70,] 0.16523856 0.33047712 0.83476144 [71,] 0.30820023 0.61640045 0.69179977 [72,] 0.22264901 0.44529803 0.77735099 > postscript(file="/var/www/rcomp/tmp/1o0q51323610799.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(x[,1], type='l', main='Actuals and Interpolation', ylab='value of Actuals and Interpolation (dots)', xlab='time or index') > points(x[,1]-mysum$resid) > grid() > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/2btm51323610799.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(mysum$resid, type='b', pch=19, main='Residuals', ylab='value of Residuals', xlab='time or index') > grid() > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/39zpj1323610799.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > hist(mysum$resid, main='Residual Histogram', xlab='values of Residuals') > grid() > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/4cmt31323610799.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > densityplot(~mysum$resid,col='black',main='Residual Density Plot', xlab='values of Residuals') > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/5iemz1323610799.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 = 85 Frequency = 1 1 2 3 4 5 6 -7912.01102 -16129.37017 -28332.59220 -7962.91276 110404.31847 196097.92300 7 8 9 10 11 12 16167.57515 -6640.83104 -5225.27519 20905.61590 -20308.66314 -20383.99629 13 14 15 16 17 18 -8421.17146 8782.81322 16242.43417 -36913.32119 -39307.32768 1819.48161 19 20 21 22 23 24 2758.53481 -23992.48057 -23008.66795 31469.70694 -15133.89880 9530.22939 25 26 27 28 29 30 -12183.41068 -6382.12833 16151.02103 197301.41477 12926.32073 -8885.02622 31 32 33 34 35 36 -17359.01115 -29675.78717 174302.55959 -22068.13302 -25377.71399 8899.92767 37 38 39 40 41 42 -27583.63630 -18100.45987 -32602.84236 -36754.16094 -28473.71193 -20702.58565 43 44 45 46 47 48 -6612.08045 -25166.45669 -43002.37159 -10771.14239 -31968.50992 -39494.90060 49 50 51 52 53 54 -39317.01144 -6507.62414 -27543.68487 -32161.38280 10563.64595 -6221.55756 55 56 57 58 59 60 108280.62269 35063.17168 109717.63435 -7057.40770 22689.94131 21662.17453 61 62 63 64 65 66 -11835.61459 3422.75953 -10885.54804 -41401.68721 -10939.06767 -20803.41124 67 68 69 70 71 72 42.36981 -40770.10877 -40096.60019 -35367.97594 -47645.43564 -37716.56322 73 74 75 76 77 78 -34619.25620 -45143.38091 -40107.03434 -55614.89827 -55433.03808 -27981.30658 79 80 81 82 83 84 9120.03643 21329.15460 148130.65143 116545.17168 -26546.33067 -5121.01924 85 -20653.67640 > postscript(file="/var/www/rcomp/tmp/6uex01323610799.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 = 85 Frequency = 1 lag(myerror, k = 1) myerror 0 -7912.01102 NA 1 -16129.37017 -7912.01102 2 -28332.59220 -16129.37017 3 -7962.91276 -28332.59220 4 110404.31847 -7962.91276 5 196097.92300 110404.31847 6 16167.57515 196097.92300 7 -6640.83104 16167.57515 8 -5225.27519 -6640.83104 9 20905.61590 -5225.27519 10 -20308.66314 20905.61590 11 -20383.99629 -20308.66314 12 -8421.17146 -20383.99629 13 8782.81322 -8421.17146 14 16242.43417 8782.81322 15 -36913.32119 16242.43417 16 -39307.32768 -36913.32119 17 1819.48161 -39307.32768 18 2758.53481 1819.48161 19 -23992.48057 2758.53481 20 -23008.66795 -23992.48057 21 31469.70694 -23008.66795 22 -15133.89880 31469.70694 23 9530.22939 -15133.89880 24 -12183.41068 9530.22939 25 -6382.12833 -12183.41068 26 16151.02103 -6382.12833 27 197301.41477 16151.02103 28 12926.32073 197301.41477 29 -8885.02622 12926.32073 30 -17359.01115 -8885.02622 31 -29675.78717 -17359.01115 32 174302.55959 -29675.78717 33 -22068.13302 174302.55959 34 -25377.71399 -22068.13302 35 8899.92767 -25377.71399 36 -27583.63630 8899.92767 37 -18100.45987 -27583.63630 38 -32602.84236 -18100.45987 39 -36754.16094 -32602.84236 40 -28473.71193 -36754.16094 41 -20702.58565 -28473.71193 42 -6612.08045 -20702.58565 43 -25166.45669 -6612.08045 44 -43002.37159 -25166.45669 45 -10771.14239 -43002.37159 46 -31968.50992 -10771.14239 47 -39494.90060 -31968.50992 48 -39317.01144 -39494.90060 49 -6507.62414 -39317.01144 50 -27543.68487 -6507.62414 51 -32161.38280 -27543.68487 52 10563.64595 -32161.38280 53 -6221.55756 10563.64595 54 108280.62269 -6221.55756 55 35063.17168 108280.62269 56 109717.63435 35063.17168 57 -7057.40770 109717.63435 58 22689.94131 -7057.40770 59 21662.17453 22689.94131 60 -11835.61459 21662.17453 61 3422.75953 -11835.61459 62 -10885.54804 3422.75953 63 -41401.68721 -10885.54804 64 -10939.06767 -41401.68721 65 -20803.41124 -10939.06767 66 42.36981 -20803.41124 67 -40770.10877 42.36981 68 -40096.60019 -40770.10877 69 -35367.97594 -40096.60019 70 -47645.43564 -35367.97594 71 -37716.56322 -47645.43564 72 -34619.25620 -37716.56322 73 -45143.38091 -34619.25620 74 -40107.03434 -45143.38091 75 -55614.89827 -40107.03434 76 -55433.03808 -55614.89827 77 -27981.30658 -55433.03808 78 9120.03643 -27981.30658 79 21329.15460 9120.03643 80 148130.65143 21329.15460 81 116545.17168 148130.65143 82 -26546.33067 116545.17168 83 -5121.01924 -26546.33067 84 -20653.67640 -5121.01924 85 NA -20653.67640 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -16129.37017 -7912.01102 [2,] -28332.59220 -16129.37017 [3,] -7962.91276 -28332.59220 [4,] 110404.31847 -7962.91276 [5,] 196097.92300 110404.31847 [6,] 16167.57515 196097.92300 [7,] -6640.83104 16167.57515 [8,] -5225.27519 -6640.83104 [9,] 20905.61590 -5225.27519 [10,] -20308.66314 20905.61590 [11,] -20383.99629 -20308.66314 [12,] -8421.17146 -20383.99629 [13,] 8782.81322 -8421.17146 [14,] 16242.43417 8782.81322 [15,] -36913.32119 16242.43417 [16,] -39307.32768 -36913.32119 [17,] 1819.48161 -39307.32768 [18,] 2758.53481 1819.48161 [19,] -23992.48057 2758.53481 [20,] -23008.66795 -23992.48057 [21,] 31469.70694 -23008.66795 [22,] -15133.89880 31469.70694 [23,] 9530.22939 -15133.89880 [24,] -12183.41068 9530.22939 [25,] -6382.12833 -12183.41068 [26,] 16151.02103 -6382.12833 [27,] 197301.41477 16151.02103 [28,] 12926.32073 197301.41477 [29,] -8885.02622 12926.32073 [30,] -17359.01115 -8885.02622 [31,] -29675.78717 -17359.01115 [32,] 174302.55959 -29675.78717 [33,] -22068.13302 174302.55959 [34,] -25377.71399 -22068.13302 [35,] 8899.92767 -25377.71399 [36,] -27583.63630 8899.92767 [37,] -18100.45987 -27583.63630 [38,] -32602.84236 -18100.45987 [39,] -36754.16094 -32602.84236 [40,] -28473.71193 -36754.16094 [41,] -20702.58565 -28473.71193 [42,] -6612.08045 -20702.58565 [43,] -25166.45669 -6612.08045 [44,] -43002.37159 -25166.45669 [45,] -10771.14239 -43002.37159 [46,] -31968.50992 -10771.14239 [47,] -39494.90060 -31968.50992 [48,] -39317.01144 -39494.90060 [49,] -6507.62414 -39317.01144 [50,] -27543.68487 -6507.62414 [51,] -32161.38280 -27543.68487 [52,] 10563.64595 -32161.38280 [53,] -6221.55756 10563.64595 [54,] 108280.62269 -6221.55756 [55,] 35063.17168 108280.62269 [56,] 109717.63435 35063.17168 [57,] -7057.40770 109717.63435 [58,] 22689.94131 -7057.40770 [59,] 21662.17453 22689.94131 [60,] -11835.61459 21662.17453 [61,] 3422.75953 -11835.61459 [62,] -10885.54804 3422.75953 [63,] -41401.68721 -10885.54804 [64,] -10939.06767 -41401.68721 [65,] -20803.41124 -10939.06767 [66,] 42.36981 -20803.41124 [67,] -40770.10877 42.36981 [68,] -40096.60019 -40770.10877 [69,] -35367.97594 -40096.60019 [70,] -47645.43564 -35367.97594 [71,] -37716.56322 -47645.43564 [72,] -34619.25620 -37716.56322 [73,] -45143.38091 -34619.25620 [74,] -40107.03434 -45143.38091 [75,] -55614.89827 -40107.03434 [76,] -55433.03808 -55614.89827 [77,] -27981.30658 -55433.03808 [78,] 9120.03643 -27981.30658 [79,] 21329.15460 9120.03643 [80,] 148130.65143 21329.15460 [81,] 116545.17168 148130.65143 [82,] -26546.33067 116545.17168 [83,] -5121.01924 -26546.33067 [84,] -20653.67640 -5121.01924 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -16129.37017 -7912.01102 2 -28332.59220 -16129.37017 3 -7962.91276 -28332.59220 4 110404.31847 -7962.91276 5 196097.92300 110404.31847 6 16167.57515 196097.92300 7 -6640.83104 16167.57515 8 -5225.27519 -6640.83104 9 20905.61590 -5225.27519 10 -20308.66314 20905.61590 11 -20383.99629 -20308.66314 12 -8421.17146 -20383.99629 13 8782.81322 -8421.17146 14 16242.43417 8782.81322 15 -36913.32119 16242.43417 16 -39307.32768 -36913.32119 17 1819.48161 -39307.32768 18 2758.53481 1819.48161 19 -23992.48057 2758.53481 20 -23008.66795 -23992.48057 21 31469.70694 -23008.66795 22 -15133.89880 31469.70694 23 9530.22939 -15133.89880 24 -12183.41068 9530.22939 25 -6382.12833 -12183.41068 26 16151.02103 -6382.12833 27 197301.41477 16151.02103 28 12926.32073 197301.41477 29 -8885.02622 12926.32073 30 -17359.01115 -8885.02622 31 -29675.78717 -17359.01115 32 174302.55959 -29675.78717 33 -22068.13302 174302.55959 34 -25377.71399 -22068.13302 35 8899.92767 -25377.71399 36 -27583.63630 8899.92767 37 -18100.45987 -27583.63630 38 -32602.84236 -18100.45987 39 -36754.16094 -32602.84236 40 -28473.71193 -36754.16094 41 -20702.58565 -28473.71193 42 -6612.08045 -20702.58565 43 -25166.45669 -6612.08045 44 -43002.37159 -25166.45669 45 -10771.14239 -43002.37159 46 -31968.50992 -10771.14239 47 -39494.90060 -31968.50992 48 -39317.01144 -39494.90060 49 -6507.62414 -39317.01144 50 -27543.68487 -6507.62414 51 -32161.38280 -27543.68487 52 10563.64595 -32161.38280 53 -6221.55756 10563.64595 54 108280.62269 -6221.55756 55 35063.17168 108280.62269 56 109717.63435 35063.17168 57 -7057.40770 109717.63435 58 22689.94131 -7057.40770 59 21662.17453 22689.94131 60 -11835.61459 21662.17453 61 3422.75953 -11835.61459 62 -10885.54804 3422.75953 63 -41401.68721 -10885.54804 64 -10939.06767 -41401.68721 65 -20803.41124 -10939.06767 66 42.36981 -20803.41124 67 -40770.10877 42.36981 68 -40096.60019 -40770.10877 69 -35367.97594 -40096.60019 70 -47645.43564 -35367.97594 71 -37716.56322 -47645.43564 72 -34619.25620 -37716.56322 73 -45143.38091 -34619.25620 74 -40107.03434 -45143.38091 75 -55614.89827 -40107.03434 76 -55433.03808 -55614.89827 77 -27981.30658 -55433.03808 78 9120.03643 -27981.30658 79 21329.15460 9120.03643 80 148130.65143 21329.15460 81 116545.17168 148130.65143 82 -26546.33067 116545.17168 83 -5121.01924 -26546.33067 84 -20653.67640 -5121.01924 > 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/rcomp/tmp/71ls21323610799.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > acf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Autocorrelation Function') > grid() > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/8o5qd1323610799.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > pacf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Partial Autocorrelation Function') > grid() > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/95gig1323610799.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0)) > plot(mylm, las = 1, sub='Residual Diagnostics') > par(opar) > dev.off() null device 1 > if (n > n25) { + postscript(file="/var/www/rcomp/tmp/10a4mj1323610799.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) + plot(kp3:nmkm3,gqarr[,2], main='Goldfeld-Quandt test',ylab='2-sided p-value',xlab='breakpoint') + grid() + dev.off() + } null device 1 > > #Note: the /var/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/114c3g1323610799.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/rcomp/tmp/12ywkg1323610799.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/rcomp/tmp/13a6g51323610799.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/rcomp/tmp/14kd5m1323610800.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/rcomp/tmp/15zyoo1323610800.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/rcomp/tmp/163e181323610800.tab") + } > > try(system("convert tmp/1o0q51323610799.ps tmp/1o0q51323610799.png",intern=TRUE)) character(0) > try(system("convert tmp/2btm51323610799.ps tmp/2btm51323610799.png",intern=TRUE)) character(0) > try(system("convert tmp/39zpj1323610799.ps tmp/39zpj1323610799.png",intern=TRUE)) character(0) > try(system("convert tmp/4cmt31323610799.ps tmp/4cmt31323610799.png",intern=TRUE)) character(0) > try(system("convert tmp/5iemz1323610799.ps tmp/5iemz1323610799.png",intern=TRUE)) character(0) > try(system("convert tmp/6uex01323610799.ps tmp/6uex01323610799.png",intern=TRUE)) character(0) > try(system("convert tmp/71ls21323610799.ps tmp/71ls21323610799.png",intern=TRUE)) character(0) > try(system("convert tmp/8o5qd1323610799.ps tmp/8o5qd1323610799.png",intern=TRUE)) character(0) > try(system("convert tmp/95gig1323610799.ps tmp/95gig1323610799.png",intern=TRUE)) character(0) > try(system("convert tmp/10a4mj1323610799.ps tmp/10a4mj1323610799.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 4.672 0.656 6.475