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 + ,93.7 + ,95.7 + ,107.2 + ,98.6 + ,99.9 + ,106.2 + ,106.7 + ,93.7 + ,95.7 + ,107.2 + ,98.6 + ,81 + ,86.7 + ,106.7 + ,93.7 + ,95.7 + ,107.2 + ,94.7 + ,95.3 + ,86.7 + ,106.7 + ,93.7 + ,95.7 + ,101 + ,99.3 + ,95.3 + ,86.7 + ,106.7 + ,93.7 + ,109.4 + ,101.8 + ,99.3 + ,95.3 + ,86.7 + ,106.7 + ,102.3 + ,96 + ,101.8 + ,99.3 + ,95.3 + ,86.7 + ,90.7 + ,91.7 + ,96 + ,101.8 + ,99.3 + ,95.3 + ,96.2 + ,95.3 + ,91.7 + ,96 + ,101.8 + ,99.3 + ,96.1 + ,96.6 + ,95.3 + ,91.7 + ,96 + ,101.8 + ,106 + ,107.2 + ,96.6 + ,95.3 + ,91.7 + ,96 + ,103.1 + ,108 + ,107.2 + ,96.6 + ,95.3 + ,91.7 + ,102 + ,98.4 + ,108 + ,107.2 + ,96.6 + ,95.3 + ,104.7 + ,103.1 + ,98.4 + ,108 + ,107.2 + ,96.6 + ,86 + ,81.1 + ,103.1 + ,98.4 + ,108 + ,107.2 + ,92.1 + ,96.6 + ,81.1 + ,103.1 + ,98.4 + ,108 + ,106.9 + ,103.7 + ,96.6 + ,81.1 + ,103.1 + ,98.4 + ,112.6 + ,106.6 + ,103.7 + ,96.6 + ,81.1 + ,103.1 + ,101.7 + ,97.6 + ,106.6 + ,103.7 + ,96.6 + ,81.1 + ,92 + ,87.6 + ,97.6 + ,106.6 + ,103.7 + ,96.6 + ,97.4 + ,99.4 + ,87.6 + ,97.6 + ,106.6 + ,103.7 + ,97 + ,98.5 + ,99.4 + ,87.6 + ,97.6 + ,106.6 + ,105.4 + ,105.2 + ,98.5 + ,99.4 + ,87.6 + ,97.6 + ,102.7 + ,104.6 + ,105.2 + ,98.5 + ,99.4 + ,87.6 + ,98.1 + ,97.5 + ,104.6 + ,105.2 + ,98.5 + ,99.4 + ,104.5 + ,108.9 + ,97.5 + ,104.6 + ,105.2 + ,98.5 + ,87.4 + ,86.8 + ,108.9 + ,97.5 + ,104.6 + ,105.2 + ,89.9 + ,88.9 + ,86.8 + ,108.9 + ,97.5 + ,104.6 + ,109.8 + ,110.3 + ,88.9 + ,86.8 + ,108.9 + ,97.5 + ,111.7 + ,114.8 + ,110.3 + ,88.9 + ,86.8 + ,108.9 + ,98.6 + ,94.6 + ,114.8 + ,110.3 + ,88.9 + ,86.8 + ,96.9 + ,92 + ,94.6 + ,114.8 + ,110.3 + ,88.9 + ,95.1 + ,93.8 + ,92 + ,94.6 + ,114.8 + ,110.3 + ,97 + ,93.8 + ,93.8 + ,92 + ,94.6 + ,114.8 + ,112.7 + ,107.6 + ,93.8 + ,93.8 + ,92 + ,94.6 + ,102.9 + ,101 + ,107.6 + ,93.8 + ,93.8 + ,92 + ,97.4 + ,95.4 + ,101 + ,107.6 + ,93.8 + ,93.8 + ,111.4 + ,96.5 + ,95.4 + ,101 + ,107.6 + ,93.8 + ,87.4 + ,89.2 + ,96.5 + ,95.4 + ,101 + ,107.6 + ,96.8 + ,87.1 + ,89.2 + ,96.5 + ,95.4 + ,101 + ,114.1 + ,110.5 + ,87.1 + ,89.2 + ,96.5 + ,95.4 + ,110.3 + ,110.8 + ,110.5 + ,87.1 + ,89.2 + ,96.5 + ,103.9 + ,104.2 + ,110.8 + ,110.5 + ,87.1 + ,89.2 + ,101.6 + ,88.9 + ,104.2 + ,110.8 + ,110.5 + ,87.1 + ,94.6 + ,89.8 + ,88.9 + ,104.2 + ,110.8 + ,110.5 + ,95.9 + ,90 + ,89.8 + ,88.9 + ,104.2 + ,110.8 + ,104.7 + ,93.9 + ,90 + ,89.8 + ,88.9 + ,104.2 + ,102.8 + ,91.3 + ,93.9 + ,90 + ,89.8 + ,88.9 + ,98.1 + ,87.8 + ,91.3 + ,93.9 + ,90 + ,89.8 + ,113.9 + ,99.7 + ,87.8 + ,91.3 + ,93.9 + ,90 + ,80.9 + ,73.5 + ,99.7 + ,87.8 + ,91.3 + ,93.9 + ,95.7 + ,79.2 + ,73.5 + ,99.7 + ,87.8 + ,91.3 + ,113.2 + ,96.9 + ,79.2 + ,73.5 + ,99.7 + ,87.8 + ,105.9 + ,95.2 + ,96.9 + ,79.2 + ,73.5 + ,99.7 + ,108.8 + ,95.6 + ,95.2 + ,96.9 + ,79.2 + ,73.5 + ,102.3 + ,89.7 + ,95.6 + ,95.2 + ,96.9 + ,79.2) + ,dim=c(6 + ,56) + ,dimnames=list(c('ProdMetal' + ,'ProdInd' + ,'(t-1)' + ,'(t-2)' + ,'(t-3)' + ,'(t-4)') + ,1:56)) > y <- array(NA,dim=c(6,56),dimnames=list(c('ProdMetal','ProdInd','(t-1)','(t-2)','(t-3)','(t-4)'),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 = '2' > #'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 ProdInd ProdMetal (t-1) (t-2) (t-3) (t-4) M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 1 93.7 101.9 95.7 107.2 98.6 99.9 1 0 0 0 0 0 0 0 0 0 0 2 106.7 106.2 93.7 95.7 107.2 98.6 0 1 0 0 0 0 0 0 0 0 0 3 86.7 81.0 106.7 93.7 95.7 107.2 0 0 1 0 0 0 0 0 0 0 0 4 95.3 94.7 86.7 106.7 93.7 95.7 0 0 0 1 0 0 0 0 0 0 0 5 99.3 101.0 95.3 86.7 106.7 93.7 0 0 0 0 1 0 0 0 0 0 0 6 101.8 109.4 99.3 95.3 86.7 106.7 0 0 0 0 0 1 0 0 0 0 0 7 96.0 102.3 101.8 99.3 95.3 86.7 0 0 0 0 0 0 1 0 0 0 0 8 91.7 90.7 96.0 101.8 99.3 95.3 0 0 0 0 0 0 0 1 0 0 0 9 95.3 96.2 91.7 96.0 101.8 99.3 0 0 0 0 0 0 0 0 1 0 0 10 96.6 96.1 95.3 91.7 96.0 101.8 0 0 0 0 0 0 0 0 0 1 0 11 107.2 106.0 96.6 95.3 91.7 96.0 0 0 0 0 0 0 0 0 0 0 1 12 108.0 103.1 107.2 96.6 95.3 91.7 0 0 0 0 0 0 0 0 0 0 0 13 98.4 102.0 108.0 107.2 96.6 95.3 1 0 0 0 0 0 0 0 0 0 0 14 103.1 104.7 98.4 108.0 107.2 96.6 0 1 0 0 0 0 0 0 0 0 0 15 81.1 86.0 103.1 98.4 108.0 107.2 0 0 1 0 0 0 0 0 0 0 0 16 96.6 92.1 81.1 103.1 98.4 108.0 0 0 0 1 0 0 0 0 0 0 0 17 103.7 106.9 96.6 81.1 103.1 98.4 0 0 0 0 1 0 0 0 0 0 0 18 106.6 112.6 103.7 96.6 81.1 103.1 0 0 0 0 0 1 0 0 0 0 0 19 97.6 101.7 106.6 103.7 96.6 81.1 0 0 0 0 0 0 1 0 0 0 0 20 87.6 92.0 97.6 106.6 103.7 96.6 0 0 0 0 0 0 0 1 0 0 0 21 99.4 97.4 87.6 97.6 106.6 103.7 0 0 0 0 0 0 0 0 1 0 0 22 98.5 97.0 99.4 87.6 97.6 106.6 0 0 0 0 0 0 0 0 0 1 0 23 105.2 105.4 98.5 99.4 87.6 97.6 0 0 0 0 0 0 0 0 0 0 1 24 104.6 102.7 105.2 98.5 99.4 87.6 0 0 0 0 0 0 0 0 0 0 0 25 97.5 98.1 104.6 105.2 98.5 99.4 1 0 0 0 0 0 0 0 0 0 0 26 108.9 104.5 97.5 104.6 105.2 98.5 0 1 0 0 0 0 0 0 0 0 0 27 86.8 87.4 108.9 97.5 104.6 105.2 0 0 1 0 0 0 0 0 0 0 0 28 88.9 89.9 86.8 108.9 97.5 104.6 0 0 0 1 0 0 0 0 0 0 0 29 110.3 109.8 88.9 86.8 108.9 97.5 0 0 0 0 1 0 0 0 0 0 0 30 114.8 111.7 110.3 88.9 86.8 108.9 0 0 0 0 0 1 0 0 0 0 0 31 94.6 98.6 114.8 110.3 88.9 86.8 0 0 0 0 0 0 1 0 0 0 0 32 92.0 96.9 94.6 114.8 110.3 88.9 0 0 0 0 0 0 0 1 0 0 0 33 93.8 95.1 92.0 94.6 114.8 110.3 0 0 0 0 0 0 0 0 1 0 0 34 93.8 97.0 93.8 92.0 94.6 114.8 0 0 0 0 0 0 0 0 0 1 0 35 107.6 112.7 93.8 93.8 92.0 94.6 0 0 0 0 0 0 0 0 0 0 1 36 101.0 102.9 107.6 93.8 93.8 92.0 0 0 0 0 0 0 0 0 0 0 0 37 95.4 97.4 101.0 107.6 93.8 93.8 1 0 0 0 0 0 0 0 0 0 0 38 96.5 111.4 95.4 101.0 107.6 93.8 0 1 0 0 0 0 0 0 0 0 0 39 89.2 87.4 96.5 95.4 101.0 107.6 0 0 1 0 0 0 0 0 0 0 0 40 87.1 96.8 89.2 96.5 95.4 101.0 0 0 0 1 0 0 0 0 0 0 0 41 110.5 114.1 87.1 89.2 96.5 95.4 0 0 0 0 1 0 0 0 0 0 0 42 110.8 110.3 110.5 87.1 89.2 96.5 0 0 0 0 0 1 0 0 0 0 0 43 104.2 103.9 110.8 110.5 87.1 89.2 0 0 0 0 0 0 1 0 0 0 0 44 88.9 101.6 104.2 110.8 110.5 87.1 0 0 0 0 0 0 0 1 0 0 0 45 89.8 94.6 88.9 104.2 110.8 110.5 0 0 0 0 0 0 0 0 1 0 0 46 90.0 95.9 89.8 88.9 104.2 110.8 0 0 0 0 0 0 0 0 0 1 0 47 93.9 104.7 90.0 89.8 88.9 104.2 0 0 0 0 0 0 0 0 0 0 1 48 91.3 102.8 93.9 90.0 89.8 88.9 0 0 0 0 0 0 0 0 0 0 0 49 87.8 98.1 91.3 93.9 90.0 89.8 1 0 0 0 0 0 0 0 0 0 0 50 99.7 113.9 87.8 91.3 93.9 90.0 0 1 0 0 0 0 0 0 0 0 0 51 73.5 80.9 99.7 87.8 91.3 93.9 0 0 1 0 0 0 0 0 0 0 0 52 79.2 95.7 73.5 99.7 87.8 91.3 0 0 0 1 0 0 0 0 0 0 0 53 96.9 113.2 79.2 73.5 99.7 87.8 0 0 0 0 1 0 0 0 0 0 0 54 95.2 105.9 96.9 79.2 73.5 99.7 0 0 0 0 0 1 0 0 0 0 0 55 95.6 108.8 95.2 96.9 79.2 73.5 0 0 0 0 0 0 1 0 0 0 0 56 89.7 102.3 95.6 95.2 96.9 79.2 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) ProdMetal `(t-1)` `(t-2)` `(t-3)` `(t-4)` -28.76360 0.73853 0.37677 0.10826 -0.09453 0.19197 M1 M2 M3 M4 M5 M6 -5.51809 0.03005 -6.57335 -0.65805 4.71602 -3.84132 M7 M8 M9 M10 M11 t -4.77496 -4.41089 1.15568 -1.37957 0.27650 -0.11921 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -7.22299 -2.57129 -0.08453 2.62046 6.84316 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -28.76360 29.72241 -0.968 0.33929 ProdMetal 0.73853 0.20924 3.530 0.00111 ** `(t-1)` 0.37677 0.13769 2.736 0.00940 ** `(t-2)` 0.10826 0.14537 0.745 0.46101 `(t-3)` -0.09453 0.15078 -0.627 0.53448 `(t-4)` 0.19197 0.15111 1.270 0.21167 M1 -5.51809 3.27276 -1.686 0.09998 . M2 0.03005 3.65169 0.008 0.99348 M3 -6.57335 4.72343 -1.392 0.17212 M4 -0.65805 4.83473 -0.136 0.89245 M5 4.71602 4.23495 1.114 0.27245 M6 -3.84132 4.74035 -0.810 0.42279 M7 -4.77496 3.44569 -1.386 0.17389 M8 -4.41089 4.09229 -1.078 0.28789 M9 1.15568 4.65935 0.248 0.80544 M10 -1.37957 4.25807 -0.324 0.74772 M11 0.27650 3.70153 0.075 0.94085 t -0.11921 0.04309 -2.766 0.00871 ** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 4.188 on 38 degrees of freedom Multiple R-squared: 0.831, Adjusted R-squared: 0.7555 F-statistic: 11 on 17 and 38 DF, p-value: 7.009e-10 > 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.13997747 0.27995494 0.8600225 [2,] 0.05363118 0.10726237 0.9463688 [3,] 0.05602409 0.11204819 0.9439759 [4,] 0.07085304 0.14170608 0.9291470 [5,] 0.03661950 0.07323899 0.9633805 [6,] 0.05958453 0.11916907 0.9404155 [7,] 0.05829040 0.11658080 0.9417096 [8,] 0.16067527 0.32135054 0.8393247 [9,] 0.24548872 0.49097745 0.7545113 [10,] 0.29287557 0.58575115 0.7071244 [11,] 0.22475187 0.44950374 0.7752481 [12,] 0.31000446 0.62000891 0.6899955 [13,] 0.44580941 0.89161882 0.5541906 [14,] 0.36851848 0.73703695 0.6314815 [15,] 0.32059161 0.64118322 0.6794084 > postscript(file="/var/www/html/rcomp/tmp/1bzbn1259092686.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/2cfs91259092686.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/30pac1259092686.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/4j1s71259092686.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/5l2wn1259092686.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 -4.67561750 2.78080901 0.69499890 1.52755096 -3.84223829 -5.69361280 7 8 9 10 11 12 -1.91982066 2.74405306 -1.44877970 0.66052280 2.23961638 2.60836086 13 14 15 16 17 18 -2.55916606 -0.99935939 -5.15694183 6.76094619 -3.49512636 -3.46315290 19 20 21 22 23 24 0.46690723 -1.84164641 4.17609182 1.45528961 0.25882535 2.65677367 25 26 27 28 29 30 1.74169782 6.53226884 -1.08561610 -0.09162304 5.39869305 4.60438396 31 32 33 34 35 36 -4.43921406 2.71466214 -0.11963527 -2.03836988 2.06697099 -1.42981929 37 38 39 40 41 42 3.31649865 -7.22299484 6.84316380 -4.62615916 3.50290793 5.79567356 43 44 45 46 47 48 3.53163798 -5.24537370 -2.60767684 -0.07744253 -4.56541272 -3.83531523 49 50 51 52 53 54 2.17658709 -1.09072363 -1.29560476 -3.57071495 -1.56423633 -1.24329182 55 56 2.36048952 1.62830491 > postscript(file="/var/www/html/rcomp/tmp/60e8b1259092686.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 -4.67561750 NA 1 2.78080901 -4.67561750 2 0.69499890 2.78080901 3 1.52755096 0.69499890 4 -3.84223829 1.52755096 5 -5.69361280 -3.84223829 6 -1.91982066 -5.69361280 7 2.74405306 -1.91982066 8 -1.44877970 2.74405306 9 0.66052280 -1.44877970 10 2.23961638 0.66052280 11 2.60836086 2.23961638 12 -2.55916606 2.60836086 13 -0.99935939 -2.55916606 14 -5.15694183 -0.99935939 15 6.76094619 -5.15694183 16 -3.49512636 6.76094619 17 -3.46315290 -3.49512636 18 0.46690723 -3.46315290 19 -1.84164641 0.46690723 20 4.17609182 -1.84164641 21 1.45528961 4.17609182 22 0.25882535 1.45528961 23 2.65677367 0.25882535 24 1.74169782 2.65677367 25 6.53226884 1.74169782 26 -1.08561610 6.53226884 27 -0.09162304 -1.08561610 28 5.39869305 -0.09162304 29 4.60438396 5.39869305 30 -4.43921406 4.60438396 31 2.71466214 -4.43921406 32 -0.11963527 2.71466214 33 -2.03836988 -0.11963527 34 2.06697099 -2.03836988 35 -1.42981929 2.06697099 36 3.31649865 -1.42981929 37 -7.22299484 3.31649865 38 6.84316380 -7.22299484 39 -4.62615916 6.84316380 40 3.50290793 -4.62615916 41 5.79567356 3.50290793 42 3.53163798 5.79567356 43 -5.24537370 3.53163798 44 -2.60767684 -5.24537370 45 -0.07744253 -2.60767684 46 -4.56541272 -0.07744253 47 -3.83531523 -4.56541272 48 2.17658709 -3.83531523 49 -1.09072363 2.17658709 50 -1.29560476 -1.09072363 51 -3.57071495 -1.29560476 52 -1.56423633 -3.57071495 53 -1.24329182 -1.56423633 54 2.36048952 -1.24329182 55 1.62830491 2.36048952 56 NA 1.62830491 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 2.78080901 -4.67561750 [2,] 0.69499890 2.78080901 [3,] 1.52755096 0.69499890 [4,] -3.84223829 1.52755096 [5,] -5.69361280 -3.84223829 [6,] -1.91982066 -5.69361280 [7,] 2.74405306 -1.91982066 [8,] -1.44877970 2.74405306 [9,] 0.66052280 -1.44877970 [10,] 2.23961638 0.66052280 [11,] 2.60836086 2.23961638 [12,] -2.55916606 2.60836086 [13,] -0.99935939 -2.55916606 [14,] -5.15694183 -0.99935939 [15,] 6.76094619 -5.15694183 [16,] -3.49512636 6.76094619 [17,] -3.46315290 -3.49512636 [18,] 0.46690723 -3.46315290 [19,] -1.84164641 0.46690723 [20,] 4.17609182 -1.84164641 [21,] 1.45528961 4.17609182 [22,] 0.25882535 1.45528961 [23,] 2.65677367 0.25882535 [24,] 1.74169782 2.65677367 [25,] 6.53226884 1.74169782 [26,] -1.08561610 6.53226884 [27,] -0.09162304 -1.08561610 [28,] 5.39869305 -0.09162304 [29,] 4.60438396 5.39869305 [30,] -4.43921406 4.60438396 [31,] 2.71466214 -4.43921406 [32,] -0.11963527 2.71466214 [33,] -2.03836988 -0.11963527 [34,] 2.06697099 -2.03836988 [35,] -1.42981929 2.06697099 [36,] 3.31649865 -1.42981929 [37,] -7.22299484 3.31649865 [38,] 6.84316380 -7.22299484 [39,] -4.62615916 6.84316380 [40,] 3.50290793 -4.62615916 [41,] 5.79567356 3.50290793 [42,] 3.53163798 5.79567356 [43,] -5.24537370 3.53163798 [44,] -2.60767684 -5.24537370 [45,] -0.07744253 -2.60767684 [46,] -4.56541272 -0.07744253 [47,] -3.83531523 -4.56541272 [48,] 2.17658709 -3.83531523 [49,] -1.09072363 2.17658709 [50,] -1.29560476 -1.09072363 [51,] -3.57071495 -1.29560476 [52,] -1.56423633 -3.57071495 [53,] -1.24329182 -1.56423633 [54,] 2.36048952 -1.24329182 [55,] 1.62830491 2.36048952 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 2.78080901 -4.67561750 2 0.69499890 2.78080901 3 1.52755096 0.69499890 4 -3.84223829 1.52755096 5 -5.69361280 -3.84223829 6 -1.91982066 -5.69361280 7 2.74405306 -1.91982066 8 -1.44877970 2.74405306 9 0.66052280 -1.44877970 10 2.23961638 0.66052280 11 2.60836086 2.23961638 12 -2.55916606 2.60836086 13 -0.99935939 -2.55916606 14 -5.15694183 -0.99935939 15 6.76094619 -5.15694183 16 -3.49512636 6.76094619 17 -3.46315290 -3.49512636 18 0.46690723 -3.46315290 19 -1.84164641 0.46690723 20 4.17609182 -1.84164641 21 1.45528961 4.17609182 22 0.25882535 1.45528961 23 2.65677367 0.25882535 24 1.74169782 2.65677367 25 6.53226884 1.74169782 26 -1.08561610 6.53226884 27 -0.09162304 -1.08561610 28 5.39869305 -0.09162304 29 4.60438396 5.39869305 30 -4.43921406 4.60438396 31 2.71466214 -4.43921406 32 -0.11963527 2.71466214 33 -2.03836988 -0.11963527 34 2.06697099 -2.03836988 35 -1.42981929 2.06697099 36 3.31649865 -1.42981929 37 -7.22299484 3.31649865 38 6.84316380 -7.22299484 39 -4.62615916 6.84316380 40 3.50290793 -4.62615916 41 5.79567356 3.50290793 42 3.53163798 5.79567356 43 -5.24537370 3.53163798 44 -2.60767684 -5.24537370 45 -0.07744253 -2.60767684 46 -4.56541272 -0.07744253 47 -3.83531523 -4.56541272 48 2.17658709 -3.83531523 49 -1.09072363 2.17658709 50 -1.29560476 -1.09072363 51 -3.57071495 -1.29560476 52 -1.56423633 -3.57071495 53 -1.24329182 -1.56423633 54 2.36048952 -1.24329182 55 1.62830491 2.36048952 > 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/78owo1259092686.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/860pt1259092686.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/90fa21259092686.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/107nf61259092686.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/11szro1259092686.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/125m1v1259092686.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/130o4m1259092686.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/14zkaj1259092686.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/15t9up1259092686.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/163anh1259092686.tab") + } > > system("convert tmp/1bzbn1259092686.ps tmp/1bzbn1259092686.png") > system("convert tmp/2cfs91259092686.ps tmp/2cfs91259092686.png") > system("convert tmp/30pac1259092686.ps tmp/30pac1259092686.png") > system("convert tmp/4j1s71259092686.ps tmp/4j1s71259092686.png") > system("convert tmp/5l2wn1259092686.ps tmp/5l2wn1259092686.png") > system("convert tmp/60e8b1259092686.ps tmp/60e8b1259092686.png") > system("convert tmp/78owo1259092686.ps tmp/78owo1259092686.png") > system("convert tmp/860pt1259092686.ps tmp/860pt1259092686.png") > system("convert tmp/90fa21259092686.ps tmp/90fa21259092686.png") > system("convert tmp/107nf61259092686.ps tmp/107nf61259092686.png") > > > proc.time() user system elapsed 2.384 1.573 2.970