is.pbalanced: Check if data are balanced

Description Usage Arguments Details Value See Also Examples

View source: R/is.pconsecutive_pbalanced.R

Description

This function checks if the data are balanced, i.e., if each individual has the same time periods

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
is.pbalanced(x, ...)

## Default S3 method:
is.pbalanced(x, y, ...)

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

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

## S3 method for class 'pseries'
is.pbalanced(x, ...)

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

## S3 method for class 'pgmm'
is.pbalanced(x, ...)

Arguments

x

an object of class pdata.frame, data.frame, pseries, panelmodel, or pgmm,

...

further arguments.

y

(only in default method) the time index variable (2nd index variable),

index

only relevant for data.frame interface; if NULL, the first two columns of the data.frame are assumed to be the index variables; if not NULL, both dimensions ('individual', 'time') need to be specified by index as character of length 2 for data frames, for further details see pdata.frame(),

Details

Balanced data are data for which each individual has the same time periods. The returned values of the is.pbalanced(object) methods are identical to pdim(object)$balanced. is.pbalanced is provided as a short cut and is faster than pdim(object)$balanced because it avoids those computations performed by pdim which are unnecessary to determine the balancedness of the data.

Value

A logical indicating whether the data associated with object x are balanced (TRUE) or not (FALSE).

See Also

punbalancedness() for two measures of unbalancedness, make.pbalanced() to make data balanced; is.pconsecutive() to check if data are consecutive; make.pconsecutive() to make data consecutive (and, optionally, also balanced).
pdim() to check the dimensions of a 'pdata.frame' (and other objects), pvar() to check for individual and time variation of a 'pdata.frame' (and other objects), pseries(), data.frame(), pdata.frame().

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# take balanced data and make it unbalanced
# by deletion of 2nd row (2nd time period for first individual)
data("Grunfeld", package = "plm")
Grunfeld_missing_period <- Grunfeld[-2, ]
is.pbalanced(Grunfeld_missing_period)     # check if balanced: FALSE
pdim(Grunfeld_missing_period)$balanced    # same

# pdata.frame interface
pGrunfeld_missing_period <- pdata.frame(Grunfeld_missing_period)
is.pbalanced(Grunfeld_missing_period)

# pseries interface
is.pbalanced(pGrunfeld_missing_period$inv)

plm documentation built on March 3, 2021, 1:12 a.m.