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(98.8,6.3,100.5,6.1,110.4,6.1,96.4,6.3,101.9,6.3,106.2,6,81,6.2,94.7,6.4,101,6.8,109.4,7.5,102.3,7.5,90.7,7.6,96.2,7.6,96.1,7.4,106,7.3,103.1,7.1,102,6.9,104.7,6.8,86,7.5,92.1,7.6,106.9,7.8,112.6,8,101.7,8.1,92,8.2,97.4,8.3,97,8.2,105.4,8,102.7,7.9,98.1,7.6,104.5,7.6,87.4,8.3,89.9,8.4,109.8,8.4,111.7,8.4,98.6,8.4,96.9,8.6,95.1,8.9,97,8.8,112.7,8.3,102.9,7.5,97.4,7.2,111.4,7.4,87.4,8.8,96.8,9.3,114.1,9.3,110.3,8.7,103.9,8.2,101.6,8.3,94.6,8.5,95.9,8.6,104.7,8.5,102.8,8.2,98.1,8.1,113.9,7.9,80.9,8.6,95.7,8.7,113.2,8.7,105.9,8.5,108.8,8.4,102.3,8.5,99,8.7,100.7,8.7,115.5,8.6,100.7,8.5,109.9,8.3,114.6,8,85.4,8.2,100.5,8.1,114.8,8.1,116.5,8,112.9,7.9,102,7.9,106,8,105.3,8,118.8,7.9,106.1,8,109.3,7.7,117.2,7.2,92.5,7.5,104.2,7.3,112.5,7,122.4,7,113.3,7,100,7.2,110.7,7.3,112.8,7.1,109.8,6.8,117.3,6.4,109.1,6.1,115.9,6.5,96,7.7,99.8,7.9,116.8,7.5,115.7,6.9,99.4,6.6,94.3,6.9,91,7.7),dim=c(2,97),dimnames=list(c('Y','X'),1:97)) > y <- array(NA,dim=c(2,97),dimnames=list(c('Y','X'),1:97)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par3 = 'No Linear Trend' > par2 = 'Do not include Seasonal Dummies' > par1 = '1' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > library(lattice) > library(lmtest) Loading required package: zoo Attaching package: 'zoo' The following object(s) are masked from package:base : as.Date.numeric > n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test > par1 <- as.numeric(par1) > x <- t(y) > k <- length(x[1,]) > n <- length(x[,1]) > x1 <- cbind(x[,par1], x[,1:k!=par1]) > mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1]) > colnames(x1) <- mycolnames #colnames(x)[par1] > x <- x1 > if (par3 == 'First Differences'){ + x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep=''))) + for (i in 1:n-1) { + for (j in 1:k) { + x2[i,j] <- x[i+1,j] - x[i,j] + } + } + x <- x2 + } > if (par2 == 'Include Monthly Dummies'){ + x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep =''))) + for (i in 1:11){ + x2[seq(i,n,12),i] <- 1 + } + x <- cbind(x, x2) + } > if (par2 == 'Include Quarterly Dummies'){ + x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep =''))) + for (i in 1:3){ + x2[seq(i,n,4),i] <- 1 + } + x <- cbind(x, x2) + } > k <- length(x[1,]) > if (par3 == 'Linear Trend'){ + x <- cbind(x, c(1:n)) + colnames(x)[k+1] <- 't' + } > x Y X 1 98.8 6.3 2 100.5 6.1 3 110.4 6.1 4 96.4 6.3 5 101.9 6.3 6 106.2 6.0 7 81.0 6.2 8 94.7 6.4 9 101.0 6.8 10 109.4 7.5 11 102.3 7.5 12 90.7 7.6 13 96.2 7.6 14 96.1 7.4 15 106.0 7.3 16 103.1 7.1 17 102.0 6.9 18 104.7 6.8 19 86.0 7.5 20 92.1 7.6 21 106.9 7.8 22 112.6 8.0 23 101.7 8.1 24 92.0 8.2 25 97.4 8.3 26 97.0 8.2 27 105.4 8.0 28 102.7 7.9 29 98.1 7.6 30 104.5 7.6 31 87.4 8.3 32 89.9 8.4 33 109.8 8.4 34 111.7 8.4 35 98.6 8.4 36 96.9 8.6 37 95.1 8.9 38 97.0 8.8 39 112.7 8.3 40 102.9 7.5 41 97.4 7.2 42 111.4 7.4 43 87.4 8.8 44 96.8 9.3 45 114.1 9.3 46 110.3 8.7 47 103.9 8.2 48 101.6 8.3 49 94.6 8.5 50 95.9 8.6 51 104.7 8.5 52 102.8 8.2 53 98.1 8.1 54 113.9 7.9 55 80.9 8.6 56 95.7 8.7 57 113.2 8.7 58 105.9 8.5 59 108.8 8.4 60 102.3 8.5 61 99.0 8.7 62 100.7 8.7 63 115.5 8.6 64 100.7 8.5 65 109.9 8.3 66 114.6 8.0 67 85.4 8.2 68 100.5 8.1 69 114.8 8.1 70 116.5 8.0 71 112.9 7.9 72 102.0 7.9 73 106.0 8.0 74 105.3 8.0 75 118.8 7.9 76 106.1 8.0 77 109.3 7.7 78 117.2 7.2 79 92.5 7.5 80 104.2 7.3 81 112.5 7.0 82 122.4 7.0 83 113.3 7.0 84 100.0 7.2 85 110.7 7.3 86 112.8 7.1 87 109.8 6.8 88 117.3 6.4 89 109.1 6.1 90 115.9 6.5 91 96.0 7.7 92 99.8 7.9 93 116.8 7.5 94 115.7 6.9 95 99.4 6.6 96 94.3 6.9 97 91.0 7.7 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X 113.617 -1.351 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -24.2413 -5.5395 -0.5851 7.4956 18.2394 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 113.617 8.875 12.802 <2e-16 *** X -1.351 1.142 -1.182 0.24 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 8.874 on 95 degrees of freedom Multiple R-squared: 0.01451, Adjusted R-squared: 0.004131 F-statistic: 1.398 on 1 and 95 DF, p-value: 0.2400 > 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.14907497 0.2981499 0.8509250 [2,] 0.06466329 0.1293266 0.9353367 [3,] 0.67303290 0.6539342 0.3269671 [4,] 0.57048834 0.8590233 0.4295117 [5,] 0.58167529 0.8366494 0.4183247 [6,] 0.55649731 0.8870054 0.4435027 [7,] 0.45968332 0.9193666 0.5403167 [8,] 0.53762015 0.9247597 0.4623798 [9,] 0.46383986 0.9276797 0.5361601 [10,] 0.39377292 0.7875458 0.6062271 [11,] 0.36059065 0.7211813 0.6394094 [12,] 0.29610620 0.5922124 0.7038938 [13,] 0.23530270 0.4706054 0.7646973 [14,] 0.19469217 0.3893843 0.8053078 [15,] 0.33631369 0.6726274 0.6636863 [16,] 0.32835070 0.6567014 0.6716493 [17,] 0.32874577 0.6574915 0.6712542 [18,] 0.41041084 0.8208217 0.5895892 [19,] 0.34245403 0.6849081 0.6575460 [20,] 0.35561340 0.7112268 0.6443866 [21,] 0.30126340 0.6025268 0.6987366 [22,] 0.25399655 0.5079931 0.7460035 [23,] 0.22320125 0.4464025 0.7767987 [24,] 0.18069669 0.3613934 0.8193033 [25,] 0.14958669 0.2991734 0.8504133 [26,] 0.12290426 0.2458085 0.8770957 [27,] 0.18802842 0.3760568 0.8119716 [28,] 0.21199344 0.4239869 0.7880066 [29,] 0.24128948 0.4825790 0.7587105 [30,] 0.28784303 0.5756861 0.7121570 [31,] 0.24184453 0.4836891 0.7581555 [32,] 0.20537167 0.4107433 0.7946283 [33,] 0.17851068 0.3570214 0.8214893 [34,] 0.14648647 0.2929729 0.8535135 [35,] 0.19102605 0.3820521 0.8089740 [36,] 0.15828664 0.3165733 0.8417134 [37,] 0.14674925 0.2934985 0.8532508 [38,] 0.15849177 0.3169835 0.8415082 [39,] 0.22131331 0.4426266 0.7786867 [40,] 0.18387529 0.3677506 0.8161247 [41,] 0.27745756 0.5549151 0.7225424 [42,] 0.29124029 0.5824806 0.7087597 [43,] 0.24671746 0.4934349 0.7532825 [44,] 0.20349571 0.4069914 0.7965043 [45,] 0.19171228 0.3834246 0.8082877 [46,] 0.17052282 0.3410456 0.8294772 [47,] 0.14093880 0.2818776 0.8590612 [48,] 0.11208879 0.2241776 0.8879112 [49,] 0.09478186 0.1895637 0.9052181 [50,] 0.11748608 0.2349722 0.8825139 [51,] 0.35024235 0.7004847 0.6497577 [52,] 0.33293246 0.6658649 0.6670675 [53,] 0.37499461 0.7499892 0.6250054 [54,] 0.33035637 0.6607127 0.6696436 [55,] 0.30640359 0.6128072 0.6935964 [56,] 0.25717284 0.5143457 0.7428272 [57,] 0.21927484 0.4385497 0.7807252 [58,] 0.18060379 0.3612076 0.8193962 [59,] 0.23777636 0.4755527 0.7622236 [60,] 0.19590250 0.3918050 0.8040975 [61,] 0.18185983 0.3637197 0.8181402 [62,] 0.21242237 0.4248447 0.7875776 [63,] 0.40640333 0.8128067 0.5935967 [64,] 0.36404031 0.7280806 0.6359597 [65,] 0.39665569 0.7933114 0.6033443 [66,] 0.46944161 0.9388832 0.5305584 [67,] 0.47722572 0.9544514 0.5227743 [68,] 0.41476528 0.8295306 0.5852347 [69,] 0.35529509 0.7105902 0.6447049 [70,] 0.29634580 0.5926916 0.7036542 [71,] 0.45024946 0.9004989 0.5497505 [72,] 0.40167125 0.8033425 0.5983288 [73,] 0.37637237 0.7527447 0.6236276 [74,] 0.44200085 0.8840017 0.5579992 [75,] 0.48454817 0.9690963 0.5154518 [76,] 0.40889638 0.8177928 0.5911036 [77,] 0.36463996 0.7292799 0.6353600 [78,] 0.54404279 0.9119144 0.4559572 [79,] 0.51275010 0.9744998 0.4872499 [80,] 0.45139844 0.9027969 0.5486016 [81,] 0.40582783 0.8116557 0.5941722 [82,] 0.37788350 0.7557670 0.6221165 [83,] 0.29407658 0.5881532 0.7059234 [84,] 0.27250915 0.5450183 0.7274909 [85,] 0.19088346 0.3817669 0.8091165 [86,] 0.17428347 0.3485669 0.8257165 [87,] 0.11776225 0.2355245 0.8822377 [88,] 0.06178033 0.1235607 0.9382197 > postscript(file="/var/www/html/rcomp/tmp/1694v1258646894.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/22mr91258646894.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/33gpu1258646894.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/4ww511258646894.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/5j59q1258646894.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 = 97 Frequency = 1 1 2 3 4 5 6 -6.3062392 -4.8764273 5.0235727 -8.7062392 -3.2062392 0.6884787 7 8 9 10 11 12 -24.2413332 -10.2711452 -3.4307692 5.9148889 -1.1851111 -12.6500171 13 14 15 16 17 18 -7.1500171 -7.5202051 2.2447009 -0.9254871 -2.2956752 0.2692308 19 20 21 22 23 24 -17.4851111 -11.2500171 3.8201709 9.7903590 -0.9745470 -10.5394530 25 26 27 28 29 30 -5.0043590 -5.5394530 2.5903590 -0.2447351 -5.2500171 1.1499829 31 32 33 34 35 36 -15.0043590 -12.3692650 7.5307350 9.4307350 -3.6692650 -5.0990770 37 38 39 40 41 42 -6.4937949 -4.7288889 10.2956410 -0.5851111 -6.4903931 7.7797949 43 44 45 46 47 48 -14.3288889 -4.2534189 13.0465811 8.4360170 1.3605470 -0.8043590 49 50 51 52 53 54 -7.5341710 -6.0990770 2.5658290 0.2605470 -4.5745470 10.9552649 55 56 57 58 59 60 -21.0990770 -6.1639830 11.3360170 3.7658290 6.5307350 0.1658290 61 62 63 64 65 66 -2.8639830 -1.1639830 13.5009230 -1.4341710 7.4956410 11.7903590 67 68 69 70 71 72 -17.1394530 -2.1745470 12.1254530 13.6903590 9.9552649 -0.9447351 73 74 75 76 77 78 3.1903590 2.4903590 15.8552649 3.2903590 6.0850769 13.3096069 79 80 81 82 83 84 -10.9851111 0.4447009 8.3394188 18.2394188 9.1394188 -3.8903931 85 86 87 88 89 90 6.9447009 8.7745129 5.3692308 12.3288548 3.7235727 11.0639488 91 92 93 94 95 96 -7.2149231 -3.1447351 13.3148889 11.4043248 -5.3009572 -9.9956752 97 -12.2149231 > postscript(file="/var/www/html/rcomp/tmp/67awd1258646894.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 = 97 Frequency = 1 lag(myerror, k = 1) myerror 0 -6.3062392 NA 1 -4.8764273 -6.3062392 2 5.0235727 -4.8764273 3 -8.7062392 5.0235727 4 -3.2062392 -8.7062392 5 0.6884787 -3.2062392 6 -24.2413332 0.6884787 7 -10.2711452 -24.2413332 8 -3.4307692 -10.2711452 9 5.9148889 -3.4307692 10 -1.1851111 5.9148889 11 -12.6500171 -1.1851111 12 -7.1500171 -12.6500171 13 -7.5202051 -7.1500171 14 2.2447009 -7.5202051 15 -0.9254871 2.2447009 16 -2.2956752 -0.9254871 17 0.2692308 -2.2956752 18 -17.4851111 0.2692308 19 -11.2500171 -17.4851111 20 3.8201709 -11.2500171 21 9.7903590 3.8201709 22 -0.9745470 9.7903590 23 -10.5394530 -0.9745470 24 -5.0043590 -10.5394530 25 -5.5394530 -5.0043590 26 2.5903590 -5.5394530 27 -0.2447351 2.5903590 28 -5.2500171 -0.2447351 29 1.1499829 -5.2500171 30 -15.0043590 1.1499829 31 -12.3692650 -15.0043590 32 7.5307350 -12.3692650 33 9.4307350 7.5307350 34 -3.6692650 9.4307350 35 -5.0990770 -3.6692650 36 -6.4937949 -5.0990770 37 -4.7288889 -6.4937949 38 10.2956410 -4.7288889 39 -0.5851111 10.2956410 40 -6.4903931 -0.5851111 41 7.7797949 -6.4903931 42 -14.3288889 7.7797949 43 -4.2534189 -14.3288889 44 13.0465811 -4.2534189 45 8.4360170 13.0465811 46 1.3605470 8.4360170 47 -0.8043590 1.3605470 48 -7.5341710 -0.8043590 49 -6.0990770 -7.5341710 50 2.5658290 -6.0990770 51 0.2605470 2.5658290 52 -4.5745470 0.2605470 53 10.9552649 -4.5745470 54 -21.0990770 10.9552649 55 -6.1639830 -21.0990770 56 11.3360170 -6.1639830 57 3.7658290 11.3360170 58 6.5307350 3.7658290 59 0.1658290 6.5307350 60 -2.8639830 0.1658290 61 -1.1639830 -2.8639830 62 13.5009230 -1.1639830 63 -1.4341710 13.5009230 64 7.4956410 -1.4341710 65 11.7903590 7.4956410 66 -17.1394530 11.7903590 67 -2.1745470 -17.1394530 68 12.1254530 -2.1745470 69 13.6903590 12.1254530 70 9.9552649 13.6903590 71 -0.9447351 9.9552649 72 3.1903590 -0.9447351 73 2.4903590 3.1903590 74 15.8552649 2.4903590 75 3.2903590 15.8552649 76 6.0850769 3.2903590 77 13.3096069 6.0850769 78 -10.9851111 13.3096069 79 0.4447009 -10.9851111 80 8.3394188 0.4447009 81 18.2394188 8.3394188 82 9.1394188 18.2394188 83 -3.8903931 9.1394188 84 6.9447009 -3.8903931 85 8.7745129 6.9447009 86 5.3692308 8.7745129 87 12.3288548 5.3692308 88 3.7235727 12.3288548 89 11.0639488 3.7235727 90 -7.2149231 11.0639488 91 -3.1447351 -7.2149231 92 13.3148889 -3.1447351 93 11.4043248 13.3148889 94 -5.3009572 11.4043248 95 -9.9956752 -5.3009572 96 -12.2149231 -9.9956752 97 NA -12.2149231 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -4.8764273 -6.3062392 [2,] 5.0235727 -4.8764273 [3,] -8.7062392 5.0235727 [4,] -3.2062392 -8.7062392 [5,] 0.6884787 -3.2062392 [6,] -24.2413332 0.6884787 [7,] -10.2711452 -24.2413332 [8,] -3.4307692 -10.2711452 [9,] 5.9148889 -3.4307692 [10,] -1.1851111 5.9148889 [11,] -12.6500171 -1.1851111 [12,] -7.1500171 -12.6500171 [13,] -7.5202051 -7.1500171 [14,] 2.2447009 -7.5202051 [15,] -0.9254871 2.2447009 [16,] -2.2956752 -0.9254871 [17,] 0.2692308 -2.2956752 [18,] -17.4851111 0.2692308 [19,] -11.2500171 -17.4851111 [20,] 3.8201709 -11.2500171 [21,] 9.7903590 3.8201709 [22,] -0.9745470 9.7903590 [23,] -10.5394530 -0.9745470 [24,] -5.0043590 -10.5394530 [25,] -5.5394530 -5.0043590 [26,] 2.5903590 -5.5394530 [27,] -0.2447351 2.5903590 [28,] -5.2500171 -0.2447351 [29,] 1.1499829 -5.2500171 [30,] -15.0043590 1.1499829 [31,] -12.3692650 -15.0043590 [32,] 7.5307350 -12.3692650 [33,] 9.4307350 7.5307350 [34,] -3.6692650 9.4307350 [35,] -5.0990770 -3.6692650 [36,] -6.4937949 -5.0990770 [37,] -4.7288889 -6.4937949 [38,] 10.2956410 -4.7288889 [39,] -0.5851111 10.2956410 [40,] -6.4903931 -0.5851111 [41,] 7.7797949 -6.4903931 [42,] -14.3288889 7.7797949 [43,] -4.2534189 -14.3288889 [44,] 13.0465811 -4.2534189 [45,] 8.4360170 13.0465811 [46,] 1.3605470 8.4360170 [47,] -0.8043590 1.3605470 [48,] -7.5341710 -0.8043590 [49,] -6.0990770 -7.5341710 [50,] 2.5658290 -6.0990770 [51,] 0.2605470 2.5658290 [52,] -4.5745470 0.2605470 [53,] 10.9552649 -4.5745470 [54,] -21.0990770 10.9552649 [55,] -6.1639830 -21.0990770 [56,] 11.3360170 -6.1639830 [57,] 3.7658290 11.3360170 [58,] 6.5307350 3.7658290 [59,] 0.1658290 6.5307350 [60,] -2.8639830 0.1658290 [61,] -1.1639830 -2.8639830 [62,] 13.5009230 -1.1639830 [63,] -1.4341710 13.5009230 [64,] 7.4956410 -1.4341710 [65,] 11.7903590 7.4956410 [66,] -17.1394530 11.7903590 [67,] -2.1745470 -17.1394530 [68,] 12.1254530 -2.1745470 [69,] 13.6903590 12.1254530 [70,] 9.9552649 13.6903590 [71,] -0.9447351 9.9552649 [72,] 3.1903590 -0.9447351 [73,] 2.4903590 3.1903590 [74,] 15.8552649 2.4903590 [75,] 3.2903590 15.8552649 [76,] 6.0850769 3.2903590 [77,] 13.3096069 6.0850769 [78,] -10.9851111 13.3096069 [79,] 0.4447009 -10.9851111 [80,] 8.3394188 0.4447009 [81,] 18.2394188 8.3394188 [82,] 9.1394188 18.2394188 [83,] -3.8903931 9.1394188 [84,] 6.9447009 -3.8903931 [85,] 8.7745129 6.9447009 [86,] 5.3692308 8.7745129 [87,] 12.3288548 5.3692308 [88,] 3.7235727 12.3288548 [89,] 11.0639488 3.7235727 [90,] -7.2149231 11.0639488 [91,] -3.1447351 -7.2149231 [92,] 13.3148889 -3.1447351 [93,] 11.4043248 13.3148889 [94,] -5.3009572 11.4043248 [95,] -9.9956752 -5.3009572 [96,] -12.2149231 -9.9956752 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -4.8764273 -6.3062392 2 5.0235727 -4.8764273 3 -8.7062392 5.0235727 4 -3.2062392 -8.7062392 5 0.6884787 -3.2062392 6 -24.2413332 0.6884787 7 -10.2711452 -24.2413332 8 -3.4307692 -10.2711452 9 5.9148889 -3.4307692 10 -1.1851111 5.9148889 11 -12.6500171 -1.1851111 12 -7.1500171 -12.6500171 13 -7.5202051 -7.1500171 14 2.2447009 -7.5202051 15 -0.9254871 2.2447009 16 -2.2956752 -0.9254871 17 0.2692308 -2.2956752 18 -17.4851111 0.2692308 19 -11.2500171 -17.4851111 20 3.8201709 -11.2500171 21 9.7903590 3.8201709 22 -0.9745470 9.7903590 23 -10.5394530 -0.9745470 24 -5.0043590 -10.5394530 25 -5.5394530 -5.0043590 26 2.5903590 -5.5394530 27 -0.2447351 2.5903590 28 -5.2500171 -0.2447351 29 1.1499829 -5.2500171 30 -15.0043590 1.1499829 31 -12.3692650 -15.0043590 32 7.5307350 -12.3692650 33 9.4307350 7.5307350 34 -3.6692650 9.4307350 35 -5.0990770 -3.6692650 36 -6.4937949 -5.0990770 37 -4.7288889 -6.4937949 38 10.2956410 -4.7288889 39 -0.5851111 10.2956410 40 -6.4903931 -0.5851111 41 7.7797949 -6.4903931 42 -14.3288889 7.7797949 43 -4.2534189 -14.3288889 44 13.0465811 -4.2534189 45 8.4360170 13.0465811 46 1.3605470 8.4360170 47 -0.8043590 1.3605470 48 -7.5341710 -0.8043590 49 -6.0990770 -7.5341710 50 2.5658290 -6.0990770 51 0.2605470 2.5658290 52 -4.5745470 0.2605470 53 10.9552649 -4.5745470 54 -21.0990770 10.9552649 55 -6.1639830 -21.0990770 56 11.3360170 -6.1639830 57 3.7658290 11.3360170 58 6.5307350 3.7658290 59 0.1658290 6.5307350 60 -2.8639830 0.1658290 61 -1.1639830 -2.8639830 62 13.5009230 -1.1639830 63 -1.4341710 13.5009230 64 7.4956410 -1.4341710 65 11.7903590 7.4956410 66 -17.1394530 11.7903590 67 -2.1745470 -17.1394530 68 12.1254530 -2.1745470 69 13.6903590 12.1254530 70 9.9552649 13.6903590 71 -0.9447351 9.9552649 72 3.1903590 -0.9447351 73 2.4903590 3.1903590 74 15.8552649 2.4903590 75 3.2903590 15.8552649 76 6.0850769 3.2903590 77 13.3096069 6.0850769 78 -10.9851111 13.3096069 79 0.4447009 -10.9851111 80 8.3394188 0.4447009 81 18.2394188 8.3394188 82 9.1394188 18.2394188 83 -3.8903931 9.1394188 84 6.9447009 -3.8903931 85 8.7745129 6.9447009 86 5.3692308 8.7745129 87 12.3288548 5.3692308 88 3.7235727 12.3288548 89 11.0639488 3.7235727 90 -7.2149231 11.0639488 91 -3.1447351 -7.2149231 92 13.3148889 -3.1447351 93 11.4043248 13.3148889 94 -5.3009572 11.4043248 95 -9.9956752 -5.3009572 96 -12.2149231 -9.9956752 > 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/7kv1x1258646894.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/8kawt1258646894.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/9ybu61258646894.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/104lhv1258646894.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/11hy1t1258646894.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/12echo1258646894.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/13nvmh1258646894.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/14xdmu1258646894.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/15ilex1258646894.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/166gqu1258646894.tab") + } > > system("convert tmp/1694v1258646894.ps tmp/1694v1258646894.png") > system("convert tmp/22mr91258646894.ps tmp/22mr91258646894.png") > system("convert tmp/33gpu1258646894.ps tmp/33gpu1258646894.png") > system("convert tmp/4ww511258646894.ps tmp/4ww511258646894.png") > system("convert tmp/5j59q1258646894.ps tmp/5j59q1258646894.png") > system("convert tmp/67awd1258646894.ps tmp/67awd1258646894.png") > system("convert tmp/7kv1x1258646894.ps tmp/7kv1x1258646894.png") > system("convert tmp/8kawt1258646894.ps tmp/8kawt1258646894.png") > system("convert tmp/9ybu61258646894.ps tmp/9ybu61258646894.png") > system("convert tmp/104lhv1258646894.ps tmp/104lhv1258646894.png") > > > proc.time() user system elapsed 2.845 1.597 3.224