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(20.3,3016,20,2155,19.2,2172,21.8,2150,21.3,2533,21.5,2058,19.5,2160,19.5,2260,19.7,2498,18.7,2695,19.7,2799,20,2946,19.7,2930,19.2,2318,19.7,2540,22,2570,21.8,2669,22.8,2450,21,2842,25,3440,23.3,2678,25,2981,26.8,2260,25.3,2844,26.5,2546,27.8,2456,22,2295,22.3,2379,28,2479,25,2057,27.3,2280,25.8,2351,27.3,2276,23.5,2548,24.5,2311,18,2201,21.3,2725,21.8,2408,20.5,2139,22.3,1898,18.7,2537,22.3,2068,17.7,2063,19.7,2520,20.5,2434,18.5,2190,10,2794,14.2,2070,15.5,2615,16.5,2265,20.5,2139,15.7,2428,11.7,2137,7.5,1823,3.5,2063,4.5,1806,2.2,1758,5,2243,2.3,1993,6.1,1932,3.3,2465),dim=c(2,61),dimnames=list(c('Y','X'),1:61)) > y <- array(NA,dim=c(2,61),dimnames=list(c('Y','X'),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 = '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 20.3 3016 1 0 0 0 0 0 0 0 0 0 0 1 2 20.0 2155 0 1 0 0 0 0 0 0 0 0 0 2 3 19.2 2172 0 0 1 0 0 0 0 0 0 0 0 3 4 21.8 2150 0 0 0 1 0 0 0 0 0 0 0 4 5 21.3 2533 0 0 0 0 1 0 0 0 0 0 0 5 6 21.5 2058 0 0 0 0 0 1 0 0 0 0 0 6 7 19.5 2160 0 0 0 0 0 0 1 0 0 0 0 7 8 19.5 2260 0 0 0 0 0 0 0 1 0 0 0 8 9 19.7 2498 0 0 0 0 0 0 0 0 1 0 0 9 10 18.7 2695 0 0 0 0 0 0 0 0 0 1 0 10 11 19.7 2799 0 0 0 0 0 0 0 0 0 0 1 11 12 20.0 2946 0 0 0 0 0 0 0 0 0 0 0 12 13 19.7 2930 1 0 0 0 0 0 0 0 0 0 0 13 14 19.2 2318 0 1 0 0 0 0 0 0 0 0 0 14 15 19.7 2540 0 0 1 0 0 0 0 0 0 0 0 15 16 22.0 2570 0 0 0 1 0 0 0 0 0 0 0 16 17 21.8 2669 0 0 0 0 1 0 0 0 0 0 0 17 18 22.8 2450 0 0 0 0 0 1 0 0 0 0 0 18 19 21.0 2842 0 0 0 0 0 0 1 0 0 0 0 19 20 25.0 3440 0 0 0 0 0 0 0 1 0 0 0 20 21 23.3 2678 0 0 0 0 0 0 0 0 1 0 0 21 22 25.0 2981 0 0 0 0 0 0 0 0 0 1 0 22 23 26.8 2260 0 0 0 0 0 0 0 0 0 0 1 23 24 25.3 2844 0 0 0 0 0 0 0 0 0 0 0 24 25 26.5 2546 1 0 0 0 0 0 0 0 0 0 0 25 26 27.8 2456 0 1 0 0 0 0 0 0 0 0 0 26 27 22.0 2295 0 0 1 0 0 0 0 0 0 0 0 27 28 22.3 2379 0 0 0 1 0 0 0 0 0 0 0 28 29 28.0 2479 0 0 0 0 1 0 0 0 0 0 0 29 30 25.0 2057 0 0 0 0 0 1 0 0 0 0 0 30 31 27.3 2280 0 0 0 0 0 0 1 0 0 0 0 31 32 25.8 2351 0 0 0 0 0 0 0 1 0 0 0 32 33 27.3 2276 0 0 0 0 0 0 0 0 1 0 0 33 34 23.5 2548 0 0 0 0 0 0 0 0 0 1 0 34 35 24.5 2311 0 0 0 0 0 0 0 0 0 0 1 35 36 18.0 2201 0 0 0 0 0 0 0 0 0 0 0 36 37 21.3 2725 1 0 0 0 0 0 0 0 0 0 0 37 38 21.8 2408 0 1 0 0 0 0 0 0 0 0 0 38 39 20.5 2139 0 0 1 0 0 0 0 0 0 0 0 39 40 22.3 1898 0 0 0 1 0 0 0 0 0 0 0 40 41 18.7 2537 0 0 0 0 1 0 0 0 0 0 0 41 42 22.3 2068 0 0 0 0 0 1 0 0 0 0 0 42 43 17.7 2063 0 0 0 0 0 0 1 0 0 0 0 43 44 19.7 2520 0 0 0 0 0 0 0 1 0 0 0 44 45 20.5 2434 0 0 0 0 0 0 0 0 1 0 0 45 46 18.5 2190 0 0 0 0 0 0 0 0 0 1 0 46 47 10.0 2794 0 0 0 0 0 0 0 0 0 0 1 47 48 14.2 2070 0 0 0 0 0 0 0 0 0 0 0 48 49 15.5 2615 1 0 0 0 0 0 0 0 0 0 0 49 50 16.5 2265 0 1 0 0 0 0 0 0 0 0 0 50 51 20.5 2139 0 0 1 0 0 0 0 0 0 0 0 51 52 15.7 2428 0 0 0 1 0 0 0 0 0 0 0 52 53 11.7 2137 0 0 0 0 1 0 0 0 0 0 0 53 54 7.5 1823 0 0 0 0 0 1 0 0 0 0 0 54 55 3.5 2063 0 0 0 0 0 0 1 0 0 0 0 55 56 4.5 1806 0 0 0 0 0 0 0 1 0 0 0 56 57 2.2 1758 0 0 0 0 0 0 0 0 1 0 0 57 58 5.0 2243 0 0 0 0 0 0 0 0 0 1 0 58 59 2.3 1993 0 0 0 0 0 0 0 0 0 0 1 59 60 6.1 1932 0 0 0 0 0 0 0 0 0 0 0 60 61 3.3 2465 1 0 0 0 0 0 0 0 0 0 0 61 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X M1 M2 M3 M4 7.229534 0.006485 -1.854800 3.162772 3.062330 3.489193 M5 M6 M7 M8 M9 M10 1.931484 4.082780 0.996539 1.008249 1.827329 0.221975 M11 t -0.441129 -0.168433 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -8.840 -3.866 -1.368 3.671 9.510 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 7.229534 8.554042 0.845 0.40230 X 0.006485 0.002947 2.201 0.03270 * M1 -1.854800 3.524316 -0.526 0.60116 M2 3.162772 3.636444 0.870 0.38886 M3 3.062330 3.657280 0.837 0.40665 M4 3.489193 3.635122 0.960 0.34204 M5 1.931484 3.589874 0.538 0.59309 M6 4.082780 3.741828 1.091 0.28078 M7 0.996539 3.615776 0.276 0.78406 M8 1.008249 3.583742 0.281 0.77968 M9 1.827329 3.591465 0.509 0.61327 M10 0.221975 3.594739 0.062 0.95102 M11 -0.441129 3.578791 -0.123 0.90243 t -0.168433 0.049605 -3.395 0.00140 ** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 5.657 on 47 degrees of freedom Multiple R-squared: 0.4513, Adjusted R-squared: 0.2995 F-statistic: 2.973 on 13 and 47 DF, p-value: 0.003084 > 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,] 1.082140e-03 2.164279e-03 0.9989179 [2,] 2.690984e-04 5.381969e-04 0.9997309 [3,] 3.044990e-05 6.089980e-05 0.9999696 [4,] 3.460766e-05 6.921533e-05 0.9999654 [5,] 6.196790e-04 1.239358e-03 0.9993803 [6,] 6.704508e-03 1.340902e-02 0.9932955 [7,] 2.707253e-02 5.414506e-02 0.9729275 [8,] 2.100556e-02 4.201112e-02 0.9789944 [9,] 1.157409e-02 2.314818e-02 0.9884259 [10,] 1.136695e-02 2.273391e-02 0.9886330 [11,] 2.249582e-02 4.499164e-02 0.9775042 [12,] 7.425571e-02 1.485114e-01 0.9257443 [13,] 5.096524e-02 1.019305e-01 0.9490348 [14,] 3.892794e-02 7.785588e-02 0.9610721 [15,] 2.999624e-02 5.999248e-02 0.9700038 [16,] 1.766691e-02 3.533383e-02 0.9823331 [17,] 1.046108e-02 2.092215e-02 0.9895389 [18,] 8.696268e-03 1.739254e-02 0.9913037 [19,] 1.355566e-02 2.711132e-02 0.9864443 [20,] 8.165914e-02 1.633183e-01 0.9183409 [21,] 9.302456e-02 1.860491e-01 0.9069754 [22,] 1.086026e-01 2.172053e-01 0.8913974 [23,] 3.477339e-01 6.954678e-01 0.6522661 [24,] 3.274197e-01 6.548395e-01 0.6725803 [25,] 5.288169e-01 9.423662e-01 0.4711831 [26,] 4.334959e-01 8.669918e-01 0.5665041 [27,] 3.806542e-01 7.613085e-01 0.6193458 [28,] 2.971198e-01 5.942396e-01 0.7028802 > postscript(file="/var/www/html/rcomp/tmp/15udr1258727146.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/2lplt1258727146.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/3lwmk1258727146.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/426261258727146.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/534q61258727146.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 = 61 Frequency = 1 1 2 3 4 5 6 -4.463956147 -4.029825783 -4.671190316 -2.186958641 -3.444431440 -2.147094331 7 8 9 10 11 12 -1.553852730 -2.045594108 -4.039584151 -4.543270203 -3.386135436 -4.312072538 13 14 15 16 17 18 -2.485085585 -3.865628961 -4.536343361 -2.689312628 -1.805149514 -1.367878580 19 20 21 22 23 24 -2.455180692 -2.176269551 0.414373902 1.923316699 9.230274099 3.670552160 25 26 27 28 29 30 8.826205759 5.860683698 1.373583927 0.870444451 7.648122932 5.401774466 31 32 33 34 35 36 9.510375414 7.706688407 9.042388649 5.252355084 8.620749873 2.561363579 37 38 39 40 41 42 4.486648445 2.193138187 2.906378834 6.010745244 -0.006793729 4.651635579 43 44 45 46 47 48 3.338732964 2.531977428 3.239008638 4.595045957 -6.990136024 1.632042648 49 50 51 52 53 54 1.421150211 -0.158367141 4.927570916 -2.004918427 -2.391748250 -6.538437133 55 56 57 58 59 60 -8.840074955 -6.016802175 -8.656187038 -7.227447537 -7.474752513 -3.551885848 61 -7.784962683 > postscript(file="/var/www/html/rcomp/tmp/618xw1258727146.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 = 61 Frequency = 1 lag(myerror, k = 1) myerror 0 -4.463956147 NA 1 -4.029825783 -4.463956147 2 -4.671190316 -4.029825783 3 -2.186958641 -4.671190316 4 -3.444431440 -2.186958641 5 -2.147094331 -3.444431440 6 -1.553852730 -2.147094331 7 -2.045594108 -1.553852730 8 -4.039584151 -2.045594108 9 -4.543270203 -4.039584151 10 -3.386135436 -4.543270203 11 -4.312072538 -3.386135436 12 -2.485085585 -4.312072538 13 -3.865628961 -2.485085585 14 -4.536343361 -3.865628961 15 -2.689312628 -4.536343361 16 -1.805149514 -2.689312628 17 -1.367878580 -1.805149514 18 -2.455180692 -1.367878580 19 -2.176269551 -2.455180692 20 0.414373902 -2.176269551 21 1.923316699 0.414373902 22 9.230274099 1.923316699 23 3.670552160 9.230274099 24 8.826205759 3.670552160 25 5.860683698 8.826205759 26 1.373583927 5.860683698 27 0.870444451 1.373583927 28 7.648122932 0.870444451 29 5.401774466 7.648122932 30 9.510375414 5.401774466 31 7.706688407 9.510375414 32 9.042388649 7.706688407 33 5.252355084 9.042388649 34 8.620749873 5.252355084 35 2.561363579 8.620749873 36 4.486648445 2.561363579 37 2.193138187 4.486648445 38 2.906378834 2.193138187 39 6.010745244 2.906378834 40 -0.006793729 6.010745244 41 4.651635579 -0.006793729 42 3.338732964 4.651635579 43 2.531977428 3.338732964 44 3.239008638 2.531977428 45 4.595045957 3.239008638 46 -6.990136024 4.595045957 47 1.632042648 -6.990136024 48 1.421150211 1.632042648 49 -0.158367141 1.421150211 50 4.927570916 -0.158367141 51 -2.004918427 4.927570916 52 -2.391748250 -2.004918427 53 -6.538437133 -2.391748250 54 -8.840074955 -6.538437133 55 -6.016802175 -8.840074955 56 -8.656187038 -6.016802175 57 -7.227447537 -8.656187038 58 -7.474752513 -7.227447537 59 -3.551885848 -7.474752513 60 -7.784962683 -3.551885848 61 NA -7.784962683 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -4.029825783 -4.463956147 [2,] -4.671190316 -4.029825783 [3,] -2.186958641 -4.671190316 [4,] -3.444431440 -2.186958641 [5,] -2.147094331 -3.444431440 [6,] -1.553852730 -2.147094331 [7,] -2.045594108 -1.553852730 [8,] -4.039584151 -2.045594108 [9,] -4.543270203 -4.039584151 [10,] -3.386135436 -4.543270203 [11,] -4.312072538 -3.386135436 [12,] -2.485085585 -4.312072538 [13,] -3.865628961 -2.485085585 [14,] -4.536343361 -3.865628961 [15,] -2.689312628 -4.536343361 [16,] -1.805149514 -2.689312628 [17,] -1.367878580 -1.805149514 [18,] -2.455180692 -1.367878580 [19,] -2.176269551 -2.455180692 [20,] 0.414373902 -2.176269551 [21,] 1.923316699 0.414373902 [22,] 9.230274099 1.923316699 [23,] 3.670552160 9.230274099 [24,] 8.826205759 3.670552160 [25,] 5.860683698 8.826205759 [26,] 1.373583927 5.860683698 [27,] 0.870444451 1.373583927 [28,] 7.648122932 0.870444451 [29,] 5.401774466 7.648122932 [30,] 9.510375414 5.401774466 [31,] 7.706688407 9.510375414 [32,] 9.042388649 7.706688407 [33,] 5.252355084 9.042388649 [34,] 8.620749873 5.252355084 [35,] 2.561363579 8.620749873 [36,] 4.486648445 2.561363579 [37,] 2.193138187 4.486648445 [38,] 2.906378834 2.193138187 [39,] 6.010745244 2.906378834 [40,] -0.006793729 6.010745244 [41,] 4.651635579 -0.006793729 [42,] 3.338732964 4.651635579 [43,] 2.531977428 3.338732964 [44,] 3.239008638 2.531977428 [45,] 4.595045957 3.239008638 [46,] -6.990136024 4.595045957 [47,] 1.632042648 -6.990136024 [48,] 1.421150211 1.632042648 [49,] -0.158367141 1.421150211 [50,] 4.927570916 -0.158367141 [51,] -2.004918427 4.927570916 [52,] -2.391748250 -2.004918427 [53,] -6.538437133 -2.391748250 [54,] -8.840074955 -6.538437133 [55,] -6.016802175 -8.840074955 [56,] -8.656187038 -6.016802175 [57,] -7.227447537 -8.656187038 [58,] -7.474752513 -7.227447537 [59,] -3.551885848 -7.474752513 [60,] -7.784962683 -3.551885848 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -4.029825783 -4.463956147 2 -4.671190316 -4.029825783 3 -2.186958641 -4.671190316 4 -3.444431440 -2.186958641 5 -2.147094331 -3.444431440 6 -1.553852730 -2.147094331 7 -2.045594108 -1.553852730 8 -4.039584151 -2.045594108 9 -4.543270203 -4.039584151 10 -3.386135436 -4.543270203 11 -4.312072538 -3.386135436 12 -2.485085585 -4.312072538 13 -3.865628961 -2.485085585 14 -4.536343361 -3.865628961 15 -2.689312628 -4.536343361 16 -1.805149514 -2.689312628 17 -1.367878580 -1.805149514 18 -2.455180692 -1.367878580 19 -2.176269551 -2.455180692 20 0.414373902 -2.176269551 21 1.923316699 0.414373902 22 9.230274099 1.923316699 23 3.670552160 9.230274099 24 8.826205759 3.670552160 25 5.860683698 8.826205759 26 1.373583927 5.860683698 27 0.870444451 1.373583927 28 7.648122932 0.870444451 29 5.401774466 7.648122932 30 9.510375414 5.401774466 31 7.706688407 9.510375414 32 9.042388649 7.706688407 33 5.252355084 9.042388649 34 8.620749873 5.252355084 35 2.561363579 8.620749873 36 4.486648445 2.561363579 37 2.193138187 4.486648445 38 2.906378834 2.193138187 39 6.010745244 2.906378834 40 -0.006793729 6.010745244 41 4.651635579 -0.006793729 42 3.338732964 4.651635579 43 2.531977428 3.338732964 44 3.239008638 2.531977428 45 4.595045957 3.239008638 46 -6.990136024 4.595045957 47 1.632042648 -6.990136024 48 1.421150211 1.632042648 49 -0.158367141 1.421150211 50 4.927570916 -0.158367141 51 -2.004918427 4.927570916 52 -2.391748250 -2.004918427 53 -6.538437133 -2.391748250 54 -8.840074955 -6.538437133 55 -6.016802175 -8.840074955 56 -8.656187038 -6.016802175 57 -7.227447537 -8.656187038 58 -7.474752513 -7.227447537 59 -3.551885848 -7.474752513 60 -7.784962683 -3.551885848 > 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/7dm231258727146.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/8r8pc1258727146.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/9m0lf1258727147.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/10u01t1258727147.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/11u4o71258727147.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/12jlhn1258727147.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/13oz1m1258727147.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/14hmv01258727147.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/15aanr1258727147.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/16dept1258727147.tab") + } > > system("convert tmp/15udr1258727146.ps tmp/15udr1258727146.png") > system("convert tmp/2lplt1258727146.ps tmp/2lplt1258727146.png") > system("convert tmp/3lwmk1258727146.ps tmp/3lwmk1258727146.png") > system("convert tmp/426261258727146.ps tmp/426261258727146.png") > system("convert tmp/534q61258727146.ps tmp/534q61258727146.png") > system("convert tmp/618xw1258727146.ps tmp/618xw1258727146.png") > system("convert tmp/7dm231258727146.ps tmp/7dm231258727146.png") > system("convert tmp/8r8pc1258727146.ps tmp/8r8pc1258727146.png") > system("convert tmp/9m0lf1258727147.ps tmp/9m0lf1258727147.png") > system("convert tmp/10u01t1258727147.ps tmp/10u01t1258727147.png") > > > proc.time() user system elapsed 2.403 1.545 2.808