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(110.3 + ,0 + ,114.1 + ,96.8 + ,87.4 + ,111.4 + ,103.9 + ,0 + ,110.3 + ,114.1 + ,96.8 + ,87.4 + ,101.6 + ,0 + ,103.9 + ,110.3 + ,114.1 + ,96.8 + ,94.6 + ,0 + ,101.6 + ,103.9 + ,110.3 + ,114.1 + ,95.9 + ,0 + ,94.6 + ,101.6 + ,103.9 + ,110.3 + ,104.7 + ,0 + ,95.9 + ,94.6 + ,101.6 + ,103.9 + ,102.8 + ,0 + ,104.7 + ,95.9 + ,94.6 + ,101.6 + ,98.1 + ,0 + ,102.8 + ,104.7 + ,95.9 + ,94.6 + ,113.9 + ,0 + ,98.1 + ,102.8 + ,104.7 + ,95.9 + ,80.9 + ,0 + ,113.9 + ,98.1 + ,102.8 + ,104.7 + ,95.7 + ,0 + ,80.9 + ,113.9 + ,98.1 + ,102.8 + ,113.2 + ,0 + ,95.7 + ,80.9 + ,113.9 + ,98.1 + ,105.9 + ,0 + ,113.2 + ,95.7 + ,80.9 + ,113.9 + ,108.8 + ,0 + ,105.9 + ,113.2 + ,95.7 + ,80.9 + ,102.3 + ,0 + ,108.8 + ,105.9 + ,113.2 + ,95.7 + ,99 + ,0 + ,102.3 + ,108.8 + ,105.9 + ,113.2 + ,100.7 + ,0 + ,99 + ,102.3 + ,108.8 + ,105.9 + ,115.5 + ,0 + ,100.7 + ,99 + ,102.3 + ,108.8 + ,100.7 + ,0 + ,115.5 + ,100.7 + ,99 + ,102.3 + ,109.9 + ,0 + ,100.7 + ,115.5 + ,100.7 + ,99 + ,114.6 + ,0 + ,109.9 + ,100.7 + ,115.5 + ,100.7 + ,85.4 + ,0 + ,114.6 + ,109.9 + ,100.7 + ,115.5 + ,100.5 + ,0 + ,85.4 + ,114.6 + ,109.9 + ,100.7 + ,114.8 + ,0 + ,100.5 + ,85.4 + ,114.6 + ,109.9 + ,116.5 + ,0 + ,114.8 + ,100.5 + ,85.4 + ,114.6 + ,112.9 + ,0 + ,116.5 + ,114.8 + ,100.5 + ,85.4 + ,102 + ,0 + ,112.9 + ,116.5 + ,114.8 + ,100.5 + ,106 + ,0 + ,102 + ,112.9 + ,116.5 + ,114.8 + ,105.3 + ,0 + ,106 + ,102 + ,112.9 + ,116.5 + ,118.8 + ,0 + ,105.3 + ,106 + ,102 + ,112.9 + ,106.1 + ,0 + ,118.8 + ,105.3 + ,106 + ,102 + ,109.3 + ,0 + ,106.1 + ,118.8 + ,105.3 + ,106 + ,117.2 + ,0 + ,109.3 + ,106.1 + ,118.8 + ,105.3 + ,92.5 + ,0 + ,117.2 + ,109.3 + ,106.1 + ,118.8 + ,104.2 + ,0 + ,92.5 + ,117.2 + ,109.3 + ,106.1 + ,112.5 + ,0 + ,104.2 + ,92.5 + ,117.2 + ,109.3 + ,122.4 + ,0 + ,112.5 + ,104.2 + ,92.5 + ,117.2 + ,113.3 + ,0 + ,122.4 + ,112.5 + ,104.2 + ,92.5 + ,100 + ,0 + ,113.3 + ,122.4 + ,112.5 + ,104.2 + ,110.7 + ,0 + ,100 + ,113.3 + ,122.4 + ,112.5 + ,112.8 + ,0 + ,110.7 + ,100 + ,113.3 + ,122.4 + ,109.8 + ,0 + ,112.8 + ,110.7 + ,100 + ,113.3 + ,117.3 + ,0 + ,109.8 + ,112.8 + ,110.7 + ,100 + ,109.1 + ,0 + ,117.3 + ,109.8 + ,112.8 + ,110.7 + ,115.9 + ,0 + ,109.1 + ,117.3 + ,109.8 + ,112.8 + ,96 + ,0 + ,115.9 + ,109.1 + ,117.3 + ,109.8 + ,99.8 + ,0 + ,96 + ,115.9 + ,109.1 + ,117.3 + ,116.8 + ,1 + ,99.8 + ,96 + ,115.9 + ,109.1 + ,115.7 + ,1 + ,116.8 + ,99.8 + ,96 + ,115.9 + ,99.4 + ,1 + ,115.7 + ,116.8 + ,99.8 + ,96 + ,94.3 + ,1 + ,99.4 + ,115.7 + ,116.8 + ,99.8 + ,91 + ,1 + ,94.3 + ,99.4 + ,115.7 + ,116.8 + ,93.2 + ,1 + ,91 + ,94.3 + ,99.4 + ,115.7 + ,103.1 + ,1 + ,93.2 + ,91 + ,94.3 + ,99.4 + ,94.1 + ,1 + ,103.1 + ,93.2 + ,91 + ,94.3 + ,91.8 + ,1 + ,94.1 + ,103.1 + ,93.2 + ,91 + ,102.7 + ,1 + ,91.8 + ,94.1 + ,103.1 + ,93.2) + ,dim=c(6 + ,57) + ,dimnames=list(c('Y' + ,'X' + ,'Y1' + ,'Y2' + ,'Y3' + ,'Y4') + ,1:57)) > y <- array(NA,dim=c(6,57),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),1:57)) > 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 Y1 Y2 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 110.3 0 114.1 96.8 87.4 111.4 1 0 0 0 0 0 0 0 0 0 0 1 2 103.9 0 110.3 114.1 96.8 87.4 0 1 0 0 0 0 0 0 0 0 0 2 3 101.6 0 103.9 110.3 114.1 96.8 0 0 1 0 0 0 0 0 0 0 0 3 4 94.6 0 101.6 103.9 110.3 114.1 0 0 0 1 0 0 0 0 0 0 0 4 5 95.9 0 94.6 101.6 103.9 110.3 0 0 0 0 1 0 0 0 0 0 0 5 6 104.7 0 95.9 94.6 101.6 103.9 0 0 0 0 0 1 0 0 0 0 0 6 7 102.8 0 104.7 95.9 94.6 101.6 0 0 0 0 0 0 1 0 0 0 0 7 8 98.1 0 102.8 104.7 95.9 94.6 0 0 0 0 0 0 0 1 0 0 0 8 9 113.9 0 98.1 102.8 104.7 95.9 0 0 0 0 0 0 0 0 1 0 0 9 10 80.9 0 113.9 98.1 102.8 104.7 0 0 0 0 0 0 0 0 0 1 0 10 11 95.7 0 80.9 113.9 98.1 102.8 0 0 0 0 0 0 0 0 0 0 1 11 12 113.2 0 95.7 80.9 113.9 98.1 0 0 0 0 0 0 0 0 0 0 0 12 13 105.9 0 113.2 95.7 80.9 113.9 1 0 0 0 0 0 0 0 0 0 0 13 14 108.8 0 105.9 113.2 95.7 80.9 0 1 0 0 0 0 0 0 0 0 0 14 15 102.3 0 108.8 105.9 113.2 95.7 0 0 1 0 0 0 0 0 0 0 0 15 16 99.0 0 102.3 108.8 105.9 113.2 0 0 0 1 0 0 0 0 0 0 0 16 17 100.7 0 99.0 102.3 108.8 105.9 0 0 0 0 1 0 0 0 0 0 0 17 18 115.5 0 100.7 99.0 102.3 108.8 0 0 0 0 0 1 0 0 0 0 0 18 19 100.7 0 115.5 100.7 99.0 102.3 0 0 0 0 0 0 1 0 0 0 0 19 20 109.9 0 100.7 115.5 100.7 99.0 0 0 0 0 0 0 0 1 0 0 0 20 21 114.6 0 109.9 100.7 115.5 100.7 0 0 0 0 0 0 0 0 1 0 0 21 22 85.4 0 114.6 109.9 100.7 115.5 0 0 0 0 0 0 0 0 0 1 0 22 23 100.5 0 85.4 114.6 109.9 100.7 0 0 0 0 0 0 0 0 0 0 1 23 24 114.8 0 100.5 85.4 114.6 109.9 0 0 0 0 0 0 0 0 0 0 0 24 25 116.5 0 114.8 100.5 85.4 114.6 1 0 0 0 0 0 0 0 0 0 0 25 26 112.9 0 116.5 114.8 100.5 85.4 0 1 0 0 0 0 0 0 0 0 0 26 27 102.0 0 112.9 116.5 114.8 100.5 0 0 1 0 0 0 0 0 0 0 0 27 28 106.0 0 102.0 112.9 116.5 114.8 0 0 0 1 0 0 0 0 0 0 0 28 29 105.3 0 106.0 102.0 112.9 116.5 0 0 0 0 1 0 0 0 0 0 0 29 30 118.8 0 105.3 106.0 102.0 112.9 0 0 0 0 0 1 0 0 0 0 0 30 31 106.1 0 118.8 105.3 106.0 102.0 0 0 0 0 0 0 1 0 0 0 0 31 32 109.3 0 106.1 118.8 105.3 106.0 0 0 0 0 0 0 0 1 0 0 0 32 33 117.2 0 109.3 106.1 118.8 105.3 0 0 0 0 0 0 0 0 1 0 0 33 34 92.5 0 117.2 109.3 106.1 118.8 0 0 0 0 0 0 0 0 0 1 0 34 35 104.2 0 92.5 117.2 109.3 106.1 0 0 0 0 0 0 0 0 0 0 1 35 36 112.5 0 104.2 92.5 117.2 109.3 0 0 0 0 0 0 0 0 0 0 0 36 37 122.4 0 112.5 104.2 92.5 117.2 1 0 0 0 0 0 0 0 0 0 0 37 38 113.3 0 122.4 112.5 104.2 92.5 0 1 0 0 0 0 0 0 0 0 0 38 39 100.0 0 113.3 122.4 112.5 104.2 0 0 1 0 0 0 0 0 0 0 0 39 40 110.7 0 100.0 113.3 122.4 112.5 0 0 0 1 0 0 0 0 0 0 0 40 41 112.8 0 110.7 100.0 113.3 122.4 0 0 0 0 1 0 0 0 0 0 0 41 42 109.8 0 112.8 110.7 100.0 113.3 0 0 0 0 0 1 0 0 0 0 0 42 43 117.3 0 109.8 112.8 110.7 100.0 0 0 0 0 0 0 1 0 0 0 0 43 44 109.1 0 117.3 109.8 112.8 110.7 0 0 0 0 0 0 0 1 0 0 0 44 45 115.9 0 109.1 117.3 109.8 112.8 0 0 0 0 0 0 0 0 1 0 0 45 46 96.0 0 115.9 109.1 117.3 109.8 0 0 0 0 0 0 0 0 0 1 0 46 47 99.8 0 96.0 115.9 109.1 117.3 0 0 0 0 0 0 0 0 0 0 1 47 48 116.8 1 99.8 96.0 115.9 109.1 0 0 0 0 0 0 0 0 0 0 0 48 49 115.7 1 116.8 99.8 96.0 115.9 1 0 0 0 0 0 0 0 0 0 0 49 50 99.4 1 115.7 116.8 99.8 96.0 0 1 0 0 0 0 0 0 0 0 0 50 51 94.3 1 99.4 115.7 116.8 99.8 0 0 1 0 0 0 0 0 0 0 0 51 52 91.0 1 94.3 99.4 115.7 116.8 0 0 0 1 0 0 0 0 0 0 0 52 53 93.2 1 91.0 94.3 99.4 115.7 0 0 0 0 1 0 0 0 0 0 0 53 54 103.1 1 93.2 91.0 94.3 99.4 0 0 0 0 0 1 0 0 0 0 0 54 55 94.1 1 103.1 93.2 91.0 94.3 0 0 0 0 0 0 1 0 0 0 0 55 56 91.8 1 94.1 103.1 93.2 91.0 0 0 0 0 0 0 0 1 0 0 0 56 57 102.7 1 91.8 94.1 103.1 93.2 0 0 0 0 0 0 0 0 1 0 0 57 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X Y1 Y2 Y3 Y4 50.23629 -10.52653 -0.20206 0.23657 0.55483 -0.01605 M1 M2 M3 M4 M5 M6 15.34547 -1.32103 -18.42725 -18.02503 -11.37462 1.64235 M7 M8 M9 M10 M11 t -3.43736 -8.17797 -2.59168 -24.24410 -20.51069 0.12120 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -6.19962 -2.14538 -0.02515 1.78187 6.78224 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 50.23629 17.61386 2.852 0.006912 ** X -10.52653 2.79076 -3.772 0.000538 *** Y1 -0.20206 0.15602 -1.295 0.202908 Y2 0.23657 0.12068 1.960 0.057134 . Y3 0.55483 0.12180 4.555 5.04e-05 *** Y4 -0.01605 0.14937 -0.107 0.914974 M1 15.34547 5.05474 3.036 0.004259 ** M2 -1.32103 7.15049 -0.185 0.854385 M3 -18.42725 4.74728 -3.882 0.000389 *** M4 -18.02503 3.20633 -5.622 1.74e-06 *** M5 -11.37462 2.91686 -3.900 0.000369 *** M6 1.64235 3.43224 0.479 0.634961 M7 -3.43736 4.61157 -0.745 0.460512 M8 -8.17797 4.62210 -1.769 0.084660 . M9 -2.59168 3.50987 -0.738 0.464693 M10 -24.24410 4.06068 -5.970 5.69e-07 *** M11 -20.51069 4.35130 -4.714 3.08e-05 *** t 0.12120 0.05806 2.088 0.043413 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 3.496 on 39 degrees of freedom Multiple R-squared: 0.8973, Adjusted R-squared: 0.8525 F-statistic: 20.04 on 17 and 39 DF, p-value: 3.535e-14 > 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.72911085 0.5417783 0.2708892 [2,] 0.61002310 0.7799538 0.3899769 [3,] 0.50626941 0.9874612 0.4937306 [4,] 0.36091909 0.7218382 0.6390809 [5,] 0.25115540 0.5023108 0.7488446 [6,] 0.18946283 0.3789257 0.8105372 [7,] 0.21022214 0.4204443 0.7897779 [8,] 0.14518170 0.2903634 0.8548183 [9,] 0.14918484 0.2983697 0.8508152 [10,] 0.16090547 0.3218109 0.8390945 [11,] 0.15659737 0.3131947 0.8434026 [12,] 0.11023345 0.2204669 0.8897666 [13,] 0.11304187 0.2260837 0.8869581 [14,] 0.10558653 0.2111731 0.8944135 [15,] 0.05571122 0.1114224 0.9442888 [16,] 0.59968595 0.8006281 0.4003141 > postscript(file="/var/www/html/rcomp/tmp/1npqs1258736139.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/2t6yn1258736139.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/3ufig1258736139.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/4jmi91258736139.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/5rknp1258736139.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 = 57 Frequency = 1 1 2 3 4 5 6 -1.95205451 -2.26792661 2.57511680 -1.51293784 -4.36492689 -5.61104725 7 8 9 10 11 12 2.76498240 -0.61499108 4.11563460 -1.85325368 1.26352186 0.08711532 13 14 15 16 17 18 -4.08157075 1.00745761 4.33337973 2.84169797 -3.08520975 3.35377108 19 20 21 22 23 24 -2.17276198 4.15871009 0.32715620 -0.11926289 -1.22799203 -0.06096645 25 26 27 28 29 30 1.76623556 2.82538706 0.08906642 1.50114404 -0.55891971 4.70508854 31 32 33 34 35 36 -2.53727443 -0.02515278 -1.68311190 3.25046538 2.25670372 -6.19962367 37 38 39 40 41 42 0.97415802 1.56830165 -3.34479995 0.93751284 6.78224101 -4.22967834 43 44 45 46 47 48 0.97563499 -1.37318887 -2.01364915 -1.27794881 -2.29223355 6.17347480 49 50 51 52 53 54 3.29323168 -3.13321970 -3.65276300 -3.76741701 1.22681534 1.78186597 55 56 57 0.96941903 -2.14537736 -0.74602975 > postscript(file="/var/www/html/rcomp/tmp/6ayzs1258736139.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 = 57 Frequency = 1 lag(myerror, k = 1) myerror 0 -1.95205451 NA 1 -2.26792661 -1.95205451 2 2.57511680 -2.26792661 3 -1.51293784 2.57511680 4 -4.36492689 -1.51293784 5 -5.61104725 -4.36492689 6 2.76498240 -5.61104725 7 -0.61499108 2.76498240 8 4.11563460 -0.61499108 9 -1.85325368 4.11563460 10 1.26352186 -1.85325368 11 0.08711532 1.26352186 12 -4.08157075 0.08711532 13 1.00745761 -4.08157075 14 4.33337973 1.00745761 15 2.84169797 4.33337973 16 -3.08520975 2.84169797 17 3.35377108 -3.08520975 18 -2.17276198 3.35377108 19 4.15871009 -2.17276198 20 0.32715620 4.15871009 21 -0.11926289 0.32715620 22 -1.22799203 -0.11926289 23 -0.06096645 -1.22799203 24 1.76623556 -0.06096645 25 2.82538706 1.76623556 26 0.08906642 2.82538706 27 1.50114404 0.08906642 28 -0.55891971 1.50114404 29 4.70508854 -0.55891971 30 -2.53727443 4.70508854 31 -0.02515278 -2.53727443 32 -1.68311190 -0.02515278 33 3.25046538 -1.68311190 34 2.25670372 3.25046538 35 -6.19962367 2.25670372 36 0.97415802 -6.19962367 37 1.56830165 0.97415802 38 -3.34479995 1.56830165 39 0.93751284 -3.34479995 40 6.78224101 0.93751284 41 -4.22967834 6.78224101 42 0.97563499 -4.22967834 43 -1.37318887 0.97563499 44 -2.01364915 -1.37318887 45 -1.27794881 -2.01364915 46 -2.29223355 -1.27794881 47 6.17347480 -2.29223355 48 3.29323168 6.17347480 49 -3.13321970 3.29323168 50 -3.65276300 -3.13321970 51 -3.76741701 -3.65276300 52 1.22681534 -3.76741701 53 1.78186597 1.22681534 54 0.96941903 1.78186597 55 -2.14537736 0.96941903 56 -0.74602975 -2.14537736 57 NA -0.74602975 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -2.26792661 -1.95205451 [2,] 2.57511680 -2.26792661 [3,] -1.51293784 2.57511680 [4,] -4.36492689 -1.51293784 [5,] -5.61104725 -4.36492689 [6,] 2.76498240 -5.61104725 [7,] -0.61499108 2.76498240 [8,] 4.11563460 -0.61499108 [9,] -1.85325368 4.11563460 [10,] 1.26352186 -1.85325368 [11,] 0.08711532 1.26352186 [12,] -4.08157075 0.08711532 [13,] 1.00745761 -4.08157075 [14,] 4.33337973 1.00745761 [15,] 2.84169797 4.33337973 [16,] -3.08520975 2.84169797 [17,] 3.35377108 -3.08520975 [18,] -2.17276198 3.35377108 [19,] 4.15871009 -2.17276198 [20,] 0.32715620 4.15871009 [21,] -0.11926289 0.32715620 [22,] -1.22799203 -0.11926289 [23,] -0.06096645 -1.22799203 [24,] 1.76623556 -0.06096645 [25,] 2.82538706 1.76623556 [26,] 0.08906642 2.82538706 [27,] 1.50114404 0.08906642 [28,] -0.55891971 1.50114404 [29,] 4.70508854 -0.55891971 [30,] -2.53727443 4.70508854 [31,] -0.02515278 -2.53727443 [32,] -1.68311190 -0.02515278 [33,] 3.25046538 -1.68311190 [34,] 2.25670372 3.25046538 [35,] -6.19962367 2.25670372 [36,] 0.97415802 -6.19962367 [37,] 1.56830165 0.97415802 [38,] -3.34479995 1.56830165 [39,] 0.93751284 -3.34479995 [40,] 6.78224101 0.93751284 [41,] -4.22967834 6.78224101 [42,] 0.97563499 -4.22967834 [43,] -1.37318887 0.97563499 [44,] -2.01364915 -1.37318887 [45,] -1.27794881 -2.01364915 [46,] -2.29223355 -1.27794881 [47,] 6.17347480 -2.29223355 [48,] 3.29323168 6.17347480 [49,] -3.13321970 3.29323168 [50,] -3.65276300 -3.13321970 [51,] -3.76741701 -3.65276300 [52,] 1.22681534 -3.76741701 [53,] 1.78186597 1.22681534 [54,] 0.96941903 1.78186597 [55,] -2.14537736 0.96941903 [56,] -0.74602975 -2.14537736 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -2.26792661 -1.95205451 2 2.57511680 -2.26792661 3 -1.51293784 2.57511680 4 -4.36492689 -1.51293784 5 -5.61104725 -4.36492689 6 2.76498240 -5.61104725 7 -0.61499108 2.76498240 8 4.11563460 -0.61499108 9 -1.85325368 4.11563460 10 1.26352186 -1.85325368 11 0.08711532 1.26352186 12 -4.08157075 0.08711532 13 1.00745761 -4.08157075 14 4.33337973 1.00745761 15 2.84169797 4.33337973 16 -3.08520975 2.84169797 17 3.35377108 -3.08520975 18 -2.17276198 3.35377108 19 4.15871009 -2.17276198 20 0.32715620 4.15871009 21 -0.11926289 0.32715620 22 -1.22799203 -0.11926289 23 -0.06096645 -1.22799203 24 1.76623556 -0.06096645 25 2.82538706 1.76623556 26 0.08906642 2.82538706 27 1.50114404 0.08906642 28 -0.55891971 1.50114404 29 4.70508854 -0.55891971 30 -2.53727443 4.70508854 31 -0.02515278 -2.53727443 32 -1.68311190 -0.02515278 33 3.25046538 -1.68311190 34 2.25670372 3.25046538 35 -6.19962367 2.25670372 36 0.97415802 -6.19962367 37 1.56830165 0.97415802 38 -3.34479995 1.56830165 39 0.93751284 -3.34479995 40 6.78224101 0.93751284 41 -4.22967834 6.78224101 42 0.97563499 -4.22967834 43 -1.37318887 0.97563499 44 -2.01364915 -1.37318887 45 -1.27794881 -2.01364915 46 -2.29223355 -1.27794881 47 6.17347480 -2.29223355 48 3.29323168 6.17347480 49 -3.13321970 3.29323168 50 -3.65276300 -3.13321970 51 -3.76741701 -3.65276300 52 1.22681534 -3.76741701 53 1.78186597 1.22681534 54 0.96941903 1.78186597 55 -2.14537736 0.96941903 56 -0.74602975 -2.14537736 > 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/7yec91258736139.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/87gkz1258736139.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/99xjd1258736139.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/10jbut1258736139.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/11jyhw1258736139.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/128sn21258736139.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/13wrw51258736139.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/14c3881258736139.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/154kk71258736139.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/16159d1258736139.tab") + } > > system("convert tmp/1npqs1258736139.ps tmp/1npqs1258736139.png") > system("convert tmp/2t6yn1258736139.ps tmp/2t6yn1258736139.png") > system("convert tmp/3ufig1258736139.ps tmp/3ufig1258736139.png") > system("convert tmp/4jmi91258736139.ps tmp/4jmi91258736139.png") > system("convert tmp/5rknp1258736139.ps tmp/5rknp1258736139.png") > system("convert tmp/6ayzs1258736139.ps tmp/6ayzs1258736139.png") > system("convert tmp/7yec91258736139.ps tmp/7yec91258736139.png") > system("convert tmp/87gkz1258736139.ps tmp/87gkz1258736139.png") > system("convert tmp/99xjd1258736139.ps tmp/99xjd1258736139.png") > system("convert tmp/10jbut1258736139.ps tmp/10jbut1258736139.png") > > > proc.time() user system elapsed 2.404 1.592 5.507