objfun

0th

Percentile

Objective function

Get the contributions of an objective function. For glm these are the (weighted) log-likelihood contributions, for lm the negative (weighted) squared error.

Usage
objfun(x, ...)

# S3 method for survreg objfun(x, newdata = NULL, weights = NULL, ...)

# S3 method for lm objfun(x, newdata = NULL, weights = NULL, ...)

# S3 method for glm objfun(x, newdata = NULL, weights = NULL, log = TRUE, ...)

Arguments
x

model object.

...

further arguments passed on to objfun methods.

newdata

optional. New data frame. Can be useful for model evaluation / benchmarking.

weights

optional. Prior weights. See glm or lm.

log

should the log-Likelihood contributions or the Likelhood contributions be returned?

Value

vector of objective function contributions.

Aliases
  • objfun
  • objfun.survreg
  • objfun.lm
  • objfun.glm
Examples
# NOT RUN {
## Example taken from ?stats::glm
## Dobson (1990) Page 93: Randomized Controlled Trial :
counts <- c(18,17,15,20,10,20,25,13,12) 
outcome <- gl(3,1,9)
treatment <- gl(3,3)
print(d.AD <- data.frame(treatment, outcome, counts))
glm.D93 <- glm(counts ~ outcome + treatment, family = poisson())
logLik_contributions <- objfun(glm.D93)
sum(logLik_contributions)
logLik(glm.D93)

if(require("survival")) {
  x <- survreg(Surv(futime, fustat) ~ rx, ovarian, dist = "weibull")
  newdata <- ovarian[3:5, ]

  sum(objfun(x))
  x$loglik

  objfun(x, newdata = newdata)
}

# }
Documentation reproduced from package model4you, version 0.9-5, License: GPL-2 | GPL-3

Community examples

Looks like there are no examples yet.