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(89.1 + ,0 + ,100 + ,88 + ,82.6 + ,0 + ,89.1 + ,100 + ,102.7 + ,0 + ,82.6 + ,89.1 + ,91.8 + ,0 + ,102.7 + ,82.6 + ,94.1 + ,0 + ,91.8 + ,102.7 + ,103.1 + ,0 + ,94.1 + ,91.8 + ,93.2 + ,0 + ,103.1 + ,94.1 + ,91 + ,0 + ,93.2 + ,103.1 + ,94.3 + ,0 + ,91 + ,93.2 + ,99.4 + ,0 + ,94.3 + ,91 + ,115.7 + ,0 + ,99.4 + ,94.3 + ,116.8 + ,0 + ,115.7 + ,99.4 + ,99.8 + ,0 + ,116.8 + ,115.7 + ,96 + ,0 + ,99.8 + ,116.8 + ,115.9 + ,0 + ,96 + ,99.8 + ,109.1 + ,0 + ,115.9 + ,96 + ,117.3 + ,0 + ,109.1 + ,115.9 + ,109.8 + ,0 + ,117.3 + ,109.1 + ,112.8 + ,0 + ,109.8 + ,117.3 + ,110.7 + ,0 + ,112.8 + ,109.8 + ,100 + ,0 + ,110.7 + ,112.8 + ,113.3 + ,0 + ,100 + ,110.7 + ,122.4 + ,0 + ,113.3 + ,100 + ,112.5 + ,0 + ,122.4 + ,113.3 + ,104.2 + ,0 + ,112.5 + ,122.4 + ,92.5 + ,0 + ,104.2 + ,112.5 + ,117.2 + ,0 + ,92.5 + ,104.2 + ,109.3 + ,0 + ,117.2 + ,92.5 + ,106.1 + ,0 + ,109.3 + ,117.2 + ,118.8 + ,0 + ,106.1 + ,109.3 + ,105.3 + ,0 + ,118.8 + ,106.1 + ,106 + ,0 + ,105.3 + ,118.8 + ,102 + ,0 + ,106 + ,105.3 + ,112.9 + ,0 + ,102 + ,106 + ,116.5 + ,0 + ,112.9 + ,102 + ,114.8 + ,0 + ,116.5 + ,112.9 + ,100.5 + ,0 + ,114.8 + ,116.5 + ,85.4 + ,0 + ,100.5 + ,114.8 + ,114.6 + ,0 + ,85.4 + ,100.5 + ,109.9 + ,0 + ,114.6 + ,85.4 + ,100.7 + ,0 + ,109.9 + ,114.6 + ,115.5 + ,0 + ,100.7 + ,109.9 + ,100.7 + ,1 + ,115.5 + ,100.7 + ,99 + ,1 + ,100.7 + ,115.5 + ,102.3 + ,1 + ,99 + ,100.7 + ,108.8 + ,1 + ,102.3 + ,99 + ,105.9 + ,1 + ,108.8 + ,102.3 + ,113.2 + ,1 + ,105.9 + ,108.8 + ,95.7 + ,1 + ,113.2 + ,105.9 + ,80.9 + ,1 + ,95.7 + ,113.2 + ,113.9 + ,1 + ,80.9 + ,95.7 + ,98.1 + ,1 + ,113.9 + ,80.9 + ,102.8 + ,1 + ,98.1 + ,113.9 + ,104.7 + ,1 + ,102.8 + ,98.1 + ,95.9 + ,1 + ,104.7 + ,102.8 + ,94.6 + ,1 + ,95.9 + ,104.7 + ,101.6 + ,1 + ,94.6 + ,95.9 + ,103.9 + ,1 + ,101.6 + ,94.6 + ,110.3 + ,1 + ,103.9 + ,101.6 + ,114.1 + ,1 + ,110.3 + ,103.9) + ,dim=c(4 + ,60) + ,dimnames=list(c('TotaleIndustrieleProductie' + ,'X' + ,'Y1' + ,'Y2') + ,1:60)) > y <- array(NA,dim=c(4,60),dimnames=list(c('TotaleIndustrieleProductie','X','Y1','Y2'),1:60)) > 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 TotaleIndustrieleProductie X Y1 Y2 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 1 89.1 0 100.0 88.0 1 0 0 0 0 0 0 0 0 0 0 2 82.6 0 89.1 100.0 0 1 0 0 0 0 0 0 0 0 0 3 102.7 0 82.6 89.1 0 0 1 0 0 0 0 0 0 0 0 4 91.8 0 102.7 82.6 0 0 0 1 0 0 0 0 0 0 0 5 94.1 0 91.8 102.7 0 0 0 0 1 0 0 0 0 0 0 6 103.1 0 94.1 91.8 0 0 0 0 0 1 0 0 0 0 0 7 93.2 0 103.1 94.1 0 0 0 0 0 0 1 0 0 0 0 8 91.0 0 93.2 103.1 0 0 0 0 0 0 0 1 0 0 0 9 94.3 0 91.0 93.2 0 0 0 0 0 0 0 0 1 0 0 10 99.4 0 94.3 91.0 0 0 0 0 0 0 0 0 0 1 0 11 115.7 0 99.4 94.3 0 0 0 0 0 0 0 0 0 0 1 12 116.8 0 115.7 99.4 0 0 0 0 0 0 0 0 0 0 0 13 99.8 0 116.8 115.7 1 0 0 0 0 0 0 0 0 0 0 14 96.0 0 99.8 116.8 0 1 0 0 0 0 0 0 0 0 0 15 115.9 0 96.0 99.8 0 0 1 0 0 0 0 0 0 0 0 16 109.1 0 115.9 96.0 0 0 0 1 0 0 0 0 0 0 0 17 117.3 0 109.1 115.9 0 0 0 0 1 0 0 0 0 0 0 18 109.8 0 117.3 109.1 0 0 0 0 0 1 0 0 0 0 0 19 112.8 0 109.8 117.3 0 0 0 0 0 0 1 0 0 0 0 20 110.7 0 112.8 109.8 0 0 0 0 0 0 0 1 0 0 0 21 100.0 0 110.7 112.8 0 0 0 0 0 0 0 0 1 0 0 22 113.3 0 100.0 110.7 0 0 0 0 0 0 0 0 0 1 0 23 122.4 0 113.3 100.0 0 0 0 0 0 0 0 0 0 0 1 24 112.5 0 122.4 113.3 0 0 0 0 0 0 0 0 0 0 0 25 104.2 0 112.5 122.4 1 0 0 0 0 0 0 0 0 0 0 26 92.5 0 104.2 112.5 0 1 0 0 0 0 0 0 0 0 0 27 117.2 0 92.5 104.2 0 0 1 0 0 0 0 0 0 0 0 28 109.3 0 117.2 92.5 0 0 0 1 0 0 0 0 0 0 0 29 106.1 0 109.3 117.2 0 0 0 0 1 0 0 0 0 0 0 30 118.8 0 106.1 109.3 0 0 0 0 0 1 0 0 0 0 0 31 105.3 0 118.8 106.1 0 0 0 0 0 0 1 0 0 0 0 32 106.0 0 105.3 118.8 0 0 0 0 0 0 0 1 0 0 0 33 102.0 0 106.0 105.3 0 0 0 0 0 0 0 0 1 0 0 34 112.9 0 102.0 106.0 0 0 0 0 0 0 0 0 0 1 0 35 116.5 0 112.9 102.0 0 0 0 0 0 0 0 0 0 0 1 36 114.8 0 116.5 112.9 0 0 0 0 0 0 0 0 0 0 0 37 100.5 0 114.8 116.5 1 0 0 0 0 0 0 0 0 0 0 38 85.4 0 100.5 114.8 0 1 0 0 0 0 0 0 0 0 0 39 114.6 0 85.4 100.5 0 0 1 0 0 0 0 0 0 0 0 40 109.9 0 114.6 85.4 0 0 0 1 0 0 0 0 0 0 0 41 100.7 0 109.9 114.6 0 0 0 0 1 0 0 0 0 0 0 42 115.5 0 100.7 109.9 0 0 0 0 0 1 0 0 0 0 0 43 100.7 1 115.5 100.7 0 0 0 0 0 0 1 0 0 0 0 44 99.0 1 100.7 115.5 0 0 0 0 0 0 0 1 0 0 0 45 102.3 1 99.0 100.7 0 0 0 0 0 0 0 0 1 0 0 46 108.8 1 102.3 99.0 0 0 0 0 0 0 0 0 0 1 0 47 105.9 1 108.8 102.3 0 0 0 0 0 0 0 0 0 0 1 48 113.2 1 105.9 108.8 0 0 0 0 0 0 0 0 0 0 0 49 95.7 1 113.2 105.9 1 0 0 0 0 0 0 0 0 0 0 50 80.9 1 95.7 113.2 0 1 0 0 0 0 0 0 0 0 0 51 113.9 1 80.9 95.7 0 0 1 0 0 0 0 0 0 0 0 52 98.1 1 113.9 80.9 0 0 0 1 0 0 0 0 0 0 0 53 102.8 1 98.1 113.9 0 0 0 0 1 0 0 0 0 0 0 54 104.7 1 102.8 98.1 0 0 0 0 0 1 0 0 0 0 0 55 95.9 1 104.7 102.8 0 0 0 0 0 0 1 0 0 0 0 56 94.6 1 95.9 104.7 0 0 0 0 0 0 0 1 0 0 0 57 101.6 1 94.6 95.9 0 0 0 0 0 0 0 0 1 0 0 58 103.9 1 101.6 94.6 0 0 0 0 0 0 0 0 0 1 0 59 110.3 1 103.9 101.6 0 0 0 0 0 0 0 0 0 0 1 60 114.1 1 110.3 103.9 0 0 0 0 0 0 0 0 0 0 0 t 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52 53 53 54 54 55 55 56 56 57 57 58 58 59 59 60 60 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X Y1 Y2 M1 M2 48.77191 -3.92815 0.22963 0.35939 -16.65493 -24.60481 M3 M4 M5 M6 M7 M8 7.98613 -3.39182 -9.89628 -0.59165 -10.28675 -11.86737 M9 M10 M11 t -8.68197 -0.59741 4.17151 0.06035 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -7.70131 -2.72756 0.04016 2.35102 10.69223 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 48.77191 14.32224 3.405 0.00142 ** X -3.92815 2.80006 -1.403 0.16767 Y1 0.22963 0.13470 1.705 0.09529 . Y2 0.35939 0.12699 2.830 0.00699 ** M1 -16.65493 3.09199 -5.386 2.67e-06 *** M2 -24.60481 3.91299 -6.288 1.27e-07 *** M3 7.98613 4.38850 1.820 0.07560 . M4 -3.39182 3.89356 -0.871 0.38841 M5 -9.89628 3.54496 -2.792 0.00773 ** M6 -0.59165 3.27060 -0.181 0.85728 M7 -10.28675 3.03538 -3.389 0.00149 ** M8 -11.86737 3.54485 -3.348 0.00168 ** M9 -8.68197 3.39331 -2.559 0.01403 * M10 -0.59741 3.41124 -0.175 0.86178 M11 4.17151 3.13977 1.329 0.19083 t 0.06035 0.07321 0.824 0.41419 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 4.754 on 44 degrees of freedom Multiple R-squared: 0.8181, Adjusted R-squared: 0.756 F-statistic: 13.19 on 15 and 44 DF, p-value: 1.174e-11 > 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.8857444 0.228511291 0.114255645 [2,] 0.8496769 0.300646218 0.150323109 [3,] 0.8491035 0.301793096 0.150896548 [4,] 0.8432429 0.313514209 0.156757104 [5,] 0.9440686 0.111862802 0.055931401 [6,] 0.9982941 0.003411727 0.001705864 [7,] 0.9968478 0.006304465 0.003152233 [8,] 0.9970335 0.005932913 0.002966456 [9,] 0.9933172 0.013365576 0.006682788 [10,] 0.9861818 0.027636342 0.013818171 [11,] 0.9828266 0.034346775 0.017173387 [12,] 0.9808190 0.038362034 0.019181017 [13,] 0.9706990 0.058601985 0.029300992 [14,] 0.9640074 0.071985291 0.035992646 [15,] 0.9490335 0.101932991 0.050966495 [16,] 0.9113061 0.177387875 0.088693937 [17,] 0.9146891 0.170621862 0.085310931 [18,] 0.8810942 0.237811632 0.118905816 [19,] 0.8199253 0.360149371 0.180074686 [20,] 0.7546905 0.490618965 0.245309482 [21,] 0.7009931 0.598013829 0.299006915 [22,] 0.7251935 0.549612944 0.274806472 [23,] 0.7909782 0.418043638 0.209021819 > postscript(file="/var/www/html/rcomp/tmp/18oxh1258725988.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/2zd021258725989.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/38l4n1258725989.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/43l8o1258725989.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/5ljw61258725989.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 = 60 Frequency = 1 1 2 3 4 5 6 2.33311686 1.91295487 -5.22837153 -7.09034710 -3.06698505 -0.04276970 7 8 9 10 11 12 -3.20130159 -4.84218632 -0.72478082 -3.73682293 5.37679700 5.01206433 13 14 15 16 17 18 -1.50400917 6.09393788 0.32488429 1.63848180 10.69222976 -5.61188457 19 20 21 22 23 24 5.79811346 7.22491024 -7.31678021 1.05008982 6.11218739 -6.54619236 25 26 27 28 29 30 0.75129759 2.40473576 0.12308259 2.07362748 -1.74510177 5.16392042 31 32 33 34 35 36 -0.46760496 0.28844282 -2.26628065 1.15576110 -1.13893789 -3.47180408 37 38 39 40 41 42 -2.08065264 -5.39642021 -0.24098301 5.09814332 -7.07266466 2.16410246 43 44 45 46 47 48 0.83484112 -1.26530849 4.49829257 2.70655539 -7.70130980 2.03975008 49 50 51 52 53 54 0.50024736 -5.01520830 5.02138766 -1.71990550 1.19252172 -1.67336861 55 56 57 58 59 60 -2.96404803 -1.40585825 5.80954911 -1.17558337 -2.64873670 2.96618204 > postscript(file="/var/www/html/rcomp/tmp/66pmr1258725989.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 = 60 Frequency = 1 lag(myerror, k = 1) myerror 0 2.33311686 NA 1 1.91295487 2.33311686 2 -5.22837153 1.91295487 3 -7.09034710 -5.22837153 4 -3.06698505 -7.09034710 5 -0.04276970 -3.06698505 6 -3.20130159 -0.04276970 7 -4.84218632 -3.20130159 8 -0.72478082 -4.84218632 9 -3.73682293 -0.72478082 10 5.37679700 -3.73682293 11 5.01206433 5.37679700 12 -1.50400917 5.01206433 13 6.09393788 -1.50400917 14 0.32488429 6.09393788 15 1.63848180 0.32488429 16 10.69222976 1.63848180 17 -5.61188457 10.69222976 18 5.79811346 -5.61188457 19 7.22491024 5.79811346 20 -7.31678021 7.22491024 21 1.05008982 -7.31678021 22 6.11218739 1.05008982 23 -6.54619236 6.11218739 24 0.75129759 -6.54619236 25 2.40473576 0.75129759 26 0.12308259 2.40473576 27 2.07362748 0.12308259 28 -1.74510177 2.07362748 29 5.16392042 -1.74510177 30 -0.46760496 5.16392042 31 0.28844282 -0.46760496 32 -2.26628065 0.28844282 33 1.15576110 -2.26628065 34 -1.13893789 1.15576110 35 -3.47180408 -1.13893789 36 -2.08065264 -3.47180408 37 -5.39642021 -2.08065264 38 -0.24098301 -5.39642021 39 5.09814332 -0.24098301 40 -7.07266466 5.09814332 41 2.16410246 -7.07266466 42 0.83484112 2.16410246 43 -1.26530849 0.83484112 44 4.49829257 -1.26530849 45 2.70655539 4.49829257 46 -7.70130980 2.70655539 47 2.03975008 -7.70130980 48 0.50024736 2.03975008 49 -5.01520830 0.50024736 50 5.02138766 -5.01520830 51 -1.71990550 5.02138766 52 1.19252172 -1.71990550 53 -1.67336861 1.19252172 54 -2.96404803 -1.67336861 55 -1.40585825 -2.96404803 56 5.80954911 -1.40585825 57 -1.17558337 5.80954911 58 -2.64873670 -1.17558337 59 2.96618204 -2.64873670 60 NA 2.96618204 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 1.91295487 2.33311686 [2,] -5.22837153 1.91295487 [3,] -7.09034710 -5.22837153 [4,] -3.06698505 -7.09034710 [5,] -0.04276970 -3.06698505 [6,] -3.20130159 -0.04276970 [7,] -4.84218632 -3.20130159 [8,] -0.72478082 -4.84218632 [9,] -3.73682293 -0.72478082 [10,] 5.37679700 -3.73682293 [11,] 5.01206433 5.37679700 [12,] -1.50400917 5.01206433 [13,] 6.09393788 -1.50400917 [14,] 0.32488429 6.09393788 [15,] 1.63848180 0.32488429 [16,] 10.69222976 1.63848180 [17,] -5.61188457 10.69222976 [18,] 5.79811346 -5.61188457 [19,] 7.22491024 5.79811346 [20,] -7.31678021 7.22491024 [21,] 1.05008982 -7.31678021 [22,] 6.11218739 1.05008982 [23,] -6.54619236 6.11218739 [24,] 0.75129759 -6.54619236 [25,] 2.40473576 0.75129759 [26,] 0.12308259 2.40473576 [27,] 2.07362748 0.12308259 [28,] -1.74510177 2.07362748 [29,] 5.16392042 -1.74510177 [30,] -0.46760496 5.16392042 [31,] 0.28844282 -0.46760496 [32,] -2.26628065 0.28844282 [33,] 1.15576110 -2.26628065 [34,] -1.13893789 1.15576110 [35,] -3.47180408 -1.13893789 [36,] -2.08065264 -3.47180408 [37,] -5.39642021 -2.08065264 [38,] -0.24098301 -5.39642021 [39,] 5.09814332 -0.24098301 [40,] -7.07266466 5.09814332 [41,] 2.16410246 -7.07266466 [42,] 0.83484112 2.16410246 [43,] -1.26530849 0.83484112 [44,] 4.49829257 -1.26530849 [45,] 2.70655539 4.49829257 [46,] -7.70130980 2.70655539 [47,] 2.03975008 -7.70130980 [48,] 0.50024736 2.03975008 [49,] -5.01520830 0.50024736 [50,] 5.02138766 -5.01520830 [51,] -1.71990550 5.02138766 [52,] 1.19252172 -1.71990550 [53,] -1.67336861 1.19252172 [54,] -2.96404803 -1.67336861 [55,] -1.40585825 -2.96404803 [56,] 5.80954911 -1.40585825 [57,] -1.17558337 5.80954911 [58,] -2.64873670 -1.17558337 [59,] 2.96618204 -2.64873670 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 1.91295487 2.33311686 2 -5.22837153 1.91295487 3 -7.09034710 -5.22837153 4 -3.06698505 -7.09034710 5 -0.04276970 -3.06698505 6 -3.20130159 -0.04276970 7 -4.84218632 -3.20130159 8 -0.72478082 -4.84218632 9 -3.73682293 -0.72478082 10 5.37679700 -3.73682293 11 5.01206433 5.37679700 12 -1.50400917 5.01206433 13 6.09393788 -1.50400917 14 0.32488429 6.09393788 15 1.63848180 0.32488429 16 10.69222976 1.63848180 17 -5.61188457 10.69222976 18 5.79811346 -5.61188457 19 7.22491024 5.79811346 20 -7.31678021 7.22491024 21 1.05008982 -7.31678021 22 6.11218739 1.05008982 23 -6.54619236 6.11218739 24 0.75129759 -6.54619236 25 2.40473576 0.75129759 26 0.12308259 2.40473576 27 2.07362748 0.12308259 28 -1.74510177 2.07362748 29 5.16392042 -1.74510177 30 -0.46760496 5.16392042 31 0.28844282 -0.46760496 32 -2.26628065 0.28844282 33 1.15576110 -2.26628065 34 -1.13893789 1.15576110 35 -3.47180408 -1.13893789 36 -2.08065264 -3.47180408 37 -5.39642021 -2.08065264 38 -0.24098301 -5.39642021 39 5.09814332 -0.24098301 40 -7.07266466 5.09814332 41 2.16410246 -7.07266466 42 0.83484112 2.16410246 43 -1.26530849 0.83484112 44 4.49829257 -1.26530849 45 2.70655539 4.49829257 46 -7.70130980 2.70655539 47 2.03975008 -7.70130980 48 0.50024736 2.03975008 49 -5.01520830 0.50024736 50 5.02138766 -5.01520830 51 -1.71990550 5.02138766 52 1.19252172 -1.71990550 53 -1.67336861 1.19252172 54 -2.96404803 -1.67336861 55 -1.40585825 -2.96404803 56 5.80954911 -1.40585825 57 -1.17558337 5.80954911 58 -2.64873670 -1.17558337 59 2.96618204 -2.64873670 > 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/7z6v01258725989.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/83l351258725989.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/962nt1258725989.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/100bth1258725989.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/11vw0g1258725989.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/12k6u71258725989.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/13kqlt1258725989.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/147nvd1258725989.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/15kjer1258725989.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/165xel1258725989.tab") + } > > system("convert tmp/18oxh1258725988.ps tmp/18oxh1258725988.png") > system("convert tmp/2zd021258725989.ps tmp/2zd021258725989.png") > system("convert tmp/38l4n1258725989.ps tmp/38l4n1258725989.png") > system("convert tmp/43l8o1258725989.ps tmp/43l8o1258725989.png") > system("convert tmp/5ljw61258725989.ps tmp/5ljw61258725989.png") > system("convert tmp/66pmr1258725989.ps tmp/66pmr1258725989.png") > system("convert tmp/7z6v01258725989.ps tmp/7z6v01258725989.png") > system("convert tmp/83l351258725989.ps tmp/83l351258725989.png") > system("convert tmp/962nt1258725989.ps tmp/962nt1258725989.png") > system("convert tmp/100bth1258725989.ps tmp/100bth1258725989.png") > > > proc.time() user system elapsed 2.415 1.566 3.439