index {plm}R Documentation

Extract the indexes of panel data

Description

This function extracts the information about the structure of the individual and time dimensions of panel data.

Usage

## S3 method for class 'pindex'
index(x, which = NULL, ...)
## S3 method for class 'pdata.frame'
index(x, which = NULL, ...)
## S3 method for class 'pseries'
index(x, which = NULL, ...)
## S3 method for class 'panelmodel'
index(x, which = NULL, ...)

Arguments

x

an object of class "pindex", "pdata.frame", "pseries" or "panelmodel",

which

the index(es) to be extracted (see details),

...

further arguments.

Details

panel data are stored in a "pdata.frame" which has an "index" attribute. Fitted models in "plm" has a "model" element which is also a "pdata.frame" and therefore also have an "index" attribute. Finally, each series in a "pdata.frame" is of class "pseries", which also has this "index" attribute. "index" methods are available for all these objects. The argument "which" indicates which index should be extracted. If which = NULL, both indexes are extracted, but "which" can also be a vector of length 1 or 2 containing either characters (the names of the individual variable and/or of the time variable or "id" and "time") or integers (1 for the individual index and 2 for the time index.)

Value

a vector or a "data.frame" containing either one index or both indexes.

Author(s)

Yves Croissant

See Also

plm

Examples

data("Grunfeld", package = "plm")
Gr <- pdata.frame(Grunfeld, index = c("firm", "year"))
m <- plm(inv ~ value + capital, data = Gr)
index(Gr, "firm")
index(Gr, "time")
index(Gr$inv, c(2, 1))
index(m, "id")

[Package plm version 1.6-5 Index]