Description Usage Arguments Value Examples

View source: R/pmtree-methods.R

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

).

1 2 3 |

`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 |

`sum` |
should the sum of objective functions be computed. |

`...` |
passed on to Note that |

objective function or the sum thereof

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ```
## 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)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.