Learn R Programming

plm (version 0.1-1)

pdata.frame: Data frame for panel data

Description

a data.frame with further attributes usefull for panel data

Usage

x <- pdata.frame(x,id,time=NULL)

Arguments

x
a data.frame
id
the individual index
time
the time index

Value

  • An object of class c("pdata.frame","data.frame"), which is a data.frame with an additional attribute panel. This attribute is a list containing :
  • indexesa list containing the names of the individual (id) and time (time) index variables,
  • nTa list containing the number of individuals (n), of time observations (T) and of total observations (N),
  • balancedTRUE for a balanced panel,
  • Tinta list of two vectors containing the number of time observation for each individual (Ti) and the number of individual observation for each time observation (nt),
  • panel.namesa list of two character vectors containing the labels of the individuals (id.names) and of the time observations (time.names),
  • dim.vara list of two logical vectors indicating wheter each variable presents variations accross individuals (id.var) and accross time periods (time.var).
  • These attributes may be extracted using synonimus functions.

Details

The observations are assumed to be sorted by individuals first and by time observations. id and time can be the names of the indexes contained in the data.frame if any. time may be ommited, in this case a new variable called "time" is added to the data.frame. For balanced pannels, the argument id can be an integer. In this case, two new variables, "time" and "id" are added to the data.frame.

pdata.frame calls pdim to check for the individual and time dimensions of the panel and pvarcheck to check for the individual and time variation of each variable.

pdata.frame adds an attribute "data" to each variable in the data.frame. This can be usefull to use simply the special panel operators in model formulas. This works properly if the result of the pdata.frame is stored in an object of the same name as its data.frame argument. The print method is inheritaded from data.frame. A summary method is provided which add to the summary.data.frame method informations about the structure of the panel.

See Also

plm

Examples

Run this code
library(Ecdat)

#There are 595 individuals

data(Wages)
Wages <- pdata.frame(Wages,595)

# Gasoline contains two variables which are individual and time indexes
data(Gasoline)
Gasoline <- pdata.frame(Gasoline,country,year)
summary(Gasoline)

# Hedonic is an unbalanced panel, townid is the individual index
data(Hedonic)
Hedonic=pdata.frame(Hedonic,townid)

Run the code above in your browser using DataLab