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(6.5 + ,15.8 + ,6.8 + ,7.5 + ,8 + ,8.2 + ,6.6 + ,15.8 + ,6.5 + ,6.8 + ,7.5 + ,8 + ,7.6 + ,23.2 + ,6.6 + ,6.5 + ,6.8 + ,7.5 + ,8 + ,23.2 + ,7.6 + ,6.6 + ,6.5 + ,6.8 + ,8.1 + ,23.2 + ,8 + ,7.6 + ,6.6 + ,6.5 + ,7.7 + ,20.9 + ,8.1 + ,8 + ,7.6 + ,6.6 + ,7.5 + ,20.9 + ,7.7 + ,8.1 + ,8 + ,7.6 + ,7.6 + ,20.9 + ,7.5 + ,7.7 + ,8.1 + ,8 + ,7.8 + ,19.8 + ,7.6 + ,7.5 + ,7.7 + ,8.1 + ,7.8 + ,19.8 + ,7.8 + ,7.6 + ,7.5 + ,7.7 + ,7.8 + ,19.8 + ,7.8 + ,7.8 + ,7.6 + ,7.5 + ,7.5 + ,20.6 + ,7.8 + ,7.8 + ,7.8 + ,7.6 + ,7.5 + ,20.6 + ,7.5 + ,7.8 + ,7.8 + ,7.8 + ,7.1 + ,20.6 + ,7.5 + ,7.5 + ,7.8 + ,7.8 + ,7.5 + ,21.1 + ,7.1 + ,7.5 + ,7.5 + ,7.8 + ,7.5 + ,21.1 + ,7.5 + ,7.1 + ,7.5 + ,7.5 + ,7.6 + ,21.1 + ,7.5 + ,7.5 + ,7.1 + ,7.5 + ,7.7 + ,22.4 + ,7.6 + ,7.5 + ,7.5 + ,7.1 + ,7.7 + ,22.4 + ,7.7 + ,7.6 + ,7.5 + ,7.5 + ,7.9 + ,22.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),1:65)) > 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 Y(t-1) Y(t-2) Y(t-3) Y(t-4) M1 M2 M3 M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 61 62 7.5 18.9 7.4 7.7 7.9 7.7 0 1 0 0 0 0 0 0 0 0 0 62 63 8.0 21.9 7.5 7.4 7.7 7.9 0 0 1 0 0 0 0 0 0 0 0 63 64 8.1 21.9 8.0 7.5 7.4 7.7 0 0 0 1 0 0 0 0 0 0 0 64 65 8.0 21.9 8.1 8.0 7.5 7.4 0 0 0 0 1 0 0 0 0 0 0 65 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X `Y(t-1)` `Y(t-2)` `Y(t-3)` `Y(t-4)` 0.043844 0.091191 1.102428 -0.486419 -0.188442 0.342364 M1 M2 M3 M4 M5 M6 -0.189339 -0.248582 0.003343 -0.535099 -0.353680 -0.188467 M7 M8 M9 M10 M11 t -0.259621 -0.046703 -0.013266 -0.113339 -0.086442 0.001888 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -0.42089 -0.08001 0.03089 0.08638 0.31174 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.043844 0.401943 0.109 0.913603 X 0.091191 0.021500 4.241 0.000103 *** `Y(t-1)` 1.102428 0.156443 7.047 6.94e-09 *** `Y(t-2)` -0.486419 0.229403 -2.120 0.039281 * `Y(t-3)` -0.188442 0.221128 -0.852 0.398434 `Y(t-4)` 0.342364 0.118904 2.879 0.005982 ** M1 -0.189339 0.106143 -1.784 0.080911 . M2 -0.248582 0.111660 -2.226 0.030829 * M3 0.003343 0.140870 0.024 0.981168 M4 -0.535099 0.126357 -4.235 0.000106 *** M5 -0.353680 0.143484 -2.465 0.017413 * M6 -0.188467 0.119133 -1.582 0.120358 M7 -0.259621 0.121117 -2.144 0.037274 * M8 -0.046703 0.121031 -0.386 0.701326 M9 -0.013266 0.117847 -0.113 0.910850 M10 -0.113339 0.117581 -0.964 0.340021 M11 -0.086442 0.111035 -0.779 0.440173 t 0.001888 0.001441 1.310 0.196590 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.1696 on 47 degrees of freedom Multiple R-squared: 0.9517, Adjusted R-squared: 0.9343 F-statistic: 54.5 on 17 and 47 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.4909449 0.9818899 0.5090551 [2,] 0.5095054 0.9809892 0.4904946 [3,] 0.4933360 0.9866719 0.5066640 [4,] 0.6925896 0.6148208 0.3074104 [5,] 0.6257946 0.7484107 0.3742054 [6,] 0.6244046 0.7511908 0.3755954 [7,] 0.8470317 0.3059366 0.1529683 [8,] 0.7885944 0.4228112 0.2114056 [9,] 0.7475941 0.5048119 0.2524059 [10,] 0.7332660 0.5334680 0.2667340 [11,] 0.6506798 0.6986404 0.3493202 [12,] 0.5580440 0.8839120 0.4419560 [13,] 0.4995484 0.9990967 0.5004516 [14,] 0.3936543 0.7873086 0.6063457 [15,] 0.3241271 0.6482543 0.6758729 [16,] 0.3421524 0.6843048 0.6578476 [17,] 0.2585591 0.5171183 0.7414409 [18,] 0.4562748 0.9125497 0.5437252 [19,] 0.4100851 0.8201701 0.5899149 [20,] 0.3977337 0.7954674 0.6022663 [21,] 0.3400304 0.6800607 0.6599696 [22,] 0.3019276 0.6038552 0.6980724 [23,] 0.1881431 0.3762862 0.8118569 [24,] 0.2682375 0.5364750 0.7317625 > postscript(file="/var/www/html/rcomp/tmp/126lx1258667848.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/2ukfb1258667848.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/3fvyl1258667848.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/44dm31258667848.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/591a81258667848.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 = 65 Frequency = 1 1 2 3 4 5 0.0545659900 0.1764081565 0.0308855639 0.0967764553 0.1804707870 6 7 8 9 10 0.0616400574 0.1535311062 -0.0534577193 -0.1056123632 -0.0800140127 11 12 13 14 15 0.0758021106 -0.3820283630 0.0676784769 -0.4208921244 0.0641381940 16 17 18 19 20 0.0678631344 0.1037469850 0.0201777712 -0.1091032778 -0.0564223683 21 22 23 24 25 0.0456377895 0.0863841834 0.0823287832 0.2033579820 0.0411805688 26 27 28 29 30 -0.2049723022 -0.2703011289 0.0588405923 0.1013385389 -0.0739605236 31 32 33 34 35 0.0038746460 -0.0023360024 0.1136192873 0.0005743116 -0.0847180072 36 37 38 39 40 0.1837141461 -0.0894418208 -0.1664110559 0.1010410570 -0.0596253363 41 42 43 44 45 -0.1936676967 0.1051742952 -0.0341546089 0.1091891891 -0.0014730518 46 47 48 49 50 -0.0726988420 -0.2647888906 -0.0759417388 -0.1550390029 0.3117421090 51 52 53 54 55 0.1598270518 -0.2241868236 -0.2234337845 -0.1130316001 -0.0141478655 56 57 58 59 60 0.0030269009 -0.0521716618 0.0657543597 0.1913760041 0.0708979737 61 62 63 64 65 0.0810557879 0.3041252169 -0.0855907378 0.0603319778 0.0315451702 > postscript(file="/var/www/html/rcomp/tmp/6q97j1258667848.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 = 65 Frequency = 1 lag(myerror, k = 1) myerror 0 0.0545659900 NA 1 0.1764081565 0.0545659900 2 0.0308855639 0.1764081565 3 0.0967764553 0.0308855639 4 0.1804707870 0.0967764553 5 0.0616400574 0.1804707870 6 0.1535311062 0.0616400574 7 -0.0534577193 0.1535311062 8 -0.1056123632 -0.0534577193 9 -0.0800140127 -0.1056123632 10 0.0758021106 -0.0800140127 11 -0.3820283630 0.0758021106 12 0.0676784769 -0.3820283630 13 -0.4208921244 0.0676784769 14 0.0641381940 -0.4208921244 15 0.0678631344 0.0641381940 16 0.1037469850 0.0678631344 17 0.0201777712 0.1037469850 18 -0.1091032778 0.0201777712 19 -0.0564223683 -0.1091032778 20 0.0456377895 -0.0564223683 21 0.0863841834 0.0456377895 22 0.0823287832 0.0863841834 23 0.2033579820 0.0823287832 24 0.0411805688 0.2033579820 25 -0.2049723022 0.0411805688 26 -0.2703011289 -0.2049723022 27 0.0588405923 -0.2703011289 28 0.1013385389 0.0588405923 29 -0.0739605236 0.1013385389 30 0.0038746460 -0.0739605236 31 -0.0023360024 0.0038746460 32 0.1136192873 -0.0023360024 33 0.0005743116 0.1136192873 34 -0.0847180072 0.0005743116 35 0.1837141461 -0.0847180072 36 -0.0894418208 0.1837141461 37 -0.1664110559 -0.0894418208 38 0.1010410570 -0.1664110559 39 -0.0596253363 0.1010410570 40 -0.1936676967 -0.0596253363 41 0.1051742952 -0.1936676967 42 -0.0341546089 0.1051742952 43 0.1091891891 -0.0341546089 44 -0.0014730518 0.1091891891 45 -0.0726988420 -0.0014730518 46 -0.2647888906 -0.0726988420 47 -0.0759417388 -0.2647888906 48 -0.1550390029 -0.0759417388 49 0.3117421090 -0.1550390029 50 0.1598270518 0.3117421090 51 -0.2241868236 0.1598270518 52 -0.2234337845 -0.2241868236 53 -0.1130316001 -0.2234337845 54 -0.0141478655 -0.1130316001 55 0.0030269009 -0.0141478655 56 -0.0521716618 0.0030269009 57 0.0657543597 -0.0521716618 58 0.1913760041 0.0657543597 59 0.0708979737 0.1913760041 60 0.0810557879 0.0708979737 61 0.3041252169 0.0810557879 62 -0.0855907378 0.3041252169 63 0.0603319778 -0.0855907378 64 0.0315451702 0.0603319778 65 NA 0.0315451702 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 0.1764081565 0.0545659900 [2,] 0.0308855639 0.1764081565 [3,] 0.0967764553 0.0308855639 [4,] 0.1804707870 0.0967764553 [5,] 0.0616400574 0.1804707870 [6,] 0.1535311062 0.0616400574 [7,] -0.0534577193 0.1535311062 [8,] -0.1056123632 -0.0534577193 [9,] -0.0800140127 -0.1056123632 [10,] 0.0758021106 -0.0800140127 [11,] -0.3820283630 0.0758021106 [12,] 0.0676784769 -0.3820283630 [13,] -0.4208921244 0.0676784769 [14,] 0.0641381940 -0.4208921244 [15,] 0.0678631344 0.0641381940 [16,] 0.1037469850 0.0678631344 [17,] 0.0201777712 0.1037469850 [18,] -0.1091032778 0.0201777712 [19,] -0.0564223683 -0.1091032778 [20,] 0.0456377895 -0.0564223683 [21,] 0.0863841834 0.0456377895 [22,] 0.0823287832 0.0863841834 [23,] 0.2033579820 0.0823287832 [24,] 0.0411805688 0.2033579820 [25,] -0.2049723022 0.0411805688 [26,] -0.2703011289 -0.2049723022 [27,] 0.0588405923 -0.2703011289 [28,] 0.1013385389 0.0588405923 [29,] -0.0739605236 0.1013385389 [30,] 0.0038746460 -0.0739605236 [31,] -0.0023360024 0.0038746460 [32,] 0.1136192873 -0.0023360024 [33,] 0.0005743116 0.1136192873 [34,] -0.0847180072 0.0005743116 [35,] 0.1837141461 -0.0847180072 [36,] -0.0894418208 0.1837141461 [37,] -0.1664110559 -0.0894418208 [38,] 0.1010410570 -0.1664110559 [39,] -0.0596253363 0.1010410570 [40,] -0.1936676967 -0.0596253363 [41,] 0.1051742952 -0.1936676967 [42,] -0.0341546089 0.1051742952 [43,] 0.1091891891 -0.0341546089 [44,] -0.0014730518 0.1091891891 [45,] -0.0726988420 -0.0014730518 [46,] -0.2647888906 -0.0726988420 [47,] -0.0759417388 -0.2647888906 [48,] -0.1550390029 -0.0759417388 [49,] 0.3117421090 -0.1550390029 [50,] 0.1598270518 0.3117421090 [51,] -0.2241868236 0.1598270518 [52,] -0.2234337845 -0.2241868236 [53,] -0.1130316001 -0.2234337845 [54,] -0.0141478655 -0.1130316001 [55,] 0.0030269009 -0.0141478655 [56,] -0.0521716618 0.0030269009 [57,] 0.0657543597 -0.0521716618 [58,] 0.1913760041 0.0657543597 [59,] 0.0708979737 0.1913760041 [60,] 0.0810557879 0.0708979737 [61,] 0.3041252169 0.0810557879 [62,] -0.0855907378 0.3041252169 [63,] 0.0603319778 -0.0855907378 [64,] 0.0315451702 0.0603319778 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 0.1764081565 0.0545659900 2 0.0308855639 0.1764081565 3 0.0967764553 0.0308855639 4 0.1804707870 0.0967764553 5 0.0616400574 0.1804707870 6 0.1535311062 0.0616400574 7 -0.0534577193 0.1535311062 8 -0.1056123632 -0.0534577193 9 -0.0800140127 -0.1056123632 10 0.0758021106 -0.0800140127 11 -0.3820283630 0.0758021106 12 0.0676784769 -0.3820283630 13 -0.4208921244 0.0676784769 14 0.0641381940 -0.4208921244 15 0.0678631344 0.0641381940 16 0.1037469850 0.0678631344 17 0.0201777712 0.1037469850 18 -0.1091032778 0.0201777712 19 -0.0564223683 -0.1091032778 20 0.0456377895 -0.0564223683 21 0.0863841834 0.0456377895 22 0.0823287832 0.0863841834 23 0.2033579820 0.0823287832 24 0.0411805688 0.2033579820 25 -0.2049723022 0.0411805688 26 -0.2703011289 -0.2049723022 27 0.0588405923 -0.2703011289 28 0.1013385389 0.0588405923 29 -0.0739605236 0.1013385389 30 0.0038746460 -0.0739605236 31 -0.0023360024 0.0038746460 32 0.1136192873 -0.0023360024 33 0.0005743116 0.1136192873 34 -0.0847180072 0.0005743116 35 0.1837141461 -0.0847180072 36 -0.0894418208 0.1837141461 37 -0.1664110559 -0.0894418208 38 0.1010410570 -0.1664110559 39 -0.0596253363 0.1010410570 40 -0.1936676967 -0.0596253363 41 0.1051742952 -0.1936676967 42 -0.0341546089 0.1051742952 43 0.1091891891 -0.0341546089 44 -0.0014730518 0.1091891891 45 -0.0726988420 -0.0014730518 46 -0.2647888906 -0.0726988420 47 -0.0759417388 -0.2647888906 48 -0.1550390029 -0.0759417388 49 0.3117421090 -0.1550390029 50 0.1598270518 0.3117421090 51 -0.2241868236 0.1598270518 52 -0.2234337845 -0.2241868236 53 -0.1130316001 -0.2234337845 54 -0.0141478655 -0.1130316001 55 0.0030269009 -0.0141478655 56 -0.0521716618 0.0030269009 57 0.0657543597 -0.0521716618 58 0.1913760041 0.0657543597 59 0.0708979737 0.1913760041 60 0.0810557879 0.0708979737 61 0.3041252169 0.0810557879 62 -0.0855907378 0.3041252169 63 0.0603319778 -0.0855907378 64 0.0315451702 0.0603319778 > 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/764os1258667848.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/8nue01258667848.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/9jk481258667848.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/10lxwz1258667848.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/11u8l21258667848.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/12cb801258667848.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/13dz7i1258667848.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/14se6r1258667848.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/154dui1258667848.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/1609ij1258667848.tab") + } > > system("convert tmp/126lx1258667848.ps tmp/126lx1258667848.png") > system("convert tmp/2ukfb1258667848.ps tmp/2ukfb1258667848.png") > system("convert tmp/3fvyl1258667848.ps tmp/3fvyl1258667848.png") > system("convert tmp/44dm31258667848.ps tmp/44dm31258667848.png") > system("convert tmp/591a81258667848.ps tmp/591a81258667848.png") > system("convert tmp/6q97j1258667848.ps tmp/6q97j1258667848.png") > system("convert tmp/764os1258667848.ps tmp/764os1258667848.png") > system("convert tmp/8nue01258667848.ps tmp/8nue01258667848.png") > system("convert tmp/9jk481258667848.ps tmp/9jk481258667848.png") > system("convert tmp/10lxwz1258667848.ps tmp/10lxwz1258667848.png") > > > proc.time() user system elapsed 2.373 1.586 2.941