1% Generated by roxygen2: do not edit by hand 2% Please edit documentation in R/est_plm.R, R/est_plm.list.R, R/tool_methods.R 3\name{plm} 4\alias{plm} 5\alias{print.plm.list} 6\alias{terms.panelmodel} 7\alias{vcov.panelmodel} 8\alias{fitted.panelmodel} 9\alias{residuals.panelmodel} 10\alias{df.residual.panelmodel} 11\alias{coef.panelmodel} 12\alias{print.panelmodel} 13\alias{update.panelmodel} 14\alias{deviance.panelmodel} 15\alias{predict.plm} 16\alias{formula.plm} 17\alias{plot.plm} 18\alias{residuals.plm} 19\alias{fitted.plm} 20\title{Panel Data Estimators} 21\usage{ 22plm( 23 formula, 24 data, 25 subset, 26 weights, 27 na.action, 28 effect = c("individual", "time", "twoways", "nested"), 29 model = c("within", "random", "ht", "between", "pooling", "fd"), 30 random.method = NULL, 31 random.models = NULL, 32 random.dfcor = NULL, 33 inst.method = c("bvk", "baltagi", "am", "bms"), 34 restrict.matrix = NULL, 35 restrict.rhs = NULL, 36 index = NULL, 37 ... 38) 39 40\method{print}{plm.list}( 41 x, 42 digits = max(3, getOption("digits") - 2), 43 width = getOption("width"), 44 ... 45) 46 47\method{terms}{panelmodel}(x, ...) 48 49\method{vcov}{panelmodel}(object, ...) 50 51\method{fitted}{panelmodel}(object, ...) 52 53\method{residuals}{panelmodel}(object, ...) 54 55\method{df.residual}{panelmodel}(object, ...) 56 57\method{coef}{panelmodel}(object, ...) 58 59\method{print}{panelmodel}( 60 x, 61 digits = max(3, getOption("digits") - 2), 62 width = getOption("width"), 63 ... 64) 65 66\method{update}{panelmodel}(object, formula., ..., evaluate = TRUE) 67 68\method{deviance}{panelmodel}(object, model = NULL, ...) 69 70\method{predict}{plm}(object, newdata = NULL, ...) 71 72\method{formula}{plm}(x, ...) 73 74\method{plot}{plm}( 75 x, 76 dx = 0.2, 77 N = NULL, 78 seed = 1, 79 within = TRUE, 80 pooling = TRUE, 81 between = FALSE, 82 random = FALSE, 83 ... 84) 85 86\method{residuals}{plm}(object, model = NULL, effect = NULL, ...) 87 88\method{fitted}{plm}(object, model = NULL, effect = NULL, ...) 89} 90\arguments{ 91\item{formula}{a symbolic description for the model to be 92estimated,} 93 94\item{data}{a \code{data.frame},} 95 96\item{subset}{see \code{\link[stats:lm]{stats::lm()}},} 97 98\item{weights}{see \code{\link[stats:lm]{stats::lm()}},} 99 100\item{na.action}{see \code{\link[stats:lm]{stats::lm()}}; currently, not fully 101supported,} 102 103\item{effect}{the effects introduced in the model, one of 104\code{"individual"}, \code{"time"}, \code{"twoways"}, or 105\code{"nested"},} 106 107\item{model}{one of \code{"pooling"}, \code{"within"}, 108\code{"between"}, \code{"random"} \code{"fd"}, or \code{"ht"},} 109 110\item{random.method}{method of estimation for the variance 111components in the random effects model, one of \code{"swar"} 112(default), \code{"amemiya"}, \code{"walhus"}, \code{"nerlove"}; for 113Hausman-Taylor estimation set to \code{"ht"} (see Details and Examples),} 114 115\item{random.models}{an alternative to the previous argument, the 116models used to compute the variance components estimations are 117indicated,} 118 119\item{random.dfcor}{a numeric vector of length 2 indicating which 120degree of freedom should be used,} 121 122\item{inst.method}{the instrumental variable transformation: one of 123\code{"bvk"}, \code{"baltagi"}, \code{"am"}, or \code{"bms"} (see also Details),} 124 125\item{restrict.matrix}{a matrix which defines linear restrictions 126on the coefficients,} 127 128\item{restrict.rhs}{the right hand side vector of the linear 129restrictions on the coefficients,} 130 131\item{index}{the indexes,} 132 133\item{\dots}{further arguments.} 134 135\item{x, object}{an object of class \code{"plm"},} 136 137\item{digits}{number of digits for printed output,} 138 139\item{width}{the maximum length of the lines in the printed output,} 140 141\item{formula.}{a new formula for the update method,} 142 143\item{evaluate}{a boolean for the update method, if \code{TRUE} the 144updated model is returned, if \code{FALSE} the call is returned,} 145 146\item{newdata}{the new data set for the \code{predict} method,} 147 148\item{dx}{the half--length of the individual lines for the plot 149method (relative to x range),} 150 151\item{N}{the number of individual to plot,} 152 153\item{seed}{the seed which will lead to individual selection,} 154 155\item{within}{if \code{TRUE}, the within model is plotted,} 156 157\item{pooling}{if \code{TRUE}, the pooling model is plotted,} 158 159\item{between}{if \code{TRUE}, the between model is plotted,} 160 161\item{random}{if \code{TRUE}, the random effect model is plotted,} 162} 163\value{ 164An object of class \code{"plm"}. 165 166A \code{"plm"} object has the following elements : 167 168\item{coefficients}{the vector of coefficients,} 169\item{vcov}{the variance--covariance matrix of the coefficients,} 170\item{residuals}{the vector of residuals (these are the residuals 171of the (quasi-)demeaned model),} 172\item{weights}{(only for weighted estimations) weights as 173specified,} 174\item{df.residual}{degrees of freedom of the residuals,} 175\item{formula}{an object of class \code{"pFormula"} describing the model,} 176\item{model}{the model frame as a \code{"pdata.frame"} containing the 177variables used for estimation: the response is in first column followed by 178the other variables, the individual and time indexes are in the 'index' 179attribute of \code{model},} 180\item{ercomp}{an object of class \code{"ercomp"} providing the 181estimation of the components of the errors (for random effects 182models only),} 183\item{aliased}{named logical vector indicating any aliased 184coefficients which are silently dropped by \code{plm} due to 185linearly dependent terms (see also \code{\link[=detect.lindep]{detect.lindep()}}),} 186\item{call}{the call.} 187 188It has \code{print}, \code{summary} and \code{print.summary} methods. The 189\code{summary} method creates an object of class \code{"summary.plm"} that 190extends the object it is run on with information about (inter alia) F 191statistic and (adjusted) R-squared of model, standard errors, t--values, and 192p--values of coefficients, (if supplied) the furnished vcov, see 193\code{\link[=summary.plm]{summary.plm()}} for further details. 194} 195\description{ 196Linear models for panel data estimated using the \code{lm} function on 197transformed data. 198} 199\details{ 200\code{plm} is a general function for the estimation of linear panel 201models. It supports the following estimation methods: pooled OLS 202(\code{model = "pooling"}), fixed effects (\code{"within"}), random effects 203(\code{"random"}), first--differences (\code{"fd"}), and between 204(\code{"between"}). It supports unbalanced panels and two--way effects 205(although not with all methods). 206 207For random effects models, four estimators of the transformation 208parameter are available by setting \code{random.method} to one of 209\code{"swar"} \insertCite{SWAM:AROR:72}{plm} (default), \code{"amemiya"} 210\insertCite{AMEM:71}{plm}, \code{"walhus"} 211\insertCite{WALL:HUSS:69}{plm}, or \code{"nerlove"} 212\insertCite{NERLO:71}{plm} (see below for Hausman-Taylor instrumental 213variable case). 214 215For first--difference models, the intercept is maintained (which 216from a specification viewpoint amounts to allowing for a trend in 217the levels model). The user can exclude it from the estimated 218specification the usual way by adding \code{"-1"} to the model formula. 219 220Instrumental variables estimation is obtained using two--part 221formulas, the second part indicating the instrumental variables 222used. This can be a complete list of instrumental variables or an 223update of the first part. If, for example, the model is \code{y ~ x1 + x2 + x3}, with \code{x1} and \code{x2} endogenous and \code{z1} and \code{z2} external 224instruments, the model can be estimated with: 225 226\itemize{ 227\item \code{formula = y~x1+x2+x3 | x3+z1+z2}, 228\item \code{formula = y~x1+x2+x3 | . -x1-x2+z1+z2}. 229} 230 231If an instrument variable estimation is requested, argument 232\code{inst.method} selects the instrument variable transformation 233method: 234\itemize{ 235\item \code{"bvk"} (default) for \insertCite{BALE:VARA:87;textual}{plm}, 236\item \code{"baltagi"} for \insertCite{BALT:81;textual}{plm}, 237\item \code{"am"} for \insertCite{AMEM:MACU:86;textual}{plm}, 238\item \code{"bms"} for \insertCite{BREU:MIZO:SCHM:89;textual}{plm}. 239} 240 241The Hausman--Taylor estimator \insertCite{HAUS:TAYL:81}{plm} is 242computed with arguments \code{random.method = "ht"}, \code{model = "random"}, 243\code{inst.method = "baltagi"} (the other way with only \code{model = "ht"} 244is deprecated). 245 246See also the vignettes for introductions to model estimations (and more) with 247examples. 248} 249\examples{ 250 251data("Produc", package = "plm") 252zz <- plm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp, 253 data = Produc, index = c("state","year")) 254summary(zz) 255 256# replicates some results from Baltagi (2013), table 3.1 257data("Grunfeld", package = "plm") 258p <- plm(inv ~ value + capital, 259 data = Grunfeld, model = "pooling") 260 261wi <- plm(inv ~ value + capital, 262 data = Grunfeld, model = "within", effect = "twoways") 263 264swar <- plm(inv ~ value + capital, 265 data = Grunfeld, model = "random", effect = "twoways") 266 267amemiya <- plm(inv ~ value + capital, 268 data = Grunfeld, model = "random", random.method = "amemiya", 269 effect = "twoways") 270 271walhus <- plm(inv ~ value + capital, 272 data = Grunfeld, model = "random", random.method = "walhus", 273 effect = "twoways") 274 275# summary and summary with a furnished vcov (passed as matrix, 276# as function, and as function with additional argument) 277summary(wi) 278summary(wi, vcov = vcovHC(wi)) 279summary(wi, vcov = vcovHC) 280summary(wi, vcov = function(x) vcovHC(x, method = "white2")) 281 282 283## nested random effect model 284# replicate Baltagi/Song/Jung (2001), p. 378 (table 6), columns SA, WH 285# == Baltagi (2013), pp. 204-205 286data("Produc", package = "plm") 287pProduc <- pdata.frame(Produc, index = c("state", "year", "region")) 288form <- log(gsp) ~ log(pc) + log(emp) + log(hwy) + log(water) + log(util) + unemp 289summary(plm(form, data = pProduc, model = "random", effect = "nested")) 290summary(plm(form, data = pProduc, model = "random", effect = "nested", 291 random.method = "walhus")) 292 293## Instrumental variable estimations 294# replicate Baltagi (2013/2021), p. 133/162, table 7.1 295data("Crime", package = "plm") 296FE2SLS <- plm(lcrmrte ~ lprbarr + lpolpc + lprbconv + lprbpris + lavgsen + 297 ldensity + lwcon + lwtuc + lwtrd + lwfir + lwser + lwmfg + lwfed + 298 lwsta + lwloc + lpctymle + lpctmin + region + smsa + factor(year) 299 | . - lprbarr - lpolpc + ltaxpc + lmix, 300 data = Crime, model = "within") 301G2SLS <- update(FE2SLS, model = "random", inst.method = "bvk") 302EC2SLS <- update(G2SLS, model = "random", inst.method = "baltagi") 303 304## Hausman-Taylor estimator and Amemiya-MaCurdy estimator 305# replicate Baltagi (2005, 2013), table 7.4; Baltagi (2021), table 7.5 306data("Wages", package = "plm") 307ht <- plm(lwage ~ wks + south + smsa + married + exp + I(exp ^ 2) + 308 bluecol + ind + union + sex + black + ed | 309 bluecol + south + smsa + ind + sex + black | 310 wks + married + union + exp + I(exp ^ 2), 311 data = Wages, index = 595, 312 random.method = "ht", model = "random", inst.method = "baltagi") 313summary(ht) 314 315am <- plm(lwage ~ wks + south + smsa + married + exp + I(exp ^ 2) + 316 bluecol + ind + union + sex + black + ed | 317 bluecol + south + smsa + ind + sex + black | 318 wks + married + union + exp + I(exp ^ 2), 319 data = Wages, index = 595, 320 random.method = "ht", model = "random", inst.method = "am") 321summary(am) 322 323} 324\references{ 325\insertRef{AMEM:71}{plm} 326 327\insertRef{AMEM:MACU:86}{plm} 328 329\insertRef{BALE:VARA:87}{plm} 330 331\insertRef{BALT:81}{plm} 332 333\insertRef{BALT:SONG:JUNG:01}{plm} 334 335\insertRef{BALT:13}{plm} 336 337\insertRef{BREU:MIZO:SCHM:89}{plm} 338 339\insertRef{HAUS:TAYL:81}{plm} 340 341\insertRef{NERLO:71}{plm} 342 343\insertRef{SWAM:AROR:72}{plm} 344 345\insertRef{WALL:HUSS:69}{plm} 346} 347\seealso{ 348\code{\link[=summary.plm]{summary.plm()}} for further details about the associated 349summary method and the "summary.plm" object both of which provide some model 350tests and tests of coefficients. \code{\link[=fixef]{fixef()}} to compute the fixed 351effects for "within" models (=fixed effects models). 352} 353\author{ 354Yves Croissant 355} 356\keyword{regression} 357