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 = 'Include Monthly Dummies' > par1 = '4' > par3 <- 'Linear Trend' > par2 <- 'Include Monthly 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)) +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 0 0 0 0 0 0 0 0 0 0 1 59 60 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 60 61 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 61 62 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 62 63 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 63 64 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 64 65 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 65 66 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 66 67 0 1 1 1 0 0 0 0 0 0 1 0 0 0 0 67 68 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 68 69 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 69 70 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 70 71 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 71 72 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 72 73 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 73 74 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 74 75 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 75 76 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 76 77 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 77 78 1 0 0 1 0 0 0 0 0 1 0 0 0 0 0 78 79 1 1 1 1 0 0 0 0 0 0 1 0 0 0 0 79 80 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 80 81 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 81 82 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 82 83 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 83 84 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 84 85 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 85 86 0 0 0 0 0 1 0 0 0 0 0 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 M1 M2 0.478652 0.064777 -0.227074 0.141564 0.071468 -0.531489 M3 M4 M5 M6 M7 M8 -0.044637 -0.214543 0.015743 -0.182026 -0.140866 -0.346173 M9 M10 M11 t -0.171511 0.062253 -0.307897 0.002249 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -0.8399 -0.3967 -0.1001 0.4118 0.8433 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.478652 0.224046 2.136 0.0361 * Treatment 0.064777 0.156564 0.414 0.6803 CA -0.227074 0.249830 -0.909 0.3665 Used 0.141564 0.149502 0.947 0.3469 M1 0.071468 0.288905 0.247 0.8053 M2 -0.531489 0.278768 -1.907 0.0607 . M3 -0.044637 0.281240 -0.159 0.8744 M4 -0.214543 0.293979 -0.730 0.4680 M5 0.015743 0.272323 0.058 0.9541 M6 -0.182026 0.276712 -0.658 0.5128 M7 -0.140866 0.272898 -0.516 0.6074 M8 -0.346173 0.291651 -1.187 0.2393 M9 -0.171511 0.277978 -0.617 0.5392 M10 0.062253 0.284690 0.219 0.8275 M11 -0.307897 0.278441 -1.106 0.2726 t 0.002249 0.002268 0.992 0.3247 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.5086 on 70 degrees of freedom Multiple R-squared: 0.1537, Adjusted R-squared: -0.02768 F-statistic: 0.8474 on 15 and 70 DF, p-value: 0.6232 > 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.9476996 0.1046007 0.05230035 [2,] 0.9473902 0.1052196 0.05260978 [3,] 0.9314093 0.1371813 0.06859066 [4,] 0.9019550 0.1960899 0.09804497 [5,] 0.9386284 0.1227433 0.06137164 [6,] 0.9351436 0.1297128 0.06485638 [7,] 0.8978192 0.2043617 0.10218085 [8,] 0.8718131 0.2563738 0.12818692 [9,] 0.8368997 0.3262007 0.16310035 [10,] 0.8459778 0.3080444 0.15402221 [11,] 0.8382883 0.3234235 0.16171175 [12,] 0.8380557 0.3238887 0.16194435 [13,] 0.8324492 0.3351015 0.16755076 [14,] 0.7951146 0.4097708 0.20488540 [15,] 0.7712976 0.4574048 0.22870239 [16,] 0.7248829 0.5502343 0.27511713 [17,] 0.6792548 0.6414903 0.32074517 [18,] 0.6898284 0.6203432 0.31017160 [19,] 0.7839528 0.4320943 0.21604717 [20,] 0.8272400 0.3455200 0.17276002 [21,] 0.8181703 0.3636595 0.18182974 [22,] 0.8169726 0.3660548 0.18302739 [23,] 0.8194381 0.3611238 0.18056188 [24,] 0.7840590 0.4318819 0.21594095 [25,] 0.7710452 0.4579095 0.22895475 [26,] 0.7284213 0.5431575 0.27157874 [27,] 0.7159389 0.5681222 0.28406111 [28,] 0.6734345 0.6531310 0.32656552 [29,] 0.6267238 0.7465524 0.37327622 [30,] 0.5775035 0.8449930 0.42249649 [31,] 0.5220259 0.9559483 0.47797414 [32,] 0.4525636 0.9051272 0.54743641 [33,] 0.5909842 0.8180316 0.40901578 [34,] 0.5718297 0.8563406 0.42817032 [35,] 0.5359599 0.9280802 0.46404010 [36,] 0.4828118 0.9656235 0.51718824 [37,] 0.4617261 0.9234523 0.53827387 [38,] 0.4306109 0.8612217 0.56938913 [39,] 0.3691674 0.7383349 0.63083257 [40,] 0.3668102 0.7336204 0.63318980 [41,] 0.5353882 0.9292235 0.46461176 [42,] 0.6126549 0.7746902 0.38734512 [43,] 0.6228313 0.7543375 0.37716874 [44,] 0.5596729 0.8806541 0.44032706 [45,] 0.5278585 0.9442831 0.47214153 [46,] 0.4594944 0.9189887 0.54050563 [47,] 0.4209768 0.8419536 0.57902318 [48,] 0.3103509 0.6207019 0.68964907 [49,] 0.3205587 0.6411174 0.67944132 > postscript(file="/var/fisher/rcomp/tmp/161ds1356038450.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/24ki71356038450.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/31tkh1356038450.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/4w7xv1356038450.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/589q01356038450.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 0.38285339 0.04833894 -0.44076235 -0.27310557 -0.50564072 0.68987908 7 8 9 10 11 12 -0.35352973 -0.21524876 0.67261750 -0.56339602 -0.26027185 -0.50564072 13 14 15 16 17 18 -0.72092247 -0.04342642 0.39068492 0.49356483 -0.51189602 -0.40188628 19 20 21 22 23 24 0.61948178 0.84327281 -0.35437099 0.26805124 0.77751653 0.46737080 25 26 27 28 29 30 0.18731218 -0.14720228 0.50526068 -0.46864679 0.44038231 -0.36409790 31 32 33 34 35 36 -0.40750671 -0.20444887 -0.38135948 0.31785013 -0.24947196 -0.55961769 37 38 39 40 41 42 -0.83967631 0.82580923 0.47827219 -0.41884790 0.49890388 0.46734937 43 44 45 46 47 48 0.56550480 -0.29621422 -0.40834797 0.35563851 -0.27646045 0.41339382 49 50 51 52 53 54 0.33967631 -0.05961501 -0.75505740 -0.36032633 0.38640534 -0.33256482 55 56 57 58 59 60 -0.46148368 0.53523305 0.42309930 0.32865003 0.69655107 0.40713852 61 62 63 64 65 66 0.24791096 -0.22816774 -0.57570478 0.52717513 -0.64058315 -0.44506336 67 68 69 70 71 72 -0.46773898 -0.28541433 0.53767506 -0.83990270 -0.33043742 0.35941685 73 74 75 76 77 78 0.14413509 -0.25515623 0.39730673 0.50018664 0.33242836 0.38638391 79 80 81 82 83 84 0.50527253 -0.37717968 -0.48931343 0.13310881 -0.35742591 -0.58206158 85 86 0.25871085 -0.14058047 > postscript(file="/var/fisher/rcomp/tmp/6jceq1356038450.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.38285339 NA 1 0.04833894 0.38285339 2 -0.44076235 0.04833894 3 -0.27310557 -0.44076235 4 -0.50564072 -0.27310557 5 0.68987908 -0.50564072 6 -0.35352973 0.68987908 7 -0.21524876 -0.35352973 8 0.67261750 -0.21524876 9 -0.56339602 0.67261750 10 -0.26027185 -0.56339602 11 -0.50564072 -0.26027185 12 -0.72092247 -0.50564072 13 -0.04342642 -0.72092247 14 0.39068492 -0.04342642 15 0.49356483 0.39068492 16 -0.51189602 0.49356483 17 -0.40188628 -0.51189602 18 0.61948178 -0.40188628 19 0.84327281 0.61948178 20 -0.35437099 0.84327281 21 0.26805124 -0.35437099 22 0.77751653 0.26805124 23 0.46737080 0.77751653 24 0.18731218 0.46737080 25 -0.14720228 0.18731218 26 0.50526068 -0.14720228 27 -0.46864679 0.50526068 28 0.44038231 -0.46864679 29 -0.36409790 0.44038231 30 -0.40750671 -0.36409790 31 -0.20444887 -0.40750671 32 -0.38135948 -0.20444887 33 0.31785013 -0.38135948 34 -0.24947196 0.31785013 35 -0.55961769 -0.24947196 36 -0.83967631 -0.55961769 37 0.82580923 -0.83967631 38 0.47827219 0.82580923 39 -0.41884790 0.47827219 40 0.49890388 -0.41884790 41 0.46734937 0.49890388 42 0.56550480 0.46734937 43 -0.29621422 0.56550480 44 -0.40834797 -0.29621422 45 0.35563851 -0.40834797 46 -0.27646045 0.35563851 47 0.41339382 -0.27646045 48 0.33967631 0.41339382 49 -0.05961501 0.33967631 50 -0.75505740 -0.05961501 51 -0.36032633 -0.75505740 52 0.38640534 -0.36032633 53 -0.33256482 0.38640534 54 -0.46148368 -0.33256482 55 0.53523305 -0.46148368 56 0.42309930 0.53523305 57 0.32865003 0.42309930 58 0.69655107 0.32865003 59 0.40713852 0.69655107 60 0.24791096 0.40713852 61 -0.22816774 0.24791096 62 -0.57570478 -0.22816774 63 0.52717513 -0.57570478 64 -0.64058315 0.52717513 65 -0.44506336 -0.64058315 66 -0.46773898 -0.44506336 67 -0.28541433 -0.46773898 68 0.53767506 -0.28541433 69 -0.83990270 0.53767506 70 -0.33043742 -0.83990270 71 0.35941685 -0.33043742 72 0.14413509 0.35941685 73 -0.25515623 0.14413509 74 0.39730673 -0.25515623 75 0.50018664 0.39730673 76 0.33242836 0.50018664 77 0.38638391 0.33242836 78 0.50527253 0.38638391 79 -0.37717968 0.50527253 80 -0.48931343 -0.37717968 81 0.13310881 -0.48931343 82 -0.35742591 0.13310881 83 -0.58206158 -0.35742591 84 0.25871085 -0.58206158 85 -0.14058047 0.25871085 86 NA -0.14058047 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 0.04833894 0.38285339 [2,] -0.44076235 0.04833894 [3,] -0.27310557 -0.44076235 [4,] -0.50564072 -0.27310557 [5,] 0.68987908 -0.50564072 [6,] -0.35352973 0.68987908 [7,] -0.21524876 -0.35352973 [8,] 0.67261750 -0.21524876 [9,] -0.56339602 0.67261750 [10,] -0.26027185 -0.56339602 [11,] -0.50564072 -0.26027185 [12,] -0.72092247 -0.50564072 [13,] -0.04342642 -0.72092247 [14,] 0.39068492 -0.04342642 [15,] 0.49356483 0.39068492 [16,] -0.51189602 0.49356483 [17,] -0.40188628 -0.51189602 [18,] 0.61948178 -0.40188628 [19,] 0.84327281 0.61948178 [20,] -0.35437099 0.84327281 [21,] 0.26805124 -0.35437099 [22,] 0.77751653 0.26805124 [23,] 0.46737080 0.77751653 [24,] 0.18731218 0.46737080 [25,] -0.14720228 0.18731218 [26,] 0.50526068 -0.14720228 [27,] -0.46864679 0.50526068 [28,] 0.44038231 -0.46864679 [29,] -0.36409790 0.44038231 [30,] -0.40750671 -0.36409790 [31,] -0.20444887 -0.40750671 [32,] -0.38135948 -0.20444887 [33,] 0.31785013 -0.38135948 [34,] -0.24947196 0.31785013 [35,] -0.55961769 -0.24947196 [36,] -0.83967631 -0.55961769 [37,] 0.82580923 -0.83967631 [38,] 0.47827219 0.82580923 [39,] -0.41884790 0.47827219 [40,] 0.49890388 -0.41884790 [41,] 0.46734937 0.49890388 [42,] 0.56550480 0.46734937 [43,] -0.29621422 0.56550480 [44,] -0.40834797 -0.29621422 [45,] 0.35563851 -0.40834797 [46,] -0.27646045 0.35563851 [47,] 0.41339382 -0.27646045 [48,] 0.33967631 0.41339382 [49,] -0.05961501 0.33967631 [50,] -0.75505740 -0.05961501 [51,] -0.36032633 -0.75505740 [52,] 0.38640534 -0.36032633 [53,] -0.33256482 0.38640534 [54,] -0.46148368 -0.33256482 [55,] 0.53523305 -0.46148368 [56,] 0.42309930 0.53523305 [57,] 0.32865003 0.42309930 [58,] 0.69655107 0.32865003 [59,] 0.40713852 0.69655107 [60,] 0.24791096 0.40713852 [61,] -0.22816774 0.24791096 [62,] -0.57570478 -0.22816774 [63,] 0.52717513 -0.57570478 [64,] -0.64058315 0.52717513 [65,] -0.44506336 -0.64058315 [66,] -0.46773898 -0.44506336 [67,] -0.28541433 -0.46773898 [68,] 0.53767506 -0.28541433 [69,] -0.83990270 0.53767506 [70,] -0.33043742 -0.83990270 [71,] 0.35941685 -0.33043742 [72,] 0.14413509 0.35941685 [73,] -0.25515623 0.14413509 [74,] 0.39730673 -0.25515623 [75,] 0.50018664 0.39730673 [76,] 0.33242836 0.50018664 [77,] 0.38638391 0.33242836 [78,] 0.50527253 0.38638391 [79,] -0.37717968 0.50527253 [80,] -0.48931343 -0.37717968 [81,] 0.13310881 -0.48931343 [82,] -0.35742591 0.13310881 [83,] -0.58206158 -0.35742591 [84,] 0.25871085 -0.58206158 [85,] -0.14058047 0.25871085 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 0.04833894 0.38285339 2 -0.44076235 0.04833894 3 -0.27310557 -0.44076235 4 -0.50564072 -0.27310557 5 0.68987908 -0.50564072 6 -0.35352973 0.68987908 7 -0.21524876 -0.35352973 8 0.67261750 -0.21524876 9 -0.56339602 0.67261750 10 -0.26027185 -0.56339602 11 -0.50564072 -0.26027185 12 -0.72092247 -0.50564072 13 -0.04342642 -0.72092247 14 0.39068492 -0.04342642 15 0.49356483 0.39068492 16 -0.51189602 0.49356483 17 -0.40188628 -0.51189602 18 0.61948178 -0.40188628 19 0.84327281 0.61948178 20 -0.35437099 0.84327281 21 0.26805124 -0.35437099 22 0.77751653 0.26805124 23 0.46737080 0.77751653 24 0.18731218 0.46737080 25 -0.14720228 0.18731218 26 0.50526068 -0.14720228 27 -0.46864679 0.50526068 28 0.44038231 -0.46864679 29 -0.36409790 0.44038231 30 -0.40750671 -0.36409790 31 -0.20444887 -0.40750671 32 -0.38135948 -0.20444887 33 0.31785013 -0.38135948 34 -0.24947196 0.31785013 35 -0.55961769 -0.24947196 36 -0.83967631 -0.55961769 37 0.82580923 -0.83967631 38 0.47827219 0.82580923 39 -0.41884790 0.47827219 40 0.49890388 -0.41884790 41 0.46734937 0.49890388 42 0.56550480 0.46734937 43 -0.29621422 0.56550480 44 -0.40834797 -0.29621422 45 0.35563851 -0.40834797 46 -0.27646045 0.35563851 47 0.41339382 -0.27646045 48 0.33967631 0.41339382 49 -0.05961501 0.33967631 50 -0.75505740 -0.05961501 51 -0.36032633 -0.75505740 52 0.38640534 -0.36032633 53 -0.33256482 0.38640534 54 -0.46148368 -0.33256482 55 0.53523305 -0.46148368 56 0.42309930 0.53523305 57 0.32865003 0.42309930 58 0.69655107 0.32865003 59 0.40713852 0.69655107 60 0.24791096 0.40713852 61 -0.22816774 0.24791096 62 -0.57570478 -0.22816774 63 0.52717513 -0.57570478 64 -0.64058315 0.52717513 65 -0.44506336 -0.64058315 66 -0.46773898 -0.44506336 67 -0.28541433 -0.46773898 68 0.53767506 -0.28541433 69 -0.83990270 0.53767506 70 -0.33043742 -0.83990270 71 0.35941685 -0.33043742 72 0.14413509 0.35941685 73 -0.25515623 0.14413509 74 0.39730673 -0.25515623 75 0.50018664 0.39730673 76 0.33242836 0.50018664 77 0.38638391 0.33242836 78 0.50527253 0.38638391 79 -0.37717968 0.50527253 80 -0.48931343 -0.37717968 81 0.13310881 -0.48931343 82 -0.35742591 0.13310881 83 -0.58206158 -0.35742591 84 0.25871085 -0.58206158 85 -0.14058047 0.25871085 > 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/73nc71356038450.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/8xt411356038450.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/9rcn41356038450.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/10rpxq1356038450.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/11y7ux1356038450.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/12zzm91356038450.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/13dukp1356038450.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/14j0a11356038450.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/15p3in1356038450.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/16nf311356038450.tab") + } > > try(system("convert tmp/161ds1356038450.ps tmp/161ds1356038450.png",intern=TRUE)) character(0) > try(system("convert tmp/24ki71356038450.ps tmp/24ki71356038450.png",intern=TRUE)) character(0) > try(system("convert tmp/31tkh1356038450.ps tmp/31tkh1356038450.png",intern=TRUE)) character(0) > try(system("convert tmp/4w7xv1356038450.ps tmp/4w7xv1356038450.png",intern=TRUE)) character(0) > try(system("convert tmp/589q01356038450.ps tmp/589q01356038450.png",intern=TRUE)) character(0) > try(system("convert tmp/6jceq1356038450.ps tmp/6jceq1356038450.png",intern=TRUE)) character(0) > try(system("convert tmp/73nc71356038450.ps tmp/73nc71356038450.png",intern=TRUE)) character(0) > try(system("convert tmp/8xt411356038450.ps tmp/8xt411356038450.png",intern=TRUE)) character(0) > try(system("convert tmp/9rcn41356038450.ps tmp/9rcn41356038450.png",intern=TRUE)) character(0) > try(system("convert tmp/10rpxq1356038450.ps tmp/10rpxq1356038450.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 6.538 1.754 8.291