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. > ## ---------------------------------------------------------------------------- > ## Bera, Sosa-Escudero and Yoon (2001) > ## > ## data > ## availability: none > ## firms: General Motors, Chrysler, General Electric, Westinghouse, US Steel > ## (taken from Greene, 4e, 2000) > ## errors: as in Greene (1993/2000/2003) > ## > ## analysis > ## result: exact at precision given (except for tiny deviation for RSO_mu*) > ## ---------------------------------------------------------------------------- > > ## 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", "Chrysler", "General Electric", + "Westinghouse", "US Steel")) > gr$firm <- factor(gr$firm) > gr$invest[c(66, 78)] <- c(261.6, 645.2) > gr$capital[72] <- 232.6 > pgr <- plm.data(gr, c("firm", "year")) > > > ## model fitting > fm_pool <- plm(invest ~ value + capital, data = pgr, model = "pooling") > > ## preliminary computations for Table 1 > rr <- residuals(fm_pool) > u <- rr[-((0:4) * 20 + 1)] > u1 <- rr[-((1:5) * 20)] > A <- 1 - crossprod(rr, kronecker(diag(5), matrix(1, nrow = 20, ncol = 20)) %*% rr) / sum(rr^2) > B <- crossprod(u, u1) / sum(u^2) > > ## Table 1 (p. 13) gives the following statistics: > plmtest(invest ~ value + capital, data = pgr, type = "bp") ## RS_mu Lagrange Multiplier Test - (Breusch-Pagan) data: invest ~ value + capital chisq = 453.8221, df = 1, p-value < 2.2e-16 alternative hypothesis: significant effects > 5 * 20 * (A + 2*B)^2 / 2 / (20 - 1) / (1 - 2/20) ## RS_mu* [,1] [1,] 384.1832 > 5 * 20^2 * B^2 / (20 - 1) ## RS_rho [,1] [1,] 73.35132 > pbsytest(invest ~ value + capital, data = pgr) ## RS_rho* Bera, Sosa-Escudero and Yoon locally robust test data: formula chisq = 3.7125, df = 1, p-value = 0.05401 alternative hypothesis: AR(1) errors sub random effects > pbsytest(invest ~ value + capital, data = pgr, test = "J") ## RS_mu,rho Baltagi and Li AR-RE joint test data: formula chisq = 457.5346, df = 2, p-value < 2.2e-16 alternative hypothesis: AR(1) errors or random effects > plmtest(invest ~ value + capital, data = pgr, type = "honda") ## RSO_mu Lagrange Multiplier Test - (Honda) data: invest ~ value + capital normal = 21.3031, p-value < 2.2e-16 alternative hypothesis: significant effects > pbsytest(invest ~ value + capital, data = pgr, test = "RE") ## RSO_mu* Bera, Sosa-Escudero and Yoon locally robust test data: formula z = 19.6006, p-value < 2.2e-16 alternative hypothesis: random effects sub AR(1) errors > ## small deviation for RSO_mu* = 19.60059 instead of 19.605 >