Learn R Programming

plm (version 0.3-1)

plm.data: Data Frame Special Format for Panel Data

Description

This function transform a data frame in a format suitable for the use of the estimation functions of plm.

Usage

x <- plm.data(x, index = NULL)

Arguments

x
a data.frame,
index
a vector (of length one or two) indicating the (individual and time) indexes.

Value

  • A data.frame.

Details

indexes can be :
  • a character string which is the name of the individual index variable, in this case a new variable called ``time'' which contains the time index is added,
  • an integer, the number of individuals in case of balanced panel, in this case two new variables ``time'' and ``id'' which contain the individual and the time indexes are added,
  • a vector of two character strings which contains the names of the individual and of the time indexes.

Examples

Run this code
#There are 595 individuals

data("Wages", package="Ecdat")
Wages <- plm.data(Wages, 595)

# Gasoline contains two variables which are individual and time indexes
# The pdata.frame is called gas
data("Gasoline", package="Ecdat")
Gasoline <- plm.data(Gasoline, c("country","year"))
summary(Gasoline)

# Hedonic is an unbalanced panel, townid is the individual index
data("Hedonic", package="Ecdat")
Hedonic <- plm.data(Hedonic, "townid")

Run the code above in your browser using DataLab