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 = 'Do not include Seasonal Dummies' > par1 = '1' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > library(lattice) > library(lmtest) Loading required package: zoo Attaching package: 'zoo' The following object(s) are masked from package:base : as.Date.numeric > n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test > par1 <- as.numeric(par1) > x <- t(y) > k <- length(x[1,]) > n <- length(x[,1]) > x1 <- cbind(x[,par1], x[,1:k!=par1]) > mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1]) > colnames(x1) <- mycolnames #colnames(x)[par1] > x <- x1 > if (par3 == 'First Differences'){ + x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep=''))) + for (i in 1:n-1) { + for (j in 1:k) { + x2[i,j] <- x[i+1,j] - x[i,j] + } + } + x <- x2 + } > if (par2 == 'Include Monthly Dummies'){ + x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep =''))) + for (i in 1:11){ + x2[seq(i,n,12),i] <- 1 + } + x <- cbind(x, x2) + } > if (par2 == 'Include Quarterly Dummies'){ + x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep =''))) + for (i in 1:3){ + x2[seq(i,n,4),i] <- 1 + } + x <- cbind(x, x2) + } > k <- length(x[1,]) > if (par3 == 'Linear Trend'){ + x <- cbind(x, c(1:n)) + colnames(x)[k+1] <- 't' + } > x Y X 1 14.2 -0.8 2 13.5 -0.2 3 11.9 0.2 4 14.6 1.0 5 15.6 0.0 6 14.1 -0.2 7 14.9 1.0 8 14.2 0.4 9 14.6 1.0 10 17.2 1.7 11 15.4 3.1 12 14.3 3.3 13 17.5 3.1 14 14.5 3.5 15 14.4 6.0 16 16.6 5.7 17 16.7 4.7 18 16.6 4.2 19 16.9 3.6 20 15.7 4.4 21 16.4 2.5 22 18.4 -0.6 23 16.9 -1.9 24 16.5 -1.9 25 18.3 0.7 26 15.1 -0.9 27 15.7 -1.7 28 18.1 -3.1 29 16.8 -2.1 30 18.9 0.2 31 19.0 1.2 32 18.1 3.8 33 17.8 4.0 34 21.5 6.6 35 17.1 5.3 36 18.7 7.6 37 19.0 4.7 38 16.4 6.6 39 16.9 4.4 40 18.6 4.6 41 19.3 6.0 42 19.4 4.8 43 17.6 4.0 44 18.6 2.7 45 18.1 3.0 46 20.4 4.1 47 18.1 4.0 48 19.6 2.7 49 19.9 2.6 50 19.2 3.1 51 17.8 4.4 52 19.2 3.0 53 22.0 2.0 54 21.1 1.3 55 19.5 1.5 56 22.2 1.3 57 20.9 3.2 58 22.2 1.8 59 23.5 3.3 60 21.5 1.0 61 24.3 2.4 62 22.8 0.4 63 20.3 -0.1 64 23.7 1.3 65 23.3 -1.1 66 19.6 -4.4 67 18.0 -7.5 68 17.3 -12.2 69 16.8 -14.5 70 18.2 -16.0 71 16.5 -16.7 72 16.0 -16.3 73 18.4 -16.9 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X 17.95438 0.05081 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -6.06454 -1.64397 -0.04744 1.30423 6.22369 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 17.95438 0.31481 57.032 <2e-16 *** X 0.05081 0.05696 0.892 0.375 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 2.674 on 71 degrees of freedom Multiple R-squared: 0.01108, Adjusted R-squared: -0.002846 F-statistic: 0.7957 on 1 and 71 DF, p-value: 0.3754 > 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.249267006 0.49853401 0.750732994 [2,] 0.131170652 0.26234130 0.868829348 [3,] 0.070958037 0.14191607 0.929041963 [4,] 0.034765603 0.06953121 0.965234397 [5,] 0.016475049 0.03295010 0.983524951 [6,] 0.021778229 0.04355646 0.978221771 [7,] 0.015671991 0.03134398 0.984328009 [8,] 0.016488750 0.03297750 0.983511250 [9,] 0.018139758 0.03627952 0.981860242 [10,] 0.018675896 0.03735179 0.981324104 [11,] 0.025784413 0.05156883 0.974215587 [12,] 0.018292041 0.03658408 0.981707959 [13,] 0.013631995 0.02726399 0.986368005 [14,] 0.010081726 0.02016345 0.989918274 [15,] 0.008702101 0.01740420 0.991297899 [16,] 0.006683921 0.01336784 0.993316079 [17,] 0.005944689 0.01188938 0.994055311 [18,] 0.039035974 0.07807195 0.960964026 [19,] 0.048154084 0.09630817 0.951845916 [20,] 0.046293413 0.09258683 0.953706587 [21,] 0.067125477 0.13425095 0.932874523 [22,] 0.070066940 0.14013388 0.929933060 [23,] 0.068004165 0.13600833 0.931995835 [24,] 0.084146061 0.16829212 0.915853939 [25,] 0.076625502 0.15325100 0.923374498 [26,] 0.106945671 0.21389134 0.893054329 [27,] 0.138999765 0.27799953 0.861000235 [28,] 0.145802337 0.29160467 0.854197663 [29,] 0.145697843 0.29139569 0.854302157 [30,] 0.296260320 0.59252064 0.703739680 [31,] 0.294358860 0.58871772 0.705641140 [32,] 0.274602391 0.54920478 0.725397609 [33,] 0.262394703 0.52478941 0.737605297 [34,] 0.333588296 0.66717659 0.666411704 [35,] 0.381275720 0.76255144 0.618724280 [36,] 0.381557439 0.76311488 0.618442561 [37,] 0.378040227 0.75608045 0.621959773 [38,] 0.375972734 0.75194547 0.624027266 [39,] 0.427415457 0.85483091 0.572584543 [40,] 0.443987497 0.88797499 0.556012503 [41,] 0.491849109 0.98369822 0.508150891 [42,] 0.510121446 0.97975711 0.489878554 [43,] 0.599023626 0.80195275 0.400976374 [44,] 0.620985174 0.75802965 0.379014826 [45,] 0.638566601 0.72286680 0.361433399 [46,] 0.684570967 0.63085807 0.315429033 [47,] 0.897613541 0.20477292 0.102386459 [48,] 0.956946903 0.08610619 0.043053097 [49,] 0.964685784 0.07062843 0.035314216 [50,] 0.966336112 0.06732778 0.033663888 [51,] 0.985765523 0.02846895 0.014234477 [52,] 0.985294413 0.02941117 0.014705587 [53,] 0.991258312 0.01748338 0.008741688 [54,] 0.989387681 0.02122464 0.010612319 [55,] 0.987260162 0.02547968 0.012739838 [56,] 0.983873748 0.03225250 0.016126252 [57,] 0.985835964 0.02832807 0.014164036 [58,] 0.979717101 0.04056580 0.020282899 [59,] 0.978617470 0.04276506 0.021382530 [60,] 0.972457325 0.05508535 0.027542675 [61,] 0.993546012 0.01290798 0.006453988 [62,] 0.987360162 0.02527968 0.012639838 [63,] 0.964011306 0.07197739 0.035988694 [64,] 0.903149676 0.19370065 0.096850324 > postscript(file="/var/www/html/rcomp/tmp/11vgy1258722725.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/25yei1258722725.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/32sld1258722725.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/41aea1258722725.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/5ihpl1258722725.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 -3.713734268 -4.444217543 -6.064539727 -3.405184094 -2.354378635 -3.844217543 7 8 9 10 11 12 -3.105184094 -3.774700819 -3.405184094 -0.840747915 -2.711875557 -3.822036649 13 14 15 16 17 18 -0.611875557 -3.632197741 -3.859211388 -1.643969750 -1.493164292 -1.567761562 19 20 21 22 23 24 -1.237278287 -2.477922654 -1.681392282 0.476104640 -0.957848263 -1.357848263 25 26 27 28 29 30 0.310057544 -2.808653722 -2.168009355 0.303118287 -1.047687171 0.935460273 31 32 33 34 35 36 0.984654814 -0.047439379 -0.357600470 3.210305337 -1.123647567 0.359499878 37 38 39 40 41 42 0.806835708 -1.889694663 -1.277922654 0.411916254 1.040788612 1.201755163 43 44 45 46 47 48 -0.557600470 0.508446626 -0.006795012 2.237318984 -0.057600470 1.508446626 49 50 51 52 53 54 1.813527172 1.088124443 -0.377922654 1.093204988 3.944010447 3.079574268 55 56 57 58 59 60 1.469413177 4.179574268 2.783043897 4.154171539 5.377963351 3.494815906 61 62 63 64 65 66 6.223688264 4.825299181 2.350701911 5.679574268 5.401507370 1.869165384 67 68 69 70 71 72 0.426662306 -0.034552037 -0.417699482 1.058508706 -0.605927472 -1.126249656 73 1.304233619 > postscript(file="/var/www/html/rcomp/tmp/6di1p1258722725.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 -3.713734268 NA 1 -4.444217543 -3.713734268 2 -6.064539727 -4.444217543 3 -3.405184094 -6.064539727 4 -2.354378635 -3.405184094 5 -3.844217543 -2.354378635 6 -3.105184094 -3.844217543 7 -3.774700819 -3.105184094 8 -3.405184094 -3.774700819 9 -0.840747915 -3.405184094 10 -2.711875557 -0.840747915 11 -3.822036649 -2.711875557 12 -0.611875557 -3.822036649 13 -3.632197741 -0.611875557 14 -3.859211388 -3.632197741 15 -1.643969750 -3.859211388 16 -1.493164292 -1.643969750 17 -1.567761562 -1.493164292 18 -1.237278287 -1.567761562 19 -2.477922654 -1.237278287 20 -1.681392282 -2.477922654 21 0.476104640 -1.681392282 22 -0.957848263 0.476104640 23 -1.357848263 -0.957848263 24 0.310057544 -1.357848263 25 -2.808653722 0.310057544 26 -2.168009355 -2.808653722 27 0.303118287 -2.168009355 28 -1.047687171 0.303118287 29 0.935460273 -1.047687171 30 0.984654814 0.935460273 31 -0.047439379 0.984654814 32 -0.357600470 -0.047439379 33 3.210305337 -0.357600470 34 -1.123647567 3.210305337 35 0.359499878 -1.123647567 36 0.806835708 0.359499878 37 -1.889694663 0.806835708 38 -1.277922654 -1.889694663 39 0.411916254 -1.277922654 40 1.040788612 0.411916254 41 1.201755163 1.040788612 42 -0.557600470 1.201755163 43 0.508446626 -0.557600470 44 -0.006795012 0.508446626 45 2.237318984 -0.006795012 46 -0.057600470 2.237318984 47 1.508446626 -0.057600470 48 1.813527172 1.508446626 49 1.088124443 1.813527172 50 -0.377922654 1.088124443 51 1.093204988 -0.377922654 52 3.944010447 1.093204988 53 3.079574268 3.944010447 54 1.469413177 3.079574268 55 4.179574268 1.469413177 56 2.783043897 4.179574268 57 4.154171539 2.783043897 58 5.377963351 4.154171539 59 3.494815906 5.377963351 60 6.223688264 3.494815906 61 4.825299181 6.223688264 62 2.350701911 4.825299181 63 5.679574268 2.350701911 64 5.401507370 5.679574268 65 1.869165384 5.401507370 66 0.426662306 1.869165384 67 -0.034552037 0.426662306 68 -0.417699482 -0.034552037 69 1.058508706 -0.417699482 70 -0.605927472 1.058508706 71 -1.126249656 -0.605927472 72 1.304233619 -1.126249656 73 NA 1.304233619 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -4.444217543 -3.713734268 [2,] -6.064539727 -4.444217543 [3,] -3.405184094 -6.064539727 [4,] -2.354378635 -3.405184094 [5,] -3.844217543 -2.354378635 [6,] -3.105184094 -3.844217543 [7,] -3.774700819 -3.105184094 [8,] -3.405184094 -3.774700819 [9,] -0.840747915 -3.405184094 [10,] -2.711875557 -0.840747915 [11,] -3.822036649 -2.711875557 [12,] -0.611875557 -3.822036649 [13,] -3.632197741 -0.611875557 [14,] -3.859211388 -3.632197741 [15,] -1.643969750 -3.859211388 [16,] -1.493164292 -1.643969750 [17,] -1.567761562 -1.493164292 [18,] -1.237278287 -1.567761562 [19,] -2.477922654 -1.237278287 [20,] -1.681392282 -2.477922654 [21,] 0.476104640 -1.681392282 [22,] -0.957848263 0.476104640 [23,] -1.357848263 -0.957848263 [24,] 0.310057544 -1.357848263 [25,] -2.808653722 0.310057544 [26,] -2.168009355 -2.808653722 [27,] 0.303118287 -2.168009355 [28,] -1.047687171 0.303118287 [29,] 0.935460273 -1.047687171 [30,] 0.984654814 0.935460273 [31,] -0.047439379 0.984654814 [32,] -0.357600470 -0.047439379 [33,] 3.210305337 -0.357600470 [34,] -1.123647567 3.210305337 [35,] 0.359499878 -1.123647567 [36,] 0.806835708 0.359499878 [37,] -1.889694663 0.806835708 [38,] -1.277922654 -1.889694663 [39,] 0.411916254 -1.277922654 [40,] 1.040788612 0.411916254 [41,] 1.201755163 1.040788612 [42,] -0.557600470 1.201755163 [43,] 0.508446626 -0.557600470 [44,] -0.006795012 0.508446626 [45,] 2.237318984 -0.006795012 [46,] -0.057600470 2.237318984 [47,] 1.508446626 -0.057600470 [48,] 1.813527172 1.508446626 [49,] 1.088124443 1.813527172 [50,] -0.377922654 1.088124443 [51,] 1.093204988 -0.377922654 [52,] 3.944010447 1.093204988 [53,] 3.079574268 3.944010447 [54,] 1.469413177 3.079574268 [55,] 4.179574268 1.469413177 [56,] 2.783043897 4.179574268 [57,] 4.154171539 2.783043897 [58,] 5.377963351 4.154171539 [59,] 3.494815906 5.377963351 [60,] 6.223688264 3.494815906 [61,] 4.825299181 6.223688264 [62,] 2.350701911 4.825299181 [63,] 5.679574268 2.350701911 [64,] 5.401507370 5.679574268 [65,] 1.869165384 5.401507370 [66,] 0.426662306 1.869165384 [67,] -0.034552037 0.426662306 [68,] -0.417699482 -0.034552037 [69,] 1.058508706 -0.417699482 [70,] -0.605927472 1.058508706 [71,] -1.126249656 -0.605927472 [72,] 1.304233619 -1.126249656 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -4.444217543 -3.713734268 2 -6.064539727 -4.444217543 3 -3.405184094 -6.064539727 4 -2.354378635 -3.405184094 5 -3.844217543 -2.354378635 6 -3.105184094 -3.844217543 7 -3.774700819 -3.105184094 8 -3.405184094 -3.774700819 9 -0.840747915 -3.405184094 10 -2.711875557 -0.840747915 11 -3.822036649 -2.711875557 12 -0.611875557 -3.822036649 13 -3.632197741 -0.611875557 14 -3.859211388 -3.632197741 15 -1.643969750 -3.859211388 16 -1.493164292 -1.643969750 17 -1.567761562 -1.493164292 18 -1.237278287 -1.567761562 19 -2.477922654 -1.237278287 20 -1.681392282 -2.477922654 21 0.476104640 -1.681392282 22 -0.957848263 0.476104640 23 -1.357848263 -0.957848263 24 0.310057544 -1.357848263 25 -2.808653722 0.310057544 26 -2.168009355 -2.808653722 27 0.303118287 -2.168009355 28 -1.047687171 0.303118287 29 0.935460273 -1.047687171 30 0.984654814 0.935460273 31 -0.047439379 0.984654814 32 -0.357600470 -0.047439379 33 3.210305337 -0.357600470 34 -1.123647567 3.210305337 35 0.359499878 -1.123647567 36 0.806835708 0.359499878 37 -1.889694663 0.806835708 38 -1.277922654 -1.889694663 39 0.411916254 -1.277922654 40 1.040788612 0.411916254 41 1.201755163 1.040788612 42 -0.557600470 1.201755163 43 0.508446626 -0.557600470 44 -0.006795012 0.508446626 45 2.237318984 -0.006795012 46 -0.057600470 2.237318984 47 1.508446626 -0.057600470 48 1.813527172 1.508446626 49 1.088124443 1.813527172 50 -0.377922654 1.088124443 51 1.093204988 -0.377922654 52 3.944010447 1.093204988 53 3.079574268 3.944010447 54 1.469413177 3.079574268 55 4.179574268 1.469413177 56 2.783043897 4.179574268 57 4.154171539 2.783043897 58 5.377963351 4.154171539 59 3.494815906 5.377963351 60 6.223688264 3.494815906 61 4.825299181 6.223688264 62 2.350701911 4.825299181 63 5.679574268 2.350701911 64 5.401507370 5.679574268 65 1.869165384 5.401507370 66 0.426662306 1.869165384 67 -0.034552037 0.426662306 68 -0.417699482 -0.034552037 69 1.058508706 -0.417699482 70 -0.605927472 1.058508706 71 -1.126249656 -0.605927472 72 1.304233619 -1.126249656 > 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/7lr1a1258722725.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/85es41258722725.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/9n2vh1258722725.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/10s6mf1258722725.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/11b7m61258722726.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/12sd941258722726.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/13s1lw1258722726.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/144p571258722726.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/15gwlz1258722726.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/16nbas1258722726.tab") + } > > system("convert tmp/11vgy1258722725.ps tmp/11vgy1258722725.png") > system("convert tmp/25yei1258722725.ps tmp/25yei1258722725.png") > system("convert tmp/32sld1258722725.ps tmp/32sld1258722725.png") > system("convert tmp/41aea1258722725.ps tmp/41aea1258722725.png") > system("convert tmp/5ihpl1258722725.ps tmp/5ihpl1258722725.png") > system("convert tmp/6di1p1258722725.ps tmp/6di1p1258722725.png") > system("convert tmp/7lr1a1258722725.ps tmp/7lr1a1258722725.png") > system("convert tmp/85es41258722725.ps tmp/85es41258722725.png") > system("convert tmp/9n2vh1258722725.ps tmp/9n2vh1258722725.png") > system("convert tmp/10s6mf1258722725.ps tmp/10s6mf1258722725.png") > > > proc.time() user system elapsed 2.608 1.595 4.907