punbalancedness: Measures for Unbalancedness of Panel Data

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

View source: R/tool_misc.R

Description

This function reports unbalancedness measures for panel data as defined in \insertCiteAHRE:PINC:81;textualplm and \insertCiteBALT:SONG:JUNG:01;textualplm.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
punbalancedness(x, ...)

## S3 method for class 'pdata.frame'
punbalancedness(x, ...)

## S3 method for class 'data.frame'
punbalancedness(x, index = NULL, ...)

## S3 method for class 'panelmodel'
punbalancedness(x, ...)

Arguments

x

a panelmodel, a data.frame, or a pdata.frame object,

...

further arguments.

index

only relevant for data.frame interface, for details see pdata.frame(),

Details

punbalancedness returns measures for the unbalancedness of a panel data set.

If the panel data are balanced, both measures equal 1. The more "unbalanced" the panel data, the lower the measures (but > 0). The upper and lower bounds as given in \insertCiteAHRE:PINC:81;textualplm are:
0 < γ, ν ≤ 1, and for ν more precisely 1/n < ν ≤ 1, with n being the number of individuals (as in pdim(x)$nT$n).

Values are 1 if the data are balanced and become smaller as the data become more unbalanced.

An application of the measure "gamma" is found in e. g. \insertCiteBALT:SONG:JUNG:01;textualplm, pp. 488-491, and \insertCiteBALT:CHAN:94;textualplm, pp. 78–87, where it is used to measure the unbalancedness of various unbalanced data sets used for Monte Carlo simulation studies. Measures c1, c2, c3 are used for similar purposes in \insertCiteBALT:SONG:JUNG:01;textualplm.

In the two-dimensional case, punbalancedness uses output of pdim() to calculate the two unbalancedness measures, so inputs to punbalancedness can be whatever pdim works on. pdim returns detailed information about the number of individuals and time observations (see pdim()).

Value

A named numeric containing either two or three entries, depending on the panel structure inputted:

Note

Calling punbalancedness on an estimated panelmodel object and on the corresponding (p)data.frame used for this estimation does not necessarily yield the same result (true also for pdim). When called on an estimated panelmodel, the number of observations (individual, time) actually used for model estimation are taken into account. When called on a (p)data.frame, the rows in the (p)data.frame are considered, disregarding any NA values in the dependent or independent variable(s) which would be dropped during model estimation.

Author(s)

Kevin Tappe

References

\insertRef

AHRE:PINC:81plm

\insertRef

BALT:CHAN:94plm

\insertRef

BALT:SONG:JUNG:01plm

\insertRef

BALT:SONG:JUNG:02plm

See Also

nobs(), pdim(), pdata.frame()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Grunfeld is a balanced panel, Hedonic is an unbalanced panel
data(list=c("Grunfeld", "Hedonic"), package="plm")

# Grunfeld has individual and time index in first two columns
punbalancedness(Grunfeld) # c(1,1) indicates balanced panel
pdim(Grunfeld)$balanced   # TRUE

# Hedonic has individual index in column "townid" (in last column)
punbalancedness(Hedonic, index="townid") # c(0.472, 0.519)
pdim(Hedonic, index="townid")$balanced   # FALSE

# punbalancedness on estimated models
plm_mod_pool <- plm(inv ~ value + capital, data = Grunfeld)
punbalancedness(plm_mod_pool)

plm_mod_fe <- plm(inv ~ value + capital, data = Grunfeld[1:99, ], model = "within")
punbalancedness(plm_mod_fe)

# replicate results for panel data design no. 1 in Ahrens/Pincus (1981), p. 234
ind_d1  <- c(1,1,1,2,2,2,3,3,3,3,3,4,4,4,4,4,4,4,5,5,5,5,5,5,5)
time_d1 <- c(1,2,3,1,2,3,1,2,3,4,5,1,2,3,4,5,6,7,1,2,3,4,5,6,7)
df_d1 <- data.frame(individual = ind_d1, time = time_d1)
punbalancedness(df_d1) # c(0.868, 0.887)

# example for a nested panel structure with a third index variable
# specifying a group (states are grouped by region) and without grouping
data("Produc", package = "plm")
punbalancedness(Produc, index = c("state", "year", "region"))
punbalancedness(Produc, index = c("state", "year")) 

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