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(30 + ,35 + ,47 + ,30 + ,37 + ,43 + ,30 + ,35 + ,47 + ,30 + ,82 + ,43 + ,30 + ,35 + ,47 + ,40 + ,82 + ,43 + ,30 + ,35 + ,47 + ,40 + ,82 + ,43 + ,30 + ,19 + ,47 + ,40 + ,82 + ,43 + ,52 + ,19 + ,47 + ,40 + ,82 + ,136 + ,52 + ,19 + ,47 + ,40 + ,80 + ,136 + ,52 + ,19 + ,47 + ,42 + ,80 + ,136 + ,52 + ,19 + ,54 + ,42 + ,80 + ,136 + ,52 + ,66 + ,54 + ,42 + ,80 + ,136 + ,81 + ,66 + ,54 + ,42 + ,80 + ,63 + ,81 + ,66 + ,54 + ,42 + ,137 + ,63 + ,81 + ,66 + ,54 + ,72 + ,137 + ,63 + ,81 + ,66 + ,107 + ,72 + ,137 + ,63 + ,81 + ,58 + ,107 + ,72 + ,137 + ,63 + ,36 + ,58 + ,107 + ,72 + ,137 + ,52 + ,36 + ,58 + ,107 + ,72 + ,79 + ,52 + ,36 + ,58 + ,107 + ,77 + ,79 + ,52 + ,36 + ,58 + ,54 + ,77 + ,79 + ,52 + ,36 + ,84 + ,54 + ,77 + ,79 + ,52 + ,48 + ,84 + ,54 + ,77 + ,79 + ,96 + ,48 + ,84 + ,54 + ,77 + ,83 + ,96 + ,48 + ,84 + ,54 + ,66 + ,83 + ,96 + ,48 + ,84 + ,61 + ,66 + ,83 + ,96 + ,48 + ,53 + ,61 + ,66 + ,83 + ,96 + ,30 + ,53 + ,61 + ,66 + ,83 + ,74 + ,30 + ,53 + ,61 + ,66 + ,69 + ,74 + ,30 + ,53 + ,61 + ,59 + ,69 + ,74 + ,30 + ,53 + ,42 + ,59 + ,69 + ,74 + ,30 + ,65 + ,42 + ,59 + ,69 + ,74 + ,70 + ,65 + ,42 + ,59 + ,69 + ,100 + ,70 + ,65 + ,42 + ,59 + ,63 + ,100 + ,70 + ,65 + ,42 + ,105 + ,63 + ,100 + ,70 + ,65 + ,82 + ,105 + ,63 + ,100 + ,70 + ,81 + ,82 + ,105 + ,63 + ,100 + ,75 + ,81 + ,82 + ,105 + ,63 + ,102 + ,75 + ,81 + ,82 + ,105 + ,121 + ,102 + ,75 + ,81 + ,82 + ,98 + ,121 + ,102 + ,75 + ,81 + ,76 + ,98 + ,121 + ,102 + ,75 + ,77 + ,76 + ,98 + ,121 + ,102 + ,63 + ,77 + ,76 + ,98 + ,121 + ,37 + ,63 + ,77 + ,76 + ,98 + ,35 + ,37 + ,63 + ,77 + ,76 + ,23 + ,35 + ,37 + ,63 + ,77 + ,40 + ,23 + ,35 + ,37 + ,63 + ,29 + ,40 + ,23 + ,35 + ,37 + ,37 + ,29 + ,40 + ,23 + ,35 + ,51 + ,37 + ,29 + ,40 + ,23 + ,20 + ,51 + ,37 + ,29 + ,40 + ,28 + ,20 + ,51 + ,37 + ,29 + ,13 + ,28 + ,20 + ,51 + ,37 + ,22 + ,13 + ,28 + ,20 + ,51 + ,25 + ,22 + ,13 + ,28 + ,20 + ,13 + ,25 + ,22 + ,13 + ,28 + ,16 + ,13 + ,25 + ,22 + ,13 + ,13 + ,16 + ,13 + ,25 + ,22 + ,16 + ,13 + ,16 + ,13 + ,25 + ,17 + ,16 + ,13 + ,16 + ,13 + ,9 + ,17 + ,16 + ,13 + ,16 + ,17 + ,9 + ,17 + ,16 + ,13 + ,25 + ,17 + ,9 + ,17 + ,16 + ,14 + ,25 + ,17 + ,9 + ,17 + ,8 + ,14 + ,25 + ,17 + ,9 + ,7 + ,8 + ,14 + ,25 + ,17 + ,10 + ,7 + ,8 + ,14 + ,25 + ,7 + ,10 + ,7 + ,8 + ,14 + ,10 + ,7 + ,10 + ,7 + ,8 + ,3 + ,10 + ,7 + ,10 + ,7) + ,dim=c(5 + ,76) + ,dimnames=list(c('X' + ,'Y1' + ,'Y2' + ,'Y3' + ,'Y4 ') + ,1:76)) > y <- array(NA,dim=c(5,76),dimnames=list(c('X','Y1','Y2','Y3','Y4 '),1:76)) > 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 X Y1 Y2 Y3 Y4\r M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 30 35 47 30 37 1 0 0 0 0 0 0 0 0 0 0 1 2 43 30 35 47 30 0 1 0 0 0 0 0 0 0 0 0 2 3 82 43 30 35 47 0 0 1 0 0 0 0 0 0 0 0 3 4 40 82 43 30 35 0 0 0 1 0 0 0 0 0 0 0 4 5 47 40 82 43 30 0 0 0 0 1 0 0 0 0 0 0 5 6 19 47 40 82 43 0 0 0 0 0 1 0 0 0 0 0 6 7 52 19 47 40 82 0 0 0 0 0 0 1 0 0 0 0 7 8 136 52 19 47 40 0 0 0 0 0 0 0 1 0 0 0 8 9 80 136 52 19 47 0 0 0 0 0 0 0 0 1 0 0 9 10 42 80 136 52 19 0 0 0 0 0 0 0 0 0 1 0 10 11 54 42 80 136 52 0 0 0 0 0 0 0 0 0 0 1 11 12 66 54 42 80 136 0 0 0 0 0 0 0 0 0 0 0 12 13 81 66 54 42 80 1 0 0 0 0 0 0 0 0 0 0 13 14 63 81 66 54 42 0 1 0 0 0 0 0 0 0 0 0 14 15 137 63 81 66 54 0 0 1 0 0 0 0 0 0 0 0 15 16 72 137 63 81 66 0 0 0 1 0 0 0 0 0 0 0 16 17 107 72 137 63 81 0 0 0 0 1 0 0 0 0 0 0 17 18 58 107 72 137 63 0 0 0 0 0 1 0 0 0 0 0 18 19 36 58 107 72 137 0 0 0 0 0 0 1 0 0 0 0 19 20 52 36 58 107 72 0 0 0 0 0 0 0 1 0 0 0 20 21 79 52 36 58 107 0 0 0 0 0 0 0 0 1 0 0 21 22 77 79 52 36 58 0 0 0 0 0 0 0 0 0 1 0 22 23 54 77 79 52 36 0 0 0 0 0 0 0 0 0 0 1 23 24 84 54 77 79 52 0 0 0 0 0 0 0 0 0 0 0 24 25 48 84 54 77 79 1 0 0 0 0 0 0 0 0 0 0 25 26 96 48 84 54 77 0 1 0 0 0 0 0 0 0 0 0 26 27 83 96 48 84 54 0 0 1 0 0 0 0 0 0 0 0 27 28 66 83 96 48 84 0 0 0 1 0 0 0 0 0 0 0 28 29 61 66 83 96 48 0 0 0 0 1 0 0 0 0 0 0 29 30 53 61 66 83 96 0 0 0 0 0 1 0 0 0 0 0 30 31 30 53 61 66 83 0 0 0 0 0 0 1 0 0 0 0 31 32 74 30 53 61 66 0 0 0 0 0 0 0 1 0 0 0 32 33 69 74 30 53 61 0 0 0 0 0 0 0 0 1 0 0 33 34 59 69 74 30 53 0 0 0 0 0 0 0 0 0 1 0 34 35 42 59 69 74 30 0 0 0 0 0 0 0 0 0 0 1 35 36 65 42 59 69 74 0 0 0 0 0 0 0 0 0 0 0 36 37 70 65 42 59 69 1 0 0 0 0 0 0 0 0 0 0 37 38 100 70 65 42 59 0 1 0 0 0 0 0 0 0 0 0 38 39 63 100 70 65 42 0 0 1 0 0 0 0 0 0 0 0 39 40 105 63 100 70 65 0 0 0 1 0 0 0 0 0 0 0 40 41 82 105 63 100 70 0 0 0 0 1 0 0 0 0 0 0 41 42 81 82 105 63 100 0 0 0 0 0 1 0 0 0 0 0 42 43 75 81 82 105 63 0 0 0 0 0 0 1 0 0 0 0 43 44 102 75 81 82 105 0 0 0 0 0 0 0 1 0 0 0 44 45 121 102 75 81 82 0 0 0 0 0 0 0 0 1 0 0 45 46 98 121 102 75 81 0 0 0 0 0 0 0 0 0 1 0 46 47 76 98 121 102 75 0 0 0 0 0 0 0 0 0 0 1 47 48 77 76 98 121 102 0 0 0 0 0 0 0 0 0 0 0 48 49 63 77 76 98 121 1 0 0 0 0 0 0 0 0 0 0 49 50 37 63 77 76 98 0 1 0 0 0 0 0 0 0 0 0 50 51 35 37 63 77 76 0 0 1 0 0 0 0 0 0 0 0 51 52 23 35 37 63 77 0 0 0 1 0 0 0 0 0 0 0 52 53 40 23 35 37 63 0 0 0 0 1 0 0 0 0 0 0 53 54 29 40 23 35 37 0 0 0 0 0 1 0 0 0 0 0 54 55 37 29 40 23 35 0 0 0 0 0 0 1 0 0 0 0 55 56 51 37 29 40 23 0 0 0 0 0 0 0 1 0 0 0 56 57 20 51 37 29 40 0 0 0 0 0 0 0 0 1 0 0 57 58 28 20 51 37 29 0 0 0 0 0 0 0 0 0 1 0 58 59 13 28 20 51 37 0 0 0 0 0 0 0 0 0 0 1 59 60 22 13 28 20 51 0 0 0 0 0 0 0 0 0 0 0 60 61 25 22 13 28 20 1 0 0 0 0 0 0 0 0 0 0 61 62 13 25 22 13 28 0 1 0 0 0 0 0 0 0 0 0 62 63 16 13 25 22 13 0 0 1 0 0 0 0 0 0 0 0 63 64 13 16 13 25 22 0 0 0 1 0 0 0 0 0 0 0 64 65 16 13 16 13 25 0 0 0 0 1 0 0 0 0 0 0 65 66 17 16 13 16 13 0 0 0 0 0 1 0 0 0 0 0 66 67 9 17 16 13 16 0 0 0 0 0 0 1 0 0 0 0 67 68 17 9 17 16 13 0 0 0 0 0 0 0 1 0 0 0 68 69 25 17 9 17 16 0 0 0 0 0 0 0 0 1 0 0 69 70 14 25 17 9 17 0 0 0 0 0 0 0 0 0 1 0 70 71 8 14 25 17 9 0 0 0 0 0 0 0 0 0 0 1 71 72 7 8 14 25 17 0 0 0 0 0 0 0 0 0 0 0 72 73 10 7 8 14 25 1 0 0 0 0 0 0 0 0 0 0 73 74 7 10 7 8 14 0 1 0 0 0 0 0 0 0 0 0 74 75 10 7 10 7 8 0 0 1 0 0 0 0 0 0 0 0 75 76 3 10 7 10 7 0 0 0 1 0 0 0 0 0 0 0 76 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) Y1 Y2 Y3 `Y4\r` M1 27.28342 0.39713 0.24163 -0.07212 0.19455 -8.55124 M2 M3 M4 M5 M6 M7 -2.43346 8.75388 -12.74014 -2.18969 -16.60868 -17.57429 M8 M9 M10 M11 t 23.49448 3.14624 -11.59046 -13.66912 -0.29072 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -38.5345 -10.2488 -0.4374 8.9409 57.9137 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 27.28342 13.82700 1.973 0.05316 . Y1 0.39713 0.12633 3.144 0.00261 ** Y2 0.24163 0.13573 1.780 0.08018 . Y3 -0.07212 0.13495 -0.534 0.59509 `Y4\r` 0.19455 0.12345 1.576 0.12037 M1 -8.55124 12.08055 -0.708 0.48182 M2 -2.43346 12.23900 -0.199 0.84308 M3 8.75388 12.31178 0.711 0.47988 M4 -12.74014 12.46660 -1.022 0.31098 M5 -2.18969 12.73441 -0.172 0.86406 M6 -16.60868 12.47235 -1.332 0.18810 M7 -17.57429 12.33230 -1.425 0.15941 M8 23.49448 12.33227 1.905 0.06164 . M9 3.14624 13.50924 0.233 0.81665 M10 -11.59046 13.78116 -0.841 0.40372 M11 -13.66912 13.15108 -1.039 0.30286 t -0.29072 0.13498 -2.154 0.03535 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 21.05 on 59 degrees of freedom Multiple R-squared: 0.671, Adjusted R-squared: 0.5818 F-statistic: 7.521 on 16 and 59 DF, p-value: 3.647e-09 > 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.9960993 0.0078013281 0.0039006641 [2,] 0.9970242 0.0059515098 0.0029757549 [3,] 0.9970102 0.0059795977 0.0029897988 [4,] 0.9979756 0.0040487255 0.0020243628 [5,] 0.9968934 0.0062132858 0.0031066429 [6,] 0.9982857 0.0034286470 0.0017143235 [7,] 0.9986466 0.0027068789 0.0013534394 [8,] 0.9989825 0.0020350940 0.0010175470 [9,] 0.9989892 0.0020215843 0.0010107922 [10,] 0.9986225 0.0027549268 0.0013774634 [11,] 0.9973382 0.0053235408 0.0026617704 [12,] 0.9975492 0.0049016449 0.0024508224 [13,] 0.9965722 0.0068556899 0.0034278449 [14,] 0.9934910 0.0130179116 0.0065089558 [15,] 0.9915275 0.0169450092 0.0084725046 [16,] 0.9905750 0.0188500234 0.0094250117 [17,] 0.9832028 0.0335944699 0.0167972349 [18,] 0.9746837 0.0506325429 0.0253162714 [19,] 0.9874621 0.0250757602 0.0125378801 [20,] 0.9939527 0.0120945038 0.0060472519 [21,] 0.9986173 0.0027654650 0.0013827325 [22,] 0.9977995 0.0044010641 0.0022005321 [23,] 0.9956442 0.0087115193 0.0043557597 [24,] 0.9942915 0.0114170251 0.0057085125 [25,] 0.9954019 0.0091961872 0.0045980936 [26,] 0.9998960 0.0002079003 0.0001039501 [27,] 0.9998623 0.0002754050 0.0001377025 [28,] 0.9996216 0.0007567590 0.0003783795 [29,] 0.9994282 0.0011435396 0.0005717698 [30,] 0.9992981 0.0014038938 0.0007019469 [31,] 0.9988153 0.0023694395 0.0011847198 [32,] 0.9975886 0.0048227259 0.0024113629 [33,] 0.9936887 0.0126226836 0.0063113418 [34,] 0.9869473 0.0261053290 0.0130526645 [35,] 0.9645165 0.0709670569 0.0354835285 [36,] 0.9486502 0.1026996818 0.0513498409 [37,] 0.9953251 0.0093498991 0.0046749495 > postscript(file="/var/www/html/rcomp/tmp/1g3e31291022852.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/2qdeo1291022852.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/3qdeo1291022852.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/4qdeo1291022852.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/5qdeo1291022852.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 = 76 Frequency = 1 1 2 3 4 5 6 -18.7324280 -4.0864699 15.8896318 -20.9806139 -15.0743383 -20.7127912 7 8 9 10 11 12 12.3551972 57.9136990 -22.1607198 -35.3637957 7.2649875 -10.0780078 13 14 15 16 17 18 14.2535349 -10.1715109 54.9864345 -14.5196820 13.9368065 -9.7084772 19 20 21 22 23 24 -38.5345089 -27.5659438 8.6918052 15.0773831 -5.8489240 19.2240686 25 26 27 28 29 30 -19.6874471 28.2635923 0.6418108 -9.4417768 -4.3437192 -1.8167802 31 32 33 34 35 36 -17.8720618 -0.6363588 3.4824020 -0.2384464 -2.0418419 7.8262278 37 38 39 40 41 42 16.8936156 34.2430478 -21.8093951 45.3059519 5.4979293 9.6882175 43 44 45 46 47 48 21.1264835 0.1428998 34.9118759 12.6317991 0.6585599 -1.3083827 49 50 51 52 53 54 -6.9028901 -30.5236211 -25.3598753 -9.7027018 3.1350840 7.9073808 55 56 57 58 59 60 16.9481244 -6.7883964 -28.7429062 5.9296068 -2.9343250 -8.2482109 61 62 63 64 65 66 10.2521506 -13.5791015 -13.8677526 5.0905225 -3.1517623 14.6424504 67 68 69 70 71 72 5.9767655 -23.0658997 3.8175430 1.9634531 2.9015434 -7.4156950 73 74 75 76 3.9234641 -4.1459367 -10.4808539 4.2483001 > postscript(file="/var/www/html/rcomp/tmp/61mdr1291022852.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 = 76 Frequency = 1 lag(myerror, k = 1) myerror 0 -18.7324280 NA 1 -4.0864699 -18.7324280 2 15.8896318 -4.0864699 3 -20.9806139 15.8896318 4 -15.0743383 -20.9806139 5 -20.7127912 -15.0743383 6 12.3551972 -20.7127912 7 57.9136990 12.3551972 8 -22.1607198 57.9136990 9 -35.3637957 -22.1607198 10 7.2649875 -35.3637957 11 -10.0780078 7.2649875 12 14.2535349 -10.0780078 13 -10.1715109 14.2535349 14 54.9864345 -10.1715109 15 -14.5196820 54.9864345 16 13.9368065 -14.5196820 17 -9.7084772 13.9368065 18 -38.5345089 -9.7084772 19 -27.5659438 -38.5345089 20 8.6918052 -27.5659438 21 15.0773831 8.6918052 22 -5.8489240 15.0773831 23 19.2240686 -5.8489240 24 -19.6874471 19.2240686 25 28.2635923 -19.6874471 26 0.6418108 28.2635923 27 -9.4417768 0.6418108 28 -4.3437192 -9.4417768 29 -1.8167802 -4.3437192 30 -17.8720618 -1.8167802 31 -0.6363588 -17.8720618 32 3.4824020 -0.6363588 33 -0.2384464 3.4824020 34 -2.0418419 -0.2384464 35 7.8262278 -2.0418419 36 16.8936156 7.8262278 37 34.2430478 16.8936156 38 -21.8093951 34.2430478 39 45.3059519 -21.8093951 40 5.4979293 45.3059519 41 9.6882175 5.4979293 42 21.1264835 9.6882175 43 0.1428998 21.1264835 44 34.9118759 0.1428998 45 12.6317991 34.9118759 46 0.6585599 12.6317991 47 -1.3083827 0.6585599 48 -6.9028901 -1.3083827 49 -30.5236211 -6.9028901 50 -25.3598753 -30.5236211 51 -9.7027018 -25.3598753 52 3.1350840 -9.7027018 53 7.9073808 3.1350840 54 16.9481244 7.9073808 55 -6.7883964 16.9481244 56 -28.7429062 -6.7883964 57 5.9296068 -28.7429062 58 -2.9343250 5.9296068 59 -8.2482109 -2.9343250 60 10.2521506 -8.2482109 61 -13.5791015 10.2521506 62 -13.8677526 -13.5791015 63 5.0905225 -13.8677526 64 -3.1517623 5.0905225 65 14.6424504 -3.1517623 66 5.9767655 14.6424504 67 -23.0658997 5.9767655 68 3.8175430 -23.0658997 69 1.9634531 3.8175430 70 2.9015434 1.9634531 71 -7.4156950 2.9015434 72 3.9234641 -7.4156950 73 -4.1459367 3.9234641 74 -10.4808539 -4.1459367 75 4.2483001 -10.4808539 76 NA 4.2483001 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -4.0864699 -18.7324280 [2,] 15.8896318 -4.0864699 [3,] -20.9806139 15.8896318 [4,] -15.0743383 -20.9806139 [5,] -20.7127912 -15.0743383 [6,] 12.3551972 -20.7127912 [7,] 57.9136990 12.3551972 [8,] -22.1607198 57.9136990 [9,] -35.3637957 -22.1607198 [10,] 7.2649875 -35.3637957 [11,] -10.0780078 7.2649875 [12,] 14.2535349 -10.0780078 [13,] -10.1715109 14.2535349 [14,] 54.9864345 -10.1715109 [15,] -14.5196820 54.9864345 [16,] 13.9368065 -14.5196820 [17,] -9.7084772 13.9368065 [18,] -38.5345089 -9.7084772 [19,] -27.5659438 -38.5345089 [20,] 8.6918052 -27.5659438 [21,] 15.0773831 8.6918052 [22,] -5.8489240 15.0773831 [23,] 19.2240686 -5.8489240 [24,] -19.6874471 19.2240686 [25,] 28.2635923 -19.6874471 [26,] 0.6418108 28.2635923 [27,] -9.4417768 0.6418108 [28,] -4.3437192 -9.4417768 [29,] -1.8167802 -4.3437192 [30,] -17.8720618 -1.8167802 [31,] -0.6363588 -17.8720618 [32,] 3.4824020 -0.6363588 [33,] -0.2384464 3.4824020 [34,] -2.0418419 -0.2384464 [35,] 7.8262278 -2.0418419 [36,] 16.8936156 7.8262278 [37,] 34.2430478 16.8936156 [38,] -21.8093951 34.2430478 [39,] 45.3059519 -21.8093951 [40,] 5.4979293 45.3059519 [41,] 9.6882175 5.4979293 [42,] 21.1264835 9.6882175 [43,] 0.1428998 21.1264835 [44,] 34.9118759 0.1428998 [45,] 12.6317991 34.9118759 [46,] 0.6585599 12.6317991 [47,] -1.3083827 0.6585599 [48,] -6.9028901 -1.3083827 [49,] -30.5236211 -6.9028901 [50,] -25.3598753 -30.5236211 [51,] -9.7027018 -25.3598753 [52,] 3.1350840 -9.7027018 [53,] 7.9073808 3.1350840 [54,] 16.9481244 7.9073808 [55,] -6.7883964 16.9481244 [56,] -28.7429062 -6.7883964 [57,] 5.9296068 -28.7429062 [58,] -2.9343250 5.9296068 [59,] -8.2482109 -2.9343250 [60,] 10.2521506 -8.2482109 [61,] -13.5791015 10.2521506 [62,] -13.8677526 -13.5791015 [63,] 5.0905225 -13.8677526 [64,] -3.1517623 5.0905225 [65,] 14.6424504 -3.1517623 [66,] 5.9767655 14.6424504 [67,] -23.0658997 5.9767655 [68,] 3.8175430 -23.0658997 [69,] 1.9634531 3.8175430 [70,] 2.9015434 1.9634531 [71,] -7.4156950 2.9015434 [72,] 3.9234641 -7.4156950 [73,] -4.1459367 3.9234641 [74,] -10.4808539 -4.1459367 [75,] 4.2483001 -10.4808539 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -4.0864699 -18.7324280 2 15.8896318 -4.0864699 3 -20.9806139 15.8896318 4 -15.0743383 -20.9806139 5 -20.7127912 -15.0743383 6 12.3551972 -20.7127912 7 57.9136990 12.3551972 8 -22.1607198 57.9136990 9 -35.3637957 -22.1607198 10 7.2649875 -35.3637957 11 -10.0780078 7.2649875 12 14.2535349 -10.0780078 13 -10.1715109 14.2535349 14 54.9864345 -10.1715109 15 -14.5196820 54.9864345 16 13.9368065 -14.5196820 17 -9.7084772 13.9368065 18 -38.5345089 -9.7084772 19 -27.5659438 -38.5345089 20 8.6918052 -27.5659438 21 15.0773831 8.6918052 22 -5.8489240 15.0773831 23 19.2240686 -5.8489240 24 -19.6874471 19.2240686 25 28.2635923 -19.6874471 26 0.6418108 28.2635923 27 -9.4417768 0.6418108 28 -4.3437192 -9.4417768 29 -1.8167802 -4.3437192 30 -17.8720618 -1.8167802 31 -0.6363588 -17.8720618 32 3.4824020 -0.6363588 33 -0.2384464 3.4824020 34 -2.0418419 -0.2384464 35 7.8262278 -2.0418419 36 16.8936156 7.8262278 37 34.2430478 16.8936156 38 -21.8093951 34.2430478 39 45.3059519 -21.8093951 40 5.4979293 45.3059519 41 9.6882175 5.4979293 42 21.1264835 9.6882175 43 0.1428998 21.1264835 44 34.9118759 0.1428998 45 12.6317991 34.9118759 46 0.6585599 12.6317991 47 -1.3083827 0.6585599 48 -6.9028901 -1.3083827 49 -30.5236211 -6.9028901 50 -25.3598753 -30.5236211 51 -9.7027018 -25.3598753 52 3.1350840 -9.7027018 53 7.9073808 3.1350840 54 16.9481244 7.9073808 55 -6.7883964 16.9481244 56 -28.7429062 -6.7883964 57 5.9296068 -28.7429062 58 -2.9343250 5.9296068 59 -8.2482109 -2.9343250 60 10.2521506 -8.2482109 61 -13.5791015 10.2521506 62 -13.8677526 -13.5791015 63 5.0905225 -13.8677526 64 -3.1517623 5.0905225 65 14.6424504 -3.1517623 66 5.9767655 14.6424504 67 -23.0658997 5.9767655 68 3.8175430 -23.0658997 69 1.9634531 3.8175430 70 2.9015434 1.9634531 71 -7.4156950 2.9015434 72 3.9234641 -7.4156950 73 -4.1459367 3.9234641 74 -10.4808539 -4.1459367 75 4.2483001 -10.4808539 > 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/7uvuc1291022852.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/8uvuc1291022852.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/9uvuc1291022852.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/10mmcx1291022852.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/11qna31291022852.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/12tor91291022852.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/138gpi1291022852.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/14tg551291022852.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/15eg3b1291022852.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/16sr5c1291022853.tab") + } > > try(system("convert tmp/1g3e31291022852.ps tmp/1g3e31291022852.png",intern=TRUE)) character(0) > try(system("convert tmp/2qdeo1291022852.ps tmp/2qdeo1291022852.png",intern=TRUE)) character(0) > try(system("convert tmp/3qdeo1291022852.ps tmp/3qdeo1291022852.png",intern=TRUE)) character(0) > try(system("convert tmp/4qdeo1291022852.ps tmp/4qdeo1291022852.png",intern=TRUE)) character(0) > try(system("convert tmp/5qdeo1291022852.ps tmp/5qdeo1291022852.png",intern=TRUE)) character(0) > try(system("convert tmp/61mdr1291022852.ps tmp/61mdr1291022852.png",intern=TRUE)) character(0) > try(system("convert tmp/7uvuc1291022852.ps tmp/7uvuc1291022852.png",intern=TRUE)) character(0) > try(system("convert tmp/8uvuc1291022852.ps tmp/8uvuc1291022852.png",intern=TRUE)) character(0) > try(system("convert tmp/9uvuc1291022852.ps tmp/9uvuc1291022852.png",intern=TRUE)) character(0) > try(system("convert tmp/10mmcx1291022852.ps tmp/10mmcx1291022852.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.625 1.611 32.528