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(96.92 + ,148.3 + ,98.2 + ,98.54 + ,99.06 + ,152.2 + ,96.92 + ,98.2 + ,99.65 + ,169.4 + ,99.06 + ,96.92 + ,99.82 + ,168.6 + ,99.65 + ,99.06 + ,99.99 + ,161.1 + ,99.82 + ,99.65 + ,100.33 + ,174.1 + ,99.99 + ,99.82 + ,99.31 + ,179 + ,100.33 + ,99.99 + ,101.1 + ,190.6 + ,99.31 + ,100.33 + ,101.1 + ,190 + ,101.1 + ,99.31 + ,100.93 + ,181.6 + ,101.1 + ,101.1 + ,100.85 + ,174.8 + ,100.93 + ,101.1 + ,100.93 + ,180.5 + ,100.85 + ,100.93 + ,99.6 + ,196.8 + ,100.93 + ,100.85 + ,101.88 + ,193.8 + ,99.6 + ,100.93 + ,101.81 + ,197 + ,101.88 + ,99.6 + ,102.38 + ,216.3 + ,101.81 + ,101.88 + ,102.74 + ,221.4 + ,102.38 + ,101.81 + ,102.82 + ,217.9 + ,102.74 + ,102.38 + ,101.72 + ,229.7 + ,102.82 + ,102.74 + ,103.47 + ,227.4 + ,101.72 + ,102.82 + ,102.98 + ,204.2 + ,103.47 + ,101.72 + ,102.68 + ,196.6 + ,102.98 + ,103.47 + ,102.9 + ,198.8 + ,102.68 + ,102.98 + ,103.03 + ,207.5 + ,102.9 + ,102.68 + ,101.29 + ,190.7 + ,103.03 + ,102.9 + ,103.69 + ,201.6 + ,101.29 + ,103.03 + ,103.68 + ,210.5 + ,103.69 + ,101.29 + ,104.2 + ,223.5 + ,103.68 + ,103.69 + ,104.08 + ,223.8 + ,104.2 + ,103.68 + ,104.16 + ,231.2 + ,104.08 + ,104.2 + ,103.05 + ,244 + ,104.16 + ,104.08 + ,104.66 + ,234.7 + ,103.05 + ,104.16 + ,104.46 + ,250.2 + ,104.66 + ,103.05 + ,104.95 + ,265.7 + ,104.46 + ,104.66 + ,105.85 + ,287.6 + ,104.95 + ,104.46 + ,106.23 + ,283.3 + ,105.85 + ,104.95 + ,104.86 + ,295.4 + ,106.23 + ,105.85 + ,107.44 + ,312.3 + ,104.86 + ,106.23 + ,108.23 + ,333.8 + ,107.44 + ,104.86 + ,108.45 + ,347.7 + ,108.23 + ,107.44 + ,109.39 + ,383.2 + ,108.45 + ,108.23 + ,110.15 + ,407.1 + ,109.39 + ,108.45 + ,109.13 + ,413.6 + ,110.15 + ,109.39 + ,110.28 + ,362.7 + ,109.13 + ,110.15 + ,110.17 + ,321.9 + ,110.28 + ,109.13 + ,109.99 + ,239.4 + ,110.17 + ,110.28 + ,109.26 + ,191 + ,109.99 + ,110.17 + ,109.11 + ,159.7 + ,109.26 + ,109.99 + ,107.06 + ,163.4 + ,109.11 + ,109.26 + ,109.53 + ,157.6 + ,107.06 + ,109.11 + ,108.92 + ,166.2 + ,109.53 + ,107.06 + ,109.24 + ,176.7 + ,108.92 + ,109.53 + ,109.12 + ,198.3 + ,109.24 + ,108.92 + ,109 + ,226.2 + ,109.12 + ,109.24 + ,107.23 + ,216.2 + ,109 + ,109.12 + ,109.49 + ,235.9 + ,107.23 + ,109 + ,109.04 + ,226.9 + ,109.49 + ,107.23) + ,dim=c(4 + ,57) + ,dimnames=list(c('Y' + ,'X' + ,'Y1' + ,'Y2') + ,1:57)) > y <- array(NA,dim=c(4,57),dimnames=list(c('Y','X','Y1','Y2'),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 Y X Y1 Y2 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 96.92 148.3 98.20 98.54 1 0 0 0 0 0 0 0 0 0 0 1 2 99.06 152.2 96.92 98.20 0 1 0 0 0 0 0 0 0 0 0 2 3 99.65 169.4 99.06 96.92 0 0 1 0 0 0 0 0 0 0 0 3 4 99.82 168.6 99.65 99.06 0 0 0 1 0 0 0 0 0 0 0 4 5 99.99 161.1 99.82 99.65 0 0 0 0 1 0 0 0 0 0 0 5 6 100.33 174.1 99.99 99.82 0 0 0 0 0 1 0 0 0 0 0 6 7 99.31 179.0 100.33 99.99 0 0 0 0 0 0 1 0 0 0 0 7 8 101.10 190.6 99.31 100.33 0 0 0 0 0 0 0 1 0 0 0 8 9 101.10 190.0 101.10 99.31 0 0 0 0 0 0 0 0 1 0 0 9 10 100.93 181.6 101.10 101.10 0 0 0 0 0 0 0 0 0 1 0 10 11 100.85 174.8 100.93 101.10 0 0 0 0 0 0 0 0 0 0 1 11 12 100.93 180.5 100.85 100.93 0 0 0 0 0 0 0 0 0 0 0 12 13 99.60 196.8 100.93 100.85 1 0 0 0 0 0 0 0 0 0 0 13 14 101.88 193.8 99.60 100.93 0 1 0 0 0 0 0 0 0 0 0 14 15 101.81 197.0 101.88 99.60 0 0 1 0 0 0 0 0 0 0 0 15 16 102.38 216.3 101.81 101.88 0 0 0 1 0 0 0 0 0 0 0 16 17 102.74 221.4 102.38 101.81 0 0 0 0 1 0 0 0 0 0 0 17 18 102.82 217.9 102.74 102.38 0 0 0 0 0 1 0 0 0 0 0 18 19 101.72 229.7 102.82 102.74 0 0 0 0 0 0 1 0 0 0 0 19 20 103.47 227.4 101.72 102.82 0 0 0 0 0 0 0 1 0 0 0 20 21 102.98 204.2 103.47 101.72 0 0 0 0 0 0 0 0 1 0 0 21 22 102.68 196.6 102.98 103.47 0 0 0 0 0 0 0 0 0 1 0 22 23 102.90 198.8 102.68 102.98 0 0 0 0 0 0 0 0 0 0 1 23 24 103.03 207.5 102.90 102.68 0 0 0 0 0 0 0 0 0 0 0 24 25 101.29 190.7 103.03 102.90 1 0 0 0 0 0 0 0 0 0 0 25 26 103.69 201.6 101.29 103.03 0 1 0 0 0 0 0 0 0 0 0 26 27 103.68 210.5 103.69 101.29 0 0 1 0 0 0 0 0 0 0 0 27 28 104.20 223.5 103.68 103.69 0 0 0 1 0 0 0 0 0 0 0 28 29 104.08 223.8 104.20 103.68 0 0 0 0 1 0 0 0 0 0 0 29 30 104.16 231.2 104.08 104.20 0 0 0 0 0 1 0 0 0 0 0 30 31 103.05 244.0 104.16 104.08 0 0 0 0 0 0 1 0 0 0 0 31 32 104.66 234.7 103.05 104.16 0 0 0 0 0 0 0 1 0 0 0 32 33 104.46 250.2 104.66 103.05 0 0 0 0 0 0 0 0 1 0 0 33 34 104.95 265.7 104.46 104.66 0 0 0 0 0 0 0 0 0 1 0 34 35 105.85 287.6 104.95 104.46 0 0 0 0 0 0 0 0 0 0 1 35 36 106.23 283.3 105.85 104.95 0 0 0 0 0 0 0 0 0 0 0 36 37 104.86 295.4 106.23 105.85 1 0 0 0 0 0 0 0 0 0 0 37 38 107.44 312.3 104.86 106.23 0 1 0 0 0 0 0 0 0 0 0 38 39 108.23 333.8 107.44 104.86 0 0 1 0 0 0 0 0 0 0 0 39 40 108.45 347.7 108.23 107.44 0 0 0 1 0 0 0 0 0 0 0 40 41 109.39 383.2 108.45 108.23 0 0 0 0 1 0 0 0 0 0 0 41 42 110.15 407.1 109.39 108.45 0 0 0 0 0 1 0 0 0 0 0 42 43 109.13 413.6 110.15 109.39 0 0 0 0 0 0 1 0 0 0 0 43 44 110.28 362.7 109.13 110.15 0 0 0 0 0 0 0 1 0 0 0 44 45 110.17 321.9 110.28 109.13 0 0 0 0 0 0 0 0 1 0 0 45 46 109.99 239.4 110.17 110.28 0 0 0 0 0 0 0 0 0 1 0 46 47 109.26 191.0 109.99 110.17 0 0 0 0 0 0 0 0 0 0 1 47 48 109.11 159.7 109.26 109.99 0 0 0 0 0 0 0 0 0 0 0 48 49 107.06 163.4 109.11 109.26 1 0 0 0 0 0 0 0 0 0 0 49 50 109.53 157.6 107.06 109.11 0 1 0 0 0 0 0 0 0 0 0 50 51 108.92 166.2 109.53 107.06 0 0 1 0 0 0 0 0 0 0 0 51 52 109.24 176.7 108.92 109.53 0 0 0 1 0 0 0 0 0 0 0 52 53 109.12 198.3 109.24 108.92 0 0 0 0 1 0 0 0 0 0 0 53 54 109.00 226.2 109.12 109.24 0 0 0 0 0 1 0 0 0 0 0 54 55 107.23 216.2 109.00 109.12 0 0 0 0 0 0 1 0 0 0 0 55 56 109.49 235.9 107.23 109.00 0 0 0 0 0 0 0 1 0 0 0 56 57 109.04 226.9 109.49 107.23 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) X Y1 Y2 M1 M2 15.862808 0.005488 0.547489 0.284805 -1.720614 1.450338 M3 M4 M5 M6 M7 M8 0.642971 0.166917 0.093132 -0.014504 -1.464946 0.852531 M9 M10 M11 t 0.048899 -0.261059 -0.085038 0.023012 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -0.557294 -0.163907 0.002809 0.129784 0.512009 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 15.8628084 4.2896395 3.698 0.000638 *** X 0.0054885 0.0008545 6.423 1.08e-07 *** Y1 0.5474891 0.1374757 3.982 0.000273 *** Y2 0.2848049 0.1289307 2.209 0.032822 * M1 -1.7206141 0.1807498 -9.519 6.10e-12 *** M2 1.4503383 0.2932000 4.947 1.33e-05 *** M3 0.6429706 0.3416281 1.882 0.066937 . M4 0.1669169 0.1807103 0.924 0.361062 M5 0.0931323 0.1826589 0.510 0.612876 M6 -0.0145037 0.1822573 -0.080 0.936960 M7 -1.4649456 0.1826195 -8.022 6.19e-10 *** M8 0.8525315 0.2652558 3.214 0.002552 ** M9 0.0488988 0.2704487 0.181 0.857411 M10 -0.2610593 0.1953144 -1.337 0.188720 M11 -0.0850383 0.1908207 -0.446 0.658198 t 0.0230124 0.0092104 2.499 0.016572 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.2685 on 41 degrees of freedom Multiple R-squared: 0.9962, Adjusted R-squared: 0.9947 F-statistic: 708.2 on 15 and 41 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.2263898696 0.452779739 0.7736101 [2,] 0.1292813865 0.258562773 0.8707186 [3,] 0.0674370656 0.134874131 0.9325629 [4,] 0.0306494994 0.061298999 0.9693505 [5,] 0.0150687757 0.030137551 0.9849312 [6,] 0.0055383445 0.011076689 0.9944617 [7,] 0.0034633024 0.006926605 0.9965367 [8,] 0.0029424465 0.005884893 0.9970576 [9,] 0.0012986441 0.002597288 0.9987014 [10,] 0.0005041847 0.001008369 0.9994958 [11,] 0.0014293290 0.002858658 0.9985707 [12,] 0.0029110005 0.005822001 0.9970890 [13,] 0.0028563762 0.005712752 0.9971436 [14,] 0.0020815339 0.004163068 0.9979185 [15,] 0.0021887265 0.004377453 0.9978113 [16,] 0.0014489827 0.002897965 0.9985510 [17,] 0.0045896653 0.009179331 0.9954103 [18,] 0.0108611411 0.021722282 0.9891389 [19,] 0.0136346507 0.027269301 0.9863653 [20,] 0.0097681225 0.019536245 0.9902319 > postscript(file="/var/www/html/rcomp/tmp/1ctkk1258723654.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/243ou1258723654.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/3nny71258723654.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/4drlr1258723654.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/5aa1t1258723654.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 0.112751205 -0.164998903 0.307878376 0.002809462 0.003637220 0.215420782 7 8 9 10 11 12 0.361393711 0.208843330 0.303252185 -0.043499698 -0.192138342 -0.159257303 13 14 15 16 17 18 0.097867719 -0.094255560 -0.266947986 0.039135061 0.129783710 -0.045817912 19 20 21 22 23 24 0.070518845 0.072106540 -0.154761313 -0.356242109 -0.043548979 -0.104355441 25 26 27 28 29 30 -0.188378101 -0.126560768 -0.219466150 0.004168304 -0.348552245 -0.306943132 31 32 33 34 35 36 -0.069388505 -0.163906655 -0.233681629 0.109154842 0.478615374 0.141870532 37 38 39 40 41 42 -0.061308392 -0.126194046 0.307820055 -0.262741278 0.187747000 0.323899419 43 44 45 46 47 48 0.011845627 -0.557293655 -0.001855421 0.290586965 -0.242928053 0.121742211 49 50 51 52 53 54 0.039067568 0.512009276 -0.129284295 0.216628452 0.027384314 -0.186559158 55 56 57 -0.374369677 0.440250439 0.087046178 > postscript(file="/var/www/html/rcomp/tmp/6kktg1258723654.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 0.112751205 NA 1 -0.164998903 0.112751205 2 0.307878376 -0.164998903 3 0.002809462 0.307878376 4 0.003637220 0.002809462 5 0.215420782 0.003637220 6 0.361393711 0.215420782 7 0.208843330 0.361393711 8 0.303252185 0.208843330 9 -0.043499698 0.303252185 10 -0.192138342 -0.043499698 11 -0.159257303 -0.192138342 12 0.097867719 -0.159257303 13 -0.094255560 0.097867719 14 -0.266947986 -0.094255560 15 0.039135061 -0.266947986 16 0.129783710 0.039135061 17 -0.045817912 0.129783710 18 0.070518845 -0.045817912 19 0.072106540 0.070518845 20 -0.154761313 0.072106540 21 -0.356242109 -0.154761313 22 -0.043548979 -0.356242109 23 -0.104355441 -0.043548979 24 -0.188378101 -0.104355441 25 -0.126560768 -0.188378101 26 -0.219466150 -0.126560768 27 0.004168304 -0.219466150 28 -0.348552245 0.004168304 29 -0.306943132 -0.348552245 30 -0.069388505 -0.306943132 31 -0.163906655 -0.069388505 32 -0.233681629 -0.163906655 33 0.109154842 -0.233681629 34 0.478615374 0.109154842 35 0.141870532 0.478615374 36 -0.061308392 0.141870532 37 -0.126194046 -0.061308392 38 0.307820055 -0.126194046 39 -0.262741278 0.307820055 40 0.187747000 -0.262741278 41 0.323899419 0.187747000 42 0.011845627 0.323899419 43 -0.557293655 0.011845627 44 -0.001855421 -0.557293655 45 0.290586965 -0.001855421 46 -0.242928053 0.290586965 47 0.121742211 -0.242928053 48 0.039067568 0.121742211 49 0.512009276 0.039067568 50 -0.129284295 0.512009276 51 0.216628452 -0.129284295 52 0.027384314 0.216628452 53 -0.186559158 0.027384314 54 -0.374369677 -0.186559158 55 0.440250439 -0.374369677 56 0.087046178 0.440250439 57 NA 0.087046178 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -0.164998903 0.112751205 [2,] 0.307878376 -0.164998903 [3,] 0.002809462 0.307878376 [4,] 0.003637220 0.002809462 [5,] 0.215420782 0.003637220 [6,] 0.361393711 0.215420782 [7,] 0.208843330 0.361393711 [8,] 0.303252185 0.208843330 [9,] -0.043499698 0.303252185 [10,] -0.192138342 -0.043499698 [11,] -0.159257303 -0.192138342 [12,] 0.097867719 -0.159257303 [13,] -0.094255560 0.097867719 [14,] -0.266947986 -0.094255560 [15,] 0.039135061 -0.266947986 [16,] 0.129783710 0.039135061 [17,] -0.045817912 0.129783710 [18,] 0.070518845 -0.045817912 [19,] 0.072106540 0.070518845 [20,] -0.154761313 0.072106540 [21,] -0.356242109 -0.154761313 [22,] -0.043548979 -0.356242109 [23,] -0.104355441 -0.043548979 [24,] -0.188378101 -0.104355441 [25,] -0.126560768 -0.188378101 [26,] -0.219466150 -0.126560768 [27,] 0.004168304 -0.219466150 [28,] -0.348552245 0.004168304 [29,] -0.306943132 -0.348552245 [30,] -0.069388505 -0.306943132 [31,] -0.163906655 -0.069388505 [32,] -0.233681629 -0.163906655 [33,] 0.109154842 -0.233681629 [34,] 0.478615374 0.109154842 [35,] 0.141870532 0.478615374 [36,] -0.061308392 0.141870532 [37,] -0.126194046 -0.061308392 [38,] 0.307820055 -0.126194046 [39,] -0.262741278 0.307820055 [40,] 0.187747000 -0.262741278 [41,] 0.323899419 0.187747000 [42,] 0.011845627 0.323899419 [43,] -0.557293655 0.011845627 [44,] -0.001855421 -0.557293655 [45,] 0.290586965 -0.001855421 [46,] -0.242928053 0.290586965 [47,] 0.121742211 -0.242928053 [48,] 0.039067568 0.121742211 [49,] 0.512009276 0.039067568 [50,] -0.129284295 0.512009276 [51,] 0.216628452 -0.129284295 [52,] 0.027384314 0.216628452 [53,] -0.186559158 0.027384314 [54,] -0.374369677 -0.186559158 [55,] 0.440250439 -0.374369677 [56,] 0.087046178 0.440250439 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -0.164998903 0.112751205 2 0.307878376 -0.164998903 3 0.002809462 0.307878376 4 0.003637220 0.002809462 5 0.215420782 0.003637220 6 0.361393711 0.215420782 7 0.208843330 0.361393711 8 0.303252185 0.208843330 9 -0.043499698 0.303252185 10 -0.192138342 -0.043499698 11 -0.159257303 -0.192138342 12 0.097867719 -0.159257303 13 -0.094255560 0.097867719 14 -0.266947986 -0.094255560 15 0.039135061 -0.266947986 16 0.129783710 0.039135061 17 -0.045817912 0.129783710 18 0.070518845 -0.045817912 19 0.072106540 0.070518845 20 -0.154761313 0.072106540 21 -0.356242109 -0.154761313 22 -0.043548979 -0.356242109 23 -0.104355441 -0.043548979 24 -0.188378101 -0.104355441 25 -0.126560768 -0.188378101 26 -0.219466150 -0.126560768 27 0.004168304 -0.219466150 28 -0.348552245 0.004168304 29 -0.306943132 -0.348552245 30 -0.069388505 -0.306943132 31 -0.163906655 -0.069388505 32 -0.233681629 -0.163906655 33 0.109154842 -0.233681629 34 0.478615374 0.109154842 35 0.141870532 0.478615374 36 -0.061308392 0.141870532 37 -0.126194046 -0.061308392 38 0.307820055 -0.126194046 39 -0.262741278 0.307820055 40 0.187747000 -0.262741278 41 0.323899419 0.187747000 42 0.011845627 0.323899419 43 -0.557293655 0.011845627 44 -0.001855421 -0.557293655 45 0.290586965 -0.001855421 46 -0.242928053 0.290586965 47 0.121742211 -0.242928053 48 0.039067568 0.121742211 49 0.512009276 0.039067568 50 -0.129284295 0.512009276 51 0.216628452 -0.129284295 52 0.027384314 0.216628452 53 -0.186559158 0.027384314 54 -0.374369677 -0.186559158 55 0.440250439 -0.374369677 56 0.087046178 0.440250439 > 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/7v8lx1258723654.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/8tro91258723654.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/96ckx1258723654.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/10r4v01258723654.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/11wuui1258723654.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/12dsii1258723654.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/13tckq1258723654.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/14tj7y1258723654.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/15gwgi1258723654.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/16fyrr1258723655.tab") + } > > system("convert tmp/1ctkk1258723654.ps tmp/1ctkk1258723654.png") > system("convert tmp/243ou1258723654.ps tmp/243ou1258723654.png") > system("convert tmp/3nny71258723654.ps tmp/3nny71258723654.png") > system("convert tmp/4drlr1258723654.ps tmp/4drlr1258723654.png") > system("convert tmp/5aa1t1258723654.ps tmp/5aa1t1258723654.png") > system("convert tmp/6kktg1258723654.ps tmp/6kktg1258723654.png") > system("convert tmp/7v8lx1258723654.ps tmp/7v8lx1258723654.png") > system("convert tmp/8tro91258723654.ps tmp/8tro91258723654.png") > system("convert tmp/96ckx1258723654.ps tmp/96ckx1258723654.png") > system("convert tmp/10r4v01258723654.ps tmp/10r4v01258723654.png") > > > proc.time() user system elapsed 2.394 1.570 3.489