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(1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,1,1,1,0,1,1,1,1,1,0,1,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,1,1,0,1,1,0,0,1,0,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,1,0,0,0,1,1,0,0,0,0,1,1,1,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,0,1,0,1,1,1,0,0,0,0,1,0,1,1,0,0,0,0,0,1,0,1,1,0,0,1,1,0,0,0,1,0,0,0,1,1,1,1,1,1,0,0,1,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,1,0,0,0,0,1,1,0,0,1,0,0,0,1,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0),dim=c(4,86),dimnames=list(c('Treatment','CA','Used','Outcome'),1:86)) > y <- array(NA,dim=c(4,86),dimnames=list(c('Treatment','CA','Used','Outcome'),1:86)) > 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 = 'Do not include Seasonal Dummies' > par1 = '4' > par3 <- 'Linear Trend' > par2 <- 'Do not include Seasonal Dummies' > par1 <- '4' > #'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 Outcome Treatment CA Used t 1 1 1 0 0 1 2 0 0 0 0 2 3 0 0 0 0 3 4 0 0 0 0 4 5 0 0 0 0 5 6 1 0 0 0 6 7 0 0 0 0 7 8 0 1 0 0 8 9 1 0 0 0 9 10 0 0 0 0 10 11 0 1 0 0 11 12 0 0 0 0 12 13 0 0 0 1 13 14 0 1 0 0 14 15 1 0 0 1 15 16 1 1 0 1 16 17 0 1 1 1 17 18 0 1 0 0 18 19 1 0 0 0 19 20 1 1 1 1 20 21 0 0 0 0 21 22 1 0 0 1 22 23 1 0 0 0 23 24 1 0 0 0 24 25 1 1 0 1 25 26 0 0 0 1 26 27 1 0 0 0 27 28 0 0 0 1 28 29 1 0 0 0 29 30 0 0 0 0 30 31 0 0 0 0 31 32 0 0 0 0 32 33 0 0 0 0 33 34 1 1 0 0 34 35 0 0 0 0 35 36 0 0 0 0 36 37 0 1 0 1 37 38 1 0 0 1 38 39 1 0 0 0 39 40 0 1 0 0 40 41 1 0 1 1 41 42 1 0 0 1 42 43 1 0 0 0 43 44 0 1 0 0 44 45 0 0 0 0 45 46 1 0 0 0 46 47 0 0 0 0 47 48 1 0 0 0 48 49 1 0 0 0 49 50 0 0 0 0 50 51 0 1 0 1 51 52 0 1 1 1 52 53 1 0 0 0 53 54 0 0 1 1 54 55 0 0 0 0 55 56 1 1 0 1 56 57 1 0 0 1 57 58 1 0 0 0 58 59 1 0 0 0 59 60 1 1 1 1 60 61 1 1 0 0 61 62 0 0 0 1 62 63 0 0 0 0 63 64 1 1 0 0 64 65 0 0 0 0 65 66 0 0 0 0 66 67 0 1 1 1 67 68 0 0 0 0 68 69 1 0 0 0 69 70 0 0 0 1 70 71 0 0 0 0 71 72 1 0 0 0 72 73 1 0 0 1 73 74 0 0 0 1 74 75 1 0 0 0 75 76 1 1 0 0 76 77 1 0 0 0 77 78 1 0 0 1 78 79 1 1 1 1 79 80 0 1 0 0 80 81 0 0 0 0 81 82 1 0 0 1 82 83 0 0 0 0 83 84 0 0 1 1 84 85 1 0 0 0 85 86 0 0 0 0 86 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) Treatment CA Used t 0.339186 0.032335 -0.162233 0.137637 0.002056 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -0.6290 -0.4534 -0.3484 0.5112 0.6485 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.339186 0.120155 2.823 0.00599 ** Treatment 0.032335 0.131151 0.247 0.80588 CA -0.162233 0.213142 -0.761 0.44878 Used 0.137637 0.134716 1.022 0.30997 t 0.002056 0.002244 0.916 0.36228 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.5074 on 81 degrees of freedom Multiple R-squared: 0.02516, Adjusted R-squared: -0.02298 F-statistic: 0.5226 on 4 and 81 DF, p-value: 0.7194 > 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.7953116 0.4093768 0.2046884 [2,] 0.8649875 0.2700250 0.1350125 [3,] 0.8048199 0.3903601 0.1951801 [4,] 0.7475524 0.5048952 0.2524476 [5,] 0.6557471 0.6885057 0.3442529 [6,] 0.5623110 0.8753779 0.4376890 [7,] 0.4715687 0.9431374 0.5284313 [8,] 0.5596210 0.8807581 0.4403790 [9,] 0.5070946 0.9858108 0.4929054 [10,] 0.4257782 0.8515565 0.5742218 [11,] 0.3552805 0.7105610 0.6447195 [12,] 0.4935093 0.9870187 0.5064907 [13,] 0.5430272 0.9139456 0.4569728 [14,] 0.4993828 0.9987656 0.5006172 [15,] 0.4502386 0.9004772 0.5497614 [16,] 0.4684530 0.9369060 0.5315470 [17,] 0.4519010 0.9038020 0.5480990 [18,] 0.3966462 0.7932924 0.6033538 [19,] 0.4963431 0.9926862 0.5036569 [20,] 0.4748646 0.9497293 0.5251354 [21,] 0.5295378 0.9409243 0.4704622 [22,] 0.5067622 0.9864756 0.4932378 [23,] 0.5264054 0.9471892 0.4735946 [24,] 0.5236347 0.9527305 0.4763653 [25,] 0.5089972 0.9820056 0.4910028 [26,] 0.4886220 0.9772441 0.5113780 [27,] 0.4825722 0.9651444 0.5174278 [28,] 0.4658706 0.9317412 0.5341294 [29,] 0.4490108 0.8980215 0.5509892 [30,] 0.4801939 0.9603878 0.5198061 [31,] 0.4564116 0.9128232 0.5435884 [32,] 0.4608896 0.9217793 0.5391104 [33,] 0.4558854 0.9117707 0.5441146 [34,] 0.4489856 0.8979712 0.5510144 [35,] 0.4217541 0.8435081 0.5782459 [36,] 0.4241719 0.8483438 0.5758281 [37,] 0.4304039 0.8608078 0.5695961 [38,] 0.4222332 0.8444664 0.5777668 [39,] 0.4222418 0.8444835 0.5777582 [40,] 0.4154970 0.8309940 0.5845030 [41,] 0.4140065 0.8280129 0.5859935 [42,] 0.4182215 0.8364429 0.5817785 [43,] 0.4071213 0.8142426 0.5928787 [44,] 0.4770228 0.9540456 0.5229772 [45,] 0.4900192 0.9800384 0.5099808 [46,] 0.4917327 0.9834655 0.5082673 [47,] 0.4652519 0.9305038 0.5347481 [48,] 0.4590230 0.9180460 0.5409770 [49,] 0.4096071 0.8192143 0.5903929 [50,] 0.3751748 0.7503497 0.6248252 [51,] 0.3781708 0.7563416 0.6218292 [52,] 0.4048663 0.8097327 0.5951337 [53,] 0.4186301 0.8372601 0.5813699 [54,] 0.3937939 0.7875877 0.6062061 [55,] 0.3917528 0.7835056 0.6082472 [56,] 0.3561229 0.7122458 0.6438771 [57,] 0.3342327 0.6684654 0.6657673 [58,] 0.2994643 0.5989286 0.7005357 [59,] 0.2728734 0.5457468 0.7271266 [60,] 0.2627050 0.5254099 0.7372950 [61,] 0.2698385 0.5396769 0.7301615 [62,] 0.2403745 0.4807491 0.7596255 [63,] 0.3010958 0.6021916 0.6989042 [64,] 0.3736824 0.7473647 0.6263176 [65,] 0.3007693 0.6015385 0.6992307 [66,] 0.2258363 0.4516727 0.7741637 [67,] 0.5167404 0.9665191 0.4832596 [68,] 0.4079148 0.8158297 0.5920852 [69,] 0.3192139 0.6384278 0.6807861 [70,] 0.3352110 0.6704220 0.6647890 [71,] 0.2108070 0.4216140 0.7891930 > postscript(file="/var/fisher/rcomp/tmp/1rq7i1356028973.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/fisher/rcomp/tmp/27bv61356028973.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/fisher/rcomp/tmp/3v1kh1356028973.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/fisher/rcomp/tmp/4bfr21356028973.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/fisher/rcomp/tmp/5yn1s1356028973.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 = 86 Frequency = 1 1 2 3 4 5 6 7 0.6264221 -0.3432988 -0.3453551 -0.3474114 -0.3494676 0.6484761 -0.3535802 8 9 10 11 12 13 14 -0.3879718 0.6423073 -0.3597490 -0.3941406 -0.3638616 -0.5035550 -0.4003095 15 16 17 18 19 20 21 0.4923324 0.4579408 -0.3818824 -0.4085346 0.6217445 0.6119488 -0.3823680 22 23 24 25 26 27 28 0.4779385 0.6135194 0.6114631 0.4394343 -0.5302866 0.6052943 -0.5343991 29 30 31 32 33 34 35 0.6011818 -0.4008745 -0.4029308 -0.4049871 -0.4070433 0.5585650 -0.4111559 36 37 38 39 40 41 42 -0.4132122 -0.5852410 0.4450381 0.5806190 -0.4537726 0.6011023 0.4368130 43 44 45 46 47 48 49 0.5723939 -0.4619977 -0.4317186 0.5662251 -0.4358312 0.5621125 0.5600563 50 51 52 53 54 55 56 -0.4420000 -0.6140288 -0.4538520 0.5518312 -0.4256292 -0.4522814 0.3756898 57 58 59 60 61 62 63 0.4059689 0.5415498 0.5394935 0.5296978 0.5030456 -0.6043125 -0.4687316 64 65 66 67 68 69 70 0.4968768 -0.4728441 -0.4749004 -0.4846962 -0.4790130 0.5189308 -0.6207627 71 72 73 74 75 76 77 -0.4851818 0.5127619 0.3730685 -0.6289878 0.5065931 0.4722015 0.5024806 78 79 80 81 82 83 84 0.3627871 0.4906285 -0.5360236 -0.5057445 0.3545620 -0.5098571 -0.4873175 85 86 0.4860304 -0.5160259 > postscript(file="/var/fisher/rcomp/tmp/65x9i1356028973.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 = 86 Frequency = 1 lag(myerror, k = 1) myerror 0 0.6264221 NA 1 -0.3432988 0.6264221 2 -0.3453551 -0.3432988 3 -0.3474114 -0.3453551 4 -0.3494676 -0.3474114 5 0.6484761 -0.3494676 6 -0.3535802 0.6484761 7 -0.3879718 -0.3535802 8 0.6423073 -0.3879718 9 -0.3597490 0.6423073 10 -0.3941406 -0.3597490 11 -0.3638616 -0.3941406 12 -0.5035550 -0.3638616 13 -0.4003095 -0.5035550 14 0.4923324 -0.4003095 15 0.4579408 0.4923324 16 -0.3818824 0.4579408 17 -0.4085346 -0.3818824 18 0.6217445 -0.4085346 19 0.6119488 0.6217445 20 -0.3823680 0.6119488 21 0.4779385 -0.3823680 22 0.6135194 0.4779385 23 0.6114631 0.6135194 24 0.4394343 0.6114631 25 -0.5302866 0.4394343 26 0.6052943 -0.5302866 27 -0.5343991 0.6052943 28 0.6011818 -0.5343991 29 -0.4008745 0.6011818 30 -0.4029308 -0.4008745 31 -0.4049871 -0.4029308 32 -0.4070433 -0.4049871 33 0.5585650 -0.4070433 34 -0.4111559 0.5585650 35 -0.4132122 -0.4111559 36 -0.5852410 -0.4132122 37 0.4450381 -0.5852410 38 0.5806190 0.4450381 39 -0.4537726 0.5806190 40 0.6011023 -0.4537726 41 0.4368130 0.6011023 42 0.5723939 0.4368130 43 -0.4619977 0.5723939 44 -0.4317186 -0.4619977 45 0.5662251 -0.4317186 46 -0.4358312 0.5662251 47 0.5621125 -0.4358312 48 0.5600563 0.5621125 49 -0.4420000 0.5600563 50 -0.6140288 -0.4420000 51 -0.4538520 -0.6140288 52 0.5518312 -0.4538520 53 -0.4256292 0.5518312 54 -0.4522814 -0.4256292 55 0.3756898 -0.4522814 56 0.4059689 0.3756898 57 0.5415498 0.4059689 58 0.5394935 0.5415498 59 0.5296978 0.5394935 60 0.5030456 0.5296978 61 -0.6043125 0.5030456 62 -0.4687316 -0.6043125 63 0.4968768 -0.4687316 64 -0.4728441 0.4968768 65 -0.4749004 -0.4728441 66 -0.4846962 -0.4749004 67 -0.4790130 -0.4846962 68 0.5189308 -0.4790130 69 -0.6207627 0.5189308 70 -0.4851818 -0.6207627 71 0.5127619 -0.4851818 72 0.3730685 0.5127619 73 -0.6289878 0.3730685 74 0.5065931 -0.6289878 75 0.4722015 0.5065931 76 0.5024806 0.4722015 77 0.3627871 0.5024806 78 0.4906285 0.3627871 79 -0.5360236 0.4906285 80 -0.5057445 -0.5360236 81 0.3545620 -0.5057445 82 -0.5098571 0.3545620 83 -0.4873175 -0.5098571 84 0.4860304 -0.4873175 85 -0.5160259 0.4860304 86 NA -0.5160259 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -0.3432988 0.6264221 [2,] -0.3453551 -0.3432988 [3,] -0.3474114 -0.3453551 [4,] -0.3494676 -0.3474114 [5,] 0.6484761 -0.3494676 [6,] -0.3535802 0.6484761 [7,] -0.3879718 -0.3535802 [8,] 0.6423073 -0.3879718 [9,] -0.3597490 0.6423073 [10,] -0.3941406 -0.3597490 [11,] -0.3638616 -0.3941406 [12,] -0.5035550 -0.3638616 [13,] -0.4003095 -0.5035550 [14,] 0.4923324 -0.4003095 [15,] 0.4579408 0.4923324 [16,] -0.3818824 0.4579408 [17,] -0.4085346 -0.3818824 [18,] 0.6217445 -0.4085346 [19,] 0.6119488 0.6217445 [20,] -0.3823680 0.6119488 [21,] 0.4779385 -0.3823680 [22,] 0.6135194 0.4779385 [23,] 0.6114631 0.6135194 [24,] 0.4394343 0.6114631 [25,] -0.5302866 0.4394343 [26,] 0.6052943 -0.5302866 [27,] -0.5343991 0.6052943 [28,] 0.6011818 -0.5343991 [29,] -0.4008745 0.6011818 [30,] -0.4029308 -0.4008745 [31,] -0.4049871 -0.4029308 [32,] -0.4070433 -0.4049871 [33,] 0.5585650 -0.4070433 [34,] -0.4111559 0.5585650 [35,] -0.4132122 -0.4111559 [36,] -0.5852410 -0.4132122 [37,] 0.4450381 -0.5852410 [38,] 0.5806190 0.4450381 [39,] -0.4537726 0.5806190 [40,] 0.6011023 -0.4537726 [41,] 0.4368130 0.6011023 [42,] 0.5723939 0.4368130 [43,] -0.4619977 0.5723939 [44,] -0.4317186 -0.4619977 [45,] 0.5662251 -0.4317186 [46,] -0.4358312 0.5662251 [47,] 0.5621125 -0.4358312 [48,] 0.5600563 0.5621125 [49,] -0.4420000 0.5600563 [50,] -0.6140288 -0.4420000 [51,] -0.4538520 -0.6140288 [52,] 0.5518312 -0.4538520 [53,] -0.4256292 0.5518312 [54,] -0.4522814 -0.4256292 [55,] 0.3756898 -0.4522814 [56,] 0.4059689 0.3756898 [57,] 0.5415498 0.4059689 [58,] 0.5394935 0.5415498 [59,] 0.5296978 0.5394935 [60,] 0.5030456 0.5296978 [61,] -0.6043125 0.5030456 [62,] -0.4687316 -0.6043125 [63,] 0.4968768 -0.4687316 [64,] -0.4728441 0.4968768 [65,] -0.4749004 -0.4728441 [66,] -0.4846962 -0.4749004 [67,] -0.4790130 -0.4846962 [68,] 0.5189308 -0.4790130 [69,] -0.6207627 0.5189308 [70,] -0.4851818 -0.6207627 [71,] 0.5127619 -0.4851818 [72,] 0.3730685 0.5127619 [73,] -0.6289878 0.3730685 [74,] 0.5065931 -0.6289878 [75,] 0.4722015 0.5065931 [76,] 0.5024806 0.4722015 [77,] 0.3627871 0.5024806 [78,] 0.4906285 0.3627871 [79,] -0.5360236 0.4906285 [80,] -0.5057445 -0.5360236 [81,] 0.3545620 -0.5057445 [82,] -0.5098571 0.3545620 [83,] -0.4873175 -0.5098571 [84,] 0.4860304 -0.4873175 [85,] -0.5160259 0.4860304 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -0.3432988 0.6264221 2 -0.3453551 -0.3432988 3 -0.3474114 -0.3453551 4 -0.3494676 -0.3474114 5 0.6484761 -0.3494676 6 -0.3535802 0.6484761 7 -0.3879718 -0.3535802 8 0.6423073 -0.3879718 9 -0.3597490 0.6423073 10 -0.3941406 -0.3597490 11 -0.3638616 -0.3941406 12 -0.5035550 -0.3638616 13 -0.4003095 -0.5035550 14 0.4923324 -0.4003095 15 0.4579408 0.4923324 16 -0.3818824 0.4579408 17 -0.4085346 -0.3818824 18 0.6217445 -0.4085346 19 0.6119488 0.6217445 20 -0.3823680 0.6119488 21 0.4779385 -0.3823680 22 0.6135194 0.4779385 23 0.6114631 0.6135194 24 0.4394343 0.6114631 25 -0.5302866 0.4394343 26 0.6052943 -0.5302866 27 -0.5343991 0.6052943 28 0.6011818 -0.5343991 29 -0.4008745 0.6011818 30 -0.4029308 -0.4008745 31 -0.4049871 -0.4029308 32 -0.4070433 -0.4049871 33 0.5585650 -0.4070433 34 -0.4111559 0.5585650 35 -0.4132122 -0.4111559 36 -0.5852410 -0.4132122 37 0.4450381 -0.5852410 38 0.5806190 0.4450381 39 -0.4537726 0.5806190 40 0.6011023 -0.4537726 41 0.4368130 0.6011023 42 0.5723939 0.4368130 43 -0.4619977 0.5723939 44 -0.4317186 -0.4619977 45 0.5662251 -0.4317186 46 -0.4358312 0.5662251 47 0.5621125 -0.4358312 48 0.5600563 0.5621125 49 -0.4420000 0.5600563 50 -0.6140288 -0.4420000 51 -0.4538520 -0.6140288 52 0.5518312 -0.4538520 53 -0.4256292 0.5518312 54 -0.4522814 -0.4256292 55 0.3756898 -0.4522814 56 0.4059689 0.3756898 57 0.5415498 0.4059689 58 0.5394935 0.5415498 59 0.5296978 0.5394935 60 0.5030456 0.5296978 61 -0.6043125 0.5030456 62 -0.4687316 -0.6043125 63 0.4968768 -0.4687316 64 -0.4728441 0.4968768 65 -0.4749004 -0.4728441 66 -0.4846962 -0.4749004 67 -0.4790130 -0.4846962 68 0.5189308 -0.4790130 69 -0.6207627 0.5189308 70 -0.4851818 -0.6207627 71 0.5127619 -0.4851818 72 0.3730685 0.5127619 73 -0.6289878 0.3730685 74 0.5065931 -0.6289878 75 0.4722015 0.5065931 76 0.5024806 0.4722015 77 0.3627871 0.5024806 78 0.4906285 0.3627871 79 -0.5360236 0.4906285 80 -0.5057445 -0.5360236 81 0.3545620 -0.5057445 82 -0.5098571 0.3545620 83 -0.4873175 -0.5098571 84 0.4860304 -0.4873175 85 -0.5160259 0.4860304 > 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/fisher/rcomp/tmp/7eltk1356028973.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/fisher/rcomp/tmp/8opj51356028973.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/fisher/rcomp/tmp/9919y1356028973.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/fisher/rcomp/tmp/10zxz21356028973.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/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/119cq21356028973.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/fisher/rcomp/tmp/12n0h81356028973.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/fisher/rcomp/tmp/1346tu1356028973.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/fisher/rcomp/tmp/14erfj1356028973.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/fisher/rcomp/tmp/15ums01356028973.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/fisher/rcomp/tmp/16n2uh1356028973.tab") + } > > try(system("convert tmp/1rq7i1356028973.ps tmp/1rq7i1356028973.png",intern=TRUE)) character(0) > try(system("convert tmp/27bv61356028973.ps tmp/27bv61356028973.png",intern=TRUE)) character(0) > try(system("convert tmp/3v1kh1356028973.ps tmp/3v1kh1356028973.png",intern=TRUE)) character(0) > try(system("convert tmp/4bfr21356028973.ps tmp/4bfr21356028973.png",intern=TRUE)) character(0) > try(system("convert tmp/5yn1s1356028973.ps tmp/5yn1s1356028973.png",intern=TRUE)) character(0) > try(system("convert tmp/65x9i1356028973.ps tmp/65x9i1356028973.png",intern=TRUE)) character(0) > try(system("convert tmp/7eltk1356028973.ps tmp/7eltk1356028973.png",intern=TRUE)) character(0) > try(system("convert tmp/8opj51356028973.ps tmp/8opj51356028973.png",intern=TRUE)) character(0) > try(system("convert tmp/9919y1356028973.ps tmp/9919y1356028973.png",intern=TRUE)) character(0) > try(system("convert tmp/10zxz21356028973.ps tmp/10zxz21356028973.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 6.828 1.781 8.632