View source: R/tool_model.extract.R

pmodel.response | R Documentation |

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

```
pmodel.response(object, ...)
## S3 method for class 'plm'
pmodel.response(object, ...)
## S3 method for class 'data.frame'
pmodel.response(object, ...)
## S3 method for class 'formula'
pmodel.response(object, data, ...)
```

`object` |
an object of class |

`...` |
further arguments. |

`data` |
a |

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 `Formula`

+ `data`

(being a model frame) 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.

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.

Yves Croissant

`plm`

's `model.matrix()`

for (transformed)
model matrix and the corresponding `model.frame()`

method to construct a model frame.

```
# First, make a pdata.frame
data("Grunfeld", package = "plm")
pGrunfeld <- pdata.frame(Grunfeld)
# then make a model frame from a Formula and a pdata.frame
form <- inv ~ value + capital
mf <- model.frame(pGrunfeld, form)
# 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_mf, pmodel.response(fe_model), check.attributes = FALSE) # TRUE
```

plm documentation built on April 9, 2023, 5:06 p.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.