R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) 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(-0.31664 + ,-0.061163 + ,-0.076389 + ,-0.034761 + ,0.147816 + ,-0.00596 + ,0.212195 + ,0.047547 + ,0.085082 + ,0.010674 + ,-0.112901 + ,-0.085962 + ,-0.050705 + ,-0.009859 + ,0.066562 + ,0.012191 + ,-0.329558 + ,-0.090791 + ,-0.053405 + ,-0.169425 + ,-0.138675 + ,-0.074849 + ,-0.07899 + ,0.007822 + ,0.056005 + ,-0.085657 + ,-0.009098 + ,-0.109931 + ,0.177024 + ,0.085405 + ,0.197013 + ,0.093925 + ,0.079313 + ,0.053081 + ,0.048745 + ,0.000196 + ,0.14716 + ,0.074142 + ,0.0295 + ,0.03356 + ,0.101896 + ,0.035723 + ,0.016995 + ,-0.019762 + ,0.060531 + ,0.057364 + ,0.054134 + ,0.017771 + ,-0.088591 + ,-0.036974 + ,0.06538 + ,0.028514 + ,0.14847 + ,0.058796 + ,0.111021 + ,0.014759 + ,-0.016125 + ,-0.081976 + ,-0.020827 + ,-0.053882 + ,0.022741 + ,0.068778 + ,-0.055005 + ,-0.047449 + ,0.167215 + ,0.087551 + ,0.060723 + ,0.036856 + ,0.03379 + ,-0.00229 + ,0.03667 + ,0.0653 + ,0.051959 + ,0.022646 + ,0.040935 + ,0.031957 + ,-0.013314 + ,-0.001047 + ,0.004656 + ,0.028495 + ,-0.006569 + ,-0.013501 + ,-0.03496 + ,-0.018258 + ,0.163285 + ,-0.021474 + ,-0.014469 + ,-0.056791 + ,-0.009121 + ,-0.071762 + ,0.061523 + ,0.107723 + ,-0.055783 + ,-0.005059 + ,0.059655 + ,0.008533 + ,0.127111 + ,0.043583 + ,0.188311 + ,0.040589 + ,0.105284 + ,0.031332 + ,-0.025969 + ,-0.007497 + ,-0.010702 + ,-0.062651 + ,0.010853 + ,0.039555 + ,0.045822 + ,0.012598 + ,0.093539 + ,0.019763 + ,0.002803 + ,0.024236 + ,-0.107607 + ,-0.019789 + ,-0.012413 + ,0.002847 + ,-0.090738 + ,0.007068) + ,dim=c(2 + ,60) + ,dimnames=list(c('Returns' + ,'S&P500') + ,1:60)) > y <- array(NA,dim=c(2,60),dimnames=list(c('Returns','S&P500'),1:60)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par3 = 'No Linear Trend' > par2 = 'Do not include Seasonal Dummies' > par1 = '1' > par3 <- 'No Linear Trend' > par2 <- 'Do not include Seasonal Dummies' > par1 <- '1' > #'GNU S' R Code compiled by R2WASP v. 1.2.327 () > #Author: root > #To cite this work: Wessa P., (2013), Multiple Regression (v1.0.29) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_multipleregression.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > # > library(lattice) > library(lmtest) Loading required package: zoo Attaching package: 'zoo' The following objects are masked from 'package:base': as.Date, 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 Returns S&P500 1 -0.316640 -0.061163 2 -0.076389 -0.034761 3 0.147816 -0.005960 4 0.212195 0.047547 5 0.085082 0.010674 6 -0.112901 -0.085962 7 -0.050705 -0.009859 8 0.066562 0.012191 9 -0.329558 -0.090791 10 -0.053405 -0.169425 11 -0.138675 -0.074849 12 -0.078990 0.007822 13 0.056005 -0.085657 14 -0.009098 -0.109931 15 0.177024 0.085405 16 0.197013 0.093925 17 0.079313 0.053081 18 0.048745 0.000196 19 0.147160 0.074142 20 0.029500 0.033560 21 0.101896 0.035723 22 0.016995 -0.019762 23 0.060531 0.057364 24 0.054134 0.017771 25 -0.088591 -0.036974 26 0.065380 0.028514 27 0.148470 0.058796 28 0.111021 0.014759 29 -0.016125 -0.081976 30 -0.020827 -0.053882 31 0.022741 0.068778 32 -0.055005 -0.047449 33 0.167215 0.087551 34 0.060723 0.036856 35 0.033790 -0.002290 36 0.036670 0.065300 37 0.051959 0.022646 38 0.040935 0.031957 39 -0.013314 -0.001047 40 0.004656 0.028495 41 -0.006569 -0.013501 42 -0.034960 -0.018258 43 0.163285 -0.021474 44 -0.014469 -0.056791 45 -0.009121 -0.071762 46 0.061523 0.107723 47 -0.055783 -0.005059 48 0.059655 0.008533 49 0.127111 0.043583 50 0.188311 0.040589 51 0.105284 0.031332 52 -0.025969 -0.007497 53 -0.010702 -0.062651 54 0.010853 0.039555 55 0.045822 0.012598 56 0.093539 0.019763 57 0.002803 0.024236 58 -0.107607 -0.019789 59 -0.012413 0.002847 60 -0.090738 0.007068 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) `S&P500` 0.0213 1.2091 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -0.263984 -0.048621 0.009451 0.048981 0.167953 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.02130 0.01058 2.012 0.0488 * `S&P500` 1.20910 0.19394 6.234 5.58e-08 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.08196 on 58 degrees of freedom Multiple R-squared: 0.4012, Adjusted R-squared: 0.3909 F-statistic: 38.87 on 1 and 58 DF, p-value: 5.58e-08 > 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.8342438 3.315125e-01 1.657562e-01 [2,] 0.9540945 9.181097e-02 4.590548e-02 [3,] 0.9403533 1.192934e-01 5.964668e-02 [4,] 0.8989990 2.020019e-01 1.010010e-01 [5,] 0.9596909 8.061811e-02 4.030906e-02 [6,] 0.9999464 1.072857e-04 5.364285e-05 [7,] 0.9999217 1.565080e-04 7.825398e-05 [8,] 0.9999552 8.965436e-05 4.482718e-05 [9,] 0.9999903 1.943000e-05 9.715001e-06 [10,] 0.9999929 1.426141e-05 7.130704e-06 [11,] 0.9999875 2.500939e-05 1.250470e-05 [12,] 0.9999822 3.566675e-05 1.783337e-05 [13,] 0.9999590 8.200582e-05 4.100291e-05 [14,] 0.9999131 1.738307e-04 8.691536e-05 [15,] 0.9998477 3.045149e-04 1.522574e-04 [16,] 0.9997177 5.645220e-04 2.822610e-04 [17,] 0.9995150 9.700049e-04 4.850024e-04 [18,] 0.9990662 1.867542e-03 9.337709e-04 [19,] 0.9983803 3.239357e-03 1.619678e-03 [20,] 0.9970673 5.865377e-03 2.932689e-03 [21,] 0.9967487 6.502587e-03 3.251294e-03 [22,] 0.9943551 1.128989e-02 5.644947e-03 [23,] 0.9933577 1.328450e-02 6.642251e-03 [24,] 0.9929469 1.410616e-02 7.053080e-03 [25,] 0.9902335 1.953292e-02 9.766460e-03 [26,] 0.9841374 3.172526e-02 1.586263e-02 [27,] 0.9829648 3.407041e-02 1.703520e-02 [28,] 0.9743703 5.125943e-02 2.562972e-02 [29,] 0.9705284 5.894326e-02 2.947163e-02 [30,] 0.9552013 8.959741e-02 4.479870e-02 [31,] 0.9339379 1.321243e-01 6.606215e-02 [32,] 0.9162039 1.675921e-01 8.379606e-02 [33,] 0.8815902 2.368195e-01 1.184098e-01 [34,] 0.8375347 3.249306e-01 1.624653e-01 [35,] 0.7918050 4.163899e-01 2.081950e-01 [36,] 0.7470206 5.059588e-01 2.529794e-01 [37,] 0.6781834 6.436333e-01 3.218166e-01 [38,] 0.6196417 7.607166e-01 3.803583e-01 [39,] 0.8366666 3.266668e-01 1.633334e-01 [40,] 0.7813811 4.372377e-01 2.186189e-01 [41,] 0.7449020 5.101960e-01 2.550980e-01 [42,] 0.7897752 4.204497e-01 2.102248e-01 [43,] 0.7551003 4.897994e-01 2.448997e-01 [44,] 0.6844318 6.311364e-01 3.155682e-01 [45,] 0.6195747 7.608506e-01 3.804253e-01 [46,] 0.7883821 4.232359e-01 2.116179e-01 [47,] 0.8049258 3.901484e-01 1.950742e-01 [48,] 0.7057326 5.885348e-01 2.942674e-01 [49,] 0.7581661 4.836678e-01 2.418339e-01 [50,] 0.7385984 5.228032e-01 2.614016e-01 [51,] 0.6315342 7.369316e-01 3.684658e-01 > postscript(file="/var/wessaorg/rcomp/tmp/1g4f31411236389.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/2iwt91411236389.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/3b8l31411236389.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/4r5zt1411236389.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/5r7ss1411236389.ps",horizontal=F,onefile=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 = 60 Frequency = 1 1 2 3 4 5 6 -0.263984016 -0.055655615 0.133726161 0.133409969 0.050880030 -0.030260601 7 8 9 10 11 12 -0.060080566 0.030525828 -0.241078868 0.130150323 -0.069471305 -0.109743624 13 14 15 16 17 18 0.138276624 0.102523262 0.052464947 0.062152434 -0.006163178 0.027211956 19 20 21 22 23 24 0.036219014 -0.032373381 0.037407340 0.019593128 -0.030123744 0.011351063 25 26 27 28 29 30 -0.065181881 0.009607726 0.056083828 0.071879865 0.061695935 0.023025543 31 32 33 34 35 36 -0.081714385 -0.018930583 0.040061223 -0.005135567 0.015262773 -0.063580143 37 38 39 40 41 42 0.003281712 -0.019000197 -0.033344136 -0.051093301 -0.011541033 -0.034180355 43 44 45 46 47 48 0.167953104 0.032900809 0.056350211 -0.090020697 -0.070962236 0.028041708 49 50 51 52 53 54 0.053118832 0.117938871 0.046104489 -0.038200455 0.043753121 -0.058268922 55 56 57 58 59 60 0.009293726 0.048347540 -0.047796754 -0.104976226 -0.037151362 -0.120579964 > postscript(file="/var/wessaorg/rcomp/tmp/63ntd1411236389.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > dum <- cbind(lag(myerror,k=1),myerror) > dum Time Series: Start = 0 End = 60 Frequency = 1 lag(myerror, k = 1) myerror 0 -0.263984016 NA 1 -0.055655615 -0.263984016 2 0.133726161 -0.055655615 3 0.133409969 0.133726161 4 0.050880030 0.133409969 5 -0.030260601 0.050880030 6 -0.060080566 -0.030260601 7 0.030525828 -0.060080566 8 -0.241078868 0.030525828 9 0.130150323 -0.241078868 10 -0.069471305 0.130150323 11 -0.109743624 -0.069471305 12 0.138276624 -0.109743624 13 0.102523262 0.138276624 14 0.052464947 0.102523262 15 0.062152434 0.052464947 16 -0.006163178 0.062152434 17 0.027211956 -0.006163178 18 0.036219014 0.027211956 19 -0.032373381 0.036219014 20 0.037407340 -0.032373381 21 0.019593128 0.037407340 22 -0.030123744 0.019593128 23 0.011351063 -0.030123744 24 -0.065181881 0.011351063 25 0.009607726 -0.065181881 26 0.056083828 0.009607726 27 0.071879865 0.056083828 28 0.061695935 0.071879865 29 0.023025543 0.061695935 30 -0.081714385 0.023025543 31 -0.018930583 -0.081714385 32 0.040061223 -0.018930583 33 -0.005135567 0.040061223 34 0.015262773 -0.005135567 35 -0.063580143 0.015262773 36 0.003281712 -0.063580143 37 -0.019000197 0.003281712 38 -0.033344136 -0.019000197 39 -0.051093301 -0.033344136 40 -0.011541033 -0.051093301 41 -0.034180355 -0.011541033 42 0.167953104 -0.034180355 43 0.032900809 0.167953104 44 0.056350211 0.032900809 45 -0.090020697 0.056350211 46 -0.070962236 -0.090020697 47 0.028041708 -0.070962236 48 0.053118832 0.028041708 49 0.117938871 0.053118832 50 0.046104489 0.117938871 51 -0.038200455 0.046104489 52 0.043753121 -0.038200455 53 -0.058268922 0.043753121 54 0.009293726 -0.058268922 55 0.048347540 0.009293726 56 -0.047796754 0.048347540 57 -0.104976226 -0.047796754 58 -0.037151362 -0.104976226 59 -0.120579964 -0.037151362 60 NA -0.120579964 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -0.055655615 -0.263984016 [2,] 0.133726161 -0.055655615 [3,] 0.133409969 0.133726161 [4,] 0.050880030 0.133409969 [5,] -0.030260601 0.050880030 [6,] -0.060080566 -0.030260601 [7,] 0.030525828 -0.060080566 [8,] -0.241078868 0.030525828 [9,] 0.130150323 -0.241078868 [10,] -0.069471305 0.130150323 [11,] -0.109743624 -0.069471305 [12,] 0.138276624 -0.109743624 [13,] 0.102523262 0.138276624 [14,] 0.052464947 0.102523262 [15,] 0.062152434 0.052464947 [16,] -0.006163178 0.062152434 [17,] 0.027211956 -0.006163178 [18,] 0.036219014 0.027211956 [19,] -0.032373381 0.036219014 [20,] 0.037407340 -0.032373381 [21,] 0.019593128 0.037407340 [22,] -0.030123744 0.019593128 [23,] 0.011351063 -0.030123744 [24,] -0.065181881 0.011351063 [25,] 0.009607726 -0.065181881 [26,] 0.056083828 0.009607726 [27,] 0.071879865 0.056083828 [28,] 0.061695935 0.071879865 [29,] 0.023025543 0.061695935 [30,] -0.081714385 0.023025543 [31,] -0.018930583 -0.081714385 [32,] 0.040061223 -0.018930583 [33,] -0.005135567 0.040061223 [34,] 0.015262773 -0.005135567 [35,] -0.063580143 0.015262773 [36,] 0.003281712 -0.063580143 [37,] -0.019000197 0.003281712 [38,] -0.033344136 -0.019000197 [39,] -0.051093301 -0.033344136 [40,] -0.011541033 -0.051093301 [41,] -0.034180355 -0.011541033 [42,] 0.167953104 -0.034180355 [43,] 0.032900809 0.167953104 [44,] 0.056350211 0.032900809 [45,] -0.090020697 0.056350211 [46,] -0.070962236 -0.090020697 [47,] 0.028041708 -0.070962236 [48,] 0.053118832 0.028041708 [49,] 0.117938871 0.053118832 [50,] 0.046104489 0.117938871 [51,] -0.038200455 0.046104489 [52,] 0.043753121 -0.038200455 [53,] -0.058268922 0.043753121 [54,] 0.009293726 -0.058268922 [55,] 0.048347540 0.009293726 [56,] -0.047796754 0.048347540 [57,] -0.104976226 -0.047796754 [58,] -0.037151362 -0.104976226 [59,] -0.120579964 -0.037151362 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -0.055655615 -0.263984016 2 0.133726161 -0.055655615 3 0.133409969 0.133726161 4 0.050880030 0.133409969 5 -0.030260601 0.050880030 6 -0.060080566 -0.030260601 7 0.030525828 -0.060080566 8 -0.241078868 0.030525828 9 0.130150323 -0.241078868 10 -0.069471305 0.130150323 11 -0.109743624 -0.069471305 12 0.138276624 -0.109743624 13 0.102523262 0.138276624 14 0.052464947 0.102523262 15 0.062152434 0.052464947 16 -0.006163178 0.062152434 17 0.027211956 -0.006163178 18 0.036219014 0.027211956 19 -0.032373381 0.036219014 20 0.037407340 -0.032373381 21 0.019593128 0.037407340 22 -0.030123744 0.019593128 23 0.011351063 -0.030123744 24 -0.065181881 0.011351063 25 0.009607726 -0.065181881 26 0.056083828 0.009607726 27 0.071879865 0.056083828 28 0.061695935 0.071879865 29 0.023025543 0.061695935 30 -0.081714385 0.023025543 31 -0.018930583 -0.081714385 32 0.040061223 -0.018930583 33 -0.005135567 0.040061223 34 0.015262773 -0.005135567 35 -0.063580143 0.015262773 36 0.003281712 -0.063580143 37 -0.019000197 0.003281712 38 -0.033344136 -0.019000197 39 -0.051093301 -0.033344136 40 -0.011541033 -0.051093301 41 -0.034180355 -0.011541033 42 0.167953104 -0.034180355 43 0.032900809 0.167953104 44 0.056350211 0.032900809 45 -0.090020697 0.056350211 46 -0.070962236 -0.090020697 47 0.028041708 -0.070962236 48 0.053118832 0.028041708 49 0.117938871 0.053118832 50 0.046104489 0.117938871 51 -0.038200455 0.046104489 52 0.043753121 -0.038200455 53 -0.058268922 0.043753121 54 0.009293726 -0.058268922 55 0.048347540 0.009293726 56 -0.047796754 0.048347540 57 -0.104976226 -0.047796754 58 -0.037151362 -0.104976226 59 -0.120579964 -0.037151362 > 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/wessaorg/rcomp/tmp/7s97a1411236389.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/83a8m1411236389.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/913tu1411236389.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/1030cu1411236389.ps",horizontal=F,onefile=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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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, signif(mysum$coefficients[i,1],6), 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/wessaorg/rcomp/tmp/11kfxa1411236389.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,signif(mysum$coefficients[i,1],6)) + a<-table.element(a, signif(mysum$coefficients[i,2],6)) + a<-table.element(a, signif(mysum$coefficients[i,3],4)) + a<-table.element(a, signif(mysum$coefficients[i,4],6)) + a<-table.element(a, signif(mysum$coefficients[i,4]/2,6)) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/12oh0r1411236389.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, signif(sqrt(mysum$r.squared),6)) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'R-squared',1,TRUE) > a<-table.element(a, signif(mysum$r.squared,6)) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'Adjusted R-squared',1,TRUE) > a<-table.element(a, signif(mysum$adj.r.squared,6)) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'F-TEST (value)',1,TRUE) > a<-table.element(a, signif(mysum$fstatistic[1],6)) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'F-TEST (DF numerator)',1,TRUE) > a<-table.element(a, signif(mysum$fstatistic[2],6)) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'F-TEST (DF denominator)',1,TRUE) > a<-table.element(a, signif(mysum$fstatistic[3],6)) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'p-value',1,TRUE) > a<-table.element(a, signif(1-pf(mysum$fstatistic[1],mysum$fstatistic[2],mysum$fstatistic[3]),6)) > 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, signif(mysum$sigma,6)) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a, 'Sum Squared Residuals',1,TRUE) > a<-table.element(a, signif(sum(myerror*myerror),6)) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/13ohmy1411236389.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,signif(x[i],6)) + a<-table.element(a,signif(x[i]-mysum$resid[i],6)) + a<-table.element(a,signif(mysum$resid[i],6)) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/14ufna1411236389.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,signif(gqarr[mypoint-kp3+1,1],6)) + a<-table.element(a,signif(gqarr[mypoint-kp3+1,2],6)) + a<-table.element(a,signif(gqarr[mypoint-kp3+1,3],6)) + a<-table.row.end(a) + } + a<-table.end(a) + table.save(a,file="/var/wessaorg/rcomp/tmp/15nb831411236389.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,signif(numsignificant1,6)) + a<-table.element(a,signif(numsignificant1/numgqtests,6)) + 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,signif(numsignificant5,6)) + a<-table.element(a,signif(numsignificant5/numgqtests,6)) + 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,signif(numsignificant10,6)) + a<-table.element(a,signif(numsignificant10/numgqtests,6)) + 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/wessaorg/rcomp/tmp/16ckqe1411236389.tab") + } > > try(system("convert tmp/1g4f31411236389.ps tmp/1g4f31411236389.png",intern=TRUE)) character(0) > try(system("convert tmp/2iwt91411236389.ps tmp/2iwt91411236389.png",intern=TRUE)) character(0) > try(system("convert tmp/3b8l31411236389.ps tmp/3b8l31411236389.png",intern=TRUE)) character(0) > try(system("convert tmp/4r5zt1411236389.ps tmp/4r5zt1411236389.png",intern=TRUE)) character(0) > try(system("convert tmp/5r7ss1411236389.ps tmp/5r7ss1411236389.png",intern=TRUE)) character(0) > try(system("convert tmp/63ntd1411236389.ps tmp/63ntd1411236389.png",intern=TRUE)) character(0) > try(system("convert tmp/7s97a1411236389.ps tmp/7s97a1411236389.png",intern=TRUE)) character(0) > try(system("convert tmp/83a8m1411236389.ps tmp/83a8m1411236389.png",intern=TRUE)) character(0) > try(system("convert tmp/913tu1411236389.ps tmp/913tu1411236389.png",intern=TRUE)) character(0) > try(system("convert tmp/1030cu1411236389.ps tmp/1030cu1411236389.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 4.079 0.628 4.750