bnmarg {bernor}R Documentation

Observed Data Log Density for Bernoulli-Normal Random Effects Model

Description

Evaluate by Monte Carlo the observed data log density for Bernoulli regression model with normal random effects.

Usage

bnmarg(y, beta, sigma, nmiss, x, z, i, model, deriv = 0, want.weights = FALSE)

Arguments

y

a zero-one-valued (Bernoulli) vector, the response.

beta

the fixed effect vector.

sigma

the scale parameter vector for the fixed effects.

nmiss

integer, the number of simulations of the missing data.

x

the model matrix for fixed effects.

z

the model matrix for random effects.

i

the index vector for random effects.

model

the model for the importance sampling distribution, an object of class model produced by the model function.

deriv

the number of derivatives wanted. No more than 2. Zero, the default, means no derivatives.

want.weights

logical, TRUE if want weights returned.

Details

evaluates by good old-fashioned (IID) Monte Carlo observed data log density as if doing the R statements

    logf <- rep(NA, nmiss)
    logh <- rep(NA, nmiss)
    for (j in 1:nmiss) {
        b <- rmiss(model)
        out <- bernor(y, beta, b, sigma, x, z, i)
        logf[j] <- out$value
        logh[j] <- dmiss(b, model)
    }
    mean(exp(logf / logh))
  
or, more precisely, the same thing done so as to avoid overflow.

Value

A list containing some of the following components:

value

the function value.

gradient

the gradient vector. The length is nparm, which is length(beta) + length(mu).

hessian

the hessian matrix. The dimension is nparm by nparm.

weigh

the vector of normalized importance weights.

See Also

bernor, bnlogl.

Examples

data(salam)
attach(salam)
beta <- c(0.91, -3.01, -0.49, 3.54)
sigma <- c(1.18, 0.98)
moo <- model("gauss", length(i), 1)
nmiss <- 100
bnmarg(y[ , 1], beta, sigma, nmiss, x, z, i, moo, deriv = 2)

[Package bernor version 0.3-8 Index]