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(14.2,-0.8,13.5,-0.2,11.9,0.2,14.6,1,15.6,0,14.1,-0.2,14.9,1,14.2,0.4,14.6,1,17.2,1.7,15.4,3.1,14.3,3.3,17.5,3.1,14.5,3.5,14.4,6,16.6,5.7,16.7,4.7,16.6,4.2,16.9,3.6,15.7,4.4,16.4,2.5,18.4,-0.6,16.9,-1.9,16.5,-1.9,18.3,0.7,15.1,-0.9,15.7,-1.7,18.1,-3.1,16.8,-2.1,18.9,0.2,19,1.2,18.1,3.8,17.8,4,21.5,6.6,17.1,5.3,18.7,7.6,19,4.7,16.4,6.6,16.9,4.4,18.6,4.6,19.3,6,19.4,4.8,17.6,4,18.6,2.7,18.1,3,20.4,4.1,18.1,4,19.6,2.7,19.9,2.6,19.2,3.1,17.8,4.4,19.2,3,22,2,21.1,1.3,19.5,1.5,22.2,1.3,20.9,3.2,22.2,1.8,23.5,3.3,21.5,1,24.3,2.4,22.8,0.4,20.3,-0.1,23.7,1.3,23.3,-1.1,19.6,-4.4,18,-7.5,17.3,-12.2,16.8,-14.5,18.2,-16,16.5,-16.7,16,-16.3,18.4,-16.9),dim=c(2,73),dimnames=list(c('Y','X'),1:73)) > y <- array(NA,dim=c(2,73),dimnames=list(c('Y','X'),1:73)) > 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 = '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 1 14.2 -0.8 1 0 0 0 0 0 0 0 0 0 0 2 13.5 -0.2 0 1 0 0 0 0 0 0 0 0 0 3 11.9 0.2 0 0 1 0 0 0 0 0 0 0 0 4 14.6 1.0 0 0 0 1 0 0 0 0 0 0 0 5 15.6 0.0 0 0 0 0 1 0 0 0 0 0 0 6 14.1 -0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1 0 0 70 18.2 -16.0 0 0 0 0 0 0 0 0 0 1 0 71 16.5 -16.7 0 0 0 0 0 0 0 0 0 0 1 72 16.0 -16.3 0 0 0 0 0 0 0 0 0 0 0 73 18.4 -16.9 1 0 0 0 0 0 0 0 0 0 0 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X M1 M2 M3 M4 17.80625 0.06597 1.03333 -1.02701 -1.78470 0.52299 M5 M6 M7 M8 M9 M10 1.03931 0.41222 -0.19802 -0.12731 -0.36412 1.87014 M11 0.14230 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -4.58681 -1.89552 -0.03268 1.31262 5.99438 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 17.80625 1.11264 16.004 <2e-16 *** X 0.06597 0.05918 1.115 0.269 M1 1.03333 1.51550 0.682 0.498 M2 -1.02701 1.58070 -0.650 0.518 M3 -1.78470 1.58141 -1.129 0.264 M4 0.52299 1.58070 0.331 0.742 M5 1.03931 1.57801 0.659 0.513 M6 0.41222 1.57550 0.262 0.794 M7 -0.19802 1.57440 -0.126 0.900 M8 -0.12731 1.57320 -0.081 0.936 M9 -0.36412 1.57295 -0.231 0.818 M10 1.87014 1.57275 1.189 0.239 M11 0.14230 1.57272 0.090 0.928 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 2.724 on 60 degrees of freedom Multiple R-squared: 0.1326, Adjusted R-squared: -0.04088 F-statistic: 0.7644 on 12 and 60 DF, p-value: 0.6836 > 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.034408847 0.068817695 0.965591153 [2,] 0.016516035 0.033032069 0.983483965 [3,] 0.005687145 0.011374290 0.994312855 [4,] 0.002225177 0.004450354 0.997774823 [5,] 0.000731527 0.001463054 0.999268473 [6,] 0.000440695 0.000881390 0.999559305 [7,] 0.001370594 0.002741189 0.998629406 [8,] 0.009199902 0.018399803 0.990800098 [9,] 0.028877448 0.057754895 0.971122552 [10,] 0.039065524 0.078131049 0.960934476 [11,] 0.039060263 0.078120526 0.960939737 [12,] 0.069326819 0.138653638 0.930673181 [13,] 0.086092181 0.172184362 0.913907819 [14,] 0.082785647 0.165571293 0.917214353 [15,] 0.120085877 0.240171755 0.879914123 [16,] 0.132632838 0.265265677 0.867367162 [17,] 0.154552375 0.309104749 0.845447625 [18,] 0.141687525 0.283375050 0.858312475 [19,] 0.155586350 0.311172701 0.844413650 [20,] 0.138989183 0.277978366 0.861010817 [21,] 0.131445089 0.262890177 0.868554911 [22,] 0.129933025 0.259866050 0.870066975 [23,] 0.183272214 0.366544429 0.816727786 [24,] 0.187517462 0.375034924 0.812482538 [25,] 0.192092941 0.384185882 0.807907059 [26,] 0.251973407 0.503946814 0.748026593 [27,] 0.238366253 0.476732505 0.761633747 [28,] 0.210449123 0.420898245 0.789550877 [29,] 0.232712776 0.465425553 0.767287224 [30,] 0.224573157 0.449146313 0.775426843 [31,] 0.196250344 0.392500687 0.803749656 [32,] 0.293876729 0.587753458 0.706123271 [33,] 0.297357923 0.594715846 0.702642077 [34,] 0.451506582 0.903013164 0.548493418 [35,] 0.677119431 0.645761137 0.322880569 [36,] 0.797704234 0.404591531 0.202295766 [37,] 0.987927838 0.024144325 0.012072162 [38,] 0.996466464 0.007067072 0.003533536 [39,] 0.991508895 0.016982210 0.008491105 [40,] 0.986133396 0.027733208 0.013866604 [41,] 0.977369920 0.045260159 0.022630080 [42,] 0.959617900 0.080764201 0.040382100 > postscript(file="/var/www/html/rcomp/tmp/1o25j1258723296.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/2vt6n1258723296.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/39trc1258723296.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/4lnhe1258723296.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/5vfgc1258723296.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 = 73 Frequency = 1 1 2 3 4 5 6 -4.58680690 -3.26604540 -4.13473563 -3.79520402 -3.24555460 -4.10527414 7 8 9 10 11 12 -2.77418736 -3.50532184 -2.90809425 -2.58852758 -2.75304310 -3.72393218 13 14 15 16 17 18 -1.54407241 -2.51011781 -2.01733563 -2.10524195 -2.45559253 -1.89552241 19 20 21 22 23 24 -0.94569770 -2.26918390 -1.20704253 -1.23680690 -0.92321552 -1.18091150 25 26 27 28 29 30 -0.58575517 -1.61986954 -0.20940115 -0.02474541 -1.90702702 0.66833965 31 32 33 34 35 36 1.31261954 0.17039541 0.09400920 1.38824139 -1.19816724 0.39241610 37 38 39 40 41 42 -0.14961724 -0.81461092 0.58820920 -0.03267988 0.05865230 0.86489828 43 44 45 46 47 48 -0.27208390 0.74295747 0.45997472 0.45315518 -0.11241206 1.61564713 49 50 51 52 53 54 0.88891035 2.21626839 1.48820920 0.67286494 3.02251437 2.79577759 55 56 57 58 59 60 1.79282989 4.43530920 3.24678161 2.40487586 5.33376380 3.62778851 61 62 63 64 65 66 5.30210345 5.99437529 4.28505402 5.28500632 4.52700747 1.67178103 67 68 69 70 71 72 0.88651953 0.42584367 0.31437125 -0.42093795 -0.34692588 -0.73100806 73 0.67523791 > postscript(file="/var/www/html/rcomp/tmp/6j3uw1258723296.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 = 73 Frequency = 1 lag(myerror, k = 1) myerror 0 -4.58680690 NA 1 -3.26604540 -4.58680690 2 -4.13473563 -3.26604540 3 -3.79520402 -4.13473563 4 -3.24555460 -3.79520402 5 -4.10527414 -3.24555460 6 -2.77418736 -4.10527414 7 -3.50532184 -2.77418736 8 -2.90809425 -3.50532184 9 -2.58852758 -2.90809425 10 -2.75304310 -2.58852758 11 -3.72393218 -2.75304310 12 -1.54407241 -3.72393218 13 -2.51011781 -1.54407241 14 -2.01733563 -2.51011781 15 -2.10524195 -2.01733563 16 -2.45559253 -2.10524195 17 -1.89552241 -2.45559253 18 -0.94569770 -1.89552241 19 -2.26918390 -0.94569770 20 -1.20704253 -2.26918390 21 -1.23680690 -1.20704253 22 -0.92321552 -1.23680690 23 -1.18091150 -0.92321552 24 -0.58575517 -1.18091150 25 -1.61986954 -0.58575517 26 -0.20940115 -1.61986954 27 -0.02474541 -0.20940115 28 -1.90702702 -0.02474541 29 0.66833965 -1.90702702 30 1.31261954 0.66833965 31 0.17039541 1.31261954 32 0.09400920 0.17039541 33 1.38824139 0.09400920 34 -1.19816724 1.38824139 35 0.39241610 -1.19816724 36 -0.14961724 0.39241610 37 -0.81461092 -0.14961724 38 0.58820920 -0.81461092 39 -0.03267988 0.58820920 40 0.05865230 -0.03267988 41 0.86489828 0.05865230 42 -0.27208390 0.86489828 43 0.74295747 -0.27208390 44 0.45997472 0.74295747 45 0.45315518 0.45997472 46 -0.11241206 0.45315518 47 1.61564713 -0.11241206 48 0.88891035 1.61564713 49 2.21626839 0.88891035 50 1.48820920 2.21626839 51 0.67286494 1.48820920 52 3.02251437 0.67286494 53 2.79577759 3.02251437 54 1.79282989 2.79577759 55 4.43530920 1.79282989 56 3.24678161 4.43530920 57 2.40487586 3.24678161 58 5.33376380 2.40487586 59 3.62778851 5.33376380 60 5.30210345 3.62778851 61 5.99437529 5.30210345 62 4.28505402 5.99437529 63 5.28500632 4.28505402 64 4.52700747 5.28500632 65 1.67178103 4.52700747 66 0.88651953 1.67178103 67 0.42584367 0.88651953 68 0.31437125 0.42584367 69 -0.42093795 0.31437125 70 -0.34692588 -0.42093795 71 -0.73100806 -0.34692588 72 0.67523791 -0.73100806 73 NA 0.67523791 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -3.26604540 -4.58680690 [2,] -4.13473563 -3.26604540 [3,] -3.79520402 -4.13473563 [4,] -3.24555460 -3.79520402 [5,] -4.10527414 -3.24555460 [6,] -2.77418736 -4.10527414 [7,] -3.50532184 -2.77418736 [8,] -2.90809425 -3.50532184 [9,] -2.58852758 -2.90809425 [10,] -2.75304310 -2.58852758 [11,] -3.72393218 -2.75304310 [12,] -1.54407241 -3.72393218 [13,] -2.51011781 -1.54407241 [14,] -2.01733563 -2.51011781 [15,] -2.10524195 -2.01733563 [16,] -2.45559253 -2.10524195 [17,] -1.89552241 -2.45559253 [18,] -0.94569770 -1.89552241 [19,] -2.26918390 -0.94569770 [20,] -1.20704253 -2.26918390 [21,] -1.23680690 -1.20704253 [22,] -0.92321552 -1.23680690 [23,] -1.18091150 -0.92321552 [24,] -0.58575517 -1.18091150 [25,] -1.61986954 -0.58575517 [26,] -0.20940115 -1.61986954 [27,] -0.02474541 -0.20940115 [28,] -1.90702702 -0.02474541 [29,] 0.66833965 -1.90702702 [30,] 1.31261954 0.66833965 [31,] 0.17039541 1.31261954 [32,] 0.09400920 0.17039541 [33,] 1.38824139 0.09400920 [34,] -1.19816724 1.38824139 [35,] 0.39241610 -1.19816724 [36,] -0.14961724 0.39241610 [37,] -0.81461092 -0.14961724 [38,] 0.58820920 -0.81461092 [39,] -0.03267988 0.58820920 [40,] 0.05865230 -0.03267988 [41,] 0.86489828 0.05865230 [42,] -0.27208390 0.86489828 [43,] 0.74295747 -0.27208390 [44,] 0.45997472 0.74295747 [45,] 0.45315518 0.45997472 [46,] -0.11241206 0.45315518 [47,] 1.61564713 -0.11241206 [48,] 0.88891035 1.61564713 [49,] 2.21626839 0.88891035 [50,] 1.48820920 2.21626839 [51,] 0.67286494 1.48820920 [52,] 3.02251437 0.67286494 [53,] 2.79577759 3.02251437 [54,] 1.79282989 2.79577759 [55,] 4.43530920 1.79282989 [56,] 3.24678161 4.43530920 [57,] 2.40487586 3.24678161 [58,] 5.33376380 2.40487586 [59,] 3.62778851 5.33376380 [60,] 5.30210345 3.62778851 [61,] 5.99437529 5.30210345 [62,] 4.28505402 5.99437529 [63,] 5.28500632 4.28505402 [64,] 4.52700747 5.28500632 [65,] 1.67178103 4.52700747 [66,] 0.88651953 1.67178103 [67,] 0.42584367 0.88651953 [68,] 0.31437125 0.42584367 [69,] -0.42093795 0.31437125 [70,] -0.34692588 -0.42093795 [71,] -0.73100806 -0.34692588 [72,] 0.67523791 -0.73100806 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -3.26604540 -4.58680690 2 -4.13473563 -3.26604540 3 -3.79520402 -4.13473563 4 -3.24555460 -3.79520402 5 -4.10527414 -3.24555460 6 -2.77418736 -4.10527414 7 -3.50532184 -2.77418736 8 -2.90809425 -3.50532184 9 -2.58852758 -2.90809425 10 -2.75304310 -2.58852758 11 -3.72393218 -2.75304310 12 -1.54407241 -3.72393218 13 -2.51011781 -1.54407241 14 -2.01733563 -2.51011781 15 -2.10524195 -2.01733563 16 -2.45559253 -2.10524195 17 -1.89552241 -2.45559253 18 -0.94569770 -1.89552241 19 -2.26918390 -0.94569770 20 -1.20704253 -2.26918390 21 -1.23680690 -1.20704253 22 -0.92321552 -1.23680690 23 -1.18091150 -0.92321552 24 -0.58575517 -1.18091150 25 -1.61986954 -0.58575517 26 -0.20940115 -1.61986954 27 -0.02474541 -0.20940115 28 -1.90702702 -0.02474541 29 0.66833965 -1.90702702 30 1.31261954 0.66833965 31 0.17039541 1.31261954 32 0.09400920 0.17039541 33 1.38824139 0.09400920 34 -1.19816724 1.38824139 35 0.39241610 -1.19816724 36 -0.14961724 0.39241610 37 -0.81461092 -0.14961724 38 0.58820920 -0.81461092 39 -0.03267988 0.58820920 40 0.05865230 -0.03267988 41 0.86489828 0.05865230 42 -0.27208390 0.86489828 43 0.74295747 -0.27208390 44 0.45997472 0.74295747 45 0.45315518 0.45997472 46 -0.11241206 0.45315518 47 1.61564713 -0.11241206 48 0.88891035 1.61564713 49 2.21626839 0.88891035 50 1.48820920 2.21626839 51 0.67286494 1.48820920 52 3.02251437 0.67286494 53 2.79577759 3.02251437 54 1.79282989 2.79577759 55 4.43530920 1.79282989 56 3.24678161 4.43530920 57 2.40487586 3.24678161 58 5.33376380 2.40487586 59 3.62778851 5.33376380 60 5.30210345 3.62778851 61 5.99437529 5.30210345 62 4.28505402 5.99437529 63 5.28500632 4.28505402 64 4.52700747 5.28500632 65 1.67178103 4.52700747 66 0.88651953 1.67178103 67 0.42584367 0.88651953 68 0.31437125 0.42584367 69 -0.42093795 0.31437125 70 -0.34692588 -0.42093795 71 -0.73100806 -0.34692588 72 0.67523791 -0.73100806 > 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/7til51258723296.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/85w291258723296.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/9fv471258723296.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/10v3ru1258723296.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/113xf11258723296.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/126d0t1258723296.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/13pogc1258723296.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/1411nm1258723296.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/15ycan1258723296.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/16ai401258723296.tab") + } > > system("convert tmp/1o25j1258723296.ps tmp/1o25j1258723296.png") > system("convert tmp/2vt6n1258723296.ps tmp/2vt6n1258723296.png") > system("convert tmp/39trc1258723296.ps tmp/39trc1258723296.png") > system("convert tmp/4lnhe1258723296.ps tmp/4lnhe1258723296.png") > system("convert tmp/5vfgc1258723296.ps tmp/5vfgc1258723296.png") > system("convert tmp/6j3uw1258723296.ps tmp/6j3uw1258723296.png") > system("convert tmp/7til51258723296.ps tmp/7til51258723296.png") > system("convert tmp/85w291258723296.ps tmp/85w291258723296.png") > system("convert tmp/9fv471258723296.ps tmp/9fv471258723296.png") > system("convert tmp/10v3ru1258723296.ps tmp/10v3ru1258723296.png") > > > proc.time() user system elapsed 2.577 1.579 2.951