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(96.38 + ,108.3 + ,98.30 + ,95.62 + ,93.11 + ,96.96 + ,100.82 + ,113.2 + ,96.38 + ,98.30 + ,95.62 + ,93.11 + ,99.06 + ,105 + ,100.82 + ,96.38 + ,98.30 + ,95.62 + ,94.03 + ,104 + ,99.06 + ,100.82 + ,96.38 + ,98.30 + ,102.07 + ,109.8 + ,94.03 + ,99.06 + ,100.82 + ,96.38 + ,99.31 + ,98.6 + ,102.07 + ,94.03 + ,99.06 + ,100.82 + ,98.64 + ,93.5 + ,99.31 + ,102.07 + ,94.03 + ,99.06 + ,101.82 + ,98.2 + ,98.64 + ,99.31 + ,102.07 + ,94.03 + ,99.14 + ,88 + ,101.82 + ,98.64 + ,99.31 + ,102.07 + ,97.63 + ,85.3 + ,99.14 + ,101.82 + ,98.64 + ,99.31 + ,100.06 + ,96.8 + ,97.63 + ,99.14 + ,101.82 + ,98.64 + ,101.32 + ,98.8 + ,100.06 + ,97.63 + ,99.14 + ,101.82 + ,101.49 + ,110.3 + ,101.32 + ,100.06 + ,97.63 + ,99.14 + ,105.43 + ,111.6 + ,101.49 + ,101.32 + ,100.06 + ,97.63 + ,105.09 + ,111.2 + ,105.43 + ,101.49 + ,101.32 + ,100.06 + ,99.48 + ,106.9 + ,105.09 + ,105.43 + ,101.49 + ,101.32 + ,108.53 + ,117.6 + ,99.48 + ,105.09 + ,105.43 + ,101.49 + ,104.34 + ,97 + ,108.53 + ,99.48 + ,105.09 + ,105.43 + ,106.10 + ,97.3 + ,104.34 + ,108.53 + ,99.48 + ,105.09 + ,107.35 + ,98.4 + ,106.10 + ,104.34 + ,108.53 + ,99.48 + ,103.00 + ,87.6 + ,107.35 + ,106.10 + ,104.34 + ,108.53 + ,104.50 + ,87.4 + ,103.00 + ,107.35 + ,106.10 + ,104.34 + ,105.17 + ,94.7 + ,104.50 + ,103.00 + ,107.35 + ,106.10 + ,104.84 + ,101.5 + ,105.17 + ,104.50 + ,103.00 + ,107.35 + ,106.18 + ,110.4 + ,104.84 + ,105.17 + ,104.50 + ,103.00 + ,108.86 + ,108.4 + ,106.18 + ,104.84 + ,105.17 + ,104.50 + ,107.77 + ,109.7 + ,108.86 + ,106.18 + ,104.84 + ,105.17 + ,102.74 + ,105.2 + ,107.77 + ,108.86 + ,106.18 + ,104.84 + ,112.63 + ,111.1 + ,102.74 + ,107.77 + ,108.86 + ,106.18 + ,106.26 + ,96.2 + ,112.63 + ,102.74 + ,107.77 + ,108.86 + ,108.86 + ,97.3 + ,106.26 + ,112.63 + ,102.74 + ,107.77 + ,111.38 + ,98.9 + ,108.86 + ,106.26 + ,112.63 + ,102.74 + ,106.85 + ,91.7 + ,111.38 + ,108.86 + ,106.26 + ,112.63 + ,107.86 + ,90.9 + ,106.85 + ,111.38 + ,108.86 + ,106.26 + ,107.94 + ,98.8 + ,107.86 + ,106.85 + ,111.38 + ,108.86 + ,111.38 + ,111.5 + ,107.94 + ,107.86 + ,106.85 + ,111.38 + ,111.29 + ,119 + ,111.38 + ,107.94 + ,107.86 + ,106.85 + ,113.72 + ,115.3 + ,111.29 + ,111.38 + ,107.94 + ,107.86 + ,111.88 + ,116.3 + ,113.72 + ,111.29 + ,111.38 + ,107.94 + ,109.87 + ,113.6 + ,111.88 + ,113.72 + ,111.29 + ,111.38 + ,113.72 + ,115.1 + ,109.87 + ,111.88 + ,113.72 + ,111.29 + ,111.71 + ,109.7 + ,113.72 + ,109.87 + ,111.88 + ,113.72 + ,114.81 + ,97.6 + ,111.71 + ,113.72 + ,109.87 + ,111.88 + ,112.05 + ,100.8 + ,114.81 + ,111.71 + ,113.72 + ,109.87 + ,111.54 + ,94 + ,112.05 + ,114.81 + ,111.71 + ,113.72 + ,110.87 + ,87.2 + ,111.54 + ,112.05 + ,114.81 + ,111.71 + ,110.87 + ,102.9 + ,110.87 + ,111.54 + ,112.05 + ,114.81 + ,115.48 + ,111.3 + ,110.87 + ,110.87 + ,111.54 + ,112.05 + ,111.63 + ,106.6 + ,115.48 + ,110.87 + ,110.87 + ,111.54 + ,116.24 + ,108.9 + ,111.63 + ,115.48 + ,110.87 + ,110.87 + ,113.56 + ,108.3 + ,116.24 + ,111.63 + ,115.48 + ,110.87 + ,106.01 + ,100.5 + ,113.56 + ,116.24 + ,111.63 + ,115.48 + ,110.45 + ,104 + ,106.01 + ,113.56 + ,116.24 + ,111.63 + ,107.77 + ,89.9 + ,110.45 + ,106.01 + ,113.56 + ,116.24 + ,108.61 + ,86.8 + ,107.77 + ,110.45 + ,106.01 + ,113.56 + ,108.19 + ,91.2 + ,108.61 + ,107.77 + ,110.45 + ,106.01) + ,dim=c(6 + ,56) + ,dimnames=list(c('BESTC' + ,'INDUSTR' + ,'Y1' + ,'Y2' + ,'Y3' + ,'Y4') + ,1:56)) > y <- array(NA,dim=c(6,56),dimnames=list(c('BESTC','INDUSTR','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 BESTC INDUSTR Y1 Y2 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 1 96.38 108.3 98.30 95.62 93.11 96.96 1 0 0 0 0 0 0 0 0 0 2 100.82 113.2 96.38 98.30 95.62 93.11 0 1 0 0 0 0 0 0 0 0 3 99.06 105.0 100.82 96.38 98.30 95.62 0 0 1 0 0 0 0 0 0 0 4 94.03 104.0 99.06 100.82 96.38 98.30 0 0 0 1 0 0 0 0 0 0 5 102.07 109.8 94.03 99.06 100.82 96.38 0 0 0 0 1 0 0 0 0 0 6 99.31 98.6 102.07 94.03 99.06 100.82 0 0 0 0 0 1 0 0 0 0 7 98.64 93.5 99.31 102.07 94.03 99.06 0 0 0 0 0 0 1 0 0 0 8 101.82 98.2 98.64 99.31 102.07 94.03 0 0 0 0 0 0 0 1 0 0 9 99.14 88.0 101.82 98.64 99.31 102.07 0 0 0 0 0 0 0 0 1 0 10 97.63 85.3 99.14 101.82 98.64 99.31 0 0 0 0 0 0 0 0 0 1 11 100.06 96.8 97.63 99.14 101.82 98.64 0 0 0 0 0 0 0 0 0 0 12 101.32 98.8 100.06 97.63 99.14 101.82 0 0 0 0 0 0 0 0 0 0 13 101.49 110.3 101.32 100.06 97.63 99.14 1 0 0 0 0 0 0 0 0 0 14 105.43 111.6 101.49 101.32 100.06 97.63 0 1 0 0 0 0 0 0 0 0 15 105.09 111.2 105.43 101.49 101.32 100.06 0 0 1 0 0 0 0 0 0 0 16 99.48 106.9 105.09 105.43 101.49 101.32 0 0 0 1 0 0 0 0 0 0 17 108.53 117.6 99.48 105.09 105.43 101.49 0 0 0 0 1 0 0 0 0 0 18 104.34 97.0 108.53 99.48 105.09 105.43 0 0 0 0 0 1 0 0 0 0 19 106.10 97.3 104.34 108.53 99.48 105.09 0 0 0 0 0 0 1 0 0 0 20 107.35 98.4 106.10 104.34 108.53 99.48 0 0 0 0 0 0 0 1 0 0 21 103.00 87.6 107.35 106.10 104.34 108.53 0 0 0 0 0 0 0 0 1 0 22 104.50 87.4 103.00 107.35 106.10 104.34 0 0 0 0 0 0 0 0 0 1 23 105.17 94.7 104.50 103.00 107.35 106.10 0 0 0 0 0 0 0 0 0 0 24 104.84 101.5 105.17 104.50 103.00 107.35 0 0 0 0 0 0 0 0 0 0 25 106.18 110.4 104.84 105.17 104.50 103.00 1 0 0 0 0 0 0 0 0 0 26 108.86 108.4 106.18 104.84 105.17 104.50 0 1 0 0 0 0 0 0 0 0 27 107.77 109.7 108.86 106.18 104.84 105.17 0 0 1 0 0 0 0 0 0 0 28 102.74 105.2 107.77 108.86 106.18 104.84 0 0 0 1 0 0 0 0 0 0 29 112.63 111.1 102.74 107.77 108.86 106.18 0 0 0 0 1 0 0 0 0 0 30 106.26 96.2 112.63 102.74 107.77 108.86 0 0 0 0 0 1 0 0 0 0 31 108.86 97.3 106.26 112.63 102.74 107.77 0 0 0 0 0 0 1 0 0 0 32 111.38 98.9 108.86 106.26 112.63 102.74 0 0 0 0 0 0 0 1 0 0 33 106.85 91.7 111.38 108.86 106.26 112.63 0 0 0 0 0 0 0 0 1 0 34 107.86 90.9 106.85 111.38 108.86 106.26 0 0 0 0 0 0 0 0 0 1 35 107.94 98.8 107.86 106.85 111.38 108.86 0 0 0 0 0 0 0 0 0 0 36 111.38 111.5 107.94 107.86 106.85 111.38 0 0 0 0 0 0 0 0 0 0 37 111.29 119.0 111.38 107.94 107.86 106.85 1 0 0 0 0 0 0 0 0 0 38 113.72 115.3 111.29 111.38 107.94 107.86 0 1 0 0 0 0 0 0 0 0 39 111.88 116.3 113.72 111.29 111.38 107.94 0 0 1 0 0 0 0 0 0 0 40 109.87 113.6 111.88 113.72 111.29 111.38 0 0 0 1 0 0 0 0 0 0 41 113.72 115.1 109.87 111.88 113.72 111.29 0 0 0 0 1 0 0 0 0 0 42 111.71 109.7 113.72 109.87 111.88 113.72 0 0 0 0 0 1 0 0 0 0 43 114.81 97.6 111.71 113.72 109.87 111.88 0 0 0 0 0 0 1 0 0 0 44 112.05 100.8 114.81 111.71 113.72 109.87 0 0 0 0 0 0 0 1 0 0 45 111.54 94.0 112.05 114.81 111.71 113.72 0 0 0 0 0 0 0 0 1 0 46 110.87 87.2 111.54 112.05 114.81 111.71 0 0 0 0 0 0 0 0 0 1 47 110.87 102.9 110.87 111.54 112.05 114.81 0 0 0 0 0 0 0 0 0 0 48 115.48 111.3 110.87 110.87 111.54 112.05 0 0 0 0 0 0 0 0 0 0 49 111.63 106.6 115.48 110.87 110.87 111.54 1 0 0 0 0 0 0 0 0 0 50 116.24 108.9 111.63 115.48 110.87 110.87 0 1 0 0 0 0 0 0 0 0 51 113.56 108.3 116.24 111.63 115.48 110.87 0 0 1 0 0 0 0 0 0 0 52 106.01 100.5 113.56 116.24 111.63 115.48 0 0 0 1 0 0 0 0 0 0 53 110.45 104.0 106.01 113.56 116.24 111.63 0 0 0 0 1 0 0 0 0 0 54 107.77 89.9 110.45 106.01 113.56 116.24 0 0 0 0 0 1 0 0 0 0 55 108.61 86.8 107.77 110.45 106.01 113.56 0 0 0 0 0 0 1 0 0 0 56 108.19 91.2 108.61 107.77 110.45 106.01 0 0 0 0 0 0 0 1 0 0 M11 t 1 0 1 2 0 2 3 0 3 4 0 4 5 0 5 6 0 6 7 0 7 8 0 8 9 0 9 10 0 10 11 1 11 12 0 12 13 0 13 14 0 14 15 0 15 16 0 16 17 0 17 18 0 18 19 0 19 20 0 20 21 0 21 22 0 22 23 1 23 24 0 24 25 0 25 26 0 26 27 0 27 28 0 28 29 0 29 30 0 30 31 0 31 32 0 32 33 0 33 34 0 34 35 1 35 36 0 36 37 0 37 38 0 38 39 0 39 40 0 40 41 0 41 42 0 42 43 0 43 44 0 44 45 0 45 46 0 46 47 1 47 48 0 48 49 0 49 50 0 50 51 0 51 52 0 52 53 0 53 54 0 54 55 0 55 56 0 56 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) INDUSTR Y1 Y2 Y3 Y4 -6.926052 0.259802 0.155336 0.064915 0.580834 0.028575 M1 M2 M3 M4 M5 M6 -2.621253 0.187869 -2.896746 -6.453004 -2.024826 -2.171303 M7 M8 M9 M10 M11 t 3.405031 -0.584882 0.271970 0.552451 -1.888590 0.008277 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -2.60217 -0.38486 0.05628 0.39830 3.25798 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -6.926052 12.419377 -0.558 0.58033 INDUSTR 0.259802 0.050456 5.149 8.33e-06 *** Y1 0.155336 0.127793 1.216 0.23166 Y2 0.064915 0.134293 0.483 0.63160 Y3 0.580834 0.121949 4.763 2.78e-05 *** Y4 0.028575 0.157421 0.182 0.85692 M1 -2.621253 0.959351 -2.732 0.00949 ** M2 0.187869 1.028426 0.183 0.85602 M3 -2.896746 1.065543 -2.719 0.00983 ** M4 -6.453004 1.002550 -6.437 1.44e-07 *** M5 -2.024826 1.086113 -1.864 0.07002 . M6 -2.171303 0.954236 -2.275 0.02861 * M7 3.405031 1.356839 2.510 0.01647 * M8 -0.584882 1.429526 -0.409 0.68473 M9 0.271970 1.273798 0.214 0.83207 M10 0.552451 1.559290 0.354 0.72508 M11 -1.888590 0.950698 -1.987 0.05422 . t 0.008277 0.046890 0.177 0.86082 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.071 on 38 degrees of freedom Multiple R-squared: 0.972, Adjusted R-squared: 0.9595 F-statistic: 77.67 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.086565766 0.173131533 0.9134342 [2,] 0.040618547 0.081237093 0.9593815 [3,] 0.013949363 0.027898725 0.9860506 [4,] 0.013192067 0.026384134 0.9868079 [5,] 0.010023795 0.020047590 0.9899762 [6,] 0.007723423 0.015446846 0.9922766 [7,] 0.002898300 0.005796600 0.9971017 [8,] 0.001431683 0.002863366 0.9985683 [9,] 0.255251755 0.510503510 0.7447482 [10,] 0.206268414 0.412536829 0.7937316 [11,] 0.124843804 0.249687609 0.8751562 [12,] 0.122995823 0.245991645 0.8770042 [13,] 0.079396458 0.158792916 0.9206035 [14,] 0.061267898 0.122535795 0.9387321 [15,] 0.068294875 0.136589750 0.9317051 > postscript(file="/var/www/html/rcomp/tmp/15dc51258752759.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/2abtq1258752759.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/3u1fy1258752759.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/4eqkj1258752759.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/5ri7q1258752759.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.54637398 -1.42040794 -0.16710930 -0.36553883 0.10271088 0.36370480 7 8 9 10 11 12 -1.68722041 0.01041721 0.03814720 -0.38124823 0.07441800 0.10426778 13 14 15 16 17 18 0.49969430 -0.19192559 1.22398380 -0.05858567 0.37524513 0.71864128 19 20 21 22 23 24 0.14765952 -0.00412343 -0.54672556 0.40850887 0.88776044 -0.81629899 25 26 27 28 29 30 0.08525888 -0.15128687 1.16655052 0.08009590 3.25798473 0.24400678 31 32 33 34 35 36 0.27383592 0.76871064 0.10123029 0.24225745 -0.69823463 0.02659147 37 38 39 40 41 42 -0.39569433 -0.10648249 -1.50192587 0.81957132 -1.13377027 -1.07090881 43 44 45 46 47 48 0.87043952 -1.26912807 0.40734807 -0.26951809 -0.26394380 0.68543974 49 50 51 52 53 54 0.35711513 1.87010289 -0.72149916 -0.47554271 -2.60217046 -0.25544405 55 56 0.39528545 0.49412365 > postscript(file="/var/www/html/rcomp/tmp/6avwz1258752759.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.54637398 NA 1 -1.42040794 -0.54637398 2 -0.16710930 -1.42040794 3 -0.36553883 -0.16710930 4 0.10271088 -0.36553883 5 0.36370480 0.10271088 6 -1.68722041 0.36370480 7 0.01041721 -1.68722041 8 0.03814720 0.01041721 9 -0.38124823 0.03814720 10 0.07441800 -0.38124823 11 0.10426778 0.07441800 12 0.49969430 0.10426778 13 -0.19192559 0.49969430 14 1.22398380 -0.19192559 15 -0.05858567 1.22398380 16 0.37524513 -0.05858567 17 0.71864128 0.37524513 18 0.14765952 0.71864128 19 -0.00412343 0.14765952 20 -0.54672556 -0.00412343 21 0.40850887 -0.54672556 22 0.88776044 0.40850887 23 -0.81629899 0.88776044 24 0.08525888 -0.81629899 25 -0.15128687 0.08525888 26 1.16655052 -0.15128687 27 0.08009590 1.16655052 28 3.25798473 0.08009590 29 0.24400678 3.25798473 30 0.27383592 0.24400678 31 0.76871064 0.27383592 32 0.10123029 0.76871064 33 0.24225745 0.10123029 34 -0.69823463 0.24225745 35 0.02659147 -0.69823463 36 -0.39569433 0.02659147 37 -0.10648249 -0.39569433 38 -1.50192587 -0.10648249 39 0.81957132 -1.50192587 40 -1.13377027 0.81957132 41 -1.07090881 -1.13377027 42 0.87043952 -1.07090881 43 -1.26912807 0.87043952 44 0.40734807 -1.26912807 45 -0.26951809 0.40734807 46 -0.26394380 -0.26951809 47 0.68543974 -0.26394380 48 0.35711513 0.68543974 49 1.87010289 0.35711513 50 -0.72149916 1.87010289 51 -0.47554271 -0.72149916 52 -2.60217046 -0.47554271 53 -0.25544405 -2.60217046 54 0.39528545 -0.25544405 55 0.49412365 0.39528545 56 NA 0.49412365 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -1.42040794 -0.54637398 [2,] -0.16710930 -1.42040794 [3,] -0.36553883 -0.16710930 [4,] 0.10271088 -0.36553883 [5,] 0.36370480 0.10271088 [6,] -1.68722041 0.36370480 [7,] 0.01041721 -1.68722041 [8,] 0.03814720 0.01041721 [9,] -0.38124823 0.03814720 [10,] 0.07441800 -0.38124823 [11,] 0.10426778 0.07441800 [12,] 0.49969430 0.10426778 [13,] -0.19192559 0.49969430 [14,] 1.22398380 -0.19192559 [15,] -0.05858567 1.22398380 [16,] 0.37524513 -0.05858567 [17,] 0.71864128 0.37524513 [18,] 0.14765952 0.71864128 [19,] -0.00412343 0.14765952 [20,] -0.54672556 -0.00412343 [21,] 0.40850887 -0.54672556 [22,] 0.88776044 0.40850887 [23,] -0.81629899 0.88776044 [24,] 0.08525888 -0.81629899 [25,] -0.15128687 0.08525888 [26,] 1.16655052 -0.15128687 [27,] 0.08009590 1.16655052 [28,] 3.25798473 0.08009590 [29,] 0.24400678 3.25798473 [30,] 0.27383592 0.24400678 [31,] 0.76871064 0.27383592 [32,] 0.10123029 0.76871064 [33,] 0.24225745 0.10123029 [34,] -0.69823463 0.24225745 [35,] 0.02659147 -0.69823463 [36,] -0.39569433 0.02659147 [37,] -0.10648249 -0.39569433 [38,] -1.50192587 -0.10648249 [39,] 0.81957132 -1.50192587 [40,] -1.13377027 0.81957132 [41,] -1.07090881 -1.13377027 [42,] 0.87043952 -1.07090881 [43,] -1.26912807 0.87043952 [44,] 0.40734807 -1.26912807 [45,] -0.26951809 0.40734807 [46,] -0.26394380 -0.26951809 [47,] 0.68543974 -0.26394380 [48,] 0.35711513 0.68543974 [49,] 1.87010289 0.35711513 [50,] -0.72149916 1.87010289 [51,] -0.47554271 -0.72149916 [52,] -2.60217046 -0.47554271 [53,] -0.25544405 -2.60217046 [54,] 0.39528545 -0.25544405 [55,] 0.49412365 0.39528545 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -1.42040794 -0.54637398 2 -0.16710930 -1.42040794 3 -0.36553883 -0.16710930 4 0.10271088 -0.36553883 5 0.36370480 0.10271088 6 -1.68722041 0.36370480 7 0.01041721 -1.68722041 8 0.03814720 0.01041721 9 -0.38124823 0.03814720 10 0.07441800 -0.38124823 11 0.10426778 0.07441800 12 0.49969430 0.10426778 13 -0.19192559 0.49969430 14 1.22398380 -0.19192559 15 -0.05858567 1.22398380 16 0.37524513 -0.05858567 17 0.71864128 0.37524513 18 0.14765952 0.71864128 19 -0.00412343 0.14765952 20 -0.54672556 -0.00412343 21 0.40850887 -0.54672556 22 0.88776044 0.40850887 23 -0.81629899 0.88776044 24 0.08525888 -0.81629899 25 -0.15128687 0.08525888 26 1.16655052 -0.15128687 27 0.08009590 1.16655052 28 3.25798473 0.08009590 29 0.24400678 3.25798473 30 0.27383592 0.24400678 31 0.76871064 0.27383592 32 0.10123029 0.76871064 33 0.24225745 0.10123029 34 -0.69823463 0.24225745 35 0.02659147 -0.69823463 36 -0.39569433 0.02659147 37 -0.10648249 -0.39569433 38 -1.50192587 -0.10648249 39 0.81957132 -1.50192587 40 -1.13377027 0.81957132 41 -1.07090881 -1.13377027 42 0.87043952 -1.07090881 43 -1.26912807 0.87043952 44 0.40734807 -1.26912807 45 -0.26951809 0.40734807 46 -0.26394380 -0.26951809 47 0.68543974 -0.26394380 48 0.35711513 0.68543974 49 1.87010289 0.35711513 50 -0.72149916 1.87010289 51 -0.47554271 -0.72149916 52 -2.60217046 -0.47554271 53 -0.25544405 -2.60217046 54 0.39528545 -0.25544405 55 0.49412365 0.39528545 > 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/7wo091258752759.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/8aqt31258752759.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/95ts11258752759.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/109p0k1258752759.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/11bn921258752759.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/12z7lx1258752759.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/13nx2o1258752759.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/1485ch1258752759.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/156f8b1258752759.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/164pz31258752759.tab") + } > system("convert tmp/15dc51258752759.ps tmp/15dc51258752759.png") > system("convert tmp/2abtq1258752759.ps tmp/2abtq1258752759.png") > system("convert tmp/3u1fy1258752759.ps tmp/3u1fy1258752759.png") > system("convert tmp/4eqkj1258752759.ps tmp/4eqkj1258752759.png") > system("convert tmp/5ri7q1258752759.ps tmp/5ri7q1258752759.png") > system("convert tmp/6avwz1258752759.ps tmp/6avwz1258752759.png") > system("convert tmp/7wo091258752759.ps tmp/7wo091258752759.png") > system("convert tmp/8aqt31258752759.ps tmp/8aqt31258752759.png") > system("convert tmp/95ts11258752759.ps tmp/95ts11258752759.png") > system("convert tmp/109p0k1258752759.ps tmp/109p0k1258752759.png") > > > proc.time() user system elapsed 2.382 1.589 3.274