Estimators for random and fixed effects models with variable coefficients.
a symbolic description for the model to be estimated,
a data.frame,
see lm,
see lm,
the effects introduced in the model: one of
"individual", "time",
one of "within", "random",
the indexes, see pdata.frame(),
further arguments.
an object of class "pvcm",
digits,
the maximum length of the lines in the print output,
An object of class c("pvcm", "panelmodel"), which has the
following elements:
the vector (numeric) of coefficients (or data frame for fixed effects),
the vector (numeric) of residuals,
the vector of fitted values,
the covariance matrix of the coefficients (a list for
fixed effects model (model = "within")),
degrees of freedom of the residuals,
a data frame containing the variables used for the estimation,
the call,
the arguments of the call,
random coefficients model only (model = "random"):
the estimation of the covariance matrix of the coefficients,
matrix of unbiased coefficients of single estimations,
list of variance-covariance matrices for single.coefs,
matrix of standard errors of single.coefs,
htest object: parameter stability test (homogeneous coefficients),
separate OLS estimations only (model = "within"):
a data frame containing standard errors for all coefficients for each single regression.
pvcm estimates variable coefficients models. Individual or time
effects are introduced, respectively, if effect = "individual"
(default) or effect = "time".
Coefficients are assumed to be fixed if model = "within", i.e., separate
pooled OLS models are estimated per individual (effect = "individual")
or per time period (effect = "time"). Coefficients are assumed to be
random if model = "random" and the model by
Swamy (1970)
is estimated; it is a generalized least
squares model which uses the results of the OLS models estimated per
individual/time dimension (coefficient estimates are weighted averages of the
single OLS estimates with weights inversely proportional to the
variance-covariance matrices). The corresponding unbiased single coefficients,
variance-covariance matrices, and standard errors of the random coefficients
model are available in the returned object (see Value).
A test for parameter stability (homogeneous coefficients) of the random coefficients model is printed in the model's summary and is available in the returned object (see Value).
pvcm objects have print, summary and print.summary methods.
Swamy PAVB (1970). “Efficient Inference in a Random Coefficient Regression Model.” Econometrica, 38, 311–323.
Swamy PAVB (1971). Statistical Inference in Random Coefficient Regression Models. Springer.
Greene WH (2018). Econometric Analysis, 8th edition. Prentice Hall.
Poi BP (2003). “From the help desk: Swamy’s random-coefficients model.” Stata Journal, 3(3), 302–308.
Kleiber C, Zeileis A (2010). “The Grunfeld Data at 50.” German Economic Review, 11, 404-417. https://doi.org/10.1111/j.1468-0475.2010.00513.x.
data("Produc", package = "plm")
zw <- pvcm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp, data = Produc, model = "within")
zr <- pvcm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp, data = Produc, model = "random")
## replicate Greene (2018), p. 452, table 11.22/(2012), p. 419, table 11.14
summary(pvcm(log(gsp) ~ log(pc) + log(hwy) + log(water) + log(util) + log(emp) + unemp,
data = Produc, model = "random"))
#> Oneway (individual) effect Random coefficients model
#>
#> Call:
#> pvcm(formula = log(gsp) ~ log(pc) + log(hwy) + log(water) + log(util) +
#> log(emp) + unemp, data = Produc, model = "random")
#>
#> Balanced Panel: n = 48, T = 17, N = 816
#>
#> Residuals:
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> -0.23533 -0.06035 0.08087 0.09229 0.20421 0.97490
#>
#> Estimated mean of the coefficients:
#> Estimate Std. Error z-value Pr(>|z|)
#> (Intercept) 1.6530780 1.0833134 1.5259 0.12702
#> log(pc) 0.0940755 0.0515162 1.8261 0.06783 .
#> log(hwy) 0.1050114 0.1736406 0.6048 0.54534
#> log(water) 0.0767189 0.0674273 1.1378 0.25520
#> log(util) -0.0149021 0.0988643 -0.1507 0.88019
#> log(emp) 0.9190594 0.1044486 8.7992 < 2e-16 ***
#> unemp -0.0047055 0.0020673 -2.2761 0.02284 *
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Estimated variance of the coefficients:
#> (Intercept) log(pc) log(hwy) log(water) log(util) log(emp)
#> (Intercept) 50.101152 -0.1269537 -5.7011050 1.1490999 0.9323094 -1.5405556
#> log(pc) -0.126954 0.0921826 0.0050351 -0.0178555 -0.0306629 -0.0649625
#> log(hwy) -5.701105 0.0050351 1.2347643 -0.1657787 -0.4550976 -0.0467022
#> log(water) 1.149100 -0.0178555 -0.1657787 0.1883437 -0.0095582 -0.1125142
#> log(util) 0.932309 -0.0306629 -0.4550976 -0.0095582 0.3996351 0.0118384
#> log(emp) -1.540556 -0.0649625 -0.0467022 -0.1125142 0.0118384 0.4348876
#> unemp -0.027161 -0.0013129 0.0020316 -0.0024191 -0.0013977 0.0068745
#> unemp
#> (Intercept) -0.02716134
#> log(pc) -0.00131287
#> log(hwy) 0.00203161
#> log(water) -0.00241907
#> log(util) -0.00139775
#> log(emp) 0.00687449
#> unemp 0.00016044
#>
#> Total Sum of Squares: 21431
#> Residual Sum of Squares: 36.691
#> Multiple R-Squared: 0.99829
#> Chisq: 434.623 on 6 DF, p-value: < 2.22e-16
#> Test for parameter homogeneity: Chisq = 25554.4 on 329 DF, p-value: < 2.22e-16
## replicate Poi (2003) (need data adjustment, remaining tiny diffs are due
## Poi's data set having more digits, not justified by the original Grunfeld data)
data(Grunfeld) # need firm = 1, 4, 3, 8, 2
Gr.Poi.2003 <- Grunfeld[c(1:20, 61:80, 41:60, 141:160, 21:40), ]
Gr.Poi.2003$firm <- rep(1:5, each = 20)
Gr.Poi.2003[c(86, 98), "inv"] <- c(261.6, 645.2)
Gr.Poi.2003[c(92), "capital"] <- c(232.6)
mod.poi <- pvcm(inv ~ value + capital, data = Gr.Poi.2003, model = "random")
summary(mod.poi)
#> Oneway (individual) effect Random coefficients model
#>
#> Call:
#> pvcm(formula = inv ~ value + capital, data = Gr.Poi.2003, model = "random")
#>
#> Balanced Panel: n = 5, T = 20, N = 100
#>
#> Residuals:
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> -262.16 -31.94 14.09 28.95 91.50 426.27
#>
#> Estimated mean of the coefficients:
#> Estimate Std. Error z-value Pr(>|z|)
#> (Intercept) -23.583618 34.555476 -0.6825 0.494932
#> value 0.080765 0.025083 3.2199 0.001282 **
#> capital 0.283989 0.067790 4.1892 2.799e-05 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Estimated variance of the coefficients:
#> (Intercept) value capital
#> (Intercept) 3937.0408 -1.5854252 -4.6700196
#> value -1.5854 0.0026952 0.0066939
#> capital -4.6700 0.0066939 0.0203966
#>
#> Total Sum of Squares: 400600000
#> Residual Sum of Squares: 1812400
#> Multiple R-Squared: 0.99548
#> Chisq: 17.5503 on 2 DF, p-value: 0.00015452
#> Test for parameter homogeneity: Chisq = 603.994 on 12 DF, p-value: < 2.22e-16
print(mod.poi$single.coefs)
#> (Intercept) value capital
#> 1 -71.629303 0.10278481 0.3678493
#> 2 -9.819347 0.08423602 0.3092167
#> 3 -12.032688 0.02793844 0.1508282
#> 4 3.269521 0.04110891 0.1407172
#> 5 -27.706276 0.14775499 0.4513312
print(mod.poi$single.std.err)
#> (Intercept) value capital
#> 1 37.466646 0.01085665 0.03313519
#> 2 14.074959 0.01557614 0.03018058
#> 3 29.580831 0.01347698 0.02869037
#> 4 9.510794 0.01181795 0.03402793
#> 5 42.125252 0.01819023 0.05692994
if (FALSE) { # \dontrun{
# replicate Swamy (1971), p. 166, table 5.2
data(Grunfeld, package = "AER") # 11 firm Grunfeld data needed from package AER
gw <- pvcm(invest ~ value + capital, data = Grunfeld, index = c("firm", "year"))
# close replication of Swamy (1970), (7.4) [remaining diffs likely due to less
# precise numerical methods in the 1970, as supposed in Kleiber/Zeileis (2010), p. 9]
gr <- pvcm(invest ~ value + capital, data = Grunfeld, index = c("firm", "year"), model = "random")
} # }