R version 2.8.0 (2008-10-20) Copyright (C) 2008 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(90.7,0,94.3,0,104.6,0,111.1,0,110.8,0,107.2,0,99,0,99,0,91,0,96.2,0,96.9,0,96.2,0,100.1,0,99,0,115.4,0,106.9,0,107.1,0,99.3,0,99.2,0,108.3,0,105.6,0,99.5,0,107.4,0,93.1,0,88.1,0,110.7,0,113.1,0,99.6,0,93.6,0,98.6,0,99.6,0,114.3,0,107.8,0,101.2,0,112.5,0,100.5,0,93.9,0,116.2,0,112,0,106.4,0,95.7,0,96,0,95.8,0,103,0,102.2,0,98.4,0,111.4,1,86.6,1,91.3,1,107.9,1,101.8,1,104.4,1,93.4,1,100.1,1,98.5,1,112.9,1,101.4,1,107.1,1,110.8,1,90.3,1,95.5,1,111.4,1,113,1,107.5,1,95.9,1,106.3,1,105.2,1,117.2,1,106.9,1,108.2,1,113,1,97.2,1,99.9,1,108.1,1,118.1,1,109.1,1,93.3,1,112.1,1,111.8,1,112.5,1,116.3,1,110.3,1,117.1,1,103.4,1,96.2,1),dim=c(2,85),dimnames=list(c('Prodintergoed','invest'),1:85)) > y <- array(NA,dim=c(2,85),dimnames=list(c('Prodintergoed','invest'),1:85)) > 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 Prodintergoed invest M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 90.7 0 1 0 0 0 0 0 0 0 0 0 0 1 2 94.3 0 0 1 0 0 0 0 0 0 0 0 0 2 3 104.6 0 0 0 1 0 0 0 0 0 0 0 0 3 4 111.1 0 0 0 0 1 0 0 0 0 0 0 0 4 5 110.8 0 0 0 0 0 1 0 0 0 0 0 0 5 6 107.2 0 0 0 0 0 0 1 0 0 0 0 0 6 7 99.0 0 0 0 0 0 0 0 1 0 0 0 0 7 8 99.0 0 0 0 0 0 0 0 0 1 0 0 0 8 9 91.0 0 0 0 0 0 0 0 0 0 1 0 0 9 10 96.2 0 0 0 0 0 0 0 0 0 0 1 0 10 11 96.9 0 0 0 0 0 0 0 0 0 0 0 1 11 12 96.2 0 0 0 0 0 0 0 0 0 0 0 0 12 13 100.1 0 1 0 0 0 0 0 0 0 0 0 0 13 14 99.0 0 0 1 0 0 0 0 0 0 0 0 0 14 15 115.4 0 0 0 1 0 0 0 0 0 0 0 0 15 16 106.9 0 0 0 0 1 0 0 0 0 0 0 0 16 17 107.1 0 0 0 0 0 1 0 0 0 0 0 0 17 18 99.3 0 0 0 0 0 0 1 0 0 0 0 0 18 19 99.2 0 0 0 0 0 0 0 1 0 0 0 0 19 20 108.3 0 0 0 0 0 0 0 0 1 0 0 0 20 21 105.6 0 0 0 0 0 0 0 0 0 1 0 0 21 22 99.5 0 0 0 0 0 0 0 0 0 0 1 0 22 23 107.4 0 0 0 0 0 0 0 0 0 0 0 1 23 24 93.1 0 0 0 0 0 0 0 0 0 0 0 0 24 25 88.1 0 1 0 0 0 0 0 0 0 0 0 0 25 26 110.7 0 0 1 0 0 0 0 0 0 0 0 0 26 27 113.1 0 0 0 1 0 0 0 0 0 0 0 0 27 28 99.6 0 0 0 0 1 0 0 0 0 0 0 0 28 29 93.6 0 0 0 0 0 1 0 0 0 0 0 0 29 30 98.6 0 0 0 0 0 0 1 0 0 0 0 0 30 31 99.6 0 0 0 0 0 0 0 1 0 0 0 0 31 32 114.3 0 0 0 0 0 0 0 0 1 0 0 0 32 33 107.8 0 0 0 0 0 0 0 0 0 1 0 0 33 34 101.2 0 0 0 0 0 0 0 0 0 0 1 0 34 35 112.5 0 0 0 0 0 0 0 0 0 0 0 1 35 36 100.5 0 0 0 0 0 0 0 0 0 0 0 0 36 37 93.9 0 1 0 0 0 0 0 0 0 0 0 0 37 38 116.2 0 0 1 0 0 0 0 0 0 0 0 0 38 39 112.0 0 0 0 1 0 0 0 0 0 0 0 0 39 40 106.4 0 0 0 0 1 0 0 0 0 0 0 0 40 41 95.7 0 0 0 0 0 1 0 0 0 0 0 0 41 42 96.0 0 0 0 0 0 0 1 0 0 0 0 0 42 43 95.8 0 0 0 0 0 0 0 1 0 0 0 0 43 44 103.0 0 0 0 0 0 0 0 0 1 0 0 0 44 45 102.2 0 0 0 0 0 0 0 0 0 1 0 0 45 46 98.4 0 0 0 0 0 0 0 0 0 0 1 0 46 47 111.4 1 0 0 0 0 0 0 0 0 0 0 1 47 48 86.6 1 0 0 0 0 0 0 0 0 0 0 0 48 49 91.3 1 1 0 0 0 0 0 0 0 0 0 0 49 50 107.9 1 0 1 0 0 0 0 0 0 0 0 0 50 51 101.8 1 0 0 1 0 0 0 0 0 0 0 0 51 52 104.4 1 0 0 0 1 0 0 0 0 0 0 0 52 53 93.4 1 0 0 0 0 1 0 0 0 0 0 0 53 54 100.1 1 0 0 0 0 0 1 0 0 0 0 0 54 55 98.5 1 0 0 0 0 0 0 1 0 0 0 0 55 56 112.9 1 0 0 0 0 0 0 0 1 0 0 0 56 57 101.4 1 0 0 0 0 0 0 0 0 1 0 0 57 58 107.1 1 0 0 0 0 0 0 0 0 0 1 0 58 59 110.8 1 0 0 0 0 0 0 0 0 0 0 1 59 60 90.3 1 0 0 0 0 0 0 0 0 0 0 0 60 61 95.5 1 1 0 0 0 0 0 0 0 0 0 0 61 62 111.4 1 0 1 0 0 0 0 0 0 0 0 0 62 63 113.0 1 0 0 1 0 0 0 0 0 0 0 0 63 64 107.5 1 0 0 0 1 0 0 0 0 0 0 0 64 65 95.9 1 0 0 0 0 1 0 0 0 0 0 0 65 66 106.3 1 0 0 0 0 0 1 0 0 0 0 0 66 67 105.2 1 0 0 0 0 0 0 1 0 0 0 0 67 68 117.2 1 0 0 0 0 0 0 0 1 0 0 0 68 69 106.9 1 0 0 0 0 0 0 0 0 1 0 0 69 70 108.2 1 0 0 0 0 0 0 0 0 0 1 0 70 71 113.0 1 0 0 0 0 0 0 0 0 0 0 1 71 72 97.2 1 0 0 0 0 0 0 0 0 0 0 0 72 73 99.9 1 1 0 0 0 0 0 0 0 0 0 0 73 74 108.1 1 0 1 0 0 0 0 0 0 0 0 0 74 75 118.1 1 0 0 1 0 0 0 0 0 0 0 0 75 76 109.1 1 0 0 0 1 0 0 0 0 0 0 0 76 77 93.3 1 0 0 0 0 1 0 0 0 0 0 0 77 78 112.1 1 0 0 0 0 0 1 0 0 0 0 0 78 79 111.8 1 0 0 0 0 0 0 1 0 0 0 0 79 80 112.5 1 0 0 0 0 0 0 0 1 0 0 0 80 81 116.3 1 0 0 0 0 0 0 0 0 1 0 0 81 82 110.3 1 0 0 0 0 0 0 0 0 0 1 0 82 83 117.1 1 0 0 0 0 0 0 0 0 0 0 1 83 84 103.4 1 0 0 0 0 0 0 0 0 0 0 0 84 85 96.2 1 1 0 0 0 0 0 0 0 0 0 0 85 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) invest M1 M2 M3 M4 90.0120 -2.5061 -0.3421 12.5194 16.7216 11.8668 M5 M6 M7 M8 M9 M10 3.8404 7.9570 6.3164 14.4758 9.1923 7.5803 M11 t 14.6835 0.1406 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -9.5979 -3.3122 -0.2402 3.2721 16.2445 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 90.01203 2.50466 35.938 < 2e-16 *** invest -2.50614 2.43508 -1.029 0.306888 M1 -0.34210 2.87998 -0.119 0.905781 M2 12.51937 2.98278 4.197 7.71e-05 *** M3 16.72163 2.97997 5.611 3.63e-07 *** M4 11.86675 2.97798 3.985 0.000162 *** M5 3.84044 2.97681 1.290 0.201196 M6 7.95699 2.97647 2.673 0.009312 ** M7 6.31639 2.97695 2.122 0.037348 * M8 14.47579 2.97825 4.861 6.78e-06 *** M9 9.19234 2.98038 3.084 0.002906 ** M10 7.58032 2.98333 2.541 0.013244 * M11 14.68345 2.97179 4.941 4.99e-06 *** t 0.14060 0.04954 2.838 0.005911 ** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 5.559 on 71 degrees of freedom Multiple R-squared: 0.5718, Adjusted R-squared: 0.4934 F-statistic: 7.293 on 13 and 71 DF, p-value: 8.202e-09 > 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.8933608 0.2132783671 0.1066391835 [2,] 0.9396587 0.1206826847 0.0603413424 [3,] 0.8922287 0.2155425834 0.1077712917 [4,] 0.8926656 0.2146687138 0.1073343569 [5,] 0.9471641 0.1056717925 0.0528358963 [6,] 0.9121426 0.1757147876 0.0878573938 [7,] 0.8990780 0.2018440308 0.1009220154 [8,] 0.8925059 0.2149881559 0.1074940780 [9,] 0.9465220 0.1069559136 0.0534779568 [10,] 0.9651793 0.0696414610 0.0348207305 [11,] 0.9546474 0.0907052834 0.0453526417 [12,] 0.9804584 0.0390831810 0.0195415905 [13,] 0.9958887 0.0082225029 0.0041112514 [14,] 0.9938341 0.0123317450 0.0061658725 [15,] 0.9894155 0.0211689612 0.0105844806 [16,] 0.9932635 0.0134729019 0.0067364510 [17,] 0.9939605 0.0120789118 0.0060394559 [18,] 0.9898328 0.0203343298 0.0101671649 [19,] 0.9891213 0.0217573265 0.0108786633 [20,] 0.9942723 0.0114553433 0.0057276716 [21,] 0.9918855 0.0162290526 0.0081145263 [22,] 0.9986290 0.0027419356 0.0013709678 [23,] 0.9988308 0.0023383560 0.0011691780 [24,] 0.9989175 0.0021649726 0.0010824863 [25,] 0.9998487 0.0003025160 0.0001512580 [26,] 0.9997898 0.0004204522 0.0002102261 [27,] 0.9996319 0.0007361008 0.0003680504 [28,] 0.9994527 0.0010945442 0.0005472721 [29,] 0.9990825 0.0018349585 0.0009174792 [30,] 0.9982537 0.0034926150 0.0017463075 [31,] 0.9978318 0.0043363814 0.0021681907 [32,] 0.9979911 0.0040177443 0.0020088721 [33,] 0.9962791 0.0074418933 0.0037209466 [34,] 0.9946949 0.0106102477 0.0053051238 [35,] 0.9978019 0.0043961560 0.0021980780 [36,] 0.9958242 0.0083515584 0.0041757792 [37,] 0.9946342 0.0107316514 0.0053658257 [38,] 0.9926171 0.0147658772 0.0073829386 [39,] 0.9920002 0.0159995710 0.0079997855 [40,] 0.9892676 0.0214647230 0.0107323615 [41,] 0.9895716 0.0208567776 0.0104283888 [42,] 0.9849849 0.0300302272 0.0150151136 [43,] 0.9727578 0.0544844731 0.0272422365 [44,] 0.9763892 0.0472216656 0.0236108328 [45,] 0.9567301 0.0865398411 0.0432699205 [46,] 0.9522083 0.0955833665 0.0477916833 [47,] 0.9207932 0.1584136017 0.0792068008 [48,] 0.8636229 0.2727542138 0.1363771069 [49,] 0.8381985 0.3236030533 0.1618015266 [50,] 0.7559427 0.4881146659 0.2440573329 [51,] 0.6675120 0.6649760362 0.3324880181 [52,] 0.6913494 0.6173011386 0.3086505693 > postscript(file="/var/www/html/rcomp/tmp/1xkos1227512684.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/2agdo1227512684.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/3x1qf1227512684.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/4kmzj1227512684.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/5yddd1227512684.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 = 85 Frequency = 1 1 2 3 4 5 6 0.88947368 -8.51259398 -2.55545113 8.65883459 16.24454887 8.38740602 7 8 9 10 11 12 1.68740602 -6.61259398 -9.46973684 -2.79830827 -9.34204261 4.50081454 13 14 15 16 17 18 8.60231830 -5.49974937 6.55739348 2.77167920 10.85739348 -1.19974937 19 20 21 22 23 24 0.20025063 1.00025063 3.44310777 -1.18546366 -0.52919799 -0.28634085 25 26 27 28 29 30 -5.08483709 4.51309524 2.57023810 -6.21547619 -4.32976190 -3.58690476 31 32 33 34 35 36 -1.08690476 5.31309524 3.95595238 -1.17261905 2.88364662 5.42650376 37 38 39 40 41 42 -0.97199248 8.32593985 -0.21691729 -1.10263158 -3.91691729 -7.87406015 43 44 45 46 47 48 -6.57406015 -7.67406015 -3.33120301 -5.65977444 2.60263158 -7.65451128 49 50 51 52 53 54 -2.75300752 0.84492481 -9.59793233 -2.28364662 -5.39793233 -2.95507519 55 56 57 58 59 60 -3.05507519 3.04492481 -3.31221805 3.85921053 0.31547619 -5.64166667 61 62 63 64 65 66 -0.24016291 2.65776942 -0.08508772 -0.87080201 -4.58508772 1.55776942 67 68 69 70 71 72 1.95776942 5.65776942 0.50062657 3.27205514 0.82832080 -0.42882206 73 74 75 76 77 78 2.47268170 -2.32938596 3.32775689 -0.95795739 -8.87224311 5.67061404 79 80 81 82 83 84 6.87061404 -0.72938596 8.21347118 3.68489975 3.24116541 4.08402256 85 -2.91447368 > postscript(file="/var/www/html/rcomp/tmp/6uwhf1227512684.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 = 85 Frequency = 1 lag(myerror, k = 1) myerror 0 0.88947368 NA 1 -8.51259398 0.88947368 2 -2.55545113 -8.51259398 3 8.65883459 -2.55545113 4 16.24454887 8.65883459 5 8.38740602 16.24454887 6 1.68740602 8.38740602 7 -6.61259398 1.68740602 8 -9.46973684 -6.61259398 9 -2.79830827 -9.46973684 10 -9.34204261 -2.79830827 11 4.50081454 -9.34204261 12 8.60231830 4.50081454 13 -5.49974937 8.60231830 14 6.55739348 -5.49974937 15 2.77167920 6.55739348 16 10.85739348 2.77167920 17 -1.19974937 10.85739348 18 0.20025063 -1.19974937 19 1.00025063 0.20025063 20 3.44310777 1.00025063 21 -1.18546366 3.44310777 22 -0.52919799 -1.18546366 23 -0.28634085 -0.52919799 24 -5.08483709 -0.28634085 25 4.51309524 -5.08483709 26 2.57023810 4.51309524 27 -6.21547619 2.57023810 28 -4.32976190 -6.21547619 29 -3.58690476 -4.32976190 30 -1.08690476 -3.58690476 31 5.31309524 -1.08690476 32 3.95595238 5.31309524 33 -1.17261905 3.95595238 34 2.88364662 -1.17261905 35 5.42650376 2.88364662 36 -0.97199248 5.42650376 37 8.32593985 -0.97199248 38 -0.21691729 8.32593985 39 -1.10263158 -0.21691729 40 -3.91691729 -1.10263158 41 -7.87406015 -3.91691729 42 -6.57406015 -7.87406015 43 -7.67406015 -6.57406015 44 -3.33120301 -7.67406015 45 -5.65977444 -3.33120301 46 2.60263158 -5.65977444 47 -7.65451128 2.60263158 48 -2.75300752 -7.65451128 49 0.84492481 -2.75300752 50 -9.59793233 0.84492481 51 -2.28364662 -9.59793233 52 -5.39793233 -2.28364662 53 -2.95507519 -5.39793233 54 -3.05507519 -2.95507519 55 3.04492481 -3.05507519 56 -3.31221805 3.04492481 57 3.85921053 -3.31221805 58 0.31547619 3.85921053 59 -5.64166667 0.31547619 60 -0.24016291 -5.64166667 61 2.65776942 -0.24016291 62 -0.08508772 2.65776942 63 -0.87080201 -0.08508772 64 -4.58508772 -0.87080201 65 1.55776942 -4.58508772 66 1.95776942 1.55776942 67 5.65776942 1.95776942 68 0.50062657 5.65776942 69 3.27205514 0.50062657 70 0.82832080 3.27205514 71 -0.42882206 0.82832080 72 2.47268170 -0.42882206 73 -2.32938596 2.47268170 74 3.32775689 -2.32938596 75 -0.95795739 3.32775689 76 -8.87224311 -0.95795739 77 5.67061404 -8.87224311 78 6.87061404 5.67061404 79 -0.72938596 6.87061404 80 8.21347118 -0.72938596 81 3.68489975 8.21347118 82 3.24116541 3.68489975 83 4.08402256 3.24116541 84 -2.91447368 4.08402256 85 NA -2.91447368 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -8.51259398 0.88947368 [2,] -2.55545113 -8.51259398 [3,] 8.65883459 -2.55545113 [4,] 16.24454887 8.65883459 [5,] 8.38740602 16.24454887 [6,] 1.68740602 8.38740602 [7,] -6.61259398 1.68740602 [8,] -9.46973684 -6.61259398 [9,] -2.79830827 -9.46973684 [10,] -9.34204261 -2.79830827 [11,] 4.50081454 -9.34204261 [12,] 8.60231830 4.50081454 [13,] -5.49974937 8.60231830 [14,] 6.55739348 -5.49974937 [15,] 2.77167920 6.55739348 [16,] 10.85739348 2.77167920 [17,] -1.19974937 10.85739348 [18,] 0.20025063 -1.19974937 [19,] 1.00025063 0.20025063 [20,] 3.44310777 1.00025063 [21,] -1.18546366 3.44310777 [22,] -0.52919799 -1.18546366 [23,] -0.28634085 -0.52919799 [24,] -5.08483709 -0.28634085 [25,] 4.51309524 -5.08483709 [26,] 2.57023810 4.51309524 [27,] -6.21547619 2.57023810 [28,] -4.32976190 -6.21547619 [29,] -3.58690476 -4.32976190 [30,] -1.08690476 -3.58690476 [31,] 5.31309524 -1.08690476 [32,] 3.95595238 5.31309524 [33,] -1.17261905 3.95595238 [34,] 2.88364662 -1.17261905 [35,] 5.42650376 2.88364662 [36,] -0.97199248 5.42650376 [37,] 8.32593985 -0.97199248 [38,] -0.21691729 8.32593985 [39,] -1.10263158 -0.21691729 [40,] -3.91691729 -1.10263158 [41,] -7.87406015 -3.91691729 [42,] -6.57406015 -7.87406015 [43,] -7.67406015 -6.57406015 [44,] -3.33120301 -7.67406015 [45,] -5.65977444 -3.33120301 [46,] 2.60263158 -5.65977444 [47,] -7.65451128 2.60263158 [48,] -2.75300752 -7.65451128 [49,] 0.84492481 -2.75300752 [50,] -9.59793233 0.84492481 [51,] -2.28364662 -9.59793233 [52,] -5.39793233 -2.28364662 [53,] -2.95507519 -5.39793233 [54,] -3.05507519 -2.95507519 [55,] 3.04492481 -3.05507519 [56,] -3.31221805 3.04492481 [57,] 3.85921053 -3.31221805 [58,] 0.31547619 3.85921053 [59,] -5.64166667 0.31547619 [60,] -0.24016291 -5.64166667 [61,] 2.65776942 -0.24016291 [62,] -0.08508772 2.65776942 [63,] -0.87080201 -0.08508772 [64,] -4.58508772 -0.87080201 [65,] 1.55776942 -4.58508772 [66,] 1.95776942 1.55776942 [67,] 5.65776942 1.95776942 [68,] 0.50062657 5.65776942 [69,] 3.27205514 0.50062657 [70,] 0.82832080 3.27205514 [71,] -0.42882206 0.82832080 [72,] 2.47268170 -0.42882206 [73,] -2.32938596 2.47268170 [74,] 3.32775689 -2.32938596 [75,] -0.95795739 3.32775689 [76,] -8.87224311 -0.95795739 [77,] 5.67061404 -8.87224311 [78,] 6.87061404 5.67061404 [79,] -0.72938596 6.87061404 [80,] 8.21347118 -0.72938596 [81,] 3.68489975 8.21347118 [82,] 3.24116541 3.68489975 [83,] 4.08402256 3.24116541 [84,] -2.91447368 4.08402256 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -8.51259398 0.88947368 2 -2.55545113 -8.51259398 3 8.65883459 -2.55545113 4 16.24454887 8.65883459 5 8.38740602 16.24454887 6 1.68740602 8.38740602 7 -6.61259398 1.68740602 8 -9.46973684 -6.61259398 9 -2.79830827 -9.46973684 10 -9.34204261 -2.79830827 11 4.50081454 -9.34204261 12 8.60231830 4.50081454 13 -5.49974937 8.60231830 14 6.55739348 -5.49974937 15 2.77167920 6.55739348 16 10.85739348 2.77167920 17 -1.19974937 10.85739348 18 0.20025063 -1.19974937 19 1.00025063 0.20025063 20 3.44310777 1.00025063 21 -1.18546366 3.44310777 22 -0.52919799 -1.18546366 23 -0.28634085 -0.52919799 24 -5.08483709 -0.28634085 25 4.51309524 -5.08483709 26 2.57023810 4.51309524 27 -6.21547619 2.57023810 28 -4.32976190 -6.21547619 29 -3.58690476 -4.32976190 30 -1.08690476 -3.58690476 31 5.31309524 -1.08690476 32 3.95595238 5.31309524 33 -1.17261905 3.95595238 34 2.88364662 -1.17261905 35 5.42650376 2.88364662 36 -0.97199248 5.42650376 37 8.32593985 -0.97199248 38 -0.21691729 8.32593985 39 -1.10263158 -0.21691729 40 -3.91691729 -1.10263158 41 -7.87406015 -3.91691729 42 -6.57406015 -7.87406015 43 -7.67406015 -6.57406015 44 -3.33120301 -7.67406015 45 -5.65977444 -3.33120301 46 2.60263158 -5.65977444 47 -7.65451128 2.60263158 48 -2.75300752 -7.65451128 49 0.84492481 -2.75300752 50 -9.59793233 0.84492481 51 -2.28364662 -9.59793233 52 -5.39793233 -2.28364662 53 -2.95507519 -5.39793233 54 -3.05507519 -2.95507519 55 3.04492481 -3.05507519 56 -3.31221805 3.04492481 57 3.85921053 -3.31221805 58 0.31547619 3.85921053 59 -5.64166667 0.31547619 60 -0.24016291 -5.64166667 61 2.65776942 -0.24016291 62 -0.08508772 2.65776942 63 -0.87080201 -0.08508772 64 -4.58508772 -0.87080201 65 1.55776942 -4.58508772 66 1.95776942 1.55776942 67 5.65776942 1.95776942 68 0.50062657 5.65776942 69 3.27205514 0.50062657 70 0.82832080 3.27205514 71 -0.42882206 0.82832080 72 2.47268170 -0.42882206 73 -2.32938596 2.47268170 74 3.32775689 -2.32938596 75 -0.95795739 3.32775689 76 -8.87224311 -0.95795739 77 5.67061404 -8.87224311 78 6.87061404 5.67061404 79 -0.72938596 6.87061404 80 8.21347118 -0.72938596 81 3.68489975 8.21347118 82 3.24116541 3.68489975 83 4.08402256 3.24116541 84 -2.91447368 4.08402256 > 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/73nwj1227512684.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/8chz71227512684.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/9ufy91227512684.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/101mf01227512684.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/11cjr41227512684.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/12s0uq1227512684.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/13hgxq1227512684.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/14x7wi1227512684.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/15qhxh1227512685.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/168le21227512685.tab") + } > > system("convert tmp/1xkos1227512684.ps tmp/1xkos1227512684.png") > system("convert tmp/2agdo1227512684.ps tmp/2agdo1227512684.png") > system("convert tmp/3x1qf1227512684.ps tmp/3x1qf1227512684.png") > system("convert tmp/4kmzj1227512684.ps tmp/4kmzj1227512684.png") > system("convert tmp/5yddd1227512684.ps tmp/5yddd1227512684.png") > system("convert tmp/6uwhf1227512684.ps tmp/6uwhf1227512684.png") > system("convert tmp/73nwj1227512684.ps tmp/73nwj1227512684.png") > system("convert tmp/8chz71227512684.ps tmp/8chz71227512684.png") > system("convert tmp/9ufy91227512684.ps tmp/9ufy91227512684.png") > system("convert tmp/101mf01227512684.ps tmp/101mf01227512684.png") > > > proc.time() user system elapsed 2.769 1.626 3.751