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(7.1,0,6.8,0,6.5,0,6.3,0,6.1,0,6.1,0,6.3,0,6.3,0,6.0,0,6.2,0,6.4,0,6.8,0,7.5,0,7.5,0,7.6,0,7.6,0,7.4,0,7.3,0,7.1,0,6.9,0,6.8,0,7.5,0,7.6,0,7.8,0,8.0,0,8.1,0,8.2,0,8.3,0,8.2,0,8.0,0,7.9,0,7.6,0,7.6,0,8.2,0,8.3,0,8.4,0,8.4,0,8.4,0,8.6,0,8.9,0,8.8,0,8.3,0,7.5,0,7.2,0,7.5,0,8.8,0,9.3,0,9.3,0,8.7,1,8.2,1,8.3,1,8.5,1,8.6,1,8.6,1,8.2,1,8.1,1,8.0,1,8.6,1,8.7,1,8.8,1,8.5,1,8.4,1,8.5,1,8.7,1,8.7,1,8.6,1,8.5,1,8.3,1,8.1,1,8.2,1,8.1,1,8.1,1,7.9,1,7.9,1,7.9,1,8.0,1,8.0,1,7.9,1,8.0,1,7.7,1,7.2,1,7.5,1,7.3,1,7.0,1,7.0,1,7.0,1,7.2,1,7.3,1,7.1,1,6.8,1,6.6,1,6.2,1,6.2,1,6.8,1,6.9,1,6.8,1),dim=c(2,96),dimnames=list(c('w','d'),1:96)) > y <- array(NA,dim=c(2,96),dimnames=list(c('w','d'),1:96)) > 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 w d t 1 7.1 0 1 2 6.8 0 2 3 6.5 0 3 4 6.3 0 4 5 6.1 0 5 6 6.1 0 6 7 6.3 0 7 8 6.3 0 8 9 6.0 0 9 10 6.2 0 10 11 6.4 0 11 12 6.8 0 12 13 7.5 0 13 14 7.5 0 14 15 7.6 0 15 16 7.6 0 16 17 7.4 0 17 18 7.3 0 18 19 7.1 0 19 20 6.9 0 20 21 6.8 0 21 22 7.5 0 22 23 7.6 0 23 24 7.8 0 24 25 8.0 0 25 26 8.1 0 26 27 8.2 0 27 28 8.3 0 28 29 8.2 0 29 30 8.0 0 30 31 7.9 0 31 32 7.6 0 32 33 7.6 0 33 34 8.2 0 34 35 8.3 0 35 36 8.4 0 36 37 8.4 0 37 38 8.4 0 38 39 8.6 0 39 40 8.9 0 40 41 8.8 0 41 42 8.3 0 42 43 7.5 0 43 44 7.2 0 44 45 7.5 0 45 46 8.8 0 46 47 9.3 0 47 48 9.3 0 48 49 8.7 1 49 50 8.2 1 50 51 8.3 1 51 52 8.5 1 52 53 8.6 1 53 54 8.6 1 54 55 8.2 1 55 56 8.1 1 56 57 8.0 1 57 58 8.6 1 58 59 8.7 1 59 60 8.8 1 60 61 8.5 1 61 62 8.4 1 62 63 8.5 1 63 64 8.7 1 64 65 8.7 1 65 66 8.6 1 66 67 8.5 1 67 68 8.3 1 68 69 8.1 1 69 70 8.2 1 70 71 8.1 1 71 72 8.1 1 72 73 7.9 1 73 74 7.9 1 74 75 7.9 1 75 76 8.0 1 76 77 8.0 1 77 78 7.9 1 78 79 8.0 1 79 80 7.7 1 80 81 7.2 1 81 82 7.5 1 82 83 7.3 1 83 84 7.0 1 84 85 7.0 1 85 86 7.0 1 86 87 7.2 1 87 88 7.3 1 88 89 7.1 1 89 90 6.8 1 90 91 6.6 1 91 92 6.2 1 92 93 6.2 1 93 94 6.8 1 94 95 6.9 1 95 96 6.8 1 96 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) d t 7.492221 0.118815 0.003124 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -1.70153 -0.66874 0.06093 0.67736 1.66097 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 7.492221 0.187138 40.036 <2e-16 *** d 0.118815 0.330623 0.359 0.720 t 0.003124 0.005965 0.524 0.602 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.8097 on 93 degrees of freedom Multiple R-squared: 0.03042, Adjusted R-squared: 0.009571 F-statistic: 1.459 on 2 and 93 DF, p-value: 0.2377 > 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.005834185 1.166837e-02 9.941658e-01 [2,] 0.014826736 2.965347e-02 9.851733e-01 [3,] 0.011895684 2.379137e-02 9.881043e-01 [4,] 0.004688304 9.376608e-03 9.953117e-01 [5,] 0.003725382 7.450765e-03 9.962746e-01 [6,] 0.006072517 1.214503e-02 9.939275e-01 [7,] 0.025068897 5.013779e-02 9.749311e-01 [8,] 0.172465928 3.449319e-01 8.275341e-01 [9,] 0.248848814 4.976976e-01 7.511512e-01 [10,] 0.275863368 5.517267e-01 7.241366e-01 [11,] 0.257179845 5.143597e-01 7.428202e-01 [12,] 0.215314048 4.306281e-01 7.846860e-01 [13,] 0.184661498 3.693230e-01 8.153385e-01 [14,] 0.186567501 3.731350e-01 8.134325e-01 [15,] 0.244363709 4.887274e-01 7.556363e-01 [16,] 0.368745039 7.374901e-01 6.312550e-01 [17,] 0.371256397 7.425128e-01 6.287436e-01 [18,] 0.373765486 7.475310e-01 6.262345e-01 [19,] 0.372651624 7.453032e-01 6.273484e-01 [20,] 0.369414619 7.388292e-01 6.305854e-01 [21,] 0.356260792 7.125216e-01 6.437392e-01 [22,] 0.334115053 6.682301e-01 6.658849e-01 [23,] 0.304690216 6.093804e-01 6.953098e-01 [24,] 0.263843813 5.276876e-01 7.361562e-01 [25,] 0.240844788 4.816896e-01 7.591552e-01 [26,] 0.240759546 4.815191e-01 7.592405e-01 [27,] 0.343686553 6.873731e-01 6.563134e-01 [28,] 0.474568202 9.491364e-01 5.254318e-01 [29,] 0.440545135 8.810903e-01 5.594549e-01 [30,] 0.397330697 7.946614e-01 6.026693e-01 [31,] 0.348037691 6.960754e-01 6.519623e-01 [32,] 0.299550587 5.991012e-01 7.004494e-01 [33,] 0.254224332 5.084487e-01 7.457757e-01 [34,] 0.208242104 4.164842e-01 7.917579e-01 [35,] 0.188942233 3.778845e-01 8.110578e-01 [36,] 0.159597732 3.191955e-01 8.404023e-01 [37,] 0.147738430 2.954769e-01 8.522616e-01 [38,] 0.426104534 8.522091e-01 5.738955e-01 [39,] 0.903693196 1.926136e-01 9.630680e-02 [40,] 0.996141014 7.717972e-03 3.858986e-03 [41,] 0.996062114 7.875772e-03 3.937886e-03 [42,] 0.995637800 8.724401e-03 4.362200e-03 [43,] 0.994615268 1.076946e-02 5.384732e-03 [44,] 0.992436742 1.512652e-02 7.563258e-03 [45,] 0.996030431 7.939139e-03 3.969569e-03 [46,] 0.997365821 5.268358e-03 2.634179e-03 [47,] 0.997209149 5.581702e-03 2.790851e-03 [48,] 0.996421912 7.156175e-03 3.578088e-03 [49,] 0.995286979 9.426043e-03 4.713021e-03 [50,] 0.997913006 4.173988e-03 2.086994e-03 [51,] 0.999612559 7.748830e-04 3.874415e-04 [52,] 0.999990301 1.939772e-05 9.698858e-06 [53,] 0.999989148 2.170374e-05 1.085187e-05 [54,] 0.999981519 3.696210e-05 1.848105e-05 [55,] 0.999962284 7.543147e-05 3.771573e-05 [56,] 0.999955189 8.962188e-05 4.481094e-05 [57,] 0.999962810 7.437942e-05 3.718971e-05 [58,] 0.999947793 1.044135e-04 5.220675e-05 [59,] 0.999896141 2.077182e-04 1.038591e-04 [60,] 0.999813834 3.723325e-04 1.861662e-04 [61,] 0.999679304 6.413919e-04 3.206960e-04 [62,] 0.999477087 1.045826e-03 5.229132e-04 [63,] 0.999254520 1.490961e-03 7.454804e-04 [64,] 0.999260731 1.478538e-03 7.392689e-04 [65,] 0.998982452 2.035096e-03 1.017548e-03 [66,] 0.998719748 2.560504e-03 1.280252e-03 [67,] 0.998271421 3.457159e-03 1.728579e-03 [68,] 0.998216258 3.567483e-03 1.783742e-03 [69,] 0.997898684 4.202632e-03 2.101316e-03 [70,] 0.997242602 5.514796e-03 2.757398e-03 [71,] 0.996024302 7.951395e-03 3.975698e-03 [72,] 0.994766651 1.046670e-02 5.233349e-03 [73,] 0.993352652 1.329470e-02 6.647348e-03 [74,] 0.995123769 9.752461e-03 4.876231e-03 [75,] 0.994820651 1.035870e-02 5.179349e-03 [76,] 0.993898485 1.220303e-02 6.101515e-03 [77,] 0.991970892 1.605822e-02 8.029108e-03 [78,] 0.987954543 2.409091e-02 1.204546e-02 [79,] 0.982661342 3.467732e-02 1.733866e-02 [80,] 0.972871577 5.425685e-02 2.712842e-02 [81,] 0.954988777 9.002245e-02 4.501122e-02 [82,] 0.924157910 1.516842e-01 7.584209e-02 [83,] 0.914435527 1.711289e-01 8.556447e-02 [84,] 0.918313207 1.633736e-01 8.168679e-02 [85,] 0.907306357 1.853873e-01 9.269364e-02 > postscript(file="/var/www/html/rcomp/tmp/1vkea1227789088.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/21ryu1227789088.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/3ge9q1227789088.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/4fwbd1227789088.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/5dzcs1227789088.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 = 96 Frequency = 1 1 2 3 4 5 6 -0.395344388 -0.698468031 -1.001591674 -1.204715317 -1.407838960 -1.410962603 7 8 9 10 11 12 -1.214086246 -1.217209889 -1.520333532 -1.323457175 -1.126580818 -0.729704462 13 14 15 16 17 18 -0.032828105 -0.035951748 0.060924609 0.057800966 -0.145322677 -0.248446320 19 20 21 22 23 24 -0.451569963 -0.654693606 -0.757817249 -0.060940892 0.035935465 0.232811822 25 26 27 28 29 30 0.429688178 0.526564535 0.623440892 0.720317249 0.617193606 0.414069963 31 32 33 34 35 36 0.310946320 0.007822677 0.004699034 0.601575391 0.698451748 0.795328105 37 38 39 40 41 42 0.792204462 0.789080818 0.985957175 1.282833532 1.179709889 0.676586246 43 44 45 46 47 48 -0.126537397 -0.429661040 -0.132784683 1.164091674 1.660968031 1.657844388 49 50 51 52 53 54 0.935905612 0.432781969 0.529658326 0.726534683 0.823411040 0.820287397 55 56 57 58 59 60 0.417163754 0.314040111 0.210916468 0.807792825 0.904669182 1.001545538 61 62 63 64 65 66 0.698421895 0.595298252 0.692174609 0.889050966 0.885927323 0.782803680 67 68 69 70 71 72 0.679680037 0.476556394 0.273432751 0.370309108 0.267185465 0.264061822 73 74 75 76 77 78 0.060938178 0.057814535 0.054690892 0.151567249 0.148443606 0.045319963 79 80 81 82 83 84 0.142196320 -0.160927323 -0.664050966 -0.367174609 -0.570298252 -0.873421895 85 86 87 88 89 90 -0.876545538 -0.879669182 -0.682792825 -0.585916468 -0.789040111 -1.092163754 91 92 93 94 95 96 -1.295287397 -1.698411040 -1.701534683 -1.104658326 -1.007781969 -1.110905612 > postscript(file="/var/www/html/rcomp/tmp/667nq1227789088.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 = 96 Frequency = 1 lag(myerror, k = 1) myerror 0 -0.395344388 NA 1 -0.698468031 -0.395344388 2 -1.001591674 -0.698468031 3 -1.204715317 -1.001591674 4 -1.407838960 -1.204715317 5 -1.410962603 -1.407838960 6 -1.214086246 -1.410962603 7 -1.217209889 -1.214086246 8 -1.520333532 -1.217209889 9 -1.323457175 -1.520333532 10 -1.126580818 -1.323457175 11 -0.729704462 -1.126580818 12 -0.032828105 -0.729704462 13 -0.035951748 -0.032828105 14 0.060924609 -0.035951748 15 0.057800966 0.060924609 16 -0.145322677 0.057800966 17 -0.248446320 -0.145322677 18 -0.451569963 -0.248446320 19 -0.654693606 -0.451569963 20 -0.757817249 -0.654693606 21 -0.060940892 -0.757817249 22 0.035935465 -0.060940892 23 0.232811822 0.035935465 24 0.429688178 0.232811822 25 0.526564535 0.429688178 26 0.623440892 0.526564535 27 0.720317249 0.623440892 28 0.617193606 0.720317249 29 0.414069963 0.617193606 30 0.310946320 0.414069963 31 0.007822677 0.310946320 32 0.004699034 0.007822677 33 0.601575391 0.004699034 34 0.698451748 0.601575391 35 0.795328105 0.698451748 36 0.792204462 0.795328105 37 0.789080818 0.792204462 38 0.985957175 0.789080818 39 1.282833532 0.985957175 40 1.179709889 1.282833532 41 0.676586246 1.179709889 42 -0.126537397 0.676586246 43 -0.429661040 -0.126537397 44 -0.132784683 -0.429661040 45 1.164091674 -0.132784683 46 1.660968031 1.164091674 47 1.657844388 1.660968031 48 0.935905612 1.657844388 49 0.432781969 0.935905612 50 0.529658326 0.432781969 51 0.726534683 0.529658326 52 0.823411040 0.726534683 53 0.820287397 0.823411040 54 0.417163754 0.820287397 55 0.314040111 0.417163754 56 0.210916468 0.314040111 57 0.807792825 0.210916468 58 0.904669182 0.807792825 59 1.001545538 0.904669182 60 0.698421895 1.001545538 61 0.595298252 0.698421895 62 0.692174609 0.595298252 63 0.889050966 0.692174609 64 0.885927323 0.889050966 65 0.782803680 0.885927323 66 0.679680037 0.782803680 67 0.476556394 0.679680037 68 0.273432751 0.476556394 69 0.370309108 0.273432751 70 0.267185465 0.370309108 71 0.264061822 0.267185465 72 0.060938178 0.264061822 73 0.057814535 0.060938178 74 0.054690892 0.057814535 75 0.151567249 0.054690892 76 0.148443606 0.151567249 77 0.045319963 0.148443606 78 0.142196320 0.045319963 79 -0.160927323 0.142196320 80 -0.664050966 -0.160927323 81 -0.367174609 -0.664050966 82 -0.570298252 -0.367174609 83 -0.873421895 -0.570298252 84 -0.876545538 -0.873421895 85 -0.879669182 -0.876545538 86 -0.682792825 -0.879669182 87 -0.585916468 -0.682792825 88 -0.789040111 -0.585916468 89 -1.092163754 -0.789040111 90 -1.295287397 -1.092163754 91 -1.698411040 -1.295287397 92 -1.701534683 -1.698411040 93 -1.104658326 -1.701534683 94 -1.007781969 -1.104658326 95 -1.110905612 -1.007781969 96 NA -1.110905612 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -0.698468031 -0.395344388 [2,] -1.001591674 -0.698468031 [3,] -1.204715317 -1.001591674 [4,] -1.407838960 -1.204715317 [5,] -1.410962603 -1.407838960 [6,] -1.214086246 -1.410962603 [7,] -1.217209889 -1.214086246 [8,] -1.520333532 -1.217209889 [9,] -1.323457175 -1.520333532 [10,] -1.126580818 -1.323457175 [11,] -0.729704462 -1.126580818 [12,] -0.032828105 -0.729704462 [13,] -0.035951748 -0.032828105 [14,] 0.060924609 -0.035951748 [15,] 0.057800966 0.060924609 [16,] -0.145322677 0.057800966 [17,] -0.248446320 -0.145322677 [18,] -0.451569963 -0.248446320 [19,] -0.654693606 -0.451569963 [20,] -0.757817249 -0.654693606 [21,] -0.060940892 -0.757817249 [22,] 0.035935465 -0.060940892 [23,] 0.232811822 0.035935465 [24,] 0.429688178 0.232811822 [25,] 0.526564535 0.429688178 [26,] 0.623440892 0.526564535 [27,] 0.720317249 0.623440892 [28,] 0.617193606 0.720317249 [29,] 0.414069963 0.617193606 [30,] 0.310946320 0.414069963 [31,] 0.007822677 0.310946320 [32,] 0.004699034 0.007822677 [33,] 0.601575391 0.004699034 [34,] 0.698451748 0.601575391 [35,] 0.795328105 0.698451748 [36,] 0.792204462 0.795328105 [37,] 0.789080818 0.792204462 [38,] 0.985957175 0.789080818 [39,] 1.282833532 0.985957175 [40,] 1.179709889 1.282833532 [41,] 0.676586246 1.179709889 [42,] -0.126537397 0.676586246 [43,] -0.429661040 -0.126537397 [44,] -0.132784683 -0.429661040 [45,] 1.164091674 -0.132784683 [46,] 1.660968031 1.164091674 [47,] 1.657844388 1.660968031 [48,] 0.935905612 1.657844388 [49,] 0.432781969 0.935905612 [50,] 0.529658326 0.432781969 [51,] 0.726534683 0.529658326 [52,] 0.823411040 0.726534683 [53,] 0.820287397 0.823411040 [54,] 0.417163754 0.820287397 [55,] 0.314040111 0.417163754 [56,] 0.210916468 0.314040111 [57,] 0.807792825 0.210916468 [58,] 0.904669182 0.807792825 [59,] 1.001545538 0.904669182 [60,] 0.698421895 1.001545538 [61,] 0.595298252 0.698421895 [62,] 0.692174609 0.595298252 [63,] 0.889050966 0.692174609 [64,] 0.885927323 0.889050966 [65,] 0.782803680 0.885927323 [66,] 0.679680037 0.782803680 [67,] 0.476556394 0.679680037 [68,] 0.273432751 0.476556394 [69,] 0.370309108 0.273432751 [70,] 0.267185465 0.370309108 [71,] 0.264061822 0.267185465 [72,] 0.060938178 0.264061822 [73,] 0.057814535 0.060938178 [74,] 0.054690892 0.057814535 [75,] 0.151567249 0.054690892 [76,] 0.148443606 0.151567249 [77,] 0.045319963 0.148443606 [78,] 0.142196320 0.045319963 [79,] -0.160927323 0.142196320 [80,] -0.664050966 -0.160927323 [81,] -0.367174609 -0.664050966 [82,] -0.570298252 -0.367174609 [83,] -0.873421895 -0.570298252 [84,] -0.876545538 -0.873421895 [85,] -0.879669182 -0.876545538 [86,] -0.682792825 -0.879669182 [87,] -0.585916468 -0.682792825 [88,] -0.789040111 -0.585916468 [89,] -1.092163754 -0.789040111 [90,] -1.295287397 -1.092163754 [91,] -1.698411040 -1.295287397 [92,] -1.701534683 -1.698411040 [93,] -1.104658326 -1.701534683 [94,] -1.007781969 -1.104658326 [95,] -1.110905612 -1.007781969 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -0.698468031 -0.395344388 2 -1.001591674 -0.698468031 3 -1.204715317 -1.001591674 4 -1.407838960 -1.204715317 5 -1.410962603 -1.407838960 6 -1.214086246 -1.410962603 7 -1.217209889 -1.214086246 8 -1.520333532 -1.217209889 9 -1.323457175 -1.520333532 10 -1.126580818 -1.323457175 11 -0.729704462 -1.126580818 12 -0.032828105 -0.729704462 13 -0.035951748 -0.032828105 14 0.060924609 -0.035951748 15 0.057800966 0.060924609 16 -0.145322677 0.057800966 17 -0.248446320 -0.145322677 18 -0.451569963 -0.248446320 19 -0.654693606 -0.451569963 20 -0.757817249 -0.654693606 21 -0.060940892 -0.757817249 22 0.035935465 -0.060940892 23 0.232811822 0.035935465 24 0.429688178 0.232811822 25 0.526564535 0.429688178 26 0.623440892 0.526564535 27 0.720317249 0.623440892 28 0.617193606 0.720317249 29 0.414069963 0.617193606 30 0.310946320 0.414069963 31 0.007822677 0.310946320 32 0.004699034 0.007822677 33 0.601575391 0.004699034 34 0.698451748 0.601575391 35 0.795328105 0.698451748 36 0.792204462 0.795328105 37 0.789080818 0.792204462 38 0.985957175 0.789080818 39 1.282833532 0.985957175 40 1.179709889 1.282833532 41 0.676586246 1.179709889 42 -0.126537397 0.676586246 43 -0.429661040 -0.126537397 44 -0.132784683 -0.429661040 45 1.164091674 -0.132784683 46 1.660968031 1.164091674 47 1.657844388 1.660968031 48 0.935905612 1.657844388 49 0.432781969 0.935905612 50 0.529658326 0.432781969 51 0.726534683 0.529658326 52 0.823411040 0.726534683 53 0.820287397 0.823411040 54 0.417163754 0.820287397 55 0.314040111 0.417163754 56 0.210916468 0.314040111 57 0.807792825 0.210916468 58 0.904669182 0.807792825 59 1.001545538 0.904669182 60 0.698421895 1.001545538 61 0.595298252 0.698421895 62 0.692174609 0.595298252 63 0.889050966 0.692174609 64 0.885927323 0.889050966 65 0.782803680 0.885927323 66 0.679680037 0.782803680 67 0.476556394 0.679680037 68 0.273432751 0.476556394 69 0.370309108 0.273432751 70 0.267185465 0.370309108 71 0.264061822 0.267185465 72 0.060938178 0.264061822 73 0.057814535 0.060938178 74 0.054690892 0.057814535 75 0.151567249 0.054690892 76 0.148443606 0.151567249 77 0.045319963 0.148443606 78 0.142196320 0.045319963 79 -0.160927323 0.142196320 80 -0.664050966 -0.160927323 81 -0.367174609 -0.664050966 82 -0.570298252 -0.367174609 83 -0.873421895 -0.570298252 84 -0.876545538 -0.873421895 85 -0.879669182 -0.876545538 86 -0.682792825 -0.879669182 87 -0.585916468 -0.682792825 88 -0.789040111 -0.585916468 89 -1.092163754 -0.789040111 90 -1.295287397 -1.092163754 91 -1.698411040 -1.295287397 92 -1.701534683 -1.698411040 93 -1.104658326 -1.701534683 94 -1.007781969 -1.104658326 95 -1.110905612 -1.007781969 > 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/7n1sb1227789088.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/8twf61227789088.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/9o35n1227789088.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/10el311227789088.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/11dx731227789088.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/12ybta1227789088.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/134osr1227789088.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/14c3si1227789088.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/15ll1r1227789088.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/167w5u1227789088.tab") + } > > system("convert tmp/1vkea1227789088.ps tmp/1vkea1227789088.png") > system("convert tmp/21ryu1227789088.ps tmp/21ryu1227789088.png") > system("convert tmp/3ge9q1227789088.ps tmp/3ge9q1227789088.png") > system("convert tmp/4fwbd1227789088.ps tmp/4fwbd1227789088.png") > system("convert tmp/5dzcs1227789088.ps tmp/5dzcs1227789088.png") > system("convert tmp/667nq1227789088.ps tmp/667nq1227789088.png") > system("convert tmp/7n1sb1227789088.ps tmp/7n1sb1227789088.png") > system("convert tmp/8twf61227789088.ps tmp/8twf61227789088.png") > system("convert tmp/9o35n1227789088.ps tmp/9o35n1227789088.png") > system("convert tmp/10el311227789088.ps tmp/10el311227789088.png") > > > proc.time() user system elapsed 2.842 1.601 3.244