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(22,0,22,0,20,0,21,0,20,0,21,0,21,0,21,0,19,0,21,0,21,0,22,0,19,0,24,0,22,0,22,0,22,0,24,0,22,0,23,0,24,0,21,0,20,0,22,0,23,0,23,0,22,0,20,0,21,1,21,1,20,1,20,1,17,1,18,1,19,1,19,1,20,1,21,1,20,1,21,1,19,1,22,1,20,1,18,1,16,1,17,1,18,1,19,1,18,1,20,1,21,1,18,1,19,1,19,1,19,1,21,1,19,1,19,1,17,1,16,1,16,1,17,1,16,1,15,1,16,1,16,1,16,1,18,1,19,1,16,1,16,1,16,1),dim=c(2,72),dimnames=list(c('Y','X'),1:72)) > y <- array(NA,dim=c(2,72),dimnames=list(c('Y','X'),1:72)) > 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 Y X M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 22 0 1 0 0 0 0 0 0 0 0 0 0 1 2 22 0 0 1 0 0 0 0 0 0 0 0 0 2 3 20 0 0 0 1 0 0 0 0 0 0 0 0 3 4 21 0 0 0 0 1 0 0 0 0 0 0 0 4 5 20 0 0 0 0 0 1 0 0 0 0 0 0 5 6 21 0 0 0 0 0 0 1 0 0 0 0 0 6 7 21 0 0 0 0 0 0 0 1 0 0 0 0 7 8 21 0 0 0 0 0 0 0 0 1 0 0 0 8 9 19 0 0 0 0 0 0 0 0 0 1 0 0 9 10 21 0 0 0 0 0 0 0 0 0 0 1 0 10 11 21 0 0 0 0 0 0 0 0 0 0 0 1 11 12 22 0 0 0 0 0 0 0 0 0 0 0 0 12 13 19 0 1 0 0 0 0 0 0 0 0 0 0 13 14 24 0 0 1 0 0 0 0 0 0 0 0 0 14 15 22 0 0 0 1 0 0 0 0 0 0 0 0 15 16 22 0 0 0 0 1 0 0 0 0 0 0 0 16 17 22 0 0 0 0 0 1 0 0 0 0 0 0 17 18 24 0 0 0 0 0 0 1 0 0 0 0 0 18 19 22 0 0 0 0 0 0 0 1 0 0 0 0 19 20 23 0 0 0 0 0 0 0 0 1 0 0 0 20 21 24 0 0 0 0 0 0 0 0 0 1 0 0 21 22 21 0 0 0 0 0 0 0 0 0 0 1 0 22 23 20 0 0 0 0 0 0 0 0 0 0 0 1 23 24 22 0 0 0 0 0 0 0 0 0 0 0 0 24 25 23 0 1 0 0 0 0 0 0 0 0 0 0 25 26 23 0 0 1 0 0 0 0 0 0 0 0 0 26 27 22 0 0 0 1 0 0 0 0 0 0 0 0 27 28 20 0 0 0 0 1 0 0 0 0 0 0 0 28 29 21 1 0 0 0 0 1 0 0 0 0 0 0 29 30 21 1 0 0 0 0 0 1 0 0 0 0 0 30 31 20 1 0 0 0 0 0 0 1 0 0 0 0 31 32 20 1 0 0 0 0 0 0 0 1 0 0 0 32 33 17 1 0 0 0 0 0 0 0 0 1 0 0 33 34 18 1 0 0 0 0 0 0 0 0 0 1 0 34 35 19 1 0 0 0 0 0 0 0 0 0 0 1 35 36 19 1 0 0 0 0 0 0 0 0 0 0 0 36 37 20 1 1 0 0 0 0 0 0 0 0 0 0 37 38 21 1 0 1 0 0 0 0 0 0 0 0 0 38 39 20 1 0 0 1 0 0 0 0 0 0 0 0 39 40 21 1 0 0 0 1 0 0 0 0 0 0 0 40 41 19 1 0 0 0 0 1 0 0 0 0 0 0 41 42 22 1 0 0 0 0 0 1 0 0 0 0 0 42 43 20 1 0 0 0 0 0 0 1 0 0 0 0 43 44 18 1 0 0 0 0 0 0 0 1 0 0 0 44 45 16 1 0 0 0 0 0 0 0 0 1 0 0 45 46 17 1 0 0 0 0 0 0 0 0 0 1 0 46 47 18 1 0 0 0 0 0 0 0 0 0 0 1 47 48 19 1 0 0 0 0 0 0 0 0 0 0 0 48 49 18 1 1 0 0 0 0 0 0 0 0 0 0 49 50 20 1 0 1 0 0 0 0 0 0 0 0 0 50 51 21 1 0 0 1 0 0 0 0 0 0 0 0 51 52 18 1 0 0 0 1 0 0 0 0 0 0 0 52 53 19 1 0 0 0 0 1 0 0 0 0 0 0 53 54 19 1 0 0 0 0 0 1 0 0 0 0 0 54 55 19 1 0 0 0 0 0 0 1 0 0 0 0 55 56 21 1 0 0 0 0 0 0 0 1 0 0 0 56 57 19 1 0 0 0 0 0 0 0 0 1 0 0 57 58 19 1 0 0 0 0 0 0 0 0 0 1 0 58 59 17 1 0 0 0 0 0 0 0 0 0 0 1 59 60 16 1 0 0 0 0 0 0 0 0 0 0 0 60 61 16 1 1 0 0 0 0 0 0 0 0 0 0 61 62 17 1 0 1 0 0 0 0 0 0 0 0 0 62 63 16 1 0 0 1 0 0 0 0 0 0 0 0 63 64 15 1 0 0 0 1 0 0 0 0 0 0 0 64 65 16 1 0 0 0 0 1 0 0 0 0 0 0 65 66 16 1 0 0 0 0 0 1 0 0 0 0 0 66 67 16 1 0 0 0 0 0 0 1 0 0 0 0 67 68 18 1 0 0 0 0 0 0 0 1 0 0 0 68 69 19 1 0 0 0 0 0 0 0 0 1 0 0 69 70 16 1 0 0 0 0 0 0 0 0 0 1 0 70 71 16 1 0 0 0 0 0 0 0 0 0 0 1 71 72 16 1 0 0 0 0 0 0 0 0 0 0 0 72 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X M1 M2 M3 M4 22.15000 -1.05000 -0.15000 1.40833 0.46667 -0.14167 M5 M6 M7 M8 M9 M10 0.09167 1.15000 0.37500 0.93333 -0.17500 -0.45000 M11 t -0.55833 -0.05833 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -2.45000 -1.18542 0.06667 0.93333 3.25000 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 22.15000 0.74571 29.703 < 2e-16 *** X -1.05000 0.71127 -1.476 0.14529 M1 -0.15000 0.90222 -0.166 0.86853 M2 1.40833 0.90083 1.563 0.12340 M3 0.46667 0.89975 0.519 0.60597 M4 -0.14167 0.89897 -0.158 0.87533 M5 0.09167 0.90370 0.101 0.91956 M6 1.15000 0.90170 1.275 0.20726 M7 0.37500 0.89999 0.417 0.67846 M8 0.93333 0.89860 1.039 0.30328 M9 -0.17500 0.89751 -0.195 0.84609 M10 -0.45000 0.89673 -0.502 0.61769 M11 -0.55833 0.89627 -0.623 0.53576 t -0.05833 0.01670 -3.493 0.00092 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.552 on 58 degrees of freedom Multiple R-squared: 0.6273, Adjusted R-squared: 0.5437 F-statistic: 7.509 on 13 and 58 DF, p-value: 2.188e-08 > 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.78796227 0.42407547 0.2120377 [2,] 0.74719252 0.50561496 0.2528075 [3,] 0.62185282 0.75629437 0.3781472 [4,] 0.50565577 0.98868847 0.4943442 [5,] 0.69208512 0.61582976 0.3079149 [6,] 0.63096996 0.73806008 0.3690300 [7,] 0.63898090 0.72203820 0.3610191 [8,] 0.56327581 0.87344839 0.4367242 [9,] 0.49778147 0.99556294 0.5022185 [10,] 0.47236785 0.94473569 0.5276322 [11,] 0.38694961 0.77389921 0.6130504 [12,] 0.44808537 0.89617075 0.5519146 [13,] 0.36472798 0.72945596 0.6352720 [14,] 0.30011435 0.60022869 0.6998857 [15,] 0.23247525 0.46495050 0.7675248 [16,] 0.18643501 0.37287002 0.8135650 [17,] 0.32052360 0.64104720 0.6794764 [18,] 0.29372371 0.58744743 0.7062763 [19,] 0.23105203 0.46210407 0.7689480 [20,] 0.18382270 0.36764540 0.8161773 [21,] 0.13777577 0.27555154 0.8622242 [22,] 0.09696070 0.19392141 0.9030393 [23,] 0.06648899 0.13297799 0.9335110 [24,] 0.07611474 0.15222947 0.9238853 [25,] 0.05940448 0.11880897 0.9405955 [26,] 0.06182113 0.12364226 0.9381789 [27,] 0.04192001 0.08384001 0.9580800 [28,] 0.09284948 0.18569895 0.9071505 [29,] 0.54513722 0.90972556 0.4548628 [30,] 0.80201954 0.39596092 0.1979805 [31,] 0.82450909 0.35098182 0.1754909 [32,] 0.76185777 0.47628446 0.2381422 [33,] 0.69688021 0.60623958 0.3031198 [34,] 0.60943129 0.78113742 0.3905687 [35,] 0.74660413 0.50679175 0.2533959 [36,] 0.67987860 0.64024280 0.3201214 [37,] 0.59434075 0.81131850 0.4056593 [38,] 0.53137802 0.93724396 0.4686220 [39,] 0.45715732 0.91431463 0.5428427 > postscript(file="/var/www/html/rcomp/tmp/1zjsn1258726607.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/213t31258726607.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/3jzt01258726607.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/43jry1258726607.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/5tggo1258726607.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 = 72 Frequency = 1 1 2 3 4 5 5.833333e-02 -1.441667e+00 -2.441667e+00 -7.750000e-01 -1.950000e+00 6 7 8 9 10 -1.950000e+00 -1.116667e+00 -1.616667e+00 -2.450000e+00 -1.166667e-01 11 12 13 14 15 5.000000e-02 5.500000e-01 -2.241667e+00 1.258333e+00 2.583333e-01 16 17 18 19 20 9.250000e-01 7.500000e-01 1.750000e+00 5.833333e-01 1.083333e+00 21 22 23 24 25 3.250000e+00 5.833333e-01 -2.500000e-01 1.250000e+00 2.458333e+00 26 27 28 29 30 9.583333e-01 9.583333e-01 -3.750000e-01 1.500000e+00 5.000000e-01 31 32 33 34 35 3.333333e-01 -1.666667e-01 -2.000000e+00 -6.666667e-01 5.000000e-01 36 37 38 39 40 -2.556115e-15 1.208333e+00 7.083333e-01 7.083333e-01 2.375000e+00 41 42 43 44 45 2.000000e-01 2.200000e+00 1.033333e+00 -1.466667e+00 -2.300000e+00 46 47 48 49 50 -9.666667e-01 2.000000e-01 7.000000e-01 -9.166667e-02 4.083333e-01 51 52 53 54 55 2.408333e+00 7.500000e-02 9.000000e-01 -1.000000e-01 7.333333e-01 56 57 58 59 60 2.233333e+00 1.400000e+00 1.733333e+00 -1.000000e-01 -1.600000e+00 61 62 63 64 65 -1.391667e+00 -1.891667e+00 -1.891667e+00 -2.225000e+00 -1.400000e+00 66 67 68 69 70 -2.400000e+00 -1.566667e+00 -6.666667e-02 2.100000e+00 -5.666667e-01 71 72 -4.000000e-01 -9.000000e-01 > postscript(file="/var/www/html/rcomp/tmp/6obl51258726607.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 = 72 Frequency = 1 lag(myerror, k = 1) myerror 0 5.833333e-02 NA 1 -1.441667e+00 5.833333e-02 2 -2.441667e+00 -1.441667e+00 3 -7.750000e-01 -2.441667e+00 4 -1.950000e+00 -7.750000e-01 5 -1.950000e+00 -1.950000e+00 6 -1.116667e+00 -1.950000e+00 7 -1.616667e+00 -1.116667e+00 8 -2.450000e+00 -1.616667e+00 9 -1.166667e-01 -2.450000e+00 10 5.000000e-02 -1.166667e-01 11 5.500000e-01 5.000000e-02 12 -2.241667e+00 5.500000e-01 13 1.258333e+00 -2.241667e+00 14 2.583333e-01 1.258333e+00 15 9.250000e-01 2.583333e-01 16 7.500000e-01 9.250000e-01 17 1.750000e+00 7.500000e-01 18 5.833333e-01 1.750000e+00 19 1.083333e+00 5.833333e-01 20 3.250000e+00 1.083333e+00 21 5.833333e-01 3.250000e+00 22 -2.500000e-01 5.833333e-01 23 1.250000e+00 -2.500000e-01 24 2.458333e+00 1.250000e+00 25 9.583333e-01 2.458333e+00 26 9.583333e-01 9.583333e-01 27 -3.750000e-01 9.583333e-01 28 1.500000e+00 -3.750000e-01 29 5.000000e-01 1.500000e+00 30 3.333333e-01 5.000000e-01 31 -1.666667e-01 3.333333e-01 32 -2.000000e+00 -1.666667e-01 33 -6.666667e-01 -2.000000e+00 34 5.000000e-01 -6.666667e-01 35 -2.556115e-15 5.000000e-01 36 1.208333e+00 -2.556115e-15 37 7.083333e-01 1.208333e+00 38 7.083333e-01 7.083333e-01 39 2.375000e+00 7.083333e-01 40 2.000000e-01 2.375000e+00 41 2.200000e+00 2.000000e-01 42 1.033333e+00 2.200000e+00 43 -1.466667e+00 1.033333e+00 44 -2.300000e+00 -1.466667e+00 45 -9.666667e-01 -2.300000e+00 46 2.000000e-01 -9.666667e-01 47 7.000000e-01 2.000000e-01 48 -9.166667e-02 7.000000e-01 49 4.083333e-01 -9.166667e-02 50 2.408333e+00 4.083333e-01 51 7.500000e-02 2.408333e+00 52 9.000000e-01 7.500000e-02 53 -1.000000e-01 9.000000e-01 54 7.333333e-01 -1.000000e-01 55 2.233333e+00 7.333333e-01 56 1.400000e+00 2.233333e+00 57 1.733333e+00 1.400000e+00 58 -1.000000e-01 1.733333e+00 59 -1.600000e+00 -1.000000e-01 60 -1.391667e+00 -1.600000e+00 61 -1.891667e+00 -1.391667e+00 62 -1.891667e+00 -1.891667e+00 63 -2.225000e+00 -1.891667e+00 64 -1.400000e+00 -2.225000e+00 65 -2.400000e+00 -1.400000e+00 66 -1.566667e+00 -2.400000e+00 67 -6.666667e-02 -1.566667e+00 68 2.100000e+00 -6.666667e-02 69 -5.666667e-01 2.100000e+00 70 -4.000000e-01 -5.666667e-01 71 -9.000000e-01 -4.000000e-01 72 NA -9.000000e-01 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -1.441667e+00 5.833333e-02 [2,] -2.441667e+00 -1.441667e+00 [3,] -7.750000e-01 -2.441667e+00 [4,] -1.950000e+00 -7.750000e-01 [5,] -1.950000e+00 -1.950000e+00 [6,] -1.116667e+00 -1.950000e+00 [7,] -1.616667e+00 -1.116667e+00 [8,] -2.450000e+00 -1.616667e+00 [9,] -1.166667e-01 -2.450000e+00 [10,] 5.000000e-02 -1.166667e-01 [11,] 5.500000e-01 5.000000e-02 [12,] -2.241667e+00 5.500000e-01 [13,] 1.258333e+00 -2.241667e+00 [14,] 2.583333e-01 1.258333e+00 [15,] 9.250000e-01 2.583333e-01 [16,] 7.500000e-01 9.250000e-01 [17,] 1.750000e+00 7.500000e-01 [18,] 5.833333e-01 1.750000e+00 [19,] 1.083333e+00 5.833333e-01 [20,] 3.250000e+00 1.083333e+00 [21,] 5.833333e-01 3.250000e+00 [22,] -2.500000e-01 5.833333e-01 [23,] 1.250000e+00 -2.500000e-01 [24,] 2.458333e+00 1.250000e+00 [25,] 9.583333e-01 2.458333e+00 [26,] 9.583333e-01 9.583333e-01 [27,] -3.750000e-01 9.583333e-01 [28,] 1.500000e+00 -3.750000e-01 [29,] 5.000000e-01 1.500000e+00 [30,] 3.333333e-01 5.000000e-01 [31,] -1.666667e-01 3.333333e-01 [32,] -2.000000e+00 -1.666667e-01 [33,] -6.666667e-01 -2.000000e+00 [34,] 5.000000e-01 -6.666667e-01 [35,] -2.556115e-15 5.000000e-01 [36,] 1.208333e+00 -2.556115e-15 [37,] 7.083333e-01 1.208333e+00 [38,] 7.083333e-01 7.083333e-01 [39,] 2.375000e+00 7.083333e-01 [40,] 2.000000e-01 2.375000e+00 [41,] 2.200000e+00 2.000000e-01 [42,] 1.033333e+00 2.200000e+00 [43,] -1.466667e+00 1.033333e+00 [44,] -2.300000e+00 -1.466667e+00 [45,] -9.666667e-01 -2.300000e+00 [46,] 2.000000e-01 -9.666667e-01 [47,] 7.000000e-01 2.000000e-01 [48,] -9.166667e-02 7.000000e-01 [49,] 4.083333e-01 -9.166667e-02 [50,] 2.408333e+00 4.083333e-01 [51,] 7.500000e-02 2.408333e+00 [52,] 9.000000e-01 7.500000e-02 [53,] -1.000000e-01 9.000000e-01 [54,] 7.333333e-01 -1.000000e-01 [55,] 2.233333e+00 7.333333e-01 [56,] 1.400000e+00 2.233333e+00 [57,] 1.733333e+00 1.400000e+00 [58,] -1.000000e-01 1.733333e+00 [59,] -1.600000e+00 -1.000000e-01 [60,] -1.391667e+00 -1.600000e+00 [61,] -1.891667e+00 -1.391667e+00 [62,] -1.891667e+00 -1.891667e+00 [63,] -2.225000e+00 -1.891667e+00 [64,] -1.400000e+00 -2.225000e+00 [65,] -2.400000e+00 -1.400000e+00 [66,] -1.566667e+00 -2.400000e+00 [67,] -6.666667e-02 -1.566667e+00 [68,] 2.100000e+00 -6.666667e-02 [69,] -5.666667e-01 2.100000e+00 [70,] -4.000000e-01 -5.666667e-01 [71,] -9.000000e-01 -4.000000e-01 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -1.441667e+00 5.833333e-02 2 -2.441667e+00 -1.441667e+00 3 -7.750000e-01 -2.441667e+00 4 -1.950000e+00 -7.750000e-01 5 -1.950000e+00 -1.950000e+00 6 -1.116667e+00 -1.950000e+00 7 -1.616667e+00 -1.116667e+00 8 -2.450000e+00 -1.616667e+00 9 -1.166667e-01 -2.450000e+00 10 5.000000e-02 -1.166667e-01 11 5.500000e-01 5.000000e-02 12 -2.241667e+00 5.500000e-01 13 1.258333e+00 -2.241667e+00 14 2.583333e-01 1.258333e+00 15 9.250000e-01 2.583333e-01 16 7.500000e-01 9.250000e-01 17 1.750000e+00 7.500000e-01 18 5.833333e-01 1.750000e+00 19 1.083333e+00 5.833333e-01 20 3.250000e+00 1.083333e+00 21 5.833333e-01 3.250000e+00 22 -2.500000e-01 5.833333e-01 23 1.250000e+00 -2.500000e-01 24 2.458333e+00 1.250000e+00 25 9.583333e-01 2.458333e+00 26 9.583333e-01 9.583333e-01 27 -3.750000e-01 9.583333e-01 28 1.500000e+00 -3.750000e-01 29 5.000000e-01 1.500000e+00 30 3.333333e-01 5.000000e-01 31 -1.666667e-01 3.333333e-01 32 -2.000000e+00 -1.666667e-01 33 -6.666667e-01 -2.000000e+00 34 5.000000e-01 -6.666667e-01 35 -2.556115e-15 5.000000e-01 36 1.208333e+00 -2.556115e-15 37 7.083333e-01 1.208333e+00 38 7.083333e-01 7.083333e-01 39 2.375000e+00 7.083333e-01 40 2.000000e-01 2.375000e+00 41 2.200000e+00 2.000000e-01 42 1.033333e+00 2.200000e+00 43 -1.466667e+00 1.033333e+00 44 -2.300000e+00 -1.466667e+00 45 -9.666667e-01 -2.300000e+00 46 2.000000e-01 -9.666667e-01 47 7.000000e-01 2.000000e-01 48 -9.166667e-02 7.000000e-01 49 4.083333e-01 -9.166667e-02 50 2.408333e+00 4.083333e-01 51 7.500000e-02 2.408333e+00 52 9.000000e-01 7.500000e-02 53 -1.000000e-01 9.000000e-01 54 7.333333e-01 -1.000000e-01 55 2.233333e+00 7.333333e-01 56 1.400000e+00 2.233333e+00 57 1.733333e+00 1.400000e+00 58 -1.000000e-01 1.733333e+00 59 -1.600000e+00 -1.000000e-01 60 -1.391667e+00 -1.600000e+00 61 -1.891667e+00 -1.391667e+00 62 -1.891667e+00 -1.891667e+00 63 -2.225000e+00 -1.891667e+00 64 -1.400000e+00 -2.225000e+00 65 -2.400000e+00 -1.400000e+00 66 -1.566667e+00 -2.400000e+00 67 -6.666667e-02 -1.566667e+00 68 2.100000e+00 -6.666667e-02 69 -5.666667e-01 2.100000e+00 70 -4.000000e-01 -5.666667e-01 71 -9.000000e-01 -4.000000e-01 > 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/7sga01258726607.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/8y7ql1258726607.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/9baok1258726607.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/10oxey1258726607.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/115eot1258726607.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/12m1ux1258726607.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/13xz2a1258726608.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/140obu1258726608.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/151gu61258726608.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/16e5q21258726608.tab") + } > system("convert tmp/1zjsn1258726607.ps tmp/1zjsn1258726607.png") > system("convert tmp/213t31258726607.ps tmp/213t31258726607.png") > system("convert tmp/3jzt01258726607.ps tmp/3jzt01258726607.png") > system("convert tmp/43jry1258726607.ps tmp/43jry1258726607.png") > system("convert tmp/5tggo1258726607.ps tmp/5tggo1258726607.png") > system("convert tmp/6obl51258726607.ps tmp/6obl51258726607.png") > system("convert tmp/7sga01258726607.ps tmp/7sga01258726607.png") > system("convert tmp/8y7ql1258726607.ps tmp/8y7ql1258726607.png") > system("convert tmp/9baok1258726607.ps tmp/9baok1258726607.png") > system("convert tmp/10oxey1258726607.ps tmp/10oxey1258726607.png") > > > proc.time() user system elapsed 2.502 1.615 3.478