likelihood_saem: likelihood_saem

Description Usage Arguments Value Examples

View source: R/zzz.R

Description

Used in main function miss.saem. Calculate the observed log-likelihood for logistic regression model with missing data, using Monte Carlo version of Louis formula.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
likelihood_saem(
  beta,
  mu,
  Sigma,
  Y,
  X.obs,
  rindic = as.matrix(is.na(X.obs)),
  whichcolXmissing = (1:ncol(rindic))[apply(rindic, 2, sum) > 0],
  mc.size = 2
)

Arguments

beta

Estimated parameter of logistic regression model.

mu

Estimated parameter μ.

Sigma

Estimated parameter Σ.

Y

Response vector N * 1

X.obs

Design matrix with missingness N * p

rindic

Missing pattern of X.obs. If a component in X.obs is missing, the corresponding position in rindic is 1; else 0.

whichcolXmissing

The column index in covariate containing at least one missing observation.

mc.size

Monte Carlo sampling size.

Value

Observed log-likelihood.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# Generate dataset
N <- 50  # number of subjects
p <- 3     # number of explanatory variables
mu.star <- rep(0,p)  # mean of the explanatory variables
Sigma.star <- diag(rep(1,p)) # covariance
beta.star <- c(1, 1,  0) # coefficients
beta0.star <- 0 # intercept
beta.true = c(beta0.star,beta.star)
X.complete <- matrix(rnorm(N*p), nrow=N)%*%chol(Sigma.star) +
              matrix(rep(mu.star,N), nrow=N, byrow = TRUE)
p1 <- 1/(1+exp(-X.complete%*%beta.star-beta0.star))
y <- as.numeric(runif(N)<p1)
# Generate missingness
p.miss <- 0.10
patterns <- runif(N*p)<p.miss #missing completely at random
X.obs <- X.complete
X.obs[patterns] <- NA

# Observed log-likelihood
ll_obs = likelihood_saem(beta.true,mu.star,Sigma.star,y,X.obs)

misaem documentation built on April 12, 2021, 9:06 a.m.