loglikelihood: Negative 2 log likelihood

Description Usage Arguments Value Examples

Description

Calculate the -2 * log likelihood of a dataset given a specified model.

Usage

1
loglikelihood(b, dataset)

Arguments

b

intercept and coefficients of a generalized linear model.

dataset

a test dataset used to derive the likelihood.

Value

the function returns the -2 * log likelihood.

Examples

1
2
3
4
5
6
7
8
## Using the mtcars dataset
## Resample, fit an ordinary least squares model and calculate likelihood
data(mtcars)
mtc.data <- cbind(1,datashape(mtcars, y = 8, x = c(1, 6, 9)))
head(mtc.data)
mtc.boot <- randboot(mtc.data, replace = TRUE)
boot.betas <- ml.rgr(mtc.boot)
loglikelihood(b = boot.betas, dataset = mtc.data)

Example output

        mpg    wt am vs
[1,] 1 21.0 2.620  1  0
[2,] 1 21.0 2.875  1  0
[3,] 1 22.8 2.320  1  1
[4,] 1 21.4 3.215  0  1
[5,] 1 18.7 3.440  0  0
[6,] 1 18.1 3.460  0  1
         [,1]
[1,] 23.66545

apricom documentation built on May 2, 2019, 6:21 a.m.