Learn R Programming

plm (version 1.2-0)

pvar: Check Whether Variables of a Panel Have Individual and Time Variations

Description

This function checks for each variable of a panel if it has an individual and a time variation.

Usage

pvar(x, ...)
## S3 method for class 'data.frame':
pvar(x, index = NULL, ...)
## S3 method for class 'pdata.frame':
pvar(x, ...)
## S3 method for class 'pvar':
print(x, ...)

Arguments

x
a data.frame,
index
...
further arguments.

Value

  • an object of class pvar containing the following elements :
  • id.vara logical vector with TRUE values if the variable has individual variation, FALSE otherwise,
  • time.vara logical vector with TRUE values if the variable has time variation, FALSE otherwise,

Details

pvar can be time consuming for ``big'' panels.

Examples

Run this code
#There are 595 individuals

data("Wages",package="plm")
pvar(Wages, 595)

# Gasoline contains two variables which are individual and time indexes
# and are the first two variables
data("Gasoline", package = "plm")
pvar(Gasoline)

# Hedonic is an unbalanced panel, townid is the individual index ; the
# drop.index argument is passed to pdata.frame
data("Hedonic", package = "plm")
pvar(Hedonic,"townid", drop.index = TRUE)

# same using pdata.frame
Hed <- pdata.frame(Hedonic, "townid", drop.index = TRUE)
pvar(Hed)

Run the code above in your browser using DataLab