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(20604.6,2.05,18714.9,2.03,18492.6,2.04,18183.6,2.03,19435.1,2.01,22686.8,2.01,20396.7,2.01,19233.6,2.01,22751,2.01,19864,2.01,17165.4,2.02,22309.7,2.02,21786.3,2.03,21927.6,2.05,20957.9,2.08,19726,2.07,21315.7,2.06,24771.5,2.05,22592.4,2.05,21942.1,2.05,23973.7,2.05,20815.7,2.05,19931.4,2.06,24436.8,2.06,22838.7,2.07,24465.3,2.07,23007.3,2.3,22720.8,2.31,23045.7,2.31,27198.5,2.53,22401.9,2.58,25122.7,2.59,26100.5,2.73,22904.9,2.82,22040.4,3,25981.5,3.04,26157.1,3.23,25975.4,3.32,22589.8,3.49,25370.4,3.57,25091.1,3.56,28760.9,3.72,24325.9,3.82,25821.7,3.82,27645.7,3.98,26296.9,4.06,24141.5,4.08,27268.1,4.19,29060.3,4.16,28226.4,4.17,23268.5,4.21,26938.2,4.21,27217.5,4.17,27540.5,4.19,29167.6,4.25,26671.5,4.25,30184,4.2,28422.3,4.33,23774.3,4.41,29601,4.56,28523.6,5.18,23622,3.42,21320.3,2.71,20423.6,2.29,21174.9,2,23050.2,1.64,21202.9,1.3,20476.4,1.08,23173.3,1,22468,1,19842.7,1),dim=c(2,71),dimnames=list(c('Y','X'),1:71)) > y <- array(NA,dim=c(2,71),dimnames=list(c('Y','X'),1:71)) > 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 20604.6 2.05 1 0 0 0 0 0 0 0 0 0 0 2 18714.9 2.03 0 1 0 0 0 0 0 0 0 0 0 3 18492.6 2.04 0 0 1 0 0 0 0 0 0 0 0 4 18183.6 2.03 0 0 0 1 0 0 0 0 0 0 0 5 19435.1 2.01 0 0 0 0 1 0 0 0 0 0 0 6 22686.8 2.01 0 0 0 0 0 1 0 0 0 0 0 7 20396.7 2.01 0 0 0 0 0 0 1 0 0 0 0 8 19233.6 2.01 0 0 0 0 0 0 0 1 0 0 0 9 22751.0 2.01 0 0 0 0 0 0 0 0 1 0 0 10 19864.0 2.01 0 0 0 0 0 0 0 0 0 1 0 11 17165.4 2.02 0 0 0 0 0 0 0 0 0 0 1 12 22309.7 2.02 0 0 0 0 0 0 0 0 0 0 0 13 21786.3 2.03 1 0 0 0 0 0 0 0 0 0 0 14 21927.6 2.05 0 1 0 0 0 0 0 0 0 0 0 15 20957.9 2.08 0 0 1 0 0 0 0 0 0 0 0 16 19726.0 2.07 0 0 0 1 0 0 0 0 0 0 0 17 21315.7 2.06 0 0 0 0 1 0 0 0 0 0 0 18 24771.5 2.05 0 0 0 0 0 1 0 0 0 0 0 19 22592.4 2.05 0 0 0 0 0 0 1 0 0 0 0 20 21942.1 2.05 0 0 0 0 0 0 0 1 0 0 0 21 23973.7 2.05 0 0 0 0 0 0 0 0 1 0 0 22 20815.7 2.05 0 0 0 0 0 0 0 0 0 1 0 23 19931.4 2.06 0 0 0 0 0 0 0 0 0 0 1 24 24436.8 2.06 0 0 0 0 0 0 0 0 0 0 0 25 22838.7 2.07 1 0 0 0 0 0 0 0 0 0 0 26 24465.3 2.07 0 1 0 0 0 0 0 0 0 0 0 27 23007.3 2.30 0 0 1 0 0 0 0 0 0 0 0 28 22720.8 2.31 0 0 0 1 0 0 0 0 0 0 0 29 23045.7 2.31 0 0 0 0 1 0 0 0 0 0 0 30 27198.5 2.53 0 0 0 0 0 1 0 0 0 0 0 31 22401.9 2.58 0 0 0 0 0 0 1 0 0 0 0 32 25122.7 2.59 0 0 0 0 0 0 0 1 0 0 0 33 26100.5 2.73 0 0 0 0 0 0 0 0 1 0 0 34 22904.9 2.82 0 0 0 0 0 0 0 0 0 1 0 35 22040.4 3.00 0 0 0 0 0 0 0 0 0 0 1 36 25981.5 3.04 0 0 0 0 0 0 0 0 0 0 0 37 26157.1 3.23 1 0 0 0 0 0 0 0 0 0 0 38 25975.4 3.32 0 1 0 0 0 0 0 0 0 0 0 39 22589.8 3.49 0 0 1 0 0 0 0 0 0 0 0 40 25370.4 3.57 0 0 0 1 0 0 0 0 0 0 0 41 25091.1 3.56 0 0 0 0 1 0 0 0 0 0 0 42 28760.9 3.72 0 0 0 0 0 1 0 0 0 0 0 43 24325.9 3.82 0 0 0 0 0 0 1 0 0 0 0 44 25821.7 3.82 0 0 0 0 0 0 0 1 0 0 0 45 27645.7 3.98 0 0 0 0 0 0 0 0 1 0 0 46 26296.9 4.06 0 0 0 0 0 0 0 0 0 1 0 47 24141.5 4.08 0 0 0 0 0 0 0 0 0 0 1 48 27268.1 4.19 0 0 0 0 0 0 0 0 0 0 0 49 29060.3 4.16 1 0 0 0 0 0 0 0 0 0 0 50 28226.4 4.17 0 1 0 0 0 0 0 0 0 0 0 51 23268.5 4.21 0 0 1 0 0 0 0 0 0 0 0 52 26938.2 4.21 0 0 0 1 0 0 0 0 0 0 0 53 27217.5 4.17 0 0 0 0 1 0 0 0 0 0 0 54 27540.5 4.19 0 0 0 0 0 1 0 0 0 0 0 55 29167.6 4.25 0 0 0 0 0 0 1 0 0 0 0 56 26671.5 4.25 0 0 0 0 0 0 0 1 0 0 0 57 30184.0 4.20 0 0 0 0 0 0 0 0 1 0 0 58 28422.3 4.33 0 0 0 0 0 0 0 0 0 1 0 59 23774.3 4.41 0 0 0 0 0 0 0 0 0 0 1 60 29601.0 4.56 0 0 0 0 0 0 0 0 0 0 0 61 28523.6 5.18 1 0 0 0 0 0 0 0 0 0 0 62 23622.0 3.42 0 1 0 0 0 0 0 0 0 0 0 63 21320.3 2.71 0 0 1 0 0 0 0 0 0 0 0 64 20423.6 2.29 0 0 0 1 0 0 0 0 0 0 0 65 21174.9 2.00 0 0 0 0 1 0 0 0 0 0 0 66 23050.2 1.64 0 0 0 0 0 1 0 0 0 0 0 67 21202.9 1.30 0 0 0 0 0 0 1 0 0 0 0 68 20476.4 1.08 0 0 0 0 0 0 0 1 0 0 0 69 23173.3 1.00 0 0 0 0 0 0 0 0 1 0 0 70 22468.0 1.00 0 0 0 0 0 0 0 0 0 1 0 71 19842.7 1.00 0 0 0 0 0 0 0 0 0 0 1 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X M1 M2 M3 M4 18648.2 2290.9 -967.3 -1340.0 -3468.0 -2713.4 M5 M6 M7 M8 M9 M10 -1919.2 857.4 -1413.1 -1469.5 892.3 -1398.3 M11 -3825.5 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -3243.80 -1018.22 -68.14 1023.32 2927.21 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 18648.2 877.4 21.253 < 2e-16 *** X 2290.9 175.5 13.052 < 2e-16 *** M1 -967.3 918.0 -1.054 0.296378 M2 -1340.0 919.7 -1.457 0.150536 M3 -3468.0 920.2 -3.769 0.000386 *** M4 -2713.4 921.0 -2.946 0.004626 ** M5 -1919.2 921.9 -2.082 0.041789 * M6 857.4 921.8 0.930 0.356162 M7 -1413.1 922.2 -1.532 0.130876 M8 -1469.5 922.8 -1.592 0.116725 M9 892.3 922.3 0.967 0.337330 M10 -1398.3 921.5 -1.517 0.134586 M11 -3825.5 920.8 -4.155 0.000108 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1516 on 58 degrees of freedom Multiple R-squared: 0.8061, Adjusted R-squared: 0.766 F-statistic: 20.09 on 12 and 58 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.65550451 0.68899097 0.3444955 [2,] 0.50725449 0.98549101 0.4927455 [3,] 0.35837493 0.71674985 0.6416251 [4,] 0.23828346 0.47656692 0.7617165 [5,] 0.16706656 0.33413311 0.8329334 [6,] 0.11716844 0.23433687 0.8828316 [7,] 0.10303350 0.20606700 0.8969665 [8,] 0.07397116 0.14794232 0.9260288 [9,] 0.04262342 0.08524684 0.9573766 [10,] 0.02547754 0.05095509 0.9745225 [11,] 0.10860647 0.21721295 0.8913935 [12,] 0.64414298 0.71171403 0.3558570 [13,] 0.60542611 0.78914777 0.3945739 [14,] 0.60016960 0.79966080 0.3998304 [15,] 0.72312555 0.55374891 0.2768745 [16,] 0.86157923 0.27684155 0.1384208 [17,] 0.84082947 0.31834105 0.1591705 [18,] 0.82462199 0.35075602 0.1753780 [19,] 0.86241240 0.27517519 0.1375876 [20,] 0.82809424 0.34381151 0.1719058 [21,] 0.80297753 0.39404494 0.1970225 [22,] 0.74200018 0.51599963 0.2579998 [23,] 0.69113793 0.61772415 0.3088621 [24,] 0.72080922 0.55838156 0.2791908 [25,] 0.66185363 0.67629274 0.3381464 [26,] 0.58863430 0.82273141 0.4113657 [27,] 0.58014987 0.83970026 0.4198501 [28,] 0.69883569 0.60232861 0.3011643 [29,] 0.62121882 0.75756236 0.3787812 [30,] 0.61011701 0.77976597 0.3898830 [31,] 0.59940179 0.80119642 0.4005982 [32,] 0.50612494 0.98775012 0.4938751 [33,] 0.47870119 0.95740237 0.5212988 [34,] 0.52184191 0.95631618 0.4781581 [35,] 0.63408500 0.73183001 0.3659150 [36,] 0.59453820 0.81092360 0.4054618 [37,] 0.67982139 0.64035722 0.3201786 [38,] 0.66660361 0.66679277 0.3333964 [39,] 0.55166287 0.89667426 0.4483371 [40,] 0.68409078 0.63181845 0.3159092 > postscript(file="/var/www/html/rcomp/tmp/1d3ke1258476296.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/2x3vf1258476296.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/3nhoo1258476296.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/4a0hs1258476296.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/5o9ju1258476296.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 = 71 Frequency = 1 1 2 3 4 5 6 -1772.61849 -3243.80460 -1360.96260 -2401.72059 -1898.57288 -1423.48527 7 8 9 10 11 12 -1443.05380 -2549.76705 -1394.15950 -1990.55008 -2284.83255 -966.07334 13 14 15 16 17 18 -545.10139 -76.92170 1012.70320 -950.95479 -132.51563 569.58053 19 20 21 22 23 24 661.01200 67.09875 -263.09370 -1130.48428 389.53325 1069.39246 25 26 27 28 29 30 415.66441 2414.96120 2558.11511 1494.04001 1024.77062 1896.97013 31 32 33 34 35 36 -743.64114 2010.63705 305.92491 -805.24262 345.12956 369.05457 37 38 39 40 41 42 1076.67262 1061.49245 -585.50234 1257.16272 206.60188 733.25269 43 44 45 46 47 48 -1660.30134 -108.11459 -1012.44383 -253.90282 -27.89383 -978.82867 49 50 51 52 53 54 1849.37747 1365.26571 -1556.21793 1358.81552 935.58033 -1563.84916 55 56 57 58 59 60 2196.33102 -243.38224 1021.86807 1252.96633 -1151.07598 506.45498 61 62 63 64 65 66 -1023.99462 -1520.99305 -68.13544 -757.34289 -135.86433 -212.46892 67 68 69 70 71 989.65325 823.52809 1341.90405 2927.21347 2729.13955 > postscript(file="/var/www/html/rcomp/tmp/6exmm1258476296.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 = 71 Frequency = 1 lag(myerror, k = 1) myerror 0 -1772.61849 NA 1 -3243.80460 -1772.61849 2 -1360.96260 -3243.80460 3 -2401.72059 -1360.96260 4 -1898.57288 -2401.72059 5 -1423.48527 -1898.57288 6 -1443.05380 -1423.48527 7 -2549.76705 -1443.05380 8 -1394.15950 -2549.76705 9 -1990.55008 -1394.15950 10 -2284.83255 -1990.55008 11 -966.07334 -2284.83255 12 -545.10139 -966.07334 13 -76.92170 -545.10139 14 1012.70320 -76.92170 15 -950.95479 1012.70320 16 -132.51563 -950.95479 17 569.58053 -132.51563 18 661.01200 569.58053 19 67.09875 661.01200 20 -263.09370 67.09875 21 -1130.48428 -263.09370 22 389.53325 -1130.48428 23 1069.39246 389.53325 24 415.66441 1069.39246 25 2414.96120 415.66441 26 2558.11511 2414.96120 27 1494.04001 2558.11511 28 1024.77062 1494.04001 29 1896.97013 1024.77062 30 -743.64114 1896.97013 31 2010.63705 -743.64114 32 305.92491 2010.63705 33 -805.24262 305.92491 34 345.12956 -805.24262 35 369.05457 345.12956 36 1076.67262 369.05457 37 1061.49245 1076.67262 38 -585.50234 1061.49245 39 1257.16272 -585.50234 40 206.60188 1257.16272 41 733.25269 206.60188 42 -1660.30134 733.25269 43 -108.11459 -1660.30134 44 -1012.44383 -108.11459 45 -253.90282 -1012.44383 46 -27.89383 -253.90282 47 -978.82867 -27.89383 48 1849.37747 -978.82867 49 1365.26571 1849.37747 50 -1556.21793 1365.26571 51 1358.81552 -1556.21793 52 935.58033 1358.81552 53 -1563.84916 935.58033 54 2196.33102 -1563.84916 55 -243.38224 2196.33102 56 1021.86807 -243.38224 57 1252.96633 1021.86807 58 -1151.07598 1252.96633 59 506.45498 -1151.07598 60 -1023.99462 506.45498 61 -1520.99305 -1023.99462 62 -68.13544 -1520.99305 63 -757.34289 -68.13544 64 -135.86433 -757.34289 65 -212.46892 -135.86433 66 989.65325 -212.46892 67 823.52809 989.65325 68 1341.90405 823.52809 69 2927.21347 1341.90405 70 2729.13955 2927.21347 71 NA 2729.13955 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -3243.80460 -1772.61849 [2,] -1360.96260 -3243.80460 [3,] -2401.72059 -1360.96260 [4,] -1898.57288 -2401.72059 [5,] -1423.48527 -1898.57288 [6,] -1443.05380 -1423.48527 [7,] -2549.76705 -1443.05380 [8,] -1394.15950 -2549.76705 [9,] -1990.55008 -1394.15950 [10,] -2284.83255 -1990.55008 [11,] -966.07334 -2284.83255 [12,] -545.10139 -966.07334 [13,] -76.92170 -545.10139 [14,] 1012.70320 -76.92170 [15,] -950.95479 1012.70320 [16,] -132.51563 -950.95479 [17,] 569.58053 -132.51563 [18,] 661.01200 569.58053 [19,] 67.09875 661.01200 [20,] -263.09370 67.09875 [21,] -1130.48428 -263.09370 [22,] 389.53325 -1130.48428 [23,] 1069.39246 389.53325 [24,] 415.66441 1069.39246 [25,] 2414.96120 415.66441 [26,] 2558.11511 2414.96120 [27,] 1494.04001 2558.11511 [28,] 1024.77062 1494.04001 [29,] 1896.97013 1024.77062 [30,] -743.64114 1896.97013 [31,] 2010.63705 -743.64114 [32,] 305.92491 2010.63705 [33,] -805.24262 305.92491 [34,] 345.12956 -805.24262 [35,] 369.05457 345.12956 [36,] 1076.67262 369.05457 [37,] 1061.49245 1076.67262 [38,] -585.50234 1061.49245 [39,] 1257.16272 -585.50234 [40,] 206.60188 1257.16272 [41,] 733.25269 206.60188 [42,] -1660.30134 733.25269 [43,] -108.11459 -1660.30134 [44,] -1012.44383 -108.11459 [45,] -253.90282 -1012.44383 [46,] -27.89383 -253.90282 [47,] -978.82867 -27.89383 [48,] 1849.37747 -978.82867 [49,] 1365.26571 1849.37747 [50,] -1556.21793 1365.26571 [51,] 1358.81552 -1556.21793 [52,] 935.58033 1358.81552 [53,] -1563.84916 935.58033 [54,] 2196.33102 -1563.84916 [55,] -243.38224 2196.33102 [56,] 1021.86807 -243.38224 [57,] 1252.96633 1021.86807 [58,] -1151.07598 1252.96633 [59,] 506.45498 -1151.07598 [60,] -1023.99462 506.45498 [61,] -1520.99305 -1023.99462 [62,] -68.13544 -1520.99305 [63,] -757.34289 -68.13544 [64,] -135.86433 -757.34289 [65,] -212.46892 -135.86433 [66,] 989.65325 -212.46892 [67,] 823.52809 989.65325 [68,] 1341.90405 823.52809 [69,] 2927.21347 1341.90405 [70,] 2729.13955 2927.21347 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -3243.80460 -1772.61849 2 -1360.96260 -3243.80460 3 -2401.72059 -1360.96260 4 -1898.57288 -2401.72059 5 -1423.48527 -1898.57288 6 -1443.05380 -1423.48527 7 -2549.76705 -1443.05380 8 -1394.15950 -2549.76705 9 -1990.55008 -1394.15950 10 -2284.83255 -1990.55008 11 -966.07334 -2284.83255 12 -545.10139 -966.07334 13 -76.92170 -545.10139 14 1012.70320 -76.92170 15 -950.95479 1012.70320 16 -132.51563 -950.95479 17 569.58053 -132.51563 18 661.01200 569.58053 19 67.09875 661.01200 20 -263.09370 67.09875 21 -1130.48428 -263.09370 22 389.53325 -1130.48428 23 1069.39246 389.53325 24 415.66441 1069.39246 25 2414.96120 415.66441 26 2558.11511 2414.96120 27 1494.04001 2558.11511 28 1024.77062 1494.04001 29 1896.97013 1024.77062 30 -743.64114 1896.97013 31 2010.63705 -743.64114 32 305.92491 2010.63705 33 -805.24262 305.92491 34 345.12956 -805.24262 35 369.05457 345.12956 36 1076.67262 369.05457 37 1061.49245 1076.67262 38 -585.50234 1061.49245 39 1257.16272 -585.50234 40 206.60188 1257.16272 41 733.25269 206.60188 42 -1660.30134 733.25269 43 -108.11459 -1660.30134 44 -1012.44383 -108.11459 45 -253.90282 -1012.44383 46 -27.89383 -253.90282 47 -978.82867 -27.89383 48 1849.37747 -978.82867 49 1365.26571 1849.37747 50 -1556.21793 1365.26571 51 1358.81552 -1556.21793 52 935.58033 1358.81552 53 -1563.84916 935.58033 54 2196.33102 -1563.84916 55 -243.38224 2196.33102 56 1021.86807 -243.38224 57 1252.96633 1021.86807 58 -1151.07598 1252.96633 59 506.45498 -1151.07598 60 -1023.99462 506.45498 61 -1520.99305 -1023.99462 62 -68.13544 -1520.99305 63 -757.34289 -68.13544 64 -135.86433 -757.34289 65 -212.46892 -135.86433 66 989.65325 -212.46892 67 823.52809 989.65325 68 1341.90405 823.52809 69 2927.21347 1341.90405 70 2729.13955 2927.21347 > 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/7oxvl1258476296.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/8f9mw1258476296.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/9kz9t1258476296.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/103wbg1258476296.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/11o6rt1258476296.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/12vx441258476296.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/13kxa51258476296.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/14zcah1258476296.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/15vkp01258476296.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/16ypfk1258476296.tab") + } > > system("convert tmp/1d3ke1258476296.ps tmp/1d3ke1258476296.png") > system("convert tmp/2x3vf1258476296.ps tmp/2x3vf1258476296.png") > system("convert tmp/3nhoo1258476296.ps tmp/3nhoo1258476296.png") > system("convert tmp/4a0hs1258476296.ps tmp/4a0hs1258476296.png") > system("convert tmp/5o9ju1258476296.ps tmp/5o9ju1258476296.png") > system("convert tmp/6exmm1258476296.ps tmp/6exmm1258476296.png") > system("convert tmp/7oxvl1258476296.ps tmp/7oxvl1258476296.png") > system("convert tmp/8f9mw1258476296.ps tmp/8f9mw1258476296.png") > system("convert tmp/9kz9t1258476296.ps tmp/9kz9t1258476296.png") > system("convert tmp/103wbg1258476296.ps tmp/103wbg1258476296.png") > > > proc.time() user system elapsed 2.576 1.602 3.405