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(101.6 + ,8.3 + ,103.9 + ,110.3 + ,114.1 + ,96.8 + ,94.6 + ,8.5 + ,101.6 + ,103.9 + ,110.3 + ,114.1 + ,95.9 + ,8.6 + ,94.6 + ,101.6 + ,103.9 + ,110.3 + ,104.7 + ,8.5 + ,95.9 + ,94.6 + ,101.6 + ,103.9 + ,102.8 + ,8.2 + ,104.7 + ,95.9 + ,94.6 + ,101.6 + ,98.1 + ,8.1 + ,102.8 + ,104.7 + ,95.9 + ,94.6 + ,113.9 + ,7.9 + ,98.1 + ,102.8 + ,104.7 + ,95.9 + ,80.9 + ,8.6 + ,113.9 + ,98.1 + ,102.8 + ,104.7 + ,95.7 + ,8.7 + ,80.9 + ,113.9 + ,98.1 + ,102.8 + ,113.2 + ,8.7 + ,95.7 + ,80.9 + ,113.9 + ,98.1 + ,105.9 + ,8.5 + ,113.2 + ,95.7 + ,80.9 + ,113.9 + ,108.8 + ,8.4 + ,105.9 + ,113.2 + ,95.7 + ,80.9 + ,102.3 + ,8.5 + ,108.8 + ,105.9 + ,113.2 + ,95.7 + ,99 + ,8.7 + ,102.3 + ,108.8 + ,105.9 + ,113.2 + ,100.7 + ,8.7 + ,99 + ,102.3 + ,108.8 + ,105.9 + ,115.5 + ,8.6 + ,100.7 + ,99 + ,102.3 + ,108.8 + ,100.7 + ,8.5 + ,115.5 + ,100.7 + ,99 + ,102.3 + ,109.9 + ,8.3 + ,100.7 + ,115.5 + ,100.7 + ,99 + ,114.6 + ,8 + ,109.9 + ,100.7 + ,115.5 + ,100.7 + ,85.4 + ,8.2 + ,114.6 + ,109.9 + ,100.7 + ,115.5 + ,100.5 + ,8.1 + ,85.4 + ,114.6 + ,109.9 + ,100.7 + ,114.8 + ,8.1 + ,100.5 + ,85.4 + ,114.6 + ,109.9 + ,116.5 + ,8 + ,114.8 + ,100.5 + ,85.4 + ,114.6 + ,112.9 + ,7.9 + ,116.5 + ,114.8 + ,100.5 + ,85.4 + ,102 + ,7.9 + ,112.9 + ,116.5 + ,114.8 + ,100.5 + ,106 + ,8 + ,102 + ,112.9 + ,116.5 + ,114.8 + ,105.3 + ,8 + ,106 + ,102 + ,112.9 + ,116.5 + ,118.8 + ,7.9 + ,105.3 + ,106 + ,102 + ,112.9 + ,106.1 + ,8 + ,118.8 + ,105.3 + ,106 + ,102 + ,109.3 + ,7.7 + ,106.1 + ,118.8 + ,105.3 + ,106 + ,117.2 + ,7.2 + ,109.3 + ,106.1 + ,118.8 + ,105.3 + ,92.5 + ,7.5 + ,117.2 + ,109.3 + ,106.1 + ,118.8 + ,104.2 + ,7.3 + ,92.5 + ,117.2 + ,109.3 + ,106.1 + ,112.5 + ,7 + ,104.2 + ,92.5 + ,117.2 + ,109.3 + ,122.4 + ,7 + ,112.5 + ,104.2 + ,92.5 + ,117.2 + ,113.3 + ,7 + ,122.4 + ,112.5 + ,104.2 + ,92.5 + ,100 + ,7.2 + ,113.3 + ,122.4 + ,112.5 + ,104.2 + ,110.7 + ,7.3 + ,100 + ,113.3 + ,122.4 + ,112.5 + ,112.8 + ,7.1 + ,110.7 + ,100 + ,113.3 + ,122.4 + ,109.8 + ,6.8 + ,112.8 + ,110.7 + ,100 + ,113.3 + ,117.3 + ,6.4 + ,109.8 + ,112.8 + ,110.7 + ,100 + ,109.1 + ,6.1 + ,117.3 + ,109.8 + ,112.8 + ,110.7 + ,115.9 + ,6.5 + ,109.1 + ,117.3 + ,109.8 + ,112.8 + ,96 + ,7.7 + ,115.9 + ,109.1 + ,117.3 + ,109.8 + ,99.8 + ,7.9 + ,96 + ,115.9 + ,109.1 + ,117.3 + ,116.8 + ,7.5 + ,99.8 + ,96 + ,115.9 + ,109.1 + ,115.7 + ,6.9 + ,116.8 + ,99.8 + ,96 + ,115.9 + ,99.4 + ,6.6 + ,115.7 + ,116.8 + ,99.8 + ,96 + ,94.3 + ,6.9 + ,99.4 + ,115.7 + ,116.8 + ,99.8 + ,91 + ,7.7 + ,94.3 + ,99.4 + ,115.7 + ,116.8 + ,93.2 + ,8 + ,91 + ,94.3 + ,99.4 + ,115.7 + ,103.1 + ,8 + ,93.2 + ,91 + ,94.3 + ,99.4 + ,94.1 + ,7.7 + ,103.1 + ,93.2 + ,91 + ,94.3 + ,91.8 + ,7.3 + ,94.1 + ,103.1 + ,93.2 + ,91 + ,102.7 + ,7.4 + ,91.8 + ,94.1 + ,103.1 + ,93.2 + ,82.6 + ,8.1 + ,102.7 + ,91.8 + ,94.1 + ,103.1 + ,89.1 + ,8.3 + ,82.6 + ,102.7 + ,91.8 + ,94.1) + ,dim=c(6 + ,57) + ,dimnames=list(c('Y' + ,'X' + ,'Y1' + ,'Y2' + ,'Y3' + ,'Y4') + ,1:57)) > y <- array(NA,dim=c(6,57),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),1:57)) > 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 t 1 101.6 8.3 103.9 110.3 114.1 96.8 1 0 0 0 0 0 0 0 0 0 0 1 2 94.6 8.5 101.6 103.9 110.3 114.1 0 1 0 0 0 0 0 0 0 0 0 2 3 95.9 8.6 94.6 101.6 103.9 110.3 0 0 1 0 0 0 0 0 0 0 0 3 4 104.7 8.5 95.9 94.6 101.6 103.9 0 0 0 1 0 0 0 0 0 0 0 4 5 102.8 8.2 104.7 95.9 94.6 101.6 0 0 0 0 1 0 0 0 0 0 0 5 6 98.1 8.1 102.8 104.7 95.9 94.6 0 0 0 0 0 1 0 0 0 0 0 6 7 113.9 7.9 98.1 102.8 104.7 95.9 0 0 0 0 0 0 1 0 0 0 0 7 8 80.9 8.6 113.9 98.1 102.8 104.7 0 0 0 0 0 0 0 1 0 0 0 8 9 95.7 8.7 80.9 113.9 98.1 102.8 0 0 0 0 0 0 0 0 1 0 0 9 10 113.2 8.7 95.7 80.9 113.9 98.1 0 0 0 0 0 0 0 0 0 1 0 10 11 105.9 8.5 113.2 95.7 80.9 113.9 0 0 0 0 0 0 0 0 0 0 1 11 12 108.8 8.4 105.9 113.2 95.7 80.9 0 0 0 0 0 0 0 0 0 0 0 12 13 102.3 8.5 108.8 105.9 113.2 95.7 1 0 0 0 0 0 0 0 0 0 0 13 14 99.0 8.7 102.3 108.8 105.9 113.2 0 1 0 0 0 0 0 0 0 0 0 14 15 100.7 8.7 99.0 102.3 108.8 105.9 0 0 1 0 0 0 0 0 0 0 0 15 16 115.5 8.6 100.7 99.0 102.3 108.8 0 0 0 1 0 0 0 0 0 0 0 16 17 100.7 8.5 115.5 100.7 99.0 102.3 0 0 0 0 1 0 0 0 0 0 0 17 18 109.9 8.3 100.7 115.5 100.7 99.0 0 0 0 0 0 1 0 0 0 0 0 18 19 114.6 8.0 109.9 100.7 115.5 100.7 0 0 0 0 0 0 1 0 0 0 0 19 20 85.4 8.2 114.6 109.9 100.7 115.5 0 0 0 0 0 0 0 1 0 0 0 20 21 100.5 8.1 85.4 114.6 109.9 100.7 0 0 0 0 0 0 0 0 1 0 0 21 22 114.8 8.1 100.5 85.4 114.6 109.9 0 0 0 0 0 0 0 0 0 1 0 22 23 116.5 8.0 114.8 100.5 85.4 114.6 0 0 0 0 0 0 0 0 0 0 1 23 24 112.9 7.9 116.5 114.8 100.5 85.4 0 0 0 0 0 0 0 0 0 0 0 24 25 102.0 7.9 112.9 116.5 114.8 100.5 1 0 0 0 0 0 0 0 0 0 0 25 26 106.0 8.0 102.0 112.9 116.5 114.8 0 1 0 0 0 0 0 0 0 0 0 26 27 105.3 8.0 106.0 102.0 112.9 116.5 0 0 1 0 0 0 0 0 0 0 0 27 28 118.8 7.9 105.3 106.0 102.0 112.9 0 0 0 1 0 0 0 0 0 0 0 28 29 106.1 8.0 118.8 105.3 106.0 102.0 0 0 0 0 1 0 0 0 0 0 0 29 30 109.3 7.7 106.1 118.8 105.3 106.0 0 0 0 0 0 1 0 0 0 0 0 30 31 117.2 7.2 109.3 106.1 118.8 105.3 0 0 0 0 0 0 1 0 0 0 0 31 32 92.5 7.5 117.2 109.3 106.1 118.8 0 0 0 0 0 0 0 1 0 0 0 32 33 104.2 7.3 92.5 117.2 109.3 106.1 0 0 0 0 0 0 0 0 1 0 0 33 34 112.5 7.0 104.2 92.5 117.2 109.3 0 0 0 0 0 0 0 0 0 1 0 34 35 122.4 7.0 112.5 104.2 92.5 117.2 0 0 0 0 0 0 0 0 0 0 1 35 36 113.3 7.0 122.4 112.5 104.2 92.5 0 0 0 0 0 0 0 0 0 0 0 36 37 100.0 7.2 113.3 122.4 112.5 104.2 1 0 0 0 0 0 0 0 0 0 0 37 38 110.7 7.3 100.0 113.3 122.4 112.5 0 1 0 0 0 0 0 0 0 0 0 38 39 112.8 7.1 110.7 100.0 113.3 122.4 0 0 1 0 0 0 0 0 0 0 0 39 40 109.8 6.8 112.8 110.7 100.0 113.3 0 0 0 1 0 0 0 0 0 0 0 40 41 117.3 6.4 109.8 112.8 110.7 100.0 0 0 0 0 1 0 0 0 0 0 0 41 42 109.1 6.1 117.3 109.8 112.8 110.7 0 0 0 0 0 1 0 0 0 0 0 42 43 115.9 6.5 109.1 117.3 109.8 112.8 0 0 0 0 0 0 1 0 0 0 0 43 44 96.0 7.7 115.9 109.1 117.3 109.8 0 0 0 0 0 0 0 1 0 0 0 44 45 99.8 7.9 96.0 115.9 109.1 117.3 0 0 0 0 0 0 0 0 1 0 0 45 46 116.8 7.5 99.8 96.0 115.9 109.1 0 0 0 0 0 0 0 0 0 1 0 46 47 115.7 6.9 116.8 99.8 96.0 115.9 0 0 0 0 0 0 0 0 0 0 1 47 48 99.4 6.6 115.7 116.8 99.8 96.0 0 0 0 0 0 0 0 0 0 0 0 48 49 94.3 6.9 99.4 115.7 116.8 99.8 1 0 0 0 0 0 0 0 0 0 0 49 50 91.0 7.7 94.3 99.4 115.7 116.8 0 1 0 0 0 0 0 0 0 0 0 50 51 93.2 8.0 91.0 94.3 99.4 115.7 0 0 1 0 0 0 0 0 0 0 0 51 52 103.1 8.0 93.2 91.0 94.3 99.4 0 0 0 1 0 0 0 0 0 0 0 52 53 94.1 7.7 103.1 93.2 91.0 94.3 0 0 0 0 1 0 0 0 0 0 0 53 54 91.8 7.3 94.1 103.1 93.2 91.0 0 0 0 0 0 1 0 0 0 0 0 54 55 102.7 7.4 91.8 94.1 103.1 93.2 0 0 0 0 0 0 1 0 0 0 0 55 56 82.6 8.1 102.7 91.8 94.1 103.1 0 0 0 0 0 0 0 1 0 0 0 56 57 89.1 8.3 82.6 102.7 91.8 94.1 0 0 0 0 0 0 0 0 1 0 0 57 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X Y1 Y2 Y3 Y4 -6.79694 1.05487 0.11097 0.39196 0.59952 -0.10673 M1 M2 M3 M4 M5 M6 -15.45503 -10.45743 -2.31358 10.27457 1.88615 -1.91130 M7 M8 M9 M10 M11 t 4.78338 -17.39037 -8.15432 9.74104 21.71164 -0.01964 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -8.0283 -2.8328 0.1879 2.4991 8.8448 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -6.79694 30.84032 -0.220 0.826716 X 1.05487 1.85547 0.569 0.572944 Y1 0.11097 0.15817 0.702 0.487130 Y2 0.39196 0.13659 2.870 0.006606 ** Y3 0.59952 0.14352 4.177 0.000161 *** Y4 -0.10673 0.17544 -0.608 0.546499 M1 -15.45503 4.84968 -3.187 0.002831 ** M2 -10.45743 7.95191 -1.315 0.196162 M3 -2.31358 7.85966 -0.294 0.770043 M4 10.27457 6.31188 1.628 0.111618 M5 1.88615 4.40978 0.428 0.671207 M6 -1.91130 4.50751 -0.424 0.673877 M7 4.78338 5.47425 0.874 0.387578 M8 -17.39037 5.77453 -3.012 0.004544 ** M9 -8.15432 7.29110 -1.118 0.270241 M10 9.74104 8.06355 1.208 0.234309 M11 21.71164 6.33974 3.425 0.001462 ** t -0.01964 0.05723 -0.343 0.733231 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 4.218 on 39 degrees of freedom Multiple R-squared: 0.87, Adjusted R-squared: 0.8133 F-statistic: 15.35 on 17 and 39 DF, p-value: 2.816e-12 > 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.36179620 0.72359239 0.6382038 [2,] 0.20693908 0.41387817 0.7930609 [3,] 0.18112252 0.36224504 0.8188775 [4,] 0.15298168 0.30596336 0.8470183 [5,] 0.15857789 0.31715579 0.8414221 [6,] 0.10083174 0.20166348 0.8991683 [7,] 0.08659480 0.17318961 0.9134052 [8,] 0.10471469 0.20942938 0.8952853 [9,] 0.09520499 0.19040998 0.9047950 [10,] 0.06936422 0.13872844 0.9306358 [11,] 0.07091531 0.14183062 0.9290847 [12,] 0.04057600 0.08115200 0.9594240 [13,] 0.02684041 0.05368082 0.9731596 [14,] 0.38659921 0.77319841 0.6134008 [15,] 0.43123835 0.86247670 0.5687617 [16,] 0.30191717 0.60383433 0.6980828 > postscript(file="/var/www/html/rcomp/tmp/1zh781260975432.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/2du0o1260975432.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/3aigl1260975432.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/4sazh1260975432.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/5n6fv1260975432.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 = 57 Frequency = 1 1 2 3 4 5 6 2.27952423 -3.02110721 -4.84115687 -5.20886210 4.08078549 -1.46149959 7 8 9 10 11 12 4.00366313 -5.37411543 0.18785965 1.13048451 -4.18195005 2.11070974 13 14 15 16 17 18 4.60734549 1.94721167 -4.08077626 3.56742116 -3.74295921 3.95502102 19 20 21 22 23 24 -1.61490548 -2.50759890 -2.21567054 2.14238979 2.49913201 2.77307464 25 26 27 28 29 30 0.11932037 2.16345234 -0.49254337 5.20483562 -3.97765452 0.32028266 31 32 33 34 35 36 -1.47275754 2.62799319 1.69303939 -3.57779836 4.51559634 3.14452927 37 38 39 40 41 42 -1.48970271 4.12010008 8.84482852 -3.83179838 4.17366240 0.33383528 43 44 45 46 47 48 0.02975932 -1.29976425 -1.66774133 0.30492406 -2.83277830 -8.02831366 49 50 51 52 53 54 -5.51648738 -5.20965688 0.56964798 0.26840371 -0.53383416 -3.14763937 55 56 57 -0.94575943 6.55348539 2.00251283 > postscript(file="/var/www/html/rcomp/tmp/64gbi1260975432.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 = 57 Frequency = 1 lag(myerror, k = 1) myerror 0 2.27952423 NA 1 -3.02110721 2.27952423 2 -4.84115687 -3.02110721 3 -5.20886210 -4.84115687 4 4.08078549 -5.20886210 5 -1.46149959 4.08078549 6 4.00366313 -1.46149959 7 -5.37411543 4.00366313 8 0.18785965 -5.37411543 9 1.13048451 0.18785965 10 -4.18195005 1.13048451 11 2.11070974 -4.18195005 12 4.60734549 2.11070974 13 1.94721167 4.60734549 14 -4.08077626 1.94721167 15 3.56742116 -4.08077626 16 -3.74295921 3.56742116 17 3.95502102 -3.74295921 18 -1.61490548 3.95502102 19 -2.50759890 -1.61490548 20 -2.21567054 -2.50759890 21 2.14238979 -2.21567054 22 2.49913201 2.14238979 23 2.77307464 2.49913201 24 0.11932037 2.77307464 25 2.16345234 0.11932037 26 -0.49254337 2.16345234 27 5.20483562 -0.49254337 28 -3.97765452 5.20483562 29 0.32028266 -3.97765452 30 -1.47275754 0.32028266 31 2.62799319 -1.47275754 32 1.69303939 2.62799319 33 -3.57779836 1.69303939 34 4.51559634 -3.57779836 35 3.14452927 4.51559634 36 -1.48970271 3.14452927 37 4.12010008 -1.48970271 38 8.84482852 4.12010008 39 -3.83179838 8.84482852 40 4.17366240 -3.83179838 41 0.33383528 4.17366240 42 0.02975932 0.33383528 43 -1.29976425 0.02975932 44 -1.66774133 -1.29976425 45 0.30492406 -1.66774133 46 -2.83277830 0.30492406 47 -8.02831366 -2.83277830 48 -5.51648738 -8.02831366 49 -5.20965688 -5.51648738 50 0.56964798 -5.20965688 51 0.26840371 0.56964798 52 -0.53383416 0.26840371 53 -3.14763937 -0.53383416 54 -0.94575943 -3.14763937 55 6.55348539 -0.94575943 56 2.00251283 6.55348539 57 NA 2.00251283 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -3.02110721 2.27952423 [2,] -4.84115687 -3.02110721 [3,] -5.20886210 -4.84115687 [4,] 4.08078549 -5.20886210 [5,] -1.46149959 4.08078549 [6,] 4.00366313 -1.46149959 [7,] -5.37411543 4.00366313 [8,] 0.18785965 -5.37411543 [9,] 1.13048451 0.18785965 [10,] -4.18195005 1.13048451 [11,] 2.11070974 -4.18195005 [12,] 4.60734549 2.11070974 [13,] 1.94721167 4.60734549 [14,] -4.08077626 1.94721167 [15,] 3.56742116 -4.08077626 [16,] -3.74295921 3.56742116 [17,] 3.95502102 -3.74295921 [18,] -1.61490548 3.95502102 [19,] -2.50759890 -1.61490548 [20,] -2.21567054 -2.50759890 [21,] 2.14238979 -2.21567054 [22,] 2.49913201 2.14238979 [23,] 2.77307464 2.49913201 [24,] 0.11932037 2.77307464 [25,] 2.16345234 0.11932037 [26,] -0.49254337 2.16345234 [27,] 5.20483562 -0.49254337 [28,] -3.97765452 5.20483562 [29,] 0.32028266 -3.97765452 [30,] -1.47275754 0.32028266 [31,] 2.62799319 -1.47275754 [32,] 1.69303939 2.62799319 [33,] -3.57779836 1.69303939 [34,] 4.51559634 -3.57779836 [35,] 3.14452927 4.51559634 [36,] -1.48970271 3.14452927 [37,] 4.12010008 -1.48970271 [38,] 8.84482852 4.12010008 [39,] -3.83179838 8.84482852 [40,] 4.17366240 -3.83179838 [41,] 0.33383528 4.17366240 [42,] 0.02975932 0.33383528 [43,] -1.29976425 0.02975932 [44,] -1.66774133 -1.29976425 [45,] 0.30492406 -1.66774133 [46,] -2.83277830 0.30492406 [47,] -8.02831366 -2.83277830 [48,] -5.51648738 -8.02831366 [49,] -5.20965688 -5.51648738 [50,] 0.56964798 -5.20965688 [51,] 0.26840371 0.56964798 [52,] -0.53383416 0.26840371 [53,] -3.14763937 -0.53383416 [54,] -0.94575943 -3.14763937 [55,] 6.55348539 -0.94575943 [56,] 2.00251283 6.55348539 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -3.02110721 2.27952423 2 -4.84115687 -3.02110721 3 -5.20886210 -4.84115687 4 4.08078549 -5.20886210 5 -1.46149959 4.08078549 6 4.00366313 -1.46149959 7 -5.37411543 4.00366313 8 0.18785965 -5.37411543 9 1.13048451 0.18785965 10 -4.18195005 1.13048451 11 2.11070974 -4.18195005 12 4.60734549 2.11070974 13 1.94721167 4.60734549 14 -4.08077626 1.94721167 15 3.56742116 -4.08077626 16 -3.74295921 3.56742116 17 3.95502102 -3.74295921 18 -1.61490548 3.95502102 19 -2.50759890 -1.61490548 20 -2.21567054 -2.50759890 21 2.14238979 -2.21567054 22 2.49913201 2.14238979 23 2.77307464 2.49913201 24 0.11932037 2.77307464 25 2.16345234 0.11932037 26 -0.49254337 2.16345234 27 5.20483562 -0.49254337 28 -3.97765452 5.20483562 29 0.32028266 -3.97765452 30 -1.47275754 0.32028266 31 2.62799319 -1.47275754 32 1.69303939 2.62799319 33 -3.57779836 1.69303939 34 4.51559634 -3.57779836 35 3.14452927 4.51559634 36 -1.48970271 3.14452927 37 4.12010008 -1.48970271 38 8.84482852 4.12010008 39 -3.83179838 8.84482852 40 4.17366240 -3.83179838 41 0.33383528 4.17366240 42 0.02975932 0.33383528 43 -1.29976425 0.02975932 44 -1.66774133 -1.29976425 45 0.30492406 -1.66774133 46 -2.83277830 0.30492406 47 -8.02831366 -2.83277830 48 -5.51648738 -8.02831366 49 -5.20965688 -5.51648738 50 0.56964798 -5.20965688 51 0.26840371 0.56964798 52 -0.53383416 0.26840371 53 -3.14763937 -0.53383416 54 -0.94575943 -3.14763937 55 6.55348539 -0.94575943 56 2.00251283 6.55348539 > 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/7aoeg1260975432.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/81or01260975432.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/9yu9p1260975432.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/10jsni1260975432.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/111nyj1260975432.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/12qdah1260975432.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/13juim1260975432.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/14hbtd1260975432.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/156gaw1260975432.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/16myj01260975432.tab") + } > try(system("convert tmp/1zh781260975432.ps tmp/1zh781260975432.png",intern=TRUE)) character(0) > try(system("convert tmp/2du0o1260975432.ps tmp/2du0o1260975432.png",intern=TRUE)) character(0) > try(system("convert tmp/3aigl1260975432.ps tmp/3aigl1260975432.png",intern=TRUE)) character(0) > try(system("convert tmp/4sazh1260975432.ps tmp/4sazh1260975432.png",intern=TRUE)) character(0) > try(system("convert tmp/5n6fv1260975432.ps tmp/5n6fv1260975432.png",intern=TRUE)) character(0) > try(system("convert tmp/64gbi1260975432.ps tmp/64gbi1260975432.png",intern=TRUE)) character(0) > try(system("convert tmp/7aoeg1260975432.ps tmp/7aoeg1260975432.png",intern=TRUE)) character(0) > try(system("convert tmp/81or01260975432.ps tmp/81or01260975432.png",intern=TRUE)) character(0) > try(system("convert tmp/9yu9p1260975432.ps tmp/9yu9p1260975432.png",intern=TRUE)) character(0) > try(system("convert tmp/10jsni1260975432.ps tmp/10jsni1260975432.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.296 1.504 2.825