crch | R Documentation |

Fitting censored (tobit) or truncated regression models with conditional heteroscedasticy.

crch(formula, data, subset, na.action, weights, offset, link.scale = c("log", "identity", "quadratic"), dist = c("gaussian", "logistic", "student"), df = NULL, left = -Inf, right = Inf, truncated = FALSE, type = c("ml", "crps"), control = crch.control(...), model = TRUE, x = FALSE, y = FALSE, ...) trch(formula, data, subset, na.action, weights, offset, link.scale = c("log", "identity", "quadratic"), dist = c("gaussian", "logistic", "student"), df = NULL, left = -Inf, right = Inf, truncated = TRUE, type = c("ml", "crps"), control = crch.control(...), model = TRUE, x = FALSE, y = FALSE, ...) crch.fit(x, z, y, left, right, truncated = FALSE, dist = "gaussian", df = NULL, link.scale = "log", type = "ml", weights = NULL, offset = NULL, control = crch.control())

`formula` |
a formula expression of the form |

`data` |
an optional data frame containing the variables occurring in the formulas. |

`subset` |
an optional vector specifying a subset of observations to be used for fitting. |

`na.action` |
a function which indicates what should happen when the data
contain |

`weights` |
optional case weights in fitting. |

`offset` |
optional numeric vector with |

`link.scale` |
character specification of the link function in
the scale model. Currently, |

`dist` |
assumed distribution for the dependent variable |

`df` |
optional degrees of freedom for |

`left` |
left limit for the censored dependent variable |

`right` |
right limit for the censored dependent variable |

`truncated` |
logical. If |

`type` |
loss function to be optimized. Can be either |

`control` |
a list of control parameters passed to |

`model` |
logical. If |

`x, y` |
for |

`z` |
a design matrix with regressors for the scale. |

`...` |
arguments to be used to form the default |

`crch`

fits censored (tobit) or truncated regression models with conditional
heteroscedasticy with maximum likelihood estimation. Student-t, Gaussian, and
logistic distributions can be fitted to left- and/or right censored or
truncated responses. Different regressors can be used to model the location
and the scale of this distribution. If `control=crch.boost()`

optimization is performed by boosting.

`trch`

is a wrapper function for `crch`

with default
`truncated = TRUE`

.

`crch.fit`

is the lower level function where the actual
fitting takes place.

An object of class `"crch"`

or `"crch.boost"`

, i.e., a list with the
following elements.

`coefficients` |
list of coefficients for location, scale, and df. Scale and df coefficients are in log-scale. |

`df` |
if |

`residuals` |
the residuals, that is response minus fitted values. |

`fitted.values` |
list of fitted location and scale parameters. |

`dist` |
assumed distribution for the dependent variable |

`cens` |
list of censoring points. |

`optim` |
output from optimization from |

`method` |
optimization method used for |

`type` |
used loss function (maximum likelihood or minimum CRPS). |

`control` |
list of control parameters passed to |

`start` |
starting values of coefficients used in the optimization. |

`weights` |
case weights used for fitting. |

`offset` |
list of offsets for location and scale. |

`n` |
number of observations. |

`nobs` |
number of observations with non-zero weights. |

`loglik` |
log-likelihood. |

`vcov` |
covariance matrix. |

`link` |
a list with element |

`truncated` |
logical indicating wheter a truncated model has been fitted. |

`converged` |
logical variable whether optimization has converged or not. |

`iterations` |
number of iterations in optimization. |

`call` |
function call. |

`formula` |
the formula supplied. |

`terms` |
the |

`levels` |
list of levels of the factors used in fitting for location and scale respectively. |

`contrasts` |
(where relevant) the contrasts used. |

`y` |
if requested, the response used. |

`x` |
if requested, the model matrix used. |

`model` |
if requested, the model frame used. |

`stepsize, mstop, mstopopt, standardize` |
return values of boosting
optimization. See |

Messner JW, Mayr GJ, Zeileis A (2016). Heteroscedastic Censored and
Truncated Regression with crch.
*The R Journal*, **3**(1), 173–181.
https://journal.R-project.org/archive/2016-1/messner-mayr-zeileis.pdf.

Messner JW, Zeileis A, Broecker J, Mayr GJ (2014). Probabilistic Wind Power
Forecasts with an Inverse Power Curve Transformation and Censored Regression.
*Wind Energy*, **17**(11), 1753–1766. doi: 10.1002/we.1666.

`predict.crch`

, `crch.control`

, `crch.boost`

data("RainIbk") ## mean and standard deviation of square root transformed ensemble forecasts RainIbk$sqrtensmean <- apply(sqrt(RainIbk[,grep('^rainfc',names(RainIbk))]), 1, mean) RainIbk$sqrtenssd <- apply(sqrt(RainIbk[,grep('^rainfc',names(RainIbk))]), 1, sd) ## fit linear regression model with Gaussian distribution CRCH <- crch(sqrt(rain) ~ sqrtensmean, data = RainIbk, dist = "gaussian") ## same as lm? all.equal( coef(lm(sqrt(rain) ~ sqrtensmean, data = RainIbk)), head(coef(CRCH), -1), tol = 1e-6) ## print CRCH ## summary summary(CRCH) ## left censored regression model with censoring point 0: CRCH2 <- crch(sqrt(rain) ~ sqrtensmean, data = RainIbk, dist = "gaussian", left = 0) ## left censored regression model with censoring point 0 and ## conditional heteroscedasticy: CRCH3 <- crch(sqrt(rain) ~ sqrtensmean|sqrtenssd, data = RainIbk, dist = "gaussian", left = 0) ## left censored regression model with censoring point 0 and ## conditional heteroscedasticy with logistic distribution: CRCH4 <- crch(sqrt(rain) ~ sqrtensmean|sqrtenssd, data = RainIbk, dist = "logistic", left = 0) ## compare AIC AIC(CRCH, CRCH2, CRCH3, CRCH4)

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.