-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Hi,
Here's a draft S4 class that creates a subclass of data.frame to implement functions for panel data and time series manipulation, or for any dyadic data.
Contents
CountryIDby @christophergandrud (wraps aroundcountrycodeby @vincentarelbundock, with edits)MoveFrontfromDataCombineby @christophergandrudclass-HomogListandsubclass_homog_listfromDataFrameConstrby @jrnoldclass-psData(hacked fromDataFrameConstrby @jrnold)constrained_data_framefromDataFrameConstrby @jrnolddebt.rda(demo Reinhart and Rogoff data)get_dataand a bunch of get (download) functions for e.g. Polity 4 and QOG datapanelwith functions by @zmjonesutils(with snippets by more authors)
I'm sure many more people have written useful code for working with panel data, including for visualization purposes—the package should probably also look in that direction, and the draft includes a Reinhart and Rogoff plot.
Output
# install
devtools::install_github("briatte/psData")
library(psData)
# example
data(debt)The object is of class data.frame:
> head(debt)
Country Year growth ratio
1 Australia 1946 -3.557951 190.41908
2 Australia 1947 2.459475 177.32137
3 Australia 1948 6.437534 148.92981
4 Australia 1949 6.611994 125.82870
5 Australia 1950 6.920201 109.80940
6 Australia 1951 4.272612 87.09448
Now add panel design variables to quickly create a psData panel object:
> as.panel(debt, "Country", "Year")
Panel data frame [ 1171 rows x 4 columns, 20 Country x 64 Year ]
Country Year growth ratio
1 Australia 1946 -3.557951 190.41908
2 Australia 1947 2.459475 177.32137
3 Australia 1948 6.437534 148.92981
4 Australia 1949 6.611994 125.82870
5 Australia 1950 6.920201 109.80940
6 Australia 1951 4.272612 87.09448
The object is now a data.frame to which the package can pass functions similar to the xt and ts commands in Stata. Country codes and basic date formats are automatically detected and usable for safe merges between multiple panel data.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels