Package {ui}


Title: Uncertainty Intervals and Sensitivity Analysis for Missing Data
Version: 1.0.1
Description: Implements functions to derive uncertainty intervals for (i) regression (linear and probit) parameters under missing not at random (non-ignorable missingness) as introduced in Genbäck, M., Stanghellini, E., and de Luna, X. (2015) <doi:10.1007/s00362-014-0610-x> and Genbäck, M., Ng, N., Stanghellini, E., and de Luna, X. (2018) <doi:10.1007/s10433-017-0448-x>. Also includes methods for doubly robust and outcome regression estimators of average causal effects under unobserved confounding as in Genbäck, M. and de Luna, X. (2018) <doi:10.1111/biom.13001>, and for partial correlation analysis following Gorbach, T. and de Luna, X. (2018) <doi:10.1016/j.spl.2018.05.027>.
Depends: R (≥ 4.1)
Imports: Matrix, maxLik, mvtnorm, numDeriv, graphics, stats, dplyr, plotly, ggplot2
Suggests: MASS, testthat (≥ 3.0.0)
Encoding: UTF-8
License: GPL-3
Config/roxygen2/version: 8.0.0
NeedsCompilation: no
Packaged: 2026-06-25 08:36:31 UTC; miahjr04
Author: Minna Genbäck [aut, cre], Tetiana Gorbach [aut]
Maintainer: Minna Genbäck <minna.genback@umu.se>
Repository: CRAN
Date/Publication: 2026-06-25 11:00:02 UTC

Support function for ui_causal

Description

Divides the rho interval into a grid

Usage

gridrho_f(rho, gridn, rho_plotrange, plot)

Arguments

rho

interval that should be divided

gridn

number of gridpoints

rho_plotrange

a larger interval of grids to be used in a plot

plot

whether or not the larger interval of grids should be created


Gradient for the loglikelihood used by ui_probit

Description

This function derives the gradient in order for ui_probit to run faster.

Usage

grr(par, rho, Xz = Xz, Xy = Xy, y = y, z = z)

Arguments

par

Coefficients.

rho

Rho.

Xz

Covariate matrix for missingness.

Xy

Covariate matrix for outcome.

y

Outcome.

z

Missing or not.


Hessian for the loglikelihood used by ui_probit

Description

This function derives the hessian in order for ui_probit to run faster.

Usage

hess(par, rho, Xz = Xz, Xy = Xy, y = y, z = z)

Arguments

par

Coefficients.

rho

Rho.

Xz

Covariate matrix for missingness.

Xy

Covariate matrix for outcome.

y

Outcome.

z

Missing or not.


Print interval in parantesis

Description

This function allows you to print an interval (vector of two elements) in a parantesis single element.

Usage

interv_p(v, digits = 3)

Arguments

v

Lower and upper bounds.

digits

Number of decimals.


Inverse Mills rato

Description

This function allows you to calculate the inverse Mills ratio.

Usage

lambda0(x)

Arguments

x

Vector


Inverse Mills rato

Description

This function allows you to calculate the inverse Mills ratio.

Usage

lambda1(x)

Arguments

x

Vector


Loglikelihood used by ui_probit

Description

This function derives the Loglikelihood for ui_probit.

Usage

logl_probit(par, rho, Xz = Xz, Xy = Xy, y = y, z = z)

Arguments

par

Coeficient values the logliklihood should be drived at.

rho

The value of the sensitivity parameter.

Xz

covariate matrix for missingness mechanism

Xy

covariate matrix for the outcome regression

y

outcome vector

z

indicator of wether y is missing or not


Loglikelohood used in sandwich estimator of average causal effect on the treated for DR

Description

Loglikelohood used in sandwich estimator of average causal effect on the treated for DR, support function for ui_causal

Usage

logl_sand_act(x, X, z)

Arguments

x

coefficents.

X

Covariate matrix.

z

Missing or not.


Fit maximum likelihood for fixed values of rho

Description

This is a support function for ui_probit

Usage

ml_probit(out_formula, mis_formula, data, rho, progress = TRUE, method = "NR")

Arguments

out_formula

Formula for outcome regression.

mis_formula

Formula for regression model for the missingness mechanism.

data

Data frame containing the variables in the formulas

rho

Vector containing the values of rho for which we want to fit the likelihood.

progress

If TRUE prints out process time for each maximazation of the likelihood.

method

Maximazation method to be passed through maxLik


Plot of UI and CI

Description

Plot function for objects returned from ui_ols. Plots confidence intervals, coefficients and significance assuming ignorability and the uncertainty interval under non-ignorability.

Usage

## S3 method for class 'uiols'
plot(
  x,
  plot.all = TRUE,
  which = NA,
  intercept = FALSE,
  ylab = NULL,
  col = c("black", "royalblue", "lightpink2"),
  ...
)

Arguments

x

An object of class uiols

plot.all

If TRUE, plots all covariates.

which

Specify which variables should be plotted by either sending in their names in a vector or a vector with their numbers (1 intercept, 2 for the first covariate etc.).

intercept

If TRUE, also plots the intercept.

ylab

Vector of names for the y-axis, default is the variable names.

col

Vector containing the color of estimates under MAR and bounds of estimate under MNAR (default black), confidence intervals (default royalblue) and uncertainty intervals (default lightpink2).

...

Additional arguments, use is discouraged.


Plot of UI and CI for partial correlation

Description

Plot function for objects returned from ui_pcor. Plots confidence intervals, coefficients and significans assuming ignorability and the uncertainty interval under non-ignorability.

Usage

## S3 method for class 'uipcor'
plot(x, col = c("black", "red"), ...)

Arguments

x

An object of class uiols

col

Vector containing the color of confidence intervals (default black) and uncertainty intervals (default red).

...

Additional arguments, use is discouraged.


Plot of UI and CI

Description

Plot function for objects returned from ui_probit.Plots confidence intervals, coefficients and significance assuming ignorability and the uncertainty interval under non-ignorability.

Usage

## S3 method for class 'uiprobit'
plot(
  x,
  plot.all = TRUE,
  which = NA,
  intercept = FALSE,
  ylab = NULL,
  col = c("black", "royalblue", "lightpink2"),
  ...
)

Arguments

x

An object of class uiprobit

plot.all

If TRUE, plots all covariates.

which

Specify which variables should be plotted by either sending in their names in a vector or a vector with their numbers (1 for the first covariate, 2 for the second etc.).To plot the intercept, set intercept as TRUE.

intercept

If TRUE, also plots the intercept.

ylab

Vector of names for the y-axis, default is the variable names.

col

Vector containing the color of estimates under MAR and bounds of estimate under MNAR (default black), confidence intervals (default royalblue) and uncertainty intervals (default lightpink2).

...

Additional arguments, use is discouraged.


Print function for object of class uicausal

Description

Print function for object of class uicausal

Usage

## S3 method for class 'uicausal'
print(x, digits = 3, digitsci = digits, digitsui = digits, ...)

Arguments

x

An object of returned from ui_causal

digits

number of digits to be printed.

digitsci

number of digits to be printed in the confidence interval.

digitsui

number of digits to be printed in the uncertainty interval.

...

Additional arguments, use is discouraged.


Prints objects of class uiols

Description

Prints objects of class uiols

Usage

## S3 method for class 'uiols'
print(x, digits = 3, digitsci = digits, digitsui = digits, ...)

Arguments

x

an objects returned from ui_ols

digits

number of digits to be printed.

digitsci

number of digits to be printed in the confidence interval.

digitsui

number of digits to be printed in the uncertainty interval.

...

Additional arguments, use is discouraged.


Prints objects of class uipcor

Description

Prints objects of class uipcor

Usage

## S3 method for class 'uipcor'
print(x, digits = 3, digitsci = digits, digitsui = digits, ...)

Arguments

x

an objects returned from ui_pcor

digits

number of digits to be printed.

digitsci

number of digits to be printed in the confidence interval.

digitsui

number of digits to be printed in the uncertainty interval.

...

Additional arguments, use is discouraged.


Prints objects of class uiprobit

Description

Prints objects of class uiprobit

Usage

## S3 method for class 'uiprobit'
print(x, digits = 3, digitsci = digits, digitsui = digits, ...)

Arguments

x

an objects returned from ui_probit

digits

number of digits to be printed.

digitsci

number of digits to be printed in the confidence interval.

digitsui

number of digits to be printed in the uncertainty interval.

...

Additional arguments, use is discouraged.


Profile method for ui objects

Description

Profile method for ui objects

Usage

profile(x, ...)

Arguments

x

Object

...

Additional arguments


Plot of UI and CI

Description

Plot function for objects returned from ui_causal. Plots confidence intervals for different values of rho and the uncertainty interval.

Usage

## S3 method for class 'uicausal'
profile(
  x,
  dr = TRUE,
  profile = "all",
  title = NULL,
  xlab = NULL,
  ylab = NULL,
  ...
)

Arguments

x

An object of class uicausal

dr

If TRUE the doubly robust estimator is plotted, otherwise the outcome regression estimator is plotted.

profile

Character specifying profile type ("ui.only" or "all"). If ui.only, only the UI range is plotted; if all, the full profile is shown.

title

Main title

xlab

Title for xaxis, default is expression(rho).

ylab

Title for y axis, default is no title.

...

discouraged from use


Plot of UI and CI

Description

Plot function for objects returned from ui_ols. Plots confidence intervals for different values of rho and the uncertainty interval.

Usage

## S3 method for class 'uiols'
profile(
  x,
  plot.all = TRUE,
  which = NA,
  intercept = FALSE,
  xlab = NULL,
  ylab = NULL,
  scales = "fixed",
  expand = 0.1,
  ...
)

Arguments

x

An object of class uiols

plot.all

If TRUE, plots all covariates.

which

Specify which variables should be plotted by either sending in their names in a vector or a vector with their numbers (1 intercept, 2 for the first covariate etc.).

intercept

If TRUE, also plots the intercept.

xlab

Title for x-axis, default is expression(rho).

ylab

Title for y-axis, default is the variable names.

scales

Fixed or different scales of the y axis between panels. Default is "fixed", the other choice is "free_y".

expand

Add space by expanding y-axis range. Default is 0.1 which is 10% extra on above and below.

...

Additional arguments, use is discouraged.


Plot of confidence intervals for partial correlation by values of the sensitivity parameter (s).

Description

Plots confidence intervals by values of sensitivity parameter (s) for objects returned from ui_pcor.

Usage

## S3 method for class 'uipcor'
profile(x, ...)

Arguments

x

An object of class uipcor

...

Additional arguments, for instance margins.

Details

Plots estimated partial correlation, lower and upper bounds of confidence intervals for different values of rho (based on on values of the sensitivity parameter(s) in x$gridrho). Plots a 2D plot when missing data only in the outcome or the same missing in the outcome and the predictor of interest (missing data mechanisms A and B). Plots a 3D plot when different missing data in the outcome and the predictor of interest (missing data mechanism C).


Plot of UI and CI

Description

Plot function for objects returned from ui_probit. Plots confidence intervals for different values of rho and the uncertainty interval.

Usage

## S3 method for class 'uiprobit'
profile(
  x,
  plot.all = TRUE,
  which = NA,
  intercept = FALSE,
  xlab = NULL,
  ylab = NULL,
  title = NULL,
  scales = "fixed",
  expand = 0.1,
  ...
)

Arguments

x

An object of class uiprobit

plot.all

If TRUE, plots all covariates.

which

Specify which variables should be plotted by either sending in their names in a vector or a vector with their numbers (1 intercept, 2 for the first covariate etc.).

intercept

If TRUE, also plots the intercept.

xlab

Title for x-axis, default is expression(rho).

ylab

Title for y-axis, default is the variable names.

title

Main title

scales

Fixed or different scales of the y axis between panels. Default is "fixed", the other choice is "free_y".

expand

Add space by expanding y-axis range. Default is 0.1 which is 10% extra on above and below.

...

Additional arguments, use is discouraged.


Calculates standard error of Average causal effect on the treated

Description

This is a support function for ui_causal and calculates standard error of Average causal effect on the treated for the doubly robust estimator.

Usage

sand_dr_act(
  deltasigma1,
  X,
  Xz,
  y,
  z,
  u,
  BetaOLSy0,
  phat,
  NaivEst,
  n1,
  n0,
  N,
  p,
  pz
)

Arguments

deltasigma1

Coefficients.

X

Covariate matrix outcome.

Xz

Covariate matrix treatment.

y

Outcome vector.

z

Missingness indicator.

u

Fitted values from propensity score regression.

BetaOLSy0

Coefficients from non-treated regression

phat

Fitted propensity scores.

NaivEst

Naiv estimates.

n1

Number of treated.

n0

Number of non-treated.

N

Total number.

p

Number of covariates outcome regression.

pz

Number of covariates treatment regression.


Calculates standard error of Average causal effect

Description

This is a support function for ui_causal and calculates standard error of Average causal effect for the outcome regression estimator.

Usage

sand_or_ace(X, y, z, BetaOLSy0, BetaOLSy1, NaivEst, N, p)

Arguments

X

Covariate matrix.

y

Outcome vector.

z

missingness indicator.

BetaOLSy0

Coefficients from non-treated regression.

BetaOLSy1

Coefficients from treated regression.

NaivEst

Naiv estimates.

N

Total number.

p

Number of covariates outcome regression.


Calculates standard error of Average causal effect on the treated

Description

This is a support function for ui_causal and calculates standard error of Average causal effect on the treated for the outcome regression estimator.

Usage

sand_or_act(X, y, z, BetaOLSy0, NaivEst, n1, N, p)

Arguments

X

Covariate matrix.

y

Outcome vector.

z

missingness indicator

BetaOLSy0

Coefficients from non-treated regression

NaivEst

Naiv estimates.

n1

Number of treated.

N

Total number.

p

Number of covariates outcome regression.


Calculation of se for OLS

Description

This function calculates the se for UI based on OLS when we have MNAR data, for ui_ols.

Usage

se_ols(X, sigma_ols_cor, u, gridrho)

Arguments

X

Covariate matrix.

sigma_ols_cor

Output from sigma_ols_cor1

u

Fitted values from mis_model.

gridrho

Values of rho.


Correction of OLS sigma for causal effects

Description

This function is a bias correction of the residual standard deviation under MNAR, for ui_causal.

Usage

sigma_ols_cor0(X, sigma_ols, n, p, u, gridrho)

Arguments

X

Covariate matrix outcome.

sigma_ols

Residual sd from outcome regression.

n

Number of complete cases.

p

Number of covariates outcome regression.

u

Fitted values from propensity score regression.

gridrho

Values of rho.


Correction of OLS sigma

Description

This function is a bias correction of the residual standard deviation under MNAR, used by ui_causal and ui_ols.

Usage

sigma_ols_cor1(X, sigma_ols, n, p, u, gridrho)

Arguments

X

Covariate matrix outcome.

sigma_ols

Residual sd from outcome regression.

n

Number of complete cases.

p

Number of covariates outcome regression.

u

Fitted values from propensity score regression.

gridrho

Values of rho.


Uncertainty intervals for Average Causal Effects

Description

This function allows you to derive uncertainty intervals for the average causal effect (ACE) or the average causal effect on the treated (ACT). The function uses a regression imputation estimator and a doubly robust estimator. The uncertainty intervals can be used as a sensitivity analysis to unconfoundedness. Note that rho=0 render the same results as assuming no unobserved confounding.

Usage

ui_causal(
  out_formula,
  treat_formula,
  data,
  rho = c(-0.3, 0.3),
  rho0 = NULL,
  rho1 = NULL,
  ACT = FALSE,
  sand = TRUE,
  gridn = 21,
  plot = TRUE,
  rho_plotrange = c(-0.5, 0.5),
  alpha = 0.05
)

Arguments

out_formula

Formula for the outcome regression models

treat_formula

Formula for the propensity score model (regression model for treatment assignment).

data

data.frame containing the variables in the formula.

rho

Pre-specified interval for rho0 and rho1.

rho0

Pre-specified value of rho0, if an interval it has to be the same as rho1.

rho1

Pre-specified value of rho1, if an interval it has to be the same as rho0.

ACT

If TRUE Average Causal effect of the Treated is calculated, if FALSE Average Causal effect is calculated. Default is FALSE.

sand

Specifies which estimator of the standard errors should be used for OR, see details.

gridn

Number of fixed points within the rho interval for which sigma0 and sigma1 should be estimated.

plot

If TRUE the function runs slightly slower but you will be able to plot your results using profile.uicausal.

rho_plotrange

an interval larger than rho for the plot using profile.uicausal.

alpha

Default 0.05 corresponding to a confidence level of 0.95 for CI and UI.

Details

In order to visualize the results, you can use profile.uicausal. Details about estimators can be found in Genbäck and de Luna (2018)

The standard errors are calculated with the following estimators:

DR ACE - simplified sandwich estimator

DR ACT - sandwich estimator

OR ACE - if sand=TRUE sandwich estimator (default and recommended), if sand=FALSE large sample variance

OR ACT - if sand=TRUE sandwich estimator (default and recommended), if sand=FALSE large sample variance

Value

A list containing:

call

The matched call

rho0

The rage of rho0 from which the ui is calculated

rho1

If ACT==FALSE,range of rho1 from which the ui is calculated

out_model0

Outcome regression model for non-treated.

out_model1

Outcome regression model for treated.

treat_model

Regression model for treatment mechanism (propensity score).

sigma0

Consistent estimate of sigma0 for different values of rho0

sigma1

Consistent estimate of sigma1 for different values of rho1

dr

DR inference, confidence intervals for different pre-specified values of rho for the OR estimator, uncertainty interval, coefficient estimates, confounding bias, indentification bounds, standard error etc.

or

OR inference, confidence intervals for different pre-specified values of rho for the OR estimator, uncertainty interval, coefficient estimates, confounding bias, indentification bounds, standard error etc.

Author(s)

Minna Genbäck

References

Genbäck, M., de Luna, X. (2018). Causal Inference Accounting for Unobserved Confounding after Outcome Regression and Doubly Robust Estimation. Biometrics. DOI: 10.1111/biom.13001

Examples

library(MASS)
n<-500
delta<-c(-0.3,0.65)
rho<-0.3
X<-cbind(rep(1,n),rnorm(n))
x<-X[,-1]
s0<-2
s1<-3
error<-mvrnorm(n, c(0,0,0), matrix(c(1,0.6,0.9,0.6,4,0.54,0.9,0.54,9), ncol=3))
zstar<-X%*%delta+error[,1]
z<- zstar>0
y1<-ifelse(x< (-1),0.2*x-0.1*x^2, ifelse(x< 1,0.3*x, ifelse(x<3,0.4-0.1*x^2,-0.2-0.1*x)))+error[,3]
y0<-ifelse(x<1.5, x-0.4*x^2, ifelse(x<2, -0.15-0.25*x+0.5*x^2, 1.85-0.25*x))+error[,2]
y<-y0
y[z==1]<-y1[z==1]
data<-data.frame(y,z,x)


ui<-ui_causal(y~x, z~x, data=data, rho=c(0,0.3), ACT=FALSE)
ui
profile(ui)
mean(y1-y0)

ui<-ui_causal(y~x, z~x, data=data, rho=c(0,0.3), ACT=TRUE)
ui
profile(ui)
profile(ui,profile="ui")
mean(y1[z==1]-y0[z==1])


Uncertainty intervals for OLS regression

Description

This function allows you to derive uncertainty intervals for OLS regression when there is missing data in the continuous outcome. The uncertainty intervals can be used as a sensitivity analysis to ignorability (missing at random). Note that rho=0 render the same results as a complete case analysis.

Usage

ui_ols(
  out_formula,
  mis_formula = NULL,
  data,
  rho = c(-0.3, 0.3),
  alpha = 0.05,
  gridn = 101
)

Arguments

out_formula

Formula for outcome regression.

mis_formula

Formula for missingness mechanism. If NULL the same covariates as in the outcome regression will be used.

data

data.frame containing the variables in the formula.

rho

The limits of rho for which the uncertainty interval should be constructed.

alpha

Default 0.05 corresponding to a confidence level of 95 for CI and UI.

gridn

The number of distinct points within the interval rho at which confidence intervals should be constructed. Default is 101.

Details

In order to visualize the results, you can use plot.uiols, or profile.uiols.

Value

A list containing:

call

The matched call

ci

Confidence intervals for different values of rho

ui

Uncertainty intervals

coef

Estimated coefficients (outcome regression) for different values of rho

out_model

Outcome regression model when rho=0.

mis_model

Regression model for missingness mechanism (selection).

rho

The range of rho for which we want to construct an uncertainty interval

gridrho

The values of rho for which bias and standard errors are derived

sigma

Consistant estimate of sigma

se

Standard error for different values of rho

ciols

Confidence intervals from a complete case analysis

ident_bound

Bounds for the coefficient estimates.

Author(s)

Minna Genbäck

References

Genbäck, M., Stanghellini, E., de Luna, X. (2015). Uncertainty Intervals for Regression Parameters with Non-ignorable Missingness in the Outcome. Statistical Papers, 56(3), 829-847.

Examples

library(MASS)
n<-500
delta<-c(0.5,0.3,0.1)
beta<-c(0.8,-0.2,0.3)
X<-cbind(rep(1,n),rnorm(n),rbinom(n,1,0.5))
x<-X[,-1]
rho=0.4
error<-mvrnorm(n,c(0,0),matrix(c(1,rho*2,rho*2,4),2))
zstar<-X%*%delta+error[,1]
z<-as.numeric(zstar>0)
y<-X%*%beta+error[,2]
y[z==0]<-NA
data<-data.frame(y,x,z)
ui<-ui_ols(y~X1+X2,data=data,rho=c(-0.5,0.5))
ui
plot(ui)


Uncertainty intervals for partial correlation

Description

This function is used to calculate uncertainty intervals for partial correlation between two variables adjusting for a set of other variables. The two variables of interest might have missing data according to the three missing data mechanisms (see reference). Data for the variables in the adjustment set should be completely observed.

Usage

ui_pcor(
  out_formula,
  data,
  rho = c(-0.3, 0.3),
  rho2 = rho,
  alpha = 0.05,
  gridn = 101,
  gridn2 = 11
)

Arguments

out_formula

Regression formula where one variable of interest is the outcome and another variable of interest is the first predictor. Other predictors are variables in the adjustment set.

data

data.frame containing the variables in the formula.

rho

The min and the max of the sensitivity parameter.

rho2

The min and the max of the sensitivity parameter rho2 in the model for missing in the predictor of interest within missing data mechanism C. The same as rho by default.

alpha

Significance level. Default 0.05 corresponding to a confidence level of 0.95 for CI and UI.

gridn

The number of distinct points for rho at which confidence intervals should be constructed. Default is 101.

gridn2

The number of distinct points for rho2 at which confidence intervals should be constructed for missing data mechanism C. Default is 11.

Details

In order to visualize the results, you can use plot.uipcor. In the initial publication (see reference), the sensitivity parameter is called gamma, while the function denote the sensitivity paramter as rho for the corespondence with other functions in the package.

Value

A list containing:

call

The matched call

out_formula

Regression formula where one variable of interest is the outcome and another variable of interest is the first predictor. Other predictors are variables in the adjustment set.

out_model

A result of a call to lm for the specified regression.

mis_formula

Regression formula for missingness mechanism(s).

mis_model

A result of a call to glm for probit model (s) for the missingness mechanism(s).

rho

The range of values for the sensitivity parameter, rho, for which an uncertainty interval is constructed. Default is (-0.3; 0.3).

gridrho

The values of the sensitivity parameter rho (parameters rho1 and rho2 for missing data mechanisms C) for which confidence intervals are constructed.

pcor, rho0

Estimated partial correlation assuming that the sensitivity parameter(s) is 0.

pcor

Estimated partial correlation for different values of the sensitivity parameter(s) in gridrho.

ident.bound

Bounds for the estimated identification region for partial correlation. An interval from the lowest to the largest estimated partial correlation.

pcor.se

Standard error for different values of the sensitivity parameter(s) in gridrho.

ci.rho0

Confidence interval for partial correlation assuming that the sensitivity parameter(s) is 0.

ci

Confidence intervals for partial correlation for different values of the sensitivity parameter(s) in gridrho.

ui

Uncertainty interval for partial correlation. An interval from the minimum lower bound to the maximum upper bound of estimated confidence intervals.

Author(s)

Tetiana Gorbach

References

Gorbach, T., de Luna, X. (2018). Inference for partial correlation when data are missing not at random. Statistics & Probability Letters, 141, 82-89.

Examples

library(MASS)
n <- 1000
rho <- 0.1
error <- mvrnorm(n, mu = c(0, 0, 0), Sigma = diag(c(1.16, 0.028^2 * (1 - rho^2), 1)))
X3 <- rnorm(n, mean = 67, sd = 7)
X4 <- rbinom(n, 1, prob = 0.3)
X2 <- 2.313 - 0.042 * X3 - 0.216 * X4 + error[, 1]
X1 <- 1.092 + 0.01 * X2 - 0.002 * X3 - 0.006 * X4 + 0.028 * rho * error[, 3] + error[, 2]
Z <- as.numeric(2.708 + 0.548 * X2 - 0.036 * X3 - 0.042 * X4 + error[, 3] > 0)
X1[Z == 0] <- NA
data <- data.frame(X1, X2, X3, X4)
ui <-  ui_pcor(
 out_formula = X1 ~ X2 + X3 + X4,
 data = data,
 rho = c(0.1, 0.5),
 alpha = 0.05,
 gridn = 10
)
 ui


Uncertainty intervals for probit regression

Description

This function allows you to derive uncertainty intervals for probit regression when there is missing data in the binary outcome. The uncertainty intervals can be used as a sensitivity analysis to ignorability (missing at random), and are derived by maximum likelihood. Note that rho=0 render the same results as a complete case analysis.

Usage

ui_probit(
  out_formula,
  mis_formula = NULL,
  data,
  rho = c(-0.3, 0.3),
  progress = TRUE,
  max_grid = 0.1,
  alpha = 0.05,
  method = "NR"
)

Arguments

out_formula

Formula for outcome regression.

mis_formula

Formula for missingness mechanism. If NULL the same covariates as in the outcome regression will be used.

data

data.frame containing the variables in the formula.

rho

Vector containing the values of rho for which we want to fit the likelihood.

progress

If TRUE prints out process time for each maximization of the likelihood.

max_grid

Maximum distance between two elements in rho, if two wide there can difficulties with convergence of the maximum likelihood.

alpha

Default 0.05 corresponding to a confidence level of 95 for CI and UI.

method

Maximization method to be passed through maxLik

Details

In order to visualize the results, you can use plot.uiprobit or profile.uiprobit.

Value

A list containing:

coef

Estimated coefficients (outcome regression) for different values of rho.

rho

The values of rho for which the likelihood is maximized.

vcov

Covariance matrix.

ci

Confidence intervals for different values of rho.

ui

Uncertainty intervals.

out_model

Outcome regression model when rho=0.

mis_model

Regression model for missingness mechanism (selection).

se

Standard errors from outcome regression.

value

Value of maximum likelihood for different values of rho.

y

Outcome vector.

z

Indicator variable of observed outcome.

Xy

Covariate matrix for outcome regression.

Xz

Covariate matrix for missingness mechanism (selection regression model).

max.info

Information about the maximization procedure. Includes whether it converged, message, method and number of iterations.

Author(s)

Minna Genbäck

References

Genbäck, M., Ng, N., Stanghellini, E., de Luna, X. (2018). Predictors of Decline in Self-reported Health: Addressing Non-ignorable Dropout in Longitudinal Studies of Aging. European journal of ageing, 15(2), 211-220.

Examples

library(MASS)
n<-500

delta<-c(0.5,0.6,0.1,-1,1)
beta<-c(-0.3,-0.5,0,-0.4,-0.3)

X<-cbind(rep(1,n),rnorm(n),runif(n),rbinom(n,2,0.5),rbinom(n,1,0.5))
x<-X[,-1]
rho=0.4
error<-mvrnorm(n,c(0,0),matrix(c(1,rho,rho,1),2))

zstar<-X%*%delta+error[,1]
z<-as.numeric(zstar>0)

ystar<-X%*%beta+error[,2]
y<-as.integer(ystar>0)
y[z==0]<-NA
data=data.frame(y=y,x1=x[,1],x2=x[,2],x3=x[,3],x4=x[,4])

m<-ui_probit(y~x1+x2+x3+x4,data=data,rho=c(0,0.4))
m
plot(m)
profile(m)