| Title: | Uncertainty Intervals and Sensitivity Analysis for Missing Data |
|---|---|
| Description: | Implements functions to derive uncertainty intervals for (i) regression (linear and probit) parameters when outcome is missing not at random (non-ignorable missingness) introduced in Genbaeck, M., Stanghellini, E., de Luna, X. (2015) <doi:10.1007/s00362-014-0610-x> and Genbaeck, M., Ng, N., Stanghellini, E., de Luna, X. (2018) <doi:10.1007/s10433-017-0448-x>; and (ii) double robust and outcome regression estimators of average causal effects (on the treated) with possibly unobserved confounding introduced in Genbaeck, M., de Luna, X. (2018) <doi:10.1111/biom.13001>. |
| Authors: | Minna Genbaeck [aut, cre], |
| Maintainer: | Minna Genbaeck <[email protected]> |
| License: | GPL-2 |
| Version: | 0.1.1 |
| Built: | 2026-05-19 06:18:06 UTC |
| Source: | https://github.com/cran/ui |
ui.causal
Divides the rho interval into a grid
gridrho.f(rho, gridn, rho.plotrange, plot)gridrho.f(rho, gridn, rho.plotrange, plot)
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 |
This function derives the gradient in order for ui.probit to run faster.
grr(par, rho, X.z = X.z, X.y = X.y, y = y, z = z)grr(par, rho, X.z = X.z, X.y = X.y, y = y, z = z)
par |
Coefficients. |
rho |
Rho. |
X.z |
Covariate matrix for missingness. |
X.y |
Covariate matrix for outcome. |
y |
Outcome. |
z |
Missing or not. |
This function derives the hessian in order for ui.probit to run faster.
hess(par, rho, X.z = X.z, X.y = X.y, y = y, z = z)hess(par, rho, X.z = X.z, X.y = X.y, y = y, z = z)
par |
Coefficients. |
rho |
Rho. |
X.z |
Covariate matrix for missingness. |
X.y |
Covariate matrix for outcome. |
y |
Outcome. |
z |
Missing or not. |
This function allows you to print an interval (vector of two elements) in a parantesis single element.
interv.p(v, digits = 3)interv.p(v, digits = 3)
v |
Lower and upper bounds. |
digits |
Number of decimals. |
This function allows you to calculate the inverse Mills ratio.
lambda0(x)lambda0(x)
x |
Vector |
This function allows you to calculate the inverse Mills ratio.
lambda1(x)lambda1(x)
x |
Vector |
This function derives the Loglikelihood for ui.probit.
LogL.probit(par, rho, X.z = X.z, X.y = X.y, y = y, z = z)LogL.probit(par, rho, X.z = X.z, X.y = X.y, y = y, z = z)
par |
Coeficient values the logliklihood should be drived at. |
rho |
The value of the sensitivity parameter. |
X.z |
covariate matrix for missingness mechanism |
X.y |
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, support function for ui.causal
Logl.sandACT(x, X, z)Logl.sandACT(x, X, z)
x |
coefficents. |
X |
Covariate matrix. |
z |
Missing or not. |
This is a support function for ui.probit
ML.probit(out.formula, mis.formula = NULL, data, rho = c(-0.5, 0.5), progress = TRUE, method = "NR")ML.probit(out.formula, mis.formula = NULL, data, rho = c(-0.5, 0.5), progress = TRUE, method = "NR")
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 |
Plot function for objects returned from ui.causal.
Plots confidence intervals for different values of rho and the uncertainty interval.
## S3 method for class 'uicausal' plot(x, DR = TRUE, main = "", xlab = NULL, ylab = "", ...)## S3 method for class 'uicausal' plot(x, DR = TRUE, main = "", xlab = NULL, ylab = "", ...)
x |
An object of class uicausal |
DR |
If TRUE the doubly robust estimator is plotted, otherwise the outcome regression estimator is plotted. |
main |
Main title, default is no title. |
xlab |
Title for xaxis, default is |
ylab |
Title for y axis, default is no title. |
... |
Additional arguments, use is discouraged. |
Plot function for objects returned from ui.ols. Plots confidence intervals,
coefficients and significans assuming ignorability and the uncertainty interval under non-ignorability.
## S3 method for class 'uiols' plot(x, plot.all = TRUE, which = NA, intercept = FALSE, ylab = NULL, col = c("black", "red"), ...)## S3 method for class 'uiols' plot(x, plot.all = TRUE, which = NA, intercept = FALSE, ylab = NULL, col = c("black", "red"), ...)
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 confidence intervals (default black) and uncertainty intervals (default red). |
... |
Additional arguments, use is discouraged. |
Plot function for objects returned from ui.probit.
Plots confidence intervals, coefficients and significans assuming ignorability and the uncertainty interval under non-ignorability.
## S3 method for class 'uiprobit' plot(x, plot.all = TRUE, which = NA, intercept = FALSE, ylab = NULL, col = c("black", "red"), ...)## S3 method for class 'uiprobit' plot(x, plot.all = TRUE, which = NA, intercept = FALSE, ylab = NULL, col = c("black", "red"), ...)
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 confidence intervals (default black) and uncertainty intervals (default red). |
... |
Additional arguments, use is discouraged. |
Print function for object of class uicausal
## S3 method for class 'uicausal' print(x, digits = 3, digitsci = digits, digitsui = digits, ...)## S3 method for class 'uicausal' print(x, digits = 3, digitsci = digits, digitsui = digits, ...)
x |
An object of returned from |
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
## S3 method for class 'uiols' print(x, digits = 3, digitsci = digits, digitsui = digits, ...)## S3 method for class 'uiols' print(x, digits = 3, digitsci = digits, digitsui = digits, ...)
x |
an objects returned from |
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
## S3 method for class 'uiprobit' print(x, digits = 3, digitsci = digits, digitsui = digits, ...)## S3 method for class 'uiprobit' print(x, digits = 3, digitsci = digits, digitsui = digits, ...)
x |
an objects returned from |
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. |
Plot function for objects returned from ui.causal.
Plots confidence intervals for different values of rho0=rho1=rho.
## S3 method for class 'uicausal' profile(fitted, DR = TRUE, main = "", xlab = NULL, ylab = "", ...)## S3 method for class 'uicausal' profile(fitted, DR = TRUE, main = "", xlab = NULL, ylab = "", ...)
fitted |
An object of class uicausal |
DR |
If TRUE, plots both DR if FALSE OR. |
main |
Main title, default is no title. |
xlab |
Title for x-axis, default is |
ylab |
Title for y-axis, default is the variable names. |
... |
Additional arguments, use is discouraged. |
Plot function for objects returned from ui.ols.
Plots confidence intervals for different values of rho and the uncertainty interval.
## S3 method for class 'uiols' profile(fitted, plot.all = TRUE, which = NA, intercept = FALSE, xlab = NULL, ylab = NULL, ...)## S3 method for class 'uiols' profile(fitted, plot.all = TRUE, which = NA, intercept = FALSE, xlab = NULL, ylab = NULL, ...)
fitted |
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 |
ylab |
Title for y-axis, default is the variable names. |
... |
Additional arguments, for instance margins. |
Plot function for objects returned from ui.probit.
Plots confidence intervals for different values of rho and the uncertainty interval.
## S3 method for class 'uiprobit' profile(fitted, plot.all = TRUE, which = NA, intercept = FALSE, xlab = NULL, ylab = NULL, cex.lab = 2, mar = c(6, 6, 2, 2), ...)## S3 method for class 'uiprobit' profile(fitted, plot.all = TRUE, which = NA, intercept = FALSE, xlab = NULL, ylab = NULL, cex.lab = 2, mar = c(6, 6, 2, 2), ...)
fitted |
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 |
ylab |
Title for y-axis, default is the variable names. |
cex.lab |
Size of lables. |
mar |
Margin around panels in plot. |
... |
Additional arguments, use is discouraged. |
This is a support function for ui.causal and calculates standard error of Average causal effect on the treated for the doubly robust estimator.
sandACT(deltasigma1, X, Xz, y, z, u, BetaOLSy0, phat, NaivEst, n1, n0, N, p, pz)sandACT(deltasigma1, X, Xz, y, z, u, BetaOLSy0, phat, NaivEst, n1, n0, N, p, pz)
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. |
This is a support function for ui.causal and calculates standard error of Average causal effect for the regression imputation estimator.
sandImpACE(X, y, z, BetaOLSy0, BetaOLSy1, NaivEst, N, p)sandImpACE(X, y, z, BetaOLSy0, BetaOLSy1, NaivEst, N, p)
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. |
This is a support function for ui.causal and calculates standard error of Average causal effect on the treated for the regression imputation estimator.
sandImpACT(X, y, z, BetaOLSy0, NaivEst, n1, N, p)sandImpACT(X, y, z, BetaOLSy0, NaivEst, n1, N, p)
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. |
This function calculates the se for UI based on OLS when we have MNAR data, for ui.ols.
se.ols(X, sigmaOLScor, u, gridrho)se.ols(X, sigmaOLScor, u, gridrho)
X |
Covariate matrix. |
sigmaOLScor |
Output from sigmaOLScor1 |
u |
Fitted values from mis.model. |
gridrho |
Values of rho. |
This function is a bias correction of the residual standard deviation under MNAR, for ui.causal.
sigmaOLScor0(X, sigmaOLS, n, p, u, gridrho)sigmaOLScor0(X, sigmaOLS, n, p, u, gridrho)
X |
Covariate matrix outcome. |
sigmaOLS |
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. |
This function is a bias correction of the residual standard deviation under MNAR, used by ui.causal and ui.ols.
sigmaOLScor1(X, sigmaOLS, n, p, u, gridrho)sigmaOLScor1(X, sigmaOLS, n, p, u, gridrho)
X |
Covariate matrix outcome. |
sigmaOLS |
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. |
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.
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)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)
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 |
Pre-specified value of |
rho1 |
Pre-specified value of |
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 |
plot |
If TRUE the function runs slightly slower but you will be able to plot your results using |
rho.plotrange |
an interval larger than |
alpha |
Default 0.05 corresponding to a confidence level of 95 for CI and UI. |
In order to visualize the results, you can use plot.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
A list containing:
call |
The matched call |
rho0 |
The rage of |
rho1 |
If ACT==FALSE,range of |
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 |
OR |
OR inference, confidence intervals for different pre-specified values of |
Minna Genbäck
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
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 plot(ui) profile(ui) mean(y1-y0) ui<-ui.causal(y~x, z~x, data=data, rho=c(0,0.3), ACT=TRUE) ui plot(ui) mean(y1[z==1]-y0[z==1])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 plot(ui) profile(ui) mean(y1-y0) ui<-ui.causal(y~x, z~x, data=data, rho=c(0,0.3), ACT=TRUE) ui plot(ui) mean(y1[z==1]-y0[z==1])
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.
ui.ols(out.formula, mis.formula = NULL, data, rho = c(-0.3, 0.3), alpha = 0.05, gridn = 101)ui.ols(out.formula, mis.formula = NULL, data, rho = c(-0.3, 0.3), alpha = 0.05, gridn = 101)
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 |
In order to visualize the results, you can use plot.uiols,
or profile.uiols.
A list containing:
call |
The matched call |
ci |
Confidence intervals for different values of |
ui |
Uncertainty intervals |
coef |
Estimated coefficients (outcome regression) for different values of |
out.model |
Outcome regression model when rho=0. |
mis.model |
Regression model for missingness mechanism (selection). |
rho |
The range of |
gridrho |
The values of |
sigma |
Consistant estimate of sigma |
se |
Standard error for different values of |
ciols |
Confidence intervals from a complete case analysis |
ident.bound |
Bounds for the coefficient estimates. |
Minna Genbäck
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.
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)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)
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.
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")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")
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 |
progress |
If TRUE prints out process time for each maximization of the likelihood. |
max.grid |
Maximum distance between two elements in |
alpha |
Default 0.05 corresponding to a confidence level of 95 for CI and UI. |
method |
Maximization method to be passed through |
In order to visualize the results, you can use plot.uiprobit
or profile.uiprobit.
A list containing:
coef |
Estimated coefficients (outcome regression) for different values of |
rho |
The values of |
vcov |
Covariance matrix. |
ci |
Confidence intervals for different values of |
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 |
y |
Outcome vector. |
z |
Indicator variable of observed outcome. |
X.y |
Covariate matrix for outcome regression. |
X.z |
Covariate matrix for missingness mechanism (selection regression model). |
max.info |
Information about the maximization procedure. Includes whether it |
Minna Genbäck
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.
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.5)) m plot(m) profile(m)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.5)) m plot(m) profile(m)