# cotram-methods: Methods for Count Transformation Models In cotram: Count Transformation Models

 cotram-methods R Documentation

## Methods for Count Transformation Models

### Description

Methods for objects inheriting from class cotram

### Usage

``````## S3 method for class 'cotram'
predict(object, newdata = model.frame(object),
type = c("lp", "trafo", "distribution", "survivor", "density",
"logdensity", "hazard", "loghazard", "cumhazard",
"logcumhazard", "odds", "logodds", "quantile"),
smooth = FALSE, q = NULL, K = 20, prob = 1:(10-1)/10, ...)
## S3 method for class 'cotram'
plot(x, newdata, type = c("distribution", "survivor","density",
"logdensity", "cumhazard", "quantile", "trafo"),
confidence = c("none", "band"), level = 0.95,
smooth = FALSE, q = NULL, K = 20, cheat = K, prob = 1:(10-1)/10,
col = "black", fill = "lightgrey",
lty = 1, lwd = 1, add = FALSE, ...)
## S3 method for class 'cotram'
as.mlt(object)
## S3 method for class 'cotram'
logLik(object, parm = coef(as.mlt(object), fixed = FALSE), newdata, ...)
``````

### Arguments

 `object, x` a fitted linear count transformation model inheriting from class `cotram`. `newdata` an optional data frame of observations. `parm` model parameters. `type` type of prediction, current options include linear predictors (`"lp"`, of `x` variables in the formula `y ~ x`), transformation functions (`"trafo"`) or distribution functions on the scale of the cdf (`"distribution"`), survivor function, density function, log-density function, cumulative hazard function or quantile function. `confidence` whether to plot a confidence band (see `confband`). `level` the confidence level. `smooth` logical; if `TRUE` a smoothed function of `type` is returned. `q` quantiles at which to evaluate the model. `prob` probabilities for the evaluation of the quantile function `(type = "quantile")`. `K` number of grid points the function is evaluated at (for `smooth = TRUE` and in absence of `q`). `cheat` number of grid points the function is evaluated at when using the quantile obtained for `K` grid points (in the absence of `q` and `smooth = TRUE`). `col` color for the lines to plot. `fill` color for the confidence band. `lty` line type for the lines to plot. `lwd` line width. `add` logical; indicating if a new plot shall be generated (the default). `...` additional arguments to the underlying methods for `predict`.

### Details

`predict` and `plot` can be used to inspect the model on different scales.

`predict.cotram`, `confband.cotram`, `tram-methods`, `mlt-methods`, `plot.ctm`

### Examples

``````  op <- options(digits = 4)

data("birds", package = "TH.data")

### fit count transformation model with cloglog link
m_birds <- cotram(SG5 ~ AOT + AFS + GST + DBH + DWC + LOG, data = birds,
method = "cloglog")
logLik(m_birds)

### classical likelihood inference
## IGNORE_RDIFF_BEGIN
summary(m_birds)
## IGNORE_RDIFF_END

### coefficients of the linear predictor (discrete hazard ratios)
exp(-coef(m_birds))

### compute predicted median along with 10% and 90% quantile for the first
### three observations
nd <- birds[1:3,]
round(predict(m_birds, newdata = nd, type = "quantile", prob = c(.1, .5, .9),
smooth = TRUE), 3)

### plot the predicted distribution for these observations
plot(m_birds, newdata = nd, type = "distribution",
col = c("skyblue", "grey", "seagreen"))

options(op)
``````

cotram documentation built on May 31, 2023, 5:22 p.m.