R version 2.7.0 (2008-04-22) Copyright (C) 2008 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(82.7,0,88.9,0,105.9,0,100.8,0,94,0,105,0,58.5,0,87.6,0,113.1,0,112.5,0,89.6,0,74.5,0,82.7,0,90.1,0,109.4,0,96,0,89.2,0,109.1,0,49.1,0,92.9,0,107.7,0,103.5,0,91.1,0,79.8,0,71.9,0,82.9,0,90.1,0,100.7,0,90.7,0,108.8,0,44.1,0,93.6,0,107.4,0,96.5,0,93.6,0,76.5,0,76.7,0,84,0,103.3,0,88.5,1,99,1,105.9,1,44.7,1,94,1,107.1,1,104.8,1,102.5,1,77.7,1,85.2,1,91.3,1,106.5,1,92.4,1,97.5,1,107,1,51.1,1,98.6,1,102.2,1,114.3,1,99.4,1,72.5,1),dim=c(2,60),dimnames=list(c('Y','X'),1:60)) > y <- array(NA,dim=c(2,60),dimnames=list(c('Y','X'),1:60)) > 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 Y X M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 82.7 0 1 0 0 0 0 0 0 0 0 0 0 1 2 88.9 0 0 1 0 0 0 0 0 0 0 0 0 2 3 105.9 0 0 0 1 0 0 0 0 0 0 0 0 3 4 100.8 0 0 0 0 1 0 0 0 0 0 0 0 4 5 94.0 0 0 0 0 0 1 0 0 0 0 0 0 5 6 105.0 0 0 0 0 0 0 1 0 0 0 0 0 6 7 58.5 0 0 0 0 0 0 0 1 0 0 0 0 7 8 87.6 0 0 0 0 0 0 0 0 1 0 0 0 8 9 113.1 0 0 0 0 0 0 0 0 0 1 0 0 9 10 112.5 0 0 0 0 0 0 0 0 0 0 1 0 10 11 89.6 0 0 0 0 0 0 0 0 0 0 0 1 11 12 74.5 0 0 0 0 0 0 0 0 0 0 0 0 12 13 82.7 0 1 0 0 0 0 0 0 0 0 0 0 13 14 90.1 0 0 1 0 0 0 0 0 0 0 0 0 14 15 109.4 0 0 0 1 0 0 0 0 0 0 0 0 15 16 96.0 0 0 0 0 1 0 0 0 0 0 0 0 16 17 89.2 0 0 0 0 0 1 0 0 0 0 0 0 17 18 109.1 0 0 0 0 0 0 1 0 0 0 0 0 18 19 49.1 0 0 0 0 0 0 0 1 0 0 0 0 19 20 92.9 0 0 0 0 0 0 0 0 1 0 0 0 20 21 107.7 0 0 0 0 0 0 0 0 0 1 0 0 21 22 103.5 0 0 0 0 0 0 0 0 0 0 1 0 22 23 91.1 0 0 0 0 0 0 0 0 0 0 0 1 23 24 79.8 0 0 0 0 0 0 0 0 0 0 0 0 24 25 71.9 0 1 0 0 0 0 0 0 0 0 0 0 25 26 82.9 0 0 1 0 0 0 0 0 0 0 0 0 26 27 90.1 0 0 0 1 0 0 0 0 0 0 0 0 27 28 100.7 0 0 0 0 1 0 0 0 0 0 0 0 28 29 90.7 0 0 0 0 0 1 0 0 0 0 0 0 29 30 108.8 0 0 0 0 0 0 1 0 0 0 0 0 30 31 44.1 0 0 0 0 0 0 0 1 0 0 0 0 31 32 93.6 0 0 0 0 0 0 0 0 1 0 0 0 32 33 107.4 0 0 0 0 0 0 0 0 0 1 0 0 33 34 96.5 0 0 0 0 0 0 0 0 0 0 1 0 34 35 93.6 0 0 0 0 0 0 0 0 0 0 0 1 35 36 76.5 0 0 0 0 0 0 0 0 0 0 0 0 36 37 76.7 0 1 0 0 0 0 0 0 0 0 0 0 37 38 84.0 0 0 1 0 0 0 0 0 0 0 0 0 38 39 103.3 0 0 0 1 0 0 0 0 0 0 0 0 39 40 88.5 1 0 0 0 1 0 0 0 0 0 0 0 40 41 99.0 1 0 0 0 0 1 0 0 0 0 0 0 41 42 105.9 1 0 0 0 0 0 1 0 0 0 0 0 42 43 44.7 1 0 0 0 0 0 0 1 0 0 0 0 43 44 94.0 1 0 0 0 0 0 0 0 1 0 0 0 44 45 107.1 1 0 0 0 0 0 0 0 0 1 0 0 45 46 104.8 1 0 0 0 0 0 0 0 0 0 1 0 46 47 102.5 1 0 0 0 0 0 0 0 0 0 0 1 47 48 77.7 1 0 0 0 0 0 0 0 0 0 0 0 48 49 85.2 1 1 0 0 0 0 0 0 0 0 0 0 49 50 91.3 1 0 1 0 0 0 0 0 0 0 0 0 50 51 106.5 1 0 0 1 0 0 0 0 0 0 0 0 51 52 92.4 1 0 0 0 1 0 0 0 0 0 0 0 52 53 97.5 1 0 0 0 0 1 0 0 0 0 0 0 53 54 107.0 1 0 0 0 0 0 1 0 0 0 0 0 54 55 51.1 1 0 0 0 0 0 0 1 0 0 0 0 55 56 98.6 1 0 0 0 0 0 0 0 1 0 0 0 56 57 102.2 1 0 0 0 0 0 0 0 0 1 0 0 57 58 114.3 1 0 0 0 0 0 0 0 0 0 1 0 58 59 99.4 1 0 0 0 0 0 0 0 0 0 0 1 59 60 72.5 1 0 0 0 0 0 0 0 0 0 0 0 60 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X M1 M2 M3 M4 78.5888 5.4679 3.3354 11.0625 26.7896 18.4631 M5 M6 M7 M8 M9 M10 16.9902 30.1973 -27.3356 16.6316 30.9187 29.8658 M11 t 18.9129 -0.1271 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -11.8464 -3.0708 0.4045 2.9503 8.1365 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 78.58885 2.75595 28.516 < 2e-16 *** X 5.46788 2.40330 2.275 0.027603 * M1 3.33535 3.11652 1.070 0.290105 M2 11.06246 3.11014 3.557 0.000883 *** M3 26.78958 3.10517 8.627 3.58e-11 *** M4 18.46311 3.13250 5.894 4.17e-07 *** M5 16.99022 3.12192 5.442 1.97e-06 *** M6 30.19733 3.11272 9.701 1.06e-12 *** M7 -27.33556 3.10491 -8.804 1.99e-11 *** M8 16.63156 3.09851 5.368 2.54e-06 *** M9 30.91867 3.09353 9.995 4.14e-13 *** M10 29.86578 3.08996 9.665 1.19e-12 *** M11 18.91289 3.08781 6.125 1.88e-07 *** t -0.12711 0.06642 -1.914 0.061901 . --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 4.881 on 46 degrees of freedom Multiple R-squared: 0.9334, Adjusted R-squared: 0.9145 F-statistic: 49.56 on 13 and 46 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.2493767 0.4987533 0.7506233 [2,] 0.2052712 0.4105425 0.7947288 [3,] 0.3393458 0.6786917 0.6606542 [4,] 0.3220256 0.6440512 0.6779744 [5,] 0.2754250 0.5508500 0.7245750 [6,] 0.2925526 0.5851051 0.7074474 [7,] 0.2227498 0.4454995 0.7772502 [8,] 0.2610655 0.5221310 0.7389345 [9,] 0.3413008 0.6826016 0.6586992 [10,] 0.2654689 0.5309379 0.7345311 [11,] 0.6181670 0.7636660 0.3818330 [12,] 0.8434451 0.3131097 0.1565549 [13,] 0.8056031 0.3887938 0.1943969 [14,] 0.8271272 0.3457455 0.1728728 [15,] 0.7853978 0.4292044 0.2146022 [16,] 0.7635646 0.4728708 0.2364354 [17,] 0.8122946 0.3754108 0.1877054 [18,] 0.8718974 0.2562053 0.1281026 [19,] 0.8496822 0.3006356 0.1503178 [20,] 0.8778994 0.2442013 0.1221006 [21,] 0.8231091 0.3537819 0.1768909 [22,] 0.7524639 0.4950722 0.2475361 [23,] 0.6659660 0.6680679 0.3340340 [24,] 0.5602251 0.8795497 0.4397749 [25,] 0.5513077 0.8973845 0.4486923 [26,] 0.3980465 0.7960929 0.6019535 [27,] 0.3251483 0.6502967 0.6748517 > postscript(file="/var/www/html/rcomp/tmp/1npai1227721969.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/2ik671227721969.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/3ga0d1227721969.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/430d41227721969.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/50zsz1227721969.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 = 60 Frequency = 1 1 2 3 4 5 6 0.9029091 -0.4970909 0.9029091 4.2564848 -0.9435152 -3.0235152 7 8 9 10 11 12 8.1364848 -6.6035152 4.7364848 5.3164848 -6.5035152 -2.5635152 13 14 15 16 17 18 2.4282424 2.2282424 5.9282424 0.9818182 -4.2181818 2.6018182 19 20 21 22 23 24 0.2618182 0.2218182 0.8618182 -2.1581818 -3.4781818 4.2618182 25 26 27 28 29 30 -6.8464242 -3.4464242 -11.8464242 7.2071515 -1.1928485 3.8271515 31 32 33 34 35 36 -3.2128485 2.4471515 2.0871515 -7.6328485 0.5471515 2.4871515 37 38 39 40 41 42 -0.5210909 -0.8210909 2.8789091 -8.9353939 3.1646061 -3.0153939 43 44 45 46 47 48 -6.5553939 -1.0953939 -2.1553939 -3.2753939 5.5046061 -0.2553939 49 50 51 52 53 54 4.0363636 2.5363636 2.1363636 -3.5100606 3.1899394 -0.3900606 55 56 57 58 59 60 1.3699394 5.0299394 -5.5300606 7.7499394 3.9299394 -3.9300606 > postscript(file="/var/www/html/rcomp/tmp/6z0oz1227721969.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 = 60 Frequency = 1 lag(myerror, k = 1) myerror 0 0.9029091 NA 1 -0.4970909 0.9029091 2 0.9029091 -0.4970909 3 4.2564848 0.9029091 4 -0.9435152 4.2564848 5 -3.0235152 -0.9435152 6 8.1364848 -3.0235152 7 -6.6035152 8.1364848 8 4.7364848 -6.6035152 9 5.3164848 4.7364848 10 -6.5035152 5.3164848 11 -2.5635152 -6.5035152 12 2.4282424 -2.5635152 13 2.2282424 2.4282424 14 5.9282424 2.2282424 15 0.9818182 5.9282424 16 -4.2181818 0.9818182 17 2.6018182 -4.2181818 18 0.2618182 2.6018182 19 0.2218182 0.2618182 20 0.8618182 0.2218182 21 -2.1581818 0.8618182 22 -3.4781818 -2.1581818 23 4.2618182 -3.4781818 24 -6.8464242 4.2618182 25 -3.4464242 -6.8464242 26 -11.8464242 -3.4464242 27 7.2071515 -11.8464242 28 -1.1928485 7.2071515 29 3.8271515 -1.1928485 30 -3.2128485 3.8271515 31 2.4471515 -3.2128485 32 2.0871515 2.4471515 33 -7.6328485 2.0871515 34 0.5471515 -7.6328485 35 2.4871515 0.5471515 36 -0.5210909 2.4871515 37 -0.8210909 -0.5210909 38 2.8789091 -0.8210909 39 -8.9353939 2.8789091 40 3.1646061 -8.9353939 41 -3.0153939 3.1646061 42 -6.5553939 -3.0153939 43 -1.0953939 -6.5553939 44 -2.1553939 -1.0953939 45 -3.2753939 -2.1553939 46 5.5046061 -3.2753939 47 -0.2553939 5.5046061 48 4.0363636 -0.2553939 49 2.5363636 4.0363636 50 2.1363636 2.5363636 51 -3.5100606 2.1363636 52 3.1899394 -3.5100606 53 -0.3900606 3.1899394 54 1.3699394 -0.3900606 55 5.0299394 1.3699394 56 -5.5300606 5.0299394 57 7.7499394 -5.5300606 58 3.9299394 7.7499394 59 -3.9300606 3.9299394 60 NA -3.9300606 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -0.4970909 0.9029091 [2,] 0.9029091 -0.4970909 [3,] 4.2564848 0.9029091 [4,] -0.9435152 4.2564848 [5,] -3.0235152 -0.9435152 [6,] 8.1364848 -3.0235152 [7,] -6.6035152 8.1364848 [8,] 4.7364848 -6.6035152 [9,] 5.3164848 4.7364848 [10,] -6.5035152 5.3164848 [11,] -2.5635152 -6.5035152 [12,] 2.4282424 -2.5635152 [13,] 2.2282424 2.4282424 [14,] 5.9282424 2.2282424 [15,] 0.9818182 5.9282424 [16,] -4.2181818 0.9818182 [17,] 2.6018182 -4.2181818 [18,] 0.2618182 2.6018182 [19,] 0.2218182 0.2618182 [20,] 0.8618182 0.2218182 [21,] -2.1581818 0.8618182 [22,] -3.4781818 -2.1581818 [23,] 4.2618182 -3.4781818 [24,] -6.8464242 4.2618182 [25,] -3.4464242 -6.8464242 [26,] -11.8464242 -3.4464242 [27,] 7.2071515 -11.8464242 [28,] -1.1928485 7.2071515 [29,] 3.8271515 -1.1928485 [30,] -3.2128485 3.8271515 [31,] 2.4471515 -3.2128485 [32,] 2.0871515 2.4471515 [33,] -7.6328485 2.0871515 [34,] 0.5471515 -7.6328485 [35,] 2.4871515 0.5471515 [36,] -0.5210909 2.4871515 [37,] -0.8210909 -0.5210909 [38,] 2.8789091 -0.8210909 [39,] -8.9353939 2.8789091 [40,] 3.1646061 -8.9353939 [41,] -3.0153939 3.1646061 [42,] -6.5553939 -3.0153939 [43,] -1.0953939 -6.5553939 [44,] -2.1553939 -1.0953939 [45,] -3.2753939 -2.1553939 [46,] 5.5046061 -3.2753939 [47,] -0.2553939 5.5046061 [48,] 4.0363636 -0.2553939 [49,] 2.5363636 4.0363636 [50,] 2.1363636 2.5363636 [51,] -3.5100606 2.1363636 [52,] 3.1899394 -3.5100606 [53,] -0.3900606 3.1899394 [54,] 1.3699394 -0.3900606 [55,] 5.0299394 1.3699394 [56,] -5.5300606 5.0299394 [57,] 7.7499394 -5.5300606 [58,] 3.9299394 7.7499394 [59,] -3.9300606 3.9299394 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -0.4970909 0.9029091 2 0.9029091 -0.4970909 3 4.2564848 0.9029091 4 -0.9435152 4.2564848 5 -3.0235152 -0.9435152 6 8.1364848 -3.0235152 7 -6.6035152 8.1364848 8 4.7364848 -6.6035152 9 5.3164848 4.7364848 10 -6.5035152 5.3164848 11 -2.5635152 -6.5035152 12 2.4282424 -2.5635152 13 2.2282424 2.4282424 14 5.9282424 2.2282424 15 0.9818182 5.9282424 16 -4.2181818 0.9818182 17 2.6018182 -4.2181818 18 0.2618182 2.6018182 19 0.2218182 0.2618182 20 0.8618182 0.2218182 21 -2.1581818 0.8618182 22 -3.4781818 -2.1581818 23 4.2618182 -3.4781818 24 -6.8464242 4.2618182 25 -3.4464242 -6.8464242 26 -11.8464242 -3.4464242 27 7.2071515 -11.8464242 28 -1.1928485 7.2071515 29 3.8271515 -1.1928485 30 -3.2128485 3.8271515 31 2.4471515 -3.2128485 32 2.0871515 2.4471515 33 -7.6328485 2.0871515 34 0.5471515 -7.6328485 35 2.4871515 0.5471515 36 -0.5210909 2.4871515 37 -0.8210909 -0.5210909 38 2.8789091 -0.8210909 39 -8.9353939 2.8789091 40 3.1646061 -8.9353939 41 -3.0153939 3.1646061 42 -6.5553939 -3.0153939 43 -1.0953939 -6.5553939 44 -2.1553939 -1.0953939 45 -3.2753939 -2.1553939 46 5.5046061 -3.2753939 47 -0.2553939 5.5046061 48 4.0363636 -0.2553939 49 2.5363636 4.0363636 50 2.1363636 2.5363636 51 -3.5100606 2.1363636 52 3.1899394 -3.5100606 53 -0.3900606 3.1899394 54 1.3699394 -0.3900606 55 5.0299394 1.3699394 56 -5.5300606 5.0299394 57 7.7499394 -5.5300606 58 3.9299394 7.7499394 59 -3.9300606 3.9299394 > 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/72ykl1227721969.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/82nhh1227721969.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/9jlth1227721969.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/10zr4l1227721969.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/11g6tf1227721969.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/12obl21227721970.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/13hvm81227721970.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/14xr521227721970.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/15q7w01227721970.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/16m80o1227721970.tab") + } > > system("convert tmp/1npai1227721969.ps tmp/1npai1227721969.png") > system("convert tmp/2ik671227721969.ps tmp/2ik671227721969.png") > system("convert tmp/3ga0d1227721969.ps tmp/3ga0d1227721969.png") > system("convert tmp/430d41227721969.ps tmp/430d41227721969.png") > system("convert tmp/50zsz1227721969.ps tmp/50zsz1227721969.png") > system("convert tmp/6z0oz1227721969.ps tmp/6z0oz1227721969.png") > system("convert tmp/72ykl1227721969.ps tmp/72ykl1227721969.png") > system("convert tmp/82nhh1227721969.ps tmp/82nhh1227721969.png") > system("convert tmp/9jlth1227721969.ps tmp/9jlth1227721969.png") > system("convert tmp/10zr4l1227721969.ps tmp/10zr4l1227721969.png") > > > proc.time() user system elapsed 4.940 2.732 5.321