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(113.6 + ,123.06 + ,83.4 + ,79.8 + ,112.9 + ,123.39 + ,113.6 + ,83.4 + ,104 + ,120.28 + ,112.9 + ,113.6 + ,109.9 + ,115.33 + ,104 + ,112.9 + ,99 + ,110.4 + ,109.9 + ,104 + ,106.3 + ,114.49 + ,99 + ,109.9 + ,128.9 + ,132.03 + ,106.3 + ,99 + ,111.1 + ,123.16 + ,128.9 + ,106.3 + ,102.9 + ,118.82 + ,111.1 + ,128.9 + ,130 + ,128.32 + ,102.9 + ,111.1 + ,87 + ,112.24 + ,130 + ,102.9 + ,87.5 + ,104.53 + ,87 + ,130 + ,117.6 + ,132.57 + ,87.5 + ,87 + ,103.4 + ,122.52 + ,117.6 + ,87.5 + ,110.8 + ,131.8 + ,103.4 + ,117.6 + ,112.6 + ,124.55 + ,110.8 + ,103.4 + ,102.5 + ,120.96 + ,112.6 + ,110.8 + ,112.4 + ,122.6 + ,102.5 + ,112.6 + ,135.6 + ,145.52 + ,112.4 + ,102.5 + ,105.1 + ,118.57 + ,135.6 + ,112.4 + ,127.7 + ,134.25 + ,105.1 + ,135.6 + ,137 + ,136.7 + ,127.7 + ,105.1 + ,91 + ,121.37 + ,137 + ,127.7 + ,90.5 + ,111.63 + ,91 + ,137 + ,122.4 + ,134.42 + ,90.5 + ,91 + ,123.3 + ,137.65 + ,122.4 + ,90.5 + ,124.3 + ,137.86 + ,123.3 + ,122.4 + ,120 + ,119.77 + ,124.3 + ,123.3 + ,118.1 + ,130.69 + ,120 + ,124.3 + ,119 + ,128.28 + ,118.1 + ,120 + ,142.7 + ,147.45 + ,119 + ,118.1 + ,123.6 + ,128.42 + ,142.7 + ,119 + ,129.6 + ,136.9 + ,123.6 + ,142.7 + ,151.6 + ,143.95 + ,129.6 + ,123.6 + ,110.4 + ,135.64 + ,151.6 + ,129.6 + ,99.2 + ,122.48 + ,110.4 + ,151.6 + ,130.5 + ,136.83 + ,99.2 + ,110.4 + ,136.2 + ,153.04 + ,130.5 + ,99.2 + ,129.7 + ,142.71 + ,136.2 + ,130.5 + ,128 + ,123.46 + ,129.7 + ,136.2 + ,121.6 + ,144.37 + ,128 + ,129.7 + ,135.8 + ,146.15 + ,121.6 + ,128 + ,143.8 + ,147.61 + ,135.8 + ,121.6 + ,147.5 + ,158.51 + ,143.8 + ,135.8 + ,136.2 + ,147.4 + ,147.5 + ,143.8 + ,156.6 + ,165.05 + ,136.2 + ,147.5 + ,123.3 + ,154.64 + ,156.6 + ,136.2 + ,104.5 + ,126.2 + ,123.3 + ,156.6 + ,139.8 + ,157.36 + ,104.5 + ,123.3 + ,136.5 + ,154.15 + ,139.8 + ,104.5 + ,112.1 + ,123.21 + ,136.5 + ,139.8 + ,118.5 + ,113.07 + ,112.1 + ,136.5 + ,94.4 + ,110.45 + ,118.5 + ,112.1 + ,102.3 + ,113.57 + ,94.4 + ,118.5 + ,111.4 + ,122.44 + ,102.3 + ,94.4 + ,99.2 + ,114.93 + ,111.4 + ,102.3 + ,87.8 + ,111.85 + ,99.2 + ,111.4 + ,115.8 + ,126.04 + ,87.8 + ,99.2) + ,dim=c(4 + ,58) + ,dimnames=list(c('Y' + ,'X' + ,'Y1' + ,'Y2') + ,1:58)) > y <- array(NA,dim=c(4,58),dimnames=list(c('Y','X','Y1','Y2'),1:58)) > 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 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 113.6 123.06 83.4 79.8 1 0 0 0 0 0 0 0 0 0 0 1 2 112.9 123.39 113.6 83.4 0 1 0 0 0 0 0 0 0 0 0 2 3 104.0 120.28 112.9 113.6 0 0 1 0 0 0 0 0 0 0 0 3 4 109.9 115.33 104.0 112.9 0 0 0 1 0 0 0 0 0 0 0 4 5 99.0 110.40 109.9 104.0 0 0 0 0 1 0 0 0 0 0 0 5 6 106.3 114.49 99.0 109.9 0 0 0 0 0 1 0 0 0 0 0 6 7 128.9 132.03 106.3 99.0 0 0 0 0 0 0 1 0 0 0 0 7 8 111.1 123.16 128.9 106.3 0 0 0 0 0 0 0 1 0 0 0 8 9 102.9 118.82 111.1 128.9 0 0 0 0 0 0 0 0 1 0 0 9 10 130.0 128.32 102.9 111.1 0 0 0 0 0 0 0 0 0 1 0 10 11 87.0 112.24 130.0 102.9 0 0 0 0 0 0 0 0 0 0 1 11 12 87.5 104.53 87.0 130.0 0 0 0 0 0 0 0 0 0 0 0 12 13 117.6 132.57 87.5 87.0 1 0 0 0 0 0 0 0 0 0 0 13 14 103.4 122.52 117.6 87.5 0 1 0 0 0 0 0 0 0 0 0 14 15 110.8 131.80 103.4 117.6 0 0 1 0 0 0 0 0 0 0 0 15 16 112.6 124.55 110.8 103.4 0 0 0 1 0 0 0 0 0 0 0 16 17 102.5 120.96 112.6 110.8 0 0 0 0 1 0 0 0 0 0 0 17 18 112.4 122.60 102.5 112.6 0 0 0 0 0 1 0 0 0 0 0 18 19 135.6 145.52 112.4 102.5 0 0 0 0 0 0 1 0 0 0 0 19 20 105.1 118.57 135.6 112.4 0 0 0 0 0 0 0 1 0 0 0 20 21 127.7 134.25 105.1 135.6 0 0 0 0 0 0 0 0 1 0 0 21 22 137.0 136.70 127.7 105.1 0 0 0 0 0 0 0 0 0 1 0 22 23 91.0 121.37 137.0 127.7 0 0 0 0 0 0 0 0 0 0 1 23 24 90.5 111.63 91.0 137.0 0 0 0 0 0 0 0 0 0 0 0 24 25 122.4 134.42 90.5 91.0 1 0 0 0 0 0 0 0 0 0 0 25 26 123.3 137.65 122.4 90.5 0 1 0 0 0 0 0 0 0 0 0 26 27 124.3 137.86 123.3 122.4 0 0 1 0 0 0 0 0 0 0 0 27 28 120.0 119.77 124.3 123.3 0 0 0 1 0 0 0 0 0 0 0 28 29 118.1 130.69 120.0 124.3 0 0 0 0 1 0 0 0 0 0 0 29 30 119.0 128.28 118.1 120.0 0 0 0 0 0 1 0 0 0 0 0 30 31 142.7 147.45 119.0 118.1 0 0 0 0 0 0 1 0 0 0 0 31 32 123.6 128.42 142.7 119.0 0 0 0 0 0 0 0 1 0 0 0 32 33 129.6 136.90 123.6 142.7 0 0 0 0 0 0 0 0 1 0 0 33 34 151.6 143.95 129.6 123.6 0 0 0 0 0 0 0 0 0 1 0 34 35 110.4 135.64 151.6 129.6 0 0 0 0 0 0 0 0 0 0 1 35 36 99.2 122.48 110.4 151.6 0 0 0 0 0 0 0 0 0 0 0 36 37 130.5 136.83 99.2 110.4 1 0 0 0 0 0 0 0 0 0 0 37 38 136.2 153.04 130.5 99.2 0 1 0 0 0 0 0 0 0 0 0 38 39 129.7 142.71 136.2 130.5 0 0 1 0 0 0 0 0 0 0 0 39 40 128.0 123.46 129.7 136.2 0 0 0 1 0 0 0 0 0 0 0 40 41 121.6 144.37 128.0 129.7 0 0 0 0 1 0 0 0 0 0 0 41 42 135.8 146.15 121.6 128.0 0 0 0 0 0 1 0 0 0 0 0 42 43 143.8 147.61 135.8 121.6 0 0 0 0 0 0 1 0 0 0 0 43 44 147.5 158.51 143.8 135.8 0 0 0 0 0 0 0 1 0 0 0 44 45 136.2 147.40 147.5 143.8 0 0 0 0 0 0 0 0 1 0 0 45 46 156.6 165.05 136.2 147.5 0 0 0 0 0 0 0 0 0 1 0 46 47 123.3 154.64 156.6 136.2 0 0 0 0 0 0 0 0 0 0 1 47 48 104.5 126.20 123.3 156.6 0 0 0 0 0 0 0 0 0 0 0 48 49 139.8 157.36 104.5 123.3 1 0 0 0 0 0 0 0 0 0 0 49 50 136.5 154.15 139.8 104.5 0 1 0 0 0 0 0 0 0 0 0 50 51 112.1 123.21 136.5 139.8 0 0 1 0 0 0 0 0 0 0 0 51 52 118.5 113.07 112.1 136.5 0 0 0 1 0 0 0 0 0 0 0 52 53 94.4 110.45 118.5 112.1 0 0 0 0 1 0 0 0 0 0 0 53 54 102.3 113.57 94.4 118.5 0 0 0 0 0 1 0 0 0 0 0 54 55 111.4 122.44 102.3 94.4 0 0 0 0 0 0 1 0 0 0 0 55 56 99.2 114.93 111.4 102.3 0 0 0 0 0 0 0 1 0 0 0 56 57 87.8 111.85 99.2 111.4 0 0 0 0 0 0 0 0 1 0 0 57 58 115.8 126.04 87.8 99.2 0 0 0 0 0 0 0 0 0 1 0 58 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X Y1 Y2 M1 M2 -37.2941 0.7390 0.1593 0.2349 25.8124 18.8217 M3 M4 M5 M6 M7 M8 10.7187 22.8169 10.4075 18.6652 26.9841 14.8733 M9 M10 M11 t 12.0425 29.6389 -5.4063 -0.1115 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -8.9452 -2.1081 0.2833 2.5902 7.4766 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -37.29407 7.49873 -4.973 1.16e-05 *** X 0.73903 0.07510 9.840 1.81e-12 *** Y1 0.15933 0.07519 2.119 0.04004 * Y2 0.23492 0.08837 2.658 0.01106 * M1 25.81245 5.43906 4.746 2.42e-05 *** M2 18.82170 6.63192 2.838 0.00696 ** M3 10.71869 4.04241 2.652 0.01125 * M4 22.81695 3.72863 6.119 2.67e-07 *** M5 10.40753 4.25972 2.443 0.01884 * M6 18.66518 3.88995 4.798 2.04e-05 *** M7 26.98406 5.33037 5.062 8.69e-06 *** M8 14.87327 5.06927 2.934 0.00540 ** M9 12.04245 3.45053 3.490 0.00115 ** M10 29.63889 4.71255 6.289 1.52e-07 *** M11 -5.40628 5.11822 -1.056 0.29688 t -0.11151 0.03800 -2.935 0.00539 ** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 4.066 on 42 degrees of freedom Multiple R-squared: 0.9572, Adjusted R-squared: 0.9419 F-statistic: 62.59 on 15 and 42 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.1195946 0.2391892 0.8804054 [2,] 0.1730436 0.3460873 0.8269564 [3,] 0.7164517 0.5670965 0.2835483 [4,] 0.7139729 0.5720542 0.2860271 [5,] 0.7532405 0.4935190 0.2467595 [6,] 0.6464945 0.7070110 0.3535055 [7,] 0.6426185 0.7147629 0.3573815 [8,] 0.5970153 0.8059694 0.4029847 [9,] 0.6696892 0.6606216 0.3303108 [10,] 0.8462186 0.3075628 0.1537814 [11,] 0.7860719 0.4278562 0.2139281 [12,] 0.8135224 0.3729553 0.1864776 [13,] 0.7273208 0.5453584 0.2726792 [14,] 0.7934810 0.4130379 0.2065190 [15,] 0.8256172 0.3487655 0.1743828 [16,] 0.8380069 0.3239861 0.1619931 [17,] 0.7465448 0.5069104 0.2534552 [18,] 0.6911528 0.6176944 0.3088472 [19,] 0.6511024 0.6977952 0.3488976 [20,] 0.6469607 0.7060787 0.3530393 [21,] 0.5384010 0.9231981 0.4615990 > postscript(file="/var/www/html/rcomp/tmp/1jl9e1258715376.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/2gj351258715376.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/3x9qu1258715376.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/4u04b1258715376.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/5ec131258715376.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 = 58 Frequency = 1 1 2 3 4 5 6 2.212382022 2.713169157 -2.657054277 -3.503064862 2.912042972 -0.606049564 7 8 9 10 11 12 2.221448580 -2.116895916 -6.640275619 1.442138520 3.090909033 4.479029055 13 14 15 16 17 18 -1.822402764 -6.406251481 -2.458607256 -5.130520550 -2.081691117 -0.353434560 19 20 21 22 23 24 -1.504143489 -5.887157232 7.476590467 1.045236926 -5.259750824 1.288233498 25 26 27 28 29 30 1.530830682 2.180736156 3.602618270 0.314232122 3.315122473 -0.837040940 31 32 33 34 35 36 0.791262381 3.989739394 4.140665745 6.976575166 2.159751687 -3.213088806 37 38 39 40 41 42 3.244193350 1.710714473 2.798164659 3.034430350 -4.499973060 1.657514134 43 44 45 46 47 48 -0.387879303 2.868382505 0.252461288 -8.945154676 0.009090105 -2.554173747 49 50 51 52 53 54 -5.165003290 -0.198368305 -1.285121397 5.284922940 0.354498732 0.139010929 55 56 57 58 -1.120688169 1.145931249 -5.229441881 -0.518795936 > postscript(file="/var/www/html/rcomp/tmp/6q3ky1258715376.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 = 58 Frequency = 1 lag(myerror, k = 1) myerror 0 2.212382022 NA 1 2.713169157 2.212382022 2 -2.657054277 2.713169157 3 -3.503064862 -2.657054277 4 2.912042972 -3.503064862 5 -0.606049564 2.912042972 6 2.221448580 -0.606049564 7 -2.116895916 2.221448580 8 -6.640275619 -2.116895916 9 1.442138520 -6.640275619 10 3.090909033 1.442138520 11 4.479029055 3.090909033 12 -1.822402764 4.479029055 13 -6.406251481 -1.822402764 14 -2.458607256 -6.406251481 15 -5.130520550 -2.458607256 16 -2.081691117 -5.130520550 17 -0.353434560 -2.081691117 18 -1.504143489 -0.353434560 19 -5.887157232 -1.504143489 20 7.476590467 -5.887157232 21 1.045236926 7.476590467 22 -5.259750824 1.045236926 23 1.288233498 -5.259750824 24 1.530830682 1.288233498 25 2.180736156 1.530830682 26 3.602618270 2.180736156 27 0.314232122 3.602618270 28 3.315122473 0.314232122 29 -0.837040940 3.315122473 30 0.791262381 -0.837040940 31 3.989739394 0.791262381 32 4.140665745 3.989739394 33 6.976575166 4.140665745 34 2.159751687 6.976575166 35 -3.213088806 2.159751687 36 3.244193350 -3.213088806 37 1.710714473 3.244193350 38 2.798164659 1.710714473 39 3.034430350 2.798164659 40 -4.499973060 3.034430350 41 1.657514134 -4.499973060 42 -0.387879303 1.657514134 43 2.868382505 -0.387879303 44 0.252461288 2.868382505 45 -8.945154676 0.252461288 46 0.009090105 -8.945154676 47 -2.554173747 0.009090105 48 -5.165003290 -2.554173747 49 -0.198368305 -5.165003290 50 -1.285121397 -0.198368305 51 5.284922940 -1.285121397 52 0.354498732 5.284922940 53 0.139010929 0.354498732 54 -1.120688169 0.139010929 55 1.145931249 -1.120688169 56 -5.229441881 1.145931249 57 -0.518795936 -5.229441881 58 NA -0.518795936 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 2.713169157 2.212382022 [2,] -2.657054277 2.713169157 [3,] -3.503064862 -2.657054277 [4,] 2.912042972 -3.503064862 [5,] -0.606049564 2.912042972 [6,] 2.221448580 -0.606049564 [7,] -2.116895916 2.221448580 [8,] -6.640275619 -2.116895916 [9,] 1.442138520 -6.640275619 [10,] 3.090909033 1.442138520 [11,] 4.479029055 3.090909033 [12,] -1.822402764 4.479029055 [13,] -6.406251481 -1.822402764 [14,] -2.458607256 -6.406251481 [15,] -5.130520550 -2.458607256 [16,] -2.081691117 -5.130520550 [17,] -0.353434560 -2.081691117 [18,] -1.504143489 -0.353434560 [19,] -5.887157232 -1.504143489 [20,] 7.476590467 -5.887157232 [21,] 1.045236926 7.476590467 [22,] -5.259750824 1.045236926 [23,] 1.288233498 -5.259750824 [24,] 1.530830682 1.288233498 [25,] 2.180736156 1.530830682 [26,] 3.602618270 2.180736156 [27,] 0.314232122 3.602618270 [28,] 3.315122473 0.314232122 [29,] -0.837040940 3.315122473 [30,] 0.791262381 -0.837040940 [31,] 3.989739394 0.791262381 [32,] 4.140665745 3.989739394 [33,] 6.976575166 4.140665745 [34,] 2.159751687 6.976575166 [35,] -3.213088806 2.159751687 [36,] 3.244193350 -3.213088806 [37,] 1.710714473 3.244193350 [38,] 2.798164659 1.710714473 [39,] 3.034430350 2.798164659 [40,] -4.499973060 3.034430350 [41,] 1.657514134 -4.499973060 [42,] -0.387879303 1.657514134 [43,] 2.868382505 -0.387879303 [44,] 0.252461288 2.868382505 [45,] -8.945154676 0.252461288 [46,] 0.009090105 -8.945154676 [47,] -2.554173747 0.009090105 [48,] -5.165003290 -2.554173747 [49,] -0.198368305 -5.165003290 [50,] -1.285121397 -0.198368305 [51,] 5.284922940 -1.285121397 [52,] 0.354498732 5.284922940 [53,] 0.139010929 0.354498732 [54,] -1.120688169 0.139010929 [55,] 1.145931249 -1.120688169 [56,] -5.229441881 1.145931249 [57,] -0.518795936 -5.229441881 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 2.713169157 2.212382022 2 -2.657054277 2.713169157 3 -3.503064862 -2.657054277 4 2.912042972 -3.503064862 5 -0.606049564 2.912042972 6 2.221448580 -0.606049564 7 -2.116895916 2.221448580 8 -6.640275619 -2.116895916 9 1.442138520 -6.640275619 10 3.090909033 1.442138520 11 4.479029055 3.090909033 12 -1.822402764 4.479029055 13 -6.406251481 -1.822402764 14 -2.458607256 -6.406251481 15 -5.130520550 -2.458607256 16 -2.081691117 -5.130520550 17 -0.353434560 -2.081691117 18 -1.504143489 -0.353434560 19 -5.887157232 -1.504143489 20 7.476590467 -5.887157232 21 1.045236926 7.476590467 22 -5.259750824 1.045236926 23 1.288233498 -5.259750824 24 1.530830682 1.288233498 25 2.180736156 1.530830682 26 3.602618270 2.180736156 27 0.314232122 3.602618270 28 3.315122473 0.314232122 29 -0.837040940 3.315122473 30 0.791262381 -0.837040940 31 3.989739394 0.791262381 32 4.140665745 3.989739394 33 6.976575166 4.140665745 34 2.159751687 6.976575166 35 -3.213088806 2.159751687 36 3.244193350 -3.213088806 37 1.710714473 3.244193350 38 2.798164659 1.710714473 39 3.034430350 2.798164659 40 -4.499973060 3.034430350 41 1.657514134 -4.499973060 42 -0.387879303 1.657514134 43 2.868382505 -0.387879303 44 0.252461288 2.868382505 45 -8.945154676 0.252461288 46 0.009090105 -8.945154676 47 -2.554173747 0.009090105 48 -5.165003290 -2.554173747 49 -0.198368305 -5.165003290 50 -1.285121397 -0.198368305 51 5.284922940 -1.285121397 52 0.354498732 5.284922940 53 0.139010929 0.354498732 54 -1.120688169 0.139010929 55 1.145931249 -1.120688169 56 -5.229441881 1.145931249 57 -0.518795936 -5.229441881 > 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/7er971258715376.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/8otn01258715376.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/9jupa1258715376.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/1050i51258715376.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/11b00t1258715376.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/122m551258715376.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/13pqf41258715376.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/14aszb1258715376.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/151j9k1258715376.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/16hwai1258715376.tab") + } > > system("convert tmp/1jl9e1258715376.ps tmp/1jl9e1258715376.png") > system("convert tmp/2gj351258715376.ps tmp/2gj351258715376.png") > system("convert tmp/3x9qu1258715376.ps tmp/3x9qu1258715376.png") > system("convert tmp/4u04b1258715376.ps tmp/4u04b1258715376.png") > system("convert tmp/5ec131258715376.ps tmp/5ec131258715376.png") > system("convert tmp/6q3ky1258715376.ps tmp/6q3ky1258715376.png") > system("convert tmp/7er971258715376.ps tmp/7er971258715376.png") > system("convert tmp/8otn01258715376.ps tmp/8otn01258715376.png") > system("convert tmp/9jupa1258715376.ps tmp/9jupa1258715376.png") > system("convert tmp/1050i51258715376.ps tmp/1050i51258715376.png") > > > proc.time() user system elapsed 2.326 1.528 2.731