logLik.vlm | R Documentation |
Calculates the log-likelihood value or the element-by-element contributions of the log-likelihood.
## S3 method for class 'vlm'
logLik(object, summation = TRUE, ...)
object |
Some VGAM object, for example, having
class |
summation |
Logical, apply |
... |
Currently unused.
In the future:
other possible arguments fed into
|
By default, this function returns the log-likelihood of the object. Thus this code relies on the log-likelihood being defined, and computed, for the object.
Returns the log-likelihood of the object.
If summation = FALSE
then a n
-vector or
n
-row matrix (with the number of responses as
the number of columns) is returned.
Each element is the contribution to the log-likelihood.
The prior weights are assimulated within the answer.
Not all VGAM family functions have had the
summation
checked.
Not all VGAM family functions currently have the
summation
argument implemented.
T. W. Yee.
VGLMs are described in vglm-class
;
VGAMs are described in vgam-class
;
RR-VGLMs are described in rrvglm-class
;
AIC
;
anova.vglm
.
zdata <- data.frame(x2 = runif(nn <- 50))
zdata <- transform(zdata, Ps01 = logitlink(-0.5 , inverse = TRUE),
Ps02 = logitlink( 0.5 , inverse = TRUE),
lambda1 = loglink(-0.5 + 2*x2, inverse = TRUE),
lambda2 = loglink( 0.5 + 2*x2, inverse = TRUE))
zdata <- transform(zdata, y1 = rzipois(nn, lambda = lambda1, pstr0 = Ps01),
y2 = rzipois(nn, lambda = lambda2, pstr0 = Ps02))
with(zdata, table(y1)) # Eyeball the data
with(zdata, table(y2))
fit2 <- vglm(cbind(y1, y2) ~ x2, zipoisson(zero = NULL), data = zdata)
logLik(fit2) # Summed over the two responses
sum(logLik(fit2, sum = FALSE)) # For checking purposes
(ll.matrix <- logLik(fit2, sum = FALSE)) # nn x 2 matrix
colSums(ll.matrix) # log-likelihood for each response
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.