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(105.31 + ,1576.23 + ,29.29 + ,105.63 + ,1546.37 + ,28.99 + ,106.02 + ,1545.05 + ,28.91 + ,105.85 + ,1552.34 + ,29.29 + ,106.57 + ,1594.3 + ,30.96 + ,106.48 + ,1605.78 + ,30.57 + ,106.60 + ,1673.21 + ,30.59 + ,106.75 + ,1612.94 + ,31.39 + ,106.69 + ,1566.34 + ,31.28 + ,106.69 + ,1530.17 + ,31.1 + ,106.93 + ,1582.54 + ,31.7 + ,107.21 + ,1702.16 + ,32.57 + ,107.88 + ,1701.93 + ,32.49 + ,108.84 + ,1811.15 + ,32.46 + ,108.96 + ,1924.2 + ,32.3 + ,109.52 + ,2034.25 + ,32.97 + ,108.45 + ,2011.13 + ,32.9 + ,108.67 + ,2013.04 + ,32.93 + ,108.96 + ,2151.67 + ,33.72 + ,108.76 + ,1902.09 + ,33.33 + ,107.85 + ,1944.01 + ,33.44 + ,108.78 + ,1916.67 + ,33.89 + ,107.51 + ,1967.31 + ,34.34 + ,108.83 + ,2119.88 + ,33.56 + ,111.54 + ,2216.38 + ,32.67 + ,111.74 + ,2522.83 + ,32.57 + ,112.04 + ,2647.64 + ,33.23 + ,111.74 + ,2631.23 + ,32.85 + ,111.81 + ,2693.41 + ,32.61 + ,111.86 + ,3021.76 + ,32.57 + ,114.23 + ,2953.67 + ,32.98 + ,114.80 + ,2796.8 + ,31.33 + ,115.17 + ,2672.05 + ,29.8 + ,115.11 + ,2251.23 + ,28.06 + ,114.43 + ,2046.08 + ,25.47 + ,114.66 + ,2420.04 + ,24.65 + ,115.11 + ,2608.89 + ,23.94 + ,117.74 + ,2660.47 + ,23.89 + ,118.18 + ,2493.98 + ,23.54 + ,118.56 + ,2541.7 + ,24.28 + ,117.63 + ,2554.6 + ,25.51 + ,117.71 + ,2699.61 + ,27.03 + ,117.46 + ,2805.48 + ,27.09 + ,117.37 + ,2956.66 + ,27.3 + ,117.34 + ,3149.51 + ,27.11 + ,117.09 + ,3372.5 + ,26.39 + ,116.65 + ,3379.33 + ,27.54 + ,116.71 + ,3517.54 + ,26.85 + ,116.82 + ,3527.34 + ,26.82 + ,117.33 + ,3281.06 + ,25.9 + ,117.95 + ,3089.65 + ,24.96 + ,123.53 + ,3222.76 + ,25.4 + ,124.91 + ,3165.76 + ,24.38 + ,125.99 + ,3232.43 + ,24.73 + ,126.29 + ,3229.54 + ,25.43 + ,125.68 + ,3071.74 + ,26.04 + ,125.52 + ,2850.17 + ,25.59) + ,dim=c(3 + ,57) + ,dimnames=list(c('PC&S' + ,'PCacao' + ,'PSuiker') + ,1:57)) > y <- array(NA,dim=c(3,57),dimnames=list(c('PC&S','PCacao','PSuiker'),1:57)) > 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 PC&S PCacao PSuiker M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 105.31 1576.23 29.29 1 0 0 0 0 0 0 0 0 0 0 1 2 105.63 1546.37 28.99 0 1 0 0 0 0 0 0 0 0 0 2 3 106.02 1545.05 28.91 0 0 1 0 0 0 0 0 0 0 0 3 4 105.85 1552.34 29.29 0 0 0 1 0 0 0 0 0 0 0 4 5 106.57 1594.30 30.96 0 0 0 0 1 0 0 0 0 0 0 5 6 106.48 1605.78 30.57 0 0 0 0 0 1 0 0 0 0 0 6 7 106.60 1673.21 30.59 0 0 0 0 0 0 1 0 0 0 0 7 8 106.75 1612.94 31.39 0 0 0 0 0 0 0 1 0 0 0 8 9 106.69 1566.34 31.28 0 0 0 0 0 0 0 0 1 0 0 9 10 106.69 1530.17 31.10 0 0 0 0 0 0 0 0 0 1 0 10 11 106.93 1582.54 31.70 0 0 0 0 0 0 0 0 0 0 1 11 12 107.21 1702.16 32.57 0 0 0 0 0 0 0 0 0 0 0 12 13 107.88 1701.93 32.49 1 0 0 0 0 0 0 0 0 0 0 13 14 108.84 1811.15 32.46 0 1 0 0 0 0 0 0 0 0 0 14 15 108.96 1924.20 32.30 0 0 1 0 0 0 0 0 0 0 0 15 16 109.52 2034.25 32.97 0 0 0 1 0 0 0 0 0 0 0 16 17 108.45 2011.13 32.90 0 0 0 0 1 0 0 0 0 0 0 17 18 108.67 2013.04 32.93 0 0 0 0 0 1 0 0 0 0 0 18 19 108.96 2151.67 33.72 0 0 0 0 0 0 1 0 0 0 0 19 20 108.76 1902.09 33.33 0 0 0 0 0 0 0 1 0 0 0 20 21 107.85 1944.01 33.44 0 0 0 0 0 0 0 0 1 0 0 21 22 108.78 1916.67 33.89 0 0 0 0 0 0 0 0 0 1 0 22 23 107.51 1967.31 34.34 0 0 0 0 0 0 0 0 0 0 1 23 24 108.83 2119.88 33.56 0 0 0 0 0 0 0 0 0 0 0 24 25 111.54 2216.38 32.67 1 0 0 0 0 0 0 0 0 0 0 25 26 111.74 2522.83 32.57 0 1 0 0 0 0 0 0 0 0 0 26 27 112.04 2647.64 33.23 0 0 1 0 0 0 0 0 0 0 0 27 28 111.74 2631.23 32.85 0 0 0 1 0 0 0 0 0 0 0 28 29 111.81 2693.41 32.61 0 0 0 0 1 0 0 0 0 0 0 29 30 111.86 3021.76 32.57 0 0 0 0 0 1 0 0 0 0 0 30 31 114.23 2953.67 32.98 0 0 0 0 0 0 1 0 0 0 0 31 32 114.80 2796.80 31.33 0 0 0 0 0 0 0 1 0 0 0 32 33 115.17 2672.05 29.80 0 0 0 0 0 0 0 0 1 0 0 33 34 115.11 2251.23 28.06 0 0 0 0 0 0 0 0 0 1 0 34 35 114.43 2046.08 25.47 0 0 0 0 0 0 0 0 0 0 1 35 36 114.66 2420.04 24.65 0 0 0 0 0 0 0 0 0 0 0 36 37 115.11 2608.89 23.94 1 0 0 0 0 0 0 0 0 0 0 37 38 117.74 2660.47 23.89 0 1 0 0 0 0 0 0 0 0 0 38 39 118.18 2493.98 23.54 0 0 1 0 0 0 0 0 0 0 0 39 40 118.56 2541.70 24.28 0 0 0 1 0 0 0 0 0 0 0 40 41 117.63 2554.60 25.51 0 0 0 0 1 0 0 0 0 0 0 41 42 117.71 2699.61 27.03 0 0 0 0 0 1 0 0 0 0 0 42 43 117.46 2805.48 27.09 0 0 0 0 0 0 1 0 0 0 0 43 44 117.37 2956.66 27.30 0 0 0 0 0 0 0 1 0 0 0 44 45 117.34 3149.51 27.11 0 0 0 0 0 0 0 0 1 0 0 45 46 117.09 3372.50 26.39 0 0 0 0 0 0 0 0 0 1 0 46 47 116.65 3379.33 27.54 0 0 0 0 0 0 0 0 0 0 1 47 48 116.71 3517.54 26.85 0 0 0 0 0 0 0 0 0 0 0 48 49 116.82 3527.34 26.82 1 0 0 0 0 0 0 0 0 0 0 49 50 117.33 3281.06 25.90 0 1 0 0 0 0 0 0 0 0 0 50 51 117.95 3089.65 24.96 0 0 1 0 0 0 0 0 0 0 0 51 52 123.53 3222.76 25.40 0 0 0 1 0 0 0 0 0 0 0 52 53 124.91 3165.76 24.38 0 0 0 0 1 0 0 0 0 0 0 53 54 125.99 3232.43 24.73 0 0 0 0 0 1 0 0 0 0 0 54 55 126.29 3229.54 25.43 0 0 0 0 0 0 1 0 0 0 0 55 56 125.68 3071.74 26.04 0 0 0 0 0 0 0 1 0 0 0 56 57 125.52 2850.17 25.59 0 0 0 0 0 0 0 0 1 0 0 57 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) PCacao PSuiker M1 M2 M3 113.738844 -0.002073 -0.273358 1.012109 1.565134 1.467599 M4 M5 M6 M7 M8 M9 2.521886 2.283366 2.487496 2.887973 2.259124 1.543265 M10 M11 t 0.578953 -0.408249 0.373660 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -3.0859 -0.8122 -0.2118 0.9666 3.0463 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.137e+02 3.049e+00 37.307 < 2e-16 *** PCacao -2.073e-03 9.879e-04 -2.098 0.04194 * PSuiker -2.734e-01 9.366e-02 -2.919 0.00563 ** M1 1.012e+00 1.041e+00 0.972 0.33670 M2 1.565e+00 1.043e+00 1.501 0.14082 M3 1.468e+00 1.038e+00 1.414 0.16476 M4 2.522e+00 1.034e+00 2.439 0.01903 * M5 2.283e+00 1.031e+00 2.215 0.03221 * M6 2.487e+00 1.033e+00 2.409 0.02047 * M7 2.888e+00 1.034e+00 2.793 0.00783 ** M8 2.259e+00 1.035e+00 2.183 0.03470 * M9 1.543e+00 1.039e+00 1.485 0.14505 M10 5.790e-01 1.092e+00 0.530 0.59865 M11 -4.082e-01 1.099e+00 -0.371 0.71214 t 3.737e-01 4.379e-02 8.533 1.02e-10 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.536 on 42 degrees of freedom Multiple R-squared: 0.9503, Adjusted R-squared: 0.9338 F-statistic: 57.38 on 14 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,] 4.276366e-04 8.552732e-04 0.9995724 [2,] 6.418144e-04 1.283629e-03 0.9993582 [3,] 1.064231e-04 2.128463e-04 0.9998936 [4,] 1.402185e-04 2.804370e-04 0.9998598 [5,] 2.980931e-05 5.961862e-05 0.9999702 [6,] 3.608241e-04 7.216483e-04 0.9996392 [7,] 1.885700e-04 3.771401e-04 0.9998114 [8,] 2.518789e-03 5.037577e-03 0.9974812 [9,] 1.370012e-03 2.740023e-03 0.9986300 [10,] 9.930196e-04 1.986039e-03 0.9990070 [11,] 3.401117e-04 6.802235e-04 0.9996599 [12,] 1.084338e-04 2.168676e-04 0.9998916 [13,] 3.552161e-05 7.104323e-05 0.9999645 [14,] 1.410120e-04 2.820240e-04 0.9998590 [15,] 5.417602e-04 1.083520e-03 0.9994582 [16,] 6.704310e-03 1.340862e-02 0.9932957 [17,] 7.692261e-02 1.538452e-01 0.9230774 [18,] 5.260627e-02 1.052125e-01 0.9473937 [19,] 4.526826e-02 9.053651e-02 0.9547317 [20,] 1.376257e-01 2.752514e-01 0.8623743 [21,] 9.603333e-02 1.920667e-01 0.9039667 [22,] 8.792140e-01 2.415720e-01 0.1207860 > postscript(file="/var/www/html/rcomp/tmp/1zbds1292931581.ps",horizontal=F,onefile=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/2zbds1292931581.ps",horizontal=F,onefile=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/3zbds1292931581.ps",horizontal=F,onefile=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/4a2ud1292931581.ps",horizontal=F,onefile=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/5a2ud1292931581.ps",horizontal=F,onefile=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 = 57 Frequency = 1 1 2 3 4 5 6 1.459213428 0.708627334 0.797897390 -0.681063715 0.447277865 -0.303326835 7 8 9 10 11 12 -0.812229099 -0.313281354 -0.157742929 0.308731721 1.434839361 1.418697255 13 14 15 16 17 18 0.680582999 0.932085610 0.966550775 0.509862200 -0.762335244 -1.107966164 19 20 21 22 23 24 -1.088801060 -1.657546884 -2.108387348 -0.521394647 -0.949876584 -0.308760989 25 26 27 28 29 30 0.972204850 0.853386615 1.316381055 -0.549456838 -0.551317061 -0.409445055 31 32 33 34 35 36 1.157359214 1.206349904 1.241732579 0.424474629 -0.775211149 -0.776137327 37 38 39 40 41 42 -1.514545946 0.282014529 0.005117076 -0.741632768 -1.443803576 -1.225516705 43 44 45 46 47 48 -2.013807033 -1.477851273 -0.817854544 -0.211811703 0.290248371 -0.333798938 49 50 51 52 53 54 -1.597455331 -2.776114088 -3.085946295 1.462291120 2.310178016 3.046254758 55 56 57 2.757477978 2.242329607 1.842252242 > postscript(file="/var/www/html/rcomp/tmp/6a2ud1292931581.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > dum <- cbind(lag(myerror,k=1),myerror) > dum Time Series: Start = 0 End = 57 Frequency = 1 lag(myerror, k = 1) myerror 0 1.459213428 NA 1 0.708627334 1.459213428 2 0.797897390 0.708627334 3 -0.681063715 0.797897390 4 0.447277865 -0.681063715 5 -0.303326835 0.447277865 6 -0.812229099 -0.303326835 7 -0.313281354 -0.812229099 8 -0.157742929 -0.313281354 9 0.308731721 -0.157742929 10 1.434839361 0.308731721 11 1.418697255 1.434839361 12 0.680582999 1.418697255 13 0.932085610 0.680582999 14 0.966550775 0.932085610 15 0.509862200 0.966550775 16 -0.762335244 0.509862200 17 -1.107966164 -0.762335244 18 -1.088801060 -1.107966164 19 -1.657546884 -1.088801060 20 -2.108387348 -1.657546884 21 -0.521394647 -2.108387348 22 -0.949876584 -0.521394647 23 -0.308760989 -0.949876584 24 0.972204850 -0.308760989 25 0.853386615 0.972204850 26 1.316381055 0.853386615 27 -0.549456838 1.316381055 28 -0.551317061 -0.549456838 29 -0.409445055 -0.551317061 30 1.157359214 -0.409445055 31 1.206349904 1.157359214 32 1.241732579 1.206349904 33 0.424474629 1.241732579 34 -0.775211149 0.424474629 35 -0.776137327 -0.775211149 36 -1.514545946 -0.776137327 37 0.282014529 -1.514545946 38 0.005117076 0.282014529 39 -0.741632768 0.005117076 40 -1.443803576 -0.741632768 41 -1.225516705 -1.443803576 42 -2.013807033 -1.225516705 43 -1.477851273 -2.013807033 44 -0.817854544 -1.477851273 45 -0.211811703 -0.817854544 46 0.290248371 -0.211811703 47 -0.333798938 0.290248371 48 -1.597455331 -0.333798938 49 -2.776114088 -1.597455331 50 -3.085946295 -2.776114088 51 1.462291120 -3.085946295 52 2.310178016 1.462291120 53 3.046254758 2.310178016 54 2.757477978 3.046254758 55 2.242329607 2.757477978 56 1.842252242 2.242329607 57 NA 1.842252242 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 0.708627334 1.459213428 [2,] 0.797897390 0.708627334 [3,] -0.681063715 0.797897390 [4,] 0.447277865 -0.681063715 [5,] -0.303326835 0.447277865 [6,] -0.812229099 -0.303326835 [7,] -0.313281354 -0.812229099 [8,] -0.157742929 -0.313281354 [9,] 0.308731721 -0.157742929 [10,] 1.434839361 0.308731721 [11,] 1.418697255 1.434839361 [12,] 0.680582999 1.418697255 [13,] 0.932085610 0.680582999 [14,] 0.966550775 0.932085610 [15,] 0.509862200 0.966550775 [16,] -0.762335244 0.509862200 [17,] -1.107966164 -0.762335244 [18,] -1.088801060 -1.107966164 [19,] -1.657546884 -1.088801060 [20,] -2.108387348 -1.657546884 [21,] -0.521394647 -2.108387348 [22,] -0.949876584 -0.521394647 [23,] -0.308760989 -0.949876584 [24,] 0.972204850 -0.308760989 [25,] 0.853386615 0.972204850 [26,] 1.316381055 0.853386615 [27,] -0.549456838 1.316381055 [28,] -0.551317061 -0.549456838 [29,] -0.409445055 -0.551317061 [30,] 1.157359214 -0.409445055 [31,] 1.206349904 1.157359214 [32,] 1.241732579 1.206349904 [33,] 0.424474629 1.241732579 [34,] -0.775211149 0.424474629 [35,] -0.776137327 -0.775211149 [36,] -1.514545946 -0.776137327 [37,] 0.282014529 -1.514545946 [38,] 0.005117076 0.282014529 [39,] -0.741632768 0.005117076 [40,] -1.443803576 -0.741632768 [41,] -1.225516705 -1.443803576 [42,] -2.013807033 -1.225516705 [43,] -1.477851273 -2.013807033 [44,] -0.817854544 -1.477851273 [45,] -0.211811703 -0.817854544 [46,] 0.290248371 -0.211811703 [47,] -0.333798938 0.290248371 [48,] -1.597455331 -0.333798938 [49,] -2.776114088 -1.597455331 [50,] -3.085946295 -2.776114088 [51,] 1.462291120 -3.085946295 [52,] 2.310178016 1.462291120 [53,] 3.046254758 2.310178016 [54,] 2.757477978 3.046254758 [55,] 2.242329607 2.757477978 [56,] 1.842252242 2.242329607 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 0.708627334 1.459213428 2 0.797897390 0.708627334 3 -0.681063715 0.797897390 4 0.447277865 -0.681063715 5 -0.303326835 0.447277865 6 -0.812229099 -0.303326835 7 -0.313281354 -0.812229099 8 -0.157742929 -0.313281354 9 0.308731721 -0.157742929 10 1.434839361 0.308731721 11 1.418697255 1.434839361 12 0.680582999 1.418697255 13 0.932085610 0.680582999 14 0.966550775 0.932085610 15 0.509862200 0.966550775 16 -0.762335244 0.509862200 17 -1.107966164 -0.762335244 18 -1.088801060 -1.107966164 19 -1.657546884 -1.088801060 20 -2.108387348 -1.657546884 21 -0.521394647 -2.108387348 22 -0.949876584 -0.521394647 23 -0.308760989 -0.949876584 24 0.972204850 -0.308760989 25 0.853386615 0.972204850 26 1.316381055 0.853386615 27 -0.549456838 1.316381055 28 -0.551317061 -0.549456838 29 -0.409445055 -0.551317061 30 1.157359214 -0.409445055 31 1.206349904 1.157359214 32 1.241732579 1.206349904 33 0.424474629 1.241732579 34 -0.775211149 0.424474629 35 -0.776137327 -0.775211149 36 -1.514545946 -0.776137327 37 0.282014529 -1.514545946 38 0.005117076 0.282014529 39 -0.741632768 0.005117076 40 -1.443803576 -0.741632768 41 -1.225516705 -1.443803576 42 -2.013807033 -1.225516705 43 -1.477851273 -2.013807033 44 -0.817854544 -1.477851273 45 -0.211811703 -0.817854544 46 0.290248371 -0.211811703 47 -0.333798938 0.290248371 48 -1.597455331 -0.333798938 49 -2.776114088 -1.597455331 50 -3.085946295 -2.776114088 51 1.462291120 -3.085946295 52 2.310178016 1.462291120 53 3.046254758 2.310178016 54 2.757477978 3.046254758 55 2.242329607 2.757477978 56 1.842252242 2.242329607 > 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/7lccg1292931581.ps",horizontal=F,onefile=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/8v3bj1292931581.ps",horizontal=F,onefile=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/9v3bj1292931581.ps",horizontal=F,onefile=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/10oca41292931581.ps",horizontal=F,onefile=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/11sd9s1292931581.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/12k4qd1292931581.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/13r5571292931581.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/14u5lu1292931581.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/15ne3x1292931581.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/1616io1292931581.tab") + } > try(system("convert tmp/1zbds1292931581.ps tmp/1zbds1292931581.png",intern=TRUE)) character(0) > try(system("convert tmp/2zbds1292931581.ps tmp/2zbds1292931581.png",intern=TRUE)) character(0) > try(system("convert tmp/3zbds1292931581.ps tmp/3zbds1292931581.png",intern=TRUE)) character(0) > try(system("convert tmp/4a2ud1292931581.ps tmp/4a2ud1292931581.png",intern=TRUE)) character(0) > try(system("convert tmp/5a2ud1292931581.ps tmp/5a2ud1292931581.png",intern=TRUE)) character(0) > try(system("convert tmp/6a2ud1292931581.ps tmp/6a2ud1292931581.png",intern=TRUE)) character(0) > try(system("convert tmp/7lccg1292931581.ps tmp/7lccg1292931581.png",intern=TRUE)) character(0) > try(system("convert tmp/8v3bj1292931581.ps tmp/8v3bj1292931581.png",intern=TRUE)) character(0) > try(system("convert tmp/9v3bj1292931581.ps tmp/9v3bj1292931581.png",intern=TRUE)) character(0) > try(system("convert tmp/10oca41292931581.ps tmp/10oca41292931581.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.426 1.625 5.492