R version 2.8.0 (2008-10-20) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > x <- array(list(32.68 + ,10967.87 + ,31.54 + ,10433.56 + ,32.43 + ,10665.78 + ,26.54 + ,10666.71 + ,25.85 + ,10682.74 + ,27.6 + ,10777.22 + ,25.71 + ,10052.6 + ,25.38 + ,10213.97 + ,28.57 + ,10546.82 + ,27.64 + ,10767.2 + ,25.36 + ,10444.5 + ,25.9 + ,10314.68 + ,26.29 + ,9042.56 + ,21.74 + ,9220.75 + ,19.2 + ,9721.84 + ,19.32 + ,9978.53 + ,19.82 + ,9923.81 + ,20.36 + ,9892.56 + ,24.31 + ,10500.98 + ,25.97 + ,10179.35 + ,25.61 + ,10080.48 + ,24.67 + ,9492.44 + ,25.59 + ,8616.49 + ,26.09 + ,8685.4 + ,28.37 + ,8160.67 + ,27.34 + ,8048.1 + ,24.46 + ,8641.21 + ,27.46 + ,8526.63 + ,30.23 + ,8474.21 + ,32.33 + ,7916.13 + ,29.87 + ,7977.64 + ,24.87 + ,8334.59 + ,25.48 + ,8623.36 + ,27.28 + ,9098.03 + ,28.24 + ,9154.34 + ,29.58 + ,9284.73 + ,26.95 + ,9492.49 + ,29.08 + ,9682.35 + ,28.76 + ,9762.12 + ,29.59 + ,10124.63 + ,30.7 + ,10540.05 + ,30.52 + ,10601.61 + ,32.67 + ,10323.73 + ,33.19 + ,10418.4 + ,37.13 + ,10092.96 + ,35.54 + ,10364.91 + ,37.75 + ,10152.09 + ,41.84 + ,10032.8 + ,42.94 + ,10204.59 + ,49.14 + ,10001.6 + ,44.61 + ,10411.75 + ,40.22 + ,10673.38 + ,44.23 + ,10539.51 + ,45.85 + ,10723.78 + ,53.38 + ,10682.06 + ,53.26 + ,10283.19 + ,51.8 + ,10377.18 + ,55.3 + ,10486.64 + ,57.81 + ,10545.38 + ,63.96 + ,10554.27 + ,63.77 + ,10532.54 + ,59.15 + ,10324.31 + ,56.12 + ,10695.25 + ,57.42 + ,10827.81 + ,63.52 + ,10872.48 + ,61.71 + ,10971.19 + ,63.01 + ,11145.65 + ,68.18 + ,11234.68 + ,72.03 + ,11333.88 + ,69.75 + ,10997.97 + ,74.41 + ,11036.89 + ,74.33 + ,11257.35 + ,64.24 + ,11533.59 + ,60.03 + ,11963.12 + ,59.44 + ,12185.15 + ,62.5 + ,12377.62 + ,55.04 + ,12512.89 + ,58.34 + ,12631.48 + ,61.92 + ,12268.53 + ,67.65 + ,12754.8 + ,67.68 + ,13407.75 + ,70.3 + ,13480.21 + ,75.26 + ,13673.28 + ,71.44 + ,13239.71 + ,76.36 + ,13557.69 + ,81.71 + ,13901.28 + ,92.6 + ,13200.58 + ,90.6 + ,13406.97 + ,92.23 + ,12538.12 + ,94.09 + ,12419.57 + ,102.79 + ,12193.88 + ,109.65 + ,12656.63 + ,124.05 + ,12812.48 + ,132.69 + ,12056.67 + ,135.81 + ,11322.38 + ,116.07 + ,11530.75 + ,101.42 + ,11114.08 + ,75.73 + ,9181.73 + ,55.48 + ,8614.55) + ,dim=c(2 + ,99) + ,dimnames=list(c('Olieprijs' + ,'DowJones') + ,1:99)) > y <- array(NA,dim=c(2,99),dimnames=list(c('Olieprijs','DowJones'),1:99)) > 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 Olieprijs DowJones 1 32.68 10967.87 2 31.54 10433.56 3 32.43 10665.78 4 26.54 10666.71 5 25.85 10682.74 6 27.60 10777.22 7 25.71 10052.60 8 25.38 10213.97 9 28.57 10546.82 10 27.64 10767.20 11 25.36 10444.50 12 25.90 10314.68 13 26.29 9042.56 14 21.74 9220.75 15 19.20 9721.84 16 19.32 9978.53 17 19.82 9923.81 18 20.36 9892.56 19 24.31 10500.98 20 25.97 10179.35 21 25.61 10080.48 22 24.67 9492.44 23 25.59 8616.49 24 26.09 8685.40 25 28.37 8160.67 26 27.34 8048.10 27 24.46 8641.21 28 27.46 8526.63 29 30.23 8474.21 30 32.33 7916.13 31 29.87 7977.64 32 24.87 8334.59 33 25.48 8623.36 34 27.28 9098.03 35 28.24 9154.34 36 29.58 9284.73 37 26.95 9492.49 38 29.08 9682.35 39 28.76 9762.12 40 29.59 10124.63 41 30.70 10540.05 42 30.52 10601.61 43 32.67 10323.73 44 33.19 10418.40 45 37.13 10092.96 46 35.54 10364.91 47 37.75 10152.09 48 41.84 10032.80 49 42.94 10204.59 50 49.14 10001.60 51 44.61 10411.75 52 40.22 10673.38 53 44.23 10539.51 54 45.85 10723.78 55 53.38 10682.06 56 53.26 10283.19 57 51.80 10377.18 58 55.30 10486.64 59 57.81 10545.38 60 63.96 10554.27 61 63.77 10532.54 62 59.15 10324.31 63 56.12 10695.25 64 57.42 10827.81 65 63.52 10872.48 66 61.71 10971.19 67 63.01 11145.65 68 68.18 11234.68 69 72.03 11333.88 70 69.75 10997.97 71 74.41 11036.89 72 74.33 11257.35 73 64.24 11533.59 74 60.03 11963.12 75 59.44 12185.15 76 62.50 12377.62 77 55.04 12512.89 78 58.34 12631.48 79 61.92 12268.53 80 67.65 12754.80 81 67.68 13407.75 82 70.30 13480.21 83 75.26 13673.28 84 71.44 13239.71 85 76.36 13557.69 86 81.71 13901.28 87 92.60 13200.58 88 90.60 13406.97 89 92.23 12538.12 90 94.09 12419.57 91 102.79 12193.88 92 109.65 12656.63 93 124.05 12812.48 94 132.69 12056.67 95 135.81 11322.38 96 116.07 11530.75 97 101.42 11114.08 98 75.73 9181.73 99 55.48 8614.55 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) DowJones -91.02199 0.01327 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -24.852 -15.487 -2.575 8.879 76.622 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -91.02200 15.36990 -5.922 4.82e-08 *** DowJones 0.01327 0.00143 9.278 4.86e-15 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 20.05 on 97 degrees of freedom Multiple R-squared: 0.4702, Adjusted R-squared: 0.4647 F-statistic: 86.08 on 1 and 97 DF, p-value: 4.863e-15 > 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,] 9.327890e-03 1.865578e-02 0.9906721 [2,] 1.821574e-03 3.643149e-03 0.9981784 [3,] 3.019532e-04 6.039064e-04 0.9996980 [4,] 4.885762e-05 9.771524e-05 0.9999511 [5,] 6.745274e-06 1.349055e-05 0.9999933 [6,] 1.151332e-06 2.302665e-06 0.9999988 [7,] 2.220620e-07 4.441240e-07 0.9999998 [8,] 3.056270e-08 6.112541e-08 1.0000000 [9,] 8.790757e-09 1.758151e-08 1.0000000 [10,] 1.862253e-09 3.724505e-09 1.0000000 [11,] 2.295927e-09 4.591855e-09 1.0000000 [12,] 2.416426e-09 4.832853e-09 1.0000000 [13,] 1.228831e-09 2.457661e-09 1.0000000 [14,] 4.244147e-10 8.488293e-10 1.0000000 [15,] 1.164611e-10 2.329222e-10 1.0000000 [16,] 2.292223e-11 4.584446e-11 1.0000000 [17,] 4.463572e-12 8.927144e-12 1.0000000 [18,] 1.045095e-12 2.090190e-12 1.0000000 [19,] 8.159073e-13 1.631815e-12 1.0000000 [20,] 3.159577e-13 6.319153e-13 1.0000000 [21,] 2.552639e-13 5.105279e-13 1.0000000 [22,] 7.730918e-14 1.546184e-13 1.0000000 [23,] 1.358579e-14 2.717159e-14 1.0000000 [24,] 3.151427e-15 6.302854e-15 1.0000000 [25,] 1.493965e-15 2.987931e-15 1.0000000 [26,] 1.315891e-15 2.631781e-15 1.0000000 [27,] 3.499047e-16 6.998094e-16 1.0000000 [28,] 6.737142e-17 1.347428e-16 1.0000000 [29,] 1.195759e-17 2.391518e-17 1.0000000 [30,] 2.164074e-18 4.328148e-18 1.0000000 [31,] 4.285315e-19 8.570630e-19 1.0000000 [32,] 1.099803e-19 2.199606e-19 1.0000000 [33,] 2.088651e-20 4.177302e-20 1.0000000 [34,] 5.328151e-21 1.065630e-20 1.0000000 [35,] 1.327618e-21 2.655236e-21 1.0000000 [36,] 4.523246e-22 9.046491e-22 1.0000000 [37,] 2.485774e-22 4.971547e-22 1.0000000 [38,] 1.329383e-22 2.658766e-22 1.0000000 [39,] 1.302087e-22 2.604175e-22 1.0000000 [40,] 1.501432e-22 3.002864e-22 1.0000000 [41,] 1.007487e-21 2.014973e-21 1.0000000 [42,] 2.109094e-21 4.218189e-21 1.0000000 [43,] 9.614389e-21 1.922878e-20 1.0000000 [44,] 2.370895e-19 4.741790e-19 1.0000000 [45,] 4.118268e-18 8.236536e-18 1.0000000 [46,] 6.150580e-16 1.230116e-15 1.0000000 [47,] 3.620591e-15 7.241181e-15 1.0000000 [48,] 6.045481e-15 1.209096e-14 1.0000000 [49,] 2.037098e-14 4.074196e-14 1.0000000 [50,] 7.599272e-14 1.519854e-13 1.0000000 [51,] 1.302835e-12 2.605670e-12 1.0000000 [52,] 1.345043e-11 2.690087e-11 1.0000000 [53,] 6.068384e-11 1.213677e-10 1.0000000 [54,] 3.499324e-10 6.998647e-10 1.0000000 [55,] 1.995403e-09 3.990806e-09 1.0000000 [56,] 1.984478e-08 3.968956e-08 1.0000000 [57,] 1.048602e-07 2.097205e-07 0.9999999 [58,] 2.592171e-07 5.184341e-07 0.9999997 [59,] 3.897295e-07 7.794590e-07 0.9999996 [60,] 5.711166e-07 1.142233e-06 0.9999994 [61,] 1.073240e-06 2.146481e-06 0.9999989 [62,] 1.548804e-06 3.097608e-06 0.9999985 [63,] 2.036437e-06 4.072875e-06 0.9999980 [64,] 2.958578e-06 5.917156e-06 0.9999970 [65,] 4.365733e-06 8.731466e-06 0.9999956 [66,] 6.196376e-06 1.239275e-05 0.9999938 [67,] 9.786367e-06 1.957273e-05 0.9999902 [68,] 1.163759e-05 2.327518e-05 0.9999884 [69,] 9.965093e-06 1.993019e-05 0.9999900 [70,] 9.454576e-06 1.890915e-05 0.9999905 [71,] 9.989500e-06 1.997900e-05 0.9999900 [72,] 9.564250e-06 1.912850e-05 0.9999904 [73,] 1.871296e-05 3.742592e-05 0.9999813 [74,] 3.224546e-05 6.449092e-05 0.9999678 [75,] 4.886824e-05 9.773649e-05 0.9999511 [76,] 5.592963e-05 1.118593e-04 0.9999441 [77,] 7.583189e-05 1.516638e-04 0.9999242 [78,] 1.046616e-04 2.093232e-04 0.9998953 [79,] 1.300095e-04 2.600190e-04 0.9998700 [80,] 2.886880e-04 5.773760e-04 0.9997113 [81,] 7.136478e-04 1.427296e-03 0.9992864 [82,] 2.571007e-03 5.142014e-03 0.9974290 [83,] 4.642378e-03 9.284757e-03 0.9953576 [84,] 1.917949e-02 3.835899e-02 0.9808205 [85,] 5.149553e-02 1.029911e-01 0.9485045 [86,] 1.434826e-01 2.869652e-01 0.8565174 [87,] 2.210458e-01 4.420916e-01 0.7789542 [88,] 4.328008e-01 8.656016e-01 0.5671992 [89,] 6.542372e-01 6.915256e-01 0.3457628 [90,] 5.712331e-01 8.575338e-01 0.4287669 > postscript(file="/var/www/html/rcomp/tmp/17fx71229180856.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/221be1229180856.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/3lmpl1229180856.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/45gpn1229180856.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/5ahrg1229180856.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 = 99 Frequency = 1 1 2 3 4 5 6 -21.8049556 -15.8564490 -18.0472317 -23.9495697 -24.8522342 -24.3556677 7 8 9 10 11 12 -16.6323840 -19.1032242 -20.3290304 -24.1827359 -22.1815862 -19.9193090 13 14 15 16 17 18 -2.6525315 -9.5665168 -18.7543051 -22.0397229 -20.8137715 -19.8591885 19 20 21 22 23 24 -23.9808869 -18.0539326 -17.1022584 -10.2409344 2.2999923 1.8857871 25 26 27 28 29 30 11.1271991 11.5906265 0.8420406 5.3621339 8.8275720 18.3314270 31 32 33 34 35 36 15.0553950 5.3198624 2.0988504 -2.3984329 -2.1854782 -2.5753174 37 38 39 40 41 42 -7.9615977 -8.3504049 -9.7286860 -13.7079812 -18.1092151 -19.1059104 43 44 45 46 47 48 -13.2693723 -14.0053265 -5.7478262 -10.9456931 -5.9122835 -0.2397042 49 50 51 52 53 54 -1.4187829 7.4742154 -2.4971032 -10.3580583 -4.5720511 -5.3966977 55 56 57 58 59 60 2.6867872 7.8584580 5.1515250 7.1993569 8.9300736 14.9621330 61 62 63 64 65 66 15.0604175 13.2029331 5.2518000 4.7931722 10.3005507 7.1809991 67 68 69 70 71 72 6.1664984 10.1553681 12.6893159 14.8657181 19.0093799 16.0046131 73 74 75 76 77 78 2.2498322 -7.6585942 -11.1941897 -10.6876228 -19.9422033 -18.2154960 79 80 81 82 83 84 -9.8203634 -10.5415399 -19.1740024 -17.5153043 -15.1166974 -13.1846737 85 86 87 88 89 90 -12.4832047 -11.6914948 8.4944505 3.7563456 16.9130790 20.3458410 91 92 93 94 95 96 32.0399924 32.7608477 45.0932394 63.7603102 76.6218825 54.1175095 97 98 99 44.9953268 44.9411481 32.2157296 > postscript(file="/var/www/html/rcomp/tmp/6e1cm1229180856.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 = 99 Frequency = 1 lag(myerror, k = 1) myerror 0 -21.8049556 NA 1 -15.8564490 -21.8049556 2 -18.0472317 -15.8564490 3 -23.9495697 -18.0472317 4 -24.8522342 -23.9495697 5 -24.3556677 -24.8522342 6 -16.6323840 -24.3556677 7 -19.1032242 -16.6323840 8 -20.3290304 -19.1032242 9 -24.1827359 -20.3290304 10 -22.1815862 -24.1827359 11 -19.9193090 -22.1815862 12 -2.6525315 -19.9193090 13 -9.5665168 -2.6525315 14 -18.7543051 -9.5665168 15 -22.0397229 -18.7543051 16 -20.8137715 -22.0397229 17 -19.8591885 -20.8137715 18 -23.9808869 -19.8591885 19 -18.0539326 -23.9808869 20 -17.1022584 -18.0539326 21 -10.2409344 -17.1022584 22 2.2999923 -10.2409344 23 1.8857871 2.2999923 24 11.1271991 1.8857871 25 11.5906265 11.1271991 26 0.8420406 11.5906265 27 5.3621339 0.8420406 28 8.8275720 5.3621339 29 18.3314270 8.8275720 30 15.0553950 18.3314270 31 5.3198624 15.0553950 32 2.0988504 5.3198624 33 -2.3984329 2.0988504 34 -2.1854782 -2.3984329 35 -2.5753174 -2.1854782 36 -7.9615977 -2.5753174 37 -8.3504049 -7.9615977 38 -9.7286860 -8.3504049 39 -13.7079812 -9.7286860 40 -18.1092151 -13.7079812 41 -19.1059104 -18.1092151 42 -13.2693723 -19.1059104 43 -14.0053265 -13.2693723 44 -5.7478262 -14.0053265 45 -10.9456931 -5.7478262 46 -5.9122835 -10.9456931 47 -0.2397042 -5.9122835 48 -1.4187829 -0.2397042 49 7.4742154 -1.4187829 50 -2.4971032 7.4742154 51 -10.3580583 -2.4971032 52 -4.5720511 -10.3580583 53 -5.3966977 -4.5720511 54 2.6867872 -5.3966977 55 7.8584580 2.6867872 56 5.1515250 7.8584580 57 7.1993569 5.1515250 58 8.9300736 7.1993569 59 14.9621330 8.9300736 60 15.0604175 14.9621330 61 13.2029331 15.0604175 62 5.2518000 13.2029331 63 4.7931722 5.2518000 64 10.3005507 4.7931722 65 7.1809991 10.3005507 66 6.1664984 7.1809991 67 10.1553681 6.1664984 68 12.6893159 10.1553681 69 14.8657181 12.6893159 70 19.0093799 14.8657181 71 16.0046131 19.0093799 72 2.2498322 16.0046131 73 -7.6585942 2.2498322 74 -11.1941897 -7.6585942 75 -10.6876228 -11.1941897 76 -19.9422033 -10.6876228 77 -18.2154960 -19.9422033 78 -9.8203634 -18.2154960 79 -10.5415399 -9.8203634 80 -19.1740024 -10.5415399 81 -17.5153043 -19.1740024 82 -15.1166974 -17.5153043 83 -13.1846737 -15.1166974 84 -12.4832047 -13.1846737 85 -11.6914948 -12.4832047 86 8.4944505 -11.6914948 87 3.7563456 8.4944505 88 16.9130790 3.7563456 89 20.3458410 16.9130790 90 32.0399924 20.3458410 91 32.7608477 32.0399924 92 45.0932394 32.7608477 93 63.7603102 45.0932394 94 76.6218825 63.7603102 95 54.1175095 76.6218825 96 44.9953268 54.1175095 97 44.9411481 44.9953268 98 32.2157296 44.9411481 99 NA 32.2157296 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -15.8564490 -21.8049556 [2,] -18.0472317 -15.8564490 [3,] -23.9495697 -18.0472317 [4,] -24.8522342 -23.9495697 [5,] -24.3556677 -24.8522342 [6,] -16.6323840 -24.3556677 [7,] -19.1032242 -16.6323840 [8,] -20.3290304 -19.1032242 [9,] -24.1827359 -20.3290304 [10,] -22.1815862 -24.1827359 [11,] -19.9193090 -22.1815862 [12,] -2.6525315 -19.9193090 [13,] -9.5665168 -2.6525315 [14,] -18.7543051 -9.5665168 [15,] -22.0397229 -18.7543051 [16,] -20.8137715 -22.0397229 [17,] -19.8591885 -20.8137715 [18,] -23.9808869 -19.8591885 [19,] -18.0539326 -23.9808869 [20,] -17.1022584 -18.0539326 [21,] -10.2409344 -17.1022584 [22,] 2.2999923 -10.2409344 [23,] 1.8857871 2.2999923 [24,] 11.1271991 1.8857871 [25,] 11.5906265 11.1271991 [26,] 0.8420406 11.5906265 [27,] 5.3621339 0.8420406 [28,] 8.8275720 5.3621339 [29,] 18.3314270 8.8275720 [30,] 15.0553950 18.3314270 [31,] 5.3198624 15.0553950 [32,] 2.0988504 5.3198624 [33,] -2.3984329 2.0988504 [34,] -2.1854782 -2.3984329 [35,] -2.5753174 -2.1854782 [36,] -7.9615977 -2.5753174 [37,] -8.3504049 -7.9615977 [38,] -9.7286860 -8.3504049 [39,] -13.7079812 -9.7286860 [40,] -18.1092151 -13.7079812 [41,] -19.1059104 -18.1092151 [42,] -13.2693723 -19.1059104 [43,] -14.0053265 -13.2693723 [44,] -5.7478262 -14.0053265 [45,] -10.9456931 -5.7478262 [46,] -5.9122835 -10.9456931 [47,] -0.2397042 -5.9122835 [48,] -1.4187829 -0.2397042 [49,] 7.4742154 -1.4187829 [50,] -2.4971032 7.4742154 [51,] -10.3580583 -2.4971032 [52,] -4.5720511 -10.3580583 [53,] -5.3966977 -4.5720511 [54,] 2.6867872 -5.3966977 [55,] 7.8584580 2.6867872 [56,] 5.1515250 7.8584580 [57,] 7.1993569 5.1515250 [58,] 8.9300736 7.1993569 [59,] 14.9621330 8.9300736 [60,] 15.0604175 14.9621330 [61,] 13.2029331 15.0604175 [62,] 5.2518000 13.2029331 [63,] 4.7931722 5.2518000 [64,] 10.3005507 4.7931722 [65,] 7.1809991 10.3005507 [66,] 6.1664984 7.1809991 [67,] 10.1553681 6.1664984 [68,] 12.6893159 10.1553681 [69,] 14.8657181 12.6893159 [70,] 19.0093799 14.8657181 [71,] 16.0046131 19.0093799 [72,] 2.2498322 16.0046131 [73,] -7.6585942 2.2498322 [74,] -11.1941897 -7.6585942 [75,] -10.6876228 -11.1941897 [76,] -19.9422033 -10.6876228 [77,] -18.2154960 -19.9422033 [78,] -9.8203634 -18.2154960 [79,] -10.5415399 -9.8203634 [80,] -19.1740024 -10.5415399 [81,] -17.5153043 -19.1740024 [82,] -15.1166974 -17.5153043 [83,] -13.1846737 -15.1166974 [84,] -12.4832047 -13.1846737 [85,] -11.6914948 -12.4832047 [86,] 8.4944505 -11.6914948 [87,] 3.7563456 8.4944505 [88,] 16.9130790 3.7563456 [89,] 20.3458410 16.9130790 [90,] 32.0399924 20.3458410 [91,] 32.7608477 32.0399924 [92,] 45.0932394 32.7608477 [93,] 63.7603102 45.0932394 [94,] 76.6218825 63.7603102 [95,] 54.1175095 76.6218825 [96,] 44.9953268 54.1175095 [97,] 44.9411481 44.9953268 [98,] 32.2157296 44.9411481 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -15.8564490 -21.8049556 2 -18.0472317 -15.8564490 3 -23.9495697 -18.0472317 4 -24.8522342 -23.9495697 5 -24.3556677 -24.8522342 6 -16.6323840 -24.3556677 7 -19.1032242 -16.6323840 8 -20.3290304 -19.1032242 9 -24.1827359 -20.3290304 10 -22.1815862 -24.1827359 11 -19.9193090 -22.1815862 12 -2.6525315 -19.9193090 13 -9.5665168 -2.6525315 14 -18.7543051 -9.5665168 15 -22.0397229 -18.7543051 16 -20.8137715 -22.0397229 17 -19.8591885 -20.8137715 18 -23.9808869 -19.8591885 19 -18.0539326 -23.9808869 20 -17.1022584 -18.0539326 21 -10.2409344 -17.1022584 22 2.2999923 -10.2409344 23 1.8857871 2.2999923 24 11.1271991 1.8857871 25 11.5906265 11.1271991 26 0.8420406 11.5906265 27 5.3621339 0.8420406 28 8.8275720 5.3621339 29 18.3314270 8.8275720 30 15.0553950 18.3314270 31 5.3198624 15.0553950 32 2.0988504 5.3198624 33 -2.3984329 2.0988504 34 -2.1854782 -2.3984329 35 -2.5753174 -2.1854782 36 -7.9615977 -2.5753174 37 -8.3504049 -7.9615977 38 -9.7286860 -8.3504049 39 -13.7079812 -9.7286860 40 -18.1092151 -13.7079812 41 -19.1059104 -18.1092151 42 -13.2693723 -19.1059104 43 -14.0053265 -13.2693723 44 -5.7478262 -14.0053265 45 -10.9456931 -5.7478262 46 -5.9122835 -10.9456931 47 -0.2397042 -5.9122835 48 -1.4187829 -0.2397042 49 7.4742154 -1.4187829 50 -2.4971032 7.4742154 51 -10.3580583 -2.4971032 52 -4.5720511 -10.3580583 53 -5.3966977 -4.5720511 54 2.6867872 -5.3966977 55 7.8584580 2.6867872 56 5.1515250 7.8584580 57 7.1993569 5.1515250 58 8.9300736 7.1993569 59 14.9621330 8.9300736 60 15.0604175 14.9621330 61 13.2029331 15.0604175 62 5.2518000 13.2029331 63 4.7931722 5.2518000 64 10.3005507 4.7931722 65 7.1809991 10.3005507 66 6.1664984 7.1809991 67 10.1553681 6.1664984 68 12.6893159 10.1553681 69 14.8657181 12.6893159 70 19.0093799 14.8657181 71 16.0046131 19.0093799 72 2.2498322 16.0046131 73 -7.6585942 2.2498322 74 -11.1941897 -7.6585942 75 -10.6876228 -11.1941897 76 -19.9422033 -10.6876228 77 -18.2154960 -19.9422033 78 -9.8203634 -18.2154960 79 -10.5415399 -9.8203634 80 -19.1740024 -10.5415399 81 -17.5153043 -19.1740024 82 -15.1166974 -17.5153043 83 -13.1846737 -15.1166974 84 -12.4832047 -13.1846737 85 -11.6914948 -12.4832047 86 8.4944505 -11.6914948 87 3.7563456 8.4944505 88 16.9130790 3.7563456 89 20.3458410 16.9130790 90 32.0399924 20.3458410 91 32.7608477 32.0399924 92 45.0932394 32.7608477 93 63.7603102 45.0932394 94 76.6218825 63.7603102 95 54.1175095 76.6218825 96 44.9953268 54.1175095 97 44.9411481 44.9953268 98 32.2157296 44.9411481 > 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/7z7211229180856.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/8xoqk1229180856.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/94qti1229180856.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/103iik1229180856.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/112d5c1229180856.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/12gnr01229180856.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/13th751229180856.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/14mzfc1229180856.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/15z45h1229180856.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/163w0x1229180856.tab") + } > > system("convert tmp/17fx71229180856.ps tmp/17fx71229180856.png") > system("convert tmp/221be1229180856.ps tmp/221be1229180856.png") > system("convert tmp/3lmpl1229180856.ps tmp/3lmpl1229180856.png") > system("convert tmp/45gpn1229180856.ps tmp/45gpn1229180856.png") > system("convert tmp/5ahrg1229180856.ps tmp/5ahrg1229180856.png") > system("convert tmp/6e1cm1229180856.ps tmp/6e1cm1229180856.png") > system("convert tmp/7z7211229180856.ps tmp/7z7211229180856.png") > system("convert tmp/8xoqk1229180856.ps tmp/8xoqk1229180856.png") > system("convert tmp/94qti1229180856.ps tmp/94qti1229180856.png") > system("convert tmp/103iik1229180856.ps tmp/103iik1229180856.png") > > > proc.time() user system elapsed 2.907 1.671 4.020