R version 2.10.1 (2009-12-14) 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. > ## ---------------------------------------------------------------------------- > ## Boot and De Wit (1960) > ## > ## data > ## availability: printed > ## firms: General Motors, US Steel, General Electric, Chrysler, Atlantic Refining, > ## IBM, Union Oil, Westinghouse, Goodyear, Diamond Match > ## errors: none > ## > ## analysis > ## result: mostly exact at precision given > ## Westinghouse: error for intercept/variance > ## and tiny deviation for capital coef > ## US Steel: error in standard deviation of capital coef > ## Macro regression: interchanged standard deviations > ## Adjustment differences: > ## - wrong df for residual variance > ## - adjusted R^2 = 1 - (1 - R^2) * n/(n-k) instead of (n-1)/(n-k) > ## ---------------------------------------------------------------------------- > > ## preliminaries > source("start.R") Loading required package: kinship Loading required package: survival Loading required package: splines Loading required package: nlme Loading required package: lattice [1] "kinship is loaded" Loading required package: Formula Loading required package: MASS Loading required package: sandwich Loading required package: zoo Loading required package: Matrix Loading required package: car Loading required package: lmtest > > ## data pre-processing > gr <- subset(Grunfeld, firm %in% c("General Motors", "US Steel", "General Electric", "Chrysler", + "Atlantic Refining", "IBM", "Union Oil", "Westinghouse", "Goodyear", "Diamond Match")) > gr$firm <- factor(gr$firm) > pgr <- plm.data(gr, c("firm", "year")) > > ## summary statistics (Table 1, p. 8) > sort(tapply(gr$invest, gr$firm, mean), decreasing = TRUE) General Motors US Steel General Electric Chrysler 608.0200 410.4750 102.2900 86.1235 Atlantic Refining IBM Union Oil Westinghouse 61.8025 55.4110 47.5955 42.8915 Goodyear Diamond Match 41.8890 3.0845 > > ## Microregressions (Table 2, p. 9) > lm_GM <- lm(invest ~ value + capital, data = gr, subset = firm == "General Motors") > gsummary(lm_GM) (Intercept) value capital R^2 sigma^2 -149.782 0.119 0.371 0.921 8423.875 105.842 0.026 0.037 > var(residuals(lm_GM)) ## df = n-1 (instead of n-k) [1] 7537.151 > > lm_US <- lm(invest ~ value + capital, data = gr, subset = firm == "US Steel") > lm_GE <- lm(invest ~ value + capital, data = gr, subset = firm == "General Electric") > lm_CH <- lm(invest ~ value + capital, data = gr, subset = firm == "Chrysler") > lm_AR <- lm(invest ~ value + capital, data = gr, subset = firm == "Atlantic Refining") > lm_IBM<- lm(invest ~ value + capital, data = gr, subset = firm == "IBM") > lm_UO <- lm(invest ~ value + capital, data = gr, subset = firm == "Union Oil") > lm_WH <- lm(invest ~ value + capital, data = gr, subset = firm == "Westinghouse") > lm_GY <- lm(invest ~ value + capital, data = gr, subset = firm == "Goodyear") > lm_DM <- lm(invest ~ value + capital, data = gr, subset = firm == "Diamond Match") > > ## alternatively: > sf <- systemfit(invest ~ value + capital, method = "OLS", data = pgr) > gsummary(sf) Method: OLS (Intercept) value capital R^2 sigma^2 Atlantic.Refining 22.707 0.162 0.003 0.680 82.167 6.872 0.057 0.022 Chrysler -6.190 0.078 0.316 0.914 176.320 13.506 0.020 0.029 Diamond.Match 0.162 0.005 0.437 0.643 1.178 2.066 0.027 0.080 General.Electric -9.956 0.027 0.152 0.705 777.446 31.374 0.016 0.026 General.Motors -149.782 0.119 0.371 0.921 8423.875 105.842 0.026 0.037 Goodyear -7.723 0.075 0.082 0.666 82.786 9.359 0.034 0.028 IBM -8.686 0.131 0.085 0.952 65.325 4.545 0.031 0.100 US.Steel -49.198 0.175 0.390 0.471 9299.604 148.075 0.074 0.142 Union.Oil -4.500 0.088 0.124 0.764 88.671 11.289 0.066 0.017 Westinghouse -0.509 0.053 0.092 0.744 104.308 8.015 0.016 0.056 > structure( + sapply(sf$eq, function(x) var(residuals(x))), + .Names = sapply(sf$eq, function(x) x$eqnLabel)) Atlantic.Refining Chrysler Diamond.Match General.Electric 73.517696 157.760230 1.054039 695.609883 General.Motors Goodyear IBM US.Steel 7537.151443 74.071569 58.449112 8320.698357 Union.Oil Westinghouse 79.337016 93.328102 > ## df = n-1 (instead of n-k) > structure( + sapply(sf$eq, function(x) 1 + (summary(x)$adj.r.squared - 1) * 20/19), + .Names = sapply(sf$eq, function(x) x$eqnLabel)) Atlantic.Refining Chrysler Diamond.Match General.Electric 0.6240090 0.8983276 0.5801856 0.6533020 General.Motors Goodyear IBM US.Steel 0.9074753 0.6064877 0.9436967 0.3774851 Union.Oil Westinghouse 0.7217657 0.6993484 > ## usually: adjusted R^2 = 1 - (1 - R^2) * (n-1)/(n-k) > ## here: adjusted R^2 = 1 - (1 - R^2) * n /(n-k) > > ## Macro regression (Equation 4.1, p. 10) > gr_macro <- aggregate(gr[,-4], list(gr$year), sum)[,-1] > lm_macro <- lm(invest ~ value + capital, data = gr_macro) > gsummary(lm_macro) (Intercept) value capital R^2 sigma^2 -332.246 0.099 0.260 0.939 22585.63 194.123 0.020 0.025 >