R version 2.8.0 (2008-10-20) Copyright (C) 2008 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(10540.05 + ,0 + ,1 + ,0 + ,10601.61 + ,0 + ,2 + ,0 + ,10323.73 + ,0 + ,3 + ,0 + ,10418.4 + ,0 + ,4 + ,0 + ,10092.96 + ,0 + ,5 + ,0 + ,10364.91 + ,0 + ,6 + ,0 + ,10152.09 + ,0 + ,7 + ,0 + ,10032.8 + ,0 + ,8 + ,0 + ,10204.59 + ,0 + ,9 + ,0 + ,10001.6 + ,0 + ,10 + ,0 + ,10411.75 + ,0 + ,11 + ,0 + ,10673.38 + ,0 + ,12 + ,0 + ,10539.51 + ,0 + ,13 + ,0 + ,10723.78 + ,0 + ,14 + ,0 + ,10682.06 + ,0 + ,15 + ,0 + ,10283.19 + ,0 + ,16 + ,0 + ,10377.18 + ,0 + ,17 + ,0 + ,10486.64 + ,0 + ,18 + ,0 + ,10545.38 + ,0 + ,19 + ,0 + ,10554.27 + ,0 + ,20 + ,0 + ,10532.54 + ,0 + ,21 + ,0 + ,10324.31 + ,0 + ,22 + ,0 + ,10695.25 + ,0 + ,23 + ,0 + ,10827.81 + ,0 + ,24 + ,0 + ,10872.48 + ,0 + ,25 + ,0 + ,10971.19 + ,0 + ,26 + ,0 + ,11145.65 + ,0 + ,27 + ,0 + ,11234.68 + ,0 + ,28 + ,0 + ,11333.88 + ,0 + ,29 + ,0 + ,10997.97 + ,0 + ,30 + ,0 + ,11036.89 + ,0 + ,31 + ,0 + ,11257.35 + ,0 + ,32 + ,0 + ,11533.59 + ,0 + ,33 + ,0 + ,11963.12 + ,0 + ,34 + ,0 + ,12185.15 + ,0 + ,35 + ,0 + ,12377.62 + ,0 + ,36 + ,0 + ,12512.89 + ,0 + ,37 + ,0 + ,12631.48 + ,0 + ,38 + ,0 + ,12268.53 + ,0 + ,39 + ,0 + ,12754.8 + ,1 + ,40 + ,40 + ,13407.75 + ,1 + ,41 + ,41 + ,13480.21 + ,1 + ,42 + ,42 + ,13673.28 + ,1 + ,43 + ,43 + ,13239.71 + ,1 + ,44 + ,44 + ,13557.69 + ,1 + ,45 + ,45 + ,13901.28 + ,1 + ,46 + ,46 + ,13200.58 + ,1 + ,47 + ,47 + ,13406.97 + ,1 + ,48 + ,48 + ,12538.12 + ,1 + ,49 + ,49 + ,12419.57 + ,1 + ,50 + ,50 + ,12193.88 + ,1 + ,51 + ,51 + ,12656.63 + ,1 + ,52 + ,52 + ,12812.48 + ,1 + ,53 + ,53 + ,12056.67 + ,1 + ,54 + ,54 + ,11322.38 + ,1 + ,55 + ,55 + ,11530.75 + ,1 + ,56 + ,56 + ,11114.08 + ,1 + ,57 + ,57 + ,9181.73 + ,1 + ,58 + ,58 + ,8614.55 + ,1 + ,59 + ,59) + ,dim=c(4 + ,59) + ,dimnames=list(c('DowJones' + ,'Dummy' + ,'Trend' + ,'Dumtrend') + ,1:59)) > y <- array(NA,dim=c(4,59),dimnames=list(c('DowJones','Dummy','Trend','Dumtrend'),1:59)) > 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 = '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 DowJones Dummy Trend Dumtrend M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 1 10540.05 0 1 0 1 0 0 0 0 0 0 0 0 0 0 2 10601.61 0 2 0 0 1 0 0 0 0 0 0 0 0 0 3 10323.73 0 3 0 0 0 1 0 0 0 0 0 0 0 0 4 10418.40 0 4 0 0 0 0 1 0 0 0 0 0 0 0 5 10092.96 0 5 0 0 0 0 0 1 0 0 0 0 0 0 6 10364.91 0 6 0 0 0 0 0 0 1 0 0 0 0 0 7 10152.09 0 7 0 0 0 0 0 0 0 1 0 0 0 0 8 10032.80 0 8 0 0 0 0 0 0 0 0 1 0 0 0 9 10204.59 0 9 0 0 0 0 0 0 0 0 0 1 0 0 10 10001.60 0 10 0 0 0 0 0 0 0 0 0 0 1 0 11 10411.75 0 11 0 0 0 0 0 0 0 0 0 0 0 1 12 10673.38 0 12 0 0 0 0 0 0 0 0 0 0 0 0 13 10539.51 0 13 0 1 0 0 0 0 0 0 0 0 0 0 14 10723.78 0 14 0 0 1 0 0 0 0 0 0 0 0 0 15 10682.06 0 15 0 0 0 1 0 0 0 0 0 0 0 0 16 10283.19 0 16 0 0 0 0 1 0 0 0 0 0 0 0 17 10377.18 0 17 0 0 0 0 0 1 0 0 0 0 0 0 18 10486.64 0 18 0 0 0 0 0 0 1 0 0 0 0 0 19 10545.38 0 19 0 0 0 0 0 0 0 1 0 0 0 0 20 10554.27 0 20 0 0 0 0 0 0 0 0 1 0 0 0 21 10532.54 0 21 0 0 0 0 0 0 0 0 0 1 0 0 22 10324.31 0 22 0 0 0 0 0 0 0 0 0 0 1 0 23 10695.25 0 23 0 0 0 0 0 0 0 0 0 0 0 1 24 10827.81 0 24 0 0 0 0 0 0 0 0 0 0 0 0 25 10872.48 0 25 0 1 0 0 0 0 0 0 0 0 0 0 26 10971.19 0 26 0 0 1 0 0 0 0 0 0 0 0 0 27 11145.65 0 27 0 0 0 1 0 0 0 0 0 0 0 0 28 11234.68 0 28 0 0 0 0 1 0 0 0 0 0 0 0 29 11333.88 0 29 0 0 0 0 0 1 0 0 0 0 0 0 30 10997.97 0 30 0 0 0 0 0 0 1 0 0 0 0 0 31 11036.89 0 31 0 0 0 0 0 0 0 1 0 0 0 0 32 11257.35 0 32 0 0 0 0 0 0 0 0 1 0 0 0 33 11533.59 0 33 0 0 0 0 0 0 0 0 0 1 0 0 34 11963.12 0 34 0 0 0 0 0 0 0 0 0 0 1 0 35 12185.15 0 35 0 0 0 0 0 0 0 0 0 0 0 1 36 12377.62 0 36 0 0 0 0 0 0 0 0 0 0 0 0 37 12512.89 0 37 0 1 0 0 0 0 0 0 0 0 0 0 38 12631.48 0 38 0 0 1 0 0 0 0 0 0 0 0 0 39 12268.53 0 39 0 0 0 1 0 0 0 0 0 0 0 0 40 12754.80 1 40 40 0 0 0 1 0 0 0 0 0 0 0 41 13407.75 1 41 41 0 0 0 0 1 0 0 0 0 0 0 42 13480.21 1 42 42 0 0 0 0 0 1 0 0 0 0 0 43 13673.28 1 43 43 0 0 0 0 0 0 1 0 0 0 0 44 13239.71 1 44 44 0 0 0 0 0 0 0 1 0 0 0 45 13557.69 1 45 45 0 0 0 0 0 0 0 0 1 0 0 46 13901.28 1 46 46 0 0 0 0 0 0 0 0 0 1 0 47 13200.58 1 47 47 0 0 0 0 0 0 0 0 0 0 1 48 13406.97 1 48 48 0 0 0 0 0 0 0 0 0 0 0 49 12538.12 1 49 49 1 0 0 0 0 0 0 0 0 0 0 50 12419.57 1 50 50 0 1 0 0 0 0 0 0 0 0 0 51 12193.88 1 51 51 0 0 1 0 0 0 0 0 0 0 0 52 12656.63 1 52 52 0 0 0 1 0 0 0 0 0 0 0 53 12812.48 1 53 53 0 0 0 0 1 0 0 0 0 0 0 54 12056.67 1 54 54 0 0 0 0 0 1 0 0 0 0 0 55 11322.38 1 55 55 0 0 0 0 0 0 1 0 0 0 0 56 11530.75 1 56 56 0 0 0 0 0 0 0 1 0 0 0 57 11114.08 1 57 57 0 0 0 0 0 0 0 0 1 0 0 58 9181.73 1 58 58 0 0 0 0 0 0 0 0 0 1 0 59 8614.55 1 59 59 0 0 0 0 0 0 0 0 0 0 1 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) Dummy Trend Dumtrend M1 M2 10136.66 12188.47 53.42 -247.08 -87.88 -22.97 M3 M4 M5 M6 M7 M8 -173.73 -492.01 -311.29 -393.45 -479.32 -456.93 M9 M10 M11 -346.00 -614.68 -622.22 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -1662.44 -217.17 -54.59 313.73 1099.18 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 10136.655 359.960 28.160 < 2e-16 *** Dummy 12188.472 1195.721 10.193 3.69e-13 *** Trend 53.422 8.594 6.216 1.62e-07 *** Dumtrend -247.081 25.046 -9.865 1.01e-12 *** M1 -87.882 401.465 -0.219 0.828 M2 -22.972 401.066 -0.057 0.955 M3 -173.733 400.845 -0.433 0.667 M4 -492.014 404.308 -1.217 0.230 M5 -311.293 403.249 -0.772 0.444 M6 -393.452 402.485 -0.978 0.334 M7 -479.317 402.016 -1.192 0.240 M8 -456.934 401.845 -1.137 0.262 M9 -346.001 401.971 -0.861 0.394 M10 -614.680 402.395 -1.528 0.134 M11 -622.221 403.115 -1.544 0.130 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 596.3 on 44 degrees of freedom Multiple R-squared: 0.8193, Adjusted R-squared: 0.7618 F-statistic: 14.25 on 14 and 44 DF, p-value: 5.445e-12 > 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.829297e-02 3.658594e-02 0.9817070 [2,] 6.523382e-03 1.304676e-02 0.9934766 [3,] 3.423702e-03 6.847405e-03 0.9965763 [4,] 8.283227e-04 1.656645e-03 0.9991717 [5,] 1.826716e-04 3.653431e-04 0.9998173 [6,] 3.951468e-05 7.902935e-05 0.9999605 [7,] 7.595167e-06 1.519033e-05 0.9999924 [8,] 1.258798e-06 2.517596e-06 0.9999987 [9,] 1.974065e-07 3.948129e-07 0.9999998 [10,] 1.279624e-07 2.559249e-07 0.9999999 [11,] 4.631017e-07 9.262034e-07 0.9999995 [12,] 2.291361e-06 4.582723e-06 0.9999977 [13,] 5.201596e-07 1.040319e-06 0.9999995 [14,] 1.347887e-07 2.695774e-07 0.9999999 [15,] 9.975042e-08 1.995008e-07 0.9999999 [16,] 2.142938e-07 4.285877e-07 0.9999998 [17,] 7.179944e-06 1.435989e-05 0.9999928 [18,] 1.793166e-05 3.586333e-05 0.9999821 [19,] 2.284494e-05 4.568988e-05 0.9999772 [20,] 1.826741e-05 3.653481e-05 0.9999817 [21,] 1.067392e-05 2.134783e-05 0.9999893 [22,] 3.137692e-06 6.275385e-06 0.9999969 [23,] 9.304526e-06 1.860905e-05 0.9999907 [24,] 3.536784e-05 7.073568e-05 0.9999646 > postscript(file="/var/www/html/rcomp/tmp/1q1c51229329558.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/294ve1229329558.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/3ph151229329558.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/4y1yw1229329558.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/5e70s1229329558.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 = 59 Frequency = 1 1 2 3 4 5 437.8553722 381.0831441 200.5429159 560.0720380 0.4895817 6 7 8 9 10 301.1771253 120.8006690 -74.2937873 -66.8582436 -54.5906999 11 12 13 14 15 309.6788437 -104.3335372 -203.7426655 -137.8048937 -82.1851218 16 17 18 19 20 -216.1959997 -356.3484561 -218.1509124 -126.9673687 -193.8818250 21 22 23 24 25 -379.9662814 -372.9387377 -47.8791940 -590.9615750 -511.8307032 26 27 28 29 30 -531.4529314 -259.6531595 94.2359625 -40.7064938 -347.8789501 31 32 33 34 35 -276.5154064 -131.8598628 -19.9743191 624.8132246 800.9627683 36 37 38 39 40 317.7903873 487.5212590 487.7790309 222.1688027 -1331.9288263 41 42 43 44 45 -666.0401418 -317.7614574 154.8332271 -107.4600884 293.2465961 46 47 48 49 50 1099.1752806 599.6759650 377.5047249 -209.8032626 -199.6043499 51 52 53 54 55 -80.8734373 893.8168256 1062.6055100 582.6141945 127.8488790 56 57 58 59 507.4955635 173.5522480 -1296.4590675 -1662.4383831 > postscript(file="/var/www/html/rcomp/tmp/6n7261229329558.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 = 59 Frequency = 1 lag(myerror, k = 1) myerror 0 437.8553722 NA 1 381.0831441 437.8553722 2 200.5429159 381.0831441 3 560.0720380 200.5429159 4 0.4895817 560.0720380 5 301.1771253 0.4895817 6 120.8006690 301.1771253 7 -74.2937873 120.8006690 8 -66.8582436 -74.2937873 9 -54.5906999 -66.8582436 10 309.6788437 -54.5906999 11 -104.3335372 309.6788437 12 -203.7426655 -104.3335372 13 -137.8048937 -203.7426655 14 -82.1851218 -137.8048937 15 -216.1959997 -82.1851218 16 -356.3484561 -216.1959997 17 -218.1509124 -356.3484561 18 -126.9673687 -218.1509124 19 -193.8818250 -126.9673687 20 -379.9662814 -193.8818250 21 -372.9387377 -379.9662814 22 -47.8791940 -372.9387377 23 -590.9615750 -47.8791940 24 -511.8307032 -590.9615750 25 -531.4529314 -511.8307032 26 -259.6531595 -531.4529314 27 94.2359625 -259.6531595 28 -40.7064938 94.2359625 29 -347.8789501 -40.7064938 30 -276.5154064 -347.8789501 31 -131.8598628 -276.5154064 32 -19.9743191 -131.8598628 33 624.8132246 -19.9743191 34 800.9627683 624.8132246 35 317.7903873 800.9627683 36 487.5212590 317.7903873 37 487.7790309 487.5212590 38 222.1688027 487.7790309 39 -1331.9288263 222.1688027 40 -666.0401418 -1331.9288263 41 -317.7614574 -666.0401418 42 154.8332271 -317.7614574 43 -107.4600884 154.8332271 44 293.2465961 -107.4600884 45 1099.1752806 293.2465961 46 599.6759650 1099.1752806 47 377.5047249 599.6759650 48 -209.8032626 377.5047249 49 -199.6043499 -209.8032626 50 -80.8734373 -199.6043499 51 893.8168256 -80.8734373 52 1062.6055100 893.8168256 53 582.6141945 1062.6055100 54 127.8488790 582.6141945 55 507.4955635 127.8488790 56 173.5522480 507.4955635 57 -1296.4590675 173.5522480 58 -1662.4383831 -1296.4590675 59 NA -1662.4383831 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 381.0831441 437.8553722 [2,] 200.5429159 381.0831441 [3,] 560.0720380 200.5429159 [4,] 0.4895817 560.0720380 [5,] 301.1771253 0.4895817 [6,] 120.8006690 301.1771253 [7,] -74.2937873 120.8006690 [8,] -66.8582436 -74.2937873 [9,] -54.5906999 -66.8582436 [10,] 309.6788437 -54.5906999 [11,] -104.3335372 309.6788437 [12,] -203.7426655 -104.3335372 [13,] -137.8048937 -203.7426655 [14,] -82.1851218 -137.8048937 [15,] -216.1959997 -82.1851218 [16,] -356.3484561 -216.1959997 [17,] -218.1509124 -356.3484561 [18,] -126.9673687 -218.1509124 [19,] -193.8818250 -126.9673687 [20,] -379.9662814 -193.8818250 [21,] -372.9387377 -379.9662814 [22,] -47.8791940 -372.9387377 [23,] -590.9615750 -47.8791940 [24,] -511.8307032 -590.9615750 [25,] -531.4529314 -511.8307032 [26,] -259.6531595 -531.4529314 [27,] 94.2359625 -259.6531595 [28,] -40.7064938 94.2359625 [29,] -347.8789501 -40.7064938 [30,] -276.5154064 -347.8789501 [31,] -131.8598628 -276.5154064 [32,] -19.9743191 -131.8598628 [33,] 624.8132246 -19.9743191 [34,] 800.9627683 624.8132246 [35,] 317.7903873 800.9627683 [36,] 487.5212590 317.7903873 [37,] 487.7790309 487.5212590 [38,] 222.1688027 487.7790309 [39,] -1331.9288263 222.1688027 [40,] -666.0401418 -1331.9288263 [41,] -317.7614574 -666.0401418 [42,] 154.8332271 -317.7614574 [43,] -107.4600884 154.8332271 [44,] 293.2465961 -107.4600884 [45,] 1099.1752806 293.2465961 [46,] 599.6759650 1099.1752806 [47,] 377.5047249 599.6759650 [48,] -209.8032626 377.5047249 [49,] -199.6043499 -209.8032626 [50,] -80.8734373 -199.6043499 [51,] 893.8168256 -80.8734373 [52,] 1062.6055100 893.8168256 [53,] 582.6141945 1062.6055100 [54,] 127.8488790 582.6141945 [55,] 507.4955635 127.8488790 [56,] 173.5522480 507.4955635 [57,] -1296.4590675 173.5522480 [58,] -1662.4383831 -1296.4590675 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 381.0831441 437.8553722 2 200.5429159 381.0831441 3 560.0720380 200.5429159 4 0.4895817 560.0720380 5 301.1771253 0.4895817 6 120.8006690 301.1771253 7 -74.2937873 120.8006690 8 -66.8582436 -74.2937873 9 -54.5906999 -66.8582436 10 309.6788437 -54.5906999 11 -104.3335372 309.6788437 12 -203.7426655 -104.3335372 13 -137.8048937 -203.7426655 14 -82.1851218 -137.8048937 15 -216.1959997 -82.1851218 16 -356.3484561 -216.1959997 17 -218.1509124 -356.3484561 18 -126.9673687 -218.1509124 19 -193.8818250 -126.9673687 20 -379.9662814 -193.8818250 21 -372.9387377 -379.9662814 22 -47.8791940 -372.9387377 23 -590.9615750 -47.8791940 24 -511.8307032 -590.9615750 25 -531.4529314 -511.8307032 26 -259.6531595 -531.4529314 27 94.2359625 -259.6531595 28 -40.7064938 94.2359625 29 -347.8789501 -40.7064938 30 -276.5154064 -347.8789501 31 -131.8598628 -276.5154064 32 -19.9743191 -131.8598628 33 624.8132246 -19.9743191 34 800.9627683 624.8132246 35 317.7903873 800.9627683 36 487.5212590 317.7903873 37 487.7790309 487.5212590 38 222.1688027 487.7790309 39 -1331.9288263 222.1688027 40 -666.0401418 -1331.9288263 41 -317.7614574 -666.0401418 42 154.8332271 -317.7614574 43 -107.4600884 154.8332271 44 293.2465961 -107.4600884 45 1099.1752806 293.2465961 46 599.6759650 1099.1752806 47 377.5047249 599.6759650 48 -209.8032626 377.5047249 49 -199.6043499 -209.8032626 50 -80.8734373 -199.6043499 51 893.8168256 -80.8734373 52 1062.6055100 893.8168256 53 582.6141945 1062.6055100 54 127.8488790 582.6141945 55 507.4955635 127.8488790 56 173.5522480 507.4955635 57 -1296.4590675 173.5522480 58 -1662.4383831 -1296.4590675 > 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/70q6s1229329558.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/8sd7k1229329558.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/9figx1229329558.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/10gi841229329558.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/110eht1229329558.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/12gnn51229329558.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/133u3m1229329559.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/14my071229329559.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/1515e71229329559.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/16v1vn1229329559.tab") + } > system("convert tmp/1q1c51229329558.ps tmp/1q1c51229329558.png") > system("convert tmp/294ve1229329558.ps tmp/294ve1229329558.png") > system("convert tmp/3ph151229329558.ps tmp/3ph151229329558.png") > system("convert tmp/4y1yw1229329558.ps tmp/4y1yw1229329558.png") > system("convert tmp/5e70s1229329558.ps tmp/5e70s1229329558.png") > system("convert tmp/6n7261229329558.ps tmp/6n7261229329558.png") > system("convert tmp/70q6s1229329558.ps tmp/70q6s1229329558.png") > system("convert tmp/8sd7k1229329558.ps tmp/8sd7k1229329558.png") > system("convert tmp/9figx1229329558.ps tmp/9figx1229329558.png") > system("convert tmp/10gi841229329558.ps tmp/10gi841229329558.png") > > > proc.time() user system elapsed 2.420 1.579 3.028