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(88.9 + ,94.8 + ,104.2 + ,110.8 + ,110.5 + ,89.8 + ,58.5 + ,88.9 + ,104.2 + ,110.8 + ,90 + ,62.4 + ,89.8 + ,88.9 + ,104.2 + ,93.9 + ,56.7 + ,90 + ,89.8 + ,88.9 + ,91.3 + ,65.1 + ,93.9 + ,90 + ,89.8 + ,87.8 + ,114.4 + ,91.3 + ,93.9 + ,90 + ,99.7 + ,50.7 + ,87.8 + ,91.3 + ,93.9 + ,73.5 + ,44.5 + ,99.7 + ,87.8 + ,91.3 + ,79.2 + ,72 + ,73.5 + ,99.7 + ,87.8 + ,96.9 + ,61.2 + ,79.2 + ,73.5 + ,99.7 + ,95.2 + ,68.4 + ,96.9 + ,79.2 + ,73.5 + ,95.6 + ,78.7 + ,95.2 + ,96.9 + ,79.2 + ,89.7 + ,64.1 + ,95.6 + ,95.2 + ,96.9 + ,92.8 + ,64.6 + ,89.7 + ,95.6 + ,95.2 + ,88 + ,71.9 + ,92.8 + ,89.7 + ,95.6 + ,101.1 + ,71 + ,88 + ,92.8 + ,89.7 + ,92.7 + ,76.4 + ,101.1 + ,88 + ,92.8 + ,95.8 + ,117.3 + ,92.7 + ,101.1 + ,88 + ,103.8 + ,66.1 + ,95.8 + ,92.7 + ,101.1 + ,81.8 + ,57.3 + ,103.8 + ,95.8 + ,92.7 + ,87.1 + ,75 + ,81.8 + ,103.8 + ,95.8 + ,105.9 + ,63.8 + ,87.1 + ,81.8 + ,103.8 + ,108.1 + ,62.2 + ,105.9 + ,87.1 + ,81.8 + ,102.6 + ,75.4 + ,108.1 + ,105.9 + ,87.1 + ,93.7 + ,58 + ,102.6 + ,108.1 + ,105.9 + ,103.5 + ,62.1 + ,93.7 + ,102.6 + ,108.1 + ,100.6 + ,99.2 + ,103.5 + ,93.7 + ,102.6 + ,113.3 + ,70.7 + ,100.6 + ,103.5 + ,93.7 + ,102.4 + ,73.3 + ,113.3 + ,100.6 + ,103.5 + ,102.1 + ,111.2 + ,102.4 + ,113.3 + ,100.6 + ,106.9 + ,68.9 + ,102.1 + ,102.4 + ,113.3 + ,87.3 + ,57.6 + ,106.9 + ,102.1 + ,102.4 + ,93.1 + ,72.9 + ,87.3 + ,106.9 + ,102.1 + ,109.1 + ,75.9 + ,93.1 + ,87.3 + ,106.9 + ,120.3 + ,79.4 + ,109.1 + ,93.1 + ,87.3 + ,104.9 + ,96.9 + ,120.3 + ,109.1 + ,93.1 + ,92.6 + ,75.2 + ,104.9 + ,120.3 + ,109.1 + ,109.8 + ,60.3 + ,92.6 + ,104.9 + ,120.3 + ,111.4 + ,88.9 + ,109.8 + ,92.6 + ,104.9 + ,117.9 + ,90.5 + ,111.4 + ,109.8 + ,92.6 + ,121.6 + ,79.9 + ,117.9 + ,111.4 + ,109.8 + ,117.8 + ,116.3 + ,121.6 + ,117.9 + ,111.4 + ,124.2 + ,95.2 + ,117.8 + ,121.6 + ,117.9 + ,106.8 + ,81.5 + ,124.2 + ,117.8 + ,121.6 + ,102.7 + ,89.1 + ,106.8 + ,124.2 + ,117.8 + ,116.8 + ,76 + ,102.7 + ,106.8 + ,124.2 + ,113.6 + ,100.5 + ,116.8 + ,102.7 + ,106.8 + ,96.1 + ,83.9 + ,113.6 + ,116.8 + ,102.7 + ,85 + ,75.1 + ,96.1 + ,113.6 + ,116.8 + ,83.2 + ,69.5 + ,85 + ,96.1 + ,113.6 + ,84.9 + ,95.1 + ,83.2 + ,85 + ,96.1 + ,83 + ,90.1 + ,84.9 + ,83.2 + ,85 + ,79.6 + ,78.4 + ,83 + ,84.9 + ,83.2 + ,83.2 + ,113.8 + ,79.6 + ,83 + ,84.9 + ,83.8 + ,73.6 + ,83.2 + ,79.6 + ,83 + ,82.8 + ,56.5 + ,83.8 + ,83.2 + ,79.6) + ,dim=c(5 + ,56) + ,dimnames=list(c('Y' + ,'X' + ,'Y1' + ,'Y2' + ,'Y3 ') + ,1:56)) > y <- array(NA,dim=c(5,56),dimnames=list(c('Y','X','Y1','Y2','Y3 '),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 = 'No 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\r M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 1 88.9 94.8 104.2 110.8 110.5 1 0 0 0 0 0 0 0 0 0 0 2 89.8 58.5 88.9 104.2 110.8 0 1 0 0 0 0 0 0 0 0 0 3 90.0 62.4 89.8 88.9 104.2 0 0 1 0 0 0 0 0 0 0 0 4 93.9 56.7 90.0 89.8 88.9 0 0 0 1 0 0 0 0 0 0 0 5 91.3 65.1 93.9 90.0 89.8 0 0 0 0 1 0 0 0 0 0 0 6 87.8 114.4 91.3 93.9 90.0 0 0 0 0 0 1 0 0 0 0 0 7 99.7 50.7 87.8 91.3 93.9 0 0 0 0 0 0 1 0 0 0 0 8 73.5 44.5 99.7 87.8 91.3 0 0 0 0 0 0 0 1 0 0 0 9 79.2 72.0 73.5 99.7 87.8 0 0 0 0 0 0 0 0 1 0 0 10 96.9 61.2 79.2 73.5 99.7 0 0 0 0 0 0 0 0 0 1 0 11 95.2 68.4 96.9 79.2 73.5 0 0 0 0 0 0 0 0 0 0 1 12 95.6 78.7 95.2 96.9 79.2 0 0 0 0 0 0 0 0 0 0 0 13 89.7 64.1 95.6 95.2 96.9 1 0 0 0 0 0 0 0 0 0 0 14 92.8 64.6 89.7 95.6 95.2 0 1 0 0 0 0 0 0 0 0 0 15 88.0 71.9 92.8 89.7 95.6 0 0 1 0 0 0 0 0 0 0 0 16 101.1 71.0 88.0 92.8 89.7 0 0 0 1 0 0 0 0 0 0 0 17 92.7 76.4 101.1 88.0 92.8 0 0 0 0 1 0 0 0 0 0 0 18 95.8 117.3 92.7 101.1 88.0 0 0 0 0 0 1 0 0 0 0 0 19 103.8 66.1 95.8 92.7 101.1 0 0 0 0 0 0 1 0 0 0 0 20 81.8 57.3 103.8 95.8 92.7 0 0 0 0 0 0 0 1 0 0 0 21 87.1 75.0 81.8 103.8 95.8 0 0 0 0 0 0 0 0 1 0 0 22 105.9 63.8 87.1 81.8 103.8 0 0 0 0 0 0 0 0 0 1 0 23 108.1 62.2 105.9 87.1 81.8 0 0 0 0 0 0 0 0 0 0 1 24 102.6 75.4 108.1 105.9 87.1 0 0 0 0 0 0 0 0 0 0 0 25 93.7 58.0 102.6 108.1 105.9 1 0 0 0 0 0 0 0 0 0 0 26 103.5 62.1 93.7 102.6 108.1 0 1 0 0 0 0 0 0 0 0 0 27 100.6 99.2 103.5 93.7 102.6 0 0 1 0 0 0 0 0 0 0 0 28 113.3 70.7 100.6 103.5 93.7 0 0 0 1 0 0 0 0 0 0 0 29 102.4 73.3 113.3 100.6 103.5 0 0 0 0 1 0 0 0 0 0 0 30 102.1 111.2 102.4 113.3 100.6 0 0 0 0 0 1 0 0 0 0 0 31 106.9 68.9 102.1 102.4 113.3 0 0 0 0 0 0 1 0 0 0 0 32 87.3 57.6 106.9 102.1 102.4 0 0 0 0 0 0 0 1 0 0 0 33 93.1 72.9 87.3 106.9 102.1 0 0 0 0 0 0 0 0 1 0 0 34 109.1 75.9 93.1 87.3 106.9 0 0 0 0 0 0 0 0 0 1 0 35 120.3 79.4 109.1 93.1 87.3 0 0 0 0 0 0 0 0 0 0 1 36 104.9 96.9 120.3 109.1 93.1 0 0 0 0 0 0 0 0 0 0 0 37 92.6 75.2 104.9 120.3 109.1 1 0 0 0 0 0 0 0 0 0 0 38 109.8 60.3 92.6 104.9 120.3 0 1 0 0 0 0 0 0 0 0 0 39 111.4 88.9 109.8 92.6 104.9 0 0 1 0 0 0 0 0 0 0 0 40 117.9 90.5 111.4 109.8 92.6 0 0 0 1 0 0 0 0 0 0 0 41 121.6 79.9 117.9 111.4 109.8 0 0 0 0 1 0 0 0 0 0 0 42 117.8 116.3 121.6 117.9 111.4 0 0 0 0 0 1 0 0 0 0 0 43 124.2 95.2 117.8 121.6 117.9 0 0 0 0 0 0 1 0 0 0 0 44 106.8 81.5 124.2 117.8 121.6 0 0 0 0 0 0 0 1 0 0 0 45 102.7 89.1 106.8 124.2 117.8 0 0 0 0 0 0 0 0 1 0 0 46 116.8 76.0 102.7 106.8 124.2 0 0 0 0 0 0 0 0 0 1 0 47 113.6 100.5 116.8 102.7 106.8 0 0 0 0 0 0 0 0 0 0 1 48 96.1 83.9 113.6 116.8 102.7 0 0 0 0 0 0 0 0 0 0 0 49 85.0 75.1 96.1 113.6 116.8 1 0 0 0 0 0 0 0 0 0 0 50 83.2 69.5 85.0 96.1 113.6 0 1 0 0 0 0 0 0 0 0 0 51 84.9 95.1 83.2 85.0 96.1 0 0 1 0 0 0 0 0 0 0 0 52 83.0 90.1 84.9 83.2 85.0 0 0 0 1 0 0 0 0 0 0 0 53 79.6 78.4 83.0 84.9 83.2 0 0 0 0 1 0 0 0 0 0 0 54 83.2 113.8 79.6 83.0 84.9 0 0 0 0 0 1 0 0 0 0 0 55 83.8 73.6 83.2 79.6 83.0 0 0 0 0 0 0 1 0 0 0 0 56 82.8 56.5 83.8 83.2 79.6 0 0 0 0 0 0 0 1 0 0 0 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X Y1 Y2 `Y3\r` M1 2.8645 -0.0863 0.7219 0.3932 -0.1864 -2.2102 M2 M3 M4 M5 M6 M7 14.2880 13.5452 16.0561 8.1013 11.6360 17.3124 M8 M9 M10 M11 -6.2243 7.3610 30.8506 16.4618 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -8.7685 -3.3371 -0.3225 2.6336 12.6720 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.86448 9.19809 0.311 0.757098 X -0.08629 0.08349 -1.034 0.307557 Y1 0.72187 0.16952 4.258 0.000121 *** Y2 0.39317 0.21327 1.843 0.072678 . `Y3\r` -0.18644 0.17710 -1.053 0.298769 M1 -2.21023 5.26997 -0.419 0.677167 M2 14.28805 6.68478 2.137 0.038730 * M3 13.54516 5.95224 2.276 0.028298 * M4 16.05609 4.32890 3.709 0.000632 *** M5 8.10130 4.82046 1.681 0.100633 M6 11.63604 5.20438 2.236 0.031010 * M7 17.31243 5.36167 3.229 0.002484 ** M8 -6.22433 5.08543 -1.224 0.228130 M9 7.36102 6.03702 1.219 0.229867 M10 30.85058 7.62918 4.044 0.000233 *** M11 16.46185 5.01584 3.282 0.002144 ** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 5.662 on 40 degrees of freedom Multiple R-squared: 0.8445, Adjusted R-squared: 0.7862 F-statistic: 14.48 on 15 and 40 DF, p-value: 1.106e-11 > 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.34542244 0.69084487 0.6545776 [2,] 0.31805861 0.63611722 0.6819414 [3,] 0.28048709 0.56097419 0.7195129 [4,] 0.18041543 0.36083085 0.8195846 [5,] 0.15739912 0.31479824 0.8426009 [6,] 0.11717132 0.23434265 0.8828287 [7,] 0.06581039 0.13162078 0.9341896 [8,] 0.11137628 0.22275257 0.8886237 [9,] 0.07700237 0.15400473 0.9229976 [10,] 0.05069525 0.10139050 0.9493047 [11,] 0.04679143 0.09358286 0.9532086 [12,] 0.02891116 0.05782232 0.9710888 [13,] 0.01463597 0.02927193 0.9853640 [14,] 0.03878673 0.07757346 0.9612133 [15,] 0.02441036 0.04882073 0.9755896 [16,] 0.01357723 0.02715446 0.9864228 [17,] 0.02350826 0.04701651 0.9764917 [18,] 0.16496564 0.32993128 0.8350344 [19,] 0.11110164 0.22220328 0.8888984 > postscript(file="/var/www/html/rcomp/tmp/1ieq51258640342.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/2rvlx1258640342.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/353rz1258640342.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/47ue31258640342.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/53awp1258640342.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 6 -1.75363410 -6.78891425 -1.37423792 -3.82778119 -0.47426757 -2.87396579 7 8 9 10 11 12 2.12867692 -8.76848166 -0.69901436 0.98437905 -5.60843382 7.47308314 13 14 15 16 17 18 6.20305547 -3.36726009 -6.63797937 5.01959996 -1.95096720 1.16199362 19 20 21 22 23 24 2.57456639 -5.20790760 1.34788763 2.00710036 -1.29883218 2.81058519 25 26 27 28 29 30 1.22970461 3.88244442 0.32622875 4.63704427 -4.28426294 -2.51400517 31 32 33 34 35 36 -0.17073192 -2.58829222 3.15214840 0.33557956 8.74184756 -1.98041653 37 38 39 40 41 42 -4.24637214 12.19145866 6.55092927 0.46742533 9.09305214 -0.02881586 43 44 45 46 47 48 1.37426225 3.89270978 -3.80102166 -3.32705898 -1.83458155 -8.30325180 49 50 51 52 53 54 -1.43275384 -5.91772874 1.13505928 -6.29628837 -2.38355442 4.25479321 55 56 -5.90677364 12.67197169 > postscript(file="/var/www/html/rcomp/tmp/6g7c21258640342.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.75363410 NA 1 -6.78891425 -1.75363410 2 -1.37423792 -6.78891425 3 -3.82778119 -1.37423792 4 -0.47426757 -3.82778119 5 -2.87396579 -0.47426757 6 2.12867692 -2.87396579 7 -8.76848166 2.12867692 8 -0.69901436 -8.76848166 9 0.98437905 -0.69901436 10 -5.60843382 0.98437905 11 7.47308314 -5.60843382 12 6.20305547 7.47308314 13 -3.36726009 6.20305547 14 -6.63797937 -3.36726009 15 5.01959996 -6.63797937 16 -1.95096720 5.01959996 17 1.16199362 -1.95096720 18 2.57456639 1.16199362 19 -5.20790760 2.57456639 20 1.34788763 -5.20790760 21 2.00710036 1.34788763 22 -1.29883218 2.00710036 23 2.81058519 -1.29883218 24 1.22970461 2.81058519 25 3.88244442 1.22970461 26 0.32622875 3.88244442 27 4.63704427 0.32622875 28 -4.28426294 4.63704427 29 -2.51400517 -4.28426294 30 -0.17073192 -2.51400517 31 -2.58829222 -0.17073192 32 3.15214840 -2.58829222 33 0.33557956 3.15214840 34 8.74184756 0.33557956 35 -1.98041653 8.74184756 36 -4.24637214 -1.98041653 37 12.19145866 -4.24637214 38 6.55092927 12.19145866 39 0.46742533 6.55092927 40 9.09305214 0.46742533 41 -0.02881586 9.09305214 42 1.37426225 -0.02881586 43 3.89270978 1.37426225 44 -3.80102166 3.89270978 45 -3.32705898 -3.80102166 46 -1.83458155 -3.32705898 47 -8.30325180 -1.83458155 48 -1.43275384 -8.30325180 49 -5.91772874 -1.43275384 50 1.13505928 -5.91772874 51 -6.29628837 1.13505928 52 -2.38355442 -6.29628837 53 4.25479321 -2.38355442 54 -5.90677364 4.25479321 55 12.67197169 -5.90677364 56 NA 12.67197169 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -6.78891425 -1.75363410 [2,] -1.37423792 -6.78891425 [3,] -3.82778119 -1.37423792 [4,] -0.47426757 -3.82778119 [5,] -2.87396579 -0.47426757 [6,] 2.12867692 -2.87396579 [7,] -8.76848166 2.12867692 [8,] -0.69901436 -8.76848166 [9,] 0.98437905 -0.69901436 [10,] -5.60843382 0.98437905 [11,] 7.47308314 -5.60843382 [12,] 6.20305547 7.47308314 [13,] -3.36726009 6.20305547 [14,] -6.63797937 -3.36726009 [15,] 5.01959996 -6.63797937 [16,] -1.95096720 5.01959996 [17,] 1.16199362 -1.95096720 [18,] 2.57456639 1.16199362 [19,] -5.20790760 2.57456639 [20,] 1.34788763 -5.20790760 [21,] 2.00710036 1.34788763 [22,] -1.29883218 2.00710036 [23,] 2.81058519 -1.29883218 [24,] 1.22970461 2.81058519 [25,] 3.88244442 1.22970461 [26,] 0.32622875 3.88244442 [27,] 4.63704427 0.32622875 [28,] -4.28426294 4.63704427 [29,] -2.51400517 -4.28426294 [30,] -0.17073192 -2.51400517 [31,] -2.58829222 -0.17073192 [32,] 3.15214840 -2.58829222 [33,] 0.33557956 3.15214840 [34,] 8.74184756 0.33557956 [35,] -1.98041653 8.74184756 [36,] -4.24637214 -1.98041653 [37,] 12.19145866 -4.24637214 [38,] 6.55092927 12.19145866 [39,] 0.46742533 6.55092927 [40,] 9.09305214 0.46742533 [41,] -0.02881586 9.09305214 [42,] 1.37426225 -0.02881586 [43,] 3.89270978 1.37426225 [44,] -3.80102166 3.89270978 [45,] -3.32705898 -3.80102166 [46,] -1.83458155 -3.32705898 [47,] -8.30325180 -1.83458155 [48,] -1.43275384 -8.30325180 [49,] -5.91772874 -1.43275384 [50,] 1.13505928 -5.91772874 [51,] -6.29628837 1.13505928 [52,] -2.38355442 -6.29628837 [53,] 4.25479321 -2.38355442 [54,] -5.90677364 4.25479321 [55,] 12.67197169 -5.90677364 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -6.78891425 -1.75363410 2 -1.37423792 -6.78891425 3 -3.82778119 -1.37423792 4 -0.47426757 -3.82778119 5 -2.87396579 -0.47426757 6 2.12867692 -2.87396579 7 -8.76848166 2.12867692 8 -0.69901436 -8.76848166 9 0.98437905 -0.69901436 10 -5.60843382 0.98437905 11 7.47308314 -5.60843382 12 6.20305547 7.47308314 13 -3.36726009 6.20305547 14 -6.63797937 -3.36726009 15 5.01959996 -6.63797937 16 -1.95096720 5.01959996 17 1.16199362 -1.95096720 18 2.57456639 1.16199362 19 -5.20790760 2.57456639 20 1.34788763 -5.20790760 21 2.00710036 1.34788763 22 -1.29883218 2.00710036 23 2.81058519 -1.29883218 24 1.22970461 2.81058519 25 3.88244442 1.22970461 26 0.32622875 3.88244442 27 4.63704427 0.32622875 28 -4.28426294 4.63704427 29 -2.51400517 -4.28426294 30 -0.17073192 -2.51400517 31 -2.58829222 -0.17073192 32 3.15214840 -2.58829222 33 0.33557956 3.15214840 34 8.74184756 0.33557956 35 -1.98041653 8.74184756 36 -4.24637214 -1.98041653 37 12.19145866 -4.24637214 38 6.55092927 12.19145866 39 0.46742533 6.55092927 40 9.09305214 0.46742533 41 -0.02881586 9.09305214 42 1.37426225 -0.02881586 43 3.89270978 1.37426225 44 -3.80102166 3.89270978 45 -3.32705898 -3.80102166 46 -1.83458155 -3.32705898 47 -8.30325180 -1.83458155 48 -1.43275384 -8.30325180 49 -5.91772874 -1.43275384 50 1.13505928 -5.91772874 51 -6.29628837 1.13505928 52 -2.38355442 -6.29628837 53 4.25479321 -2.38355442 54 -5.90677364 4.25479321 55 12.67197169 -5.90677364 > 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/7eeup1258640342.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/8fr7i1258640342.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/9d32f1258640342.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/105vzl1258640342.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/11rfiq1258640342.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/12ejti1258640342.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/13p1dr1258640342.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/1452y31258640342.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/154xcp1258640342.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/16v4rd1258640342.tab") + } > > system("convert tmp/1ieq51258640342.ps tmp/1ieq51258640342.png") > system("convert tmp/2rvlx1258640342.ps tmp/2rvlx1258640342.png") > system("convert tmp/353rz1258640342.ps tmp/353rz1258640342.png") > system("convert tmp/47ue31258640342.ps tmp/47ue31258640342.png") > system("convert tmp/53awp1258640342.ps tmp/53awp1258640342.png") > system("convert tmp/6g7c21258640342.ps tmp/6g7c21258640342.png") > system("convert tmp/7eeup1258640342.ps tmp/7eeup1258640342.png") > system("convert tmp/8fr7i1258640342.ps tmp/8fr7i1258640342.png") > system("convert tmp/9d32f1258640342.ps tmp/9d32f1258640342.png") > system("convert tmp/105vzl1258640342.ps tmp/105vzl1258640342.png") > > > proc.time() user system elapsed 2.386 1.593 3.120