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(20.3,3016,20,2155,19.2,2172,21.8,2150,21.3,2533,21.5,2058,19.5,2160,19.5,2260,19.7,2498,18.7,2695,19.7,2799,20,2946,19.7,2930,19.2,2318,19.7,2540,22,2570,21.8,2669,22.8,2450,21,2842,25,3440,23.3,2678,25,2981,26.8,2260,25.3,2844,26.5,2546,27.8,2456,22,2295,22.3,2379,28,2479,25,2057,27.3,2280,25.8,2351,27.3,2276,23.5,2548,24.5,2311,18,2201,21.3,2725,21.8,2408,20.5,2139,22.3,1898,18.7,2537,22.3,2068,17.7,2063,19.7,2520,20.5,2434,18.5,2190,10,2794,14.2,2070,15.5,2615,16.5,2265,20.5,2139,15.7,2428,11.7,2137,7.5,1823,3.5,2063,4.5,1806,2.2,1758,5,2243,2.3,1993,6.1,1932,3.3,2465),dim=c(2,61),dimnames=list(c('Y','X'),1:61)) > y <- array(NA,dim=c(2,61),dimnames=list(c('Y','X'),1:61)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par3 = 'No Linear Trend' > par2 = 'Include Monthly Dummies' > par1 = '1' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > library(lattice) > library(lmtest) Loading required package: zoo Attaching package: 'zoo' The following object(s) are masked from package:base : as.Date.numeric > n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test > par1 <- as.numeric(par1) > x <- t(y) > k <- length(x[1,]) > n <- length(x[,1]) > x1 <- cbind(x[,par1], x[,1:k!=par1]) > mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1]) > colnames(x1) <- mycolnames #colnames(x)[par1] > x <- x1 > if (par3 == 'First Differences'){ + x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep=''))) + for (i in 1:n-1) { + for (j in 1:k) { + x2[i,j] <- x[i+1,j] - x[i,j] + } + } + x <- x2 + } > if (par2 == 'Include Monthly Dummies'){ + x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep =''))) + for (i in 1:11){ + x2[seq(i,n,12),i] <- 1 + } + x <- cbind(x, x2) + } > if (par2 == 'Include Quarterly Dummies'){ + x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep =''))) + for (i in 1:3){ + x2[seq(i,n,4),i] <- 1 + } + x <- cbind(x, x2) + } > k <- length(x[1,]) > if (par3 == 'Linear Trend'){ + x <- cbind(x, c(1:n)) + colnames(x)[k+1] <- 't' + } > x Y X M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 1 20.3 3016 1 0 0 0 0 0 0 0 0 0 0 2 20.0 2155 0 1 0 0 0 0 0 0 0 0 0 3 19.2 2172 0 0 1 0 0 0 0 0 0 0 0 4 21.8 2150 0 0 0 1 0 0 0 0 0 0 0 5 21.3 2533 0 0 0 0 1 0 0 0 0 0 0 6 21.5 2058 0 0 0 0 0 1 0 0 0 0 0 7 19.5 2160 0 0 0 0 0 0 1 0 0 0 0 8 19.5 2260 0 0 0 0 0 0 0 1 0 0 0 9 19.7 2498 0 0 0 0 0 0 0 0 1 0 0 10 18.7 2695 0 0 0 0 0 0 0 0 0 1 0 11 19.7 2799 0 0 0 0 0 0 0 0 0 0 1 12 20.0 2946 0 0 0 0 0 0 0 0 0 0 0 13 19.7 2930 1 0 0 0 0 0 0 0 0 0 0 14 19.2 2318 0 1 0 0 0 0 0 0 0 0 0 15 19.7 2540 0 0 1 0 0 0 0 0 0 0 0 16 22.0 2570 0 0 0 1 0 0 0 0 0 0 0 17 21.8 2669 0 0 0 0 1 0 0 0 0 0 0 18 22.8 2450 0 0 0 0 0 1 0 0 0 0 0 19 21.0 2842 0 0 0 0 0 0 1 0 0 0 0 20 25.0 3440 0 0 0 0 0 0 0 1 0 0 0 21 23.3 2678 0 0 0 0 0 0 0 0 1 0 0 22 25.0 2981 0 0 0 0 0 0 0 0 0 1 0 23 26.8 2260 0 0 0 0 0 0 0 0 0 0 1 24 25.3 2844 0 0 0 0 0 0 0 0 0 0 0 25 26.5 2546 1 0 0 0 0 0 0 0 0 0 0 26 27.8 2456 0 1 0 0 0 0 0 0 0 0 0 27 22.0 2295 0 0 1 0 0 0 0 0 0 0 0 28 22.3 2379 0 0 0 1 0 0 0 0 0 0 0 29 28.0 2479 0 0 0 0 1 0 0 0 0 0 0 30 25.0 2057 0 0 0 0 0 1 0 0 0 0 0 31 27.3 2280 0 0 0 0 0 0 1 0 0 0 0 32 25.8 2351 0 0 0 0 0 0 0 1 0 0 0 33 27.3 2276 0 0 0 0 0 0 0 0 1 0 0 34 23.5 2548 0 0 0 0 0 0 0 0 0 1 0 35 24.5 2311 0 0 0 0 0 0 0 0 0 0 1 36 18.0 2201 0 0 0 0 0 0 0 0 0 0 0 37 21.3 2725 1 0 0 0 0 0 0 0 0 0 0 38 21.8 2408 0 1 0 0 0 0 0 0 0 0 0 39 20.5 2139 0 0 1 0 0 0 0 0 0 0 0 40 22.3 1898 0 0 0 1 0 0 0 0 0 0 0 41 18.7 2537 0 0 0 0 1 0 0 0 0 0 0 42 22.3 2068 0 0 0 0 0 1 0 0 0 0 0 43 17.7 2063 0 0 0 0 0 0 1 0 0 0 0 44 19.7 2520 0 0 0 0 0 0 0 1 0 0 0 45 20.5 2434 0 0 0 0 0 0 0 0 1 0 0 46 18.5 2190 0 0 0 0 0 0 0 0 0 1 0 47 10.0 2794 0 0 0 0 0 0 0 0 0 0 1 48 14.2 2070 0 0 0 0 0 0 0 0 0 0 0 49 15.5 2615 1 0 0 0 0 0 0 0 0 0 0 50 16.5 2265 0 1 0 0 0 0 0 0 0 0 0 51 20.5 2139 0 0 1 0 0 0 0 0 0 0 0 52 15.7 2428 0 0 0 1 0 0 0 0 0 0 0 53 11.7 2137 0 0 0 0 1 0 0 0 0 0 0 54 7.5 1823 0 0 0 0 0 1 0 0 0 0 0 55 3.5 2063 0 0 0 0 0 0 1 0 0 0 0 56 4.5 1806 0 0 0 0 0 0 0 1 0 0 0 57 2.2 1758 0 0 0 0 0 0 0 0 1 0 0 58 5.0 2243 0 0 0 0 0 0 0 0 0 1 0 59 2.3 1993 0 0 0 0 0 0 0 0 0 0 1 60 6.1 1932 0 0 0 0 0 0 0 0 0 0 0 61 3.3 2465 1 0 0 0 0 0 0 0 0 0 0 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X M1 M2 M3 M4 -11.79335 0.01189 -2.72841 5.26960 5.34327 5.45042 M5 M6 M7 M8 M9 M10 2.71935 6.75422 2.47084 1.26704 2.70975 -0.15866 M11 -0.44991 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -11.7014 -3.2272 0.2698 3.1606 12.1775 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -11.793348 7.137969 -1.652 0.105 X 0.011887 0.002738 4.341 7.29e-05 *** M1 -2.728406 3.881330 -0.703 0.485 M2 5.269602 3.956646 1.332 0.189 M3 5.343269 3.969830 1.346 0.185 M4 5.450420 3.963075 1.375 0.175 M5 2.719345 3.955818 0.687 0.495 M6 6.754216 4.039534 1.672 0.101 M7 2.470837 3.963817 0.623 0.536 M8 1.267040 3.956440 0.320 0.750 M9 2.709747 3.955467 0.685 0.497 M10 -0.158659 3.967549 -0.040 0.968 M11 -0.449910 3.951867 -0.114 0.910 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 6.247 on 48 degrees of freedom Multiple R-squared: 0.3167, Adjusted R-squared: 0.1458 F-statistic: 1.854 on 12 and 48 DF, p-value: 0.06562 > 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.015528e-04 6.031056e-04 0.9996984 [2,] 1.881490e-05 3.762981e-05 0.9999812 [3,] 2.521424e-06 5.042849e-06 0.9999975 [4,] 1.588813e-07 3.177626e-07 0.9999998 [5,] 4.851454e-07 9.702908e-07 0.9999995 [6,] 1.018894e-06 2.037788e-06 0.9999990 [7,] 9.230957e-06 1.846191e-05 0.9999908 [8,] 4.191904e-04 8.383808e-04 0.9995808 [9,] 3.808165e-04 7.616330e-04 0.9996192 [10,] 1.378376e-03 2.756751e-03 0.9986216 [11,] 2.873487e-03 5.746973e-03 0.9971265 [12,] 1.404790e-03 2.809580e-03 0.9985952 [13,] 5.617168e-04 1.123434e-03 0.9994383 [14,] 8.119646e-04 1.623929e-03 0.9991880 [15,] 4.903207e-04 9.806413e-04 0.9995097 [16,] 9.945831e-04 1.989166e-03 0.9990054 [17,] 8.082504e-04 1.616501e-03 0.9991917 [18,] 1.271175e-03 2.542350e-03 0.9987288 [19,] 6.802227e-04 1.360445e-03 0.9993198 [20,] 3.580395e-03 7.160789e-03 0.9964196 [21,] 2.884119e-03 5.768239e-03 0.9971159 [22,] 2.509889e-03 5.019778e-03 0.9974901 [23,] 1.186035e-03 2.372069e-03 0.9988140 [24,] 4.906026e-04 9.812052e-04 0.9995094 [25,] 1.705136e-03 3.410271e-03 0.9982949 [26,] 1.098215e-03 2.196429e-03 0.9989018 [27,] 1.164968e-03 2.329935e-03 0.9988350 [28,] 6.742712e-03 1.348542e-02 0.9932573 [29,] 3.286628e-03 6.573256e-03 0.9967134 [30,] 2.976573e-03 5.953146e-03 0.9970234 > postscript(file="/var/www/html/rcomp/tmp/1gpg31258726847.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(x[,1], type='l', main='Actuals and Interpolation', ylab='value of Actuals and Interpolation (dots)', xlab='time or index') > points(x[,1]-mysum$resid) > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/2yi221258726847.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(mysum$resid, type='b', pch=19, main='Residuals', ylab='value of Residuals', xlab='time or index') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/3eccp1258726847.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > hist(mysum$resid, main='Residual Histogram', xlab='values of Residuals') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/4klas1258726847.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > densityplot(~mysum$resid,col='black',main='Residual Density Plot', xlab='values of Residuals') > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/54cwl1258726847.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 = 61 Frequency = 1 1 2 3 4 5 6 -1.0309342 0.9061918 -0.1695628 2.5848120 0.2629753 2.0746649 7 8 9 10 11 12 3.1455195 3.1605666 -0.9113643 -1.3847943 -1.3298435 -3.2272153 13 14 15 16 17 18 -0.6086096 -1.8314700 -4.0441614 -2.2079363 -0.8537242 -1.2852336 19 20 21 22 23 24 -3.4617527 -5.3666786 0.5488864 1.5153818 12.1775168 3.2853093 25 26 27 28 29 30 10.7561889 5.1280555 1.1682752 0.3625754 7.6049000 5.5865524 31 32 33 34 35 36 9.5190200 8.3788045 9.3276598 5.1626676 9.2712545 3.6289692 37 38 39 40 41 42 3.4283271 -0.3013446 1.5227245 6.0804609 -2.3845747 2.7557899 43 44 45 46 47 48 2.4986066 0.2698177 0.6494354 4.4183911 -10.9704060 1.3862312 49 50 51 52 53 54 -1.0640483 -3.9014327 1.5227245 -6.8199119 -4.6295763 -9.1317736 55 56 57 58 59 60 -11.7013934 -6.4425102 -9.6146173 -9.7116462 -9.1485218 -5.0732944 61 -11.4809239 > postscript(file="/var/www/html/rcomp/tmp/6cha21258726847.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 = 61 Frequency = 1 lag(myerror, k = 1) myerror 0 -1.0309342 NA 1 0.9061918 -1.0309342 2 -0.1695628 0.9061918 3 2.5848120 -0.1695628 4 0.2629753 2.5848120 5 2.0746649 0.2629753 6 3.1455195 2.0746649 7 3.1605666 3.1455195 8 -0.9113643 3.1605666 9 -1.3847943 -0.9113643 10 -1.3298435 -1.3847943 11 -3.2272153 -1.3298435 12 -0.6086096 -3.2272153 13 -1.8314700 -0.6086096 14 -4.0441614 -1.8314700 15 -2.2079363 -4.0441614 16 -0.8537242 -2.2079363 17 -1.2852336 -0.8537242 18 -3.4617527 -1.2852336 19 -5.3666786 -3.4617527 20 0.5488864 -5.3666786 21 1.5153818 0.5488864 22 12.1775168 1.5153818 23 3.2853093 12.1775168 24 10.7561889 3.2853093 25 5.1280555 10.7561889 26 1.1682752 5.1280555 27 0.3625754 1.1682752 28 7.6049000 0.3625754 29 5.5865524 7.6049000 30 9.5190200 5.5865524 31 8.3788045 9.5190200 32 9.3276598 8.3788045 33 5.1626676 9.3276598 34 9.2712545 5.1626676 35 3.6289692 9.2712545 36 3.4283271 3.6289692 37 -0.3013446 3.4283271 38 1.5227245 -0.3013446 39 6.0804609 1.5227245 40 -2.3845747 6.0804609 41 2.7557899 -2.3845747 42 2.4986066 2.7557899 43 0.2698177 2.4986066 44 0.6494354 0.2698177 45 4.4183911 0.6494354 46 -10.9704060 4.4183911 47 1.3862312 -10.9704060 48 -1.0640483 1.3862312 49 -3.9014327 -1.0640483 50 1.5227245 -3.9014327 51 -6.8199119 1.5227245 52 -4.6295763 -6.8199119 53 -9.1317736 -4.6295763 54 -11.7013934 -9.1317736 55 -6.4425102 -11.7013934 56 -9.6146173 -6.4425102 57 -9.7116462 -9.6146173 58 -9.1485218 -9.7116462 59 -5.0732944 -9.1485218 60 -11.4809239 -5.0732944 61 NA -11.4809239 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 0.9061918 -1.0309342 [2,] -0.1695628 0.9061918 [3,] 2.5848120 -0.1695628 [4,] 0.2629753 2.5848120 [5,] 2.0746649 0.2629753 [6,] 3.1455195 2.0746649 [7,] 3.1605666 3.1455195 [8,] -0.9113643 3.1605666 [9,] -1.3847943 -0.9113643 [10,] -1.3298435 -1.3847943 [11,] -3.2272153 -1.3298435 [12,] -0.6086096 -3.2272153 [13,] -1.8314700 -0.6086096 [14,] -4.0441614 -1.8314700 [15,] -2.2079363 -4.0441614 [16,] -0.8537242 -2.2079363 [17,] -1.2852336 -0.8537242 [18,] -3.4617527 -1.2852336 [19,] -5.3666786 -3.4617527 [20,] 0.5488864 -5.3666786 [21,] 1.5153818 0.5488864 [22,] 12.1775168 1.5153818 [23,] 3.2853093 12.1775168 [24,] 10.7561889 3.2853093 [25,] 5.1280555 10.7561889 [26,] 1.1682752 5.1280555 [27,] 0.3625754 1.1682752 [28,] 7.6049000 0.3625754 [29,] 5.5865524 7.6049000 [30,] 9.5190200 5.5865524 [31,] 8.3788045 9.5190200 [32,] 9.3276598 8.3788045 [33,] 5.1626676 9.3276598 [34,] 9.2712545 5.1626676 [35,] 3.6289692 9.2712545 [36,] 3.4283271 3.6289692 [37,] -0.3013446 3.4283271 [38,] 1.5227245 -0.3013446 [39,] 6.0804609 1.5227245 [40,] -2.3845747 6.0804609 [41,] 2.7557899 -2.3845747 [42,] 2.4986066 2.7557899 [43,] 0.2698177 2.4986066 [44,] 0.6494354 0.2698177 [45,] 4.4183911 0.6494354 [46,] -10.9704060 4.4183911 [47,] 1.3862312 -10.9704060 [48,] -1.0640483 1.3862312 [49,] -3.9014327 -1.0640483 [50,] 1.5227245 -3.9014327 [51,] -6.8199119 1.5227245 [52,] -4.6295763 -6.8199119 [53,] -9.1317736 -4.6295763 [54,] -11.7013934 -9.1317736 [55,] -6.4425102 -11.7013934 [56,] -9.6146173 -6.4425102 [57,] -9.7116462 -9.6146173 [58,] -9.1485218 -9.7116462 [59,] -5.0732944 -9.1485218 [60,] -11.4809239 -5.0732944 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 0.9061918 -1.0309342 2 -0.1695628 0.9061918 3 2.5848120 -0.1695628 4 0.2629753 2.5848120 5 2.0746649 0.2629753 6 3.1455195 2.0746649 7 3.1605666 3.1455195 8 -0.9113643 3.1605666 9 -1.3847943 -0.9113643 10 -1.3298435 -1.3847943 11 -3.2272153 -1.3298435 12 -0.6086096 -3.2272153 13 -1.8314700 -0.6086096 14 -4.0441614 -1.8314700 15 -2.2079363 -4.0441614 16 -0.8537242 -2.2079363 17 -1.2852336 -0.8537242 18 -3.4617527 -1.2852336 19 -5.3666786 -3.4617527 20 0.5488864 -5.3666786 21 1.5153818 0.5488864 22 12.1775168 1.5153818 23 3.2853093 12.1775168 24 10.7561889 3.2853093 25 5.1280555 10.7561889 26 1.1682752 5.1280555 27 0.3625754 1.1682752 28 7.6049000 0.3625754 29 5.5865524 7.6049000 30 9.5190200 5.5865524 31 8.3788045 9.5190200 32 9.3276598 8.3788045 33 5.1626676 9.3276598 34 9.2712545 5.1626676 35 3.6289692 9.2712545 36 3.4283271 3.6289692 37 -0.3013446 3.4283271 38 1.5227245 -0.3013446 39 6.0804609 1.5227245 40 -2.3845747 6.0804609 41 2.7557899 -2.3845747 42 2.4986066 2.7557899 43 0.2698177 2.4986066 44 0.6494354 0.2698177 45 4.4183911 0.6494354 46 -10.9704060 4.4183911 47 1.3862312 -10.9704060 48 -1.0640483 1.3862312 49 -3.9014327 -1.0640483 50 1.5227245 -3.9014327 51 -6.8199119 1.5227245 52 -4.6295763 -6.8199119 53 -9.1317736 -4.6295763 54 -11.7013934 -9.1317736 55 -6.4425102 -11.7013934 56 -9.6146173 -6.4425102 57 -9.7116462 -9.6146173 58 -9.1485218 -9.7116462 59 -5.0732944 -9.1485218 60 -11.4809239 -5.0732944 > 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/7gseb1258726847.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > acf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Autocorrelation Function') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/8sf6a1258726847.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > pacf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Partial Autocorrelation Function') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/9ectn1258726847.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0)) > plot(mylm, las = 1, sub='Residual Diagnostics') > par(opar) > dev.off() null device 1 > if (n > n25) { + postscript(file="/var/www/html/rcomp/tmp/10k3yu1258726847.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) + plot(kp3:nmkm3,gqarr[,2], main='Goldfeld-Quandt test',ylab='2-sided p-value',xlab='breakpoint') + grid() + dev.off() + } null device 1 > > #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a, 'Multiple Linear Regression - Estimated Regression Equation', 1, TRUE) > a<-table.row.end(a) > myeq <- colnames(x)[1] > myeq <- paste(myeq, '[t] = ', sep='') > for (i in 1:k){ + if (mysum$coefficients[i,1] > 0) myeq <- paste(myeq, '+', '') + myeq <- paste(myeq, mysum$coefficients[i,1], sep=' ') + if (rownames(mysum$coefficients)[i] != '(Intercept)') { + myeq <- paste(myeq, rownames(mysum$coefficients)[i], sep='') + if (rownames(mysum$coefficients)[i] != 't') myeq <- paste(myeq, '[t]', sep='') + } + } > myeq <- paste(myeq, ' + e[t]') > a<-table.row.start(a) > a<-table.element(a, myeq) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/11lnc51258726847.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/12unjj1258726847.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/13ipvo1258726847.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/14uf531258726847.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/159adn1258726847.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/16hmn71258726847.tab") + } > > system("convert tmp/1gpg31258726847.ps tmp/1gpg31258726847.png") > system("convert tmp/2yi221258726847.ps tmp/2yi221258726847.png") > system("convert tmp/3eccp1258726847.ps tmp/3eccp1258726847.png") > system("convert tmp/4klas1258726847.ps tmp/4klas1258726847.png") > system("convert tmp/54cwl1258726847.ps tmp/54cwl1258726847.png") > system("convert tmp/6cha21258726847.ps tmp/6cha21258726847.png") > system("convert tmp/7gseb1258726847.ps tmp/7gseb1258726847.png") > system("convert tmp/8sf6a1258726847.ps tmp/8sf6a1258726847.png") > system("convert tmp/9ectn1258726847.ps tmp/9ectn1258726847.png") > system("convert tmp/10k3yu1258726847.ps tmp/10k3yu1258726847.png") > > > proc.time() user system elapsed 2.421 1.542 2.828