Package {ovbsa}


Title: Sensitivity Analysis of Omitted Variable Bias
Version: 2.1.0
Description: Conduct sensitivity analysis of omitted variable bias in linear econometric models using the methodology presented in Basu (2025) <doi:10.2139/ssrn.4704246>.
License: MIT + file LICENSE
Encoding: UTF-8
RoxygenNote: 7.3.3
Imports: dplyr, ggplot2, lmtest, stats, tictoc, tidyr
Suggests: sensemakr
URL: https://github.com/dbasu-umass/ovbsa/, https://github.com/dbasu-umass/ovbsa
BugReports: https://github.com/dbasu-umass/ovbsa/issues
NeedsCompilation: no
Packaged: 2026-09-22 21:01:16 UTC; dbasu
Author: Deepankar Basu [aut, cre, cph]
Maintainer: Deepankar Basu <dbasu@umass.edu>
Repository: CRAN
Date/Publication: 2026-09-22 23:50:02 UTC

Compute bias adjusted confidence interval using truncated exponential prior distributions for kD, kY.

Description

Compute bias adjusted confidence interval using truncated exponential prior distributions for kD, kY.

Usage

baci(fit, treatment, benchmark, N = 1000, alpha = 5/100, medkd = 1, medky = 1)

Arguments

fit

An object of class lm.

treatment

A character string naming the treatment variable.

benchmark

A character string naming the benchmark variable.

N

Numeric value for grid size.

alpha

Significance level.

medkd

Median of the distribution of kD (default=1).

medky

Median of the distribution of kY (default=1).

Value

A list containing the following two elements:

results

A data frame with 2 rows ("Unadjusted" and "Bias-adjusted") and 2 columns ("Lower" and "Upper") containing the computed 100*(1-alpha)\ unadjusted and bias-adjusted confidence intervals.

undstats

A data frame of underlying statistics: the estimate, std error, max(kD) and max(k(Y).

support_kdky_plot

A ggplot2 plot object visualizing the support of the joint distribution of (kD,kY).

Examples

# CRAN requires checking if the optional package is installed before running the example
if (requireNamespace("sensemakr", quietly = TRUE)) {
  library(sensemakr)

  # Define example variables
  myN <- 500

  # Fit the model using the darfur dataset provided by sensemakr
  fit <- lm(peacefactor ~ directlyharmed + age + farmer_dar + herder_dar +
              pastvoted + hhsize_darfur + female + village,
            data = sensemakr::darfur)

  # Run baci function and see results
  res1 <- baci(fit = fit, treatment = "directlyharmed",
               benchmark = "female", N = myN, alpha = 1/100)
}

basic sensitivity analysis of omitted variable bias

Description

bsal() is deprecated; please use baci() instead.

Usage

bsal(kd, ky, alpha, data, outcome, treatment, bnch_reg, other_reg)

Arguments

kd

sensitivity parameter kD (scalar)

ky

sensitivity parameter kY (scalar)

alpha

significance level for hypothesis test (e.g. 0.05)

data

data frame for analysis

outcome

name of outcome variable

treatment

name of treatment variable

bnch_reg

name(s) of benchmark covariate(s)

other_reg

name(s) of other regressors

Value

a matrix with following rows for case 1, 2 and 3 (in columns):

r2yd.x

partial R2 of Y on D conditioning on X

r2dz.x

partial R2 of D on Z conditioning on X

r2yz.dx

partial R2 of Y on Z conditioning on D and X

estimate

unadjusted parameter estimate

adjusted_estimate

bias-adjusted parameter estimate

adjusted_se

bias-adjusted standard error

adjusted_lower_CI

bias-adjusted confidence interval lower boundary

adjusted_upper_CI

bias-adjusted confidence interval upper boundary

Examples


require("sensemakr")
Y <- "peacefactor"
D <- "directlyharmed"
X <- "female"
X_oth <- c("village","age","farmer_dar","herder_dar","pastvoted","hhsize_darfur")


res1 <- bsal(kd=1,ky=1,alpha=0.05,data=darfur,outcome=Y,treatment=D,bnch_reg=X,other_reg=X_oth)


truncated exponential density

Description

truncated exponential density

Usage

dtruncexp(x, rate = 1, a = 0, b = Inf)

Arguments

x

point between a and b at which density is computed

rate

rate parameter

a

lower bound

b

upper bound

Value

a real number

Examples

dtruncexp(x=1, rate=1, a=0, b=10)

truncated gamma density

Description

truncated gamma density

Usage

dtruncgamma(x, shape, scale, a = 0, b = Inf)

Arguments

x

point at which density is computed

shape

shape parameter

scale

scale parameter

a

lower limit (default is 0)

b

upper limit (default is Inf)

Value

a real number

Examples

dtruncgamma(x=1,shape=2, scale=3, a=0, b=20)

compute max(kD) and max(kY) for partial R2-based analysis without conditioning on treatment

Description

kdkyrngpr2ncd() is deprecated; please use baci() instead.

Usage

kdkyrngpr2ncd(data, outcome, treatment, bnch_reg, other_reg = NULL)

Arguments

data

data frame for analysis

outcome

name of outcome variable

treatment

name of treatment variable

bnch_reg

name(s) of benchmark covariate(s)

other_reg

name(s) of other covariates

Value

a data frame with 2 columns and 1 row:

kd_high

max(kD), a scalar

ky_high

max(kY), a scalar

Examples

require("sensemakr")
Y <- "peacefactor"
D <- "directlyharmed"
X <- "female"
X_oth <- c("village","age","farmer_dar","herder_dar","pastvoted","hhsize_darfur")


r1 <- kdkyrngpr2ncd(data=darfur,outcome=Y,treatment=D,bnch_reg=X,other_reg=X_oth)


compute max(kD) and max(kY) for total R2-based analysis

Description

kdkyrngtr2() is deprecated; please use baci() instead.

Usage

kdkyrngtr2(data, outcome, treatment, bnch_reg, other_reg = NULL)

Arguments

data

data frame for analysis

outcome

name of outcome variable

treatment

name of treatment variable

bnch_reg

name(s) of benchmark covariate(s)

other_reg

name(s) of other covariates

Value

a data frame with 2 columns and 1 row:

kd_high

max(kD), a scalar

ky_high

max(kY), a scalar

Examples

require("sensemakr")
Y <- "peacefactor"
D <- "directlyharmed"
X <- "female"
X_oth <- c("village","age","farmer_dar","herder_dar","pastvoted","hhsize_darfur")


r1 <- kdkyrngtr2(data=darfur,outcome=Y,treatment=D,bnch_reg=X,other_reg=X_oth)


quasi-triangular probability distribution function

Description

linvx() is deprecated; please use baci() instead.

Usage

linvx(x, xvec, k)

Arguments

x

point (scalar) at which pdf is evaluated

xvec

vector of all possible x values

k

mode and median of the distribution

Value

the value (scalar) of the pdf at x

Examples

xfull <- runif(n=100,min=0,max=10)
xpoint <- 5
xmod <- 2
res_pdf <- linvx(x=xpoint,xvec=xfull,k=xmod)


bias and std error for (kd,ky) using partial R2-based analysis without conditioning on treatment

Description

pr2ncdbias() is deprecated; please use baci() instead.

Usage

pr2ncdbias(kd, ky, alpha, data, outcome, treatment, bnch_reg, other_reg = NULL)

Arguments

kd

sensitivity parameter kD (scalar)

ky

sensitivity parameter kY (scalar)

alpha

significance level for hypothesis test (e.g. 0.05)

data

data frame for analysis

outcome

name of outcome variable

treatment

name of treatment variable

bnch_reg

name(s) of benchmark covariate(s)

other_reg

name(s) of other covariate(s)

Value

a list with the following elements:

adjestp

Adj std error when unadj estimate>0

adjestn

Adj std error when unadj estimate<0

cilbp

Adj lower boundary of conf int when unadj estimate>0

ciubp

Adj upper boundary of conf int when unadj estimate>0

cilbn

Adj lower boundary of conf int when unadj estimate<0

ciubn

Adj upper boundary of conf int when unadj estimate<0

Examples

require("sensemakr")
Y <- "peacefactor"
D <- "directlyharmed"
X <- "female"
X_oth <- c("village","age","farmer_dar","herder_dar","pastvoted","hhsize_darfur")


res4<-pr2ncdbias(kd=1,ky=1,alpha=0.05,data=darfur,outcome=Y,treatment=D,bnch_reg=X,other_reg=X_oth)


probability of conclusion being overturned using partial R2-based analysis without conditioning on treatment

Description

salpr2ncd() is deprecated; please use baci() instead.

Usage

salpr2ncd(
  alpha,
  data,
  outcome,
  treatment,
  bnch_reg,
  other_reg,
  N,
  maxkd = NULL,
  maxky = NULL,
  k_kd = 1,
  k_ky = 1
)

Arguments

alpha

significance level (scalar) for hypothesis test (e.g. 0.05)

data

data frame for analysis

outcome

name of outcome variable

treatment

name of treatment variable

bnch_reg

name(s) of benchmark covariate(s)

other_reg

name(s) of other covariate(s)

N

number of points on grid = N^2

maxkd

max of sensitivity parameter kD

maxky

max of sensitivity parameter kY

k_kd

mode (and median) of sensitivity parameter kD

k_ky

mode (and median) of sensitivity parameter kY

Value

list with the following elements:

dataplot

data set used for contour plot

kdmax

max of sensitivity parameter kD

kymax

max of sensitivity parameter kY

frac_prob

prob of conclusion being overturned (unwt)

frac_prob_wt

prob of conclusion being overturned (wt)

frac_prob_rest

prob of conclusion being overturned (unwt, rest)

frac_prob_rest_wt

prob of conclusion being overturned (wt, rest)

Examples


require("sensemakr")
Y <- "peacefactor"
D <- "directlyharmed"
X <- "female"
X_oth <- c("village","age","farmer_dar","herder_dar","pastvoted","hhsize_darfur")

darfur1 <- dplyr::slice_sample(darfur, prop=0.25)

res4 <- salpr2ncd(alpha=0.05,data=darfur1,outcome=Y,treatment=D,bnch_reg=X,other_reg=X_oth,N=500)


probability of conclusion being overturned using total R2-based analysis

Description

saltr2() is deprecated; please use baci() instead.

Usage

saltr2(
  alpha,
  data,
  outcome,
  treatment,
  bnch_reg,
  other_reg,
  N,
  maxkd = NULL,
  maxky = NULL,
  k_kd = 1,
  k_ky = 1
)

Arguments

alpha

significance level for hypothesis test (e.g. 0.05)

data

data frame for analysis

outcome

name of outcome variable

treatment

name of treatment variable

bnch_reg

name(s) of benchmark covariate(s)

other_reg

name(s) of other covariate(s)

N

number of points on grid = N^2

maxkd

max of sensitivity parameter kD

maxky

max of sensitivity parameter kY

k_kd

mode (and median) of sensitivity parameter kD

k_ky

mode (and median) of sensitivity parameter kY

Value

list with the following elements:

dataplot

data set used for contour plot

kdmax

max of sensitivity parameter kD

kymax

max of sensitivity parameter kY

frac_prob

prob of conclusion being overturned (unwt)

frac_prob_wt

prob of conclusion being overturned (wt)

frac_prob_rest

prob of conclusion being overturned (unwt, rest)

frac_prob_rest_wt

prob of conclusion being overturned (wt, rest)

Examples


require("sensemakr")
Y <- "peacefactor"
D <- "directlyharmed"
X <- "female"
X_oth <- c("village","age","farmer_dar","herder_dar","pastvoted","hhsize_darfur")

darfur1 <- dplyr::slice_sample(darfur, prop=0.25)

res3 <- saltr2(alpha=0.05,data=darfur1,outcome=Y,treatment=D,bnch_reg=X,other_reg=X_oth,N=500)


bias and std error for (kd,ky) using total R2-based analysis

Description

tr2bias() is deprecated; please use baci() instead.

Usage

tr2bias(kd, ky, alpha, data, outcome, treatment, bnch_reg, other_reg = NULL)

Arguments

kd

sensitivity parameter kD (scalar)

ky

sensitivity parameter kY (scalar)

alpha

significance level for hypothesis test (e.g. 0.05)

data

data frame for analysis

outcome

name of outcome variable

treatment

name of treatment variable

bnch_reg

name(s) of benchmark covariate(s)

other_reg

name(s) of other covariate(s)

Value

a list with the following elements:

adjestp

Adj std error when unadj estimate>0

adjestn

Adj std error when unadj estimate<0

cilbp

Adj lower boundary of conf int when unadj estimate>0

ciubp

Adj upper boundary of conf int when unadj estimate>0

cilbn

Adj lower boundary of conf int when unadj estimate<0

ciubn

Adj upper boundary of conf int when unadj estimate<0

Examples


require("sensemakr")
Y <- "peacefactor"
D <- "directlyharmed"
X <- "female"
X_oth <- c("village","age","farmer_dar","herder_dar","pastvoted","hhsize_darfur")


res2 <- tr2bias(kd=1,ky=1,alpha=0.05,data=darfur,outcome=Y,treatment=D,bnch_reg=X,other_reg=X_oth)