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(9487,1169,8700,2154,9627,2249,8947,2687,9283,4359,8829,5382,9947,4459,9628,6398,9318,4596,9605,3024,8640,1887,9214,2070,9567,1351,8547,2218,9185,2461,9470,3028,9123,4784,9278,4975,10170,4607,9434,6249,9655,4809,9429,3157,8739,1910,9552,2228,9784,1594,9089,2467,9763,2222,9330,3607,9144,4685,9895,4962,10404,5770,10195,5480,9987,5000,9789,3228,9437,1993,10096,2288,9776,1580,9106,2111,10258,2192,9766,3601,9826,4665,9957,4876,10036,5813,10508,5589,10146,5331,10166,3075,9365,2002,9968,2306,10123,1507,9144,1992,10447,2487,9699,3490,10451,4647,10192,5594,10404,5611,10597,5788,10633,6204,10727,3013,9784,1931,9667,2549,10297,1504,9426,2090,10274,2702,9598,2939,10400,4500,9985,6208,10761,6415,11081,5657,10297,5964,10751,3163,9760,1997,10133,2422),dim=c(2,72),dimnames=list(c('Y','X'),1:72)) > y <- array(NA,dim=c(2,72),dimnames=list(c('Y','X'),1:72)) > 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 = 'Include Monthly Dummies' > par1 = '1' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > library(lattice) > library(lmtest) Loading required package: zoo Attaching package: 'zoo' The following object(s) are masked from package:base : as.Date.numeric > n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test > par1 <- as.numeric(par1) > x <- t(y) > k <- length(x[1,]) > n <- length(x[,1]) > x1 <- cbind(x[,par1], x[,1:k!=par1]) > mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1]) > colnames(x1) <- mycolnames #colnames(x)[par1] > x <- x1 > if (par3 == 'First Differences'){ + x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep=''))) + for (i in 1:n-1) { + for (j in 1:k) { + x2[i,j] <- x[i+1,j] - x[i,j] + } + } + x <- x2 + } > if (par2 == 'Include Monthly Dummies'){ + x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep =''))) + for (i in 1:11){ + x2[seq(i,n,12),i] <- 1 + } + x <- cbind(x, x2) + } > if (par2 == 'Include Quarterly Dummies'){ + x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep =''))) + for (i in 1:3){ + x2[seq(i,n,4),i] <- 1 + } + x <- cbind(x, x2) + } > k <- length(x[1,]) > if (par3 == 'Linear Trend'){ + x <- cbind(x, c(1:n)) + colnames(x)[k+1] <- 't' + } > x Y X M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 9487 1169 1 0 0 0 0 0 0 0 0 0 0 1 2 8700 2154 0 1 0 0 0 0 0 0 0 0 0 2 3 9627 2249 0 0 1 0 0 0 0 0 0 0 0 3 4 8947 2687 0 0 0 1 0 0 0 0 0 0 0 4 5 9283 4359 0 0 0 0 1 0 0 0 0 0 0 5 6 8829 5382 0 0 0 0 0 1 0 0 0 0 0 6 7 9947 4459 0 0 0 0 0 0 1 0 0 0 0 7 8 9628 6398 0 0 0 0 0 0 0 1 0 0 0 8 9 9318 4596 0 0 0 0 0 0 0 0 1 0 0 9 10 9605 3024 0 0 0 0 0 0 0 0 0 1 0 10 11 8640 1887 0 0 0 0 0 0 0 0 0 0 1 11 12 9214 2070 0 0 0 0 0 0 0 0 0 0 0 12 13 9567 1351 1 0 0 0 0 0 0 0 0 0 0 13 14 8547 2218 0 1 0 0 0 0 0 0 0 0 0 14 15 9185 2461 0 0 1 0 0 0 0 0 0 0 0 15 16 9470 3028 0 0 0 1 0 0 0 0 0 0 0 16 17 9123 4784 0 0 0 0 1 0 0 0 0 0 0 17 18 9278 4975 0 0 0 0 0 1 0 0 0 0 0 18 19 10170 4607 0 0 0 0 0 0 1 0 0 0 0 19 20 9434 6249 0 0 0 0 0 0 0 1 0 0 0 20 21 9655 4809 0 0 0 0 0 0 0 0 1 0 0 21 22 9429 3157 0 0 0 0 0 0 0 0 0 1 0 22 23 8739 1910 0 0 0 0 0 0 0 0 0 0 1 23 24 9552 2228 0 0 0 0 0 0 0 0 0 0 0 24 25 9784 1594 1 0 0 0 0 0 0 0 0 0 0 25 26 9089 2467 0 1 0 0 0 0 0 0 0 0 0 26 27 9763 2222 0 0 1 0 0 0 0 0 0 0 0 27 28 9330 3607 0 0 0 1 0 0 0 0 0 0 0 28 29 9144 4685 0 0 0 0 1 0 0 0 0 0 0 29 30 9895 4962 0 0 0 0 0 1 0 0 0 0 0 30 31 10404 5770 0 0 0 0 0 0 1 0 0 0 0 31 32 10195 5480 0 0 0 0 0 0 0 1 0 0 0 32 33 9987 5000 0 0 0 0 0 0 0 0 1 0 0 33 34 9789 3228 0 0 0 0 0 0 0 0 0 1 0 34 35 9437 1993 0 0 0 0 0 0 0 0 0 0 1 35 36 10096 2288 0 0 0 0 0 0 0 0 0 0 0 36 37 9776 1580 1 0 0 0 0 0 0 0 0 0 0 37 38 9106 2111 0 1 0 0 0 0 0 0 0 0 0 38 39 10258 2192 0 0 1 0 0 0 0 0 0 0 0 39 40 9766 3601 0 0 0 1 0 0 0 0 0 0 0 40 41 9826 4665 0 0 0 0 1 0 0 0 0 0 0 41 42 9957 4876 0 0 0 0 0 1 0 0 0 0 0 42 43 10036 5813 0 0 0 0 0 0 1 0 0 0 0 43 44 10508 5589 0 0 0 0 0 0 0 1 0 0 0 44 45 10146 5331 0 0 0 0 0 0 0 0 1 0 0 45 46 10166 3075 0 0 0 0 0 0 0 0 0 1 0 46 47 9365 2002 0 0 0 0 0 0 0 0 0 0 1 47 48 9968 2306 0 0 0 0 0 0 0 0 0 0 0 48 49 10123 1507 1 0 0 0 0 0 0 0 0 0 0 49 50 9144 1992 0 1 0 0 0 0 0 0 0 0 0 50 51 10447 2487 0 0 1 0 0 0 0 0 0 0 0 51 52 9699 3490 0 0 0 1 0 0 0 0 0 0 0 52 53 10451 4647 0 0 0 0 1 0 0 0 0 0 0 53 54 10192 5594 0 0 0 0 0 1 0 0 0 0 0 54 55 10404 5611 0 0 0 0 0 0 1 0 0 0 0 55 56 10597 5788 0 0 0 0 0 0 0 1 0 0 0 56 57 10633 6204 0 0 0 0 0 0 0 0 1 0 0 57 58 10727 3013 0 0 0 0 0 0 0 0 0 1 0 58 59 9784 1931 0 0 0 0 0 0 0 0 0 0 1 59 60 9667 2549 0 0 0 0 0 0 0 0 0 0 0 60 61 10297 1504 1 0 0 0 0 0 0 0 0 0 0 61 62 9426 2090 0 1 0 0 0 0 0 0 0 0 0 62 63 10274 2702 0 0 1 0 0 0 0 0 0 0 0 63 64 9598 2939 0 0 0 1 0 0 0 0 0 0 0 64 65 10400 4500 0 0 0 0 1 0 0 0 0 0 0 65 66 9985 6208 0 0 0 0 0 1 0 0 0 0 0 66 67 10761 6415 0 0 0 0 0 0 1 0 0 0 0 67 68 11081 5657 0 0 0 0 0 0 0 1 0 0 0 68 69 10297 5964 0 0 0 0 0 0 0 0 1 0 0 69 70 10751 3163 0 0 0 0 0 0 0 0 0 1 0 70 71 9760 1997 0 0 0 0 0 0 0 0 0 0 1 71 72 10133 2422 0 0 0 0 0 0 0 0 0 0 0 72 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X M1 M2 M3 M4 9399.8468 -0.1821 118.3606 -606.1771 337.4994 14.2390 M5 M6 M7 M8 M9 M10 483.0926 581.2988 1180.6730 1190.7571 838.5291 489.5081 M11 t -530.3400 18.8712 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -488.61 -153.06 11.29 125.70 448.79 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 9399.84684 210.24830 44.708 < 2e-16 *** X -0.18211 0.08818 -2.065 0.043380 * M1 118.36057 152.90451 0.774 0.442027 M2 -606.17714 136.37407 -4.445 4.02e-05 *** M3 337.49935 136.64086 2.470 0.016475 * M4 14.23901 160.64404 0.089 0.929676 M5 483.09262 247.38044 1.953 0.055670 . M6 581.29882 302.35653 1.923 0.059451 . M7 1180.67299 310.71470 3.800 0.000349 *** M8 1190.75709 343.37098 3.468 0.000995 *** M9 838.52910 299.43455 2.800 0.006923 ** M10 489.50809 153.38607 3.191 0.002287 ** M11 -530.33999 139.04537 -3.814 0.000334 *** t 18.87121 1.47966 12.754 < 2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 234.8 on 58 degrees of freedom Multiple R-squared: 0.8571, Adjusted R-squared: 0.8251 F-statistic: 26.76 on 13 and 58 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,] 0.7153409 0.5693181 0.2846591 [2,] 0.7000152 0.5999696 0.2999848 [3,] 0.5887669 0.8224662 0.4112331 [4,] 0.6269470 0.7461059 0.3730530 [5,] 0.5860488 0.8279025 0.4139512 [6,] 0.5651499 0.8697003 0.4348501 [7,] 0.5025828 0.9948344 0.4974172 [8,] 0.4578440 0.9156881 0.5421560 [9,] 0.3800396 0.7600792 0.6199604 [10,] 0.3871979 0.7743957 0.6128021 [11,] 0.3208439 0.6416878 0.6791561 [12,] 0.2399849 0.4799698 0.7600151 [13,] 0.4153268 0.8306536 0.5846732 [14,] 0.5601653 0.8796693 0.4398347 [15,] 0.5976891 0.8046219 0.4023109 [16,] 0.5617670 0.8764660 0.4382330 [17,] 0.5113268 0.9773465 0.4886732 [18,] 0.5600820 0.8798360 0.4399180 [19,] 0.5793767 0.8412465 0.4206233 [20,] 0.7094600 0.5810799 0.2905400 [21,] 0.7041835 0.5916330 0.2958165 [22,] 0.6445419 0.7109162 0.3554581 [23,] 0.6020056 0.7959889 0.3979944 [24,] 0.6276265 0.7447471 0.3723735 [25,] 0.6390554 0.7218892 0.3609446 [26,] 0.5696563 0.8606873 0.4303437 [27,] 0.6427699 0.7144601 0.3572301 [28,] 0.5696210 0.8607580 0.4303790 [29,] 0.4924631 0.9849263 0.5075369 [30,] 0.5658130 0.8683740 0.4341870 [31,] 0.5781598 0.8436803 0.4218402 [32,] 0.5163823 0.9672355 0.4836177 [33,] 0.4289270 0.8578539 0.5710730 [34,] 0.4240474 0.8480949 0.5759526 [35,] 0.3796785 0.7593570 0.6203215 [36,] 0.2961379 0.5922758 0.7038621 [37,] 0.2653762 0.5307524 0.7346238 [38,] 0.2886851 0.5773702 0.7113149 [39,] 0.1831978 0.3663957 0.8168022 > postscript(file="/var/www/html/rcomp/tmp/1g0tb1260911929.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/2xl301260911929.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/36lus1260911929.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/4r4de1260911929.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/5rpg01260911929.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 = 72 Frequency = 1 1 2 3 4 5 6 162.810974 260.858339 242.611334 -53.234232 99.533154 -285.243100 7 8 9 10 11 12 46.421615 51.582574 -253.227498 77.641352 -93.443768 -35.328373 13 14 15 16 17 18 49.500915 -106.941003 -387.235349 305.411606 -209.523552 -136.817460 19 20 21 22 23 24 69.919729 -396.006745 -103.892068 -300.592223 -216.709725 104.990866 25 26 27 28 29 30 84.299722 253.950480 -79.214798 44.400236 -433.007243 251.360530 31 32 33 34 35 36 289.262096 -1.505854 36.436886 -154.116777 269.951072 433.463074 37 38 39 40 41 42 -152.704400 -20.336140 183.867279 252.853014 18.895960 71.244303 43 44 45 46 47 48 -297.361609 104.889870 29.261599 -31.434546 -26.864462 82.286554 49 50 51 52 53 54 -45.453164 -230.462081 200.135939 -60.816027 414.163387 210.546579 55 56 57 58 59 60 -192.602894 3.675724 448.791322 291.819928 152.751000 -400.914639 61 62 63 64 65 66 -98.454048 -157.069596 -160.164405 -488.614597 109.938294 -111.090852 67 68 69 70 71 72 84.361063 237.364432 -157.370240 116.682267 -85.684117 -184.497481 > postscript(file="/var/www/html/rcomp/tmp/6uh3v1260911929.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 = 72 Frequency = 1 lag(myerror, k = 1) myerror 0 162.810974 NA 1 260.858339 162.810974 2 242.611334 260.858339 3 -53.234232 242.611334 4 99.533154 -53.234232 5 -285.243100 99.533154 6 46.421615 -285.243100 7 51.582574 46.421615 8 -253.227498 51.582574 9 77.641352 -253.227498 10 -93.443768 77.641352 11 -35.328373 -93.443768 12 49.500915 -35.328373 13 -106.941003 49.500915 14 -387.235349 -106.941003 15 305.411606 -387.235349 16 -209.523552 305.411606 17 -136.817460 -209.523552 18 69.919729 -136.817460 19 -396.006745 69.919729 20 -103.892068 -396.006745 21 -300.592223 -103.892068 22 -216.709725 -300.592223 23 104.990866 -216.709725 24 84.299722 104.990866 25 253.950480 84.299722 26 -79.214798 253.950480 27 44.400236 -79.214798 28 -433.007243 44.400236 29 251.360530 -433.007243 30 289.262096 251.360530 31 -1.505854 289.262096 32 36.436886 -1.505854 33 -154.116777 36.436886 34 269.951072 -154.116777 35 433.463074 269.951072 36 -152.704400 433.463074 37 -20.336140 -152.704400 38 183.867279 -20.336140 39 252.853014 183.867279 40 18.895960 252.853014 41 71.244303 18.895960 42 -297.361609 71.244303 43 104.889870 -297.361609 44 29.261599 104.889870 45 -31.434546 29.261599 46 -26.864462 -31.434546 47 82.286554 -26.864462 48 -45.453164 82.286554 49 -230.462081 -45.453164 50 200.135939 -230.462081 51 -60.816027 200.135939 52 414.163387 -60.816027 53 210.546579 414.163387 54 -192.602894 210.546579 55 3.675724 -192.602894 56 448.791322 3.675724 57 291.819928 448.791322 58 152.751000 291.819928 59 -400.914639 152.751000 60 -98.454048 -400.914639 61 -157.069596 -98.454048 62 -160.164405 -157.069596 63 -488.614597 -160.164405 64 109.938294 -488.614597 65 -111.090852 109.938294 66 84.361063 -111.090852 67 237.364432 84.361063 68 -157.370240 237.364432 69 116.682267 -157.370240 70 -85.684117 116.682267 71 -184.497481 -85.684117 72 NA -184.497481 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 260.858339 162.810974 [2,] 242.611334 260.858339 [3,] -53.234232 242.611334 [4,] 99.533154 -53.234232 [5,] -285.243100 99.533154 [6,] 46.421615 -285.243100 [7,] 51.582574 46.421615 [8,] -253.227498 51.582574 [9,] 77.641352 -253.227498 [10,] -93.443768 77.641352 [11,] -35.328373 -93.443768 [12,] 49.500915 -35.328373 [13,] -106.941003 49.500915 [14,] -387.235349 -106.941003 [15,] 305.411606 -387.235349 [16,] -209.523552 305.411606 [17,] -136.817460 -209.523552 [18,] 69.919729 -136.817460 [19,] -396.006745 69.919729 [20,] -103.892068 -396.006745 [21,] -300.592223 -103.892068 [22,] -216.709725 -300.592223 [23,] 104.990866 -216.709725 [24,] 84.299722 104.990866 [25,] 253.950480 84.299722 [26,] -79.214798 253.950480 [27,] 44.400236 -79.214798 [28,] -433.007243 44.400236 [29,] 251.360530 -433.007243 [30,] 289.262096 251.360530 [31,] -1.505854 289.262096 [32,] 36.436886 -1.505854 [33,] -154.116777 36.436886 [34,] 269.951072 -154.116777 [35,] 433.463074 269.951072 [36,] -152.704400 433.463074 [37,] -20.336140 -152.704400 [38,] 183.867279 -20.336140 [39,] 252.853014 183.867279 [40,] 18.895960 252.853014 [41,] 71.244303 18.895960 [42,] -297.361609 71.244303 [43,] 104.889870 -297.361609 [44,] 29.261599 104.889870 [45,] -31.434546 29.261599 [46,] -26.864462 -31.434546 [47,] 82.286554 -26.864462 [48,] -45.453164 82.286554 [49,] -230.462081 -45.453164 [50,] 200.135939 -230.462081 [51,] -60.816027 200.135939 [52,] 414.163387 -60.816027 [53,] 210.546579 414.163387 [54,] -192.602894 210.546579 [55,] 3.675724 -192.602894 [56,] 448.791322 3.675724 [57,] 291.819928 448.791322 [58,] 152.751000 291.819928 [59,] -400.914639 152.751000 [60,] -98.454048 -400.914639 [61,] -157.069596 -98.454048 [62,] -160.164405 -157.069596 [63,] -488.614597 -160.164405 [64,] 109.938294 -488.614597 [65,] -111.090852 109.938294 [66,] 84.361063 -111.090852 [67,] 237.364432 84.361063 [68,] -157.370240 237.364432 [69,] 116.682267 -157.370240 [70,] -85.684117 116.682267 [71,] -184.497481 -85.684117 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 260.858339 162.810974 2 242.611334 260.858339 3 -53.234232 242.611334 4 99.533154 -53.234232 5 -285.243100 99.533154 6 46.421615 -285.243100 7 51.582574 46.421615 8 -253.227498 51.582574 9 77.641352 -253.227498 10 -93.443768 77.641352 11 -35.328373 -93.443768 12 49.500915 -35.328373 13 -106.941003 49.500915 14 -387.235349 -106.941003 15 305.411606 -387.235349 16 -209.523552 305.411606 17 -136.817460 -209.523552 18 69.919729 -136.817460 19 -396.006745 69.919729 20 -103.892068 -396.006745 21 -300.592223 -103.892068 22 -216.709725 -300.592223 23 104.990866 -216.709725 24 84.299722 104.990866 25 253.950480 84.299722 26 -79.214798 253.950480 27 44.400236 -79.214798 28 -433.007243 44.400236 29 251.360530 -433.007243 30 289.262096 251.360530 31 -1.505854 289.262096 32 36.436886 -1.505854 33 -154.116777 36.436886 34 269.951072 -154.116777 35 433.463074 269.951072 36 -152.704400 433.463074 37 -20.336140 -152.704400 38 183.867279 -20.336140 39 252.853014 183.867279 40 18.895960 252.853014 41 71.244303 18.895960 42 -297.361609 71.244303 43 104.889870 -297.361609 44 29.261599 104.889870 45 -31.434546 29.261599 46 -26.864462 -31.434546 47 82.286554 -26.864462 48 -45.453164 82.286554 49 -230.462081 -45.453164 50 200.135939 -230.462081 51 -60.816027 200.135939 52 414.163387 -60.816027 53 210.546579 414.163387 54 -192.602894 210.546579 55 3.675724 -192.602894 56 448.791322 3.675724 57 291.819928 448.791322 58 152.751000 291.819928 59 -400.914639 152.751000 60 -98.454048 -400.914639 61 -157.069596 -98.454048 62 -160.164405 -157.069596 63 -488.614597 -160.164405 64 109.938294 -488.614597 65 -111.090852 109.938294 66 84.361063 -111.090852 67 237.364432 84.361063 68 -157.370240 237.364432 69 116.682267 -157.370240 70 -85.684117 116.682267 71 -184.497481 -85.684117 > 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/760tq1260911929.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/88hvw1260911929.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/9bzwi1260911929.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/10ri1r1260911929.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/11r66a1260911929.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/12267d1260911929.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/13ip6c1260911930.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/14s8s51260911930.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/15vbr41260911930.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/16f5j81260911930.tab") + } > > try(system("convert tmp/1g0tb1260911929.ps tmp/1g0tb1260911929.png",intern=TRUE)) character(0) > try(system("convert tmp/2xl301260911929.ps tmp/2xl301260911929.png",intern=TRUE)) character(0) > try(system("convert tmp/36lus1260911929.ps tmp/36lus1260911929.png",intern=TRUE)) character(0) > try(system("convert tmp/4r4de1260911929.ps tmp/4r4de1260911929.png",intern=TRUE)) character(0) > try(system("convert tmp/5rpg01260911929.ps tmp/5rpg01260911929.png",intern=TRUE)) character(0) > try(system("convert tmp/6uh3v1260911929.ps tmp/6uh3v1260911929.png",intern=TRUE)) character(0) > try(system("convert tmp/760tq1260911929.ps tmp/760tq1260911929.png",intern=TRUE)) character(0) > try(system("convert tmp/88hvw1260911929.ps tmp/88hvw1260911929.png",intern=TRUE)) character(0) > try(system("convert tmp/9bzwi1260911929.ps tmp/9bzwi1260911929.png",intern=TRUE)) character(0) > try(system("convert tmp/10ri1r1260911929.ps tmp/10ri1r1260911929.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.551 1.596 3.551