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(101.9 + ,96.4 + ,110.4 + ,100.5 + ,98.8 + ,93.7 + ,106.2 + ,101.9 + ,96.4 + ,110.4 + ,100.5 + ,106.7 + ,81 + ,106.2 + ,101.9 + ,96.4 + ,110.4 + ,86.7 + ,94.7 + ,81 + ,106.2 + ,101.9 + ,96.4 + ,95.3 + ,101 + ,94.7 + ,81 + ,106.2 + ,101.9 + ,99.3 + ,109.4 + ,101 + ,94.7 + ,81 + ,106.2 + ,101.8 + ,102.3 + ,109.4 + ,101 + ,94.7 + ,81 + ,96 + ,90.7 + ,102.3 + ,109.4 + ,101 + ,94.7 + ,91.7 + ,96.2 + ,90.7 + ,102.3 + ,109.4 + ,101 + ,95.3 + ,96.1 + ,96.2 + ,90.7 + ,102.3 + ,109.4 + ,96.6 + ,106 + ,96.1 + ,96.2 + ,90.7 + ,102.3 + ,107.2 + ,103.1 + ,106 + ,96.1 + ,96.2 + ,90.7 + ,108 + ,102 + ,103.1 + ,106 + ,96.1 + ,96.2 + ,98.4 + ,104.7 + ,102 + ,103.1 + ,106 + ,96.1 + ,103.1 + ,86 + ,104.7 + ,102 + ,103.1 + ,106 + ,81.1 + ,92.1 + ,86 + ,104.7 + ,102 + ,103.1 + ,96.6 + ,106.9 + ,92.1 + ,86 + ,104.7 + ,102 + ,103.7 + ,112.6 + ,106.9 + ,92.1 + ,86 + ,104.7 + ,106.6 + ,101.7 + ,112.6 + ,106.9 + ,92.1 + ,86 + ,97.6 + ,92 + ,101.7 + ,112.6 + ,106.9 + ,92.1 + ,87.6 + ,97.4 + ,92 + ,101.7 + ,112.6 + ,106.9 + ,99.4 + ,97 + ,97.4 + ,92 + ,101.7 + ,112.6 + ,98.5 + ,105.4 + ,97 + ,97.4 + ,92 + ,101.7 + ,105.2 + ,102.7 + ,105.4 + ,97 + ,97.4 + ,92 + ,104.6 + ,98.1 + ,102.7 + ,105.4 + ,97 + ,97.4 + ,97.5 + ,104.5 + ,98.1 + ,102.7 + ,105.4 + ,97 + ,108.9 + ,87.4 + ,104.5 + ,98.1 + ,102.7 + ,105.4 + ,86.8 + ,89.9 + ,87.4 + ,104.5 + ,98.1 + ,102.7 + ,88.9 + ,109.8 + ,89.9 + ,87.4 + ,104.5 + ,98.1 + ,110.3 + ,111.7 + ,109.8 + ,89.9 + ,87.4 + ,104.5 + ,114.8 + ,98.6 + ,111.7 + ,109.8 + ,89.9 + ,87.4 + ,94.6 + ,96.9 + ,98.6 + ,111.7 + ,109.8 + ,89.9 + ,92 + ,95.1 + ,96.9 + ,98.6 + ,111.7 + ,109.8 + ,93.8 + ,97 + ,95.1 + ,96.9 + ,98.6 + ,111.7 + ,93.8 + ,112.7 + ,97 + ,95.1 + ,96.9 + ,98.6 + ,107.6 + ,102.9 + ,112.7 + ,97 + ,95.1 + ,96.9 + ,101 + ,97.4 + ,102.9 + ,112.7 + ,97 + ,95.1 + ,95.4 + ,111.4 + ,97.4 + ,102.9 + ,112.7 + ,97 + ,96.5 + ,87.4 + ,111.4 + ,97.4 + ,102.9 + ,112.7 + ,89.2 + ,96.8 + ,87.4 + ,111.4 + ,97.4 + ,102.9 + ,87.1 + ,114.1 + ,96.8 + ,87.4 + ,111.4 + ,97.4 + ,110.5 + ,110.3 + ,114.1 + ,96.8 + ,87.4 + ,111.4 + ,110.8 + ,103.9 + ,110.3 + ,114.1 + ,96.8 + ,87.4 + ,104.2 + ,101.6 + ,103.9 + ,110.3 + ,114.1 + ,96.8 + ,88.9 + ,94.6 + ,101.6 + ,103.9 + ,110.3 + ,114.1 + ,89.8 + ,95.9 + ,94.6 + ,101.6 + ,103.9 + ,110.3 + ,90 + ,104.7 + ,95.9 + ,94.6 + ,101.6 + ,103.9 + ,93.9 + ,102.8 + ,104.7 + ,95.9 + ,94.6 + ,101.6 + ,91.3 + ,98.1 + ,102.8 + ,104.7 + ,95.9 + ,94.6 + ,87.8 + ,113.9 + ,98.1 + ,102.8 + ,104.7 + ,95.9 + ,99.7 + ,80.9 + ,113.9 + ,98.1 + ,102.8 + ,104.7 + ,73.5 + ,95.7 + ,80.9 + ,113.9 + ,98.1 + ,102.8 + ,79.2 + ,113.2 + ,95.7 + ,80.9 + ,113.9 + ,98.1 + ,96.9 + ,105.9 + ,113.2 + ,95.7 + ,80.9 + ,113.9 + ,95.2 + ,108.8 + ,105.9 + ,113.2 + ,95.7 + ,80.9 + ,95.6 + ,102.3 + ,108.8 + ,105.9 + ,113.2 + ,95.7 + ,89.7) + ,dim=c(6 + ,56) + ,dimnames=list(c('Y' + ,'Y(t-1)' + ,'Y(t-2)' + ,'Y(t-3)' + ,'Y(t-4)' + ,'X') + ,1:56)) > y <- array(NA,dim=c(6,56),dimnames=list(c('Y','Y(t-1)','Y(t-2)','Y(t-3)','Y(t-4)','X'),1:56)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par3 = 'Linear Trend' > par2 = 'Include Monthly Dummies' > par1 = '1' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > library(lattice) > library(lmtest) Loading required package: zoo Attaching package: 'zoo' The following object(s) are masked from package:base : as.Date.numeric > n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test > par1 <- as.numeric(par1) > x <- t(y) > k <- length(x[1,]) > n <- length(x[,1]) > x1 <- cbind(x[,par1], x[,1:k!=par1]) > mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1]) > colnames(x1) <- mycolnames #colnames(x)[par1] > x <- x1 > if (par3 == 'First Differences'){ + x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep=''))) + for (i in 1:n-1) { + for (j in 1:k) { + x2[i,j] <- x[i+1,j] - x[i,j] + } + } + x <- x2 + } > if (par2 == 'Include Monthly Dummies'){ + x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep =''))) + for (i in 1:11){ + x2[seq(i,n,12),i] <- 1 + } + x <- cbind(x, x2) + } > if (par2 == 'Include Quarterly Dummies'){ + x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep =''))) + for (i in 1:3){ + x2[seq(i,n,4),i] <- 1 + } + x <- cbind(x, x2) + } > k <- length(x[1,]) > if (par3 == 'Linear Trend'){ + x <- cbind(x, c(1:n)) + colnames(x)[k+1] <- 't' + } > x Y Y(t-1) Y(t-2) Y(t-3) Y(t-4) X M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 1 101.9 96.4 110.4 100.5 98.8 93.7 1 0 0 0 0 0 0 0 0 0 0 2 106.2 101.9 96.4 110.4 100.5 106.7 0 1 0 0 0 0 0 0 0 0 0 3 81.0 106.2 101.9 96.4 110.4 86.7 0 0 1 0 0 0 0 0 0 0 0 4 94.7 81.0 106.2 101.9 96.4 95.3 0 0 0 1 0 0 0 0 0 0 0 5 101.0 94.7 81.0 106.2 101.9 99.3 0 0 0 0 1 0 0 0 0 0 0 6 109.4 101.0 94.7 81.0 106.2 101.8 0 0 0 0 0 1 0 0 0 0 0 7 102.3 109.4 101.0 94.7 81.0 96.0 0 0 0 0 0 0 1 0 0 0 0 8 90.7 102.3 109.4 101.0 94.7 91.7 0 0 0 0 0 0 0 1 0 0 0 9 96.2 90.7 102.3 109.4 101.0 95.3 0 0 0 0 0 0 0 0 1 0 0 10 96.1 96.2 90.7 102.3 109.4 96.6 0 0 0 0 0 0 0 0 0 1 0 11 106.0 96.1 96.2 90.7 102.3 107.2 0 0 0 0 0 0 0 0 0 0 1 12 103.1 106.0 96.1 96.2 90.7 108.0 0 0 0 0 0 0 0 0 0 0 0 13 102.0 103.1 106.0 96.1 96.2 98.4 1 0 0 0 0 0 0 0 0 0 0 14 104.7 102.0 103.1 106.0 96.1 103.1 0 1 0 0 0 0 0 0 0 0 0 15 86.0 104.7 102.0 103.1 106.0 81.1 0 0 1 0 0 0 0 0 0 0 0 16 92.1 86.0 104.7 102.0 103.1 96.6 0 0 0 1 0 0 0 0 0 0 0 17 106.9 92.1 86.0 104.7 102.0 103.7 0 0 0 0 1 0 0 0 0 0 0 18 112.6 106.9 92.1 86.0 104.7 106.6 0 0 0 0 0 1 0 0 0 0 0 19 101.7 112.6 106.9 92.1 86.0 97.6 0 0 0 0 0 0 1 0 0 0 0 20 92.0 101.7 112.6 106.9 92.1 87.6 0 0 0 0 0 0 0 1 0 0 0 21 97.4 92.0 101.7 112.6 106.9 99.4 0 0 0 0 0 0 0 0 1 0 0 22 97.0 97.4 92.0 101.7 112.6 98.5 0 0 0 0 0 0 0 0 0 1 0 23 105.4 97.0 97.4 92.0 101.7 105.2 0 0 0 0 0 0 0 0 0 0 1 24 102.7 105.4 97.0 97.4 92.0 104.6 0 0 0 0 0 0 0 0 0 0 0 25 98.1 102.7 105.4 97.0 97.4 97.5 1 0 0 0 0 0 0 0 0 0 0 26 104.5 98.1 102.7 105.4 97.0 108.9 0 1 0 0 0 0 0 0 0 0 0 27 87.4 104.5 98.1 102.7 105.4 86.8 0 0 1 0 0 0 0 0 0 0 0 28 89.9 87.4 104.5 98.1 102.7 88.9 0 0 0 1 0 0 0 0 0 0 0 29 109.8 89.9 87.4 104.5 98.1 110.3 0 0 0 0 1 0 0 0 0 0 0 30 111.7 109.8 89.9 87.4 104.5 114.8 0 0 0 0 0 1 0 0 0 0 0 31 98.6 111.7 109.8 89.9 87.4 94.6 0 0 0 0 0 0 1 0 0 0 0 32 96.9 98.6 111.7 109.8 89.9 92.0 0 0 0 0 0 0 0 1 0 0 0 33 95.1 96.9 98.6 111.7 109.8 93.8 0 0 0 0 0 0 0 0 1 0 0 34 97.0 95.1 96.9 98.6 111.7 93.8 0 0 0 0 0 0 0 0 0 1 0 35 112.7 97.0 95.1 96.9 98.6 107.6 0 0 0 0 0 0 0 0 0 0 1 36 102.9 112.7 97.0 95.1 96.9 101.0 0 0 0 0 0 0 0 0 0 0 0 37 97.4 102.9 112.7 97.0 95.1 95.4 1 0 0 0 0 0 0 0 0 0 0 38 111.4 97.4 102.9 112.7 97.0 96.5 0 1 0 0 0 0 0 0 0 0 0 39 87.4 111.4 97.4 102.9 112.7 89.2 0 0 1 0 0 0 0 0 0 0 0 40 96.8 87.4 111.4 97.4 102.9 87.1 0 0 0 1 0 0 0 0 0 0 0 41 114.1 96.8 87.4 111.4 97.4 110.5 0 0 0 0 1 0 0 0 0 0 0 42 110.3 114.1 96.8 87.4 111.4 110.8 0 0 0 0 0 1 0 0 0 0 0 43 103.9 110.3 114.1 96.8 87.4 104.2 0 0 0 0 0 0 1 0 0 0 0 44 101.6 103.9 110.3 114.1 96.8 88.9 0 0 0 0 0 0 0 1 0 0 0 45 94.6 101.6 103.9 110.3 114.1 89.8 0 0 0 0 0 0 0 0 1 0 0 46 95.9 94.6 101.6 103.9 110.3 90.0 0 0 0 0 0 0 0 0 0 1 0 47 104.7 95.9 94.6 101.6 103.9 93.9 0 0 0 0 0 0 0 0 0 0 1 48 102.8 104.7 95.9 94.6 101.6 91.3 0 0 0 0 0 0 0 0 0 0 0 49 98.1 102.8 104.7 95.9 94.6 87.8 1 0 0 0 0 0 0 0 0 0 0 50 113.9 98.1 102.8 104.7 95.9 99.7 0 1 0 0 0 0 0 0 0 0 0 51 80.9 113.9 98.1 102.8 104.7 73.5 0 0 1 0 0 0 0 0 0 0 0 52 95.7 80.9 113.9 98.1 102.8 79.2 0 0 0 1 0 0 0 0 0 0 0 53 113.2 95.7 80.9 113.9 98.1 96.9 0 0 0 0 1 0 0 0 0 0 0 54 105.9 113.2 95.7 80.9 113.9 95.2 0 0 0 0 0 1 0 0 0 0 0 55 108.8 105.9 113.2 95.7 80.9 95.6 0 0 0 0 0 0 1 0 0 0 0 56 102.3 108.8 105.9 113.2 95.7 89.7 0 0 0 0 0 0 0 1 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 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) `Y(t-1)` `Y(t-2)` `Y(t-3)` `Y(t-4)` X 95.41289 -0.37352 -0.07516 0.35885 -0.07881 0.24021 M1 M2 M3 M4 M5 M6 -2.86774 -1.32952 -14.21143 -14.37463 -4.43379 11.53044 M7 M8 M9 M10 M11 t 2.77911 -9.08766 -13.60441 -9.75894 0.54283 0.11883 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -4.73664 -1.69797 0.02436 1.35731 4.28109 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 95.41289 29.57155 3.227 0.002580 ** `Y(t-1)` -0.37352 0.15293 -2.443 0.019347 * `Y(t-2)` -0.07516 0.14320 -0.525 0.602730 `Y(t-3)` 0.35885 0.13368 2.684 0.010706 * `Y(t-4)` -0.07881 0.14080 -0.560 0.578927 X 0.24021 0.08373 2.869 0.006688 ** M1 -2.86774 2.43224 -1.179 0.245706 M2 -1.32952 2.72907 -0.487 0.628936 M3 -14.21143 2.99754 -4.741 2.97e-05 *** M4 -14.37463 3.89792 -3.688 0.000705 *** M5 -4.43379 3.96881 -1.117 0.270940 M6 11.53044 2.95942 3.896 0.000384 *** M7 2.77911 3.33762 0.833 0.410237 M8 -9.08766 3.56879 -2.546 0.015058 * M9 -13.60441 4.06424 -3.347 0.001849 ** M10 -9.75894 3.86144 -2.527 0.015776 * M11 0.54283 2.91376 0.186 0.853202 t 0.11883 0.03212 3.700 0.000680 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 2.539 on 38 degrees of freedom Multiple R-squared: 0.9317, Adjusted R-squared: 0.9011 F-statistic: 30.47 on 17 and 38 DF, p-value: < 2.2e-16 > if (n > n25) { + kp3 <- k + 3 + nmkm3 <- n - k - 3 + gqarr <- array(NA, dim=c(nmkm3-kp3+1,3)) + numgqtests <- 0 + numsignificant1 <- 0 + numsignificant5 <- 0 + numsignificant10 <- 0 + for (mypoint in kp3:nmkm3) { + j <- 0 + numgqtests <- numgqtests + 1 + for (myalt in c('greater', 'two.sided', 'less')) { + j <- j + 1 + gqarr[mypoint-kp3+1,j] <- gqtest(mylm, point=mypoint, alternative=myalt)$p.value + } + if (gqarr[mypoint-kp3+1,2] < 0.01) numsignificant1 <- numsignificant1 + 1 + if (gqarr[mypoint-kp3+1,2] < 0.05) numsignificant5 <- numsignificant5 + 1 + if (gqarr[mypoint-kp3+1,2] < 0.10) numsignificant10 <- numsignificant10 + 1 + } + gqarr + } [,1] [,2] [,3] [1,] 0.134811767 0.26962353 0.8651882 [2,] 0.053011374 0.10602275 0.9469886 [3,] 0.025996028 0.05199206 0.9740040 [4,] 0.008691643 0.01738329 0.9913084 [5,] 0.039274356 0.07854871 0.9607256 [6,] 0.142077264 0.28415453 0.8579227 [7,] 0.147039788 0.29407958 0.8529602 [8,] 0.300637984 0.60127597 0.6993620 [9,] 0.245606993 0.49121399 0.7543930 [10,] 0.236046779 0.47209356 0.7639532 [11,] 0.162639601 0.32527920 0.8373604 [12,] 0.286608429 0.57321686 0.7133916 [13,] 0.695066113 0.60986777 0.3049339 [14,] 0.753568751 0.49286250 0.2464312 [15,] 0.645597182 0.70880564 0.3544028 > postscript(file="/var/www/html/rcomp/tmp/1nrvb1260718563.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/227721260718563.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/34cio1260718563.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/4em3p1260718563.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/5m0bd1260718563.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 = 56 Frequency = 1 1 2 3 4 5 6 2.755413923 -0.140899428 0.050096241 -0.437994725 -3.044869076 1.436373282 7 8 9 10 11 12 1.070831371 -0.950020784 0.698807354 0.714630880 1.626919210 -0.238815942 13 14 15 16 17 18 3.846341264 -0.429056291 1.665421613 -2.529248695 0.322988646 2.153236554 19 20 21 22 23 24 1.626271427 -2.396904755 -0.754917387 0.745664283 -0.006101384 -1.732742095 25 26 27 28 29 30 -1.686373990 -4.648850145 -0.001366505 -2.429734391 -0.740541535 -1.742799113 31 32 33 34 35 36 -1.397500221 -2.419464711 -0.986955503 0.999337426 3.115822150 1.844261315 37 38 39 40 41 42 -2.865841224 0.937711654 1.024368648 4.262194601 2.131462846 -0.939411450 43 44 45 46 47 48 -2.505362949 2.474369858 1.043065535 -2.459632589 -4.736639976 0.127296723 49 50 51 52 53 54 -2.049539973 4.281094210 -2.738519996 1.134783210 1.330959118 -0.907399274 55 56 1.205760371 3.292020392 > postscript(file="/var/www/html/rcomp/tmp/6vx031260718563.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 = 56 Frequency = 1 lag(myerror, k = 1) myerror 0 2.755413923 NA 1 -0.140899428 2.755413923 2 0.050096241 -0.140899428 3 -0.437994725 0.050096241 4 -3.044869076 -0.437994725 5 1.436373282 -3.044869076 6 1.070831371 1.436373282 7 -0.950020784 1.070831371 8 0.698807354 -0.950020784 9 0.714630880 0.698807354 10 1.626919210 0.714630880 11 -0.238815942 1.626919210 12 3.846341264 -0.238815942 13 -0.429056291 3.846341264 14 1.665421613 -0.429056291 15 -2.529248695 1.665421613 16 0.322988646 -2.529248695 17 2.153236554 0.322988646 18 1.626271427 2.153236554 19 -2.396904755 1.626271427 20 -0.754917387 -2.396904755 21 0.745664283 -0.754917387 22 -0.006101384 0.745664283 23 -1.732742095 -0.006101384 24 -1.686373990 -1.732742095 25 -4.648850145 -1.686373990 26 -0.001366505 -4.648850145 27 -2.429734391 -0.001366505 28 -0.740541535 -2.429734391 29 -1.742799113 -0.740541535 30 -1.397500221 -1.742799113 31 -2.419464711 -1.397500221 32 -0.986955503 -2.419464711 33 0.999337426 -0.986955503 34 3.115822150 0.999337426 35 1.844261315 3.115822150 36 -2.865841224 1.844261315 37 0.937711654 -2.865841224 38 1.024368648 0.937711654 39 4.262194601 1.024368648 40 2.131462846 4.262194601 41 -0.939411450 2.131462846 42 -2.505362949 -0.939411450 43 2.474369858 -2.505362949 44 1.043065535 2.474369858 45 -2.459632589 1.043065535 46 -4.736639976 -2.459632589 47 0.127296723 -4.736639976 48 -2.049539973 0.127296723 49 4.281094210 -2.049539973 50 -2.738519996 4.281094210 51 1.134783210 -2.738519996 52 1.330959118 1.134783210 53 -0.907399274 1.330959118 54 1.205760371 -0.907399274 55 3.292020392 1.205760371 56 NA 3.292020392 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -0.140899428 2.755413923 [2,] 0.050096241 -0.140899428 [3,] -0.437994725 0.050096241 [4,] -3.044869076 -0.437994725 [5,] 1.436373282 -3.044869076 [6,] 1.070831371 1.436373282 [7,] -0.950020784 1.070831371 [8,] 0.698807354 -0.950020784 [9,] 0.714630880 0.698807354 [10,] 1.626919210 0.714630880 [11,] -0.238815942 1.626919210 [12,] 3.846341264 -0.238815942 [13,] -0.429056291 3.846341264 [14,] 1.665421613 -0.429056291 [15,] -2.529248695 1.665421613 [16,] 0.322988646 -2.529248695 [17,] 2.153236554 0.322988646 [18,] 1.626271427 2.153236554 [19,] -2.396904755 1.626271427 [20,] -0.754917387 -2.396904755 [21,] 0.745664283 -0.754917387 [22,] -0.006101384 0.745664283 [23,] -1.732742095 -0.006101384 [24,] -1.686373990 -1.732742095 [25,] -4.648850145 -1.686373990 [26,] -0.001366505 -4.648850145 [27,] -2.429734391 -0.001366505 [28,] -0.740541535 -2.429734391 [29,] -1.742799113 -0.740541535 [30,] -1.397500221 -1.742799113 [31,] -2.419464711 -1.397500221 [32,] -0.986955503 -2.419464711 [33,] 0.999337426 -0.986955503 [34,] 3.115822150 0.999337426 [35,] 1.844261315 3.115822150 [36,] -2.865841224 1.844261315 [37,] 0.937711654 -2.865841224 [38,] 1.024368648 0.937711654 [39,] 4.262194601 1.024368648 [40,] 2.131462846 4.262194601 [41,] -0.939411450 2.131462846 [42,] -2.505362949 -0.939411450 [43,] 2.474369858 -2.505362949 [44,] 1.043065535 2.474369858 [45,] -2.459632589 1.043065535 [46,] -4.736639976 -2.459632589 [47,] 0.127296723 -4.736639976 [48,] -2.049539973 0.127296723 [49,] 4.281094210 -2.049539973 [50,] -2.738519996 4.281094210 [51,] 1.134783210 -2.738519996 [52,] 1.330959118 1.134783210 [53,] -0.907399274 1.330959118 [54,] 1.205760371 -0.907399274 [55,] 3.292020392 1.205760371 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -0.140899428 2.755413923 2 0.050096241 -0.140899428 3 -0.437994725 0.050096241 4 -3.044869076 -0.437994725 5 1.436373282 -3.044869076 6 1.070831371 1.436373282 7 -0.950020784 1.070831371 8 0.698807354 -0.950020784 9 0.714630880 0.698807354 10 1.626919210 0.714630880 11 -0.238815942 1.626919210 12 3.846341264 -0.238815942 13 -0.429056291 3.846341264 14 1.665421613 -0.429056291 15 -2.529248695 1.665421613 16 0.322988646 -2.529248695 17 2.153236554 0.322988646 18 1.626271427 2.153236554 19 -2.396904755 1.626271427 20 -0.754917387 -2.396904755 21 0.745664283 -0.754917387 22 -0.006101384 0.745664283 23 -1.732742095 -0.006101384 24 -1.686373990 -1.732742095 25 -4.648850145 -1.686373990 26 -0.001366505 -4.648850145 27 -2.429734391 -0.001366505 28 -0.740541535 -2.429734391 29 -1.742799113 -0.740541535 30 -1.397500221 -1.742799113 31 -2.419464711 -1.397500221 32 -0.986955503 -2.419464711 33 0.999337426 -0.986955503 34 3.115822150 0.999337426 35 1.844261315 3.115822150 36 -2.865841224 1.844261315 37 0.937711654 -2.865841224 38 1.024368648 0.937711654 39 4.262194601 1.024368648 40 2.131462846 4.262194601 41 -0.939411450 2.131462846 42 -2.505362949 -0.939411450 43 2.474369858 -2.505362949 44 1.043065535 2.474369858 45 -2.459632589 1.043065535 46 -4.736639976 -2.459632589 47 0.127296723 -4.736639976 48 -2.049539973 0.127296723 49 4.281094210 -2.049539973 50 -2.738519996 4.281094210 51 1.134783210 -2.738519996 52 1.330959118 1.134783210 53 -0.907399274 1.330959118 54 1.205760371 -0.907399274 55 3.292020392 1.205760371 > 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/701eg1260718563.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/8kblw1260718563.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/9stco1260718563.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/10nqxq1260718564.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/11dmrg1260718564.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/125q0l1260718564.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/13p1k61260718564.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/143ptm1260718564.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/15osfq1260718564.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/165m1w1260718564.tab") + } > try(system("convert tmp/1nrvb1260718563.ps tmp/1nrvb1260718563.png",intern=TRUE)) character(0) > try(system("convert tmp/227721260718563.ps tmp/227721260718563.png",intern=TRUE)) character(0) > try(system("convert tmp/34cio1260718563.ps tmp/34cio1260718563.png",intern=TRUE)) character(0) > try(system("convert tmp/4em3p1260718563.ps tmp/4em3p1260718563.png",intern=TRUE)) character(0) > try(system("convert tmp/5m0bd1260718563.ps tmp/5m0bd1260718563.png",intern=TRUE)) character(0) > try(system("convert tmp/6vx031260718563.ps tmp/6vx031260718563.png",intern=TRUE)) character(0) > try(system("convert tmp/701eg1260718563.ps tmp/701eg1260718563.png",intern=TRUE)) character(0) > try(system("convert tmp/8kblw1260718563.ps tmp/8kblw1260718563.png",intern=TRUE)) character(0) > try(system("convert tmp/9stco1260718563.ps tmp/9stco1260718563.png",intern=TRUE)) character(0) > try(system("convert tmp/10nqxq1260718564.ps tmp/10nqxq1260718564.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.319 1.554 2.730