Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/tool_model.extract.R
Methods to create model frame and model matrix for panel data.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ## S3 method for class 'pdata.frame'
model.frame(
formula,
data = NULL,
...,
lhs = NULL,
rhs = NULL,
dot = "previous"
)
## S3 method for class 'pdata.frame'
formula(x, ...)
## S3 method for class 'plm'
model.matrix(object, ...)
## S3 method for class 'pdata.frame'
model.matrix(
object,
model = c("pooling", "within", "Between", "Sum", "between", "mean", "random", "fd"),
effect = c("individual", "time", "twoways", "nested"),
rhs = 1,
theta = NULL,
cstcovar.rm = NULL,
...
)
|
data |
a |
... |
further arguments. |
lhs |
inherited from package |
rhs |
inherited from package |
dot |
inherited from package |
x |
a |
object, formula |
an object of class |
model |
one of |
effect |
the effects introduced in the model, one of
|
theta |
the parameter for the transformation if |
cstcovar.rm |
remove the constant columns, one of |
The lhs
and rhs
arguments are inherited from Formula
, see
there for more details.
The model.frame
methods return a
pdata.frame
object suitable as an input to plm's
model.matrix
.
The model.matrix
methods builds a model matrix
with transformations performed as specified by the model
and
effect
arguments (and theta
if model = "random"
is
requested), in this case the supplied data
argument should be a
model frame created by plm's model.frame
method. If not, it is
tried to construct the model frame from the data. Constructing the
model frame first ensures proper NA handling, see Examples.
The model.frame
methods return a pdata.frame
.
The
model.matrix
methods return a matrix
.
Yves Croissant
pmodel.response()
for (transformed) response
variable.
Formula::Formula()
from package Formula
,
especially for the lhs
and rhs
arguments.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # 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
mf <- model.frame(pGrunfeld, form)
# then construct the (transformed) model matrix (design matrix)
# from model frame
modmat <- model.matrix(mf, model = "within")
## retrieve model frame and model matrix from an estimated plm object
fe_model <- plm(form, data = pGrunfeld, model = "within")
model.frame(fe_model)
model.matrix(fe_model)
# same as constructed before
all.equal(mf, model.frame(fe_model), check.attributes = FALSE) # TRUE
all.equal(modmat, model.matrix(fe_model), check.attributes = FALSE) # TRUE
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.