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(-3 + ,-19 + ,53 + ,24 + ,-2 + ,-29 + ,-4 + ,-20 + ,50 + ,24 + ,-4 + ,-29 + ,-7 + ,-21 + ,50 + ,31 + ,-5 + ,-27 + ,-7 + ,-19 + ,51 + ,25 + ,-2 + ,-29 + ,-7 + ,-17 + ,53 + ,28 + ,-4 + ,-24 + ,-3 + ,-16 + ,49 + ,24 + ,-4 + ,-29 + ,0 + ,-10 + ,54 + ,25 + ,-5 + ,-21 + ,-5 + ,-16 + ,57 + ,16 + ,-7 + ,-20 + ,-3 + ,-10 + ,58 + ,17 + ,-5 + ,-26 + ,3 + ,-8 + ,56 + ,11 + ,-6 + ,-19 + ,2 + ,-7 + ,60 + ,12 + ,-4 + ,-22 + ,-7 + ,-15 + ,55 + ,39 + ,-2 + ,-22 + ,-1 + ,-7 + ,54 + ,19 + ,-3 + ,-15 + ,0 + ,-6 + ,52 + ,14 + ,0 + ,-16 + ,-3 + ,-6 + ,55 + ,15 + ,-4 + ,-22 + ,4 + ,2 + ,56 + ,7 + ,-3 + ,-21 + ,2 + ,-4 + ,54 + ,12 + ,-3 + ,-11 + ,3 + ,-4 + ,53 + ,12 + ,-3 + ,-10 + ,0 + ,-8 + ,59 + ,14 + ,-4 + ,-6 + ,-10 + ,-10 + ,62 + ,9 + ,-5 + ,-8 + ,-10 + ,-16 + ,63 + ,8 + ,-5 + ,-15 + ,-9 + ,-14 + ,64 + ,4 + ,-6 + ,-16 + ,-22 + ,-30 + ,75 + ,7 + ,-10 + ,-24 + ,-16 + ,-33 + ,77 + ,3 + ,-11 + ,-27 + ,-18 + ,-40 + ,79 + ,5 + ,-13 + ,-33 + ,-14 + ,-38 + ,77 + ,0 + ,-12 + ,-29 + ,-12 + ,-39 + ,82 + ,-2 + ,-13 + ,-34 + ,-17 + ,-46 + ,83 + ,6 + ,-12 + ,-37 + ,-23 + ,-50 + ,81 + ,11 + ,-15 + ,-31 + ,-28 + ,-55 + ,78 + ,9 + ,-14 + ,-33 + ,-31 + ,-66 + ,79 + ,17 + ,-16 + ,-25 + ,-21 + ,-63 + ,79 + ,21 + ,-16 + ,-27 + ,-19 + ,-56 + ,73 + ,21 + ,-12 + ,-21 + ,-22 + ,-66 + ,72 + ,41 + ,-16 + ,-32 + ,-22 + ,-63 + ,67 + ,57 + ,-15 + ,-31 + ,-25 + ,-69 + ,67 + ,65 + ,-17 + ,-32 + ,-16 + ,-69 + ,50 + ,68 + ,-15 + ,-30 + ,-22 + ,-72 + ,45 + ,73 + ,-14 + ,-34 + ,-21 + ,-69 + ,39 + ,71 + ,-15 + ,-35 + ,-10 + ,-67 + ,39 + ,71 + ,-14 + ,-37 + ,-7 + ,-64 + ,37 + ,70 + ,-16 + ,-32 + ,-5 + ,-61 + ,30 + ,69 + ,-11 + ,-28 + ,-4 + ,-58 + ,24 + ,65 + ,-14 + ,-26 + ,7 + ,-47 + ,27 + ,57 + ,-12 + ,-24 + ,6 + ,-44 + ,19 + ,57 + ,-11 + ,-27 + ,3 + ,-42 + ,19 + ,57 + ,-13 + ,-26 + ,10 + ,-34 + ,25 + ,55 + ,-12 + ,-27 + ,0 + ,-38 + ,16 + ,65 + ,-12 + ,-27 + ,-2 + ,-41 + ,20 + ,65 + ,-10 + ,-24 + ,-1 + ,-38 + ,25 + ,64 + ,-12 + ,-28 + ,2 + ,-37 + ,34 + ,60 + ,-11 + ,-23 + ,8 + ,-22 + ,39 + ,43 + ,-10 + ,-23 + ,-6 + ,-37 + ,40 + ,47 + ,-12 + ,-29 + ,-4 + ,-36 + ,38 + ,40 + ,-12 + ,-25 + ,4 + ,-25 + ,42 + ,31 + ,-11 + ,-24 + ,7 + ,-15 + ,46 + ,27 + ,-12 + ,-20 + ,3 + ,-17 + ,48 + ,24 + ,-9 + ,-22 + ,3 + ,-19 + ,51 + ,23 + ,-6 + ,-24 + ,8 + ,-12 + ,55 + ,17 + ,-7 + ,-27 + ,3 + ,-17 + ,52 + ,16 + ,-7 + ,-25 + ,-3 + ,-21 + ,55 + ,15 + ,-10 + ,-26 + ,4 + ,-10 + ,58 + ,8 + ,-8 + ,-24 + ,-5 + ,-19 + ,72 + ,5 + ,-11 + ,-26 + ,-1 + ,-14 + ,70 + ,6 + ,-12 + ,-22 + ,5 + ,-8 + ,70 + ,5 + ,-11 + ,-20 + ,0 + ,-16 + ,63 + ,12 + ,-11 + ,-26 + ,-6 + ,-14 + ,66 + ,8 + ,-9 + ,-22 + ,-13 + ,-30 + ,65 + ,17 + ,-9 + ,-29 + ,-15 + ,-33 + ,55 + ,22 + ,-12 + ,-30 + ,-8 + ,-37 + ,57 + ,24 + ,-10 + ,-26 + ,-20 + ,-47 + ,60 + ,36 + ,-10 + ,-30 + ,-10 + ,-48 + ,63 + ,31 + ,-13 + ,-33 + ,-22 + ,-50 + ,65 + ,34 + ,-13 + ,-33 + ,-25 + ,-56 + ,61 + ,47 + ,-12 + ,-31 + ,-10 + ,-47 + ,65 + ,33 + ,-14 + ,-36 + ,-8 + ,-37 + ,63 + ,35 + ,-9 + ,-43 + ,-9 + ,-35 + ,59 + ,31 + ,-12 + ,-40 + ,-5 + ,-29 + ,56 + ,35 + ,-10 + ,-38 + ,-7 + ,-28 + ,54 + ,39 + ,-13 + ,-41 + ,-11 + ,-29 + ,56 + ,46 + ,-11 + ,-38 + ,-11 + ,-33 + ,54 + ,40 + ,-11 + ,-40 + ,-16 + ,-41 + ,58 + ,50 + ,-11 + ,-41) + ,dim=c(6 + ,82) + ,dimnames=list(c('Y_t' + ,'X_1t' + ,'X_2t' + ,'X_3t' + ,'X_4t' + ,'X_5t') + ,1:82)) > y <- array(NA,dim=c(6,82),dimnames=list(c('Y_t','X_1t','X_2t','X_3t','X_4t','X_5t'),1:82)) > 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 Y_t X_1t X_2t X_3t X_4t X_5t 1 -3 -19 53 24 -2 -29 2 -4 -20 50 24 -4 -29 3 -7 -21 50 31 -5 -27 4 -7 -19 51 25 -2 -29 5 -7 -17 53 28 -4 -24 6 -3 -16 49 24 -4 -29 7 0 -10 54 25 -5 -21 8 -5 -16 57 16 -7 -20 9 -3 -10 58 17 -5 -26 10 3 -8 56 11 -6 -19 11 2 -7 60 12 -4 -22 12 -7 -15 55 39 -2 -22 13 -1 -7 54 19 -3 -15 14 0 -6 52 14 0 -16 15 -3 -6 55 15 -4 -22 16 4 2 56 7 -3 -21 17 2 -4 54 12 -3 -11 18 3 -4 53 12 -3 -10 19 0 -8 59 14 -4 -6 20 -10 -10 62 9 -5 -8 21 -10 -16 63 8 -5 -15 22 -9 -14 64 4 -6 -16 23 -22 -30 75 7 -10 -24 24 -16 -33 77 3 -11 -27 25 -18 -40 79 5 -13 -33 26 -14 -38 77 0 -12 -29 27 -12 -39 82 -2 -13 -34 28 -17 -46 83 6 -12 -37 29 -23 -50 81 11 -15 -31 30 -28 -55 78 9 -14 -33 31 -31 -66 79 17 -16 -25 32 -21 -63 79 21 -16 -27 33 -19 -56 73 21 -12 -21 34 -22 -66 72 41 -16 -32 35 -22 -63 67 57 -15 -31 36 -25 -69 67 65 -17 -32 37 -16 -69 50 68 -15 -30 38 -22 -72 45 73 -14 -34 39 -21 -69 39 71 -15 -35 40 -10 -67 39 71 -14 -37 41 -7 -64 37 70 -16 -32 42 -5 -61 30 69 -11 -28 43 -4 -58 24 65 -14 -26 44 7 -47 27 57 -12 -24 45 6 -44 19 57 -11 -27 46 3 -42 19 57 -13 -26 47 10 -34 25 55 -12 -27 48 0 -38 16 65 -12 -27 49 -2 -41 20 65 -10 -24 50 -1 -38 25 64 -12 -28 51 2 -37 34 60 -11 -23 52 8 -22 39 43 -10 -23 53 -6 -37 40 47 -12 -29 54 -4 -36 38 40 -12 -25 55 4 -25 42 31 -11 -24 56 7 -15 46 27 -12 -20 57 3 -17 48 24 -9 -22 58 3 -19 51 23 -6 -24 59 8 -12 55 17 -7 -27 60 3 -17 52 16 -7 -25 61 -3 -21 55 15 -10 -26 62 4 -10 58 8 -8 -24 63 -5 -19 72 5 -11 -26 64 -1 -14 70 6 -12 -22 65 5 -8 70 5 -11 -20 66 0 -16 63 12 -11 -26 67 -6 -14 66 8 -9 -22 68 -13 -30 65 17 -9 -29 69 -15 -33 55 22 -12 -30 70 -8 -37 57 24 -10 -26 71 -20 -47 60 36 -10 -30 72 -10 -48 63 31 -13 -33 73 -22 -50 65 34 -13 -33 74 -25 -56 61 47 -12 -31 75 -10 -47 65 33 -14 -36 76 -8 -37 63 35 -9 -43 77 -9 -35 59 31 -12 -40 78 -5 -29 56 35 -10 -38 79 -7 -28 54 39 -13 -41 80 -11 -29 56 46 -11 -38 81 -11 -33 54 40 -11 -40 82 -16 -41 58 50 -11 -41 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X_1t X_2t X_3t X_4t X_5t 25.805037 0.428060 -0.450778 -0.077614 -0.816445 0.005186 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -9.8205 -2.9511 0.5013 3.1853 8.2359 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 25.805037 4.064581 6.349 1.44e-08 *** X_1t 0.428060 0.059689 7.172 4.17e-10 *** X_2t -0.450778 0.064245 -7.017 8.17e-10 *** X_3t -0.077614 0.062086 -1.250 0.215100 X_4t -0.816445 0.204637 -3.990 0.000151 *** X_5t 0.005186 0.080931 0.064 0.949077 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 4.068 on 76 degrees of freedom Multiple R-squared: 0.8351, Adjusted R-squared: 0.8242 F-statistic: 76.96 on 5 and 76 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.2028754613 0.405750923 0.7971245 [2,] 0.0971702778 0.194340556 0.9028297 [3,] 0.0460849200 0.092169840 0.9539151 [4,] 0.0181930656 0.036386131 0.9818069 [5,] 0.0177471682 0.035494336 0.9822528 [6,] 0.0089081990 0.017816398 0.9910918 [7,] 0.0201177751 0.040235550 0.9798822 [8,] 0.0094783545 0.018956709 0.9905216 [9,] 0.0043701820 0.008740364 0.9956298 [10,] 0.0021176328 0.004235266 0.9978824 [11,] 0.0009061939 0.001812388 0.9990938 [12,] 0.0179954122 0.035990824 0.9820046 [13,] 0.0123156302 0.024631260 0.9876844 [14,] 0.0089345572 0.017869114 0.9910654 [15,] 0.0088916023 0.017783205 0.9911084 [16,] 0.0250404995 0.050080999 0.9749595 [17,] 0.0310438940 0.062087788 0.9689561 [18,] 0.0431938051 0.086387610 0.9568062 [19,] 0.0899097418 0.179819484 0.9100903 [20,] 0.1126542171 0.225308434 0.8873458 [21,] 0.0808856433 0.161771287 0.9191144 [22,] 0.0752523490 0.150504698 0.9247477 [23,] 0.0738125471 0.147625094 0.9261875 [24,] 0.1714264341 0.342852868 0.8285736 [25,] 0.1902386330 0.380477266 0.8097614 [26,] 0.1754022100 0.350804420 0.8245978 [27,] 0.1345219266 0.269043853 0.8654781 [28,] 0.1015809882 0.203161976 0.8984190 [29,] 0.0910175065 0.182035013 0.9089825 [30,] 0.0781610628 0.156322126 0.9218389 [31,] 0.0854754050 0.170950810 0.9145246 [32,] 0.1246008275 0.249201655 0.8753992 [33,] 0.1567450708 0.313490142 0.8432549 [34,] 0.1837849874 0.367569975 0.8162150 [35,] 0.1464800990 0.292960198 0.8535199 [36,] 0.3329243660 0.665848732 0.6670756 [37,] 0.3363936110 0.672787222 0.6636064 [38,] 0.3125626091 0.625125218 0.6874374 [39,] 0.4161607732 0.832321546 0.5838392 [40,] 0.4844765710 0.968953142 0.5155234 [41,] 0.4666879072 0.933375814 0.5333121 [42,] 0.4247395151 0.849479030 0.5752605 [43,] 0.4240858107 0.848171621 0.5759142 [44,] 0.4762805898 0.952561180 0.5237194 [45,] 0.4281785056 0.856357011 0.5718215 [46,] 0.3733082032 0.746616406 0.6266918 [47,] 0.3434236234 0.686847247 0.6565764 [48,] 0.3354401419 0.670880284 0.6645599 [49,] 0.2930190484 0.586038097 0.7069810 [50,] 0.3135408858 0.627081772 0.6864591 [51,] 0.4557719700 0.911543940 0.5442280 [52,] 0.5034074333 0.993185133 0.4965926 [53,] 0.4292284895 0.858456979 0.5707715 [54,] 0.4386498116 0.877299623 0.5613502 [55,] 0.4178419344 0.835683869 0.5821581 [56,] 0.3448296585 0.689659317 0.6551703 [57,] 0.3583071016 0.716614203 0.6416929 [58,] 0.3407087143 0.681417429 0.6592913 [59,] 0.2658559436 0.531711887 0.7341441 [60,] 0.3447453447 0.689490689 0.6552547 [61,] 0.6576315078 0.684736984 0.3423685 [62,] 0.5755620894 0.848875821 0.4244379 [63,] 0.4752256323 0.950451265 0.5247744 [64,] 0.5589858702 0.882028260 0.4410141 [65,] 0.8534444259 0.293111148 0.1465556 > postscript(file="/var/wessaorg/rcomp/tmp/1an6z1355568920.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/wessaorg/rcomp/tmp/22cev1355568920.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/wessaorg/rcomp/tmp/329j11355568920.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/wessaorg/rcomp/tmp/4lhyt1355568920.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/wessaorg/rcomp/tmp/5bjhy1355568920.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 = 82 Frequency = 1 1 2 3 4 5 6 3.59954721 0.04238554 -2.81307431 -1.22439409 -2.60493705 -1.12063322 7 8 9 10 11 12 0.78457483 -2.63132972 -1.00729584 1.91660041 4.01771088 -0.08323368 13 14 15 16 17 18 -0.36351422 1.37332165 -3.43139580 0.78524813 0.78826526 1.33230189 19 20 21 22 23 24 2.06724768 -6.91844089 -3.94061436 -4.46767131 -8.65160446 -1.57721066 25 26 27 28 29 30 -1.12578031 1.52417663 5.26038156 5.16049345 -2.12120079 -5.66164291 31 32 33 34 35 36 -4.55566816 4.48097758 4.01455406 3.18792001 1.70293029 0.26449855 37 38 39 40 41 42 3.45663965 -2.28781022 -6.24314264 4.72755313 3.80538479 5.34962762 43 44 45 46 47 48 -0.40937922 8.23589769 3.17749882 -2.31669705 4.62988865 -6.93873033 49 50 51 52 53 54 -4.23410743 -3.95416054 3.15483735 4.48483132 -3.93480588 -3.82846083 55 56 57 58 59 60 1.37872099 0.75358492 0.73812514 5.32867038 7.86878864 3.56877219 61 62 63 64 65 66 -1.88841602 2.83447464 1.32609905 1.52466813 5.68476555 1.52821666 67 68 69 70 71 72 -2.67388034 -2.54086830 -9.82054212 1.56062769 -3.85432832 5.10421924 73 74 75 76 77 78 -4.90526386 -5.32496036 4.93205428 6.02364807 -0.41092927 1.60134902 79 80 81 82 -3.85158793 -4.36134447 -4.00596907 -2.99705320 > postscript(file="/var/wessaorg/rcomp/tmp/6bh2j1355568920.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 = 82 Frequency = 1 lag(myerror, k = 1) myerror 0 3.59954721 NA 1 0.04238554 3.59954721 2 -2.81307431 0.04238554 3 -1.22439409 -2.81307431 4 -2.60493705 -1.22439409 5 -1.12063322 -2.60493705 6 0.78457483 -1.12063322 7 -2.63132972 0.78457483 8 -1.00729584 -2.63132972 9 1.91660041 -1.00729584 10 4.01771088 1.91660041 11 -0.08323368 4.01771088 12 -0.36351422 -0.08323368 13 1.37332165 -0.36351422 14 -3.43139580 1.37332165 15 0.78524813 -3.43139580 16 0.78826526 0.78524813 17 1.33230189 0.78826526 18 2.06724768 1.33230189 19 -6.91844089 2.06724768 20 -3.94061436 -6.91844089 21 -4.46767131 -3.94061436 22 -8.65160446 -4.46767131 23 -1.57721066 -8.65160446 24 -1.12578031 -1.57721066 25 1.52417663 -1.12578031 26 5.26038156 1.52417663 27 5.16049345 5.26038156 28 -2.12120079 5.16049345 29 -5.66164291 -2.12120079 30 -4.55566816 -5.66164291 31 4.48097758 -4.55566816 32 4.01455406 4.48097758 33 3.18792001 4.01455406 34 1.70293029 3.18792001 35 0.26449855 1.70293029 36 3.45663965 0.26449855 37 -2.28781022 3.45663965 38 -6.24314264 -2.28781022 39 4.72755313 -6.24314264 40 3.80538479 4.72755313 41 5.34962762 3.80538479 42 -0.40937922 5.34962762 43 8.23589769 -0.40937922 44 3.17749882 8.23589769 45 -2.31669705 3.17749882 46 4.62988865 -2.31669705 47 -6.93873033 4.62988865 48 -4.23410743 -6.93873033 49 -3.95416054 -4.23410743 50 3.15483735 -3.95416054 51 4.48483132 3.15483735 52 -3.93480588 4.48483132 53 -3.82846083 -3.93480588 54 1.37872099 -3.82846083 55 0.75358492 1.37872099 56 0.73812514 0.75358492 57 5.32867038 0.73812514 58 7.86878864 5.32867038 59 3.56877219 7.86878864 60 -1.88841602 3.56877219 61 2.83447464 -1.88841602 62 1.32609905 2.83447464 63 1.52466813 1.32609905 64 5.68476555 1.52466813 65 1.52821666 5.68476555 66 -2.67388034 1.52821666 67 -2.54086830 -2.67388034 68 -9.82054212 -2.54086830 69 1.56062769 -9.82054212 70 -3.85432832 1.56062769 71 5.10421924 -3.85432832 72 -4.90526386 5.10421924 73 -5.32496036 -4.90526386 74 4.93205428 -5.32496036 75 6.02364807 4.93205428 76 -0.41092927 6.02364807 77 1.60134902 -0.41092927 78 -3.85158793 1.60134902 79 -4.36134447 -3.85158793 80 -4.00596907 -4.36134447 81 -2.99705320 -4.00596907 82 NA -2.99705320 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 0.04238554 3.59954721 [2,] -2.81307431 0.04238554 [3,] -1.22439409 -2.81307431 [4,] -2.60493705 -1.22439409 [5,] -1.12063322 -2.60493705 [6,] 0.78457483 -1.12063322 [7,] -2.63132972 0.78457483 [8,] -1.00729584 -2.63132972 [9,] 1.91660041 -1.00729584 [10,] 4.01771088 1.91660041 [11,] -0.08323368 4.01771088 [12,] -0.36351422 -0.08323368 [13,] 1.37332165 -0.36351422 [14,] -3.43139580 1.37332165 [15,] 0.78524813 -3.43139580 [16,] 0.78826526 0.78524813 [17,] 1.33230189 0.78826526 [18,] 2.06724768 1.33230189 [19,] -6.91844089 2.06724768 [20,] -3.94061436 -6.91844089 [21,] -4.46767131 -3.94061436 [22,] -8.65160446 -4.46767131 [23,] -1.57721066 -8.65160446 [24,] -1.12578031 -1.57721066 [25,] 1.52417663 -1.12578031 [26,] 5.26038156 1.52417663 [27,] 5.16049345 5.26038156 [28,] -2.12120079 5.16049345 [29,] -5.66164291 -2.12120079 [30,] -4.55566816 -5.66164291 [31,] 4.48097758 -4.55566816 [32,] 4.01455406 4.48097758 [33,] 3.18792001 4.01455406 [34,] 1.70293029 3.18792001 [35,] 0.26449855 1.70293029 [36,] 3.45663965 0.26449855 [37,] -2.28781022 3.45663965 [38,] -6.24314264 -2.28781022 [39,] 4.72755313 -6.24314264 [40,] 3.80538479 4.72755313 [41,] 5.34962762 3.80538479 [42,] -0.40937922 5.34962762 [43,] 8.23589769 -0.40937922 [44,] 3.17749882 8.23589769 [45,] -2.31669705 3.17749882 [46,] 4.62988865 -2.31669705 [47,] -6.93873033 4.62988865 [48,] -4.23410743 -6.93873033 [49,] -3.95416054 -4.23410743 [50,] 3.15483735 -3.95416054 [51,] 4.48483132 3.15483735 [52,] -3.93480588 4.48483132 [53,] -3.82846083 -3.93480588 [54,] 1.37872099 -3.82846083 [55,] 0.75358492 1.37872099 [56,] 0.73812514 0.75358492 [57,] 5.32867038 0.73812514 [58,] 7.86878864 5.32867038 [59,] 3.56877219 7.86878864 [60,] -1.88841602 3.56877219 [61,] 2.83447464 -1.88841602 [62,] 1.32609905 2.83447464 [63,] 1.52466813 1.32609905 [64,] 5.68476555 1.52466813 [65,] 1.52821666 5.68476555 [66,] -2.67388034 1.52821666 [67,] -2.54086830 -2.67388034 [68,] -9.82054212 -2.54086830 [69,] 1.56062769 -9.82054212 [70,] -3.85432832 1.56062769 [71,] 5.10421924 -3.85432832 [72,] -4.90526386 5.10421924 [73,] -5.32496036 -4.90526386 [74,] 4.93205428 -5.32496036 [75,] 6.02364807 4.93205428 [76,] -0.41092927 6.02364807 [77,] 1.60134902 -0.41092927 [78,] -3.85158793 1.60134902 [79,] -4.36134447 -3.85158793 [80,] -4.00596907 -4.36134447 [81,] -2.99705320 -4.00596907 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 0.04238554 3.59954721 2 -2.81307431 0.04238554 3 -1.22439409 -2.81307431 4 -2.60493705 -1.22439409 5 -1.12063322 -2.60493705 6 0.78457483 -1.12063322 7 -2.63132972 0.78457483 8 -1.00729584 -2.63132972 9 1.91660041 -1.00729584 10 4.01771088 1.91660041 11 -0.08323368 4.01771088 12 -0.36351422 -0.08323368 13 1.37332165 -0.36351422 14 -3.43139580 1.37332165 15 0.78524813 -3.43139580 16 0.78826526 0.78524813 17 1.33230189 0.78826526 18 2.06724768 1.33230189 19 -6.91844089 2.06724768 20 -3.94061436 -6.91844089 21 -4.46767131 -3.94061436 22 -8.65160446 -4.46767131 23 -1.57721066 -8.65160446 24 -1.12578031 -1.57721066 25 1.52417663 -1.12578031 26 5.26038156 1.52417663 27 5.16049345 5.26038156 28 -2.12120079 5.16049345 29 -5.66164291 -2.12120079 30 -4.55566816 -5.66164291 31 4.48097758 -4.55566816 32 4.01455406 4.48097758 33 3.18792001 4.01455406 34 1.70293029 3.18792001 35 0.26449855 1.70293029 36 3.45663965 0.26449855 37 -2.28781022 3.45663965 38 -6.24314264 -2.28781022 39 4.72755313 -6.24314264 40 3.80538479 4.72755313 41 5.34962762 3.80538479 42 -0.40937922 5.34962762 43 8.23589769 -0.40937922 44 3.17749882 8.23589769 45 -2.31669705 3.17749882 46 4.62988865 -2.31669705 47 -6.93873033 4.62988865 48 -4.23410743 -6.93873033 49 -3.95416054 -4.23410743 50 3.15483735 -3.95416054 51 4.48483132 3.15483735 52 -3.93480588 4.48483132 53 -3.82846083 -3.93480588 54 1.37872099 -3.82846083 55 0.75358492 1.37872099 56 0.73812514 0.75358492 57 5.32867038 0.73812514 58 7.86878864 5.32867038 59 3.56877219 7.86878864 60 -1.88841602 3.56877219 61 2.83447464 -1.88841602 62 1.32609905 2.83447464 63 1.52466813 1.32609905 64 5.68476555 1.52466813 65 1.52821666 5.68476555 66 -2.67388034 1.52821666 67 -2.54086830 -2.67388034 68 -9.82054212 -2.54086830 69 1.56062769 -9.82054212 70 -3.85432832 1.56062769 71 5.10421924 -3.85432832 72 -4.90526386 5.10421924 73 -5.32496036 -4.90526386 74 4.93205428 -5.32496036 75 6.02364807 4.93205428 76 -0.41092927 6.02364807 77 1.60134902 -0.41092927 78 -3.85158793 1.60134902 79 -4.36134447 -3.85158793 80 -4.00596907 -4.36134447 81 -2.99705320 -4.00596907 > 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/wessaorg/rcomp/tmp/7l50a1355568920.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/wessaorg/rcomp/tmp/86i3v1355568920.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/wessaorg/rcomp/tmp/90fjx1355568920.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/wessaorg/rcomp/tmp/10pirm1355568920.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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/11hrgm1355568920.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/wessaorg/rcomp/tmp/12i89k1355568920.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/wessaorg/rcomp/tmp/13p58v1355568920.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/wessaorg/rcomp/tmp/14k5mx1355568920.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/wessaorg/rcomp/tmp/15rex21355568920.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/wessaorg/rcomp/tmp/16utg21355568920.tab") + } > > try(system("convert tmp/1an6z1355568920.ps tmp/1an6z1355568920.png",intern=TRUE)) character(0) > try(system("convert tmp/22cev1355568920.ps tmp/22cev1355568920.png",intern=TRUE)) character(0) > try(system("convert tmp/329j11355568920.ps tmp/329j11355568920.png",intern=TRUE)) character(0) > try(system("convert tmp/4lhyt1355568920.ps tmp/4lhyt1355568920.png",intern=TRUE)) character(0) > try(system("convert tmp/5bjhy1355568920.ps tmp/5bjhy1355568920.png",intern=TRUE)) character(0) > try(system("convert tmp/6bh2j1355568920.ps tmp/6bh2j1355568920.png",intern=TRUE)) character(0) > try(system("convert tmp/7l50a1355568920.ps tmp/7l50a1355568920.png",intern=TRUE)) character(0) > try(system("convert tmp/86i3v1355568920.ps tmp/86i3v1355568920.png",intern=TRUE)) character(0) > try(system("convert tmp/90fjx1355568920.ps tmp/90fjx1355568920.png",intern=TRUE)) character(0) > try(system("convert tmp/10pirm1355568920.ps tmp/10pirm1355568920.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 6.575 1.213 7.779