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(395.3,0,395.1,0,403.5,0,403.3,0,405.7,0,406.7,0,407.2,0,412.4,0,415.9,0,414.0,0,411.8,0,409.9,0,412.4,0,415.9,0,416.3,0,417.2,0,421.8,0,421.4,0,415.1,0,412.4,0,411.8,0,408.8,0,404.5,0,402.5,0,409.4,0,410.7,0,413.4,0,415.2,0,417.7,0,417.8,0,417.9,0,418.4,0,418.2,0,416.6,0,418.9,0,421.0,0,423.5,0,432.3,0,432.3,0,428.6,0,426.7,0,427.3,0,428.5,0,437.0,0,442.0,0,444.9,0,441.4,0,440.3,0,447.1,0,455.3,0,478.6,0,486.5,0,487.8,0,485.9,0,483.8,0,488.4,0,494.0,0,493.6,0,487.3,0,482.1,0,484.2,0,496.8,0,501.1,0,499.8,0,495.5,0,498.1,0,503.8,0,516.2,0,526.1,0,527.1,0,525.1,0,528.9,0,540.1,0,549.0,0,556.0,0,568.9,0,589.1,0,590.3,0,603.3,0,638.8,0,643.0,0,656.7,0,656.1,0,654.1,0,659.9,0,662.1,0,669.2,0,673.1,0,678.3,0,677.4,0,678.5,0,672.4,0,665.3,0,667.9,0,672.1,0,662.5,0,682.3,0,692.1,0,702.7,0,721.4,0,733.2,0,747.7,0,737.6,0,729.3,0,706.1,0,674.3,0,659.0,0,645.7,0,646.1,0,633.0,1,622.3,1,628.2,1,637.3,1,639.6,1,638.5,1,650.5,1,655.4,1),dim=c(2,117),dimnames=list(c('Y','X'),1:117)) > y <- array(NA,dim=c(2,117),dimnames=list(c('Y','X'),1:117)) > 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 = '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 t 1 395.3 0 1 2 395.1 0 2 3 403.5 0 3 4 403.3 0 4 5 405.7 0 5 6 406.7 0 6 7 407.2 0 7 8 412.4 0 8 9 415.9 0 9 10 414.0 0 10 11 411.8 0 11 12 409.9 0 12 13 412.4 0 13 14 415.9 0 14 15 416.3 0 15 16 417.2 0 16 17 421.8 0 17 18 421.4 0 18 19 415.1 0 19 20 412.4 0 20 21 411.8 0 21 22 408.8 0 22 23 404.5 0 23 24 402.5 0 24 25 409.4 0 25 26 410.7 0 26 27 413.4 0 27 28 415.2 0 28 29 417.7 0 29 30 417.8 0 30 31 417.9 0 31 32 418.4 0 32 33 418.2 0 33 34 416.6 0 34 35 418.9 0 35 36 421.0 0 36 37 423.5 0 37 38 432.3 0 38 39 432.3 0 39 40 428.6 0 40 41 426.7 0 41 42 427.3 0 42 43 428.5 0 43 44 437.0 0 44 45 442.0 0 45 46 444.9 0 46 47 441.4 0 47 48 440.3 0 48 49 447.1 0 49 50 455.3 0 50 51 478.6 0 51 52 486.5 0 52 53 487.8 0 53 54 485.9 0 54 55 483.8 0 55 56 488.4 0 56 57 494.0 0 57 58 493.6 0 58 59 487.3 0 59 60 482.1 0 60 61 484.2 0 61 62 496.8 0 62 63 501.1 0 63 64 499.8 0 64 65 495.5 0 65 66 498.1 0 66 67 503.8 0 67 68 516.2 0 68 69 526.1 0 69 70 527.1 0 70 71 525.1 0 71 72 528.9 0 72 73 540.1 0 73 74 549.0 0 74 75 556.0 0 75 76 568.9 0 76 77 589.1 0 77 78 590.3 0 78 79 603.3 0 79 80 638.8 0 80 81 643.0 0 81 82 656.7 0 82 83 656.1 0 83 84 654.1 0 84 85 659.9 0 85 86 662.1 0 86 87 669.2 0 87 88 673.1 0 88 89 678.3 0 89 90 677.4 0 90 91 678.5 0 91 92 672.4 0 92 93 665.3 0 93 94 667.9 0 94 95 672.1 0 95 96 662.5 0 96 97 682.3 0 97 98 692.1 0 98 99 702.7 0 99 100 721.4 0 100 101 733.2 0 101 102 747.7 0 102 103 737.6 0 103 104 729.3 0 104 105 706.1 0 105 106 674.3 0 106 107 659.0 0 107 108 645.7 0 108 109 646.1 0 109 110 633.0 1 110 111 622.3 1 111 112 628.2 1 112 113 637.3 1 113 114 639.6 1 114 115 638.5 1 115 116 650.5 1 116 117 655.4 1 117 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X t 334.952 -71.068 3.297 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -54.458 -32.646 -6.284 35.384 76.448 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 334.9516 7.3390 45.640 < 2e-16 *** X -71.0679 15.4982 -4.586 1.17e-05 *** t 3.2971 0.1158 28.468 < 2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 38.05 on 114 degrees of freedom Multiple R-squared: 0.8861, Adjusted R-squared: 0.8841 F-statistic: 443.4 on 2 and 114 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,] 4.664964e-04 9.329928e-04 9.995335e-01 [2,] 4.672256e-05 9.344512e-05 9.999533e-01 [3,] 3.267757e-06 6.535514e-06 9.999967e-01 [4,] 2.650111e-07 5.300222e-07 9.999997e-01 [5,] 3.344390e-08 6.688780e-08 1.000000e+00 [6,] 2.469043e-08 4.938086e-08 1.000000e+00 [7,] 2.706360e-08 5.412719e-08 1.000000e+00 [8,] 6.446260e-09 1.289252e-08 1.000000e+00 [9,] 8.594733e-10 1.718947e-09 1.000000e+00 [10,] 1.254204e-10 2.508408e-10 1.000000e+00 [11,] 1.869946e-11 3.739892e-11 1.000000e+00 [12,] 2.775819e-12 5.551637e-12 1.000000e+00 [13,] 3.825499e-13 7.650998e-13 1.000000e+00 [14,] 5.944142e-13 1.188828e-12 1.000000e+00 [15,] 2.022262e-12 4.044525e-12 1.000000e+00 [16,] 3.574767e-12 7.149535e-12 1.000000e+00 [17,] 1.029498e-11 2.058995e-11 1.000000e+00 [18,] 5.342400e-11 1.068480e-10 1.000000e+00 [19,] 1.595243e-10 3.190486e-10 1.000000e+00 [20,] 6.633048e-11 1.326610e-10 1.000000e+00 [21,] 2.272213e-11 4.544426e-11 1.000000e+00 [22,] 6.538253e-12 1.307651e-11 1.000000e+00 [23,] 1.821904e-12 3.643808e-12 1.000000e+00 [24,] 5.377100e-13 1.075420e-12 1.000000e+00 [25,] 1.511337e-13 3.022674e-13 1.000000e+00 [26,] 4.053722e-14 8.107444e-14 1.000000e+00 [27,] 1.053749e-14 2.107498e-14 1.000000e+00 [28,] 2.585535e-15 5.171069e-15 1.000000e+00 [29,] 6.165099e-16 1.233020e-15 1.000000e+00 [30,] 1.388053e-16 2.776105e-16 1.000000e+00 [31,] 3.236646e-17 6.473292e-17 1.000000e+00 [32,] 8.777948e-18 1.755590e-17 1.000000e+00 [33,] 1.570744e-17 3.141488e-17 1.000000e+00 [34,] 1.484963e-17 2.969927e-17 1.000000e+00 [35,] 4.533825e-18 9.067650e-18 1.000000e+00 [36,] 9.971679e-19 1.994336e-18 1.000000e+00 [37,] 2.097456e-19 4.194913e-19 1.000000e+00 [38,] 4.410846e-20 8.821691e-20 1.000000e+00 [39,] 3.598267e-20 7.196534e-20 1.000000e+00 [40,] 7.966249e-20 1.593250e-19 1.000000e+00 [41,] 2.063108e-19 4.126215e-19 1.000000e+00 [42,] 1.123577e-19 2.247154e-19 1.000000e+00 [43,] 3.925910e-20 7.851819e-20 1.000000e+00 [44,] 4.047729e-20 8.095459e-20 1.000000e+00 [45,] 2.446625e-19 4.893249e-19 1.000000e+00 [46,] 2.608284e-15 5.216569e-15 1.000000e+00 [47,] 2.653410e-12 5.306820e-12 1.000000e+00 [48,] 1.391292e-10 2.782585e-10 1.000000e+00 [49,] 9.978910e-10 1.995782e-09 1.000000e+00 [50,] 2.388043e-09 4.776085e-09 1.000000e+00 [51,] 5.836239e-09 1.167248e-08 1.000000e+00 [52,] 1.590995e-08 3.181990e-08 1.000000e+00 [53,] 2.567010e-08 5.134020e-08 1.000000e+00 [54,] 1.991424e-08 3.982849e-08 1.000000e+00 [55,] 1.150282e-08 2.300564e-08 1.000000e+00 [56,] 6.904851e-09 1.380970e-08 1.000000e+00 [57,] 6.395803e-09 1.279161e-08 1.000000e+00 [58,] 6.497576e-09 1.299515e-08 1.000000e+00 [59,] 5.585441e-09 1.117088e-08 1.000000e+00 [60,] 4.472325e-09 8.944650e-09 1.000000e+00 [61,] 4.234377e-09 8.468754e-09 1.000000e+00 [62,] 5.056968e-09 1.011394e-08 1.000000e+00 [63,] 9.262544e-09 1.852509e-08 1.000000e+00 [64,] 2.526515e-08 5.053030e-08 1.000000e+00 [65,] 6.693192e-08 1.338638e-07 9.999999e-01 [66,] 1.942435e-07 3.884870e-07 9.999998e-01 [67,] 7.973435e-07 1.594687e-06 9.999992e-01 [68,] 4.769194e-06 9.538388e-06 9.999952e-01 [69,] 3.729083e-05 7.458167e-05 9.999627e-01 [70,] 3.405526e-04 6.811051e-04 9.996594e-01 [71,] 3.109085e-03 6.218169e-03 9.968909e-01 [72,] 2.210365e-02 4.420730e-02 9.778963e-01 [73,] 9.597198e-02 1.919440e-01 9.040280e-01 [74,] 2.741367e-01 5.482735e-01 7.258633e-01 [75,] 5.383210e-01 9.233581e-01 4.616790e-01 [76,] 7.213270e-01 5.573459e-01 2.786730e-01 [77,] 8.396213e-01 3.207575e-01 1.603787e-01 [78,] 8.937913e-01 2.124174e-01 1.062087e-01 [79,] 9.201624e-01 1.596753e-01 7.983764e-02 [80,] 9.354493e-01 1.291013e-01 6.455065e-02 [81,] 9.433786e-01 1.132427e-01 5.662137e-02 [82,] 9.473052e-01 1.053896e-01 5.269480e-02 [83,] 9.476657e-01 1.046685e-01 5.233427e-02 [84,] 9.454715e-01 1.090571e-01 5.452854e-02 [85,] 9.392255e-01 1.215489e-01 6.077446e-02 [86,] 9.294470e-01 1.411060e-01 7.055300e-02 [87,] 9.166385e-01 1.667229e-01 8.336147e-02 [88,] 9.086926e-01 1.826148e-01 9.130741e-02 [89,] 9.041228e-01 1.917543e-01 9.587716e-02 [90,] 9.027798e-01 1.944404e-01 9.722020e-02 [91,] 9.360210e-01 1.279579e-01 6.397896e-02 [92,] 9.476600e-01 1.046799e-01 5.233997e-02 [93,] 9.543834e-01 9.123324e-02 4.561662e-02 [94,] 9.535221e-01 9.295589e-02 4.647794e-02 [95,] 9.375867e-01 1.248265e-01 6.241326e-02 [96,] 9.180063e-01 1.639874e-01 8.199372e-02 [97,] 9.369994e-01 1.260013e-01 6.300064e-02 [98,] 9.650152e-01 6.996967e-02 3.498483e-02 [99,] 9.945543e-01 1.089147e-02 5.445737e-03 [100,] 9.998562e-01 2.875259e-04 1.437629e-04 [101,] 9.999864e-01 2.710773e-05 1.355386e-05 [102,] 9.999954e-01 9.226633e-06 4.613317e-06 [103,] 9.999681e-01 6.370496e-05 3.185248e-05 [104,] 9.997674e-01 4.651253e-04 2.325626e-04 [105,] 9.998772e-01 2.455365e-04 1.227683e-04 [106,] 9.985998e-01 2.800438e-03 1.400219e-03 > postscript(file="/var/www/html/rcomp/tmp/1xvbo1258470133.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/2d29s1258470133.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/31wia1258470133.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/4iw7f1258470133.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/5h2zd1258470133.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 = 117 Frequency = 1 1 2 3 4 5 6 57.0513212 53.5542614 58.6572016 55.1601418 54.2630820 51.9660222 7 8 9 10 11 12 49.1689624 51.0719025 51.2748427 46.0777829 40.5807231 35.3836633 13 14 15 16 17 18 34.5866035 34.7895437 31.8924839 29.4954241 30.7983643 27.1013045 19 20 21 22 23 24 17.5042447 11.5071849 7.6101251 1.3130653 -6.2839945 -11.5810543 25 26 27 28 29 30 -7.9781141 -9.9751739 -10.5722337 -12.0692935 -12.8663533 -16.0634131 31 32 33 34 35 36 -19.2604730 -22.0575328 -25.5545926 -30.4516524 -31.4487122 -32.6457720 37 38 39 40 41 42 -33.4428318 -27.9398916 -31.2369514 -38.2340112 -43.4310710 -46.1281308 43 44 45 46 47 48 -48.2251906 -43.0222504 -41.3193102 -41.7163700 -48.5134298 -52.9104896 49 50 51 52 53 54 -49.4075494 -44.5046092 -24.5016690 -19.8987288 -21.8957886 -27.0928485 55 56 57 58 59 60 -32.4899083 -31.1869681 -28.8840279 -32.5810877 -42.1781475 -50.6752073 61 62 63 64 65 66 -51.8722671 -42.5693269 -41.5663867 -46.1634465 -53.7605063 -54.4575661 67 68 69 70 71 72 -52.0546259 -42.9516857 -36.3487455 -38.6458053 -43.9428651 -43.4399249 73 74 75 76 77 78 -35.5369847 -29.9340445 -26.2311043 -16.6281641 0.2747760 -1.8222838 79 80 81 82 83 84 7.8806564 40.0835966 40.9865368 51.3894770 47.4924172 42.1953574 85 86 87 88 89 90 44.6982976 43.6012378 47.4041780 48.0071182 49.9100584 45.7129986 91 92 93 94 95 96 43.5159388 34.1188790 23.7218192 23.0247594 23.9276996 11.0306398 97 98 99 100 101 102 27.5335800 34.0365202 41.3394604 56.7424005 65.2453407 76.4482809 103 104 105 106 107 108 63.0512211 51.4541613 24.9571015 -10.1399583 -28.7370181 -45.3340779 109 110 111 112 113 114 -48.2311377 6.4397093 -7.5573505 -4.9544103 0.8485299 -0.1485299 115 116 117 -4.5455897 4.1573505 5.7602907 > postscript(file="/var/www/html/rcomp/tmp/6yeof1258470133.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 = 117 Frequency = 1 lag(myerror, k = 1) myerror 0 57.0513212 NA 1 53.5542614 57.0513212 2 58.6572016 53.5542614 3 55.1601418 58.6572016 4 54.2630820 55.1601418 5 51.9660222 54.2630820 6 49.1689624 51.9660222 7 51.0719025 49.1689624 8 51.2748427 51.0719025 9 46.0777829 51.2748427 10 40.5807231 46.0777829 11 35.3836633 40.5807231 12 34.5866035 35.3836633 13 34.7895437 34.5866035 14 31.8924839 34.7895437 15 29.4954241 31.8924839 16 30.7983643 29.4954241 17 27.1013045 30.7983643 18 17.5042447 27.1013045 19 11.5071849 17.5042447 20 7.6101251 11.5071849 21 1.3130653 7.6101251 22 -6.2839945 1.3130653 23 -11.5810543 -6.2839945 24 -7.9781141 -11.5810543 25 -9.9751739 -7.9781141 26 -10.5722337 -9.9751739 27 -12.0692935 -10.5722337 28 -12.8663533 -12.0692935 29 -16.0634131 -12.8663533 30 -19.2604730 -16.0634131 31 -22.0575328 -19.2604730 32 -25.5545926 -22.0575328 33 -30.4516524 -25.5545926 34 -31.4487122 -30.4516524 35 -32.6457720 -31.4487122 36 -33.4428318 -32.6457720 37 -27.9398916 -33.4428318 38 -31.2369514 -27.9398916 39 -38.2340112 -31.2369514 40 -43.4310710 -38.2340112 41 -46.1281308 -43.4310710 42 -48.2251906 -46.1281308 43 -43.0222504 -48.2251906 44 -41.3193102 -43.0222504 45 -41.7163700 -41.3193102 46 -48.5134298 -41.7163700 47 -52.9104896 -48.5134298 48 -49.4075494 -52.9104896 49 -44.5046092 -49.4075494 50 -24.5016690 -44.5046092 51 -19.8987288 -24.5016690 52 -21.8957886 -19.8987288 53 -27.0928485 -21.8957886 54 -32.4899083 -27.0928485 55 -31.1869681 -32.4899083 56 -28.8840279 -31.1869681 57 -32.5810877 -28.8840279 58 -42.1781475 -32.5810877 59 -50.6752073 -42.1781475 60 -51.8722671 -50.6752073 61 -42.5693269 -51.8722671 62 -41.5663867 -42.5693269 63 -46.1634465 -41.5663867 64 -53.7605063 -46.1634465 65 -54.4575661 -53.7605063 66 -52.0546259 -54.4575661 67 -42.9516857 -52.0546259 68 -36.3487455 -42.9516857 69 -38.6458053 -36.3487455 70 -43.9428651 -38.6458053 71 -43.4399249 -43.9428651 72 -35.5369847 -43.4399249 73 -29.9340445 -35.5369847 74 -26.2311043 -29.9340445 75 -16.6281641 -26.2311043 76 0.2747760 -16.6281641 77 -1.8222838 0.2747760 78 7.8806564 -1.8222838 79 40.0835966 7.8806564 80 40.9865368 40.0835966 81 51.3894770 40.9865368 82 47.4924172 51.3894770 83 42.1953574 47.4924172 84 44.6982976 42.1953574 85 43.6012378 44.6982976 86 47.4041780 43.6012378 87 48.0071182 47.4041780 88 49.9100584 48.0071182 89 45.7129986 49.9100584 90 43.5159388 45.7129986 91 34.1188790 43.5159388 92 23.7218192 34.1188790 93 23.0247594 23.7218192 94 23.9276996 23.0247594 95 11.0306398 23.9276996 96 27.5335800 11.0306398 97 34.0365202 27.5335800 98 41.3394604 34.0365202 99 56.7424005 41.3394604 100 65.2453407 56.7424005 101 76.4482809 65.2453407 102 63.0512211 76.4482809 103 51.4541613 63.0512211 104 24.9571015 51.4541613 105 -10.1399583 24.9571015 106 -28.7370181 -10.1399583 107 -45.3340779 -28.7370181 108 -48.2311377 -45.3340779 109 6.4397093 -48.2311377 110 -7.5573505 6.4397093 111 -4.9544103 -7.5573505 112 0.8485299 -4.9544103 113 -0.1485299 0.8485299 114 -4.5455897 -0.1485299 115 4.1573505 -4.5455897 116 5.7602907 4.1573505 117 NA 5.7602907 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 53.5542614 57.0513212 [2,] 58.6572016 53.5542614 [3,] 55.1601418 58.6572016 [4,] 54.2630820 55.1601418 [5,] 51.9660222 54.2630820 [6,] 49.1689624 51.9660222 [7,] 51.0719025 49.1689624 [8,] 51.2748427 51.0719025 [9,] 46.0777829 51.2748427 [10,] 40.5807231 46.0777829 [11,] 35.3836633 40.5807231 [12,] 34.5866035 35.3836633 [13,] 34.7895437 34.5866035 [14,] 31.8924839 34.7895437 [15,] 29.4954241 31.8924839 [16,] 30.7983643 29.4954241 [17,] 27.1013045 30.7983643 [18,] 17.5042447 27.1013045 [19,] 11.5071849 17.5042447 [20,] 7.6101251 11.5071849 [21,] 1.3130653 7.6101251 [22,] -6.2839945 1.3130653 [23,] -11.5810543 -6.2839945 [24,] -7.9781141 -11.5810543 [25,] -9.9751739 -7.9781141 [26,] -10.5722337 -9.9751739 [27,] -12.0692935 -10.5722337 [28,] -12.8663533 -12.0692935 [29,] -16.0634131 -12.8663533 [30,] -19.2604730 -16.0634131 [31,] -22.0575328 -19.2604730 [32,] -25.5545926 -22.0575328 [33,] -30.4516524 -25.5545926 [34,] -31.4487122 -30.4516524 [35,] -32.6457720 -31.4487122 [36,] -33.4428318 -32.6457720 [37,] -27.9398916 -33.4428318 [38,] -31.2369514 -27.9398916 [39,] -38.2340112 -31.2369514 [40,] -43.4310710 -38.2340112 [41,] -46.1281308 -43.4310710 [42,] -48.2251906 -46.1281308 [43,] -43.0222504 -48.2251906 [44,] -41.3193102 -43.0222504 [45,] -41.7163700 -41.3193102 [46,] -48.5134298 -41.7163700 [47,] -52.9104896 -48.5134298 [48,] -49.4075494 -52.9104896 [49,] -44.5046092 -49.4075494 [50,] -24.5016690 -44.5046092 [51,] -19.8987288 -24.5016690 [52,] -21.8957886 -19.8987288 [53,] -27.0928485 -21.8957886 [54,] -32.4899083 -27.0928485 [55,] -31.1869681 -32.4899083 [56,] -28.8840279 -31.1869681 [57,] -32.5810877 -28.8840279 [58,] -42.1781475 -32.5810877 [59,] -50.6752073 -42.1781475 [60,] -51.8722671 -50.6752073 [61,] -42.5693269 -51.8722671 [62,] -41.5663867 -42.5693269 [63,] -46.1634465 -41.5663867 [64,] -53.7605063 -46.1634465 [65,] -54.4575661 -53.7605063 [66,] -52.0546259 -54.4575661 [67,] -42.9516857 -52.0546259 [68,] -36.3487455 -42.9516857 [69,] -38.6458053 -36.3487455 [70,] -43.9428651 -38.6458053 [71,] -43.4399249 -43.9428651 [72,] -35.5369847 -43.4399249 [73,] -29.9340445 -35.5369847 [74,] -26.2311043 -29.9340445 [75,] -16.6281641 -26.2311043 [76,] 0.2747760 -16.6281641 [77,] -1.8222838 0.2747760 [78,] 7.8806564 -1.8222838 [79,] 40.0835966 7.8806564 [80,] 40.9865368 40.0835966 [81,] 51.3894770 40.9865368 [82,] 47.4924172 51.3894770 [83,] 42.1953574 47.4924172 [84,] 44.6982976 42.1953574 [85,] 43.6012378 44.6982976 [86,] 47.4041780 43.6012378 [87,] 48.0071182 47.4041780 [88,] 49.9100584 48.0071182 [89,] 45.7129986 49.9100584 [90,] 43.5159388 45.7129986 [91,] 34.1188790 43.5159388 [92,] 23.7218192 34.1188790 [93,] 23.0247594 23.7218192 [94,] 23.9276996 23.0247594 [95,] 11.0306398 23.9276996 [96,] 27.5335800 11.0306398 [97,] 34.0365202 27.5335800 [98,] 41.3394604 34.0365202 [99,] 56.7424005 41.3394604 [100,] 65.2453407 56.7424005 [101,] 76.4482809 65.2453407 [102,] 63.0512211 76.4482809 [103,] 51.4541613 63.0512211 [104,] 24.9571015 51.4541613 [105,] -10.1399583 24.9571015 [106,] -28.7370181 -10.1399583 [107,] -45.3340779 -28.7370181 [108,] -48.2311377 -45.3340779 [109,] 6.4397093 -48.2311377 [110,] -7.5573505 6.4397093 [111,] -4.9544103 -7.5573505 [112,] 0.8485299 -4.9544103 [113,] -0.1485299 0.8485299 [114,] -4.5455897 -0.1485299 [115,] 4.1573505 -4.5455897 [116,] 5.7602907 4.1573505 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 53.5542614 57.0513212 2 58.6572016 53.5542614 3 55.1601418 58.6572016 4 54.2630820 55.1601418 5 51.9660222 54.2630820 6 49.1689624 51.9660222 7 51.0719025 49.1689624 8 51.2748427 51.0719025 9 46.0777829 51.2748427 10 40.5807231 46.0777829 11 35.3836633 40.5807231 12 34.5866035 35.3836633 13 34.7895437 34.5866035 14 31.8924839 34.7895437 15 29.4954241 31.8924839 16 30.7983643 29.4954241 17 27.1013045 30.7983643 18 17.5042447 27.1013045 19 11.5071849 17.5042447 20 7.6101251 11.5071849 21 1.3130653 7.6101251 22 -6.2839945 1.3130653 23 -11.5810543 -6.2839945 24 -7.9781141 -11.5810543 25 -9.9751739 -7.9781141 26 -10.5722337 -9.9751739 27 -12.0692935 -10.5722337 28 -12.8663533 -12.0692935 29 -16.0634131 -12.8663533 30 -19.2604730 -16.0634131 31 -22.0575328 -19.2604730 32 -25.5545926 -22.0575328 33 -30.4516524 -25.5545926 34 -31.4487122 -30.4516524 35 -32.6457720 -31.4487122 36 -33.4428318 -32.6457720 37 -27.9398916 -33.4428318 38 -31.2369514 -27.9398916 39 -38.2340112 -31.2369514 40 -43.4310710 -38.2340112 41 -46.1281308 -43.4310710 42 -48.2251906 -46.1281308 43 -43.0222504 -48.2251906 44 -41.3193102 -43.0222504 45 -41.7163700 -41.3193102 46 -48.5134298 -41.7163700 47 -52.9104896 -48.5134298 48 -49.4075494 -52.9104896 49 -44.5046092 -49.4075494 50 -24.5016690 -44.5046092 51 -19.8987288 -24.5016690 52 -21.8957886 -19.8987288 53 -27.0928485 -21.8957886 54 -32.4899083 -27.0928485 55 -31.1869681 -32.4899083 56 -28.8840279 -31.1869681 57 -32.5810877 -28.8840279 58 -42.1781475 -32.5810877 59 -50.6752073 -42.1781475 60 -51.8722671 -50.6752073 61 -42.5693269 -51.8722671 62 -41.5663867 -42.5693269 63 -46.1634465 -41.5663867 64 -53.7605063 -46.1634465 65 -54.4575661 -53.7605063 66 -52.0546259 -54.4575661 67 -42.9516857 -52.0546259 68 -36.3487455 -42.9516857 69 -38.6458053 -36.3487455 70 -43.9428651 -38.6458053 71 -43.4399249 -43.9428651 72 -35.5369847 -43.4399249 73 -29.9340445 -35.5369847 74 -26.2311043 -29.9340445 75 -16.6281641 -26.2311043 76 0.2747760 -16.6281641 77 -1.8222838 0.2747760 78 7.8806564 -1.8222838 79 40.0835966 7.8806564 80 40.9865368 40.0835966 81 51.3894770 40.9865368 82 47.4924172 51.3894770 83 42.1953574 47.4924172 84 44.6982976 42.1953574 85 43.6012378 44.6982976 86 47.4041780 43.6012378 87 48.0071182 47.4041780 88 49.9100584 48.0071182 89 45.7129986 49.9100584 90 43.5159388 45.7129986 91 34.1188790 43.5159388 92 23.7218192 34.1188790 93 23.0247594 23.7218192 94 23.9276996 23.0247594 95 11.0306398 23.9276996 96 27.5335800 11.0306398 97 34.0365202 27.5335800 98 41.3394604 34.0365202 99 56.7424005 41.3394604 100 65.2453407 56.7424005 101 76.4482809 65.2453407 102 63.0512211 76.4482809 103 51.4541613 63.0512211 104 24.9571015 51.4541613 105 -10.1399583 24.9571015 106 -28.7370181 -10.1399583 107 -45.3340779 -28.7370181 108 -48.2311377 -45.3340779 109 6.4397093 -48.2311377 110 -7.5573505 6.4397093 111 -4.9544103 -7.5573505 112 0.8485299 -4.9544103 113 -0.1485299 0.8485299 114 -4.5455897 -0.1485299 115 4.1573505 -4.5455897 116 5.7602907 4.1573505 > 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/79fpz1258470133.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/8idho1258470133.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/9r6yx1258470133.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/10gb7u1258470133.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/11u54v1258470133.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/12o7181258470133.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/13zfg11258470133.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/148vqz1258470133.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/15fhir1258470133.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/16l5rv1258470133.tab") + } > > system("convert tmp/1xvbo1258470133.ps tmp/1xvbo1258470133.png") > system("convert tmp/2d29s1258470133.ps tmp/2d29s1258470133.png") > system("convert tmp/31wia1258470133.ps tmp/31wia1258470133.png") > system("convert tmp/4iw7f1258470133.ps tmp/4iw7f1258470133.png") > system("convert tmp/5h2zd1258470133.ps tmp/5h2zd1258470133.png") > system("convert tmp/6yeof1258470133.ps tmp/6yeof1258470133.png") > system("convert tmp/79fpz1258470133.ps tmp/79fpz1258470133.png") > system("convert tmp/8idho1258470133.ps tmp/8idho1258470133.png") > system("convert tmp/9r6yx1258470133.ps tmp/9r6yx1258470133.png") > system("convert tmp/10gb7u1258470133.ps tmp/10gb7u1258470133.png") > > > proc.time() user system elapsed 3.179 1.667 5.193