BMisc includes miscellaneous functions for working with panel data, quantiles, dealing with formulas, among other things.
You can install BMisc from github with:
# install.packages("devtools")
::install_github("bcallaway11/BMisc") devtools
or from CRAN with:
install.packages("BMisc")
The make_dist
creates a distribution function from a
vector of value of the random variable and the corresponding value of
its cdf.
library(BMisc)
<- rnorm(100)
y <- y[order(y)]
y <- runif(100)
u <- u[order(u)]
u <- make_dist(y, u)
F class(F)
#> [1] "ecdf" "stepfun" "function"
# plot(F)
Another useful function is the make_balanced_panel
function which drops observations from a panel dataset which are not
available in all time periods.
<- rep(seq(1, 100, 1), 2) ## individual ids for setting up a two period panel
id <- rep(seq(1, 2), 100) ## time periods
t <- rnorm(200) ## outcomes
y <- data.frame(id = id, t = t, y = y) ## make into data frame
dta <- dta[-7, ] ## drop the 7th row from the dataset (which creates an unbalanced panel)
dta nrow(dta)
#> [1] 199
<- make_balanced_panel(dta, idname = "id", tname = "t")
dta nrow(dta) ## now all the observations with missing data in any period are dropped
#> [1] 198