bnmarg {bernor} | R Documentation |
Evaluate by Monte Carlo the observed data log density for Bernoulli regression model with normal random effects.
bnmarg(y, beta, sigma, nmiss, x, z, i, model, deriv = 0, want.weights = FALSE)
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 |
deriv |
the number of derivatives wanted. No more than 2. Zero, the default, means no derivatives. |
want.weights |
logical, |
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.
A list containing some of the following components:
value |
the function value. |
gradient |
the gradient vector. The length is
|
hessian |
the hessian matrix. The dimension is
|
weigh |
the vector of normalized importance weights. |
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)