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(95.26 + ,96.8 + ,94.76 + ,119.93 + ,101.21 + ,108.01 + ,117.96 + ,114.1 + ,95.26 + ,94.76 + ,119.93 + ,101.21 + ,115.86 + ,110.3 + ,117.96 + ,95.26 + ,94.76 + ,119.93 + ,111.44 + ,103.9 + ,115.86 + ,117.96 + ,95.26 + ,94.76 + ,108.16 + ,101.6 + ,111.44 + ,115.86 + ,117.96 + ,95.26 + ,108.77 + ,94.6 + ,108.16 + ,111.44 + ,115.86 + ,117.96 + ,109.45 + ,95.9 + ,108.77 + ,108.16 + ,111.44 + ,115.86 + ,124.83 + ,104.7 + ,109.45 + ,108.77 + ,108.16 + ,111.44 + ,115.31 + ,102.8 + ,124.83 + ,109.45 + ,108.77 + ,108.16 + ,109.49 + ,98.1 + ,115.31 + ,124.83 + ,109.45 + ,108.77 + ,124.24 + ,113.9 + ,109.49 + ,115.31 + ,124.83 + ,109.45 + ,92.85 + ,80.9 + ,124.24 + ,109.49 + ,115.31 + ,124.83 + ,98.42 + ,95.7 + ,92.85 + ,124.24 + ,109.49 + ,115.31 + ,120.88 + ,113.2 + ,98.42 + ,92.85 + ,124.24 + ,109.49 + ,111.72 + ,105.9 + ,120.88 + ,98.42 + ,92.85 + ,124.24 + ,116.1 + ,108.8 + ,111.72 + ,120.88 + ,98.42 + ,92.85 + ,109.37 + ,102.3 + ,116.1 + ,111.72 + ,120.88 + ,98.42 + ,111.65 + ,99 + ,109.37 + ,116.1 + ,111.72 + ,120.88 + ,114.29 + ,100.7 + ,111.65 + ,109.37 + ,116.1 + ,111.72 + ,133.68 + ,115.5 + ,114.29 + ,111.65 + ,109.37 + ,116.1 + ,114.27 + ,100.7 + ,133.68 + ,114.29 + ,111.65 + ,109.37 + ,126.49 + ,109.9 + ,114.27 + ,133.68 + ,114.29 + ,111.65 + ,131 + ,114.6 + ,126.49 + ,114.27 + ,133.68 + ,114.29 + ,104 + ,85.4 + ,131 + ,126.49 + ,114.27 + ,133.68 + ,108.88 + ,100.5 + ,104 + ,131 + ,126.49 + ,114.27 + ,128.48 + ,114.8 + ,108.88 + ,104 + ,131 + ,126.49 + ,132.44 + ,116.5 + ,128.48 + ,108.88 + ,104 + ,131 + ,128.04 + ,112.9 + ,132.44 + ,128.48 + ,108.88 + ,104 + ,116.35 + ,102 + ,128.04 + ,132.44 + ,128.48 + ,108.88 + ,120.93 + ,106 + ,116.35 + ,128.04 + ,132.44 + ,128.48 + ,118.59 + ,105.3 + ,120.93 + ,116.35 + ,128.04 + ,132.44 + ,133.1 + ,118.8 + ,118.59 + ,120.93 + ,116.35 + ,128.04 + ,121.05 + ,106.1 + ,133.1 + ,118.59 + ,120.93 + ,116.35 + ,127.62 + ,109.3 + ,121.05 + ,133.1 + ,118.59 + ,120.93 + ,135.44 + ,117.2 + ,127.62 + ,121.05 + ,133.1 + ,118.59 + ,114.88 + ,92.5 + ,135.44 + ,127.62 + ,121.05 + ,133.1 + ,114.34 + ,104.2 + ,114.88 + ,135.44 + ,127.62 + ,121.05 + ,128.85 + ,112.5 + ,114.34 + ,114.88 + ,135.44 + ,127.62 + ,138.9 + ,122.4 + ,128.85 + ,114.34 + ,114.88 + ,135.44 + ,129.44 + ,113.3 + ,138.9 + ,128.85 + ,114.34 + ,114.88 + ,114.96 + ,100 + ,129.44 + ,138.9 + ,128.85 + ,114.34 + ,127.98 + ,110.7 + ,114.96 + ,129.44 + ,138.9 + ,128.85 + ,127.03 + ,112.8 + ,127.98 + ,114.96 + ,129.44 + ,138.9 + ,128.75 + ,109.8 + ,127.03 + ,127.98 + ,114.96 + ,129.44 + ,137.91 + ,117.3 + ,128.75 + ,127.03 + ,127.98 + ,114.96 + ,128.37 + ,109.1 + ,137.91 + ,128.75 + ,127.03 + ,127.98 + ,135.9 + ,115.9 + ,128.37 + ,137.91 + ,128.75 + ,127.03 + ,122.19 + ,96 + ,135.9 + ,128.37 + ,137.91 + ,128.75 + ,113.08 + ,99.8 + ,122.19 + ,135.9 + ,128.37 + ,137.91 + ,136.2 + ,116.8 + ,113.08 + ,122.19 + ,135.9 + ,128.37 + ,138 + ,115.7 + ,136.2 + ,113.08 + ,122.19 + ,135.9 + ,115.24 + ,99.4 + ,138 + ,136.2 + ,113.08 + ,122.19 + ,110.95 + ,94.3 + ,115.24 + ,138 + ,136.2 + ,113.08 + ,99.23 + ,91 + ,110.95 + ,115.24 + ,138 + ,136.2 + ,102.39 + ,93.2 + ,99.23 + ,110.95 + ,115.24 + ,138 + ,112.67 + ,103.1 + ,102.39 + ,99.23 + ,110.95 + ,115.24) + ,dim=c(6 + ,56) + ,dimnames=list(c('Y' + ,'X' + ,'Y1' + ,'Y2' + ,'Y3' + ,'Y4') + ,1:56)) > y <- array(NA,dim=c(6,56),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),1:56)) > 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 Y1 Y2 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 1 95.26 96.8 94.76 119.93 101.21 108.01 1 0 0 0 0 0 0 0 0 0 0 2 117.96 114.1 95.26 94.76 119.93 101.21 0 1 0 0 0 0 0 0 0 0 0 3 115.86 110.3 117.96 95.26 94.76 119.93 0 0 1 0 0 0 0 0 0 0 0 4 111.44 103.9 115.86 117.96 95.26 94.76 0 0 0 1 0 0 0 0 0 0 0 5 108.16 101.6 111.44 115.86 117.96 95.26 0 0 0 0 1 0 0 0 0 0 0 6 108.77 94.6 108.16 111.44 115.86 117.96 0 0 0 0 0 1 0 0 0 0 0 7 109.45 95.9 108.77 108.16 111.44 115.86 0 0 0 0 0 0 1 0 0 0 0 8 124.83 104.7 109.45 108.77 108.16 111.44 0 0 0 0 0 0 0 1 0 0 0 9 115.31 102.8 124.83 109.45 108.77 108.16 0 0 0 0 0 0 0 0 1 0 0 10 109.49 98.1 115.31 124.83 109.45 108.77 0 0 0 0 0 0 0 0 0 1 0 11 124.24 113.9 109.49 115.31 124.83 109.45 0 0 0 0 0 0 0 0 0 0 1 12 92.85 80.9 124.24 109.49 115.31 124.83 0 0 0 0 0 0 0 0 0 0 0 13 98.42 95.7 92.85 124.24 109.49 115.31 1 0 0 0 0 0 0 0 0 0 0 14 120.88 113.2 98.42 92.85 124.24 109.49 0 1 0 0 0 0 0 0 0 0 0 15 111.72 105.9 120.88 98.42 92.85 124.24 0 0 1 0 0 0 0 0 0 0 0 16 116.10 108.8 111.72 120.88 98.42 92.85 0 0 0 1 0 0 0 0 0 0 0 17 109.37 102.3 116.10 111.72 120.88 98.42 0 0 0 0 1 0 0 0 0 0 0 18 111.65 99.0 109.37 116.10 111.72 120.88 0 0 0 0 0 1 0 0 0 0 0 19 114.29 100.7 111.65 109.37 116.10 111.72 0 0 0 0 0 0 1 0 0 0 0 20 133.68 115.5 114.29 111.65 109.37 116.10 0 0 0 0 0 0 0 1 0 0 0 21 114.27 100.7 133.68 114.29 111.65 109.37 0 0 0 0 0 0 0 0 1 0 0 22 126.49 109.9 114.27 133.68 114.29 111.65 0 0 0 0 0 0 0 0 0 1 0 23 131.00 114.6 126.49 114.27 133.68 114.29 0 0 0 0 0 0 0 0 0 0 1 24 104.00 85.4 131.00 126.49 114.27 133.68 0 0 0 0 0 0 0 0 0 0 0 25 108.88 100.5 104.00 131.00 126.49 114.27 1 0 0 0 0 0 0 0 0 0 0 26 128.48 114.8 108.88 104.00 131.00 126.49 0 1 0 0 0 0 0 0 0 0 0 27 132.44 116.5 128.48 108.88 104.00 131.00 0 0 1 0 0 0 0 0 0 0 0 28 128.04 112.9 132.44 128.48 108.88 104.00 0 0 0 1 0 0 0 0 0 0 0 29 116.35 102.0 128.04 132.44 128.48 108.88 0 0 0 0 1 0 0 0 0 0 0 30 120.93 106.0 116.35 128.04 132.44 128.48 0 0 0 0 0 1 0 0 0 0 0 31 118.59 105.3 120.93 116.35 128.04 132.44 0 0 0 0 0 0 1 0 0 0 0 32 133.10 118.8 118.59 120.93 116.35 128.04 0 0 0 0 0 0 0 1 0 0 0 33 121.05 106.1 133.10 118.59 120.93 116.35 0 0 0 0 0 0 0 0 1 0 0 34 127.62 109.3 121.05 133.10 118.59 120.93 0 0 0 0 0 0 0 0 0 1 0 35 135.44 117.2 127.62 121.05 133.10 118.59 0 0 0 0 0 0 0 0 0 0 1 36 114.88 92.5 135.44 127.62 121.05 133.10 0 0 0 0 0 0 0 0 0 0 0 37 114.34 104.2 114.88 135.44 127.62 121.05 1 0 0 0 0 0 0 0 0 0 0 38 128.85 112.5 114.34 114.88 135.44 127.62 0 1 0 0 0 0 0 0 0 0 0 39 138.90 122.4 128.85 114.34 114.88 135.44 0 0 1 0 0 0 0 0 0 0 0 40 129.44 113.3 138.90 128.85 114.34 114.88 0 0 0 1 0 0 0 0 0 0 0 41 114.96 100.0 129.44 138.90 128.85 114.34 0 0 0 0 1 0 0 0 0 0 0 42 127.98 110.7 114.96 129.44 138.90 128.85 0 0 0 0 0 1 0 0 0 0 0 43 127.03 112.8 127.98 114.96 129.44 138.90 0 0 0 0 0 0 1 0 0 0 0 44 128.75 109.8 127.03 127.98 114.96 129.44 0 0 0 0 0 0 0 1 0 0 0 45 137.91 117.3 128.75 127.03 127.98 114.96 0 0 0 0 0 0 0 0 1 0 0 46 128.37 109.1 137.91 128.75 127.03 127.98 0 0 0 0 0 0 0 0 0 1 0 47 135.90 115.9 128.37 137.91 128.75 127.03 0 0 0 0 0 0 0 0 0 0 1 48 122.19 96.0 135.90 128.37 137.91 128.75 0 0 0 0 0 0 0 0 0 0 0 49 113.08 99.8 122.19 135.90 128.37 137.91 1 0 0 0 0 0 0 0 0 0 0 50 136.20 116.8 113.08 122.19 135.90 128.37 0 1 0 0 0 0 0 0 0 0 0 51 138.00 115.7 136.20 113.08 122.19 135.90 0 0 1 0 0 0 0 0 0 0 0 52 115.24 99.4 138.00 136.20 113.08 122.19 0 0 0 1 0 0 0 0 0 0 0 53 110.95 94.3 115.24 138.00 136.20 113.08 0 0 0 0 1 0 0 0 0 0 0 54 99.23 91.0 110.95 115.24 138.00 136.20 0 0 0 0 0 1 0 0 0 0 0 55 102.39 93.2 99.23 110.95 115.24 138.00 0 0 0 0 0 0 1 0 0 0 0 56 112.67 103.1 102.39 99.23 110.95 115.24 0 0 0 0 0 0 0 1 0 0 0 t 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52 53 53 54 54 55 55 56 56 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X Y1 Y2 Y3 Y4 -40.08887 0.96554 0.21200 0.31498 0.15741 -0.17912 M1 M2 M3 M4 M5 M6 -10.63113 1.03583 3.24682 -8.72618 -11.38376 -2.30380 M7 M8 M9 M10 M11 t 0.54262 3.56311 -4.05011 -4.49687 -4.03470 0.01180 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -4.06872 -1.40714 -0.02654 1.24060 5.64215 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -40.08887 12.06175 -3.324 0.001975 ** X 0.96554 0.08652 11.160 1.48e-13 *** Y1 0.21200 0.07587 2.794 0.008105 ** Y2 0.31498 0.06896 4.567 5.08e-05 *** Y3 0.15741 0.09088 1.732 0.091377 . Y4 -0.17912 0.09768 -1.834 0.074529 . M1 -10.63113 2.61716 -4.062 0.000235 *** M2 1.03583 3.50009 0.296 0.768884 M3 3.24682 3.86879 0.839 0.406588 M4 -8.72618 3.68731 -2.367 0.023155 * M5 -11.38376 2.66567 -4.271 0.000126 *** M6 -2.30380 2.50076 -0.921 0.362736 M7 0.54262 2.58302 0.210 0.834734 M8 3.56311 3.19415 1.116 0.271637 M9 -4.05011 2.83430 -1.429 0.161184 M10 -4.49687 2.60726 -1.725 0.092699 . M11 -4.03470 2.83204 -1.425 0.162417 t 0.01180 0.05348 0.221 0.826536 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 2.495 on 38 degrees of freedom Multiple R-squared: 0.9673, Adjusted R-squared: 0.9527 F-statistic: 66.18 on 17 and 38 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.0886574 0.1773148 0.9113426 [2,] 0.4730560 0.9461120 0.5269440 [3,] 0.4080290 0.8160579 0.5919710 [4,] 0.3138280 0.6276559 0.6861720 [5,] 0.3373429 0.6746858 0.6626571 [6,] 0.3629823 0.7259646 0.6370177 [7,] 0.4306656 0.8613311 0.5693344 [8,] 0.3200595 0.6401190 0.6799405 [9,] 0.2711753 0.5423506 0.7288247 [10,] 0.7116316 0.5767368 0.2883684 [11,] 0.7654772 0.4690456 0.2345228 [12,] 0.8295407 0.3409185 0.1704593 [13,] 0.7122160 0.5755680 0.2877840 [14,] 0.5894221 0.8211559 0.4105779 [15,] 0.5177774 0.9644453 0.4822226 > postscript(file="/var/www/html/rcomp/tmp/1hxes1258660744.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/2g0xn1258660744.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/3s0s01258660744.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/4r8301258660744.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/5yqec1258660744.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 = 56 Frequency = 1 1 2 3 4 5 -1.9445355426 -3.9698968307 -2.2782190991 0.1503640797 -0.1483286908 6 7 8 9 10 4.6129066251 2.4028924923 5.6421522224 1.3998445145 -2.2710909680 11 12 13 14 15 -1.3173367519 -1.9313893064 1.1875238358 0.4138584897 -2.8531613419 16 17 18 19 20 -0.9440128289 0.6666601394 2.5533239881 -0.0001016305 2.6337606507 21 22 23 24 25 -1.3914269206 0.3808591878 0.8226512407 -0.3067129749 -0.4839918079 26 27 28 29 30 2.5788748603 2.0403963477 0.4599430353 -0.5855925923 -2.2078762332 31 32 33 34 35 -2.6171358239 -4.0687221135 -1.4089022458 1.6793001168 1.0970484437 36 37 38 39 40 1.1080058044 -1.4065574280 -0.0529784221 -0.0534527234 0.9354562585 41 42 43 44 45 -1.5979243937 -0.9344274322 -1.6802947449 -3.4107830412 1.4004846519 46 47 48 49 50 0.2109316634 -0.6023629325 1.1300964769 2.6475609427 1.0301419028 51 52 53 54 55 3.1444368167 -0.6017505446 1.6651855374 -4.0239269479 1.8946397070 56 -0.7964077184 > postscript(file="/var/www/html/rcomp/tmp/6s7gy1258660744.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 = 56 Frequency = 1 lag(myerror, k = 1) myerror 0 -1.9445355426 NA 1 -3.9698968307 -1.9445355426 2 -2.2782190991 -3.9698968307 3 0.1503640797 -2.2782190991 4 -0.1483286908 0.1503640797 5 4.6129066251 -0.1483286908 6 2.4028924923 4.6129066251 7 5.6421522224 2.4028924923 8 1.3998445145 5.6421522224 9 -2.2710909680 1.3998445145 10 -1.3173367519 -2.2710909680 11 -1.9313893064 -1.3173367519 12 1.1875238358 -1.9313893064 13 0.4138584897 1.1875238358 14 -2.8531613419 0.4138584897 15 -0.9440128289 -2.8531613419 16 0.6666601394 -0.9440128289 17 2.5533239881 0.6666601394 18 -0.0001016305 2.5533239881 19 2.6337606507 -0.0001016305 20 -1.3914269206 2.6337606507 21 0.3808591878 -1.3914269206 22 0.8226512407 0.3808591878 23 -0.3067129749 0.8226512407 24 -0.4839918079 -0.3067129749 25 2.5788748603 -0.4839918079 26 2.0403963477 2.5788748603 27 0.4599430353 2.0403963477 28 -0.5855925923 0.4599430353 29 -2.2078762332 -0.5855925923 30 -2.6171358239 -2.2078762332 31 -4.0687221135 -2.6171358239 32 -1.4089022458 -4.0687221135 33 1.6793001168 -1.4089022458 34 1.0970484437 1.6793001168 35 1.1080058044 1.0970484437 36 -1.4065574280 1.1080058044 37 -0.0529784221 -1.4065574280 38 -0.0534527234 -0.0529784221 39 0.9354562585 -0.0534527234 40 -1.5979243937 0.9354562585 41 -0.9344274322 -1.5979243937 42 -1.6802947449 -0.9344274322 43 -3.4107830412 -1.6802947449 44 1.4004846519 -3.4107830412 45 0.2109316634 1.4004846519 46 -0.6023629325 0.2109316634 47 1.1300964769 -0.6023629325 48 2.6475609427 1.1300964769 49 1.0301419028 2.6475609427 50 3.1444368167 1.0301419028 51 -0.6017505446 3.1444368167 52 1.6651855374 -0.6017505446 53 -4.0239269479 1.6651855374 54 1.8946397070 -4.0239269479 55 -0.7964077184 1.8946397070 56 NA -0.7964077184 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -3.9698968307 -1.9445355426 [2,] -2.2782190991 -3.9698968307 [3,] 0.1503640797 -2.2782190991 [4,] -0.1483286908 0.1503640797 [5,] 4.6129066251 -0.1483286908 [6,] 2.4028924923 4.6129066251 [7,] 5.6421522224 2.4028924923 [8,] 1.3998445145 5.6421522224 [9,] -2.2710909680 1.3998445145 [10,] -1.3173367519 -2.2710909680 [11,] -1.9313893064 -1.3173367519 [12,] 1.1875238358 -1.9313893064 [13,] 0.4138584897 1.1875238358 [14,] -2.8531613419 0.4138584897 [15,] -0.9440128289 -2.8531613419 [16,] 0.6666601394 -0.9440128289 [17,] 2.5533239881 0.6666601394 [18,] -0.0001016305 2.5533239881 [19,] 2.6337606507 -0.0001016305 [20,] -1.3914269206 2.6337606507 [21,] 0.3808591878 -1.3914269206 [22,] 0.8226512407 0.3808591878 [23,] -0.3067129749 0.8226512407 [24,] -0.4839918079 -0.3067129749 [25,] 2.5788748603 -0.4839918079 [26,] 2.0403963477 2.5788748603 [27,] 0.4599430353 2.0403963477 [28,] -0.5855925923 0.4599430353 [29,] -2.2078762332 -0.5855925923 [30,] -2.6171358239 -2.2078762332 [31,] -4.0687221135 -2.6171358239 [32,] -1.4089022458 -4.0687221135 [33,] 1.6793001168 -1.4089022458 [34,] 1.0970484437 1.6793001168 [35,] 1.1080058044 1.0970484437 [36,] -1.4065574280 1.1080058044 [37,] -0.0529784221 -1.4065574280 [38,] -0.0534527234 -0.0529784221 [39,] 0.9354562585 -0.0534527234 [40,] -1.5979243937 0.9354562585 [41,] -0.9344274322 -1.5979243937 [42,] -1.6802947449 -0.9344274322 [43,] -3.4107830412 -1.6802947449 [44,] 1.4004846519 -3.4107830412 [45,] 0.2109316634 1.4004846519 [46,] -0.6023629325 0.2109316634 [47,] 1.1300964769 -0.6023629325 [48,] 2.6475609427 1.1300964769 [49,] 1.0301419028 2.6475609427 [50,] 3.1444368167 1.0301419028 [51,] -0.6017505446 3.1444368167 [52,] 1.6651855374 -0.6017505446 [53,] -4.0239269479 1.6651855374 [54,] 1.8946397070 -4.0239269479 [55,] -0.7964077184 1.8946397070 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -3.9698968307 -1.9445355426 2 -2.2782190991 -3.9698968307 3 0.1503640797 -2.2782190991 4 -0.1483286908 0.1503640797 5 4.6129066251 -0.1483286908 6 2.4028924923 4.6129066251 7 5.6421522224 2.4028924923 8 1.3998445145 5.6421522224 9 -2.2710909680 1.3998445145 10 -1.3173367519 -2.2710909680 11 -1.9313893064 -1.3173367519 12 1.1875238358 -1.9313893064 13 0.4138584897 1.1875238358 14 -2.8531613419 0.4138584897 15 -0.9440128289 -2.8531613419 16 0.6666601394 -0.9440128289 17 2.5533239881 0.6666601394 18 -0.0001016305 2.5533239881 19 2.6337606507 -0.0001016305 20 -1.3914269206 2.6337606507 21 0.3808591878 -1.3914269206 22 0.8226512407 0.3808591878 23 -0.3067129749 0.8226512407 24 -0.4839918079 -0.3067129749 25 2.5788748603 -0.4839918079 26 2.0403963477 2.5788748603 27 0.4599430353 2.0403963477 28 -0.5855925923 0.4599430353 29 -2.2078762332 -0.5855925923 30 -2.6171358239 -2.2078762332 31 -4.0687221135 -2.6171358239 32 -1.4089022458 -4.0687221135 33 1.6793001168 -1.4089022458 34 1.0970484437 1.6793001168 35 1.1080058044 1.0970484437 36 -1.4065574280 1.1080058044 37 -0.0529784221 -1.4065574280 38 -0.0534527234 -0.0529784221 39 0.9354562585 -0.0534527234 40 -1.5979243937 0.9354562585 41 -0.9344274322 -1.5979243937 42 -1.6802947449 -0.9344274322 43 -3.4107830412 -1.6802947449 44 1.4004846519 -3.4107830412 45 0.2109316634 1.4004846519 46 -0.6023629325 0.2109316634 47 1.1300964769 -0.6023629325 48 2.6475609427 1.1300964769 49 1.0301419028 2.6475609427 50 3.1444368167 1.0301419028 51 -0.6017505446 3.1444368167 52 1.6651855374 -0.6017505446 53 -4.0239269479 1.6651855374 54 1.8946397070 -4.0239269479 55 -0.7964077184 1.8946397070 > 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/7hre21258660744.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/8q1wb1258660744.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/9scf41258660744.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/107bfq1258660744.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/11z3l31258660744.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/12zp671258660744.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/130yvl1258660744.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/143ggm1258660744.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/153uqu1258660744.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/16vj7o1258660744.tab") + } > > system("convert tmp/1hxes1258660744.ps tmp/1hxes1258660744.png") > system("convert tmp/2g0xn1258660744.ps tmp/2g0xn1258660744.png") > system("convert tmp/3s0s01258660744.ps tmp/3s0s01258660744.png") > system("convert tmp/4r8301258660744.ps tmp/4r8301258660744.png") > system("convert tmp/5yqec1258660744.ps tmp/5yqec1258660744.png") > system("convert tmp/6s7gy1258660744.ps tmp/6s7gy1258660744.png") > system("convert tmp/7hre21258660744.ps tmp/7hre21258660744.png") > system("convert tmp/8q1wb1258660744.ps tmp/8q1wb1258660744.png") > system("convert tmp/9scf41258660744.ps tmp/9scf41258660744.png") > system("convert tmp/107bfq1258660744.ps tmp/107bfq1258660744.png") > > > proc.time() user system elapsed 2.351 1.563 2.729