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(98.8,6.3,100.5,6.1,110.4,6.1,96.4,6.3,101.9,6.3,106.2,6,81,6.2,94.7,6.4,101,6.8,109.4,7.5,102.3,7.5,90.7,7.6,96.2,7.6,96.1,7.4,106,7.3,103.1,7.1,102,6.9,104.7,6.8,86,7.5,92.1,7.6,106.9,7.8,112.6,8,101.7,8.1,92,8.2,97.4,8.3,97,8.2,105.4,8,102.7,7.9,98.1,7.6,104.5,7.6,87.4,8.3,89.9,8.4,109.8,8.4,111.7,8.4,98.6,8.4,96.9,8.6,95.1,8.9,97,8.8,112.7,8.3,102.9,7.5,97.4,7.2,111.4,7.4,87.4,8.8,96.8,9.3,114.1,9.3,110.3,8.7,103.9,8.2,101.6,8.3,94.6,8.5,95.9,8.6,104.7,8.5,102.8,8.2,98.1,8.1,113.9,7.9,80.9,8.6,95.7,8.7,113.2,8.7,105.9,8.5,108.8,8.4,102.3,8.5,99,8.7,100.7,8.7,115.5,8.6,100.7,8.5,109.9,8.3,114.6,8,85.4,8.2,100.5,8.1,114.8,8.1,116.5,8,112.9,7.9,102,7.9,106,8,105.3,8,118.8,7.9,106.1,8,109.3,7.7,117.2,7.2,92.5,7.5,104.2,7.3,112.5,7,122.4,7,113.3,7,100,7.2,110.7,7.3,112.8,7.1,109.8,6.8,117.3,6.4,109.1,6.1,115.9,6.5,96,7.7,99.8,7.9,116.8,7.5,115.7,6.9,99.4,6.6,94.3,6.9,91,7.7),dim=c(2,97),dimnames=list(c('Y','X'),1:97)) > y <- array(NA,dim=c(2,97),dimnames=list(c('Y','X'),1:97)) > 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 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 98.8 6.3 1 0 0 0 0 0 0 0 0 0 0 1 2 100.5 6.1 0 1 0 0 0 0 0 0 0 0 0 2 3 110.4 6.1 0 0 1 0 0 0 0 0 0 0 0 3 4 96.4 6.3 0 0 0 1 0 0 0 0 0 0 0 4 5 101.9 6.3 0 0 0 0 1 0 0 0 0 0 0 5 6 106.2 6.0 0 0 0 0 0 1 0 0 0 0 0 6 7 81.0 6.2 0 0 0 0 0 0 1 0 0 0 0 7 8 94.7 6.4 0 0 0 0 0 0 0 1 0 0 0 8 9 101.0 6.8 0 0 0 0 0 0 0 0 1 0 0 9 10 109.4 7.5 0 0 0 0 0 0 0 0 0 1 0 10 11 102.3 7.5 0 0 0 0 0 0 0 0 0 0 1 11 12 90.7 7.6 0 0 0 0 0 0 0 0 0 0 0 12 13 96.2 7.6 1 0 0 0 0 0 0 0 0 0 0 13 14 96.1 7.4 0 1 0 0 0 0 0 0 0 0 0 14 15 106.0 7.3 0 0 1 0 0 0 0 0 0 0 0 15 16 103.1 7.1 0 0 0 1 0 0 0 0 0 0 0 16 17 102.0 6.9 0 0 0 0 1 0 0 0 0 0 0 17 18 104.7 6.8 0 0 0 0 0 1 0 0 0 0 0 18 19 86.0 7.5 0 0 0 0 0 0 1 0 0 0 0 19 20 92.1 7.6 0 0 0 0 0 0 0 1 0 0 0 20 21 106.9 7.8 0 0 0 0 0 0 0 0 1 0 0 21 22 112.6 8.0 0 0 0 0 0 0 0 0 0 1 0 22 23 101.7 8.1 0 0 0 0 0 0 0 0 0 0 1 23 24 92.0 8.2 0 0 0 0 0 0 0 0 0 0 0 24 25 97.4 8.3 1 0 0 0 0 0 0 0 0 0 0 25 26 97.0 8.2 0 1 0 0 0 0 0 0 0 0 0 26 27 105.4 8.0 0 0 1 0 0 0 0 0 0 0 0 27 28 102.7 7.9 0 0 0 1 0 0 0 0 0 0 0 28 29 98.1 7.6 0 0 0 0 1 0 0 0 0 0 0 29 30 104.5 7.6 0 0 0 0 0 1 0 0 0 0 0 30 31 87.4 8.3 0 0 0 0 0 0 1 0 0 0 0 31 32 89.9 8.4 0 0 0 0 0 0 0 1 0 0 0 32 33 109.8 8.4 0 0 0 0 0 0 0 0 1 0 0 33 34 111.7 8.4 0 0 0 0 0 0 0 0 0 1 0 34 35 98.6 8.4 0 0 0 0 0 0 0 0 0 0 1 35 36 96.9 8.6 0 0 0 0 0 0 0 0 0 0 0 36 37 95.1 8.9 1 0 0 0 0 0 0 0 0 0 0 37 38 97.0 8.8 0 1 0 0 0 0 0 0 0 0 0 38 39 112.7 8.3 0 0 1 0 0 0 0 0 0 0 0 39 40 102.9 7.5 0 0 0 1 0 0 0 0 0 0 0 40 41 97.4 7.2 0 0 0 0 1 0 0 0 0 0 0 41 42 111.4 7.4 0 0 0 0 0 1 0 0 0 0 0 42 43 87.4 8.8 0 0 0 0 0 0 1 0 0 0 0 43 44 96.8 9.3 0 0 0 0 0 0 0 1 0 0 0 44 45 114.1 9.3 0 0 0 0 0 0 0 0 1 0 0 45 46 110.3 8.7 0 0 0 0 0 0 0 0 0 1 0 46 47 103.9 8.2 0 0 0 0 0 0 0 0 0 0 1 47 48 101.6 8.3 0 0 0 0 0 0 0 0 0 0 0 48 49 94.6 8.5 1 0 0 0 0 0 0 0 0 0 0 49 50 95.9 8.6 0 1 0 0 0 0 0 0 0 0 0 50 51 104.7 8.5 0 0 1 0 0 0 0 0 0 0 0 51 52 102.8 8.2 0 0 0 1 0 0 0 0 0 0 0 52 53 98.1 8.1 0 0 0 0 1 0 0 0 0 0 0 53 54 113.9 7.9 0 0 0 0 0 1 0 0 0 0 0 54 55 80.9 8.6 0 0 0 0 0 0 1 0 0 0 0 55 56 95.7 8.7 0 0 0 0 0 0 0 1 0 0 0 56 57 113.2 8.7 0 0 0 0 0 0 0 0 1 0 0 57 58 105.9 8.5 0 0 0 0 0 0 0 0 0 1 0 58 59 108.8 8.4 0 0 0 0 0 0 0 0 0 0 1 59 60 102.3 8.5 0 0 0 0 0 0 0 0 0 0 0 60 61 99.0 8.7 1 0 0 0 0 0 0 0 0 0 0 61 62 100.7 8.7 0 1 0 0 0 0 0 0 0 0 0 62 63 115.5 8.6 0 0 1 0 0 0 0 0 0 0 0 63 64 100.7 8.5 0 0 0 1 0 0 0 0 0 0 0 64 65 109.9 8.3 0 0 0 0 1 0 0 0 0 0 0 65 66 114.6 8.0 0 0 0 0 0 1 0 0 0 0 0 66 67 85.4 8.2 0 0 0 0 0 0 1 0 0 0 0 67 68 100.5 8.1 0 0 0 0 0 0 0 1 0 0 0 68 69 114.8 8.1 0 0 0 0 0 0 0 0 1 0 0 69 70 116.5 8.0 0 0 0 0 0 0 0 0 0 1 0 70 71 112.9 7.9 0 0 0 0 0 0 0 0 0 0 1 71 72 102.0 7.9 0 0 0 0 0 0 0 0 0 0 0 72 73 106.0 8.0 1 0 0 0 0 0 0 0 0 0 0 73 74 105.3 8.0 0 1 0 0 0 0 0 0 0 0 0 74 75 118.8 7.9 0 0 1 0 0 0 0 0 0 0 0 75 76 106.1 8.0 0 0 0 1 0 0 0 0 0 0 0 76 77 109.3 7.7 0 0 0 0 1 0 0 0 0 0 0 77 78 117.2 7.2 0 0 0 0 0 1 0 0 0 0 0 78 79 92.5 7.5 0 0 0 0 0 0 1 0 0 0 0 79 80 104.2 7.3 0 0 0 0 0 0 0 1 0 0 0 80 81 112.5 7.0 0 0 0 0 0 0 0 0 1 0 0 81 82 122.4 7.0 0 0 0 0 0 0 0 0 0 1 0 82 83 113.3 7.0 0 0 0 0 0 0 0 0 0 0 1 83 84 100.0 7.2 0 0 0 0 0 0 0 0 0 0 0 84 85 110.7 7.3 1 0 0 0 0 0 0 0 0 0 0 85 86 112.8 7.1 0 1 0 0 0 0 0 0 0 0 0 86 87 109.8 6.8 0 0 1 0 0 0 0 0 0 0 0 87 88 117.3 6.4 0 0 0 1 0 0 0 0 0 0 0 88 89 109.1 6.1 0 0 0 0 1 0 0 0 0 0 0 89 90 115.9 6.5 0 0 0 0 0 1 0 0 0 0 0 90 91 96.0 7.7 0 0 0 0 0 0 1 0 0 0 0 91 92 99.8 7.9 0 0 0 0 0 0 0 1 0 0 0 92 93 116.8 7.5 0 0 0 0 0 0 0 0 1 0 0 93 94 115.7 6.9 0 0 0 0 0 0 0 0 0 1 0 94 95 99.4 6.6 0 0 0 0 0 0 0 0 0 0 1 95 96 94.3 6.9 0 0 0 0 0 0 0 0 0 0 0 96 97 91.0 7.7 1 0 0 0 0 0 0 0 0 0 0 97 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X M1 M2 M3 M4 97.7415 -0.8150 1.8702 4.3000 13.7930 7.1032 M5 M6 M7 M8 M9 M10 6.0407 13.6699 -9.8692 -0.2543 14.0462 15.7957 M11 t 7.6397 0.1143 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -13.4232 -2.2188 0.8326 2.7413 7.6129 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 97.74154 4.79057 20.403 < 2e-16 *** X -0.81505 0.57639 -1.414 0.16108 M1 1.87018 2.04927 0.913 0.36409 M2 4.29996 2.11271 2.035 0.04501 * M3 13.79303 2.11449 6.523 5.10e-09 *** M4 7.10321 2.12279 3.346 0.00123 ** M5 6.04071 2.13873 2.824 0.00593 ** M6 13.66991 2.14848 6.363 1.03e-08 *** M7 -9.86924 2.10861 -4.680 1.10e-05 *** M8 -0.25435 2.10841 -0.121 0.90427 M9 14.04616 2.10787 6.664 2.74e-09 *** M10 15.79573 2.10736 7.496 6.51e-11 *** M11 7.63973 2.10859 3.623 0.00050 *** t 0.11430 0.01544 7.405 9.84e-11 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 4.214 on 83 degrees of freedom Multiple R-squared: 0.8058, Adjusted R-squared: 0.7754 F-statistic: 26.5 on 13 and 83 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.2231052379 0.4462104759 0.7768948 [2,] 0.1331139557 0.2662279114 0.8668860 [3,] 0.2408011316 0.4816022632 0.7591989 [4,] 0.1490622275 0.2981244550 0.8509378 [5,] 0.1544531977 0.3089063953 0.8455468 [6,] 0.0944037259 0.1888074518 0.9055963 [7,] 0.0642078344 0.1284156689 0.9357922 [8,] 0.0359339606 0.0718679211 0.9640660 [9,] 0.0202194504 0.0404389009 0.9797805 [10,] 0.0111505555 0.0223011109 0.9888494 [11,] 0.0083015705 0.0166031410 0.9916984 [12,] 0.0049866715 0.0099733430 0.9950133 [13,] 0.0061768231 0.0123536462 0.9938232 [14,] 0.0035818647 0.0071637294 0.9964181 [15,] 0.0035914393 0.0071828786 0.9964086 [16,] 0.0029133861 0.0058267722 0.9970866 [17,] 0.0036010672 0.0072021344 0.9963989 [18,] 0.0020103221 0.0040206443 0.9979897 [19,] 0.0021287670 0.0042575339 0.9978712 [20,] 0.0021028781 0.0042057563 0.9978971 [21,] 0.0014245100 0.0028490200 0.9985755 [22,] 0.0007935997 0.0015871993 0.9992064 [23,] 0.0007974861 0.0015949721 0.9992025 [24,] 0.0004183135 0.0008366269 0.9995817 [25,] 0.0006646288 0.0013292577 0.9993354 [26,] 0.0007170333 0.0014340666 0.9992830 [27,] 0.0004227949 0.0008455897 0.9995772 [28,] 0.0003476238 0.0006952476 0.9996524 [29,] 0.0007316769 0.0014633538 0.9992683 [30,] 0.0004620910 0.0009241820 0.9995379 [31,] 0.0002523053 0.0005046106 0.9997477 [32,] 0.0003589960 0.0007179921 0.9996410 [33,] 0.0004001372 0.0008002744 0.9995999 [34,] 0.0004672041 0.0009344081 0.9995328 [35,] 0.0007829457 0.0015658914 0.9992171 [36,] 0.0004834319 0.0009668639 0.9995166 [37,] 0.0007541610 0.0015083219 0.9992458 [38,] 0.0008116564 0.0016233127 0.9991883 [39,] 0.0021020005 0.0042040010 0.9978980 [40,] 0.0016327329 0.0032654657 0.9983673 [41,] 0.0011644059 0.0023288119 0.9988356 [42,] 0.0048405484 0.0096810967 0.9951595 [43,] 0.0045789559 0.0091579119 0.9954210 [44,] 0.0043029195 0.0086058389 0.9956971 [45,] 0.0030030809 0.0060061617 0.9969969 [46,] 0.0030003567 0.0060007134 0.9969996 [47,] 0.0026056078 0.0052112156 0.9973944 [48,] 0.0048844579 0.0097689158 0.9951155 [49,] 0.0059653585 0.0119307169 0.9940346 [50,] 0.0041254401 0.0082508801 0.9958746 [51,] 0.0116386887 0.0232773774 0.9883613 [52,] 0.0108488757 0.0216977514 0.9891511 [53,] 0.0072889044 0.0145778088 0.9927111 [54,] 0.0063643954 0.0127287907 0.9936356 [55,] 0.0051672420 0.0103344840 0.9948328 [56,] 0.0028337570 0.0056675141 0.9971662 [57,] 0.0015866744 0.0031733488 0.9984133 [58,] 0.0019600599 0.0039201198 0.9980399 [59,] 0.0025669702 0.0051339404 0.9974330 [60,] 0.0060717466 0.0121434933 0.9939283 [61,] 0.0039811184 0.0079622368 0.9960189 [62,] 0.0038348963 0.0076697926 0.9961651 [63,] 0.0080902139 0.0161804278 0.9919098 [64,] 0.0031576376 0.0063152752 0.9968424 > postscript(file="/var/www/html/rcomp/tmp/1wlhb1258650109.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/2ech51258650109.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/33gyn1258650109.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/4a7be1258650109.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/5vzcd1258650109.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 = 97 Frequency = 1 1 2 3 4 5 6 4.2087853 3.2016909 3.4943246 -3.7671555 2.6810426 -1.0069674 7 8 9 10 11 12 -2.6191160 1.5147008 -6.2740911 0.8325725 1.7742656 -2.2187988 13 14 15 16 17 18 1.2967168 -1.5103776 -1.2992488 2.2132512 1.8984393 -3.2265607 19 20 21 22 23 24 2.0688155 -1.4788726 -0.9306745 3.0684642 0.2916623 -1.8014021 25 26 27 28 29 30 1.6956185 -1.3299709 -2.7003472 1.0936578 -2.8026590 -4.1461541 31 32 33 34 35 36 2.7492222 -4.3984659 1.0867222 1.1228509 -3.9354560 2.0529846 37 38 39 40 41 42 -1.4869848 -2.2125742 3.4725346 -0.4039953 -5.2003121 1.2192028 43 44 45 46 47 48 1.7851139 1.8634457 4.7486338 -1.4042673 -0.1700991 5.1368365 49 50 51 52 53 54 -3.6846379 -4.8472174 -5.7360886 -1.3050936 -5.1384005 2.7550945 55 56 57 58 59 60 -6.2495292 -1.0972174 1.9879708 -7.3389105 3.5212777 4.6282133 61 62 63 64 65 66 -0.4932611 -1.3373456 3.7737832 -4.5322119 5.4529763 2.1649663 67 68 69 70 71 72 -3.4471823 1.8421196 1.7273077 1.4819315 5.8421196 2.4675502 73 74 75 76 77 78 4.5645708 1.3204864 5.1316151 -0.9113699 2.9923132 2.7412933 79 80 81 82 83 84 1.7106496 3.5184466 -2.8408803 5.1952485 4.1369416 -1.4746178 85 86 87 88 89 90 7.3224028 6.7153084 -6.1365728 7.6129172 0.1166004 -0.5008747 91 92 93 94 95 96 4.0020264 -1.7641567 0.4950115 -2.9578897 -11.4607115 -8.7907659 97 -13.4232104 > postscript(file="/var/www/html/rcomp/tmp/6zwr31258650109.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 = 97 Frequency = 1 lag(myerror, k = 1) myerror 0 4.2087853 NA 1 3.2016909 4.2087853 2 3.4943246 3.2016909 3 -3.7671555 3.4943246 4 2.6810426 -3.7671555 5 -1.0069674 2.6810426 6 -2.6191160 -1.0069674 7 1.5147008 -2.6191160 8 -6.2740911 1.5147008 9 0.8325725 -6.2740911 10 1.7742656 0.8325725 11 -2.2187988 1.7742656 12 1.2967168 -2.2187988 13 -1.5103776 1.2967168 14 -1.2992488 -1.5103776 15 2.2132512 -1.2992488 16 1.8984393 2.2132512 17 -3.2265607 1.8984393 18 2.0688155 -3.2265607 19 -1.4788726 2.0688155 20 -0.9306745 -1.4788726 21 3.0684642 -0.9306745 22 0.2916623 3.0684642 23 -1.8014021 0.2916623 24 1.6956185 -1.8014021 25 -1.3299709 1.6956185 26 -2.7003472 -1.3299709 27 1.0936578 -2.7003472 28 -2.8026590 1.0936578 29 -4.1461541 -2.8026590 30 2.7492222 -4.1461541 31 -4.3984659 2.7492222 32 1.0867222 -4.3984659 33 1.1228509 1.0867222 34 -3.9354560 1.1228509 35 2.0529846 -3.9354560 36 -1.4869848 2.0529846 37 -2.2125742 -1.4869848 38 3.4725346 -2.2125742 39 -0.4039953 3.4725346 40 -5.2003121 -0.4039953 41 1.2192028 -5.2003121 42 1.7851139 1.2192028 43 1.8634457 1.7851139 44 4.7486338 1.8634457 45 -1.4042673 4.7486338 46 -0.1700991 -1.4042673 47 5.1368365 -0.1700991 48 -3.6846379 5.1368365 49 -4.8472174 -3.6846379 50 -5.7360886 -4.8472174 51 -1.3050936 -5.7360886 52 -5.1384005 -1.3050936 53 2.7550945 -5.1384005 54 -6.2495292 2.7550945 55 -1.0972174 -6.2495292 56 1.9879708 -1.0972174 57 -7.3389105 1.9879708 58 3.5212777 -7.3389105 59 4.6282133 3.5212777 60 -0.4932611 4.6282133 61 -1.3373456 -0.4932611 62 3.7737832 -1.3373456 63 -4.5322119 3.7737832 64 5.4529763 -4.5322119 65 2.1649663 5.4529763 66 -3.4471823 2.1649663 67 1.8421196 -3.4471823 68 1.7273077 1.8421196 69 1.4819315 1.7273077 70 5.8421196 1.4819315 71 2.4675502 5.8421196 72 4.5645708 2.4675502 73 1.3204864 4.5645708 74 5.1316151 1.3204864 75 -0.9113699 5.1316151 76 2.9923132 -0.9113699 77 2.7412933 2.9923132 78 1.7106496 2.7412933 79 3.5184466 1.7106496 80 -2.8408803 3.5184466 81 5.1952485 -2.8408803 82 4.1369416 5.1952485 83 -1.4746178 4.1369416 84 7.3224028 -1.4746178 85 6.7153084 7.3224028 86 -6.1365728 6.7153084 87 7.6129172 -6.1365728 88 0.1166004 7.6129172 89 -0.5008747 0.1166004 90 4.0020264 -0.5008747 91 -1.7641567 4.0020264 92 0.4950115 -1.7641567 93 -2.9578897 0.4950115 94 -11.4607115 -2.9578897 95 -8.7907659 -11.4607115 96 -13.4232104 -8.7907659 97 NA -13.4232104 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 3.2016909 4.2087853 [2,] 3.4943246 3.2016909 [3,] -3.7671555 3.4943246 [4,] 2.6810426 -3.7671555 [5,] -1.0069674 2.6810426 [6,] -2.6191160 -1.0069674 [7,] 1.5147008 -2.6191160 [8,] -6.2740911 1.5147008 [9,] 0.8325725 -6.2740911 [10,] 1.7742656 0.8325725 [11,] -2.2187988 1.7742656 [12,] 1.2967168 -2.2187988 [13,] -1.5103776 1.2967168 [14,] -1.2992488 -1.5103776 [15,] 2.2132512 -1.2992488 [16,] 1.8984393 2.2132512 [17,] -3.2265607 1.8984393 [18,] 2.0688155 -3.2265607 [19,] -1.4788726 2.0688155 [20,] -0.9306745 -1.4788726 [21,] 3.0684642 -0.9306745 [22,] 0.2916623 3.0684642 [23,] -1.8014021 0.2916623 [24,] 1.6956185 -1.8014021 [25,] -1.3299709 1.6956185 [26,] -2.7003472 -1.3299709 [27,] 1.0936578 -2.7003472 [28,] -2.8026590 1.0936578 [29,] -4.1461541 -2.8026590 [30,] 2.7492222 -4.1461541 [31,] -4.3984659 2.7492222 [32,] 1.0867222 -4.3984659 [33,] 1.1228509 1.0867222 [34,] -3.9354560 1.1228509 [35,] 2.0529846 -3.9354560 [36,] -1.4869848 2.0529846 [37,] -2.2125742 -1.4869848 [38,] 3.4725346 -2.2125742 [39,] -0.4039953 3.4725346 [40,] -5.2003121 -0.4039953 [41,] 1.2192028 -5.2003121 [42,] 1.7851139 1.2192028 [43,] 1.8634457 1.7851139 [44,] 4.7486338 1.8634457 [45,] -1.4042673 4.7486338 [46,] -0.1700991 -1.4042673 [47,] 5.1368365 -0.1700991 [48,] -3.6846379 5.1368365 [49,] -4.8472174 -3.6846379 [50,] -5.7360886 -4.8472174 [51,] -1.3050936 -5.7360886 [52,] -5.1384005 -1.3050936 [53,] 2.7550945 -5.1384005 [54,] -6.2495292 2.7550945 [55,] -1.0972174 -6.2495292 [56,] 1.9879708 -1.0972174 [57,] -7.3389105 1.9879708 [58,] 3.5212777 -7.3389105 [59,] 4.6282133 3.5212777 [60,] -0.4932611 4.6282133 [61,] -1.3373456 -0.4932611 [62,] 3.7737832 -1.3373456 [63,] -4.5322119 3.7737832 [64,] 5.4529763 -4.5322119 [65,] 2.1649663 5.4529763 [66,] -3.4471823 2.1649663 [67,] 1.8421196 -3.4471823 [68,] 1.7273077 1.8421196 [69,] 1.4819315 1.7273077 [70,] 5.8421196 1.4819315 [71,] 2.4675502 5.8421196 [72,] 4.5645708 2.4675502 [73,] 1.3204864 4.5645708 [74,] 5.1316151 1.3204864 [75,] -0.9113699 5.1316151 [76,] 2.9923132 -0.9113699 [77,] 2.7412933 2.9923132 [78,] 1.7106496 2.7412933 [79,] 3.5184466 1.7106496 [80,] -2.8408803 3.5184466 [81,] 5.1952485 -2.8408803 [82,] 4.1369416 5.1952485 [83,] -1.4746178 4.1369416 [84,] 7.3224028 -1.4746178 [85,] 6.7153084 7.3224028 [86,] -6.1365728 6.7153084 [87,] 7.6129172 -6.1365728 [88,] 0.1166004 7.6129172 [89,] -0.5008747 0.1166004 [90,] 4.0020264 -0.5008747 [91,] -1.7641567 4.0020264 [92,] 0.4950115 -1.7641567 [93,] -2.9578897 0.4950115 [94,] -11.4607115 -2.9578897 [95,] -8.7907659 -11.4607115 [96,] -13.4232104 -8.7907659 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 3.2016909 4.2087853 2 3.4943246 3.2016909 3 -3.7671555 3.4943246 4 2.6810426 -3.7671555 5 -1.0069674 2.6810426 6 -2.6191160 -1.0069674 7 1.5147008 -2.6191160 8 -6.2740911 1.5147008 9 0.8325725 -6.2740911 10 1.7742656 0.8325725 11 -2.2187988 1.7742656 12 1.2967168 -2.2187988 13 -1.5103776 1.2967168 14 -1.2992488 -1.5103776 15 2.2132512 -1.2992488 16 1.8984393 2.2132512 17 -3.2265607 1.8984393 18 2.0688155 -3.2265607 19 -1.4788726 2.0688155 20 -0.9306745 -1.4788726 21 3.0684642 -0.9306745 22 0.2916623 3.0684642 23 -1.8014021 0.2916623 24 1.6956185 -1.8014021 25 -1.3299709 1.6956185 26 -2.7003472 -1.3299709 27 1.0936578 -2.7003472 28 -2.8026590 1.0936578 29 -4.1461541 -2.8026590 30 2.7492222 -4.1461541 31 -4.3984659 2.7492222 32 1.0867222 -4.3984659 33 1.1228509 1.0867222 34 -3.9354560 1.1228509 35 2.0529846 -3.9354560 36 -1.4869848 2.0529846 37 -2.2125742 -1.4869848 38 3.4725346 -2.2125742 39 -0.4039953 3.4725346 40 -5.2003121 -0.4039953 41 1.2192028 -5.2003121 42 1.7851139 1.2192028 43 1.8634457 1.7851139 44 4.7486338 1.8634457 45 -1.4042673 4.7486338 46 -0.1700991 -1.4042673 47 5.1368365 -0.1700991 48 -3.6846379 5.1368365 49 -4.8472174 -3.6846379 50 -5.7360886 -4.8472174 51 -1.3050936 -5.7360886 52 -5.1384005 -1.3050936 53 2.7550945 -5.1384005 54 -6.2495292 2.7550945 55 -1.0972174 -6.2495292 56 1.9879708 -1.0972174 57 -7.3389105 1.9879708 58 3.5212777 -7.3389105 59 4.6282133 3.5212777 60 -0.4932611 4.6282133 61 -1.3373456 -0.4932611 62 3.7737832 -1.3373456 63 -4.5322119 3.7737832 64 5.4529763 -4.5322119 65 2.1649663 5.4529763 66 -3.4471823 2.1649663 67 1.8421196 -3.4471823 68 1.7273077 1.8421196 69 1.4819315 1.7273077 70 5.8421196 1.4819315 71 2.4675502 5.8421196 72 4.5645708 2.4675502 73 1.3204864 4.5645708 74 5.1316151 1.3204864 75 -0.9113699 5.1316151 76 2.9923132 -0.9113699 77 2.7412933 2.9923132 78 1.7106496 2.7412933 79 3.5184466 1.7106496 80 -2.8408803 3.5184466 81 5.1952485 -2.8408803 82 4.1369416 5.1952485 83 -1.4746178 4.1369416 84 7.3224028 -1.4746178 85 6.7153084 7.3224028 86 -6.1365728 6.7153084 87 7.6129172 -6.1365728 88 0.1166004 7.6129172 89 -0.5008747 0.1166004 90 4.0020264 -0.5008747 91 -1.7641567 4.0020264 92 0.4950115 -1.7641567 93 -2.9578897 0.4950115 94 -11.4607115 -2.9578897 95 -8.7907659 -11.4607115 96 -13.4232104 -8.7907659 > 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/74cg01258650109.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/8ka771258650109.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/93vhk1258650109.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/10xjyr1258650109.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/119ffb1258650109.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/12cm0g1258650109.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/13kc4w1258650110.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/14qoc11258650110.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/15epwo1258650110.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/1635d01258650110.tab") + } > > system("convert tmp/1wlhb1258650109.ps tmp/1wlhb1258650109.png") > system("convert tmp/2ech51258650109.ps tmp/2ech51258650109.png") > system("convert tmp/33gyn1258650109.ps tmp/33gyn1258650109.png") > system("convert tmp/4a7be1258650109.ps tmp/4a7be1258650109.png") > system("convert tmp/5vzcd1258650109.ps tmp/5vzcd1258650109.png") > system("convert tmp/6zwr31258650109.ps tmp/6zwr31258650109.png") > system("convert tmp/74cg01258650109.ps tmp/74cg01258650109.png") > system("convert tmp/8ka771258650109.ps tmp/8ka771258650109.png") > system("convert tmp/93vhk1258650109.ps tmp/93vhk1258650109.png") > system("convert tmp/10xjyr1258650109.ps tmp/10xjyr1258650109.png") > > > proc.time() user system elapsed 2.978 1.639 5.541