R version 2.9.0 (2009-04-17) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > x <- array(list(24,33,22,34,25,36,24,36,29,38,26,42,26,35,21,25,23,24,22,22,21,27,16,17,19,30,16,30,25,34,27,37,23,36,22,33,23,33,20,33,24,37,23,40,20,35,21,37,22,43,17,42,21,33,19,39,23,40,22,37,15,44,23,42,21,43,18,40,18,30,18,30,18,31,10,18,13,24,10,22,9,26,9,28,6,23,11,17,9,12,10,9,9,19,16,21,10,18,7,18,7,15,14,24,11,18,10,19,6,30,8,33,13,35,12,36,15,47,16,46,16,43),dim=c(2,61),dimnames=list(c('S.','E.S'),1:61)) > y <- array(NA,dim=c(2,61),dimnames=list(c('S.','E.S'),1:61)) > 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 S. E.S M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 24 33 1 0 0 0 0 0 0 0 0 0 0 1 2 22 34 0 1 0 0 0 0 0 0 0 0 0 2 3 25 36 0 0 1 0 0 0 0 0 0 0 0 3 4 24 36 0 0 0 1 0 0 0 0 0 0 0 4 5 29 38 0 0 0 0 1 0 0 0 0 0 0 5 6 26 42 0 0 0 0 0 1 0 0 0 0 0 6 7 26 35 0 0 0 0 0 0 1 0 0 0 0 7 8 21 25 0 0 0 0 0 0 0 1 0 0 0 8 9 23 24 0 0 0 0 0 0 0 0 1 0 0 9 10 22 22 0 0 0 0 0 0 0 0 0 1 0 10 11 21 27 0 0 0 0 0 0 0 0 0 0 1 11 12 16 17 0 0 0 0 0 0 0 0 0 0 0 12 13 19 30 1 0 0 0 0 0 0 0 0 0 0 13 14 16 30 0 1 0 0 0 0 0 0 0 0 0 14 15 25 34 0 0 1 0 0 0 0 0 0 0 0 15 16 27 37 0 0 0 1 0 0 0 0 0 0 0 16 17 23 36 0 0 0 0 1 0 0 0 0 0 0 17 18 22 33 0 0 0 0 0 1 0 0 0 0 0 18 19 23 33 0 0 0 0 0 0 1 0 0 0 0 19 20 20 33 0 0 0 0 0 0 0 1 0 0 0 20 21 24 37 0 0 0 0 0 0 0 0 1 0 0 21 22 23 40 0 0 0 0 0 0 0 0 0 1 0 22 23 20 35 0 0 0 0 0 0 0 0 0 0 1 23 24 21 37 0 0 0 0 0 0 0 0 0 0 0 24 25 22 43 1 0 0 0 0 0 0 0 0 0 0 25 26 17 42 0 1 0 0 0 0 0 0 0 0 0 26 27 21 33 0 0 1 0 0 0 0 0 0 0 0 27 28 19 39 0 0 0 1 0 0 0 0 0 0 0 28 29 23 40 0 0 0 0 1 0 0 0 0 0 0 29 30 22 37 0 0 0 0 0 1 0 0 0 0 0 30 31 15 44 0 0 0 0 0 0 1 0 0 0 0 31 32 23 42 0 0 0 0 0 0 0 1 0 0 0 32 33 21 43 0 0 0 0 0 0 0 0 1 0 0 33 34 18 40 0 0 0 0 0 0 0 0 0 1 0 34 35 18 30 0 0 0 0 0 0 0 0 0 0 1 35 36 18 30 0 0 0 0 0 0 0 0 0 0 0 36 37 18 31 1 0 0 0 0 0 0 0 0 0 0 37 38 10 18 0 1 0 0 0 0 0 0 0 0 0 38 39 13 24 0 0 1 0 0 0 0 0 0 0 0 39 40 10 22 0 0 0 1 0 0 0 0 0 0 0 40 41 9 26 0 0 0 0 1 0 0 0 0 0 0 41 42 9 28 0 0 0 0 0 1 0 0 0 0 0 42 43 6 23 0 0 0 0 0 0 1 0 0 0 0 43 44 11 17 0 0 0 0 0 0 0 1 0 0 0 44 45 9 12 0 0 0 0 0 0 0 0 1 0 0 45 46 10 9 0 0 0 0 0 0 0 0 0 1 0 46 47 9 19 0 0 0 0 0 0 0 0 0 0 1 47 48 16 21 0 0 0 0 0 0 0 0 0 0 0 48 49 10 18 1 0 0 0 0 0 0 0 0 0 0 49 50 7 18 0 1 0 0 0 0 0 0 0 0 0 50 51 7 15 0 0 1 0 0 0 0 0 0 0 0 51 52 14 24 0 0 0 1 0 0 0 0 0 0 0 52 53 11 18 0 0 0 0 1 0 0 0 0 0 0 53 54 10 19 0 0 0 0 0 1 0 0 0 0 0 54 55 6 30 0 0 0 0 0 0 1 0 0 0 0 55 56 8 33 0 0 0 0 0 0 0 1 0 0 0 56 57 13 35 0 0 0 0 0 0 0 0 1 0 0 57 58 12 36 0 0 0 0 0 0 0 0 0 1 0 58 59 15 47 0 0 0 0 0 0 0 0 0 0 1 59 60 16 46 0 0 0 0 0 0 0 0 0 0 0 60 61 16 43 1 0 0 0 0 0 0 0 0 0 0 61 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) E.S M1 M2 M3 M4 17.8744 0.2836 -1.2830 -5.0005 -0.9494 -1.0059 M5 M6 M7 M8 M9 M10 -0.5548 -1.5604 -4.2497 -1.7477 -0.1533 -0.6753 M11 t -1.4482 -0.2511 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -5.3984 -1.3729 -0.2084 1.6176 4.7867 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 17.87440 1.83681 9.731 7.66e-13 *** E.S 0.28362 0.03684 7.698 7.21e-10 *** M1 -1.28301 1.53653 -0.835 0.40794 M2 -5.00054 1.61456 -3.097 0.00329 ** M3 -0.94944 1.61218 -0.589 0.55874 M4 -1.00593 1.60674 -0.626 0.53430 M5 -0.55482 1.60516 -0.346 0.73115 M6 -1.56044 1.60393 -0.973 0.33559 M7 -4.24968 1.60442 -2.649 0.01097 * M8 -1.74770 1.60168 -1.091 0.28076 M9 -0.15332 1.60076 -0.096 0.92410 M10 -0.67531 1.60063 -0.422 0.67502 M11 -1.44818 1.60052 -0.905 0.37018 t -0.25111 0.01925 -13.045 < 2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 2.529 on 47 degrees of freedom Multiple R-squared: 0.8694, Adjusted R-squared: 0.8333 F-statistic: 24.07 on 13 and 47 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.28690358 0.57380715 0.7130964 [2,] 0.50394611 0.99210777 0.4960539 [3,] 0.48102203 0.96204406 0.5189780 [4,] 0.40711998 0.81423996 0.5928800 [5,] 0.29738267 0.59476535 0.7026173 [6,] 0.21144647 0.42289294 0.7885535 [7,] 0.13519123 0.27038246 0.8648088 [8,] 0.11353556 0.22707111 0.8864644 [9,] 0.07483313 0.14966626 0.9251669 [10,] 0.05356761 0.10713521 0.9464324 [11,] 0.03386293 0.06772585 0.9661371 [12,] 0.04474315 0.08948631 0.9552568 [13,] 0.03295327 0.06590653 0.9670467 [14,] 0.04266190 0.08532379 0.9573381 [15,] 0.26582105 0.53164209 0.7341790 [16,] 0.41895129 0.83790258 0.5810487 [17,] 0.38934186 0.77868371 0.6106581 [18,] 0.33067559 0.66135118 0.6693244 [19,] 0.37463173 0.74926345 0.6253683 [20,] 0.31967109 0.63934217 0.6803289 [21,] 0.35793036 0.71586071 0.6420696 [22,] 0.31059379 0.62118758 0.6894062 [23,] 0.53614330 0.92771341 0.4638567 [24,] 0.54729008 0.90541984 0.4527099 [25,] 0.59461552 0.81076897 0.4053845 [26,] 0.65119135 0.69761730 0.3488087 [27,] 0.70120034 0.59759932 0.2987997 [28,] 0.57559147 0.84881706 0.4244085 > postscript(file="/var/www/html/rcomp/tmp/1keoq1260370819.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/2wsam1260370819.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/3pqvk1260370819.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/4xtap1260370819.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/5v9431260370819.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 = 61 Frequency = 1 1 2 3 4 5 6 -1.69986888 -0.01485638 -1.38210445 -2.07450753 2.15824439 -0.71952695 7 8 9 10 11 12 4.20619016 -0.20844158 0.73190727 1.07225611 -0.32189119 -3.68272447 13 14 15 16 17 18 -2.83571588 -1.86707934 2.19842451 3.65514931 -0.26122665 0.84637027 19 20 21 22 23 24 4.78671912 -0.46415300 1.05807566 -0.01969568 -0.57760261 -1.34192434 25 26 27 28 29 30 -0.50954749 -1.25728691 1.49532943 -1.89881788 1.61755808 2.72515500 31 32 33 34 35 36 -3.31986442 2.99651155 -0.63038768 -2.00641480 1.85379846 0.65672481 37 38 39 40 41 42 1.90722185 1.56297088 -0.93877335 -3.06392835 -5.39842451 -4.70894777 43 44 45 46 47 48 -3.35047874 1.10039337 -0.82476163 1.79921125 -1.01305624 4.22262203 49 50 51 52 53 54 0.60761523 1.57625176 -1.37287613 3.38210445 1.88384868 1.85694945 55 56 57 58 59 60 -2.32256612 -3.42431035 -0.33483361 -0.84535688 0.05875158 0.14530197 61 2.53029516 > postscript(file="/var/www/html/rcomp/tmp/6tjeh1260370819.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 = 61 Frequency = 1 lag(myerror, k = 1) myerror 0 -1.69986888 NA 1 -0.01485638 -1.69986888 2 -1.38210445 -0.01485638 3 -2.07450753 -1.38210445 4 2.15824439 -2.07450753 5 -0.71952695 2.15824439 6 4.20619016 -0.71952695 7 -0.20844158 4.20619016 8 0.73190727 -0.20844158 9 1.07225611 0.73190727 10 -0.32189119 1.07225611 11 -3.68272447 -0.32189119 12 -2.83571588 -3.68272447 13 -1.86707934 -2.83571588 14 2.19842451 -1.86707934 15 3.65514931 2.19842451 16 -0.26122665 3.65514931 17 0.84637027 -0.26122665 18 4.78671912 0.84637027 19 -0.46415300 4.78671912 20 1.05807566 -0.46415300 21 -0.01969568 1.05807566 22 -0.57760261 -0.01969568 23 -1.34192434 -0.57760261 24 -0.50954749 -1.34192434 25 -1.25728691 -0.50954749 26 1.49532943 -1.25728691 27 -1.89881788 1.49532943 28 1.61755808 -1.89881788 29 2.72515500 1.61755808 30 -3.31986442 2.72515500 31 2.99651155 -3.31986442 32 -0.63038768 2.99651155 33 -2.00641480 -0.63038768 34 1.85379846 -2.00641480 35 0.65672481 1.85379846 36 1.90722185 0.65672481 37 1.56297088 1.90722185 38 -0.93877335 1.56297088 39 -3.06392835 -0.93877335 40 -5.39842451 -3.06392835 41 -4.70894777 -5.39842451 42 -3.35047874 -4.70894777 43 1.10039337 -3.35047874 44 -0.82476163 1.10039337 45 1.79921125 -0.82476163 46 -1.01305624 1.79921125 47 4.22262203 -1.01305624 48 0.60761523 4.22262203 49 1.57625176 0.60761523 50 -1.37287613 1.57625176 51 3.38210445 -1.37287613 52 1.88384868 3.38210445 53 1.85694945 1.88384868 54 -2.32256612 1.85694945 55 -3.42431035 -2.32256612 56 -0.33483361 -3.42431035 57 -0.84535688 -0.33483361 58 0.05875158 -0.84535688 59 0.14530197 0.05875158 60 2.53029516 0.14530197 61 NA 2.53029516 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -0.01485638 -1.69986888 [2,] -1.38210445 -0.01485638 [3,] -2.07450753 -1.38210445 [4,] 2.15824439 -2.07450753 [5,] -0.71952695 2.15824439 [6,] 4.20619016 -0.71952695 [7,] -0.20844158 4.20619016 [8,] 0.73190727 -0.20844158 [9,] 1.07225611 0.73190727 [10,] -0.32189119 1.07225611 [11,] -3.68272447 -0.32189119 [12,] -2.83571588 -3.68272447 [13,] -1.86707934 -2.83571588 [14,] 2.19842451 -1.86707934 [15,] 3.65514931 2.19842451 [16,] -0.26122665 3.65514931 [17,] 0.84637027 -0.26122665 [18,] 4.78671912 0.84637027 [19,] -0.46415300 4.78671912 [20,] 1.05807566 -0.46415300 [21,] -0.01969568 1.05807566 [22,] -0.57760261 -0.01969568 [23,] -1.34192434 -0.57760261 [24,] -0.50954749 -1.34192434 [25,] -1.25728691 -0.50954749 [26,] 1.49532943 -1.25728691 [27,] -1.89881788 1.49532943 [28,] 1.61755808 -1.89881788 [29,] 2.72515500 1.61755808 [30,] -3.31986442 2.72515500 [31,] 2.99651155 -3.31986442 [32,] -0.63038768 2.99651155 [33,] -2.00641480 -0.63038768 [34,] 1.85379846 -2.00641480 [35,] 0.65672481 1.85379846 [36,] 1.90722185 0.65672481 [37,] 1.56297088 1.90722185 [38,] -0.93877335 1.56297088 [39,] -3.06392835 -0.93877335 [40,] -5.39842451 -3.06392835 [41,] -4.70894777 -5.39842451 [42,] -3.35047874 -4.70894777 [43,] 1.10039337 -3.35047874 [44,] -0.82476163 1.10039337 [45,] 1.79921125 -0.82476163 [46,] -1.01305624 1.79921125 [47,] 4.22262203 -1.01305624 [48,] 0.60761523 4.22262203 [49,] 1.57625176 0.60761523 [50,] -1.37287613 1.57625176 [51,] 3.38210445 -1.37287613 [52,] 1.88384868 3.38210445 [53,] 1.85694945 1.88384868 [54,] -2.32256612 1.85694945 [55,] -3.42431035 -2.32256612 [56,] -0.33483361 -3.42431035 [57,] -0.84535688 -0.33483361 [58,] 0.05875158 -0.84535688 [59,] 0.14530197 0.05875158 [60,] 2.53029516 0.14530197 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -0.01485638 -1.69986888 2 -1.38210445 -0.01485638 3 -2.07450753 -1.38210445 4 2.15824439 -2.07450753 5 -0.71952695 2.15824439 6 4.20619016 -0.71952695 7 -0.20844158 4.20619016 8 0.73190727 -0.20844158 9 1.07225611 0.73190727 10 -0.32189119 1.07225611 11 -3.68272447 -0.32189119 12 -2.83571588 -3.68272447 13 -1.86707934 -2.83571588 14 2.19842451 -1.86707934 15 3.65514931 2.19842451 16 -0.26122665 3.65514931 17 0.84637027 -0.26122665 18 4.78671912 0.84637027 19 -0.46415300 4.78671912 20 1.05807566 -0.46415300 21 -0.01969568 1.05807566 22 -0.57760261 -0.01969568 23 -1.34192434 -0.57760261 24 -0.50954749 -1.34192434 25 -1.25728691 -0.50954749 26 1.49532943 -1.25728691 27 -1.89881788 1.49532943 28 1.61755808 -1.89881788 29 2.72515500 1.61755808 30 -3.31986442 2.72515500 31 2.99651155 -3.31986442 32 -0.63038768 2.99651155 33 -2.00641480 -0.63038768 34 1.85379846 -2.00641480 35 0.65672481 1.85379846 36 1.90722185 0.65672481 37 1.56297088 1.90722185 38 -0.93877335 1.56297088 39 -3.06392835 -0.93877335 40 -5.39842451 -3.06392835 41 -4.70894777 -5.39842451 42 -3.35047874 -4.70894777 43 1.10039337 -3.35047874 44 -0.82476163 1.10039337 45 1.79921125 -0.82476163 46 -1.01305624 1.79921125 47 4.22262203 -1.01305624 48 0.60761523 4.22262203 49 1.57625176 0.60761523 50 -1.37287613 1.57625176 51 3.38210445 -1.37287613 52 1.88384868 3.38210445 53 1.85694945 1.88384868 54 -2.32256612 1.85694945 55 -3.42431035 -2.32256612 56 -0.33483361 -3.42431035 57 -0.84535688 -0.33483361 58 0.05875158 -0.84535688 59 0.14530197 0.05875158 60 2.53029516 0.14530197 > 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/7kl8x1260370819.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/8n2o71260370819.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/99tjm1260370819.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/10glhh1260370819.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/11ozio1260370820.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/12i4bg1260370820.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/13brjy1260370820.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/14ax591260370820.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/154uti1260370820.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/1651sb1260370820.tab") + } > > system("convert tmp/1keoq1260370819.ps tmp/1keoq1260370819.png") > system("convert tmp/2wsam1260370819.ps tmp/2wsam1260370819.png") > system("convert tmp/3pqvk1260370819.ps tmp/3pqvk1260370819.png") > system("convert tmp/4xtap1260370819.ps tmp/4xtap1260370819.png") > system("convert tmp/5v9431260370819.ps tmp/5v9431260370819.png") > system("convert tmp/6tjeh1260370819.ps tmp/6tjeh1260370819.png") > system("convert tmp/7kl8x1260370819.ps tmp/7kl8x1260370819.png") > system("convert tmp/8n2o71260370819.ps tmp/8n2o71260370819.png") > system("convert tmp/99tjm1260370819.ps tmp/99tjm1260370819.png") > system("convert tmp/10glhh1260370819.ps tmp/10glhh1260370819.png") > > > proc.time() user system elapsed 2.438 1.580 3.321