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(105.29,0,101.23,0,102.33,0,100.26,0,104.13,0,103.54,0,100.02,0,98.66,0,108.64,0,105.67,0,102.66,0,100.3,0,95.13,0,93.2,0,102.84,0,101.36,0,102.55,0,103.12,0,96.3,0,99.13,0,102.23,0,104.3,0,99.58,0,98.45,0,96.23,0,97.62,0,102.32,0,105.23,0,100.05,0,102.66,0,100.98,0,99.2,0,98.36,0,102.56,0,97.33,0,96.22,0,99.22,0,102.32,0,104.22,0,100.06,0,107.23,0,99.62,0,98.32,1,101.23,1,102.33,1,100.6,1,95.63,1,94.63,1,95.66,1,100.78,1,90.36,1,95.45,1,103.65,1,99.89,1,97.68,1,99.62,1,98.33,1,96.23,1,102.65,1,99.35,1,92.65,1,100.6,1,97.67,1),dim=c(2,63),dimnames=list(c('Y','X'),1:63)) > y <- array(NA,dim=c(2,63),dimnames=list(c('Y','X'),1:63)) > 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 105.29 0 1 0 0 0 0 0 0 0 0 0 0 2 101.23 0 0 1 0 0 0 0 0 0 0 0 0 3 102.33 0 0 0 1 0 0 0 0 0 0 0 0 4 100.26 0 0 0 0 1 0 0 0 0 0 0 0 5 104.13 0 0 0 0 0 1 0 0 0 0 0 0 6 103.54 0 0 0 0 0 0 1 0 0 0 0 0 7 100.02 0 0 0 0 0 0 0 1 0 0 0 0 8 98.66 0 0 0 0 0 0 0 0 1 0 0 0 9 108.64 0 0 0 0 0 0 0 0 0 1 0 0 10 105.67 0 0 0 0 0 0 0 0 0 0 1 0 11 102.66 0 0 0 0 0 0 0 0 0 0 0 1 12 100.30 0 0 0 0 0 0 0 0 0 0 0 0 13 95.13 0 1 0 0 0 0 0 0 0 0 0 0 14 93.20 0 0 1 0 0 0 0 0 0 0 0 0 15 102.84 0 0 0 1 0 0 0 0 0 0 0 0 16 101.36 0 0 0 0 1 0 0 0 0 0 0 0 17 102.55 0 0 0 0 0 1 0 0 0 0 0 0 18 103.12 0 0 0 0 0 0 1 0 0 0 0 0 19 96.30 0 0 0 0 0 0 0 1 0 0 0 0 20 99.13 0 0 0 0 0 0 0 0 1 0 0 0 21 102.23 0 0 0 0 0 0 0 0 0 1 0 0 22 104.30 0 0 0 0 0 0 0 0 0 0 1 0 23 99.58 0 0 0 0 0 0 0 0 0 0 0 1 24 98.45 0 0 0 0 0 0 0 0 0 0 0 0 25 96.23 0 1 0 0 0 0 0 0 0 0 0 0 26 97.62 0 0 1 0 0 0 0 0 0 0 0 0 27 102.32 0 0 0 1 0 0 0 0 0 0 0 0 28 105.23 0 0 0 0 1 0 0 0 0 0 0 0 29 100.05 0 0 0 0 0 1 0 0 0 0 0 0 30 102.66 0 0 0 0 0 0 1 0 0 0 0 0 31 100.98 0 0 0 0 0 0 0 1 0 0 0 0 32 99.20 0 0 0 0 0 0 0 0 1 0 0 0 33 98.36 0 0 0 0 0 0 0 0 0 1 0 0 34 102.56 0 0 0 0 0 0 0 0 0 0 1 0 35 97.33 0 0 0 0 0 0 0 0 0 0 0 1 36 96.22 0 0 0 0 0 0 0 0 0 0 0 0 37 99.22 0 1 0 0 0 0 0 0 0 0 0 0 38 102.32 0 0 1 0 0 0 0 0 0 0 0 0 39 104.22 0 0 0 1 0 0 0 0 0 0 0 0 40 100.06 0 0 0 0 1 0 0 0 0 0 0 0 41 107.23 0 0 0 0 0 1 0 0 0 0 0 0 42 99.62 0 0 0 0 0 0 1 0 0 0 0 0 43 98.32 1 0 0 0 0 0 0 1 0 0 0 0 44 101.23 1 0 0 0 0 0 0 0 1 0 0 0 45 102.33 1 0 0 0 0 0 0 0 0 1 0 0 46 100.60 1 0 0 0 0 0 0 0 0 0 1 0 47 95.63 1 0 0 0 0 0 0 0 0 0 0 1 48 94.63 1 0 0 0 0 0 0 0 0 0 0 0 49 95.66 1 1 0 0 0 0 0 0 0 0 0 0 50 100.78 1 0 1 0 0 0 0 0 0 0 0 0 51 90.36 1 0 0 1 0 0 0 0 0 0 0 0 52 95.45 1 0 0 0 1 0 0 0 0 0 0 0 53 103.65 1 0 0 0 0 1 0 0 0 0 0 0 54 99.89 1 0 0 0 0 0 1 0 0 0 0 0 55 97.68 1 0 0 0 0 0 0 1 0 0 0 0 56 99.62 1 0 0 0 0 0 0 0 1 0 0 0 57 98.33 1 0 0 0 0 0 0 0 0 1 0 0 58 96.23 1 0 0 0 0 0 0 0 0 0 1 0 59 102.65 1 0 0 0 0 0 0 0 0 0 0 1 60 99.35 1 0 0 0 0 0 0 0 0 0 0 0 61 92.65 1 1 0 0 0 0 0 0 0 0 0 0 62 100.60 1 0 1 0 0 0 0 0 0 0 0 0 63 97.67 1 0 0 1 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 98.806 -2.540 -0.596 1.332 1.997 2.174 M5 M6 M7 M8 M9 M10 5.224 3.468 0.870 1.778 4.188 4.082 M11 1.780 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -7.9031 -1.9521 0.2522 1.7262 7.0799 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 98.8062 1.4491 68.186 <2e-16 *** X -2.5404 0.8539 -2.975 0.0045 ** M1 -0.5960 1.9076 -0.312 0.7560 M2 1.3323 1.9076 0.698 0.4882 M3 1.9973 1.9076 1.047 0.3001 M4 2.1739 1.9989 1.088 0.2820 M5 5.2239 1.9989 2.613 0.0118 * M6 3.4679 1.9989 1.735 0.0889 . M7 0.8700 1.9916 0.437 0.6641 M8 1.7780 1.9916 0.893 0.3763 M9 4.1880 1.9916 2.103 0.0405 * M10 4.0820 1.9916 2.050 0.0457 * M11 1.7800 1.9916 0.894 0.3757 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 3.149 on 50 degrees of freedom Multiple R-squared: 0.3634, Adjusted R-squared: 0.2107 F-statistic: 2.379 on 12 and 50 DF, p-value: 0.01626 > 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.9659788 0.06804243 0.03402122 [2,] 0.9312443 0.13751146 0.06875573 [3,] 0.8758079 0.24838414 0.12419207 [4,] 0.8505337 0.29893266 0.14946633 [5,] 0.7772666 0.44546686 0.22273343 [6,] 0.8004355 0.39912895 0.19956448 [7,] 0.7357258 0.52854848 0.26427424 [8,] 0.6696636 0.66067281 0.33033640 [9,] 0.5808418 0.83831645 0.41915822 [10,] 0.5467873 0.90642549 0.45321274 [11,] 0.5087262 0.98254762 0.49127381 [12,] 0.4384523 0.87690462 0.56154769 [13,] 0.5198836 0.96023285 0.48011643 [14,] 0.5818303 0.83633932 0.41816966 [15,] 0.4988035 0.99760702 0.50119649 [16,] 0.4353028 0.87060555 0.56469723 [17,] 0.3808436 0.76168726 0.61915637 [18,] 0.5206728 0.95865446 0.47932723 [19,] 0.4482162 0.89643243 0.55178379 [20,] 0.4846841 0.96936823 0.51531589 [21,] 0.5051925 0.98961508 0.49480754 [22,] 0.4103833 0.82076653 0.58961673 [23,] 0.4154678 0.83093565 0.58453218 [24,] 0.5157912 0.96841755 0.48420878 [25,] 0.4461919 0.89238374 0.55380813 [26,] 0.4250709 0.85014186 0.57492907 [27,] 0.3414570 0.68291397 0.65854302 [28,] 0.2426503 0.48530053 0.75734973 [29,] 0.1698690 0.33973808 0.83013096 [30,] 0.1349608 0.26992156 0.86503922 [31,] 0.1168156 0.23363127 0.88318436 [32,] 0.1863166 0.37263323 0.81368338 > postscript(file="/var/www/html/rcomp/tmp/14ewi1258990028.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/2qs241258990028.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/346r11258990028.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/4lozp1258990028.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/544py1258990028.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 = 63 Frequency = 1 1 2 3 4 5 6 7.079869281 1.091535948 1.526535948 -0.720078431 0.099921569 1.265921569 7 8 9 10 11 12 0.343843137 -1.924156863 5.645843137 2.781843137 2.073843137 1.493843137 13 14 15 16 17 18 -3.080130719 -6.938464052 2.036535948 0.379921569 -1.480078431 0.845921569 19 20 21 22 23 24 -3.376156863 -1.454156863 -0.764156863 1.411843137 -1.006156863 -0.356156863 25 26 27 28 29 30 -1.980130719 -2.518464052 1.516535948 4.249921569 -3.980078431 0.385921569 31 32 33 34 35 36 1.303843137 -1.384156863 -4.634156863 -0.328156863 -3.256156863 -2.586156863 37 38 39 40 41 42 1.009869281 2.181535948 3.416535948 -0.920078431 3.199921569 -2.654078431 43 44 45 46 47 48 1.184235294 3.186235294 1.876235294 0.252235294 -2.415764706 -1.635764706 49 50 51 52 53 54 -0.009738562 3.181928105 -7.903071895 -2.989686275 2.160313725 0.156313725 55 56 57 58 59 60 0.544235294 1.576235294 -2.123764706 -4.117764706 4.604235294 3.084235294 61 62 63 -3.019738562 3.001928105 -0.593071895 > postscript(file="/var/www/html/rcomp/tmp/61j2f1258990028.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 = 63 Frequency = 1 lag(myerror, k = 1) myerror 0 7.079869281 NA 1 1.091535948 7.079869281 2 1.526535948 1.091535948 3 -0.720078431 1.526535948 4 0.099921569 -0.720078431 5 1.265921569 0.099921569 6 0.343843137 1.265921569 7 -1.924156863 0.343843137 8 5.645843137 -1.924156863 9 2.781843137 5.645843137 10 2.073843137 2.781843137 11 1.493843137 2.073843137 12 -3.080130719 1.493843137 13 -6.938464052 -3.080130719 14 2.036535948 -6.938464052 15 0.379921569 2.036535948 16 -1.480078431 0.379921569 17 0.845921569 -1.480078431 18 -3.376156863 0.845921569 19 -1.454156863 -3.376156863 20 -0.764156863 -1.454156863 21 1.411843137 -0.764156863 22 -1.006156863 1.411843137 23 -0.356156863 -1.006156863 24 -1.980130719 -0.356156863 25 -2.518464052 -1.980130719 26 1.516535948 -2.518464052 27 4.249921569 1.516535948 28 -3.980078431 4.249921569 29 0.385921569 -3.980078431 30 1.303843137 0.385921569 31 -1.384156863 1.303843137 32 -4.634156863 -1.384156863 33 -0.328156863 -4.634156863 34 -3.256156863 -0.328156863 35 -2.586156863 -3.256156863 36 1.009869281 -2.586156863 37 2.181535948 1.009869281 38 3.416535948 2.181535948 39 -0.920078431 3.416535948 40 3.199921569 -0.920078431 41 -2.654078431 3.199921569 42 1.184235294 -2.654078431 43 3.186235294 1.184235294 44 1.876235294 3.186235294 45 0.252235294 1.876235294 46 -2.415764706 0.252235294 47 -1.635764706 -2.415764706 48 -0.009738562 -1.635764706 49 3.181928105 -0.009738562 50 -7.903071895 3.181928105 51 -2.989686275 -7.903071895 52 2.160313725 -2.989686275 53 0.156313725 2.160313725 54 0.544235294 0.156313725 55 1.576235294 0.544235294 56 -2.123764706 1.576235294 57 -4.117764706 -2.123764706 58 4.604235294 -4.117764706 59 3.084235294 4.604235294 60 -3.019738562 3.084235294 61 3.001928105 -3.019738562 62 -0.593071895 3.001928105 63 NA -0.593071895 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 1.091535948 7.079869281 [2,] 1.526535948 1.091535948 [3,] -0.720078431 1.526535948 [4,] 0.099921569 -0.720078431 [5,] 1.265921569 0.099921569 [6,] 0.343843137 1.265921569 [7,] -1.924156863 0.343843137 [8,] 5.645843137 -1.924156863 [9,] 2.781843137 5.645843137 [10,] 2.073843137 2.781843137 [11,] 1.493843137 2.073843137 [12,] -3.080130719 1.493843137 [13,] -6.938464052 -3.080130719 [14,] 2.036535948 -6.938464052 [15,] 0.379921569 2.036535948 [16,] -1.480078431 0.379921569 [17,] 0.845921569 -1.480078431 [18,] -3.376156863 0.845921569 [19,] -1.454156863 -3.376156863 [20,] -0.764156863 -1.454156863 [21,] 1.411843137 -0.764156863 [22,] -1.006156863 1.411843137 [23,] -0.356156863 -1.006156863 [24,] -1.980130719 -0.356156863 [25,] -2.518464052 -1.980130719 [26,] 1.516535948 -2.518464052 [27,] 4.249921569 1.516535948 [28,] -3.980078431 4.249921569 [29,] 0.385921569 -3.980078431 [30,] 1.303843137 0.385921569 [31,] -1.384156863 1.303843137 [32,] -4.634156863 -1.384156863 [33,] -0.328156863 -4.634156863 [34,] -3.256156863 -0.328156863 [35,] -2.586156863 -3.256156863 [36,] 1.009869281 -2.586156863 [37,] 2.181535948 1.009869281 [38,] 3.416535948 2.181535948 [39,] -0.920078431 3.416535948 [40,] 3.199921569 -0.920078431 [41,] -2.654078431 3.199921569 [42,] 1.184235294 -2.654078431 [43,] 3.186235294 1.184235294 [44,] 1.876235294 3.186235294 [45,] 0.252235294 1.876235294 [46,] -2.415764706 0.252235294 [47,] -1.635764706 -2.415764706 [48,] -0.009738562 -1.635764706 [49,] 3.181928105 -0.009738562 [50,] -7.903071895 3.181928105 [51,] -2.989686275 -7.903071895 [52,] 2.160313725 -2.989686275 [53,] 0.156313725 2.160313725 [54,] 0.544235294 0.156313725 [55,] 1.576235294 0.544235294 [56,] -2.123764706 1.576235294 [57,] -4.117764706 -2.123764706 [58,] 4.604235294 -4.117764706 [59,] 3.084235294 4.604235294 [60,] -3.019738562 3.084235294 [61,] 3.001928105 -3.019738562 [62,] -0.593071895 3.001928105 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 1.091535948 7.079869281 2 1.526535948 1.091535948 3 -0.720078431 1.526535948 4 0.099921569 -0.720078431 5 1.265921569 0.099921569 6 0.343843137 1.265921569 7 -1.924156863 0.343843137 8 5.645843137 -1.924156863 9 2.781843137 5.645843137 10 2.073843137 2.781843137 11 1.493843137 2.073843137 12 -3.080130719 1.493843137 13 -6.938464052 -3.080130719 14 2.036535948 -6.938464052 15 0.379921569 2.036535948 16 -1.480078431 0.379921569 17 0.845921569 -1.480078431 18 -3.376156863 0.845921569 19 -1.454156863 -3.376156863 20 -0.764156863 -1.454156863 21 1.411843137 -0.764156863 22 -1.006156863 1.411843137 23 -0.356156863 -1.006156863 24 -1.980130719 -0.356156863 25 -2.518464052 -1.980130719 26 1.516535948 -2.518464052 27 4.249921569 1.516535948 28 -3.980078431 4.249921569 29 0.385921569 -3.980078431 30 1.303843137 0.385921569 31 -1.384156863 1.303843137 32 -4.634156863 -1.384156863 33 -0.328156863 -4.634156863 34 -3.256156863 -0.328156863 35 -2.586156863 -3.256156863 36 1.009869281 -2.586156863 37 2.181535948 1.009869281 38 3.416535948 2.181535948 39 -0.920078431 3.416535948 40 3.199921569 -0.920078431 41 -2.654078431 3.199921569 42 1.184235294 -2.654078431 43 3.186235294 1.184235294 44 1.876235294 3.186235294 45 0.252235294 1.876235294 46 -2.415764706 0.252235294 47 -1.635764706 -2.415764706 48 -0.009738562 -1.635764706 49 3.181928105 -0.009738562 50 -7.903071895 3.181928105 51 -2.989686275 -7.903071895 52 2.160313725 -2.989686275 53 0.156313725 2.160313725 54 0.544235294 0.156313725 55 1.576235294 0.544235294 56 -2.123764706 1.576235294 57 -4.117764706 -2.123764706 58 4.604235294 -4.117764706 59 3.084235294 4.604235294 60 -3.019738562 3.084235294 61 3.001928105 -3.019738562 62 -0.593071895 3.001928105 > 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/7uu4o1258990028.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/8306e1258990028.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/96n0i1258990028.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/10g1tf1258990028.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/11kb471258990028.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/12ij6g1258990028.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/13lhmg1258990028.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/14p8j81258990028.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/15sevy1258990028.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/160dlb1258990028.tab") + } > > system("convert tmp/14ewi1258990028.ps tmp/14ewi1258990028.png") > system("convert tmp/2qs241258990028.ps tmp/2qs241258990028.png") > system("convert tmp/346r11258990028.ps tmp/346r11258990028.png") > system("convert tmp/4lozp1258990028.ps tmp/4lozp1258990028.png") > system("convert tmp/544py1258990028.ps tmp/544py1258990028.png") > system("convert tmp/61j2f1258990028.ps tmp/61j2f1258990028.png") > system("convert tmp/7uu4o1258990028.ps tmp/7uu4o1258990028.png") > system("convert tmp/8306e1258990028.ps tmp/8306e1258990028.png") > system("convert tmp/96n0i1258990028.ps tmp/96n0i1258990028.png") > system("convert tmp/10g1tf1258990028.ps tmp/10g1tf1258990028.png") > > > proc.time() user system elapsed 2.424 1.564 2.937