R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-pc-linux-gnu (32-bit) 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(104.8 + ,117.6 + ,112.3 + ,103.9 + ,100.4 + ,111.4 + ,118.6 + ,125.7 + ,110.9 + ,108.6 + ,106.9 + ,110.1 + ,117.5 + ,106.6 + ,109.9 + ,103.9 + ,113.1 + ,105.8 + ,103.2 + ,109.5 + ,107.6 + ,91.2 + ,115.1 + ,108.7 + ,109.2 + ,104.7 + ,106.2 + ,119.3 + ,104.6 + ,100.9 + ,109.1 + ,115.5 + ,119.0 + ,108.7 + ,98.4 + ,109.3 + ,106.2 + ,126.8 + ,109.5 + ,94.2 + ,102.2 + ,95.9 + ,116.3 + ,102.6 + ,94.7 + ,109.8 + ,113.2 + ,127.1 + ,109.5 + ,95.2 + ,106.2 + ,78.3 + ,106.5 + ,108.1 + ,100.3 + ,95.1 + ,79.8 + ,95.5 + ,96.1 + ,100.9 + ,118.7 + ,121.2 + ,121.3 + ,118.5 + ,97.9 + ,116.9 + ,125.6 + ,118.3 + ,116.3 + ,106.9 + ,105.3 + ,97.2 + ,95.6 + ,105.9 + ,100.8 + ,119.5 + ,102.8 + ,90.1 + ,120.7 + ,106.6 + ,96.5 + ,88.8 + ,82.6 + ,97.0 + ,108.2 + ,99.3 + ,95.3 + ,86.9 + ,99.6 + ,98.4 + ,113.8 + ,107.6 + ,95.9 + ,114.2 + ,102.0 + ,102.7 + ,95.0 + ,88.8 + ,103.3 + ,95.7 + ,98.8 + ,87.5 + ,93.2 + ,99.6 + ,100.8 + ,109.9 + ,106.7 + ,98.9 + ,110.1 + ,98.8 + ,103.6 + ,75.8 + ,79.6 + ,105.7 + ,99.6 + ,96.6 + ,80.0 + ,80.7 + ,97.8 + ,106.1 + ,111.6 + ,117.2 + ,102.9 + ,111.1 + ,106.3 + ,111.6 + ,106.6 + ,101.7 + ,112.0 + ,105.7 + ,107.0 + ,104.7 + ,95.9 + ,107.2 + ,103.7 + ,111.5 + ,95.2 + ,87.1 + ,112.7 + ,111.2 + ,102.0 + ,94.0 + ,87.5 + ,102.5 + ,114.8 + ,113.5 + ,95.7 + ,93.6 + ,114.9 + ,103.6 + ,125.5 + ,112.6 + ,109.6 + ,126.4 + ,107.0 + ,106.7 + ,99.1 + ,103.2 + ,107.3 + ,104.8 + ,102.9 + ,91.6 + ,98.9 + ,103.8 + ,104.7 + ,123.6 + ,111.5 + ,113.7 + ,124.5 + ,102.0 + ,107.7 + ,76.6 + ,87.9 + ,110.1 + ,103.4 + ,105.5 + ,83.4 + ,89.6 + ,107.1 + ,107.0 + ,117.1 + ,113.5 + ,114.4 + ,117.3 + ,104.0 + ,113.3 + ,106.4 + ,108.8 + ,113.8 + ,105.4 + ,118.0 + ,104.1 + ,104.3 + ,119.0 + ,107.9 + ,118.4 + ,108.4 + ,97.0 + ,119.1 + ,110.1 + ,105.8 + ,91.0 + ,100.4 + ,106.9 + ,111.0 + ,114.6 + ,108.3 + ,105.3 + ,115.0 + ,98.5 + ,140.3 + ,121.0 + ,122.3 + ,141.7 + ,101.9 + ,113.8 + ,95.4 + ,105.6 + ,115.2 + ,103.4 + ,117.4 + ,109.9 + ,116.9 + ,117.9 + ,102.9 + ,115.4 + ,101.4 + ,110.5 + ,116.5 + ,101.0 + ,105.9 + ,86.0 + ,88.6 + ,107.4 + ,103.4 + ,120.4 + ,96.5 + ,94.5 + ,122.2 + ,107.2 + ,126.9 + ,124.6 + ,115.7 + ,126.9 + ,104.5 + ,117.1 + ,109.3 + ,107.8 + ,117.7 + ,104.7 + ,113.8 + ,104.5 + ,106.6 + ,114.4 + ,107.0 + ,112.8 + ,101.8 + ,100.7 + ,113.6 + ,110.3 + ,106.7 + ,101.5 + ,100.4 + ,107.0 + ,107.9 + ,107.3 + ,103.4 + ,101.7 + ,107.5 + ,97.1 + ,121.8 + ,125.9 + ,115.2 + ,121.4 + ,98.6 + ,101.1 + ,96.8 + ,100.9 + ,101.3 + ,95.3 + ,103.1 + ,104.4 + ,105.3 + ,102.9 + ,101.7 + ,110.4 + ,121.1 + ,109.8 + ,109.5 + ,96.3 + ,108.3 + ,83.7 + ,92.1 + ,110.2 + ,99.0 + ,116.3 + ,91.5 + ,92.5 + ,118.2 + ,104.0) + ,dim=c(5 + ,60) + ,dimnames=list(c('consumer_goods' + ,'durable_consumer_goods' + ,'intermediate_and_capital_goods' + ,'non-durable_consumer_goods' + ,'energy') + ,1:60)) > y <- array(NA,dim=c(5,60),dimnames=list(c('consumer_goods','durable_consumer_goods','intermediate_and_capital_goods','non-durable_consumer_goods','energy'),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 = 'No Linear Trend' > par2 = 'Do not include Seasonal Dummies' > par1 = '1' > library(lattice) > library(lmtest) Loading required package: zoo Attaching package: 'zoo' The following object(s) are masked from 'package:base': as.Date, 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 consumer_goods durable_consumer_goods intermediate_and_capital_goods 1 104.8 117.6 112.3 2 111.4 118.6 125.7 3 106.9 110.1 117.5 4 103.9 113.1 105.8 5 107.6 91.2 115.1 6 104.7 106.2 119.3 7 109.1 115.5 119.0 8 109.3 106.2 126.8 9 102.2 95.9 116.3 10 109.8 113.2 127.1 11 106.2 78.3 106.5 12 95.1 79.8 95.5 13 118.7 121.2 121.3 14 116.9 125.6 118.3 15 105.3 97.2 95.6 16 119.5 102.8 90.1 17 96.5 88.8 82.6 18 99.3 95.3 86.9 19 113.8 107.6 95.9 20 102.7 95.0 88.8 21 98.8 87.5 93.2 22 109.9 106.7 98.9 23 103.6 75.8 79.6 24 96.6 80.0 80.7 25 111.6 117.2 102.9 26 111.6 106.6 101.7 27 107.0 104.7 95.9 28 111.5 95.2 87.1 29 102.0 94.0 87.5 30 113.5 95.7 93.6 31 125.5 112.6 109.6 32 106.7 99.1 103.2 33 102.9 91.6 98.9 34 123.6 111.5 113.7 35 107.7 76.6 87.9 36 105.5 83.4 89.6 37 117.1 113.5 114.4 38 113.3 106.4 108.8 39 118.0 104.1 104.3 40 118.4 108.4 97.0 41 105.8 91.0 100.4 42 114.6 108.3 105.3 43 140.3 121.0 122.3 44 113.8 95.4 105.6 45 117.4 109.9 116.9 46 115.4 101.4 110.5 47 105.9 86.0 88.6 48 120.4 96.5 94.5 49 126.9 124.6 115.7 50 117.1 109.3 107.8 51 113.8 104.5 106.6 52 112.8 101.8 100.7 53 106.7 101.5 100.4 54 107.3 103.4 101.7 55 121.8 125.9 115.2 56 101.1 96.8 100.9 57 103.1 104.4 105.3 58 110.4 121.1 109.8 59 108.3 83.7 92.1 60 116.3 91.5 92.5 non-durable_consumer_goods energy 1 103.9 100.4 2 110.9 108.6 3 106.6 109.9 4 103.2 109.5 5 108.7 109.2 6 104.6 100.9 7 108.7 98.4 8 109.5 94.2 9 102.6 94.7 10 109.5 95.2 11 108.1 100.3 12 96.1 100.9 13 118.5 97.9 14 116.3 106.9 15 105.9 100.8 16 120.7 106.6 17 97.0 108.2 18 99.6 98.4 19 114.2 102.0 20 103.3 95.7 21 99.6 100.8 22 110.1 98.8 23 105.7 99.6 24 97.8 106.1 25 111.1 106.3 26 112.0 105.7 27 107.2 103.7 28 112.7 111.2 29 102.5 114.8 30 114.9 103.6 31 126.4 107.0 32 107.3 104.8 33 103.8 104.7 34 124.5 102.0 35 110.1 103.4 36 107.1 107.0 37 117.3 104.0 38 113.8 105.4 39 119.0 107.9 40 119.1 110.1 41 106.9 111.0 42 115.0 98.5 43 141.7 101.9 44 115.2 103.4 45 117.9 102.9 46 116.5 101.0 47 107.4 103.4 48 122.2 107.2 49 126.9 104.5 50 117.7 104.7 51 114.4 107.0 52 113.6 110.3 53 107.0 107.9 54 107.5 97.1 55 121.4 98.6 56 101.3 95.3 57 102.9 101.7 58 109.5 96.3 59 110.2 99.0 60 118.2 104.0 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) durable_consumer_goods -0.0429447 0.0694911 intermediate_and_capital_goods `non-durable_consumer_goods` 0.0007872 0.9298108 energy 0.0006376 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -0.11013 -0.04453 -0.00012 0.04136 0.14145 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -0.0429447 0.2069829 -0.207 0.836 durable_consumer_goods 0.0694911 0.0009555 72.727 <2e-16 *** intermediate_and_capital_goods 0.0007872 0.0009668 0.814 0.419 `non-durable_consumer_goods` 0.9298108 0.0011181 831.564 <2e-16 *** energy 0.0006376 0.0017294 0.369 0.714 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.05972 on 55 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 0.9999 F-statistic: 2.809e+05 on 4 and 55 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.25929111 0.51858222 0.74070889 [2,] 0.13027166 0.26054332 0.86972834 [3,] 0.24575105 0.49150210 0.75424895 [4,] 0.22512386 0.45024771 0.77487614 [5,] 0.19854633 0.39709265 0.80145367 [6,] 0.16938613 0.33877226 0.83061387 [7,] 0.21071906 0.42143812 0.78928094 [8,] 0.24504769 0.49009538 0.75495231 [9,] 0.17474774 0.34949548 0.82525226 [10,] 0.12573230 0.25146460 0.87426770 [11,] 0.09344932 0.18689863 0.90655068 [12,] 0.11133258 0.22266515 0.88866742 [13,] 0.13081557 0.26163115 0.86918443 [14,] 0.10630372 0.21260745 0.89369628 [15,] 0.09609544 0.19219088 0.90390456 [16,] 0.44723812 0.89447624 0.55276188 [17,] 0.42354362 0.84708724 0.57645638 [18,] 0.56046272 0.87907456 0.43953728 [19,] 0.63043154 0.73913692 0.36956846 [20,] 0.72681906 0.54636189 0.27318094 [21,] 0.68227448 0.63545105 0.31772552 [22,] 0.65879433 0.68241133 0.34120567 [23,] 0.82707507 0.34584987 0.17292493 [24,] 0.79414536 0.41170929 0.20585464 [25,] 0.85270297 0.29459406 0.14729703 [26,] 0.93707281 0.12585437 0.06292719 [27,] 0.91508990 0.16982020 0.08491010 [28,] 0.95004513 0.09990973 0.04995487 [29,] 0.96389686 0.07220628 0.03610314 [30,] 0.94974680 0.10050640 0.05025320 [31,] 0.93853735 0.12292530 0.06146265 [32,] 0.90735698 0.18528605 0.09264302 [33,] 0.86965024 0.26069953 0.13034976 [34,] 0.82899650 0.34200700 0.17100350 [35,] 0.78822325 0.42355351 0.21177675 [36,] 0.76467125 0.47065750 0.23532875 [37,] 0.70725780 0.58548440 0.29274220 [38,] 0.63055278 0.73889444 0.36944722 [39,] 0.72793711 0.54412578 0.27206289 [40,] 0.63982023 0.72035954 0.36017977 [41,] 0.56826399 0.86347203 0.43173601 [42,] 0.86813399 0.26373203 0.13186601 [43,] 0.93553499 0.12893001 0.06446501 [44,] 0.89497908 0.21004183 0.10502092 [45,] 0.78561580 0.42876839 0.21438420 > postscript(file="/var/fisher/rcomp/tmp/1o9cv1353444508.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(x[,1], type='l', main='Actuals and Interpolation', ylab='value of Actuals and Interpolation (dots)', xlab='time or index') > points(x[,1]-mysum$resid) > grid() > dev.off() null device 1 > postscript(file="/var/fisher/rcomp/tmp/20kk01353444508.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(mysum$resid, type='b', pch=19, main='Residuals', ylab='value of Residuals', xlab='time or index') > grid() > dev.off() null device 1 > postscript(file="/var/fisher/rcomp/tmp/3806g1353444508.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > hist(mysum$resid, main='Residual Histogram', xlab='values of Residuals') > grid() > dev.off() null device 1 > postscript(file="/var/fisher/rcomp/tmp/48ynt1353444508.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > densityplot(~mysum$resid,col='black',main='Residual Density Plot', xlab='values of Residuals') > dev.off() null device 1 > postscript(file="/var/fisher/rcomp/tmp/5mybp1353444508.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(mysum$resid, main='Residual Normal Q-Q Plot') > qqline(mysum$resid) > grid() > dev.off() null device 1 > (myerror <- as.ts(mysum$resid)) Time Series: Start = 1 End = 60 Frequency = 1 1 2 3 4 5 6 -0.088971472 -0.082915104 0.011571908 -0.026079470 0.074687009 -0.053469504 7 8 9 10 11 12 -0.110130888 -0.011174269 0.028225456 0.001514122 0.141453696 0.103223066 13 14 15 16 17 18 -0.019867688 -0.083421902 -0.018083017 0.032198513 0.046473542 -0.019863002 19 20 21 22 23 24 0.040778545 -0.039089661 0.015678044 0.015223558 -0.031650562 0.016981447 25 26 27 28 29 30 0.047825043 -0.051071597 -0.050105692 -0.001754194 0.063094807 -0.082354338 31 32 33 34 35 36 0.035658609 -0.060384472 -0.081414617 -0.021300075 -0.087367654 0.025891402 37 38 39 40 41 42 0.032529038 -0.016230629 0.010531214 0.023082127 -0.027331216 0.043118127 43 44 45 46 47 48 0.019082658 -0.049769135 0.023543975 -0.077796848 -0.030646087 -0.028569883 49 50 51 52 53 54 0.133651936 -0.042783386 0.058627669 -0.007357359 0.052007608 0.060932081 55 56 57 58 59 60 0.061428381 0.086177802 0.062803565 0.065451496 -0.074236366 -0.058256357 > postscript(file="/var/fisher/rcomp/tmp/6p7wz1353444508.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > dum <- cbind(lag(myerror,k=1),myerror) > dum Time Series: Start = 0 End = 60 Frequency = 1 lag(myerror, k = 1) myerror 0 -0.088971472 NA 1 -0.082915104 -0.088971472 2 0.011571908 -0.082915104 3 -0.026079470 0.011571908 4 0.074687009 -0.026079470 5 -0.053469504 0.074687009 6 -0.110130888 -0.053469504 7 -0.011174269 -0.110130888 8 0.028225456 -0.011174269 9 0.001514122 0.028225456 10 0.141453696 0.001514122 11 0.103223066 0.141453696 12 -0.019867688 0.103223066 13 -0.083421902 -0.019867688 14 -0.018083017 -0.083421902 15 0.032198513 -0.018083017 16 0.046473542 0.032198513 17 -0.019863002 0.046473542 18 0.040778545 -0.019863002 19 -0.039089661 0.040778545 20 0.015678044 -0.039089661 21 0.015223558 0.015678044 22 -0.031650562 0.015223558 23 0.016981447 -0.031650562 24 0.047825043 0.016981447 25 -0.051071597 0.047825043 26 -0.050105692 -0.051071597 27 -0.001754194 -0.050105692 28 0.063094807 -0.001754194 29 -0.082354338 0.063094807 30 0.035658609 -0.082354338 31 -0.060384472 0.035658609 32 -0.081414617 -0.060384472 33 -0.021300075 -0.081414617 34 -0.087367654 -0.021300075 35 0.025891402 -0.087367654 36 0.032529038 0.025891402 37 -0.016230629 0.032529038 38 0.010531214 -0.016230629 39 0.023082127 0.010531214 40 -0.027331216 0.023082127 41 0.043118127 -0.027331216 42 0.019082658 0.043118127 43 -0.049769135 0.019082658 44 0.023543975 -0.049769135 45 -0.077796848 0.023543975 46 -0.030646087 -0.077796848 47 -0.028569883 -0.030646087 48 0.133651936 -0.028569883 49 -0.042783386 0.133651936 50 0.058627669 -0.042783386 51 -0.007357359 0.058627669 52 0.052007608 -0.007357359 53 0.060932081 0.052007608 54 0.061428381 0.060932081 55 0.086177802 0.061428381 56 0.062803565 0.086177802 57 0.065451496 0.062803565 58 -0.074236366 0.065451496 59 -0.058256357 -0.074236366 60 NA -0.058256357 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -0.082915104 -0.088971472 [2,] 0.011571908 -0.082915104 [3,] -0.026079470 0.011571908 [4,] 0.074687009 -0.026079470 [5,] -0.053469504 0.074687009 [6,] -0.110130888 -0.053469504 [7,] -0.011174269 -0.110130888 [8,] 0.028225456 -0.011174269 [9,] 0.001514122 0.028225456 [10,] 0.141453696 0.001514122 [11,] 0.103223066 0.141453696 [12,] -0.019867688 0.103223066 [13,] -0.083421902 -0.019867688 [14,] -0.018083017 -0.083421902 [15,] 0.032198513 -0.018083017 [16,] 0.046473542 0.032198513 [17,] -0.019863002 0.046473542 [18,] 0.040778545 -0.019863002 [19,] -0.039089661 0.040778545 [20,] 0.015678044 -0.039089661 [21,] 0.015223558 0.015678044 [22,] -0.031650562 0.015223558 [23,] 0.016981447 -0.031650562 [24,] 0.047825043 0.016981447 [25,] -0.051071597 0.047825043 [26,] -0.050105692 -0.051071597 [27,] -0.001754194 -0.050105692 [28,] 0.063094807 -0.001754194 [29,] -0.082354338 0.063094807 [30,] 0.035658609 -0.082354338 [31,] -0.060384472 0.035658609 [32,] -0.081414617 -0.060384472 [33,] -0.021300075 -0.081414617 [34,] -0.087367654 -0.021300075 [35,] 0.025891402 -0.087367654 [36,] 0.032529038 0.025891402 [37,] -0.016230629 0.032529038 [38,] 0.010531214 -0.016230629 [39,] 0.023082127 0.010531214 [40,] -0.027331216 0.023082127 [41,] 0.043118127 -0.027331216 [42,] 0.019082658 0.043118127 [43,] -0.049769135 0.019082658 [44,] 0.023543975 -0.049769135 [45,] -0.077796848 0.023543975 [46,] -0.030646087 -0.077796848 [47,] -0.028569883 -0.030646087 [48,] 0.133651936 -0.028569883 [49,] -0.042783386 0.133651936 [50,] 0.058627669 -0.042783386 [51,] -0.007357359 0.058627669 [52,] 0.052007608 -0.007357359 [53,] 0.060932081 0.052007608 [54,] 0.061428381 0.060932081 [55,] 0.086177802 0.061428381 [56,] 0.062803565 0.086177802 [57,] 0.065451496 0.062803565 [58,] -0.074236366 0.065451496 [59,] -0.058256357 -0.074236366 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -0.082915104 -0.088971472 2 0.011571908 -0.082915104 3 -0.026079470 0.011571908 4 0.074687009 -0.026079470 5 -0.053469504 0.074687009 6 -0.110130888 -0.053469504 7 -0.011174269 -0.110130888 8 0.028225456 -0.011174269 9 0.001514122 0.028225456 10 0.141453696 0.001514122 11 0.103223066 0.141453696 12 -0.019867688 0.103223066 13 -0.083421902 -0.019867688 14 -0.018083017 -0.083421902 15 0.032198513 -0.018083017 16 0.046473542 0.032198513 17 -0.019863002 0.046473542 18 0.040778545 -0.019863002 19 -0.039089661 0.040778545 20 0.015678044 -0.039089661 21 0.015223558 0.015678044 22 -0.031650562 0.015223558 23 0.016981447 -0.031650562 24 0.047825043 0.016981447 25 -0.051071597 0.047825043 26 -0.050105692 -0.051071597 27 -0.001754194 -0.050105692 28 0.063094807 -0.001754194 29 -0.082354338 0.063094807 30 0.035658609 -0.082354338 31 -0.060384472 0.035658609 32 -0.081414617 -0.060384472 33 -0.021300075 -0.081414617 34 -0.087367654 -0.021300075 35 0.025891402 -0.087367654 36 0.032529038 0.025891402 37 -0.016230629 0.032529038 38 0.010531214 -0.016230629 39 0.023082127 0.010531214 40 -0.027331216 0.023082127 41 0.043118127 -0.027331216 42 0.019082658 0.043118127 43 -0.049769135 0.019082658 44 0.023543975 -0.049769135 45 -0.077796848 0.023543975 46 -0.030646087 -0.077796848 47 -0.028569883 -0.030646087 48 0.133651936 -0.028569883 49 -0.042783386 0.133651936 50 0.058627669 -0.042783386 51 -0.007357359 0.058627669 52 0.052007608 -0.007357359 53 0.060932081 0.052007608 54 0.061428381 0.060932081 55 0.086177802 0.061428381 56 0.062803565 0.086177802 57 0.065451496 0.062803565 58 -0.074236366 0.065451496 59 -0.058256357 -0.074236366 > 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/fisher/rcomp/tmp/78tnz1353444508.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > acf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Autocorrelation Function') > grid() > dev.off() null device 1 > postscript(file="/var/fisher/rcomp/tmp/8oxeo1353444508.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > pacf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Partial Autocorrelation Function') > grid() > dev.off() null device 1 > postscript(file="/var/fisher/rcomp/tmp/9aq3o1353444508.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0)) > plot(mylm, las = 1, sub='Residual Diagnostics') > par(opar) > dev.off() null device 1 > if (n > n25) { + postscript(file="/var/fisher/rcomp/tmp/10c29k1353444508.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) + plot(kp3:nmkm3,gqarr[,2], main='Goldfeld-Quandt test',ylab='2-sided p-value',xlab='breakpoint') + grid() + dev.off() + } null device 1 > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/118ose1353444508.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/fisher/rcomp/tmp/12387o1353444508.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/fisher/rcomp/tmp/13y6861353444508.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/fisher/rcomp/tmp/1402eu1353444508.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/fisher/rcomp/tmp/15h1mk1353444508.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/fisher/rcomp/tmp/16x5fb1353444509.tab") + } > > try(system("convert tmp/1o9cv1353444508.ps tmp/1o9cv1353444508.png",intern=TRUE)) character(0) > try(system("convert tmp/20kk01353444508.ps tmp/20kk01353444508.png",intern=TRUE)) character(0) > try(system("convert tmp/3806g1353444508.ps tmp/3806g1353444508.png",intern=TRUE)) character(0) > try(system("convert tmp/48ynt1353444508.ps tmp/48ynt1353444508.png",intern=TRUE)) character(0) > try(system("convert tmp/5mybp1353444508.ps tmp/5mybp1353444508.png",intern=TRUE)) character(0) > try(system("convert tmp/6p7wz1353444508.ps tmp/6p7wz1353444508.png",intern=TRUE)) character(0) > try(system("convert tmp/78tnz1353444508.ps tmp/78tnz1353444508.png",intern=TRUE)) character(0) > try(system("convert tmp/8oxeo1353444508.ps tmp/8oxeo1353444508.png",intern=TRUE)) character(0) > try(system("convert tmp/9aq3o1353444508.ps tmp/9aq3o1353444508.png",intern=TRUE)) character(0) > try(system("convert tmp/10c29k1353444508.ps tmp/10c29k1353444508.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 5.930 1.313 7.243