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(124.9,1487.6,132,1320.9,151.4,1514,108.9,1290.9,121.3,1392.5,123.4,1288.2,90.3,1304.4,79.3,1297.8,117.2,1211,116.9,1454,120.8,1405.7,96.1,1160.8,100.8,1492.1,105.3,1263,116.1,1376.3,112.8,1368.6,114.5,1427.6,117.2,1339.8,77.1,1248.3,80.1,1309.8,120.3,1424,133.4,1590.5,109.4,1423.1,93.2,1355.3,91.2,1515,99.2,1385.6,108.2,1430,101.5,1494.2,106.9,1580.9,104.4,1369.8,77.9,1407.5,60,1388.3,99.5,1478.5,95,1630.4,105.6,1413.5,102.5,1493.8,93.3,1641.3,97.3,1465,127,1725.1,111.7,1628.4,96.4,1679.8,133,1876,72.2,1669.4,95.8,1712.4,124.1,1768.8,127.6,1820.5,110.7,1776.2,104.6,1693.7,112.7,1799.1,115.3,1917.5,139.4,1887.2,119,1787.8,97.4,1803.8,154,2196.4,81.5,1759.5,88.8,2002.6,127.7,2056.8,105.1,1851.1,114.9,1984.3,106.4,1725.3,104.5,2096.6,121.6,1792.2,141.4,2029.9,99,1785.3,126.7,2026.5,134.1,1930.8,81.3,1845.5,88.6,1943.1,132.7,2066.8,132.9,2354.4,134.4,2190.7,103.7,1929.6),dim=c(2,72),dimnames=list(c('transport','Import'),1:72)) > y <- array(NA,dim=c(2,72),dimnames=list(c('transport','Import'),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 transport Import M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 124.9 1487.6 1 0 0 0 0 0 0 0 0 0 0 1 2 132.0 1320.9 0 1 0 0 0 0 0 0 0 0 0 2 3 151.4 1514.0 0 0 1 0 0 0 0 0 0 0 0 3 4 108.9 1290.9 0 0 0 1 0 0 0 0 0 0 0 4 5 121.3 1392.5 0 0 0 0 1 0 0 0 0 0 0 5 6 123.4 1288.2 0 0 0 0 0 1 0 0 0 0 0 6 7 90.3 1304.4 0 0 0 0 0 0 1 0 0 0 0 7 8 79.3 1297.8 0 0 0 0 0 0 0 1 0 0 0 8 9 117.2 1211.0 0 0 0 0 0 0 0 0 1 0 0 9 10 116.9 1454.0 0 0 0 0 0 0 0 0 0 1 0 10 11 120.8 1405.7 0 0 0 0 0 0 0 0 0 0 1 11 12 96.1 1160.8 0 0 0 0 0 0 0 0 0 0 0 12 13 100.8 1492.1 1 0 0 0 0 0 0 0 0 0 0 13 14 105.3 1263.0 0 1 0 0 0 0 0 0 0 0 0 14 15 116.1 1376.3 0 0 1 0 0 0 0 0 0 0 0 15 16 112.8 1368.6 0 0 0 1 0 0 0 0 0 0 0 16 17 114.5 1427.6 0 0 0 0 1 0 0 0 0 0 0 17 18 117.2 1339.8 0 0 0 0 0 1 0 0 0 0 0 18 19 77.1 1248.3 0 0 0 0 0 0 1 0 0 0 0 19 20 80.1 1309.8 0 0 0 0 0 0 0 1 0 0 0 20 21 120.3 1424.0 0 0 0 0 0 0 0 0 1 0 0 21 22 133.4 1590.5 0 0 0 0 0 0 0 0 0 1 0 22 23 109.4 1423.1 0 0 0 0 0 0 0 0 0 0 1 23 24 93.2 1355.3 0 0 0 0 0 0 0 0 0 0 0 24 25 91.2 1515.0 1 0 0 0 0 0 0 0 0 0 0 25 26 99.2 1385.6 0 1 0 0 0 0 0 0 0 0 0 26 27 108.2 1430.0 0 0 1 0 0 0 0 0 0 0 0 27 28 101.5 1494.2 0 0 0 1 0 0 0 0 0 0 0 28 29 106.9 1580.9 0 0 0 0 1 0 0 0 0 0 0 29 30 104.4 1369.8 0 0 0 0 0 1 0 0 0 0 0 30 31 77.9 1407.5 0 0 0 0 0 0 1 0 0 0 0 31 32 60.0 1388.3 0 0 0 0 0 0 0 1 0 0 0 32 33 99.5 1478.5 0 0 0 0 0 0 0 0 1 0 0 33 34 95.0 1630.4 0 0 0 0 0 0 0 0 0 1 0 34 35 105.6 1413.5 0 0 0 0 0 0 0 0 0 0 1 35 36 102.5 1493.8 0 0 0 0 0 0 0 0 0 0 0 36 37 93.3 1641.3 1 0 0 0 0 0 0 0 0 0 0 37 38 97.3 1465.0 0 1 0 0 0 0 0 0 0 0 0 38 39 127.0 1725.1 0 0 1 0 0 0 0 0 0 0 0 39 40 111.7 1628.4 0 0 0 1 0 0 0 0 0 0 0 40 41 96.4 1679.8 0 0 0 0 1 0 0 0 0 0 0 41 42 133.0 1876.0 0 0 0 0 0 1 0 0 0 0 0 42 43 72.2 1669.4 0 0 0 0 0 0 1 0 0 0 0 43 44 95.8 1712.4 0 0 0 0 0 0 0 1 0 0 0 44 45 124.1 1768.8 0 0 0 0 0 0 0 0 1 0 0 45 46 127.6 1820.5 0 0 0 0 0 0 0 0 0 1 0 46 47 110.7 1776.2 0 0 0 0 0 0 0 0 0 0 1 47 48 104.6 1693.7 0 0 0 0 0 0 0 0 0 0 0 48 49 112.7 1799.1 1 0 0 0 0 0 0 0 0 0 0 49 50 115.3 1917.5 0 1 0 0 0 0 0 0 0 0 0 50 51 139.4 1887.2 0 0 1 0 0 0 0 0 0 0 0 51 52 119.0 1787.8 0 0 0 1 0 0 0 0 0 0 0 52 53 97.4 1803.8 0 0 0 0 1 0 0 0 0 0 0 53 54 154.0 2196.4 0 0 0 0 0 1 0 0 0 0 0 54 55 81.5 1759.5 0 0 0 0 0 0 1 0 0 0 0 55 56 88.8 2002.6 0 0 0 0 0 0 0 1 0 0 0 56 57 127.7 2056.8 0 0 0 0 0 0 0 0 1 0 0 57 58 105.1 1851.1 0 0 0 0 0 0 0 0 0 1 0 58 59 114.9 1984.3 0 0 0 0 0 0 0 0 0 0 1 59 60 106.4 1725.3 0 0 0 0 0 0 0 0 0 0 0 60 61 104.5 2096.6 1 0 0 0 0 0 0 0 0 0 0 61 62 121.6 1792.2 0 1 0 0 0 0 0 0 0 0 0 62 63 141.4 2029.9 0 0 1 0 0 0 0 0 0 0 0 63 64 99.0 1785.3 0 0 0 1 0 0 0 0 0 0 0 64 65 126.7 2026.5 0 0 0 0 1 0 0 0 0 0 0 65 66 134.1 1930.8 0 0 0 0 0 1 0 0 0 0 0 66 67 81.3 1845.5 0 0 0 0 0 0 1 0 0 0 0 67 68 88.6 1943.1 0 0 0 0 0 0 0 1 0 0 0 68 69 132.7 2066.8 0 0 0 0 0 0 0 0 1 0 0 69 70 132.9 2354.4 0 0 0 0 0 0 0 0 0 1 0 70 71 134.4 2190.7 0 0 0 0 0 0 0 0 0 0 1 71 72 103.7 1929.6 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) Import M1 M2 M3 M4 12.45598 0.08027 -15.09938 4.86050 13.58428 0.81243 M5 M6 M7 M8 M9 M10 -4.03685 12.78114 -23.72901 -26.41892 7.89414 -2.29929 M11 t 2.84244 -0.87063 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -16.4198 -6.0561 -0.3087 6.2876 14.7352 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 12.455975 10.557965 1.180 0.24291 Import 0.080265 0.009313 8.618 5.69e-12 *** M1 -15.099376 5.266853 -2.867 0.00577 ** M2 4.860502 4.808979 1.011 0.31635 M3 13.584279 5.123560 2.651 0.01032 * M4 0.812433 4.818747 0.169 0.86670 M5 -4.036853 5.008944 -0.806 0.42358 M6 12.781136 5.015155 2.549 0.01349 * M7 -23.729008 4.740770 -5.005 5.51e-06 *** M8 -26.418924 4.810629 -5.492 9.22e-07 *** M9 7.894145 4.909453 1.608 0.11328 M10 -2.299292 5.255409 -0.438 0.66337 M11 2.842444 4.926400 0.577 0.56618 t -0.870631 0.121532 -7.164 1.56e-09 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 8.176 on 58 degrees of freedom Multiple R-squared: 0.848, Adjusted R-squared: 0.814 F-statistic: 24.9 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.19821574 0.3964315 0.8017843 [2,] 0.08818522 0.1763704 0.9118148 [3,] 0.11504942 0.2300988 0.8849506 [4,] 0.14914212 0.2982842 0.8508579 [5,] 0.20026141 0.4005228 0.7997386 [6,] 0.33728491 0.6745698 0.6627151 [7,] 0.25187201 0.5037440 0.7481280 [8,] 0.29487214 0.5897443 0.7051279 [9,] 0.22474578 0.4494916 0.7752542 [10,] 0.20368281 0.4073656 0.7963172 [11,] 0.15488130 0.3097626 0.8451187 [12,] 0.11407444 0.2281489 0.8859256 [13,] 0.09287721 0.1857544 0.9071228 [14,] 0.06628106 0.1325621 0.9337189 [15,] 0.05701755 0.1140351 0.9429824 [16,] 0.05095284 0.1019057 0.9490472 [17,] 0.07465669 0.1493134 0.9253433 [18,] 0.18010377 0.3602075 0.8198962 [19,] 0.22136584 0.4427317 0.7786342 [20,] 0.21243211 0.4248642 0.7875679 [21,] 0.16941890 0.3388378 0.8305811 [22,] 0.13429308 0.2685862 0.8657069 [23,] 0.10855003 0.2171001 0.8914500 [24,] 0.10028539 0.2005708 0.8997146 [25,] 0.10398767 0.2079753 0.8960123 [26,] 0.08441402 0.1688280 0.9155860 [27,] 0.09575903 0.1915181 0.9042410 [28,] 0.16565540 0.3313108 0.8343446 [29,] 0.11762883 0.2352577 0.8823712 [30,] 0.24500895 0.4900179 0.7549911 [31,] 0.19027638 0.3805528 0.8097236 [32,] 0.13427749 0.2685550 0.8657225 [33,] 0.37076747 0.7415349 0.6292325 [34,] 0.45879259 0.9175852 0.5412074 [35,] 0.40048333 0.8009667 0.5995167 [36,] 0.59176705 0.8164659 0.4082329 [37,] 0.76033111 0.4793378 0.2396689 [38,] 0.65527753 0.6894449 0.3447225 [39,] 0.52463507 0.9507299 0.4753649 > postscript(file="/var/www/html/freestat/rcomp/tmp/18hp71229557196.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/22gds1229557196.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/3o41t1229557196.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/4r35y1229557196.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/5xcat1229557196.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 9.01132240 10.40230624 6.44992410 -4.50040289 5.46455571 -0.01112782 7 8 9 10 11 12 2.96934858 -3.94035344 7.48423925 -1.25616894 2.24954165 0.91959620 13 14 15 16 17 18 -5.00230157 -1.20276095 -7.34996951 3.61055076 6.29481255 0.09475103 19 20 21 22 23 24 4.71980380 6.34403259 3.93529334 14.73518314 -0.09950511 -7.14444104 25 26 27 28 29 30 -5.99280766 -6.69572075 -9.11264786 -7.32320504 -3.16229297 -4.66563893 31 32 33 34 35 36 3.18913281 -9.60922602 -10.79159727 -16.41983362 7.31861212 1.48638036 37 38 39 40 41 42 -3.58274919 -4.52121816 -3.55137761 2.55275730 -11.15296438 -6.24838048 43 44 45 46 47 48 -13.08478788 10.62434958 0.95494658 11.36929660 -6.24605414 -2.01108968 49 50 51 52 53 54 13.59895129 -12.39371132 6.28518194 7.50603325 -9.65829564 -0.51782315 55 56 57 58 59 60 -0.56912435 -9.22108003 -8.11389930 -3.13925255 -8.30169991 7.70009583 61 62 63 64 65 66 -8.03241526 14.41110494 7.27888895 -1.84573339 12.21418473 11.34821934 67 68 69 70 71 72 2.77562704 5.80227731 6.53101740 -5.28922463 5.07910539 -0.95054167 > postscript(file="/var/www/html/freestat/rcomp/tmp/6rx2c1229557196.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 9.01132240 NA 1 10.40230624 9.01132240 2 6.44992410 10.40230624 3 -4.50040289 6.44992410 4 5.46455571 -4.50040289 5 -0.01112782 5.46455571 6 2.96934858 -0.01112782 7 -3.94035344 2.96934858 8 7.48423925 -3.94035344 9 -1.25616894 7.48423925 10 2.24954165 -1.25616894 11 0.91959620 2.24954165 12 -5.00230157 0.91959620 13 -1.20276095 -5.00230157 14 -7.34996951 -1.20276095 15 3.61055076 -7.34996951 16 6.29481255 3.61055076 17 0.09475103 6.29481255 18 4.71980380 0.09475103 19 6.34403259 4.71980380 20 3.93529334 6.34403259 21 14.73518314 3.93529334 22 -0.09950511 14.73518314 23 -7.14444104 -0.09950511 24 -5.99280766 -7.14444104 25 -6.69572075 -5.99280766 26 -9.11264786 -6.69572075 27 -7.32320504 -9.11264786 28 -3.16229297 -7.32320504 29 -4.66563893 -3.16229297 30 3.18913281 -4.66563893 31 -9.60922602 3.18913281 32 -10.79159727 -9.60922602 33 -16.41983362 -10.79159727 34 7.31861212 -16.41983362 35 1.48638036 7.31861212 36 -3.58274919 1.48638036 37 -4.52121816 -3.58274919 38 -3.55137761 -4.52121816 39 2.55275730 -3.55137761 40 -11.15296438 2.55275730 41 -6.24838048 -11.15296438 42 -13.08478788 -6.24838048 43 10.62434958 -13.08478788 44 0.95494658 10.62434958 45 11.36929660 0.95494658 46 -6.24605414 11.36929660 47 -2.01108968 -6.24605414 48 13.59895129 -2.01108968 49 -12.39371132 13.59895129 50 6.28518194 -12.39371132 51 7.50603325 6.28518194 52 -9.65829564 7.50603325 53 -0.51782315 -9.65829564 54 -0.56912435 -0.51782315 55 -9.22108003 -0.56912435 56 -8.11389930 -9.22108003 57 -3.13925255 -8.11389930 58 -8.30169991 -3.13925255 59 7.70009583 -8.30169991 60 -8.03241526 7.70009583 61 14.41110494 -8.03241526 62 7.27888895 14.41110494 63 -1.84573339 7.27888895 64 12.21418473 -1.84573339 65 11.34821934 12.21418473 66 2.77562704 11.34821934 67 5.80227731 2.77562704 68 6.53101740 5.80227731 69 -5.28922463 6.53101740 70 5.07910539 -5.28922463 71 -0.95054167 5.07910539 72 NA -0.95054167 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 10.40230624 9.01132240 [2,] 6.44992410 10.40230624 [3,] -4.50040289 6.44992410 [4,] 5.46455571 -4.50040289 [5,] -0.01112782 5.46455571 [6,] 2.96934858 -0.01112782 [7,] -3.94035344 2.96934858 [8,] 7.48423925 -3.94035344 [9,] -1.25616894 7.48423925 [10,] 2.24954165 -1.25616894 [11,] 0.91959620 2.24954165 [12,] -5.00230157 0.91959620 [13,] -1.20276095 -5.00230157 [14,] -7.34996951 -1.20276095 [15,] 3.61055076 -7.34996951 [16,] 6.29481255 3.61055076 [17,] 0.09475103 6.29481255 [18,] 4.71980380 0.09475103 [19,] 6.34403259 4.71980380 [20,] 3.93529334 6.34403259 [21,] 14.73518314 3.93529334 [22,] -0.09950511 14.73518314 [23,] -7.14444104 -0.09950511 [24,] -5.99280766 -7.14444104 [25,] -6.69572075 -5.99280766 [26,] -9.11264786 -6.69572075 [27,] -7.32320504 -9.11264786 [28,] -3.16229297 -7.32320504 [29,] -4.66563893 -3.16229297 [30,] 3.18913281 -4.66563893 [31,] -9.60922602 3.18913281 [32,] -10.79159727 -9.60922602 [33,] -16.41983362 -10.79159727 [34,] 7.31861212 -16.41983362 [35,] 1.48638036 7.31861212 [36,] -3.58274919 1.48638036 [37,] -4.52121816 -3.58274919 [38,] -3.55137761 -4.52121816 [39,] 2.55275730 -3.55137761 [40,] -11.15296438 2.55275730 [41,] -6.24838048 -11.15296438 [42,] -13.08478788 -6.24838048 [43,] 10.62434958 -13.08478788 [44,] 0.95494658 10.62434958 [45,] 11.36929660 0.95494658 [46,] -6.24605414 11.36929660 [47,] -2.01108968 -6.24605414 [48,] 13.59895129 -2.01108968 [49,] -12.39371132 13.59895129 [50,] 6.28518194 -12.39371132 [51,] 7.50603325 6.28518194 [52,] -9.65829564 7.50603325 [53,] -0.51782315 -9.65829564 [54,] -0.56912435 -0.51782315 [55,] -9.22108003 -0.56912435 [56,] -8.11389930 -9.22108003 [57,] -3.13925255 -8.11389930 [58,] -8.30169991 -3.13925255 [59,] 7.70009583 -8.30169991 [60,] -8.03241526 7.70009583 [61,] 14.41110494 -8.03241526 [62,] 7.27888895 14.41110494 [63,] -1.84573339 7.27888895 [64,] 12.21418473 -1.84573339 [65,] 11.34821934 12.21418473 [66,] 2.77562704 11.34821934 [67,] 5.80227731 2.77562704 [68,] 6.53101740 5.80227731 [69,] -5.28922463 6.53101740 [70,] 5.07910539 -5.28922463 [71,] -0.95054167 5.07910539 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 10.40230624 9.01132240 2 6.44992410 10.40230624 3 -4.50040289 6.44992410 4 5.46455571 -4.50040289 5 -0.01112782 5.46455571 6 2.96934858 -0.01112782 7 -3.94035344 2.96934858 8 7.48423925 -3.94035344 9 -1.25616894 7.48423925 10 2.24954165 -1.25616894 11 0.91959620 2.24954165 12 -5.00230157 0.91959620 13 -1.20276095 -5.00230157 14 -7.34996951 -1.20276095 15 3.61055076 -7.34996951 16 6.29481255 3.61055076 17 0.09475103 6.29481255 18 4.71980380 0.09475103 19 6.34403259 4.71980380 20 3.93529334 6.34403259 21 14.73518314 3.93529334 22 -0.09950511 14.73518314 23 -7.14444104 -0.09950511 24 -5.99280766 -7.14444104 25 -6.69572075 -5.99280766 26 -9.11264786 -6.69572075 27 -7.32320504 -9.11264786 28 -3.16229297 -7.32320504 29 -4.66563893 -3.16229297 30 3.18913281 -4.66563893 31 -9.60922602 3.18913281 32 -10.79159727 -9.60922602 33 -16.41983362 -10.79159727 34 7.31861212 -16.41983362 35 1.48638036 7.31861212 36 -3.58274919 1.48638036 37 -4.52121816 -3.58274919 38 -3.55137761 -4.52121816 39 2.55275730 -3.55137761 40 -11.15296438 2.55275730 41 -6.24838048 -11.15296438 42 -13.08478788 -6.24838048 43 10.62434958 -13.08478788 44 0.95494658 10.62434958 45 11.36929660 0.95494658 46 -6.24605414 11.36929660 47 -2.01108968 -6.24605414 48 13.59895129 -2.01108968 49 -12.39371132 13.59895129 50 6.28518194 -12.39371132 51 7.50603325 6.28518194 52 -9.65829564 7.50603325 53 -0.51782315 -9.65829564 54 -0.56912435 -0.51782315 55 -9.22108003 -0.56912435 56 -8.11389930 -9.22108003 57 -3.13925255 -8.11389930 58 -8.30169991 -3.13925255 59 7.70009583 -8.30169991 60 -8.03241526 7.70009583 61 14.41110494 -8.03241526 62 7.27888895 14.41110494 63 -1.84573339 7.27888895 64 12.21418473 -1.84573339 65 11.34821934 12.21418473 66 2.77562704 11.34821934 67 5.80227731 2.77562704 68 6.53101740 5.80227731 69 -5.28922463 6.53101740 70 5.07910539 -5.28922463 71 -0.95054167 5.07910539 > 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/73ji01229557196.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/8f6t11229557196.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/9yhgi1229557196.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/10sdiv1229557196.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/11ze5x1229557196.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/12jqyv1229557196.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/1309jo1229557196.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/14i1os1229557196.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/15fm5m1229557196.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/1624tv1229557196.tab") + } > > system("convert tmp/18hp71229557196.ps tmp/18hp71229557196.png") > system("convert tmp/22gds1229557196.ps tmp/22gds1229557196.png") > system("convert tmp/3o41t1229557196.ps tmp/3o41t1229557196.png") > system("convert tmp/4r35y1229557196.ps tmp/4r35y1229557196.png") > system("convert tmp/5xcat1229557196.ps tmp/5xcat1229557196.png") > system("convert tmp/6rx2c1229557196.ps tmp/6rx2c1229557196.png") > system("convert tmp/73ji01229557196.ps tmp/73ji01229557196.png") > system("convert tmp/8f6t11229557196.ps tmp/8f6t11229557196.png") > system("convert tmp/9yhgi1229557196.ps tmp/9yhgi1229557196.png") > system("convert tmp/10sdiv1229557196.ps tmp/10sdiv1229557196.png") > > > proc.time() user system elapsed 3.823 2.527 4.334