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(6 + ,10 + ,2 + ,2 + ,5 + ,6 + ,9 + ,2 + ,2 + ,7 + ,4 + ,9 + ,4 + ,6 + ,5 + ,5 + ,2 + ,2 + ,10 + ,1 + ,1 + ,5 + ,7 + ,5 + ,2 + ,10 + ,4 + ,10 + ,6 + ,3 + ,9 + ,3 + ,6 + ,8 + ,3 + ,3 + ,9 + ,1 + ,8 + ,5 + ,5 + ,5 + ,7 + ,3 + ,1 + ,7 + ,2 + ,7 + ,3 + ,3 + ,5 + ,6 + ,10 + ,9 + ,1 + ,2 + ,5 + ,9 + ,9 + ,4 + ,3 + ,10 + ,10 + ,6 + ,1 + ,4 + ,3 + ,3 + ,10 + ,7 + ,9 + ,6 + ,5 + ,6 + ,8 + ,4 + ,8 + ,3 + ,9 + ,4 + ,1 + ,4 + ,2 + ,9 + ,1 + ,10 + ,9 + ,5 + ,6 + ,4 + ,9 + ,10 + ,7 + ,9 + ,1 + ,5 + ,1 + ,2 + ,5 + ,3 + ,7 + ,4 + ,2 + ,5 + ,10 + ,5 + ,6 + ,6 + ,1 + ,7 + ,7 + ,4 + ,6 + ,3 + ,5 + ,8 + ,7 + ,2 + ,4 + ,2 + ,9 + ,4 + ,3 + ,5 + ,7 + ,10 + ,8 + ,5 + ,6 + ,9 + ,5 + ,9 + ,9 + ,1 + ,10 + ,4 + ,2 + ,3 + ,7 + ,4 + ,9 + ,1 + ,5 + ,4 + ,6 + ,6 + ,1 + ,5 + ,4 + ,10 + ,4 + ,3 + ,7 + ,2 + ,10 + ,9 + ,8 + ,4 + ,8 + ,10 + ,7 + ,3 + ,6 + ,10 + ,9 + ,7 + ,5 + ,5 + ,5 + ,9 + ,2 + ,7 + ,4 + ,5 + ,3 + ,3 + ,10 + ,8 + ,7 + ,1 + ,9 + ,2 + ,8 + ,2 + ,10 + ,8 + ,2 + ,10 + ,7 + ,7 + ,2 + ,9 + ,7 + ,10 + ,7 + ,5 + ,9 + ,4 + ,6 + ,6 + ,8 + ,4 + ,9 + ,3 + ,7 + ,3 + ,3 + ,9 + ,2 + ,7 + ,9 + ,10 + ,3 + ,3 + ,1 + ,4 + ,6 + ,5 + ,9 + ,6 + ,6 + ,8 + ,4 + ,10 + ,6 + ,1 + ,6 + ,6 + ,10 + ,7 + ,4 + ,2 + ,7 + ,2 + ,9 + ,6 + ,4 + ,10 + ,6 + ,8 + ,5 + ,6 + ,5 + ,4 + ,10 + ,7 + ,8 + ,7 + ,8 + ,10 + ,7 + ,1 + ,9 + ,7 + ,2 + ,5 + ,9 + ,10 + ,9 + ,3 + ,2 + ,8 + ,6 + ,9 + ,5 + ,8 + ,1 + ,1 + ,8 + ,2 + ,7 + ,10 + ,1 + ,5 + ,4 + ,8 + ,8 + ,4 + ,1 + ,2 + ,3 + ,1 + ,7 + ,5 + ,5 + ,4 + ,10 + ,3 + ,2 + ,9 + ,3 + ,8 + ,5 + ,4 + ,1 + ,7 + ,9 + ,2 + ,6 + ,7 + ,9 + ,10 + ,3 + ,9 + ,1 + ,10 + ,7 + ,3 + ,5 + ,5 + ,7 + ,3 + ,6 + ,8 + ,8 + ,5 + ,5 + ,8 + ,4 + ,6 + ,8 + ,5 + ,2 + ,4 + ,8 + ,9 + ,9 + ,8 + ,9 + ,9 + ,1 + ,8 + ,7 + ,5 + ,3 + ,3 + ,10 + ,5 + ,3 + ,6 + ,4 + ,5 + ,1 + ,1 + ,4 + ,2 + ,9 + ,3 + ,3 + ,2 + ,6 + ,3 + ,3 + ,10 + ,2 + ,7 + ,3 + ,1 + ,7 + ,6 + ,7 + ,5 + ,5 + ,7 + ,8 + ,8 + ,7 + ,10 + ,4 + ,2 + ,8 + ,10 + ,3 + ,9 + ,8 + ,8 + ,7 + ,1 + ,8 + ,7 + ,10 + ,7 + ,10 + ,5 + ,5 + ,3 + ,1 + ,9 + ,2 + ,9 + ,9 + ,8 + ,6 + ,5 + ,1 + ,2 + ,8 + ,9 + ,8 + ,3 + ,10 + ,6 + ,1 + ,8 + ,2 + ,6 + ,1 + ,6 + ,10 + ,6 + ,10 + ,1 + ,6 + ,4 + ,1 + ,9 + ,10 + ,10 + ,2 + ,10 + ,9 + ,7 + ,8 + ,9 + ,10 + ,8 + ,1 + ,5 + ,4 + ,1 + ,8 + ,6 + ,5 + ,7 + ,5 + ,2 + ,7 + ,7 + ,7 + ,1 + ,4 + ,6 + ,10 + ,4 + ,10 + ,4 + ,2 + ,3 + ,10 + ,10 + ,6 + ,4 + ,3 + ,5 + ,10 + ,6 + ,6 + ,9 + ,8 + ,10 + ,3 + ,1 + ,10 + ,9 + ,2 + ,1 + ,2 + ,10 + ,7 + ,5 + ,3 + ,6 + ,4 + ,9 + ,9 + ,6 + ,10 + ,9 + ,10 + ,10 + ,3 + ,2 + ,8 + ,6 + ,10 + ,3 + ,5 + ,5) + ,dim=c(8 + ,61) + ,dimnames=list(c('yt' + ,'x2t' + ,'x3t' + ,'x4t' + ,'x5t' + ,'x6t' + ,'x7t' + ,'x8t ') + ,1:61)) > y <- array(NA,dim=c(8,61),dimnames=list(c('yt','x2t','x3t','x4t','x5t','x6t','x7t','x8t '),1:61)) > 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' > par3 <- 'No Linear Trend' > par2 <- 'Do not include Seasonal 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, 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 yt x2t x3t x4t x5t x6t x7t x8t\r 1 6 10 2 2 5 6 9 2 2 2 7 4 9 4 6 5 5 3 2 2 10 1 1 5 7 5 4 2 10 4 10 6 3 9 3 5 6 8 3 3 9 1 8 5 6 5 5 7 3 1 7 2 7 7 3 3 5 6 10 9 1 2 8 5 9 9 4 3 10 10 6 9 1 4 3 3 10 7 9 6 10 5 6 8 4 8 3 9 4 11 1 4 2 9 1 10 9 5 12 6 4 9 10 7 9 1 5 13 1 2 5 3 7 4 2 5 14 10 5 6 6 1 7 7 4 15 6 3 5 8 7 2 4 2 16 9 4 3 5 7 10 8 5 17 6 9 5 9 9 1 10 4 18 2 3 7 4 9 1 5 4 19 6 6 1 5 4 10 4 3 20 7 2 10 9 8 4 8 10 21 7 3 6 10 9 7 5 5 22 5 9 2 7 4 5 3 3 23 10 8 7 1 9 2 8 2 24 10 8 2 10 7 7 2 9 25 7 10 7 5 9 4 6 6 26 8 4 9 3 7 3 3 9 27 2 7 9 10 3 3 1 4 28 6 5 9 6 6 8 4 10 29 6 1 6 6 10 7 4 2 30 7 2 9 6 4 10 6 8 31 5 6 5 4 10 7 8 7 32 8 10 7 1 9 7 2 5 33 9 10 9 3 2 8 6 9 34 5 8 1 1 8 2 7 10 35 1 5 4 8 8 4 1 2 36 3 1 7 5 5 4 10 3 37 2 9 3 8 5 4 1 7 38 9 2 6 7 9 10 3 9 39 1 10 7 3 5 5 7 3 40 6 8 8 5 5 8 4 6 41 8 5 2 4 8 9 9 8 42 9 9 1 8 7 5 3 3 43 10 5 3 6 4 5 1 1 44 4 2 9 3 3 2 6 3 45 3 10 2 7 3 1 7 6 46 7 5 5 7 8 8 7 10 47 4 2 8 10 3 9 8 8 48 7 1 8 7 10 7 10 5 49 5 3 1 9 2 9 9 8 50 6 5 1 2 8 9 8 3 51 10 6 1 8 2 6 1 6 52 10 6 10 1 6 4 1 9 53 10 10 2 10 9 7 8 9 54 10 8 1 5 4 1 8 6 55 5 7 5 2 7 7 7 1 56 4 6 10 4 10 4 2 3 57 10 10 6 4 3 5 10 6 58 6 9 8 10 3 1 10 9 59 2 1 2 10 7 5 3 6 60 4 9 9 6 10 9 10 10 61 3 2 8 6 10 3 5 5 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) x2t x3t x4t x5t x6t 3.45630 0.19616 -0.07593 -0.11307 0.04782 0.13924 x7t `x8t\\r` -0.07507 0.26781 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -5.0582 -2.1787 0.0263 1.9111 5.3888 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.45630 2.17867 1.586 0.1186 x2t 0.19616 0.13242 1.481 0.1444 x3t -0.07593 0.13247 -0.573 0.5689 x4t -0.11307 0.13423 -0.842 0.4034 x5t 0.04782 0.13037 0.367 0.7152 x6t 0.13924 0.13673 1.018 0.3131 x7t -0.07507 0.12173 -0.617 0.5401 `x8t\\r` 0.26781 0.15023 1.783 0.0804 . --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 2.825 on 53 degrees of freedom Multiple R-squared: 0.1329, Adjusted R-squared: 0.01838 F-statistic: 1.16 on 7 and 53 DF, p-value: 0.341 > 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.2514256 0.5028512 0.74857441 [2,] 0.2848256 0.5696511 0.71517443 [3,] 0.2500287 0.5000574 0.74997129 [4,] 0.7802390 0.4395219 0.21976097 [5,] 0.7371917 0.5256165 0.26280826 [6,] 0.8854970 0.2290060 0.11450302 [7,] 0.8458847 0.3082306 0.15411532 [8,] 0.8065425 0.3869151 0.19345753 [9,] 0.7368236 0.5263529 0.26317645 [10,] 0.7509649 0.4980702 0.24903510 [11,] 0.7133145 0.5733710 0.28668551 [12,] 0.6370503 0.7258994 0.36294970 [13,] 0.7488716 0.5022567 0.25112836 [14,] 0.7813925 0.4372151 0.21860754 [15,] 0.7228434 0.5543132 0.27715658 [16,] 0.6767743 0.6464513 0.32322565 [17,] 0.6638655 0.6722691 0.33613454 [18,] 0.5930082 0.8139835 0.40699175 [19,] 0.5380806 0.9238389 0.46191943 [20,] 0.4640152 0.9280304 0.53598481 [21,] 0.4026412 0.8052824 0.59735882 [22,] 0.3243247 0.6486495 0.67567526 [23,] 0.2601022 0.5202045 0.73989777 [24,] 0.2501730 0.5003461 0.74982697 [25,] 0.2634596 0.5269192 0.73654040 [26,] 0.2000624 0.4001247 0.79993764 [27,] 0.3322674 0.6645348 0.66773261 [28,] 0.2910142 0.5820284 0.70898578 [29,] 0.4985965 0.9971930 0.50140349 [30,] 0.4328508 0.8657017 0.56714916 [31,] 0.3499994 0.6999987 0.65000065 [32,] 0.3319033 0.6638066 0.66809672 [33,] 0.4847928 0.9695855 0.51520724 [34,] 0.3866392 0.7732784 0.61336082 [35,] 0.5788585 0.8422830 0.42114149 [36,] 0.4612242 0.9224483 0.53877583 [37,] 0.3443757 0.6887514 0.65562432 [38,] 0.9228899 0.1542202 0.07711009 [39,] 0.8544679 0.2910643 0.14553214 [40,] 0.7173056 0.5653888 0.28269440 > postscript(file="/var/fisher/rcomp/tmp/14h9j1353431442.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/2btdn1353431442.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/316d71353431442.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/40p5y1353431442.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/59qsj1353431442.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 = 61 Frequency = 1 1 2 3 4 5 6 0.02548072 -3.49857713 -2.53389069 -2.81601249 0.23320961 -1.31348169 7 8 9 10 11 12 -2.17871331 -1.47822176 -5.05817446 0.23047405 -4.17518023 0.72115384 13 14 15 16 17 18 -4.21044602 5.12857911 2.39080561 3.08645593 1.28527531 -2.32657989 19 20 21 22 23 24 -0.07889528 1.91113013 2.17263294 -0.74416285 4.97499196 2.68729124 25 26 27 28 29 30 0.53506604 1.84400349 -2.57275850 -0.85408816 1.79322994 1.23732474 31 32 33 34 35 36 -1.52845047 0.63260214 1.43514343 -2.65034921 -3.62896235 -0.40446460 37 38 39 40 41 42 -4.68513864 2.39046246 -4.76050574 -0.51248979 1.06433678 3.14950236 43 44 45 46 47 48 5.38883871 0.39896006 -2.83870010 0.08481436 -1.04912404 2.70512203 49 50 51 52 53 54 -0.76697406 0.02627313 3.88428859 3.05991720 2.64972450 4.27879720 55 56 57 58 59 60 -0.27545692 -1.11021752 3.79404218 0.57401034 -2.78257837 -3.51887106 61 -1.42247478 > postscript(file="/var/fisher/rcomp/tmp/63j2g1353431442.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 = 61 Frequency = 1 lag(myerror, k = 1) myerror 0 0.02548072 NA 1 -3.49857713 0.02548072 2 -2.53389069 -3.49857713 3 -2.81601249 -2.53389069 4 0.23320961 -2.81601249 5 -1.31348169 0.23320961 6 -2.17871331 -1.31348169 7 -1.47822176 -2.17871331 8 -5.05817446 -1.47822176 9 0.23047405 -5.05817446 10 -4.17518023 0.23047405 11 0.72115384 -4.17518023 12 -4.21044602 0.72115384 13 5.12857911 -4.21044602 14 2.39080561 5.12857911 15 3.08645593 2.39080561 16 1.28527531 3.08645593 17 -2.32657989 1.28527531 18 -0.07889528 -2.32657989 19 1.91113013 -0.07889528 20 2.17263294 1.91113013 21 -0.74416285 2.17263294 22 4.97499196 -0.74416285 23 2.68729124 4.97499196 24 0.53506604 2.68729124 25 1.84400349 0.53506604 26 -2.57275850 1.84400349 27 -0.85408816 -2.57275850 28 1.79322994 -0.85408816 29 1.23732474 1.79322994 30 -1.52845047 1.23732474 31 0.63260214 -1.52845047 32 1.43514343 0.63260214 33 -2.65034921 1.43514343 34 -3.62896235 -2.65034921 35 -0.40446460 -3.62896235 36 -4.68513864 -0.40446460 37 2.39046246 -4.68513864 38 -4.76050574 2.39046246 39 -0.51248979 -4.76050574 40 1.06433678 -0.51248979 41 3.14950236 1.06433678 42 5.38883871 3.14950236 43 0.39896006 5.38883871 44 -2.83870010 0.39896006 45 0.08481436 -2.83870010 46 -1.04912404 0.08481436 47 2.70512203 -1.04912404 48 -0.76697406 2.70512203 49 0.02627313 -0.76697406 50 3.88428859 0.02627313 51 3.05991720 3.88428859 52 2.64972450 3.05991720 53 4.27879720 2.64972450 54 -0.27545692 4.27879720 55 -1.11021752 -0.27545692 56 3.79404218 -1.11021752 57 0.57401034 3.79404218 58 -2.78257837 0.57401034 59 -3.51887106 -2.78257837 60 -1.42247478 -3.51887106 61 NA -1.42247478 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -3.49857713 0.02548072 [2,] -2.53389069 -3.49857713 [3,] -2.81601249 -2.53389069 [4,] 0.23320961 -2.81601249 [5,] -1.31348169 0.23320961 [6,] -2.17871331 -1.31348169 [7,] -1.47822176 -2.17871331 [8,] -5.05817446 -1.47822176 [9,] 0.23047405 -5.05817446 [10,] -4.17518023 0.23047405 [11,] 0.72115384 -4.17518023 [12,] -4.21044602 0.72115384 [13,] 5.12857911 -4.21044602 [14,] 2.39080561 5.12857911 [15,] 3.08645593 2.39080561 [16,] 1.28527531 3.08645593 [17,] -2.32657989 1.28527531 [18,] -0.07889528 -2.32657989 [19,] 1.91113013 -0.07889528 [20,] 2.17263294 1.91113013 [21,] -0.74416285 2.17263294 [22,] 4.97499196 -0.74416285 [23,] 2.68729124 4.97499196 [24,] 0.53506604 2.68729124 [25,] 1.84400349 0.53506604 [26,] -2.57275850 1.84400349 [27,] -0.85408816 -2.57275850 [28,] 1.79322994 -0.85408816 [29,] 1.23732474 1.79322994 [30,] -1.52845047 1.23732474 [31,] 0.63260214 -1.52845047 [32,] 1.43514343 0.63260214 [33,] -2.65034921 1.43514343 [34,] -3.62896235 -2.65034921 [35,] -0.40446460 -3.62896235 [36,] -4.68513864 -0.40446460 [37,] 2.39046246 -4.68513864 [38,] -4.76050574 2.39046246 [39,] -0.51248979 -4.76050574 [40,] 1.06433678 -0.51248979 [41,] 3.14950236 1.06433678 [42,] 5.38883871 3.14950236 [43,] 0.39896006 5.38883871 [44,] -2.83870010 0.39896006 [45,] 0.08481436 -2.83870010 [46,] -1.04912404 0.08481436 [47,] 2.70512203 -1.04912404 [48,] -0.76697406 2.70512203 [49,] 0.02627313 -0.76697406 [50,] 3.88428859 0.02627313 [51,] 3.05991720 3.88428859 [52,] 2.64972450 3.05991720 [53,] 4.27879720 2.64972450 [54,] -0.27545692 4.27879720 [55,] -1.11021752 -0.27545692 [56,] 3.79404218 -1.11021752 [57,] 0.57401034 3.79404218 [58,] -2.78257837 0.57401034 [59,] -3.51887106 -2.78257837 [60,] -1.42247478 -3.51887106 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -3.49857713 0.02548072 2 -2.53389069 -3.49857713 3 -2.81601249 -2.53389069 4 0.23320961 -2.81601249 5 -1.31348169 0.23320961 6 -2.17871331 -1.31348169 7 -1.47822176 -2.17871331 8 -5.05817446 -1.47822176 9 0.23047405 -5.05817446 10 -4.17518023 0.23047405 11 0.72115384 -4.17518023 12 -4.21044602 0.72115384 13 5.12857911 -4.21044602 14 2.39080561 5.12857911 15 3.08645593 2.39080561 16 1.28527531 3.08645593 17 -2.32657989 1.28527531 18 -0.07889528 -2.32657989 19 1.91113013 -0.07889528 20 2.17263294 1.91113013 21 -0.74416285 2.17263294 22 4.97499196 -0.74416285 23 2.68729124 4.97499196 24 0.53506604 2.68729124 25 1.84400349 0.53506604 26 -2.57275850 1.84400349 27 -0.85408816 -2.57275850 28 1.79322994 -0.85408816 29 1.23732474 1.79322994 30 -1.52845047 1.23732474 31 0.63260214 -1.52845047 32 1.43514343 0.63260214 33 -2.65034921 1.43514343 34 -3.62896235 -2.65034921 35 -0.40446460 -3.62896235 36 -4.68513864 -0.40446460 37 2.39046246 -4.68513864 38 -4.76050574 2.39046246 39 -0.51248979 -4.76050574 40 1.06433678 -0.51248979 41 3.14950236 1.06433678 42 5.38883871 3.14950236 43 0.39896006 5.38883871 44 -2.83870010 0.39896006 45 0.08481436 -2.83870010 46 -1.04912404 0.08481436 47 2.70512203 -1.04912404 48 -0.76697406 2.70512203 49 0.02627313 -0.76697406 50 3.88428859 0.02627313 51 3.05991720 3.88428859 52 2.64972450 3.05991720 53 4.27879720 2.64972450 54 -0.27545692 4.27879720 55 -1.11021752 -0.27545692 56 3.79404218 -1.11021752 57 0.57401034 3.79404218 58 -2.78257837 0.57401034 59 -3.51887106 -2.78257837 60 -1.42247478 -3.51887106 > 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/7lwut1353431442.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/88ae11353431442.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/9p5mi1353431442.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/1008c51353431442.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/11v3u61353431442.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/124xnt1353431442.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/13rpie1353431442.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/14wjbz1353431442.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/15mt8z1353431442.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/16phpz1353431442.tab") + } > > try(system("convert tmp/14h9j1353431442.ps tmp/14h9j1353431442.png",intern=TRUE)) character(0) > try(system("convert tmp/2btdn1353431442.ps tmp/2btdn1353431442.png",intern=TRUE)) character(0) > try(system("convert tmp/316d71353431442.ps tmp/316d71353431442.png",intern=TRUE)) character(0) > try(system("convert tmp/40p5y1353431442.ps tmp/40p5y1353431442.png",intern=TRUE)) character(0) > try(system("convert tmp/59qsj1353431442.ps tmp/59qsj1353431442.png",intern=TRUE)) character(0) > try(system("convert tmp/63j2g1353431442.ps tmp/63j2g1353431442.png",intern=TRUE)) character(0) > try(system("convert tmp/7lwut1353431442.ps tmp/7lwut1353431442.png",intern=TRUE)) character(0) > try(system("convert tmp/88ae11353431442.ps tmp/88ae11353431442.png",intern=TRUE)) character(0) > try(system("convert tmp/9p5mi1353431442.ps tmp/9p5mi1353431442.png",intern=TRUE)) character(0) > try(system("convert tmp/1008c51353431442.ps tmp/1008c51353431442.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 6.044 1.341 7.386