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(6.4,12.5,6.8,14.8,7.5,15.9,7.5,14.8,7.6,12.9,7.6,14.3,7.4,14.2,7.3,15.9,7.1,15.3,6.9,15.5,6.8,15.1,7.5,15,7.6,12.1,7.8,15.8,8,16.9,8.1,15.1,8.2,13.7,8.3,14.8,8.2,14.7,8,16,7.9,15.4,7.6,15,7.6,15.5,8.2,15.1,8.3,11.7,8.4,16.3,8.4,16.7,8.4,15,8.6,14.9,8.9,14.6,8.8,15.3,8.3,17.9,7.5,16.4,7.2,15.4,7.5,17.9,8.8,15.9,9.3,13.9,9.3,17.8,8.7,17.9,8.2,17.4,8.3,16.7,8.5,16,8.6,16.6,8.6,19.1,8.2,17.8,8.1,17.2,8,18.6,8.6,16.3,8.7,15.1,8.8,19.2,8.5,17.7,8.4,19.1,8.5,18,8.7,17.5,8.7,17.8,8.6,21.1,8.5,17.2,8.3,19.4,8.1,19.8,8.2,17.6,8.1,16.2,8.1,19.5,7.9,19.9,7.9,20,7.9,17.3,8,18.9,8,18.6,7.9,21.4,8,18.6,7.7,19.8,7.2,20.8,7.5,19.6,7.3,17.7,7,19.8,7,22.2,7,20.7,7.2,17.9,7.3,21.2,7.1,21.4,6.8,21.7,6.6,23.2,6.2,21.5,6.2,22.9,6.8,23.2,6.9,18.6),dim=c(2,85),dimnames=list(c('Werkloosheid','Export'),1:85)) > y <- array(NA,dim=c(2,85),dimnames=list(c('Werkloosheid','Export'),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 Werkloosheid Export M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 6.4 12.5 1 0 0 0 0 0 0 0 0 0 0 1 2 6.8 14.8 0 1 0 0 0 0 0 0 0 0 0 2 3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 0 0 1 0 0 0 0 0 0 0 0 63 64 7.9 20.0 0 0 0 1 0 0 0 0 0 0 0 64 65 7.9 17.3 0 0 0 0 1 0 0 0 0 0 0 65 66 8.0 18.9 0 0 0 0 0 1 0 0 0 0 0 66 67 8.0 18.6 0 0 0 0 0 0 1 0 0 0 0 67 68 7.9 21.4 0 0 0 0 0 0 0 1 0 0 0 68 69 8.0 18.6 0 0 0 0 0 0 0 0 1 0 0 69 70 7.7 19.8 0 0 0 0 0 0 0 0 0 1 0 70 71 7.2 20.8 0 0 0 0 0 0 0 0 0 0 1 71 72 7.5 19.6 0 0 0 0 0 0 0 0 0 0 0 72 73 7.3 17.7 1 0 0 0 0 0 0 0 0 0 0 73 74 7.0 19.8 0 1 0 0 0 0 0 0 0 0 0 74 75 7.0 22.2 0 0 1 0 0 0 0 0 0 0 0 75 76 7.0 20.7 0 0 0 1 0 0 0 0 0 0 0 76 77 7.2 17.9 0 0 0 0 1 0 0 0 0 0 0 77 78 7.3 21.2 0 0 0 0 0 1 0 0 0 0 0 78 79 7.1 21.4 0 0 0 0 0 0 1 0 0 0 0 79 80 6.8 21.7 0 0 0 0 0 0 0 1 0 0 0 80 81 6.6 23.2 0 0 0 0 0 0 0 0 1 0 0 81 82 6.2 21.5 0 0 0 0 0 0 0 0 0 1 0 82 83 6.2 22.9 0 0 0 0 0 0 0 0 0 0 1 83 84 6.8 23.2 0 0 0 0 0 0 0 0 0 0 0 84 85 6.9 18.6 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) Export M1 M2 M3 M4 12.90656 -0.36323 -0.99003 0.40400 0.55375 0.18845 M5 M6 M7 M8 M9 M10 -0.28172 0.13805 0.10485 0.64231 -0.10717 -0.39874 M11 t -0.16083 0.02923 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -1.28189 -0.32435 -0.02735 0.33779 1.35074 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 12.906556 1.181231 10.926 < 2e-16 *** Export -0.363231 0.087128 -4.169 8.52e-05 *** M1 -0.990033 0.384794 -2.573 0.012176 * M2 0.403999 0.347780 1.162 0.249268 M3 0.553755 0.360113 1.538 0.128561 M4 0.188452 0.341368 0.552 0.582648 M5 -0.281722 0.347341 -0.811 0.420030 M6 0.138054 0.337087 0.410 0.683369 M7 0.104849 0.336569 0.312 0.756317 M8 0.642308 0.372795 1.723 0.089250 . M9 -0.107173 0.338385 -0.317 0.752387 M10 -0.398739 0.337409 -1.182 0.241242 M11 -0.160833 0.352469 -0.456 0.649563 t 0.029234 0.008358 3.498 0.000814 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.6287 on 71 degrees of freedom Multiple R-squared: 0.313, Adjusted R-squared: 0.1872 F-statistic: 2.489 on 13 and 71 DF, p-value: 0.007397 > 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,] 6.589441e-02 1.317888e-01 0.934105592 [2,] 2.176675e-02 4.353350e-02 0.978233251 [3,] 6.607576e-03 1.321515e-02 0.993392424 [4,] 2.731409e-03 5.462818e-03 0.997268591 [5,] 8.102816e-04 1.620563e-03 0.999189718 [6,] 4.416888e-04 8.833776e-04 0.999558311 [7,] 1.411815e-04 2.823630e-04 0.999858819 [8,] 4.832475e-05 9.664950e-05 0.999951675 [9,] 1.598410e-05 3.196819e-05 0.999984016 [10,] 5.096493e-06 1.019299e-05 0.999994904 [11,] 6.040115e-05 1.208023e-04 0.999939599 [12,] 2.266885e-04 4.533771e-04 0.999773311 [13,] 1.151994e-04 2.303988e-04 0.999884801 [14,] 4.599230e-05 9.198461e-05 0.999954008 [15,] 1.768624e-05 3.537248e-05 0.999982314 [16,] 1.003118e-05 2.006236e-05 0.999989969 [17,] 1.768400e-03 3.536800e-03 0.998231600 [18,] 1.072531e-01 2.145061e-01 0.892746929 [19,] 2.034018e-01 4.068035e-01 0.796598231 [20,] 1.770851e-01 3.541702e-01 0.822914887 [21,] 3.546131e-01 7.092262e-01 0.645386895 [22,] 3.902763e-01 7.805525e-01 0.609723749 [23,] 3.756353e-01 7.512707e-01 0.624364663 [24,] 5.733841e-01 8.532319e-01 0.426615944 [25,] 6.817622e-01 6.364756e-01 0.318237814 [26,] 8.339204e-01 3.321592e-01 0.166079593 [27,] 8.701516e-01 2.596968e-01 0.129848423 [28,] 8.655613e-01 2.688774e-01 0.134438711 [29,] 9.412085e-01 1.175830e-01 0.058791497 [30,] 9.779631e-01 4.407376e-02 0.022036882 [31,] 9.927661e-01 1.446773e-02 0.007233866 [32,] 9.973869e-01 5.226123e-03 0.002613061 [33,] 9.973086e-01 5.382870e-03 0.002691435 [34,] 9.953636e-01 9.272886e-03 0.004636443 [35,] 9.971457e-01 5.708596e-03 0.002854298 [36,] 9.964639e-01 7.072129e-03 0.003536064 [37,] 9.952584e-01 9.483182e-03 0.004741591 [38,] 9.941794e-01 1.164120e-02 0.005820601 [39,] 9.908140e-01 1.837195e-02 0.009185974 [40,] 9.831150e-01 3.377009e-02 0.016885045 [41,] 9.736317e-01 5.273659e-02 0.026368293 [42,] 9.578845e-01 8.423101e-02 0.042115506 [43,] 9.346333e-01 1.307334e-01 0.065366717 [44,] 9.512653e-01 9.746939e-02 0.048734697 [45,] 9.596723e-01 8.065535e-02 0.040327677 [46,] 9.594484e-01 8.110320e-02 0.040551602 [47,] 9.481423e-01 1.037153e-01 0.051857667 [48,] 9.176841e-01 1.646318e-01 0.082315923 [49,] 8.903305e-01 2.193389e-01 0.109669465 [50,] 8.514530e-01 2.970940e-01 0.148546994 [51,] 7.666026e-01 4.667947e-01 0.233397351 [52,] 6.559432e-01 6.881136e-01 0.344056793 > postscript(file="/var/www/html/rcomp/tmp/1t9521228903818.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/22eka1228903818.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/36ms51228903818.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/4lzzp1228903818.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/5grar1228903818.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 -1.00536331 -1.19319668 -0.27263146 -0.33611744 -0.48531772 -0.42580302 7 8 9 10 11 12 -0.65815488 -0.70735515 -0.40504694 -0.27006876 -0.78250053 -0.30889099 13 14 15 16 17 18 -0.30146356 -0.18077283 0.23979239 0.02204436 0.05445984 0.10500508 19 20 21 22 23 24 -0.02734678 -0.32183965 0.08046856 -0.10249216 -0.18801558 0.07662451 25 26 27 28 29 30 -0.09756381 0.25003527 0.21633844 -0.06508644 0.53952999 0.28155113 31 32 33 34 35 36 0.43978447 0.31749255 -0.30710759 -0.70800721 0.23293237 0.61640206 37 38 39 40 41 42 1.35073784 1.34407487 0.60140859 0.25586151 0.54253904 0.03926758 43 44 45 46 47 48 0.36117777 0.70256270 0.55060886 0.49500184 0.63638677 0.21088701 49 50 51 52 53 54 0.83580799 1.00179132 -0.02204536 0.72254741 0.86393234 0.43330718 55 56 57 58 59 60 0.54624792 1.07821805 0.28186232 1.14330349 0.82145692 -0.06771968 61 62 63 64 65 66 0.28455499 0.05995312 -0.17374371 0.19864811 -0.34113736 -0.10897637 67 68 69 70 71 72 -0.21397453 0.13637985 -0.06042123 0.33778844 -0.06611923 -0.39206434 73 74 75 76 77 78 -0.32140541 -1.28188508 -0.58911891 -0.79789749 -1.17400611 -0.32435157 79 80 81 82 83 84 -0.44773398 -1.20545835 -0.14036399 -0.89552566 -0.65414073 -0.13523859 85 -0.74530471 > postscript(file="/var/www/html/rcomp/tmp/6sojf1228903818.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 -1.00536331 NA 1 -1.19319668 -1.00536331 2 -0.27263146 -1.19319668 3 -0.33611744 -0.27263146 4 -0.48531772 -0.33611744 5 -0.42580302 -0.48531772 6 -0.65815488 -0.42580302 7 -0.70735515 -0.65815488 8 -0.40504694 -0.70735515 9 -0.27006876 -0.40504694 10 -0.78250053 -0.27006876 11 -0.30889099 -0.78250053 12 -0.30146356 -0.30889099 13 -0.18077283 -0.30146356 14 0.23979239 -0.18077283 15 0.02204436 0.23979239 16 0.05445984 0.02204436 17 0.10500508 0.05445984 18 -0.02734678 0.10500508 19 -0.32183965 -0.02734678 20 0.08046856 -0.32183965 21 -0.10249216 0.08046856 22 -0.18801558 -0.10249216 23 0.07662451 -0.18801558 24 -0.09756381 0.07662451 25 0.25003527 -0.09756381 26 0.21633844 0.25003527 27 -0.06508644 0.21633844 28 0.53952999 -0.06508644 29 0.28155113 0.53952999 30 0.43978447 0.28155113 31 0.31749255 0.43978447 32 -0.30710759 0.31749255 33 -0.70800721 -0.30710759 34 0.23293237 -0.70800721 35 0.61640206 0.23293237 36 1.35073784 0.61640206 37 1.34407487 1.35073784 38 0.60140859 1.34407487 39 0.25586151 0.60140859 40 0.54253904 0.25586151 41 0.03926758 0.54253904 42 0.36117777 0.03926758 43 0.70256270 0.36117777 44 0.55060886 0.70256270 45 0.49500184 0.55060886 46 0.63638677 0.49500184 47 0.21088701 0.63638677 48 0.83580799 0.21088701 49 1.00179132 0.83580799 50 -0.02204536 1.00179132 51 0.72254741 -0.02204536 52 0.86393234 0.72254741 53 0.43330718 0.86393234 54 0.54624792 0.43330718 55 1.07821805 0.54624792 56 0.28186232 1.07821805 57 1.14330349 0.28186232 58 0.82145692 1.14330349 59 -0.06771968 0.82145692 60 0.28455499 -0.06771968 61 0.05995312 0.28455499 62 -0.17374371 0.05995312 63 0.19864811 -0.17374371 64 -0.34113736 0.19864811 65 -0.10897637 -0.34113736 66 -0.21397453 -0.10897637 67 0.13637985 -0.21397453 68 -0.06042123 0.13637985 69 0.33778844 -0.06042123 70 -0.06611923 0.33778844 71 -0.39206434 -0.06611923 72 -0.32140541 -0.39206434 73 -1.28188508 -0.32140541 74 -0.58911891 -1.28188508 75 -0.79789749 -0.58911891 76 -1.17400611 -0.79789749 77 -0.32435157 -1.17400611 78 -0.44773398 -0.32435157 79 -1.20545835 -0.44773398 80 -0.14036399 -1.20545835 81 -0.89552566 -0.14036399 82 -0.65414073 -0.89552566 83 -0.13523859 -0.65414073 84 -0.74530471 -0.13523859 85 NA -0.74530471 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -1.19319668 -1.00536331 [2,] -0.27263146 -1.19319668 [3,] -0.33611744 -0.27263146 [4,] -0.48531772 -0.33611744 [5,] -0.42580302 -0.48531772 [6,] -0.65815488 -0.42580302 [7,] -0.70735515 -0.65815488 [8,] -0.40504694 -0.70735515 [9,] -0.27006876 -0.40504694 [10,] -0.78250053 -0.27006876 [11,] -0.30889099 -0.78250053 [12,] -0.30146356 -0.30889099 [13,] -0.18077283 -0.30146356 [14,] 0.23979239 -0.18077283 [15,] 0.02204436 0.23979239 [16,] 0.05445984 0.02204436 [17,] 0.10500508 0.05445984 [18,] -0.02734678 0.10500508 [19,] -0.32183965 -0.02734678 [20,] 0.08046856 -0.32183965 [21,] -0.10249216 0.08046856 [22,] -0.18801558 -0.10249216 [23,] 0.07662451 -0.18801558 [24,] -0.09756381 0.07662451 [25,] 0.25003527 -0.09756381 [26,] 0.21633844 0.25003527 [27,] -0.06508644 0.21633844 [28,] 0.53952999 -0.06508644 [29,] 0.28155113 0.53952999 [30,] 0.43978447 0.28155113 [31,] 0.31749255 0.43978447 [32,] -0.30710759 0.31749255 [33,] -0.70800721 -0.30710759 [34,] 0.23293237 -0.70800721 [35,] 0.61640206 0.23293237 [36,] 1.35073784 0.61640206 [37,] 1.34407487 1.35073784 [38,] 0.60140859 1.34407487 [39,] 0.25586151 0.60140859 [40,] 0.54253904 0.25586151 [41,] 0.03926758 0.54253904 [42,] 0.36117777 0.03926758 [43,] 0.70256270 0.36117777 [44,] 0.55060886 0.70256270 [45,] 0.49500184 0.55060886 [46,] 0.63638677 0.49500184 [47,] 0.21088701 0.63638677 [48,] 0.83580799 0.21088701 [49,] 1.00179132 0.83580799 [50,] -0.02204536 1.00179132 [51,] 0.72254741 -0.02204536 [52,] 0.86393234 0.72254741 [53,] 0.43330718 0.86393234 [54,] 0.54624792 0.43330718 [55,] 1.07821805 0.54624792 [56,] 0.28186232 1.07821805 [57,] 1.14330349 0.28186232 [58,] 0.82145692 1.14330349 [59,] -0.06771968 0.82145692 [60,] 0.28455499 -0.06771968 [61,] 0.05995312 0.28455499 [62,] -0.17374371 0.05995312 [63,] 0.19864811 -0.17374371 [64,] -0.34113736 0.19864811 [65,] -0.10897637 -0.34113736 [66,] -0.21397453 -0.10897637 [67,] 0.13637985 -0.21397453 [68,] -0.06042123 0.13637985 [69,] 0.33778844 -0.06042123 [70,] -0.06611923 0.33778844 [71,] -0.39206434 -0.06611923 [72,] -0.32140541 -0.39206434 [73,] -1.28188508 -0.32140541 [74,] -0.58911891 -1.28188508 [75,] -0.79789749 -0.58911891 [76,] -1.17400611 -0.79789749 [77,] -0.32435157 -1.17400611 [78,] -0.44773398 -0.32435157 [79,] -1.20545835 -0.44773398 [80,] -0.14036399 -1.20545835 [81,] -0.89552566 -0.14036399 [82,] -0.65414073 -0.89552566 [83,] -0.13523859 -0.65414073 [84,] -0.74530471 -0.13523859 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -1.19319668 -1.00536331 2 -0.27263146 -1.19319668 3 -0.33611744 -0.27263146 4 -0.48531772 -0.33611744 5 -0.42580302 -0.48531772 6 -0.65815488 -0.42580302 7 -0.70735515 -0.65815488 8 -0.40504694 -0.70735515 9 -0.27006876 -0.40504694 10 -0.78250053 -0.27006876 11 -0.30889099 -0.78250053 12 -0.30146356 -0.30889099 13 -0.18077283 -0.30146356 14 0.23979239 -0.18077283 15 0.02204436 0.23979239 16 0.05445984 0.02204436 17 0.10500508 0.05445984 18 -0.02734678 0.10500508 19 -0.32183965 -0.02734678 20 0.08046856 -0.32183965 21 -0.10249216 0.08046856 22 -0.18801558 -0.10249216 23 0.07662451 -0.18801558 24 -0.09756381 0.07662451 25 0.25003527 -0.09756381 26 0.21633844 0.25003527 27 -0.06508644 0.21633844 28 0.53952999 -0.06508644 29 0.28155113 0.53952999 30 0.43978447 0.28155113 31 0.31749255 0.43978447 32 -0.30710759 0.31749255 33 -0.70800721 -0.30710759 34 0.23293237 -0.70800721 35 0.61640206 0.23293237 36 1.35073784 0.61640206 37 1.34407487 1.35073784 38 0.60140859 1.34407487 39 0.25586151 0.60140859 40 0.54253904 0.25586151 41 0.03926758 0.54253904 42 0.36117777 0.03926758 43 0.70256270 0.36117777 44 0.55060886 0.70256270 45 0.49500184 0.55060886 46 0.63638677 0.49500184 47 0.21088701 0.63638677 48 0.83580799 0.21088701 49 1.00179132 0.83580799 50 -0.02204536 1.00179132 51 0.72254741 -0.02204536 52 0.86393234 0.72254741 53 0.43330718 0.86393234 54 0.54624792 0.43330718 55 1.07821805 0.54624792 56 0.28186232 1.07821805 57 1.14330349 0.28186232 58 0.82145692 1.14330349 59 -0.06771968 0.82145692 60 0.28455499 -0.06771968 61 0.05995312 0.28455499 62 -0.17374371 0.05995312 63 0.19864811 -0.17374371 64 -0.34113736 0.19864811 65 -0.10897637 -0.34113736 66 -0.21397453 -0.10897637 67 0.13637985 -0.21397453 68 -0.06042123 0.13637985 69 0.33778844 -0.06042123 70 -0.06611923 0.33778844 71 -0.39206434 -0.06611923 72 -0.32140541 -0.39206434 73 -1.28188508 -0.32140541 74 -0.58911891 -1.28188508 75 -0.79789749 -0.58911891 76 -1.17400611 -0.79789749 77 -0.32435157 -1.17400611 78 -0.44773398 -0.32435157 79 -1.20545835 -0.44773398 80 -0.14036399 -1.20545835 81 -0.89552566 -0.14036399 82 -0.65414073 -0.89552566 83 -0.13523859 -0.65414073 84 -0.74530471 -0.13523859 > 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/75rn61228903818.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/8fxtl1228903818.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/9i3l81228903818.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/100f121228903818.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/11oe6g1228903818.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/120y0c1228903818.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/13o3wy1228903818.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/14tff71228903818.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/15osne1228903818.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/168mwe1228903818.tab") + } > > system("convert tmp/1t9521228903818.ps tmp/1t9521228903818.png") > system("convert tmp/22eka1228903818.ps tmp/22eka1228903818.png") > system("convert tmp/36ms51228903818.ps tmp/36ms51228903818.png") > system("convert tmp/4lzzp1228903818.ps tmp/4lzzp1228903818.png") > system("convert tmp/5grar1228903818.ps tmp/5grar1228903818.png") > system("convert tmp/6sojf1228903818.ps tmp/6sojf1228903818.png") > system("convert tmp/75rn61228903818.ps tmp/75rn61228903818.png") > system("convert tmp/8fxtl1228903818.ps tmp/8fxtl1228903818.png") > system("convert tmp/9i3l81228903818.ps tmp/9i3l81228903818.png") > system("convert tmp/100f121228903818.ps tmp/100f121228903818.png") > > > proc.time() user system elapsed 3.017 1.729 4.815