# objfun.pmtree

0th

Percentile

##### Objective function of a given pmtree

Returns the contributions to the objective function or the sum thereof (if sum = TRUE).

##### Usage
# S3 method for pmtree
objfun(x, newdata = NULL, weights = NULL,
perm = NULL, sum = FALSE, ...)
##### Arguments
x

pmtree object.

newdata

an optional new data frame for which to compute the sum of objective functions.

weights

weights.

perm

the number of permutations performed (see varimp).

sum

should the sum of objective functions be computed.

...

passed on to predict.party.

Note that objfun.pmtree(x, sum = TRUE) is much faster than sum(objfun.pmtree(x)).

##### Value

objective function or the sum thereof

##### Aliases
• objfun.pmtree
##### Examples
# NOT RUN {
## generate data
set.seed(2)
n <- 1000
trt <- factor(rep(1:2, each = n/2))
age <- sample(40:60, size = n, replace = TRUE)
eff <- -1 + I(trt == 2) + 1 * I(trt == 2) * I(age > 50)
expit <- function(x) 1/(1 + exp(-x))
success <- rbinom(n = n, size = 1, prob = expit(eff))
dat <- data.frame(success, trt, age)

## compute base model
bmod1 <- glm(success ~ trt, data = dat, family = binomial)

## copmute tree
(tr1 <- pmtree(bmod1, data = dat))

## compute log-Likelihood
logLik(tr1)
objfun(tr1, newdata = dat, sum = TRUE)
objfun(tr1, sum = TRUE)

## log-Likelihood contributions of first
## 5 observations
nd <- dat[1:5, ]
objfun(tr1, newdata = nd)
# }

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

### Community examples

Looks like there are no examples yet.