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(98.6,0,98,0,106.8,0,96.7,0,100.2,0,107.7,0,92,0,98.4,0,107.4,0,117.7,0,105.7,0,97.5,0,99.9,0,98.2,0,104.5,0,100.8,0,101.5,0,103.9,0,99.6,0,98.4,0,112.7,0,118.4,0,108.1,0,105.4,0,114.6,0,106.9,0,115.9,0,109.8,0,101.8,0,114.2,0,110.8,0,108.4,0,127.5,1,128.6,1,116.6,1,127.4,1,105,1,108.3,1,125,1,111.6,1,106.5,1,130.3,1,115,1,116.1,1,134,1,126.5,1,125.8,1,136.4,1,114.9,1,110.9,1,125.5,1,116.8,1,116.8,1,125.5,1,104.2,1,115.1,1,132.8,1,123.3,1,124.8,1,122,1,117.4,1,117.9,1,137.4,1,114.6,1,124.7,1,129.6,1,109.4,1,120.9,1,134.9,1,136.3,1,133.2,1,127.2,1),dim=c(2,72),dimnames=list(c('Y','D'),1:72)) > y <- array(NA,dim=c(2,72),dimnames=list(c('Y','D'),1:72)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par3 = 'Linear Trend' > par2 = 'Include Monthly Dummies' > par1 = '1' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > library(lattice) > library(lmtest) Loading required package: zoo Attaching package: 'zoo' The following object(s) are masked from package:base : as.Date.numeric > n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test > par1 <- as.numeric(par1) > x <- t(y) > k <- length(x[1,]) > n <- length(x[,1]) > x1 <- cbind(x[,par1], x[,1:k!=par1]) > mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1]) > colnames(x1) <- mycolnames #colnames(x)[par1] > x <- x1 > if (par3 == 'First Differences'){ + x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep=''))) + for (i in 1:n-1) { + for (j in 1:k) { + x2[i,j] <- x[i+1,j] - x[i,j] + } + } + x <- x2 + } > if (par2 == 'Include Monthly Dummies'){ + x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep =''))) + for (i in 1:11){ + x2[seq(i,n,12),i] <- 1 + } + x <- cbind(x, x2) + } > if (par2 == 'Include Quarterly Dummies'){ + x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep =''))) + for (i in 1:3){ + x2[seq(i,n,4),i] <- 1 + } + x <- cbind(x, x2) + } > k <- length(x[1,]) > if (par3 == 'Linear Trend'){ + x <- cbind(x, c(1:n)) + colnames(x)[k+1] <- 't' + } > x Y D M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 98.6 0 1 0 0 0 0 0 0 0 0 0 0 1 2 98.0 0 0 1 0 0 0 0 0 0 0 0 0 2 3 106.8 0 0 0 1 0 0 0 0 0 0 0 0 3 4 96.7 0 0 0 0 1 0 0 0 0 0 0 0 4 5 100.2 0 0 0 0 0 1 0 0 0 0 0 0 5 6 107.7 0 0 0 0 0 0 1 0 0 0 0 0 6 7 92.0 0 0 0 0 0 0 0 1 0 0 0 0 7 8 98.4 0 0 0 0 0 0 0 0 1 0 0 0 8 9 107.4 0 0 0 0 0 0 0 0 0 1 0 0 9 10 117.7 0 0 0 0 0 0 0 0 0 0 1 0 10 11 105.7 0 0 0 0 0 0 0 0 0 0 0 1 11 12 97.5 0 0 0 0 0 0 0 0 0 0 0 0 12 13 99.9 0 1 0 0 0 0 0 0 0 0 0 0 13 14 98.2 0 0 1 0 0 0 0 0 0 0 0 0 14 15 104.5 0 0 0 1 0 0 0 0 0 0 0 0 15 16 100.8 0 0 0 0 1 0 0 0 0 0 0 0 16 17 101.5 0 0 0 0 0 1 0 0 0 0 0 0 17 18 103.9 0 0 0 0 0 0 1 0 0 0 0 0 18 19 99.6 0 0 0 0 0 0 0 1 0 0 0 0 19 20 98.4 0 0 0 0 0 0 0 0 1 0 0 0 20 21 112.7 0 0 0 0 0 0 0 0 0 1 0 0 21 22 118.4 0 0 0 0 0 0 0 0 0 0 1 0 22 23 108.1 0 0 0 0 0 0 0 0 0 0 0 1 23 24 105.4 0 0 0 0 0 0 0 0 0 0 0 0 24 25 114.6 0 1 0 0 0 0 0 0 0 0 0 0 25 26 106.9 0 0 1 0 0 0 0 0 0 0 0 0 26 27 115.9 0 0 0 1 0 0 0 0 0 0 0 0 27 28 109.8 0 0 0 0 1 0 0 0 0 0 0 0 28 29 101.8 0 0 0 0 0 1 0 0 0 0 0 0 29 30 114.2 0 0 0 0 0 0 1 0 0 0 0 0 30 31 110.8 0 0 0 0 0 0 0 1 0 0 0 0 31 32 108.4 0 0 0 0 0 0 0 0 1 0 0 0 32 33 127.5 1 0 0 0 0 0 0 0 0 1 0 0 33 34 128.6 1 0 0 0 0 0 0 0 0 0 1 0 34 35 116.6 1 0 0 0 0 0 0 0 0 0 0 1 35 36 127.4 1 0 0 0 0 0 0 0 0 0 0 0 36 37 105.0 1 1 0 0 0 0 0 0 0 0 0 0 37 38 108.3 1 0 1 0 0 0 0 0 0 0 0 0 38 39 125.0 1 0 0 1 0 0 0 0 0 0 0 0 39 40 111.6 1 0 0 0 1 0 0 0 0 0 0 0 40 41 106.5 1 0 0 0 0 1 0 0 0 0 0 0 41 42 130.3 1 0 0 0 0 0 1 0 0 0 0 0 42 43 115.0 1 0 0 0 0 0 0 1 0 0 0 0 43 44 116.1 1 0 0 0 0 0 0 0 1 0 0 0 44 45 134.0 1 0 0 0 0 0 0 0 0 1 0 0 45 46 126.5 1 0 0 0 0 0 0 0 0 0 1 0 46 47 125.8 1 0 0 0 0 0 0 0 0 0 0 1 47 48 136.4 1 0 0 0 0 0 0 0 0 0 0 0 48 49 114.9 1 1 0 0 0 0 0 0 0 0 0 0 49 50 110.9 1 0 1 0 0 0 0 0 0 0 0 0 50 51 125.5 1 0 0 1 0 0 0 0 0 0 0 0 51 52 116.8 1 0 0 0 1 0 0 0 0 0 0 0 52 53 116.8 1 0 0 0 0 1 0 0 0 0 0 0 53 54 125.5 1 0 0 0 0 0 1 0 0 0 0 0 54 55 104.2 1 0 0 0 0 0 0 1 0 0 0 0 55 56 115.1 1 0 0 0 0 0 0 0 1 0 0 0 56 57 132.8 1 0 0 0 0 0 0 0 0 1 0 0 57 58 123.3 1 0 0 0 0 0 0 0 0 0 1 0 58 59 124.8 1 0 0 0 0 0 0 0 0 0 0 1 59 60 122.0 1 0 0 0 0 0 0 0 0 0 0 0 60 61 117.4 1 1 0 0 0 0 0 0 0 0 0 0 61 62 117.9 1 0 1 0 0 0 0 0 0 0 0 0 62 63 137.4 1 0 0 1 0 0 0 0 0 0 0 0 63 64 114.6 1 0 0 0 1 0 0 0 0 0 0 0 64 65 124.7 1 0 0 0 0 1 0 0 0 0 0 0 65 66 129.6 1 0 0 0 0 0 1 0 0 0 0 0 66 67 109.4 1 0 0 0 0 0 0 1 0 0 0 0 67 68 120.9 1 0 0 0 0 0 0 0 1 0 0 0 68 69 134.9 1 0 0 0 0 0 0 0 0 1 0 0 69 70 136.3 1 0 0 0 0 0 0 0 0 0 1 0 70 71 133.2 1 0 0 0 0 0 0 0 0 0 0 1 71 72 127.2 1 0 0 0 0 0 0 0 0 0 0 0 72 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) D M1 M2 M3 M4 1.038e+02 5.362e+00 -6.906e+00 -8.890e+00 3.310e+00 -7.773e+00 M5 M6 M7 M8 M9 M10 -7.856e+00 1.810e+00 -1.184e+01 -7.740e+00 6.417e+00 6.383e+00 M11 t -6.246e-15 2.833e-01 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -9.74231 -2.40288 -0.04744 2.49295 13.59615 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.038e+02 2.464e+00 42.140 < 2e-16 *** D 5.362e+00 2.413e+00 2.222 0.030206 * M1 -6.906e+00 2.962e+00 -2.331 0.023233 * M2 -8.890e+00 2.957e+00 -3.006 0.003908 ** M3 3.310e+00 2.953e+00 1.121 0.266983 M4 -7.773e+00 2.951e+00 -2.634 0.010790 * M5 -7.856e+00 2.949e+00 -2.664 0.009976 ** M6 1.810e+00 2.948e+00 0.614 0.541620 M7 -1.184e+01 2.949e+00 -4.015 0.000173 *** M8 -7.740e+00 2.951e+00 -2.623 0.011114 * M9 6.417e+00 2.946e+00 2.178 0.033499 * M10 6.383e+00 2.944e+00 2.169 0.034228 * M11 -6.246e-15 2.942e+00 -2.12e-15 1.000000 t 2.833e-01 5.777e-02 4.904 7.93e-06 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 5.094 on 58 degrees of freedom Multiple R-squared: 0.847, Adjusted R-squared: 0.8127 F-statistic: 24.69 on 13 and 58 DF, p-value: < 2.2e-16 > 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.051841883 0.10368377 0.94815812 [2,] 0.049960014 0.09992003 0.95003999 [3,] 0.090106430 0.18021286 0.90989357 [4,] 0.045196505 0.09039301 0.95480350 [5,] 0.035610293 0.07122059 0.96438971 [6,] 0.016106551 0.03221310 0.98389345 [7,] 0.007760993 0.01552199 0.99223901 [8,] 0.018214738 0.03642948 0.98178526 [9,] 0.160694085 0.32138817 0.83930592 [10,] 0.121856006 0.24371201 0.87814399 [11,] 0.102846676 0.20569335 0.89715332 [12,] 0.086904368 0.17380874 0.91309563 [13,] 0.098666584 0.19733317 0.90133342 [14,] 0.088669056 0.17733811 0.91133094 [15,] 0.143190992 0.28638198 0.85680901 [16,] 0.103900383 0.20780077 0.89609962 [17,] 0.069384458 0.13876892 0.93061554 [18,] 0.066606413 0.13321283 0.93339359 [19,] 0.060558636 0.12111727 0.93944136 [20,] 0.138627878 0.27725576 0.86137212 [21,] 0.419289155 0.83857831 0.58071085 [22,] 0.393365403 0.78673081 0.60663460 [23,] 0.330834050 0.66166810 0.66916595 [24,] 0.272834629 0.54566926 0.72716537 [25,] 0.404644427 0.80928885 0.59535557 [26,] 0.431963661 0.86392732 0.56803634 [27,] 0.533890738 0.93221852 0.46610926 [28,] 0.447840619 0.89568124 0.55215938 [29,] 0.415778004 0.83155601 0.58422200 [30,] 0.368244386 0.73648877 0.63175561 [31,] 0.291963063 0.58392613 0.70803694 [32,] 0.955960569 0.08807886 0.04403943 [33,] 0.939413333 0.12117333 0.06058667 [34,] 0.904566930 0.19086614 0.09543307 [35,] 0.904706679 0.19058664 0.09529332 [36,] 0.957903702 0.08419260 0.04209630 [37,] 0.913454952 0.17309010 0.08654505 [38,] 0.844649578 0.31070084 0.15535042 [39,] 0.757554657 0.48489069 0.24244534 > postscript(file="/var/www/html/freestat/rcomp/tmp/1yz7d1227547524.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/freestat/rcomp/tmp/2ncbe1227547524.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/freestat/rcomp/tmp/3vgs01227547524.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/freestat/rcomp/tmp/4joyo1227547524.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/freestat/rcomp/tmp/5hzsa1227547524.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(mysum$resid, main='Residual Normal Q-Q Plot') > qqline(mysum$resid) > grid() > dev.off() null device 1 > (myerror <- as.ts(mysum$resid)) Time Series: Start = 1 End = 72 Frequency = 1 1 2 3 4 5 6 1.38076923 2.48076923 -1.20256410 -0.50256410 2.79743590 0.34743590 7 8 9 10 11 12 -1.98589744 0.03076923 -5.40897436 4.64102564 -1.25897436 -9.74230769 13 14 15 16 17 18 -0.71923077 -0.71923077 -6.90256410 0.19743590 0.69743590 -6.85256410 19 20 21 22 23 24 2.21410256 -3.36923077 -3.50897436 1.94102564 -2.25897436 -5.24230769 25 26 27 28 29 30 10.58076923 4.58076923 1.09743590 5.79743590 -2.40256410 0.04743590 31 32 33 34 35 36 10.01410256 3.23076923 2.52948718 3.37948718 -2.52051282 7.99615385 37 38 39 40 41 42 -7.78076923 -2.78076923 1.43589744 -1.16410256 -6.46410256 7.38589744 43 44 45 46 47 48 5.45256410 2.16923077 5.62948718 -2.12051282 3.27948718 13.59615385 49 50 51 52 53 54 -1.28076923 -3.58076923 -1.46410256 0.63589744 0.43589744 -0.81410256 55 56 57 58 59 60 -8.74743590 -2.23076923 1.02948718 -8.72051282 -1.12051282 -4.20384615 61 62 63 64 65 66 -2.18076923 0.01923077 7.03589744 -4.96410256 4.93589744 -0.11410256 67 68 69 70 71 72 -6.94743590 0.16923077 -0.27051282 0.87948718 3.87948718 -2.40384615 > postscript(file="/var/www/html/freestat/rcomp/tmp/6ks411227547524.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > dum <- cbind(lag(myerror,k=1),myerror) > dum Time Series: Start = 0 End = 72 Frequency = 1 lag(myerror, k = 1) myerror 0 1.38076923 NA 1 2.48076923 1.38076923 2 -1.20256410 2.48076923 3 -0.50256410 -1.20256410 4 2.79743590 -0.50256410 5 0.34743590 2.79743590 6 -1.98589744 0.34743590 7 0.03076923 -1.98589744 8 -5.40897436 0.03076923 9 4.64102564 -5.40897436 10 -1.25897436 4.64102564 11 -9.74230769 -1.25897436 12 -0.71923077 -9.74230769 13 -0.71923077 -0.71923077 14 -6.90256410 -0.71923077 15 0.19743590 -6.90256410 16 0.69743590 0.19743590 17 -6.85256410 0.69743590 18 2.21410256 -6.85256410 19 -3.36923077 2.21410256 20 -3.50897436 -3.36923077 21 1.94102564 -3.50897436 22 -2.25897436 1.94102564 23 -5.24230769 -2.25897436 24 10.58076923 -5.24230769 25 4.58076923 10.58076923 26 1.09743590 4.58076923 27 5.79743590 1.09743590 28 -2.40256410 5.79743590 29 0.04743590 -2.40256410 30 10.01410256 0.04743590 31 3.23076923 10.01410256 32 2.52948718 3.23076923 33 3.37948718 2.52948718 34 -2.52051282 3.37948718 35 7.99615385 -2.52051282 36 -7.78076923 7.99615385 37 -2.78076923 -7.78076923 38 1.43589744 -2.78076923 39 -1.16410256 1.43589744 40 -6.46410256 -1.16410256 41 7.38589744 -6.46410256 42 5.45256410 7.38589744 43 2.16923077 5.45256410 44 5.62948718 2.16923077 45 -2.12051282 5.62948718 46 3.27948718 -2.12051282 47 13.59615385 3.27948718 48 -1.28076923 13.59615385 49 -3.58076923 -1.28076923 50 -1.46410256 -3.58076923 51 0.63589744 -1.46410256 52 0.43589744 0.63589744 53 -0.81410256 0.43589744 54 -8.74743590 -0.81410256 55 -2.23076923 -8.74743590 56 1.02948718 -2.23076923 57 -8.72051282 1.02948718 58 -1.12051282 -8.72051282 59 -4.20384615 -1.12051282 60 -2.18076923 -4.20384615 61 0.01923077 -2.18076923 62 7.03589744 0.01923077 63 -4.96410256 7.03589744 64 4.93589744 -4.96410256 65 -0.11410256 4.93589744 66 -6.94743590 -0.11410256 67 0.16923077 -6.94743590 68 -0.27051282 0.16923077 69 0.87948718 -0.27051282 70 3.87948718 0.87948718 71 -2.40384615 3.87948718 72 NA -2.40384615 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 2.48076923 1.38076923 [2,] -1.20256410 2.48076923 [3,] -0.50256410 -1.20256410 [4,] 2.79743590 -0.50256410 [5,] 0.34743590 2.79743590 [6,] -1.98589744 0.34743590 [7,] 0.03076923 -1.98589744 [8,] -5.40897436 0.03076923 [9,] 4.64102564 -5.40897436 [10,] -1.25897436 4.64102564 [11,] -9.74230769 -1.25897436 [12,] -0.71923077 -9.74230769 [13,] -0.71923077 -0.71923077 [14,] -6.90256410 -0.71923077 [15,] 0.19743590 -6.90256410 [16,] 0.69743590 0.19743590 [17,] -6.85256410 0.69743590 [18,] 2.21410256 -6.85256410 [19,] -3.36923077 2.21410256 [20,] -3.50897436 -3.36923077 [21,] 1.94102564 -3.50897436 [22,] -2.25897436 1.94102564 [23,] -5.24230769 -2.25897436 [24,] 10.58076923 -5.24230769 [25,] 4.58076923 10.58076923 [26,] 1.09743590 4.58076923 [27,] 5.79743590 1.09743590 [28,] -2.40256410 5.79743590 [29,] 0.04743590 -2.40256410 [30,] 10.01410256 0.04743590 [31,] 3.23076923 10.01410256 [32,] 2.52948718 3.23076923 [33,] 3.37948718 2.52948718 [34,] -2.52051282 3.37948718 [35,] 7.99615385 -2.52051282 [36,] -7.78076923 7.99615385 [37,] -2.78076923 -7.78076923 [38,] 1.43589744 -2.78076923 [39,] -1.16410256 1.43589744 [40,] -6.46410256 -1.16410256 [41,] 7.38589744 -6.46410256 [42,] 5.45256410 7.38589744 [43,] 2.16923077 5.45256410 [44,] 5.62948718 2.16923077 [45,] -2.12051282 5.62948718 [46,] 3.27948718 -2.12051282 [47,] 13.59615385 3.27948718 [48,] -1.28076923 13.59615385 [49,] -3.58076923 -1.28076923 [50,] -1.46410256 -3.58076923 [51,] 0.63589744 -1.46410256 [52,] 0.43589744 0.63589744 [53,] -0.81410256 0.43589744 [54,] -8.74743590 -0.81410256 [55,] -2.23076923 -8.74743590 [56,] 1.02948718 -2.23076923 [57,] -8.72051282 1.02948718 [58,] -1.12051282 -8.72051282 [59,] -4.20384615 -1.12051282 [60,] -2.18076923 -4.20384615 [61,] 0.01923077 -2.18076923 [62,] 7.03589744 0.01923077 [63,] -4.96410256 7.03589744 [64,] 4.93589744 -4.96410256 [65,] -0.11410256 4.93589744 [66,] -6.94743590 -0.11410256 [67,] 0.16923077 -6.94743590 [68,] -0.27051282 0.16923077 [69,] 0.87948718 -0.27051282 [70,] 3.87948718 0.87948718 [71,] -2.40384615 3.87948718 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 2.48076923 1.38076923 2 -1.20256410 2.48076923 3 -0.50256410 -1.20256410 4 2.79743590 -0.50256410 5 0.34743590 2.79743590 6 -1.98589744 0.34743590 7 0.03076923 -1.98589744 8 -5.40897436 0.03076923 9 4.64102564 -5.40897436 10 -1.25897436 4.64102564 11 -9.74230769 -1.25897436 12 -0.71923077 -9.74230769 13 -0.71923077 -0.71923077 14 -6.90256410 -0.71923077 15 0.19743590 -6.90256410 16 0.69743590 0.19743590 17 -6.85256410 0.69743590 18 2.21410256 -6.85256410 19 -3.36923077 2.21410256 20 -3.50897436 -3.36923077 21 1.94102564 -3.50897436 22 -2.25897436 1.94102564 23 -5.24230769 -2.25897436 24 10.58076923 -5.24230769 25 4.58076923 10.58076923 26 1.09743590 4.58076923 27 5.79743590 1.09743590 28 -2.40256410 5.79743590 29 0.04743590 -2.40256410 30 10.01410256 0.04743590 31 3.23076923 10.01410256 32 2.52948718 3.23076923 33 3.37948718 2.52948718 34 -2.52051282 3.37948718 35 7.99615385 -2.52051282 36 -7.78076923 7.99615385 37 -2.78076923 -7.78076923 38 1.43589744 -2.78076923 39 -1.16410256 1.43589744 40 -6.46410256 -1.16410256 41 7.38589744 -6.46410256 42 5.45256410 7.38589744 43 2.16923077 5.45256410 44 5.62948718 2.16923077 45 -2.12051282 5.62948718 46 3.27948718 -2.12051282 47 13.59615385 3.27948718 48 -1.28076923 13.59615385 49 -3.58076923 -1.28076923 50 -1.46410256 -3.58076923 51 0.63589744 -1.46410256 52 0.43589744 0.63589744 53 -0.81410256 0.43589744 54 -8.74743590 -0.81410256 55 -2.23076923 -8.74743590 56 1.02948718 -2.23076923 57 -8.72051282 1.02948718 58 -1.12051282 -8.72051282 59 -4.20384615 -1.12051282 60 -2.18076923 -4.20384615 61 0.01923077 -2.18076923 62 7.03589744 0.01923077 63 -4.96410256 7.03589744 64 4.93589744 -4.96410256 65 -0.11410256 4.93589744 66 -6.94743590 -0.11410256 67 0.16923077 -6.94743590 68 -0.27051282 0.16923077 69 0.87948718 -0.27051282 70 3.87948718 0.87948718 71 -2.40384615 3.87948718 > 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/freestat/rcomp/tmp/7eyh91227547524.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/freestat/rcomp/tmp/8wb7o1227547524.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/freestat/rcomp/tmp/9n6721227547524.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/freestat/rcomp/tmp/106un41227547524.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/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/11dtzz1227547524.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/freestat/rcomp/tmp/12s3p11227547524.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/freestat/rcomp/tmp/1318uz1227547524.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/freestat/rcomp/tmp/14i3ck1227547524.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/freestat/rcomp/tmp/15e0u71227547524.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/freestat/rcomp/tmp/16ihut1227547525.tab") + } > > system("convert tmp/1yz7d1227547524.ps tmp/1yz7d1227547524.png") > system("convert tmp/2ncbe1227547524.ps tmp/2ncbe1227547524.png") > system("convert tmp/3vgs01227547524.ps tmp/3vgs01227547524.png") > system("convert tmp/4joyo1227547524.ps tmp/4joyo1227547524.png") > system("convert tmp/5hzsa1227547524.ps tmp/5hzsa1227547524.png") > system("convert tmp/6ks411227547524.ps tmp/6ks411227547524.png") > system("convert tmp/7eyh91227547524.ps tmp/7eyh91227547524.png") > system("convert tmp/8wb7o1227547524.ps tmp/8wb7o1227547524.png") > system("convert tmp/9n6721227547524.ps tmp/9n6721227547524.png") > system("convert tmp/106un41227547524.ps tmp/106un41227547524.png") > > > proc.time() user system elapsed 3.936 2.547 4.559