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.7

License

GPL-2

Issues

Pull Requests

Stars

Forks

Maintainer

Brantly Callaway

Last Published

January 10th, 2025

Functions in BMisc (1.4.7)

get_YiGmin1

get_YiGmin1
get_Yibar_pre

get_Yibar_pre
get_first_difference

get_first_difference
makeDist

Make a Distribution Function
getWeightedQuantiles

Get Weighted Quantiles
get_Yit_inner

get_Yit_inner
ids2rownum

Convert Vector of ids into Vector of Row Numbers
get_Yi1

get_Yi1
get_Yit

get_Yit
makeBalancedPanel

Balance a Panel Data Set
rhs

Right-hand Side of Formula
get_principal_components

get_principal_components
id2rownum

Take particular id and convert to row number
get_lagYi

get_lagYi
rhs.vars

Right-hand Side Variables
weighted.checkfun

Weighted Check Function
getWeightedMean

Weighted Mean
invertEcdf

Invert Ecdf
getWeightedQuantile

Quantile of a Weighted Check Function
lhs.vars

Left-hand Side Variables
multiplier_bootstrap

multiplier_bootstrap
mv_mult

Matrix-Vector Multiplication
t2orig

t2orig
source_all

source_all
subsample

Subsample of Observations from Panel Data
get_YiGmin1_inner

get_YiGmin1_inner
orig2t

orig2t
get_group

get_group
get_Yibar

get_Yibar
get_group_inner

get_group_inner
t2orig_inner

t2orig_inner
time_invariant_to_panel

time_invariant_to_panel
orig2t_inner

orig2t_inner
toformula

Variable Names to Formula
panel2cs2

Panel Data to Repeated Cross Sections
panel2cs

Panel Data to Repeated Cross Sections
BMisc

BMisc
checkfun

Check Function
TorF

TorF
blockBootSample

Block Bootstrap
check_staggered

check_staggered
addCovToFormla

Add a Covariate to a Formula
combineDfs

Combine Two Distribution Functions
compareBinary

Compare Variables across Groups
drop_collinear

drop_collinear
getListElement

Return Particular Element from Each Element in a List
cs2panel

Cross Section to Panel
getWeightedDf

Weighted Distribution Function
check_staggered_inner

check_staggered_inner
compareSingleBinary

Compare a single variable across two groups
get_Yi1_inner

get_Yi1_inner
element_wise_mult

element_wise_mult
dropCovFromFormla

Drop a Covariate from a Formula
get_Yibar_pre_inner

get_Yibar_pre_inner
get_Yibar_inner

get_Yibar_inner