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(-999 + ,-999 + ,38.6 + ,6.654 + ,5.712 + ,645 + ,3 + ,5 + ,3 + ,6.3 + ,2 + ,4.5 + ,1 + ,6.6 + ,42 + ,3 + ,1 + ,3 + ,-999 + ,-999 + ,14 + ,3.385 + ,44.5 + ,60 + ,1 + ,1 + ,1 + ,-999 + ,-999 + ,-999 + ,0.92 + ,5.7 + ,25 + ,5 + ,2 + ,3 + ,2.1 + ,1.8 + ,69 + ,2547 + ,4603 + ,624 + ,3 + ,5 + ,4 + ,0.1 + ,0.7 + ,27 + ,10.55 + ,0.5 + ,180 + ,4 + ,4 + ,4 + ,15.8 + ,3.9 + ,19 + ,0.023 + ,0.3 + ,35 + ,1 + ,1 + ,1 + ,5.2 + ,1 + ,30.4 + ,160 + ,169 + ,392 + ,4 + ,5 + ,4 + ,10.9 + ,3.6 + ,28 + ,3.3 + ,25.6 + ,63 + ,1 + ,2 + ,1 + ,8.3 + ,1.4 + ,50 + ,52.16 + ,440 + ,230 + ,1 + ,1 + ,1 + ,11 + ,1.5 + ,7 + ,0.425 + ,6.4 + ,112 + ,5 + ,4 + ,4 + ,3.2 + ,0.7 + ,30 + ,465 + ,423 + ,281 + ,5 + ,5 + ,5 + ,7.6 + ,2.7 + ,-999 + ,0.55 + ,2.4 + ,-999 + ,2 + ,1 + ,2 + ,-999 + ,-999 + ,40 + ,187.1 + ,419 + ,365 + ,5 + ,5 + ,5 + ,6.3 + ,2.1 + ,3.5 + ,0.075 + ,1.2 + ,42 + ,1 + ,1 + ,1 + ,8.6 + ,0 + ,50 + ,3 + ,25 + ,28 + ,2 + ,2 + ,2 + ,6.6 + ,4.1 + ,6 + ,0.785 + ,3.5 + ,42 + ,2 + ,2 + ,2 + ,9.5 + ,1.2 + ,10.4 + ,0.2 + ,5 + ,120 + ,2 + ,2 + ,2 + ,4.8 + ,1.3 + ,34 + ,1.41 + ,17.5 + ,-999 + ,1 + ,2 + ,1 + ,12 + ,6.1 + ,7 + ,60 + ,81 + ,-999 + ,1 + ,1 + ,1 + ,-999 + ,0.3 + ,28 + ,529 + ,680 + ,400 + ,5 + ,5 + ,5 + ,3.3 + ,0.5 + ,20 + ,27.66 + ,115 + ,148 + ,5 + ,5 + ,5 + ,11 + ,3.4 + ,3.9 + ,0.12 + ,1 + ,16 + ,3 + ,1 + ,2 + ,-999 + ,-999 + ,39.3 + ,207 + ,406 + ,252 + ,1 + ,4 + ,1 + ,4.7 + ,1.5 + ,41 + ,85 + ,325 + ,310 + ,1 + ,3 + ,1 + ,-999 + ,-999 + ,16.2 + ,36.33 + ,119.5 + ,63 + ,1 + ,1 + ,1 + ,10.4 + ,3.4 + ,9 + ,0.101 + ,4 + ,28 + ,5 + ,1 + ,3 + ,7.4 + ,0.8 + ,7.6 + ,1.04 + ,5.5 + ,68 + ,5 + ,3 + ,4 + ,2.1 + ,0.8 + ,46 + ,521 + ,655 + ,336 + ,5 + ,5 + ,5 + ,2.1 + ,-999 + ,22.4 + ,100 + ,157 + ,100 + ,1 + ,1 + ,1 + ,-999 + ,-999 + ,16.3 + ,35 + ,56 + ,33 + ,3 + ,5 + ,4 + ,7.7 + ,1.4 + ,2.6 + ,0.005 + ,0.14 + ,21.5 + ,5 + ,2 + ,4 + ,17.9 + ,2 + ,24 + ,0.01 + ,0.25 + ,50 + ,1 + ,1 + ,1 + ,6.1 + ,1.9 + ,100 + ,62 + ,1320 + ,267 + ,1 + ,1 + ,1 + ,8.2 + ,2.4 + ,-999 + ,0.122 + ,3 + ,30 + ,2 + ,1 + ,1 + ,8.4 + ,2.8 + ,-999 + ,1.35 + ,8.1 + ,45 + ,3 + ,1 + ,3 + ,11.9 + ,1.3 + ,3.2 + ,0.23 + ,0.4 + ,19 + ,4 + ,1 + ,3 + ,10.8 + ,2 + ,2 + ,0.048 + ,0.33 + ,30 + ,4 + ,1 + ,3 + ,13.8 + ,5.6 + ,5 + ,1.7 + ,6.3 + ,12 + ,2 + ,1 + ,1 + ,14.3 + ,3.1 + ,6.5 + ,3.5 + ,10.8 + ,120 + ,2 + ,1 + ,1 + ,-999 + ,1 + ,23.6 + ,250 + ,490 + ,440 + ,5 + ,5 + ,5 + ,15.2 + ,1.8 + ,12 + ,0.48 + ,15.5 + ,140 + ,2 + ,2 + ,2 + ,10 + ,0.9 + ,20.2 + ,10 + ,115 + ,170 + ,4 + ,4 + ,4 + ,11.9 + ,1.8 + ,13 + ,1.62 + ,11.4 + ,17 + ,2 + ,1 + ,2 + ,6.5 + ,1.9 + ,27 + ,192 + ,180 + ,115 + ,4 + ,4 + ,4 + ,7.5 + ,0.9 + ,18 + ,2.5 + ,12.1 + ,31 + ,5 + ,5 + ,5 + ,-999 + ,-999 + ,13.7 + ,4.288 + ,39.2 + ,63 + ,2 + ,2 + ,2 + ,10.6 + ,2.6 + ,4.7 + ,0.28 + ,1.9 + ,21 + ,3 + ,1 + ,3 + ,7.4 + ,2.4 + ,9.8 + ,4.235 + ,50.4 + ,52 + ,1 + ,1 + ,1 + ,8.4 + ,1.2 + ,29 + ,6.8 + ,179 + ,164 + ,2 + ,3 + ,2 + ,5.7 + ,0.9 + ,7 + ,0.75 + ,12.3 + ,225 + ,2 + ,2 + ,2 + ,4.9 + ,0.5 + ,6 + ,3.6 + ,21 + ,150 + ,3 + ,2 + ,3 + ,-999 + ,-999 + ,17 + ,14.83 + ,98.2 + ,151 + ,5 + ,5 + ,5 + ,3.2 + ,0.6 + ,20 + ,55.5 + ,175 + ,150 + ,5 + ,5 + ,5 + ,-999 + ,-999 + ,12.7 + ,1.4 + ,12.5 + ,90 + ,2 + ,2 + ,2 + ,8.1 + ,2.2 + ,3.5 + ,0.06 + ,1 + ,-999 + ,3 + ,1 + ,2 + ,11 + ,2.3 + ,4.5 + ,0.9 + ,2.6 + ,60 + ,2 + ,1 + ,2 + ,4.9 + ,0.5 + ,7.5 + ,2 + ,12.3 + ,200 + ,3 + ,1 + ,3 + ,13.2 + ,2.6 + ,2.3 + ,0.104 + ,2.5 + ,46 + ,3 + ,2 + ,2 + ,9.7 + ,0.6 + ,24 + ,4.19 + ,58 + ,210 + ,4 + ,3 + ,4 + ,12.8 + ,6.6 + ,3 + ,3.5 + ,3.9 + ,14 + ,1 + ,1 + ,2 + ,-999 + ,-999 + ,13 + ,4.05 + ,17 + ,38 + ,3 + ,1 + ,1) + ,dim=c(9 + ,62) + ,dimnames=list(c('SWS' + ,'PS' + ,'L' + ,'WB' + ,'WBR' + ,'TG' + ,'P' + ,'S' + ,'D') + ,1:62)) > y <- array(NA,dim=c(9,62),dimnames=list(c('SWS','PS','L','WB','WBR','TG','P','S','D'),1:62)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par3 = 'No Linear Trend' > par2 = 'Do not include Seasonal Dummies' > par1 = '1' > #'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 SWS PS L WB WBR TG P S D 1 -999.0 -999.0 38.6 6.654 5.712 645.0 3 5 3 2 6.3 2.0 4.5 1.000 6.600 42.0 3 1 3 3 -999.0 -999.0 14.0 3.385 44.500 60.0 1 1 1 4 -999.0 -999.0 -999.0 0.920 5.700 25.0 5 2 3 5 2.1 1.8 69.0 2547.000 4603.000 624.0 3 5 4 6 0.1 0.7 27.0 10.550 0.500 180.0 4 4 4 7 15.8 3.9 19.0 0.023 0.300 35.0 1 1 1 8 5.2 1.0 30.4 160.000 169.000 392.0 4 5 4 9 10.9 3.6 28.0 3.300 25.600 63.0 1 2 1 10 8.3 1.4 50.0 52.160 440.000 230.0 1 1 1 11 11.0 1.5 7.0 0.425 6.400 112.0 5 4 4 12 3.2 0.7 30.0 465.000 423.000 281.0 5 5 5 13 7.6 2.7 -999.0 0.550 2.400 -999.0 2 1 2 14 -999.0 -999.0 40.0 187.100 419.000 365.0 5 5 5 15 6.3 2.1 3.5 0.075 1.200 42.0 1 1 1 16 8.6 0.0 50.0 3.000 25.000 28.0 2 2 2 17 6.6 4.1 6.0 0.785 3.500 42.0 2 2 2 18 9.5 1.2 10.4 0.200 5.000 120.0 2 2 2 19 4.8 1.3 34.0 1.410 17.500 -999.0 1 2 1 20 12.0 6.1 7.0 60.000 81.000 -999.0 1 1 1 21 -999.0 0.3 28.0 529.000 680.000 400.0 5 5 5 22 3.3 0.5 20.0 27.660 115.000 148.0 5 5 5 23 11.0 3.4 3.9 0.120 1.000 16.0 3 1 2 24 -999.0 -999.0 39.3 207.000 406.000 252.0 1 4 1 25 4.7 1.5 41.0 85.000 325.000 310.0 1 3 1 26 -999.0 -999.0 16.2 36.330 119.500 63.0 1 1 1 27 10.4 3.4 9.0 0.101 4.000 28.0 5 1 3 28 7.4 0.8 7.6 1.040 5.500 68.0 5 3 4 29 2.1 0.8 46.0 521.000 655.000 336.0 5 5 5 30 2.1 -999.0 22.4 100.000 157.000 100.0 1 1 1 31 -999.0 -999.0 16.3 35.000 56.000 33.0 3 5 4 32 7.7 1.4 2.6 0.005 0.140 21.5 5 2 4 33 17.9 2.0 24.0 0.010 0.250 50.0 1 1 1 34 6.1 1.9 100.0 62.000 1320.000 267.0 1 1 1 35 8.2 2.4 -999.0 0.122 3.000 30.0 2 1 1 36 8.4 2.8 -999.0 1.350 8.100 45.0 3 1 3 37 11.9 1.3 3.2 0.230 0.400 19.0 4 1 3 38 10.8 2.0 2.0 0.048 0.330 30.0 4 1 3 39 13.8 5.6 5.0 1.700 6.300 12.0 2 1 1 40 14.3 3.1 6.5 3.500 10.800 120.0 2 1 1 41 -999.0 1.0 23.6 250.000 490.000 440.0 5 5 5 42 15.2 1.8 12.0 0.480 15.500 140.0 2 2 2 43 10.0 0.9 20.2 10.000 115.000 170.0 4 4 4 44 11.9 1.8 13.0 1.620 11.400 17.0 2 1 2 45 6.5 1.9 27.0 192.000 180.000 115.0 4 4 4 46 7.5 0.9 18.0 2.500 12.100 31.0 5 5 5 47 -999.0 -999.0 13.7 4.288 39.200 63.0 2 2 2 48 10.6 2.6 4.7 0.280 1.900 21.0 3 1 3 49 7.4 2.4 9.8 4.235 50.400 52.0 1 1 1 50 8.4 1.2 29.0 6.800 179.000 164.0 2 3 2 51 5.7 0.9 7.0 0.750 12.300 225.0 2 2 2 52 4.9 0.5 6.0 3.600 21.000 150.0 3 2 3 53 -999.0 -999.0 17.0 14.830 98.200 151.0 5 5 5 54 3.2 0.6 20.0 55.500 175.000 150.0 5 5 5 55 -999.0 -999.0 12.7 1.400 12.500 90.0 2 2 2 56 8.1 2.2 3.5 0.060 1.000 -999.0 3 1 2 57 11.0 2.3 4.5 0.900 2.600 60.0 2 1 2 58 4.9 0.5 7.5 2.000 12.300 200.0 3 1 3 59 13.2 2.6 2.3 0.104 2.500 46.0 3 2 2 60 9.7 0.6 24.0 4.190 58.000 210.0 4 3 4 61 12.8 6.6 3.0 3.500 3.900 14.0 1 1 2 62 -999.0 -999.0 13.0 4.050 17.000 38.0 3 1 1 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) PS L WB WBR TG 101.747169 0.858986 0.048356 0.008978 -0.002296 -0.046586 P S D -24.623378 -39.238612 11.529514 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -825.25 -34.52 9.05 53.31 813.85 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 101.747169 69.112230 1.472 0.147 PS 0.858986 0.075204 11.422 6.57e-16 *** L 0.048356 0.118259 0.409 0.684 WB 0.008978 0.300033 0.030 0.976 WBR -0.002296 0.163977 -0.014 0.989 TG -0.046586 0.104604 -0.445 0.658 P -24.623378 51.141729 -0.481 0.632 S -39.238612 33.633703 -1.167 0.249 D 11.529514 67.319369 0.171 0.865 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 215.8 on 53 degrees of freedom Multiple R-squared: 0.7633, Adjusted R-squared: 0.7276 F-statistic: 21.37 on 8 and 53 DF, p-value: 4.613e-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,] 9.969739e-07 1.993948e-06 9.999990e-01 [2,] 8.492604e-08 1.698521e-07 9.999999e-01 [3,] 2.465453e-09 4.930905e-09 1.000000e+00 [4,] 4.779755e-11 9.559510e-11 1.000000e+00 [5,] 7.218356e-13 1.443671e-12 1.000000e+00 [6,] 1.795647e-14 3.591294e-14 1.000000e+00 [7,] 3.204559e-16 6.409118e-16 1.000000e+00 [8,] 9.980588e-18 1.996118e-17 1.000000e+00 [9,] 1.315423e-19 2.630846e-19 1.000000e+00 [10,] 7.058429e-01 5.883141e-01 2.941571e-01 [11,] 6.376337e-01 7.247325e-01 3.623663e-01 [12,] 5.489556e-01 9.020887e-01 4.510444e-01 [13,] 4.629125e-01 9.258250e-01 5.370875e-01 [14,] 3.799495e-01 7.598989e-01 6.200505e-01 [15,] 3.332577e-01 6.665155e-01 6.667423e-01 [16,] 2.583052e-01 5.166103e-01 7.416948e-01 [17,] 2.026857e-01 4.053714e-01 7.973143e-01 [18,] 2.288031e-01 4.576063e-01 7.711969e-01 [19,] 9.995761e-01 8.477425e-04 4.238712e-04 [20,] 9.990915e-01 1.816974e-03 9.084872e-04 [21,] 9.980950e-01 3.810050e-03 1.905025e-03 [22,] 9.962090e-01 7.581948e-03 3.790974e-03 [23,] 9.998839e-01 2.321254e-04 1.160627e-04 [24,] 9.997310e-01 5.380997e-04 2.690498e-04 [25,] 9.999535e-01 9.302141e-05 4.651070e-05 [26,] 9.998812e-01 2.376098e-04 1.188049e-04 [27,] 9.997551e-01 4.898515e-04 2.449257e-04 [28,] 9.993623e-01 1.275402e-03 6.377012e-04 [29,] 9.984184e-01 3.163269e-03 1.581635e-03 [30,] 1.000000e+00 3.931491e-22 1.965745e-22 [31,] 1.000000e+00 5.675535e-21 2.837768e-21 [32,] 1.000000e+00 3.073984e-19 1.536992e-19 [33,] 1.000000e+00 2.015601e-17 1.007801e-17 [34,] 1.000000e+00 9.701104e-16 4.850552e-16 [35,] 1.000000e+00 7.463335e-14 3.731667e-14 [36,] 1.000000e+00 7.990545e-12 3.995273e-12 [37,] 1.000000e+00 6.267885e-10 3.133943e-10 [38,] 1.000000e+00 6.300459e-08 3.150229e-08 [39,] 9.999970e-01 6.049843e-06 3.024922e-06 > postscript(file="/var/www/html/rcomp/tmp/19y4e1293043559.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(x[,1], type='l', main='Actuals and Interpolation', ylab='value of Actuals and Interpolation (dots)', xlab='time or index') > points(x[,1]-mysum$resid) > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/228lz1293043559.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(mysum$resid, type='b', pch=19, main='Residuals', ylab='value of Residuals', xlab='time or index') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/328lz1293043559.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > hist(mysum$resid, main='Residual Histogram', xlab='values of Residuals') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/428lz1293043559.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > densityplot(~mysum$resid,col='black',main='Residual Density Plot', xlab='values of Residuals') > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/5dzl21293043559.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(mysum$resid, main='Residual Normal Q-Q Plot') > qqline(mysum$resid) > grid() > dev.off() null device 1 > (myerror <- as.ts(mysum$resid)) Time Series: Start = 1 End = 62 Frequency = 1 1 2 3 4 5 6 20.9885502 -16.8997716 -188.0982109 -26.1375987 136.1864883 114.0676567 7 8 9 10 11 12 -36.2525306 166.9054449 -0.7583678 -33.4784855 146.8075995 170.9503135 13 14 15 16 17 18 -29.2705213 33.3935050 -43.1291351 10.4348258 7.6633850 16.4840449 19 20 21 22 23 24 -54.6483361 -89.8846703 -825.2502206 168.7289592 -3.0600049 -63.6593843 25 26 27 28 29 30 44.9160338 -188.1884149 34.3767045 102.4839115 171.5828204 813.8499284 31 32 33 34 35 36 -18.1120072 61.1024473 -32.0634543 -34.8700660 31.0584528 33.1786764 37 38 39 40 41 42 12.9089696 11.7796217 -15.4851876 -7.8848457 -821.7067659 22.5445881 43 44 45 46 47 48 123.9266467 -25.7920520 115.1919255 167.2211962 -135.6317470 -14.1074579 49 50 51 52 53 54 -42.0500083 56.1132297 18.0094587 27.1957439 25.3464492 168.5240475 55 56 57 58 59 60 -134.3609537 -52.1936877 -24.7210768 -9.7917343 40.5443197 86.2466926 61 62 -53.3288513 -139.8970890 > postscript(file="/var/www/html/rcomp/tmp/6dzl21293043559.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > dum <- cbind(lag(myerror,k=1),myerror) > dum Time Series: Start = 0 End = 62 Frequency = 1 lag(myerror, k = 1) myerror 0 20.9885502 NA 1 -16.8997716 20.9885502 2 -188.0982109 -16.8997716 3 -26.1375987 -188.0982109 4 136.1864883 -26.1375987 5 114.0676567 136.1864883 6 -36.2525306 114.0676567 7 166.9054449 -36.2525306 8 -0.7583678 166.9054449 9 -33.4784855 -0.7583678 10 146.8075995 -33.4784855 11 170.9503135 146.8075995 12 -29.2705213 170.9503135 13 33.3935050 -29.2705213 14 -43.1291351 33.3935050 15 10.4348258 -43.1291351 16 7.6633850 10.4348258 17 16.4840449 7.6633850 18 -54.6483361 16.4840449 19 -89.8846703 -54.6483361 20 -825.2502206 -89.8846703 21 168.7289592 -825.2502206 22 -3.0600049 168.7289592 23 -63.6593843 -3.0600049 24 44.9160338 -63.6593843 25 -188.1884149 44.9160338 26 34.3767045 -188.1884149 27 102.4839115 34.3767045 28 171.5828204 102.4839115 29 813.8499284 171.5828204 30 -18.1120072 813.8499284 31 61.1024473 -18.1120072 32 -32.0634543 61.1024473 33 -34.8700660 -32.0634543 34 31.0584528 -34.8700660 35 33.1786764 31.0584528 36 12.9089696 33.1786764 37 11.7796217 12.9089696 38 -15.4851876 11.7796217 39 -7.8848457 -15.4851876 40 -821.7067659 -7.8848457 41 22.5445881 -821.7067659 42 123.9266467 22.5445881 43 -25.7920520 123.9266467 44 115.1919255 -25.7920520 45 167.2211962 115.1919255 46 -135.6317470 167.2211962 47 -14.1074579 -135.6317470 48 -42.0500083 -14.1074579 49 56.1132297 -42.0500083 50 18.0094587 56.1132297 51 27.1957439 18.0094587 52 25.3464492 27.1957439 53 168.5240475 25.3464492 54 -134.3609537 168.5240475 55 -52.1936877 -134.3609537 56 -24.7210768 -52.1936877 57 -9.7917343 -24.7210768 58 40.5443197 -9.7917343 59 86.2466926 40.5443197 60 -53.3288513 86.2466926 61 -139.8970890 -53.3288513 62 NA -139.8970890 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -16.8997716 20.9885502 [2,] -188.0982109 -16.8997716 [3,] -26.1375987 -188.0982109 [4,] 136.1864883 -26.1375987 [5,] 114.0676567 136.1864883 [6,] -36.2525306 114.0676567 [7,] 166.9054449 -36.2525306 [8,] -0.7583678 166.9054449 [9,] -33.4784855 -0.7583678 [10,] 146.8075995 -33.4784855 [11,] 170.9503135 146.8075995 [12,] -29.2705213 170.9503135 [13,] 33.3935050 -29.2705213 [14,] -43.1291351 33.3935050 [15,] 10.4348258 -43.1291351 [16,] 7.6633850 10.4348258 [17,] 16.4840449 7.6633850 [18,] -54.6483361 16.4840449 [19,] -89.8846703 -54.6483361 [20,] -825.2502206 -89.8846703 [21,] 168.7289592 -825.2502206 [22,] -3.0600049 168.7289592 [23,] -63.6593843 -3.0600049 [24,] 44.9160338 -63.6593843 [25,] -188.1884149 44.9160338 [26,] 34.3767045 -188.1884149 [27,] 102.4839115 34.3767045 [28,] 171.5828204 102.4839115 [29,] 813.8499284 171.5828204 [30,] -18.1120072 813.8499284 [31,] 61.1024473 -18.1120072 [32,] -32.0634543 61.1024473 [33,] -34.8700660 -32.0634543 [34,] 31.0584528 -34.8700660 [35,] 33.1786764 31.0584528 [36,] 12.9089696 33.1786764 [37,] 11.7796217 12.9089696 [38,] -15.4851876 11.7796217 [39,] -7.8848457 -15.4851876 [40,] -821.7067659 -7.8848457 [41,] 22.5445881 -821.7067659 [42,] 123.9266467 22.5445881 [43,] -25.7920520 123.9266467 [44,] 115.1919255 -25.7920520 [45,] 167.2211962 115.1919255 [46,] -135.6317470 167.2211962 [47,] -14.1074579 -135.6317470 [48,] -42.0500083 -14.1074579 [49,] 56.1132297 -42.0500083 [50,] 18.0094587 56.1132297 [51,] 27.1957439 18.0094587 [52,] 25.3464492 27.1957439 [53,] 168.5240475 25.3464492 [54,] -134.3609537 168.5240475 [55,] -52.1936877 -134.3609537 [56,] -24.7210768 -52.1936877 [57,] -9.7917343 -24.7210768 [58,] 40.5443197 -9.7917343 [59,] 86.2466926 40.5443197 [60,] -53.3288513 86.2466926 [61,] -139.8970890 -53.3288513 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -16.8997716 20.9885502 2 -188.0982109 -16.8997716 3 -26.1375987 -188.0982109 4 136.1864883 -26.1375987 5 114.0676567 136.1864883 6 -36.2525306 114.0676567 7 166.9054449 -36.2525306 8 -0.7583678 166.9054449 9 -33.4784855 -0.7583678 10 146.8075995 -33.4784855 11 170.9503135 146.8075995 12 -29.2705213 170.9503135 13 33.3935050 -29.2705213 14 -43.1291351 33.3935050 15 10.4348258 -43.1291351 16 7.6633850 10.4348258 17 16.4840449 7.6633850 18 -54.6483361 16.4840449 19 -89.8846703 -54.6483361 20 -825.2502206 -89.8846703 21 168.7289592 -825.2502206 22 -3.0600049 168.7289592 23 -63.6593843 -3.0600049 24 44.9160338 -63.6593843 25 -188.1884149 44.9160338 26 34.3767045 -188.1884149 27 102.4839115 34.3767045 28 171.5828204 102.4839115 29 813.8499284 171.5828204 30 -18.1120072 813.8499284 31 61.1024473 -18.1120072 32 -32.0634543 61.1024473 33 -34.8700660 -32.0634543 34 31.0584528 -34.8700660 35 33.1786764 31.0584528 36 12.9089696 33.1786764 37 11.7796217 12.9089696 38 -15.4851876 11.7796217 39 -7.8848457 -15.4851876 40 -821.7067659 -7.8848457 41 22.5445881 -821.7067659 42 123.9266467 22.5445881 43 -25.7920520 123.9266467 44 115.1919255 -25.7920520 45 167.2211962 115.1919255 46 -135.6317470 167.2211962 47 -14.1074579 -135.6317470 48 -42.0500083 -14.1074579 49 56.1132297 -42.0500083 50 18.0094587 56.1132297 51 27.1957439 18.0094587 52 25.3464492 27.1957439 53 168.5240475 25.3464492 54 -134.3609537 168.5240475 55 -52.1936877 -134.3609537 56 -24.7210768 -52.1936877 57 -9.7917343 -24.7210768 58 40.5443197 -9.7917343 59 86.2466926 40.5443197 60 -53.3288513 86.2466926 61 -139.8970890 -53.3288513 > 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/7oqkn1293043559.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > acf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Autocorrelation Function') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/8oqkn1293043559.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > pacf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Partial Autocorrelation Function') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/9yh181293043559.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0)) > plot(mylm, las = 1, sub='Residual Diagnostics') > par(opar) > dev.off() null device 1 > if (n > n25) { + postscript(file="/var/www/html/rcomp/tmp/10yh181293043559.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) + plot(kp3:nmkm3,gqarr[,2], main='Goldfeld-Quandt test',ylab='2-sided p-value',xlab='breakpoint') + grid() + dev.off() + } null device 1 > > #Note: the /var/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/11ki0w1293043559.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/12n1g21293043559.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/131swa1293043559.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/144tvg1293043559.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/1503eh1293043560.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/164mcn1293043560.tab") + } > try(system("convert tmp/19y4e1293043559.ps tmp/19y4e1293043559.png",intern=TRUE)) character(0) > try(system("convert tmp/228lz1293043559.ps tmp/228lz1293043559.png",intern=TRUE)) character(0) > try(system("convert tmp/328lz1293043559.ps tmp/328lz1293043559.png",intern=TRUE)) character(0) > try(system("convert tmp/428lz1293043559.ps tmp/428lz1293043559.png",intern=TRUE)) character(0) > try(system("convert tmp/5dzl21293043559.ps tmp/5dzl21293043559.png",intern=TRUE)) character(0) > try(system("convert tmp/6dzl21293043559.ps tmp/6dzl21293043559.png",intern=TRUE)) character(0) > try(system("convert tmp/7oqkn1293043559.ps tmp/7oqkn1293043559.png",intern=TRUE)) character(0) > try(system("convert tmp/8oqkn1293043559.ps tmp/8oqkn1293043559.png",intern=TRUE)) character(0) > try(system("convert tmp/9yh181293043559.ps tmp/9yh181293043559.png",intern=TRUE)) character(0) > try(system("convert tmp/10yh181293043559.ps tmp/10yh181293043559.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.569 1.659 6.011