btscs {pltesim}R Documentation

Generate spells for binary variables

Description

Generate spells for binary variables

Usage

btscs(df, event, t_var, cs_unit, pad_ts = FALSE)

Arguments

df

a data frame

event

character string naming the binary variable identifying the event. Note 1 must signify events and 0 non-events.

t_var

character string with the name of the time variable.

cs_unit

character string with the name of the cross-sectional unit.

pad_ts

logical indicating whether or not to fill in the time-series if panels are unbalanced.

Value

The original (df) data frame with an additional spell_time value identifying the number of observed periods in the spell, i.e. time points since the last period.

Source

This function is a port of Dave Armstrong's btscs function from:

Dave Armstrong (2015). DAMisc: Dave Armstrong's Miscellaneous Functions. R package version 1.3. https://CRAN.R-project.org/package=DAMisc.

It was ported largely to reduce the dependencies needed for the examples. There are also internal improvements, largely to handle single period spells and to start the spell time counter from 1.

David's package implemented the Stata function from:

Beck, N.. J. Katz and R. Tucker. 1998. "Beyond Ordinary Logit: Taking Time Seriously in Binary-Time-Series-Cross-Section Models". American Journal of Political Science 42(4): 1260-1288.

Examples

data('negative')

neg_set <- btscs(df = negative, event = 'y', t_var = 'tim', cs_unit = 'group')


[Package pltesim version 1.0 Index]