Learn R Programming

⚠️There's a newer version (1.4.8) of this package.Take me there.

BMisc

BMisc includes miscellaneous functions for working with panel data, quantiles, and printing results.

Installation

You can install BMisc from github with:

# install.packages("devtools")
devtools::install_github("bcallaway11/BMisc")

or from CRAN with:

install.packages("BMisc")

Example 1

One of the most useful functions in the BMisc package is makeDist which takes a vector of observations and turns them into a distribution function.

library(BMisc)
y <- rnorm(100)
y <- y[order(y)]
u <- runif(100)
u <- u[order(u)]
F <- makeDist(y,u)
class(F)
#> [1] "ecdf"     "stepfun"  "function"
##plot(F)

Example 2

Another useful function is the makeBalancedPanel function which drops observations from a panel dataset which are not available in all time periods.

id <- rep(seq(1,100,1),2) ## individual ids for setting up a two period panel
t <- rep(seq(1,2),100) ## time periods
y <- rnorm(200) ## outcomes
dta <- 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)
nrow(dta)
#> [1] 199
dta <- makeBalancedPanel(dta, idname="id", tname="t")
nrow(dta) ## now all the observations with missing data in any period are dropped
#> [1] 198

Copy Link

Version

Install

install.packages('BMisc')

Monthly Downloads

4,442

Version

1.4.2

License

GPL-2

Maintainer

Brantly Callaway

Last Published

December 18th, 2020

Functions in BMisc (1.4.2)

invertEcdf

Invert Ecdf
panel2cs

Panel Data to Repeated Cross Sections
lhs.vars

Left-hand Side Variables
panel2cs2

Panel Data to Repeated Cross Sections
ids2rownum

Convert Vector of ids into Vector of Row Numbers
getListElement

Return Particular Element from Each Element in a List
subsample

Subsample of Observations from Panel Data
id2rownum

Take particular id and convert to row number
toformula

Variable Names to Formula
getWeightedQuantiles

Get Weighted Quantiles
getWeightedQuantile

Quantile of a Weighted Check Function
getWeightedDf

Weighted Distribution Function
weighted.checkfun

Weighted Check Function
getWeightedMean

Weighted Mean
makeBalancedPanel

Balance a Panel Data Set
rhs

Right-hand Side of Formula
makeDist

Make a Distribution Function
rhs.vars

Right-hand Side Variables
combineDfs

Combine Two Distribution Functions
blockBootSample

Block Bootstrap
BMisc

BMisc
compareSingleBinary

Compare a single variable across two groups
checkfun

Check Function
compareBinary

Compare Variables across Groups
dropCovFromFormla

Drop a Covariate from a Formula
cs2panel

Cross Section to Panel
addCovToFormla

Add a Covariate to a Formula