index.plm: Extract the indexes of panel data

Description Usage Arguments Details Value Author(s) See Also Examples

Description

This function extracts the information about the structure of the individual and time dimensions of panel data. Grouping information can also be extracted if the panel data were created with a grouping variable.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## 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" have a "model" element which is also a "pdata.frame" and therefore also has an "index" attribute. Finally, each series, once extracted from a "pdata.frame", becomes 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, all indexes are extracted. "which" can also be a vector of length 1, 2, or 3 (3 only if the pdata frame was constructed with an additional group index) containing either characters (the names of the individual variable and/or of the time variable and/or the group variable or "id" and "time") and "group" or integers (1 for the individual index, 2 for the time index, and 3 for the group index (the latter only if the pdata frame was constructed with such).)

Value

A vector or an object of class c("pindex","data.frame") containing either one index, individual and time index, or (any combination of) individual, time and group indexes.

Author(s)

Yves Croissant

See Also

pdata.frame(), plm()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
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")

# with additional group index
data("Produc", package = "plm")
pProduc <- pdata.frame(Produc, index = c("state", "year", "region"))
index(pProduc, 3)
index(pProduc, "region")
index(pProduc, "group")

plm documentation built on Sept. 21, 2021, 3:01 p.m.