Miscellaneous Functions for Panel Data, Quantiles, and Printing Results

These are miscellaneous functions for working with panel data, quantiles, and printing results. For panel data, the package includes functions for making a panel data balanced (that is, dropping missing individuals that have missing observations in any time period), converting id numbers to row numbers, and to treat repeated cross sections as panel data under the assumption of rank invariance. For quantiles, there are functions to make distribution functions from a set of data points (this is particularly useful when a distribution function is created in several steps), to combine distribution functions based on some external weights, and to invert distribution functions. Finally, there are several other miscellaneous functions for obtaining weighted means, weighted distribution functions, and weighted quantiles; to generate summary statistics and their differences for two groups; and to add or drop covariates from formulas.

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


You can install BMisc from github with:


or from CRAN with:


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.

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

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)
#> [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


BMisc 1.3.1

  • Update rhs.vars to fix bug related to formulas like y~x+I(x^2)

  • Update toformula to allow for no right hand side variables

BMisc 1.3.0

  • Added function \code{invertEcdf} to take distribution functions (ecdf objects) and turn them into step functions for the quantiles.

  • Improved code for working with formulas

BMisc 1.2.0

  • Added function \code{subsample} for obtaining a subsample of a panel data set

BMisc 1.1.0

  • Added function addCovToFormla which adds covariate(s) to a particular formula

BMisc 1.0.1

  • Removed dependency on qte package

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.4.4 by Brantly Callaway, 2 days ago

Browse source code at https://github.com/cran/BMisc

Authors: Brantly Callaway [aut, cre]

Documentation:   PDF Manual  

GPL-2 license

Imports data.table, Rcpp

Suggests testthat, plm, tibble

Linking to Rcpp, RcppArmadillo

Imported by DRDID, csabounds, did, qte.

See at CRAN