# pmodel.response

From plm v2.2-5
0th

Percentile

##### A function to extract the model.response

pmodel.response has several methods to conveniently extract the response of several objects.

Keywords
manip
##### Usage
pmodel.response(object, ...)# S3 method for plm
pmodel.response(object, ...)# S3 method for data.frame
pmodel.response(object, ...)# S3 method for formula
pmodel.response(object, data, ...)
##### Arguments
object

an object of class "plm", or a formula of class "pFormula",

further arguments.

data

a data.frame

##### Details

The model response is extracted from a pdata.frame (where the response must reside in the first column; this is the case for a model frame), a pFormula + data or a plm object, and the transformation specified by effect and model is applied to it. Constructing the model frame first ensures proper NA handling and the response being placed in the first column, see also Examples for usage.

##### Value

A pseries except if model responses' of a "between" or "fd" model as these models "compress" the data (the number of observations used in estimation is smaller than the original data due to the specific transformation). A numeric is returned for the "between" and "fd" model.

plm's model.matrix() for (transformed) model matrix and the corresponding model.frame() method to construct a model frame.

##### Aliases
• pmodel.response
• pmodel.response.plm
• pmodel.response.data.frame
• pmodel.response.formula
##### Examples
# NOT RUN {
# First, make a pdata.frame
data("Grunfeld", package = "plm")
pGrunfeld <- pdata.frame(Grunfeld)

# then make a model frame from a pFormula and a pdata.frame

form <- inv ~ value + capital
mf <- model.frame(pGrunfeld, form)
# construct (transformed) response of the within model
resp <- pmodel.response(form, data = mf, model = "within", effect = "individual")
# retrieve (transformed) response directly from model frame
resp_mf <- pmodel.response(mf, model = "within", effect = "individual")

# retrieve (transformed) response from a plm object, i.e. an estimated model
fe_model <- plm(form, data = pGrunfeld, model = "within")
pmodel.response(fe_model)

# same as constructed before
all.equal(resp, pmodel.response(fe_model), check.attributes = FALSE) # TRUE

# }

Documentation reproduced from package plm, version 2.2-5, License: GPL (>= 2)

### Community examples

Looks like there are no examples yet.