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(99.06 + ,152.2 + ,96.92 + ,98.2 + ,98.54 + ,98.71 + ,99.65 + ,169.4 + ,99.06 + ,96.92 + ,98.2 + ,98.54 + ,99.82 + ,168.6 + ,99.65 + ,99.06 + ,96.92 + ,98.2 + ,99.99 + ,161.1 + ,99.82 + ,99.65 + ,99.06 + ,96.92 + ,100.33 + ,174.1 + ,99.99 + ,99.82 + ,99.65 + ,99.06 + ,99.31 + ,179 + ,100.33 + ,99.99 + ,99.82 + ,99.65 + ,101.1 + ,190.6 + ,99.31 + ,100.33 + ,99.99 + ,99.82 + ,101.1 + ,190 + ,101.1 + ,99.31 + ,100.33 + ,99.99 + ,100.93 + ,181.6 + ,101.1 + ,101.1 + ,99.31 + ,100.33 + ,100.85 + ,174.8 + ,100.93 + ,101.1 + ,101.1 + ,99.31 + ,100.93 + ,180.5 + ,100.85 + ,100.93 + ,101.1 + ,101.1 + ,99.6 + ,196.8 + ,100.93 + ,100.85 + ,100.93 + ,101.1 + ,101.88 + ,193.8 + ,99.6 + ,100.93 + ,100.85 + ,100.93 + ,101.81 + ,197 + ,101.88 + ,99.6 + ,100.93 + ,100.85 + ,102.38 + ,216.3 + ,101.81 + ,101.88 + ,99.6 + ,100.93 + ,102.74 + ,221.4 + ,102.38 + ,101.81 + ,101.88 + ,99.6 + ,102.82 + ,217.9 + ,102.74 + ,102.38 + ,101.81 + ,101.88 + ,101.72 + ,229.7 + ,102.82 + ,102.74 + ,102.38 + ,101.81 + ,103.47 + ,227.4 + ,101.72 + ,102.82 + ,102.74 + ,102.38 + ,102.98 + ,204.2 + ,103.47 + ,101.72 + ,102.82 + ,102.74 + ,102.68 + ,196.6 + ,102.98 + ,103.47 + ,101.72 + ,102.82 + ,102.9 + ,198.8 + ,102.68 + ,102.98 + ,103.47 + ,101.72 + ,103.03 + ,207.5 + ,102.9 + ,102.68 + ,102.98 + ,103.47 + ,101.29 + ,190.7 + ,103.03 + ,102.9 + ,102.68 + ,102.98 + ,103.69 + ,201.6 + ,101.29 + ,103.03 + ,102.9 + ,102.68 + ,103.68 + ,210.5 + ,103.69 + ,101.29 + ,103.03 + ,102.9 + ,104.2 + ,223.5 + ,103.68 + ,103.69 + ,101.29 + ,103.03 + ,104.08 + ,223.8 + ,104.2 + ,103.68 + ,103.69 + ,101.29 + ,104.16 + ,231.2 + ,104.08 + ,104.2 + ,103.68 + ,103.69 + ,103.05 + ,244 + ,104.16 + ,104.08 + ,104.2 + ,103.68 + ,104.66 + ,234.7 + ,103.05 + ,104.16 + ,104.08 + ,104.2 + ,104.46 + ,250.2 + ,104.66 + ,103.05 + ,104.16 + ,104.08 + ,104.95 + ,265.7 + ,104.46 + ,104.66 + ,103.05 + ,104.16 + ,105.85 + ,287.6 + ,104.95 + ,104.46 + ,104.66 + ,103.05 + ,106.23 + ,283.3 + ,105.85 + ,104.95 + ,104.46 + ,104.66 + ,104.86 + ,295.4 + ,106.23 + ,105.85 + ,104.95 + ,104.46 + ,107.44 + ,312.3 + ,104.86 + ,106.23 + ,105.85 + ,104.95 + ,108.23 + ,333.8 + ,107.44 + ,104.86 + ,106.23 + ,105.85 + ,108.45 + ,347.7 + ,108.23 + ,107.44 + ,104.86 + ,106.23 + ,109.39 + ,383.2 + ,108.45 + ,108.23 + ,107.44 + ,104.86 + ,110.15 + ,407.1 + ,109.39 + ,108.45 + ,108.23 + ,107.44 + ,109.13 + ,413.6 + ,110.15 + ,109.39 + ,108.45 + ,108.23 + ,110.28 + ,362.7 + ,109.13 + ,110.15 + ,109.39 + ,108.45 + ,110.17 + ,321.9 + ,110.28 + ,109.13 + ,110.15 + ,109.39 + ,109.99 + ,239.4 + ,110.17 + ,110.28 + ,109.13 + ,110.15 + ,109.26 + ,191 + ,109.99 + ,110.17 + ,110.28 + ,109.13 + ,109.11 + ,159.7 + ,109.26 + ,109.99 + ,110.17 + ,110.28 + ,107.06 + ,163.4 + ,109.11 + ,109.26 + ,109.99 + ,110.17 + ,109.53 + ,157.6 + ,107.06 + ,109.11 + ,109.26 + ,109.99 + ,108.92 + ,166.2 + ,109.53 + ,107.06 + ,109.11 + ,109.26 + ,109.24 + ,176.7 + ,108.92 + ,109.53 + ,107.06 + ,109.11 + ,109.12 + ,198.3 + ,109.24 + ,108.92 + ,109.53 + ,107.06 + ,109 + ,226.2 + ,109.12 + ,109.24 + ,108.92 + ,109.53 + ,107.23 + ,216.2 + ,109 + ,109.12 + ,109.24 + ,108.92 + ,109.49 + ,235.9 + ,107.23 + ,109 + ,109.12 + ,109.24 + ,109.04 + ,226.9 + ,109.49 + ,107.23 + ,109 + ,109.12) + ,dim=c(6 + ,56) + ,dimnames=list(c('Y' + ,'X' + ,'Y1' + ,'Y2' + ,'Y3' + ,'Y4') + ,1:56)) > y <- array(NA,dim=c(6,56),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),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 X Y1 Y2 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 1 99.06 152.2 96.92 98.20 98.54 98.71 1 0 0 0 0 0 0 0 0 0 0 2 99.65 169.4 99.06 96.92 98.20 98.54 0 1 0 0 0 0 0 0 0 0 0 3 99.82 168.6 99.65 99.06 96.92 98.20 0 0 1 0 0 0 0 0 0 0 0 4 99.99 161.1 99.82 99.65 99.06 96.92 0 0 0 1 0 0 0 0 0 0 0 5 100.33 174.1 99.99 99.82 99.65 99.06 0 0 0 0 1 0 0 0 0 0 0 6 99.31 179.0 100.33 99.99 99.82 99.65 0 0 0 0 0 1 0 0 0 0 0 7 101.10 190.6 99.31 100.33 99.99 99.82 0 0 0 0 0 0 1 0 0 0 0 8 101.10 190.0 101.10 99.31 100.33 99.99 0 0 0 0 0 0 0 1 0 0 0 9 100.93 181.6 101.10 101.10 99.31 100.33 0 0 0 0 0 0 0 0 1 0 0 10 100.85 174.8 100.93 101.10 101.10 99.31 0 0 0 0 0 0 0 0 0 1 0 11 100.93 180.5 100.85 100.93 101.10 101.10 0 0 0 0 0 0 0 0 0 0 1 12 99.60 196.8 100.93 100.85 100.93 101.10 0 0 0 0 0 0 0 0 0 0 0 13 101.88 193.8 99.60 100.93 100.85 100.93 1 0 0 0 0 0 0 0 0 0 0 14 101.81 197.0 101.88 99.60 100.93 100.85 0 1 0 0 0 0 0 0 0 0 0 15 102.38 216.3 101.81 101.88 99.60 100.93 0 0 1 0 0 0 0 0 0 0 0 16 102.74 221.4 102.38 101.81 101.88 99.60 0 0 0 1 0 0 0 0 0 0 0 17 102.82 217.9 102.74 102.38 101.81 101.88 0 0 0 0 1 0 0 0 0 0 0 18 101.72 229.7 102.82 102.74 102.38 101.81 0 0 0 0 0 1 0 0 0 0 0 19 103.47 227.4 101.72 102.82 102.74 102.38 0 0 0 0 0 0 1 0 0 0 0 20 102.98 204.2 103.47 101.72 102.82 102.74 0 0 0 0 0 0 0 1 0 0 0 21 102.68 196.6 102.98 103.47 101.72 102.82 0 0 0 0 0 0 0 0 1 0 0 22 102.90 198.8 102.68 102.98 103.47 101.72 0 0 0 0 0 0 0 0 0 1 0 23 103.03 207.5 102.90 102.68 102.98 103.47 0 0 0 0 0 0 0 0 0 0 1 24 101.29 190.7 103.03 102.90 102.68 102.98 0 0 0 0 0 0 0 0 0 0 0 25 103.69 201.6 101.29 103.03 102.90 102.68 1 0 0 0 0 0 0 0 0 0 0 26 103.68 210.5 103.69 101.29 103.03 102.90 0 1 0 0 0 0 0 0 0 0 0 27 104.20 223.5 103.68 103.69 101.29 103.03 0 0 1 0 0 0 0 0 0 0 0 28 104.08 223.8 104.20 103.68 103.69 101.29 0 0 0 1 0 0 0 0 0 0 0 29 104.16 231.2 104.08 104.20 103.68 103.69 0 0 0 0 1 0 0 0 0 0 0 30 103.05 244.0 104.16 104.08 104.20 103.68 0 0 0 0 0 1 0 0 0 0 0 31 104.66 234.7 103.05 104.16 104.08 104.20 0 0 0 0 0 0 1 0 0 0 0 32 104.46 250.2 104.66 103.05 104.16 104.08 0 0 0 0 0 0 0 1 0 0 0 33 104.95 265.7 104.46 104.66 103.05 104.16 0 0 0 0 0 0 0 0 1 0 0 34 105.85 287.6 104.95 104.46 104.66 103.05 0 0 0 0 0 0 0 0 0 1 0 35 106.23 283.3 105.85 104.95 104.46 104.66 0 0 0 0 0 0 0 0 0 0 1 36 104.86 295.4 106.23 105.85 104.95 104.46 0 0 0 0 0 0 0 0 0 0 0 37 107.44 312.3 104.86 106.23 105.85 104.95 1 0 0 0 0 0 0 0 0 0 0 38 108.23 333.8 107.44 104.86 106.23 105.85 0 1 0 0 0 0 0 0 0 0 0 39 108.45 347.7 108.23 107.44 104.86 106.23 0 0 1 0 0 0 0 0 0 0 0 40 109.39 383.2 108.45 108.23 107.44 104.86 0 0 0 1 0 0 0 0 0 0 0 41 110.15 407.1 109.39 108.45 108.23 107.44 0 0 0 0 1 0 0 0 0 0 0 42 109.13 413.6 110.15 109.39 108.45 108.23 0 0 0 0 0 1 0 0 0 0 0 43 110.28 362.7 109.13 110.15 109.39 108.45 0 0 0 0 0 0 1 0 0 0 0 44 110.17 321.9 110.28 109.13 110.15 109.39 0 0 0 0 0 0 0 1 0 0 0 45 109.99 239.4 110.17 110.28 109.13 110.15 0 0 0 0 0 0 0 0 1 0 0 46 109.26 191.0 109.99 110.17 110.28 109.13 0 0 0 0 0 0 0 0 0 1 0 47 109.11 159.7 109.26 109.99 110.17 110.28 0 0 0 0 0 0 0 0 0 0 1 48 107.06 163.4 109.11 109.26 109.99 110.17 0 0 0 0 0 0 0 0 0 0 0 49 109.53 157.6 107.06 109.11 109.26 109.99 1 0 0 0 0 0 0 0 0 0 0 50 108.92 166.2 109.53 107.06 109.11 109.26 0 1 0 0 0 0 0 0 0 0 0 51 109.24 176.7 108.92 109.53 107.06 109.11 0 0 1 0 0 0 0 0 0 0 0 52 109.12 198.3 109.24 108.92 109.53 107.06 0 0 0 1 0 0 0 0 0 0 0 53 109.00 226.2 109.12 109.24 108.92 109.53 0 0 0 0 1 0 0 0 0 0 0 54 107.23 216.2 109.00 109.12 109.24 108.92 0 0 0 0 0 1 0 0 0 0 0 55 109.49 235.9 107.23 109.00 109.12 109.24 0 0 0 0 0 0 1 0 0 0 0 56 109.04 226.9 109.49 107.23 109.00 109.12 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) X Y1 Y2 Y3 Y4 12.007511 0.007069 0.492628 0.141018 0.007787 0.210384 M1 M2 M3 M4 M5 M6 3.106969 2.189399 2.060312 2.325011 1.768215 0.333423 M7 M8 M9 M10 M11 t 2.557666 1.647499 1.541058 1.917512 1.687456 0.015187 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -0.463785 -0.188432 -0.001107 0.168242 0.448421 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 12.007511 4.458237 2.693 0.01047 * X 0.007069 0.001277 5.535 2.47e-06 *** Y1 0.492628 0.147233 3.346 0.00186 ** Y2 0.141018 0.168918 0.835 0.40903 Y3 0.007787 0.183195 0.043 0.96632 Y4 0.210384 0.151534 1.388 0.17311 M1 3.106969 0.309330 10.044 3.02e-12 *** M2 2.189399 0.375757 5.827 9.84e-07 *** M3 2.060312 0.401601 5.130 8.83e-06 *** M4 2.325011 0.394889 5.888 8.12e-07 *** M5 1.768215 0.182991 9.663 8.78e-12 *** M6 0.333423 0.185596 1.796 0.08037 . M7 2.557666 0.274398 9.321 2.32e-11 *** M8 1.647499 0.303220 5.433 3.41e-06 *** M9 1.541058 0.299573 5.144 8.46e-06 *** M10 1.917512 0.296605 6.465 1.31e-07 *** M11 1.687456 0.192941 8.746 1.23e-10 *** t 0.015187 0.010331 1.470 0.14979 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.2678 on 38 degrees of freedom Multiple R-squared: 0.9962, Adjusted R-squared: 0.9944 F-statistic: 578.5 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.331941144 0.66388229 0.6680589 [2,] 0.189451503 0.37890301 0.8105485 [3,] 0.133656320 0.26731264 0.8663437 [4,] 0.069097637 0.13819527 0.9309024 [5,] 0.036009972 0.07201994 0.9639900 [6,] 0.016625809 0.03325162 0.9833742 [7,] 0.006616157 0.01323231 0.9933838 [8,] 0.022253485 0.04450697 0.9777465 [9,] 0.053262103 0.10652421 0.9467379 [10,] 0.053961490 0.10792298 0.9460385 [11,] 0.033630683 0.06726137 0.9663693 [12,] 0.023159706 0.04631941 0.9768403 [13,] 0.024756815 0.04951363 0.9752432 [14,] 0.018107646 0.03621529 0.9818924 [15,] 0.008435620 0.01687124 0.9915644 > postscript(file="/var/www/html/rcomp/tmp/1zp0x1258722692.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/2po611258722692.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/32ugf1258722692.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/4hwxs1258722692.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/5zmqz1258722692.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 -0.27342156 0.26206616 0.04068883 0.06950241 0.29667717 0.34472669 7 8 9 10 11 12 0.23074162 0.35358520 0.01820738 -0.12096241 -0.17959077 0.02064721 13 14 15 16 17 18 -0.11999896 -0.22966620 0.02428811 0.05948139 -0.03102560 0.12527617 19 20 21 22 23 24 0.05999307 -0.15436429 -0.32304600 -0.07555454 -0.22261541 -0.16122759 25 26 27 28 29 30 -0.06019321 -0.21495659 -0.02027378 -0.32965549 -0.27941622 -0.08472841 31 32 33 34 35 36 -0.22134500 -0.24791279 0.08706826 0.44842141 0.22406248 0.16494183 37 38 39 40 41 42 0.01453637 0.28484490 -0.30179737 0.15571962 0.24534055 -0.07587463 43 44 45 46 47 48 -0.46378538 -0.01674939 0.21777035 -0.25190446 0.17814370 -0.02436145 49 50 51 52 53 54 0.43907736 -0.10228828 0.25709422 0.04495207 -0.23157591 -0.30939981 55 56 0.39439569 0.06544127 > postscript(file="/var/www/html/rcomp/tmp/68tyt1258722692.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 -0.27342156 NA 1 0.26206616 -0.27342156 2 0.04068883 0.26206616 3 0.06950241 0.04068883 4 0.29667717 0.06950241 5 0.34472669 0.29667717 6 0.23074162 0.34472669 7 0.35358520 0.23074162 8 0.01820738 0.35358520 9 -0.12096241 0.01820738 10 -0.17959077 -0.12096241 11 0.02064721 -0.17959077 12 -0.11999896 0.02064721 13 -0.22966620 -0.11999896 14 0.02428811 -0.22966620 15 0.05948139 0.02428811 16 -0.03102560 0.05948139 17 0.12527617 -0.03102560 18 0.05999307 0.12527617 19 -0.15436429 0.05999307 20 -0.32304600 -0.15436429 21 -0.07555454 -0.32304600 22 -0.22261541 -0.07555454 23 -0.16122759 -0.22261541 24 -0.06019321 -0.16122759 25 -0.21495659 -0.06019321 26 -0.02027378 -0.21495659 27 -0.32965549 -0.02027378 28 -0.27941622 -0.32965549 29 -0.08472841 -0.27941622 30 -0.22134500 -0.08472841 31 -0.24791279 -0.22134500 32 0.08706826 -0.24791279 33 0.44842141 0.08706826 34 0.22406248 0.44842141 35 0.16494183 0.22406248 36 0.01453637 0.16494183 37 0.28484490 0.01453637 38 -0.30179737 0.28484490 39 0.15571962 -0.30179737 40 0.24534055 0.15571962 41 -0.07587463 0.24534055 42 -0.46378538 -0.07587463 43 -0.01674939 -0.46378538 44 0.21777035 -0.01674939 45 -0.25190446 0.21777035 46 0.17814370 -0.25190446 47 -0.02436145 0.17814370 48 0.43907736 -0.02436145 49 -0.10228828 0.43907736 50 0.25709422 -0.10228828 51 0.04495207 0.25709422 52 -0.23157591 0.04495207 53 -0.30939981 -0.23157591 54 0.39439569 -0.30939981 55 0.06544127 0.39439569 56 NA 0.06544127 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 0.26206616 -0.27342156 [2,] 0.04068883 0.26206616 [3,] 0.06950241 0.04068883 [4,] 0.29667717 0.06950241 [5,] 0.34472669 0.29667717 [6,] 0.23074162 0.34472669 [7,] 0.35358520 0.23074162 [8,] 0.01820738 0.35358520 [9,] -0.12096241 0.01820738 [10,] -0.17959077 -0.12096241 [11,] 0.02064721 -0.17959077 [12,] -0.11999896 0.02064721 [13,] -0.22966620 -0.11999896 [14,] 0.02428811 -0.22966620 [15,] 0.05948139 0.02428811 [16,] -0.03102560 0.05948139 [17,] 0.12527617 -0.03102560 [18,] 0.05999307 0.12527617 [19,] -0.15436429 0.05999307 [20,] -0.32304600 -0.15436429 [21,] -0.07555454 -0.32304600 [22,] -0.22261541 -0.07555454 [23,] -0.16122759 -0.22261541 [24,] -0.06019321 -0.16122759 [25,] -0.21495659 -0.06019321 [26,] -0.02027378 -0.21495659 [27,] -0.32965549 -0.02027378 [28,] -0.27941622 -0.32965549 [29,] -0.08472841 -0.27941622 [30,] -0.22134500 -0.08472841 [31,] -0.24791279 -0.22134500 [32,] 0.08706826 -0.24791279 [33,] 0.44842141 0.08706826 [34,] 0.22406248 0.44842141 [35,] 0.16494183 0.22406248 [36,] 0.01453637 0.16494183 [37,] 0.28484490 0.01453637 [38,] -0.30179737 0.28484490 [39,] 0.15571962 -0.30179737 [40,] 0.24534055 0.15571962 [41,] -0.07587463 0.24534055 [42,] -0.46378538 -0.07587463 [43,] -0.01674939 -0.46378538 [44,] 0.21777035 -0.01674939 [45,] -0.25190446 0.21777035 [46,] 0.17814370 -0.25190446 [47,] -0.02436145 0.17814370 [48,] 0.43907736 -0.02436145 [49,] -0.10228828 0.43907736 [50,] 0.25709422 -0.10228828 [51,] 0.04495207 0.25709422 [52,] -0.23157591 0.04495207 [53,] -0.30939981 -0.23157591 [54,] 0.39439569 -0.30939981 [55,] 0.06544127 0.39439569 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 0.26206616 -0.27342156 2 0.04068883 0.26206616 3 0.06950241 0.04068883 4 0.29667717 0.06950241 5 0.34472669 0.29667717 6 0.23074162 0.34472669 7 0.35358520 0.23074162 8 0.01820738 0.35358520 9 -0.12096241 0.01820738 10 -0.17959077 -0.12096241 11 0.02064721 -0.17959077 12 -0.11999896 0.02064721 13 -0.22966620 -0.11999896 14 0.02428811 -0.22966620 15 0.05948139 0.02428811 16 -0.03102560 0.05948139 17 0.12527617 -0.03102560 18 0.05999307 0.12527617 19 -0.15436429 0.05999307 20 -0.32304600 -0.15436429 21 -0.07555454 -0.32304600 22 -0.22261541 -0.07555454 23 -0.16122759 -0.22261541 24 -0.06019321 -0.16122759 25 -0.21495659 -0.06019321 26 -0.02027378 -0.21495659 27 -0.32965549 -0.02027378 28 -0.27941622 -0.32965549 29 -0.08472841 -0.27941622 30 -0.22134500 -0.08472841 31 -0.24791279 -0.22134500 32 0.08706826 -0.24791279 33 0.44842141 0.08706826 34 0.22406248 0.44842141 35 0.16494183 0.22406248 36 0.01453637 0.16494183 37 0.28484490 0.01453637 38 -0.30179737 0.28484490 39 0.15571962 -0.30179737 40 0.24534055 0.15571962 41 -0.07587463 0.24534055 42 -0.46378538 -0.07587463 43 -0.01674939 -0.46378538 44 0.21777035 -0.01674939 45 -0.25190446 0.21777035 46 0.17814370 -0.25190446 47 -0.02436145 0.17814370 48 0.43907736 -0.02436145 49 -0.10228828 0.43907736 50 0.25709422 -0.10228828 51 0.04495207 0.25709422 52 -0.23157591 0.04495207 53 -0.30939981 -0.23157591 54 0.39439569 -0.30939981 55 0.06544127 0.39439569 > 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/78b3d1258722692.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/8jbpf1258722692.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/9vucp1258722692.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/10lnb81258722692.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/11kxaw1258722692.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/12voeh1258722692.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/13k4f41258722692.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/147atn1258722692.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/1528ho1258722692.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/16zate1258722692.tab") + } > > system("convert tmp/1zp0x1258722692.ps tmp/1zp0x1258722692.png") > system("convert tmp/2po611258722692.ps tmp/2po611258722692.png") > system("convert tmp/32ugf1258722692.ps tmp/32ugf1258722692.png") > system("convert tmp/4hwxs1258722692.ps tmp/4hwxs1258722692.png") > system("convert tmp/5zmqz1258722692.ps tmp/5zmqz1258722692.png") > system("convert tmp/68tyt1258722692.ps tmp/68tyt1258722692.png") > system("convert tmp/78b3d1258722692.ps tmp/78b3d1258722692.png") > system("convert tmp/8jbpf1258722692.ps tmp/8jbpf1258722692.png") > system("convert tmp/9vucp1258722692.ps tmp/9vucp1258722692.png") > system("convert tmp/10lnb81258722692.ps tmp/10lnb81258722692.png") > > > proc.time() user system elapsed 2.372 1.577 5.590