Last chance! 50% off unlimited learning
Sale ends in
Evaluates the objective function for approximate maximum likelihood for an aster model with random effects. Uses Laplace approximation to integrate out the random effects analytically. The “quasi” in the title is a misnomer in the context of aster models but the acronym PQL for this procedure is well-established in the generalized linear mixed models literature.
newpickle(alphaceesigma, fixed, random, obj, y, origin, zwz, deriv = 0)
a list with components value
and gradient
,
the latter missing if deriv == 0
.
the parameter value where the function is evaluated, a numeric vector, see details.
the model matrix for fixed effects. The number of rows
is nrow(obj$data)
. The number of columns is the number of fixed
effects.
the model matrix or matrices for random effects.
The number of rows is nrow(obj$data)
. The number of columns
is the number of random effects in a group. Either a matrix or a list
each element of which is a matrix.
aster model object, the result of a call to aster
.
response vector. May be omitted, in which case obj$x
is used. If supplied, must be a matrix of the same dimensions as
obj$x
.
origin of aster model. May be omitted, in which case
default origin (see aster
) is used. If supplied, must be
a matrix of the same dimensions obj$x
.
A possible value of alphaceesigma
. See details.
Number of derivatives wanted, either zero or one.
Must be zero if zwz
is missing.
Define
glm
but the origin in the terminology
of aster
), where fixed
of this function),
random
of this functions if it is a matrix or
Reduce(cbind, random)
if random
is a list of matrices),
where rep(sigma, times = nrand)
where nrand
is sapply(random, ncol)
when random
is a list of
matrices and ncol(random)
when random
is a matrix,
and where zwz
is missing.
Otherwise it evaluates the same thing except that
zwz
.
Note that
data(radish)
pred <- c(0,1,2)
fam <- c(1,3,2)
### need object of type aster to supply to penmlogl and pickle
aout <- aster(resp ~ varb + fit : (Site * Region + Block + Pop),
pred, fam, varb, id, root, data = radish)
### model matrices for fixed and random effects
modmat.fix <- model.matrix(resp ~ varb + fit : (Site * Region),
data = radish)
modmat.blk <- model.matrix(resp ~ 0 + fit:Block, data = radish)
modmat.pop <- model.matrix(resp ~ 0 + fit:Pop, data = radish)
rownames(modmat.fix) <- NULL
rownames(modmat.blk) <- NULL
rownames(modmat.pop) <- NULL
idrop <- match(aout$dropped, colnames(modmat.fix))
idrop <- idrop[! is.na(idrop)]
modmat.fix <- modmat.fix[ , - idrop]
nfix <- ncol(modmat.fix)
nblk <- ncol(modmat.blk)
npop <- ncol(modmat.pop)
alpha.start <- aout$coefficients[match(colnames(modmat.fix),
names(aout$coefficients))]
cee.start <- rep(0, nblk + npop)
sigma.start <- rep(1, 2)
alphaceesigma.start <- c(alpha.start, cee.start, sigma.start)
foo <- newpickle(alphaceesigma.start, fixed = modmat.fix,
random = list(modmat.blk, modmat.pop), obj = aout)
Run the code above in your browser using DataLab