R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-pc-linux-gnu (32-bit) 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(15579,16348,15928,16171,15937,15713,15594,15683,16438,17032,17696,17745,19394,20148,20108,18584,18441,18391,19178,18079,18483,19644,19195,19650,20830,23595,22937,21814,21928,21777,21383,21467,22052,22680,24320,24977,25204,25739,26434,27525,30695,32436,30160,30236,31293,31077,32226,33865,32810,32242,32700,32819,33947,34148,35261,39506,41591,39148,41216,40225,41126,42362,40740,40256,39804,41002,41702,42254,43605,43271),dim=c(1,70),dimnames=list(c('Goudprijs'),1:70)) > y <- array(NA,dim=c(1,70),dimnames=list(c('Goudprijs'),1:70)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par20 = '' > par19 = '' > par18 = '' > par17 = '' > par16 = '' > par15 = '' > par14 = '' > par13 = '' > par12 = '' > par11 = '' > par10 = '' > par9 = '' > par8 = '' > par7 = '' > par6 = '' > par5 = '' > par4 = '' > par3 = 'Linear Trend' > par2 = 'Include Monthly Dummies' > par1 = '1' > library(lattice) > library(lmtest) Loading required package: zoo Attaching package: 'zoo' The following object(s) are masked from 'package:base': as.Date, 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 Goudprijs M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 15579 1 0 0 0 0 0 0 0 0 0 0 1 2 16348 0 1 0 0 0 0 0 0 0 0 0 2 3 15928 0 0 1 0 0 0 0 0 0 0 0 3 4 16171 0 0 0 1 0 0 0 0 0 0 0 4 5 15937 0 0 0 0 1 0 0 0 0 0 0 5 6 15713 0 0 0 0 0 1 0 0 0 0 0 6 7 15594 0 0 0 0 0 0 1 0 0 0 0 7 8 15683 0 0 0 0 0 0 0 1 0 0 0 8 9 16438 0 0 0 0 0 0 0 0 1 0 0 9 10 17032 0 0 0 0 0 0 0 0 0 1 0 10 11 17696 0 0 0 0 0 0 0 0 0 0 1 11 12 17745 0 0 0 0 0 0 0 0 0 0 0 12 13 19394 1 0 0 0 0 0 0 0 0 0 0 13 14 20148 0 1 0 0 0 0 0 0 0 0 0 14 15 20108 0 0 1 0 0 0 0 0 0 0 0 15 16 18584 0 0 0 1 0 0 0 0 0 0 0 16 17 18441 0 0 0 0 1 0 0 0 0 0 0 17 18 18391 0 0 0 0 0 1 0 0 0 0 0 18 19 19178 0 0 0 0 0 0 1 0 0 0 0 19 20 18079 0 0 0 0 0 0 0 1 0 0 0 20 21 18483 0 0 0 0 0 0 0 0 1 0 0 21 22 19644 0 0 0 0 0 0 0 0 0 1 0 22 23 19195 0 0 0 0 0 0 0 0 0 0 1 23 24 19650 0 0 0 0 0 0 0 0 0 0 0 24 25 20830 1 0 0 0 0 0 0 0 0 0 0 25 26 23595 0 1 0 0 0 0 0 0 0 0 0 26 27 22937 0 0 1 0 0 0 0 0 0 0 0 27 28 21814 0 0 0 1 0 0 0 0 0 0 0 28 29 21928 0 0 0 0 1 0 0 0 0 0 0 29 30 21777 0 0 0 0 0 1 0 0 0 0 0 30 31 21383 0 0 0 0 0 0 1 0 0 0 0 31 32 21467 0 0 0 0 0 0 0 1 0 0 0 32 33 22052 0 0 0 0 0 0 0 0 1 0 0 33 34 22680 0 0 0 0 0 0 0 0 0 1 0 34 35 24320 0 0 0 0 0 0 0 0 0 0 1 35 36 24977 0 0 0 0 0 0 0 0 0 0 0 36 37 25204 1 0 0 0 0 0 0 0 0 0 0 37 38 25739 0 1 0 0 0 0 0 0 0 0 0 38 39 26434 0 0 1 0 0 0 0 0 0 0 0 39 40 27525 0 0 0 1 0 0 0 0 0 0 0 40 41 30695 0 0 0 0 1 0 0 0 0 0 0 41 42 32436 0 0 0 0 0 1 0 0 0 0 0 42 43 30160 0 0 0 0 0 0 1 0 0 0 0 43 44 30236 0 0 0 0 0 0 0 1 0 0 0 44 45 31293 0 0 0 0 0 0 0 0 1 0 0 45 46 31077 0 0 0 0 0 0 0 0 0 1 0 46 47 32226 0 0 0 0 0 0 0 0 0 0 1 47 48 33865 0 0 0 0 0 0 0 0 0 0 0 48 49 32810 1 0 0 0 0 0 0 0 0 0 0 49 50 32242 0 1 0 0 0 0 0 0 0 0 0 50 51 32700 0 0 1 0 0 0 0 0 0 0 0 51 52 32819 0 0 0 1 0 0 0 0 0 0 0 52 53 33947 0 0 0 0 1 0 0 0 0 0 0 53 54 34148 0 0 0 0 0 1 0 0 0 0 0 54 55 35261 0 0 0 0 0 0 1 0 0 0 0 55 56 39506 0 0 0 0 0 0 0 1 0 0 0 56 57 41591 0 0 0 0 0 0 0 0 1 0 0 57 58 39148 0 0 0 0 0 0 0 0 0 1 0 58 59 41216 0 0 0 0 0 0 0 0 0 0 1 59 60 40225 0 0 0 0 0 0 0 0 0 0 0 60 61 41126 1 0 0 0 0 0 0 0 0 0 0 61 62 42362 0 1 0 0 0 0 0 0 0 0 0 62 63 40740 0 0 1 0 0 0 0 0 0 0 0 63 64 40256 0 0 0 1 0 0 0 0 0 0 0 64 65 39804 0 0 0 0 1 0 0 0 0 0 0 65 66 41002 0 0 0 0 0 1 0 0 0 0 0 66 67 41702 0 0 0 0 0 0 1 0 0 0 0 67 68 42254 0 0 0 0 0 0 0 1 0 0 0 68 69 43605 0 0 0 0 0 0 0 0 1 0 0 69 70 43271 0 0 0 0 0 0 0 0 0 1 0 70 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) M1 M2 M3 M4 M5 11304.02 752.04 1223.09 514.46 -209.32 -56.28 M6 M7 M8 M9 M10 M11 -47.90 -523.52 -309.81 285.57 -260.22 82.32 t 444.12 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -4193.6 -1755.5 9.9 1516.3 4686.5 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 11304.02 1151.51 9.817 7.38e-14 *** M1 752.04 1407.11 0.534 0.595 M2 1223.09 1406.50 0.870 0.388 M3 514.46 1406.02 0.366 0.716 M4 -209.32 1405.68 -0.149 0.882 M5 -56.28 1405.47 -0.040 0.968 M6 -47.90 1405.41 -0.034 0.973 M7 -523.52 1405.47 -0.372 0.711 M8 -309.81 1405.68 -0.220 0.826 M9 285.57 1406.02 0.203 0.840 M10 -260.22 1406.50 -0.185 0.854 M11 82.32 1467.96 0.056 0.955 t 444.12 13.85 32.065 < 2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 2321 on 57 degrees of freedom Multiple R-squared: 0.948, Adjusted R-squared: 0.9371 F-statistic: 86.6 on 12 and 57 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,] 3.741519e-02 7.483037e-02 0.9625848 [2,] 2.077737e-02 4.155474e-02 0.9792226 [3,] 8.071879e-03 1.614376e-02 0.9919281 [4,] 2.884448e-03 5.768895e-03 0.9971156 [5,] 1.441057e-03 2.882113e-03 0.9985589 [6,] 9.778045e-04 1.955609e-03 0.9990222 [7,] 3.575651e-04 7.151303e-04 0.9996424 [8,] 4.410008e-04 8.820015e-04 0.9995590 [9,] 2.292295e-04 4.584589e-04 0.9997708 [10,] 1.150889e-04 2.301778e-04 0.9998849 [11,] 1.817756e-04 3.635511e-04 0.9998182 [12,] 1.315561e-04 2.631122e-04 0.9998684 [13,] 5.567727e-05 1.113545e-04 0.9999443 [14,] 2.140982e-05 4.281965e-05 0.9999786 [15,] 7.321367e-06 1.464273e-05 0.9999927 [16,] 2.578622e-06 5.157244e-06 0.9999974 [17,] 1.058052e-06 2.116104e-06 0.9999989 [18,] 7.313893e-07 1.462779e-06 0.9999993 [19,] 2.926206e-07 5.852411e-07 0.9999997 [20,] 9.696923e-07 1.939385e-06 0.9999990 [21,] 4.714765e-06 9.429531e-06 0.9999953 [22,] 3.138925e-06 6.277850e-06 0.9999969 [23,] 2.246245e-06 4.492491e-06 0.9999978 [24,] 1.149359e-06 2.298718e-06 0.9999989 [25,] 1.225727e-05 2.451453e-05 0.9999877 [26,] 1.638595e-02 3.277189e-02 0.9836141 [27,] 4.551636e-01 9.103273e-01 0.5448364 [28,] 5.442234e-01 9.115533e-01 0.4557766 [29,] 5.754269e-01 8.491462e-01 0.4245731 [30,] 6.209190e-01 7.581620e-01 0.3790810 [31,] 5.749179e-01 8.501642e-01 0.4250821 [32,] 6.124867e-01 7.750266e-01 0.3875133 [33,] 5.889560e-01 8.220879e-01 0.4110440 [34,] 5.486427e-01 9.027146e-01 0.4513573 [35,] 7.075132e-01 5.849735e-01 0.2924868 [36,] 7.208886e-01 5.582227e-01 0.2791114 [37,] 7.250310e-01 5.499380e-01 0.2749690 [38,] 6.221230e-01 7.557541e-01 0.3778770 [39,] 6.521847e-01 6.956307e-01 0.3478153 > postscript(file="/var/wessaorg/rcomp/tmp/1grn71355057851.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/wessaorg/rcomp/tmp/2q26q1355057851.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/wessaorg/rcomp/tmp/394qy1355057851.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/wessaorg/rcomp/tmp/4ff1i1355057851.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/wessaorg/rcomp/tmp/5kkf71355057851.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 = 70 Frequency = 1 1 2 3 4 5 6 3078.81410 2932.64744 2777.14744 3299.81410 2468.64744 1792.14744 7 8 9 10 11 12 1704.64744 1135.81410 851.31410 1546.98077 1424.31795 1111.51795 13 14 15 16 17 18 1564.35513 1403.18846 1627.68846 383.35513 -356.81154 -859.31154 19 20 21 22 23 24 -40.81154 -1797.64487 -2433.14487 -1170.47821 -2406.14103 -2312.94103 25 26 27 28 29 30 -2329.10385 -479.27051 -872.77051 -1716.10385 -2199.27051 -2802.77051 31 32 33 34 35 36 -3165.27051 -3739.10385 -4193.60385 -3463.93718 -2610.60000 -2315.40000 37 38 39 40 41 42 -3284.56282 -3664.72949 -2705.22949 -1334.56282 1238.27051 2526.77051 43 44 45 46 47 48 282.27051 -299.56282 -282.06282 -396.39615 -34.05897 1243.14103 49 50 51 52 53 54 -1008.02179 -2491.18846 -1768.68846 -1370.02179 -839.18846 -1090.68846 55 56 57 58 59 60 53.81154 3640.97821 4686.47821 2345.14487 3626.48205 2273.68205 61 62 63 64 65 66 1978.51923 2299.35256 941.85256 737.51923 -311.64744 433.85256 67 68 69 70 1165.35256 1059.51923 1371.01923 1138.68590 > postscript(file="/var/wessaorg/rcomp/tmp/6omb51355057851.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 = 70 Frequency = 1 lag(myerror, k = 1) myerror 0 3078.81410 NA 1 2932.64744 3078.81410 2 2777.14744 2932.64744 3 3299.81410 2777.14744 4 2468.64744 3299.81410 5 1792.14744 2468.64744 6 1704.64744 1792.14744 7 1135.81410 1704.64744 8 851.31410 1135.81410 9 1546.98077 851.31410 10 1424.31795 1546.98077 11 1111.51795 1424.31795 12 1564.35513 1111.51795 13 1403.18846 1564.35513 14 1627.68846 1403.18846 15 383.35513 1627.68846 16 -356.81154 383.35513 17 -859.31154 -356.81154 18 -40.81154 -859.31154 19 -1797.64487 -40.81154 20 -2433.14487 -1797.64487 21 -1170.47821 -2433.14487 22 -2406.14103 -1170.47821 23 -2312.94103 -2406.14103 24 -2329.10385 -2312.94103 25 -479.27051 -2329.10385 26 -872.77051 -479.27051 27 -1716.10385 -872.77051 28 -2199.27051 -1716.10385 29 -2802.77051 -2199.27051 30 -3165.27051 -2802.77051 31 -3739.10385 -3165.27051 32 -4193.60385 -3739.10385 33 -3463.93718 -4193.60385 34 -2610.60000 -3463.93718 35 -2315.40000 -2610.60000 36 -3284.56282 -2315.40000 37 -3664.72949 -3284.56282 38 -2705.22949 -3664.72949 39 -1334.56282 -2705.22949 40 1238.27051 -1334.56282 41 2526.77051 1238.27051 42 282.27051 2526.77051 43 -299.56282 282.27051 44 -282.06282 -299.56282 45 -396.39615 -282.06282 46 -34.05897 -396.39615 47 1243.14103 -34.05897 48 -1008.02179 1243.14103 49 -2491.18846 -1008.02179 50 -1768.68846 -2491.18846 51 -1370.02179 -1768.68846 52 -839.18846 -1370.02179 53 -1090.68846 -839.18846 54 53.81154 -1090.68846 55 3640.97821 53.81154 56 4686.47821 3640.97821 57 2345.14487 4686.47821 58 3626.48205 2345.14487 59 2273.68205 3626.48205 60 1978.51923 2273.68205 61 2299.35256 1978.51923 62 941.85256 2299.35256 63 737.51923 941.85256 64 -311.64744 737.51923 65 433.85256 -311.64744 66 1165.35256 433.85256 67 1059.51923 1165.35256 68 1371.01923 1059.51923 69 1138.68590 1371.01923 70 NA 1138.68590 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 2932.64744 3078.81410 [2,] 2777.14744 2932.64744 [3,] 3299.81410 2777.14744 [4,] 2468.64744 3299.81410 [5,] 1792.14744 2468.64744 [6,] 1704.64744 1792.14744 [7,] 1135.81410 1704.64744 [8,] 851.31410 1135.81410 [9,] 1546.98077 851.31410 [10,] 1424.31795 1546.98077 [11,] 1111.51795 1424.31795 [12,] 1564.35513 1111.51795 [13,] 1403.18846 1564.35513 [14,] 1627.68846 1403.18846 [15,] 383.35513 1627.68846 [16,] -356.81154 383.35513 [17,] -859.31154 -356.81154 [18,] -40.81154 -859.31154 [19,] -1797.64487 -40.81154 [20,] -2433.14487 -1797.64487 [21,] -1170.47821 -2433.14487 [22,] -2406.14103 -1170.47821 [23,] -2312.94103 -2406.14103 [24,] -2329.10385 -2312.94103 [25,] -479.27051 -2329.10385 [26,] -872.77051 -479.27051 [27,] -1716.10385 -872.77051 [28,] -2199.27051 -1716.10385 [29,] -2802.77051 -2199.27051 [30,] -3165.27051 -2802.77051 [31,] -3739.10385 -3165.27051 [32,] -4193.60385 -3739.10385 [33,] -3463.93718 -4193.60385 [34,] -2610.60000 -3463.93718 [35,] -2315.40000 -2610.60000 [36,] -3284.56282 -2315.40000 [37,] -3664.72949 -3284.56282 [38,] -2705.22949 -3664.72949 [39,] -1334.56282 -2705.22949 [40,] 1238.27051 -1334.56282 [41,] 2526.77051 1238.27051 [42,] 282.27051 2526.77051 [43,] -299.56282 282.27051 [44,] -282.06282 -299.56282 [45,] -396.39615 -282.06282 [46,] -34.05897 -396.39615 [47,] 1243.14103 -34.05897 [48,] -1008.02179 1243.14103 [49,] -2491.18846 -1008.02179 [50,] -1768.68846 -2491.18846 [51,] -1370.02179 -1768.68846 [52,] -839.18846 -1370.02179 [53,] -1090.68846 -839.18846 [54,] 53.81154 -1090.68846 [55,] 3640.97821 53.81154 [56,] 4686.47821 3640.97821 [57,] 2345.14487 4686.47821 [58,] 3626.48205 2345.14487 [59,] 2273.68205 3626.48205 [60,] 1978.51923 2273.68205 [61,] 2299.35256 1978.51923 [62,] 941.85256 2299.35256 [63,] 737.51923 941.85256 [64,] -311.64744 737.51923 [65,] 433.85256 -311.64744 [66,] 1165.35256 433.85256 [67,] 1059.51923 1165.35256 [68,] 1371.01923 1059.51923 [69,] 1138.68590 1371.01923 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 2932.64744 3078.81410 2 2777.14744 2932.64744 3 3299.81410 2777.14744 4 2468.64744 3299.81410 5 1792.14744 2468.64744 6 1704.64744 1792.14744 7 1135.81410 1704.64744 8 851.31410 1135.81410 9 1546.98077 851.31410 10 1424.31795 1546.98077 11 1111.51795 1424.31795 12 1564.35513 1111.51795 13 1403.18846 1564.35513 14 1627.68846 1403.18846 15 383.35513 1627.68846 16 -356.81154 383.35513 17 -859.31154 -356.81154 18 -40.81154 -859.31154 19 -1797.64487 -40.81154 20 -2433.14487 -1797.64487 21 -1170.47821 -2433.14487 22 -2406.14103 -1170.47821 23 -2312.94103 -2406.14103 24 -2329.10385 -2312.94103 25 -479.27051 -2329.10385 26 -872.77051 -479.27051 27 -1716.10385 -872.77051 28 -2199.27051 -1716.10385 29 -2802.77051 -2199.27051 30 -3165.27051 -2802.77051 31 -3739.10385 -3165.27051 32 -4193.60385 -3739.10385 33 -3463.93718 -4193.60385 34 -2610.60000 -3463.93718 35 -2315.40000 -2610.60000 36 -3284.56282 -2315.40000 37 -3664.72949 -3284.56282 38 -2705.22949 -3664.72949 39 -1334.56282 -2705.22949 40 1238.27051 -1334.56282 41 2526.77051 1238.27051 42 282.27051 2526.77051 43 -299.56282 282.27051 44 -282.06282 -299.56282 45 -396.39615 -282.06282 46 -34.05897 -396.39615 47 1243.14103 -34.05897 48 -1008.02179 1243.14103 49 -2491.18846 -1008.02179 50 -1768.68846 -2491.18846 51 -1370.02179 -1768.68846 52 -839.18846 -1370.02179 53 -1090.68846 -839.18846 54 53.81154 -1090.68846 55 3640.97821 53.81154 56 4686.47821 3640.97821 57 2345.14487 4686.47821 58 3626.48205 2345.14487 59 2273.68205 3626.48205 60 1978.51923 2273.68205 61 2299.35256 1978.51923 62 941.85256 2299.35256 63 737.51923 941.85256 64 -311.64744 737.51923 65 433.85256 -311.64744 66 1165.35256 433.85256 67 1059.51923 1165.35256 68 1371.01923 1059.51923 69 1138.68590 1371.01923 > 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/wessaorg/rcomp/tmp/7d83i1355057851.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/wessaorg/rcomp/tmp/89yep1355057851.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/wessaorg/rcomp/tmp/9dn4a1355057851.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/wessaorg/rcomp/tmp/10ahpv1355057851.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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/11l3u01355057851.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/wessaorg/rcomp/tmp/12h6a71355057851.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/wessaorg/rcomp/tmp/13jzp81355057851.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/wessaorg/rcomp/tmp/14z7y51355057851.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/wessaorg/rcomp/tmp/15rqu21355057851.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/wessaorg/rcomp/tmp/16c9q01355057851.tab") + } > > try(system("convert tmp/1grn71355057851.ps tmp/1grn71355057851.png",intern=TRUE)) character(0) > try(system("convert tmp/2q26q1355057851.ps tmp/2q26q1355057851.png",intern=TRUE)) character(0) > try(system("convert tmp/394qy1355057851.ps tmp/394qy1355057851.png",intern=TRUE)) character(0) > try(system("convert tmp/4ff1i1355057851.ps tmp/4ff1i1355057851.png",intern=TRUE)) character(0) > try(system("convert tmp/5kkf71355057851.ps tmp/5kkf71355057851.png",intern=TRUE)) character(0) > try(system("convert tmp/6omb51355057851.ps tmp/6omb51355057851.png",intern=TRUE)) character(0) > try(system("convert tmp/7d83i1355057851.ps tmp/7d83i1355057851.png",intern=TRUE)) character(0) > try(system("convert tmp/89yep1355057851.ps tmp/89yep1355057851.png",intern=TRUE)) character(0) > try(system("convert tmp/9dn4a1355057851.ps tmp/9dn4a1355057851.png",intern=TRUE)) character(0) > try(system("convert tmp/10ahpv1355057851.ps tmp/10ahpv1355057851.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 5.724 1.102 6.859