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(463 + ,1802 + ,461 + ,461 + ,455 + ,462 + ,462 + ,1863 + ,463 + ,461 + ,461 + ,455 + ,456 + ,1989 + ,462 + ,463 + ,461 + ,461 + ,455 + ,2197 + ,456 + ,462 + ,463 + ,461 + ,456 + ,2409 + ,455 + ,456 + ,462 + ,463 + ,472 + ,2502 + ,456 + ,455 + ,456 + ,462 + ,472 + ,2593 + ,472 + ,456 + ,455 + ,456 + ,471 + ,2598 + ,472 + ,472 + ,456 + ,455 + ,465 + ,2053 + ,471 + ,472 + ,472 + ,456 + ,459 + ,2213 + ,465 + ,471 + ,472 + ,472 + ,465 + ,2238 + ,459 + ,465 + ,471 + ,472 + ,468 + ,2359 + ,465 + ,459 + ,465 + ,471 + ,467 + ,2151 + ,468 + ,465 + ,459 + ,465 + ,463 + ,2474 + ,467 + ,468 + ,465 + ,459 + ,460 + ,3079 + ,463 + ,467 + ,468 + ,465 + ,462 + ,2312 + ,460 + ,463 + ,467 + ,468 + ,461 + ,2565 + ,462 + ,460 + ,463 + ,467 + ,476 + ,1972 + ,461 + ,462 + ,460 + ,463 + ,476 + ,2484 + ,476 + ,461 + ,462 + ,460 + ,471 + ,2202 + ,476 + ,476 + ,461 + ,462 + ,453 + ,2151 + ,471 + ,476 + ,476 + ,461 + ,443 + ,1976 + ,453 + ,471 + ,476 + ,476 + ,442 + ,2012 + ,443 + ,453 + ,471 + ,476 + ,444 + ,2114 + ,442 + ,443 + ,453 + ,471 + ,438 + ,1772 + ,444 + ,442 + ,443 + ,453 + ,427 + ,1957 + ,438 + ,444 + ,442 + ,443 + ,424 + ,2070 + ,427 + ,438 + ,444 + ,442 + ,416 + ,1990 + ,424 + ,427 + ,438 + ,444 + ,406 + ,2182 + ,416 + ,424 + ,427 + ,438 + ,431 + ,2008 + ,406 + ,416 + ,424 + ,427 + ,434 + ,1916 + ,431 + ,406 + ,416 + ,424 + ,418 + ,2397 + ,434 + ,431 + ,406 + ,416 + ,412 + ,2114 + ,418 + ,434 + ,431 + ,406 + ,404 + ,1778 + ,412 + ,418 + ,434 + ,431 + ,409 + ,1641 + ,404 + ,412 + ,418 + ,434 + ,412 + ,2186 + ,409 + ,404 + ,412 + ,418 + ,406 + ,1773 + ,412 + ,409 + ,404 + ,412 + ,398 + ,1785 + ,406 + ,412 + ,409 + ,404 + ,397 + ,2217 + ,398 + ,406 + ,412 + ,409 + ,385 + ,2153 + ,397 + ,398 + ,406 + ,412 + ,390 + ,1895 + ,385 + ,397 + ,398 + ,406 + ,413 + ,2475 + ,390 + ,385 + ,397 + ,398 + ,413 + ,1793 + ,413 + ,390 + ,385 + ,397 + ,401 + ,2308 + ,413 + ,413 + ,390 + ,385 + ,397 + ,2051 + ,401 + ,413 + ,413 + ,390 + ,397 + ,1898 + ,397 + ,401 + ,413 + ,413 + ,409 + ,2142 + ,397 + ,397 + ,401 + ,413 + ,419 + ,1874 + ,409 + ,397 + ,397 + ,401 + ,424 + ,1560 + ,419 + ,409 + ,397 + ,397 + ,428 + ,1808 + ,424 + ,419 + ,409 + ,397 + ,430 + ,1575 + ,428 + ,424 + ,419 + ,409 + ,424 + ,1525 + ,430 + ,428 + ,424 + ,419 + ,433 + ,1997 + ,424 + ,430 + ,428 + ,424 + ,456 + ,1753 + ,433 + ,424 + ,430 + ,428 + ,459 + ,1623 + ,456 + ,433 + ,424 + ,430 + ,446 + ,2251 + ,459 + ,456 + ,433 + ,424 + ,441 + ,1890 + ,446 + ,459 + ,456 + ,433) + ,dim=c(6 + ,57) + ,dimnames=list(c('wkl' + ,'bvg' + ,'Y1' + ,'Y2' + ,'Y3' + ,'Y4') + ,1:57)) > y <- array(NA,dim=c(6,57),dimnames=list(c('wkl','bvg','Y1','Y2','Y3','Y4'),1:57)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par3 = 'Linear Trend' > par2 = 'Include Monthly Dummies' > par1 = '1' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > library(lattice) > library(lmtest) Loading required package: zoo Attaching package: 'zoo' The following object(s) are masked from package:base : as.Date.numeric > n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test > par1 <- as.numeric(par1) > x <- t(y) > k <- length(x[1,]) > n <- length(x[,1]) > x1 <- cbind(x[,par1], x[,1:k!=par1]) > mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1]) > colnames(x1) <- mycolnames #colnames(x)[par1] > x <- x1 > if (par3 == 'First Differences'){ + x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep=''))) + for (i in 1:n-1) { + for (j in 1:k) { + x2[i,j] <- x[i+1,j] - x[i,j] + } + } + x <- x2 + } > if (par2 == 'Include Monthly Dummies'){ + x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep =''))) + for (i in 1:11){ + x2[seq(i,n,12),i] <- 1 + } + x <- cbind(x, x2) + } > if (par2 == 'Include Quarterly Dummies'){ + x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep =''))) + for (i in 1:3){ + x2[seq(i,n,4),i] <- 1 + } + x <- cbind(x, x2) + } > k <- length(x[1,]) > if (par3 == 'Linear Trend'){ + x <- cbind(x, c(1:n)) + colnames(x)[k+1] <- 't' + } > x wkl bvg Y1 Y2 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 463 1802 461 461 455 462 1 0 0 0 0 0 0 0 0 0 0 1 2 462 1863 463 461 461 455 0 1 0 0 0 0 0 0 0 0 0 2 3 456 1989 462 463 461 461 0 0 1 0 0 0 0 0 0 0 0 3 4 455 2197 456 462 463 461 0 0 0 1 0 0 0 0 0 0 0 4 5 456 2409 455 456 462 463 0 0 0 0 1 0 0 0 0 0 0 5 6 472 2502 456 455 456 462 0 0 0 0 0 1 0 0 0 0 0 6 7 472 2593 472 456 455 456 0 0 0 0 0 0 1 0 0 0 0 7 8 471 2598 472 472 456 455 0 0 0 0 0 0 0 1 0 0 0 8 9 465 2053 471 472 472 456 0 0 0 0 0 0 0 0 1 0 0 9 10 459 2213 465 471 472 472 0 0 0 0 0 0 0 0 0 1 0 10 11 465 2238 459 465 471 472 0 0 0 0 0 0 0 0 0 0 1 11 12 468 2359 465 459 465 471 0 0 0 0 0 0 0 0 0 0 0 12 13 467 2151 468 465 459 465 1 0 0 0 0 0 0 0 0 0 0 13 14 463 2474 467 468 465 459 0 1 0 0 0 0 0 0 0 0 0 14 15 460 3079 463 467 468 465 0 0 1 0 0 0 0 0 0 0 0 15 16 462 2312 460 463 467 468 0 0 0 1 0 0 0 0 0 0 0 16 17 461 2565 462 460 463 467 0 0 0 0 1 0 0 0 0 0 0 17 18 476 1972 461 462 460 463 0 0 0 0 0 1 0 0 0 0 0 18 19 476 2484 476 461 462 460 0 0 0 0 0 0 1 0 0 0 0 19 20 471 2202 476 476 461 462 0 0 0 0 0 0 0 1 0 0 0 20 21 453 2151 471 476 476 461 0 0 0 0 0 0 0 0 1 0 0 21 22 443 1976 453 471 476 476 0 0 0 0 0 0 0 0 0 1 0 22 23 442 2012 443 453 471 476 0 0 0 0 0 0 0 0 0 0 1 23 24 444 2114 442 443 453 471 0 0 0 0 0 0 0 0 0 0 0 24 25 438 1772 444 442 443 453 1 0 0 0 0 0 0 0 0 0 0 25 26 427 1957 438 444 442 443 0 1 0 0 0 0 0 0 0 0 0 26 27 424 2070 427 438 444 442 0 0 1 0 0 0 0 0 0 0 0 27 28 416 1990 424 427 438 444 0 0 0 1 0 0 0 0 0 0 0 28 29 406 2182 416 424 427 438 0 0 0 0 1 0 0 0 0 0 0 29 30 431 2008 406 416 424 427 0 0 0 0 0 1 0 0 0 0 0 30 31 434 1916 431 406 416 424 0 0 0 0 0 0 1 0 0 0 0 31 32 418 2397 434 431 406 416 0 0 0 0 0 0 0 1 0 0 0 32 33 412 2114 418 434 431 406 0 0 0 0 0 0 0 0 1 0 0 33 34 404 1778 412 418 434 431 0 0 0 0 0 0 0 0 0 1 0 34 35 409 1641 404 412 418 434 0 0 0 0 0 0 0 0 0 0 1 35 36 412 2186 409 404 412 418 0 0 0 0 0 0 0 0 0 0 0 36 37 406 1773 412 409 404 412 1 0 0 0 0 0 0 0 0 0 0 37 38 398 1785 406 412 409 404 0 1 0 0 0 0 0 0 0 0 0 38 39 397 2217 398 406 412 409 0 0 1 0 0 0 0 0 0 0 0 39 40 385 2153 397 398 406 412 0 0 0 1 0 0 0 0 0 0 0 40 41 390 1895 385 397 398 406 0 0 0 0 1 0 0 0 0 0 0 41 42 413 2475 390 385 397 398 0 0 0 0 0 1 0 0 0 0 0 42 43 413 1793 413 390 385 397 0 0 0 0 0 0 1 0 0 0 0 43 44 401 2308 413 413 390 385 0 0 0 0 0 0 0 1 0 0 0 44 45 397 2051 401 413 413 390 0 0 0 0 0 0 0 0 1 0 0 45 46 397 1898 397 401 413 413 0 0 0 0 0 0 0 0 0 1 0 46 47 409 2142 397 397 401 413 0 0 0 0 0 0 0 0 0 0 1 47 48 419 1874 409 397 397 401 0 0 0 0 0 0 0 0 0 0 0 48 49 424 1560 419 409 397 397 1 0 0 0 0 0 0 0 0 0 0 49 50 428 1808 424 419 409 397 0 1 0 0 0 0 0 0 0 0 0 50 51 430 1575 428 424 419 409 0 0 1 0 0 0 0 0 0 0 0 51 52 424 1525 430 428 424 419 0 0 0 1 0 0 0 0 0 0 0 52 53 433 1997 424 430 428 424 0 0 0 0 1 0 0 0 0 0 0 53 54 456 1753 433 424 430 428 0 0 0 0 0 1 0 0 0 0 0 54 55 459 1623 456 433 424 430 0 0 0 0 0 0 1 0 0 0 0 55 56 446 2251 459 456 433 424 0 0 0 0 0 0 0 1 0 0 0 56 57 441 1890 446 459 456 433 0 0 0 0 0 0 0 0 1 0 0 57 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) bvg Y1 Y2 Y3 Y4 38.521096 -0.001521 1.098984 -0.082395 0.409148 -0.483747 M1 M2 M3 M4 M5 M6 -7.658921 -15.013007 -11.293830 -12.133417 -4.629920 13.410054 M7 M8 M9 M10 M11 t -6.784556 -18.090000 -23.806852 -12.952858 2.413947 -0.068808 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -7.6444 -2.9062 0.4764 2.5887 8.7736 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 38.521096 22.308104 1.727 0.092122 . bvg -0.001521 0.002951 -0.515 0.609190 Y1 1.098984 0.143791 7.643 2.85e-09 *** Y2 -0.082395 0.220760 -0.373 0.710998 Y3 0.409148 0.226494 1.806 0.078570 . Y4 -0.483747 0.157295 -3.075 0.003830 ** M1 -7.658921 3.784777 -2.024 0.049901 * M2 -15.013007 4.295187 -3.495 0.001196 ** M3 -11.293830 4.014019 -2.814 0.007636 ** M4 -12.133417 3.601294 -3.369 0.001709 ** M5 -4.629920 3.654506 -1.267 0.212702 M6 13.410054 3.392235 3.953 0.000315 *** M7 -6.784556 3.848867 -1.763 0.085780 . M8 -18.090000 5.252776 -3.444 0.001384 ** M9 -23.806852 5.934347 -4.012 0.000264 *** M10 -12.952858 4.268398 -3.035 0.004274 ** M11 2.413947 3.746094 0.644 0.523095 t -0.068808 0.075876 -0.907 0.370056 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 4.711 on 39 degrees of freedom Multiple R-squared: 0.9779, Adjusted R-squared: 0.9683 F-statistic: 101.6 on 17 and 39 DF, p-value: < 2.2e-16 > if (n > n25) { + kp3 <- k + 3 + nmkm3 <- n - k - 3 + gqarr <- array(NA, dim=c(nmkm3-kp3+1,3)) + numgqtests <- 0 + numsignificant1 <- 0 + numsignificant5 <- 0 + numsignificant10 <- 0 + for (mypoint in kp3:nmkm3) { + j <- 0 + numgqtests <- numgqtests + 1 + for (myalt in c('greater', 'two.sided', 'less')) { + j <- j + 1 + gqarr[mypoint-kp3+1,j] <- gqtest(mylm, point=mypoint, alternative=myalt)$p.value + } + if (gqarr[mypoint-kp3+1,2] < 0.01) numsignificant1 <- numsignificant1 + 1 + if (gqarr[mypoint-kp3+1,2] < 0.05) numsignificant5 <- numsignificant5 + 1 + if (gqarr[mypoint-kp3+1,2] < 0.10) numsignificant10 <- numsignificant10 + 1 + } + gqarr + } [,1] [,2] [,3] [1,] 0.5072768 0.98544631 0.49272315 [2,] 0.4130923 0.82618470 0.58690765 [3,] 0.3597732 0.71954644 0.64022678 [4,] 0.4014801 0.80296021 0.59851989 [5,] 0.3258122 0.65162447 0.67418776 [6,] 0.2158548 0.43170953 0.78414523 [7,] 0.2537657 0.50753133 0.74623434 [8,] 0.3138463 0.62769251 0.68615375 [9,] 0.4846393 0.96927870 0.51536065 [10,] 0.8955566 0.20888672 0.10444336 [11,] 0.9898372 0.02032566 0.01016283 [12,] 0.9809801 0.03803985 0.01901993 [13,] 0.9544439 0.09111221 0.04555611 [14,] 0.9223831 0.15523383 0.07761692 [15,] 0.9562595 0.08748096 0.04374048 [16,] 0.9502743 0.09945144 0.04972572 > postscript(file="/var/www/html/rcomp/tmp/1lr1f1258744456.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/2j0pg1258744456.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/363rb1258744456.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/4qn781258744456.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/50f661258744456.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 = 57 Frequency = 1 1 2 3 4 5 6 7 3.6281262 2.1047099 -3.1877729 2.7301811 -1.4008201 -2.4407790 -2.0336413 8 9 10 11 12 13 14 8.7736353 2.7667654 0.4763797 -2.2749106 -1.7252565 1.4359517 1.3388930 15 16 17 18 19 20 21 1.5972426 8.1668720 -1.1753360 -4.4921620 -2.2867372 6.2711843 -7.1467721 22 23 24 25 26 27 28 -1.5721749 -6.2629425 3.5959162 -2.0928219 -3.0581879 0.7557172 -0.6445663 29 30 31 32 33 34 35 -7.6444046 5.3567073 2.0036011 -2.9061723 -0.7861709 -3.9405654 1.8481909 36 37 38 39 40 41 42 -3.2793012 -4.6939747 -4.3274570 1.1679937 -5.6749928 4.9740467 0.9405183 43 44 45 46 47 48 49 -0.2719417 -6.0700523 1.5208693 5.0363606 6.6896622 1.4086415 1.7227186 50 51 52 53 54 55 56 3.9420421 -0.3331805 -4.5774941 5.2465140 0.6357154 2.5887191 -6.0685950 57 3.6453083 > postscript(file="/var/www/html/rcomp/tmp/67cf01258744456.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 = 57 Frequency = 1 lag(myerror, k = 1) myerror 0 3.6281262 NA 1 2.1047099 3.6281262 2 -3.1877729 2.1047099 3 2.7301811 -3.1877729 4 -1.4008201 2.7301811 5 -2.4407790 -1.4008201 6 -2.0336413 -2.4407790 7 8.7736353 -2.0336413 8 2.7667654 8.7736353 9 0.4763797 2.7667654 10 -2.2749106 0.4763797 11 -1.7252565 -2.2749106 12 1.4359517 -1.7252565 13 1.3388930 1.4359517 14 1.5972426 1.3388930 15 8.1668720 1.5972426 16 -1.1753360 8.1668720 17 -4.4921620 -1.1753360 18 -2.2867372 -4.4921620 19 6.2711843 -2.2867372 20 -7.1467721 6.2711843 21 -1.5721749 -7.1467721 22 -6.2629425 -1.5721749 23 3.5959162 -6.2629425 24 -2.0928219 3.5959162 25 -3.0581879 -2.0928219 26 0.7557172 -3.0581879 27 -0.6445663 0.7557172 28 -7.6444046 -0.6445663 29 5.3567073 -7.6444046 30 2.0036011 5.3567073 31 -2.9061723 2.0036011 32 -0.7861709 -2.9061723 33 -3.9405654 -0.7861709 34 1.8481909 -3.9405654 35 -3.2793012 1.8481909 36 -4.6939747 -3.2793012 37 -4.3274570 -4.6939747 38 1.1679937 -4.3274570 39 -5.6749928 1.1679937 40 4.9740467 -5.6749928 41 0.9405183 4.9740467 42 -0.2719417 0.9405183 43 -6.0700523 -0.2719417 44 1.5208693 -6.0700523 45 5.0363606 1.5208693 46 6.6896622 5.0363606 47 1.4086415 6.6896622 48 1.7227186 1.4086415 49 3.9420421 1.7227186 50 -0.3331805 3.9420421 51 -4.5774941 -0.3331805 52 5.2465140 -4.5774941 53 0.6357154 5.2465140 54 2.5887191 0.6357154 55 -6.0685950 2.5887191 56 3.6453083 -6.0685950 57 NA 3.6453083 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 2.1047099 3.6281262 [2,] -3.1877729 2.1047099 [3,] 2.7301811 -3.1877729 [4,] -1.4008201 2.7301811 [5,] -2.4407790 -1.4008201 [6,] -2.0336413 -2.4407790 [7,] 8.7736353 -2.0336413 [8,] 2.7667654 8.7736353 [9,] 0.4763797 2.7667654 [10,] -2.2749106 0.4763797 [11,] -1.7252565 -2.2749106 [12,] 1.4359517 -1.7252565 [13,] 1.3388930 1.4359517 [14,] 1.5972426 1.3388930 [15,] 8.1668720 1.5972426 [16,] -1.1753360 8.1668720 [17,] -4.4921620 -1.1753360 [18,] -2.2867372 -4.4921620 [19,] 6.2711843 -2.2867372 [20,] -7.1467721 6.2711843 [21,] -1.5721749 -7.1467721 [22,] -6.2629425 -1.5721749 [23,] 3.5959162 -6.2629425 [24,] -2.0928219 3.5959162 [25,] -3.0581879 -2.0928219 [26,] 0.7557172 -3.0581879 [27,] -0.6445663 0.7557172 [28,] -7.6444046 -0.6445663 [29,] 5.3567073 -7.6444046 [30,] 2.0036011 5.3567073 [31,] -2.9061723 2.0036011 [32,] -0.7861709 -2.9061723 [33,] -3.9405654 -0.7861709 [34,] 1.8481909 -3.9405654 [35,] -3.2793012 1.8481909 [36,] -4.6939747 -3.2793012 [37,] -4.3274570 -4.6939747 [38,] 1.1679937 -4.3274570 [39,] -5.6749928 1.1679937 [40,] 4.9740467 -5.6749928 [41,] 0.9405183 4.9740467 [42,] -0.2719417 0.9405183 [43,] -6.0700523 -0.2719417 [44,] 1.5208693 -6.0700523 [45,] 5.0363606 1.5208693 [46,] 6.6896622 5.0363606 [47,] 1.4086415 6.6896622 [48,] 1.7227186 1.4086415 [49,] 3.9420421 1.7227186 [50,] -0.3331805 3.9420421 [51,] -4.5774941 -0.3331805 [52,] 5.2465140 -4.5774941 [53,] 0.6357154 5.2465140 [54,] 2.5887191 0.6357154 [55,] -6.0685950 2.5887191 [56,] 3.6453083 -6.0685950 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 2.1047099 3.6281262 2 -3.1877729 2.1047099 3 2.7301811 -3.1877729 4 -1.4008201 2.7301811 5 -2.4407790 -1.4008201 6 -2.0336413 -2.4407790 7 8.7736353 -2.0336413 8 2.7667654 8.7736353 9 0.4763797 2.7667654 10 -2.2749106 0.4763797 11 -1.7252565 -2.2749106 12 1.4359517 -1.7252565 13 1.3388930 1.4359517 14 1.5972426 1.3388930 15 8.1668720 1.5972426 16 -1.1753360 8.1668720 17 -4.4921620 -1.1753360 18 -2.2867372 -4.4921620 19 6.2711843 -2.2867372 20 -7.1467721 6.2711843 21 -1.5721749 -7.1467721 22 -6.2629425 -1.5721749 23 3.5959162 -6.2629425 24 -2.0928219 3.5959162 25 -3.0581879 -2.0928219 26 0.7557172 -3.0581879 27 -0.6445663 0.7557172 28 -7.6444046 -0.6445663 29 5.3567073 -7.6444046 30 2.0036011 5.3567073 31 -2.9061723 2.0036011 32 -0.7861709 -2.9061723 33 -3.9405654 -0.7861709 34 1.8481909 -3.9405654 35 -3.2793012 1.8481909 36 -4.6939747 -3.2793012 37 -4.3274570 -4.6939747 38 1.1679937 -4.3274570 39 -5.6749928 1.1679937 40 4.9740467 -5.6749928 41 0.9405183 4.9740467 42 -0.2719417 0.9405183 43 -6.0700523 -0.2719417 44 1.5208693 -6.0700523 45 5.0363606 1.5208693 46 6.6896622 5.0363606 47 1.4086415 6.6896622 48 1.7227186 1.4086415 49 3.9420421 1.7227186 50 -0.3331805 3.9420421 51 -4.5774941 -0.3331805 52 5.2465140 -4.5774941 53 0.6357154 5.2465140 54 2.5887191 0.6357154 55 -6.0685950 2.5887191 56 3.6453083 -6.0685950 > 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/75gte1258744456.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/8ihaw1258744456.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/905yi1258744456.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/10hagw1258744456.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/11s5m51258744456.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/122siw1258744456.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/13sktt1258744456.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/14ftzf1258744456.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/15g7hq1258744456.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/166itp1258744456.tab") + } > > system("convert tmp/1lr1f1258744456.ps tmp/1lr1f1258744456.png") > system("convert tmp/2j0pg1258744456.ps tmp/2j0pg1258744456.png") > system("convert tmp/363rb1258744456.ps tmp/363rb1258744456.png") > system("convert tmp/4qn781258744456.ps tmp/4qn781258744456.png") > system("convert tmp/50f661258744456.ps tmp/50f661258744456.png") > system("convert tmp/67cf01258744456.ps tmp/67cf01258744456.png") > system("convert tmp/75gte1258744456.ps tmp/75gte1258744456.png") > system("convert tmp/8ihaw1258744456.ps tmp/8ihaw1258744456.png") > system("convert tmp/905yi1258744456.ps tmp/905yi1258744456.png") > system("convert tmp/10hagw1258744456.ps tmp/10hagw1258744456.png") > > > proc.time() user system elapsed 2.358 1.553 2.762