Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

gfun

Gradients of common densities


Description

Gradients of common density functions in their standard forms, i.e., with zero location (mean) and unit scale. These are implemented in C for speed and care is taken that the correct results are provided for the argument being NA, NaN, Inf, -Inf or just extremely small or large.

Usage

gnorm(x)

glogis(x)

gcauchy(x)

Arguments

x

numeric vector of quantiles.

Details

The gradients are given by:

  • gnorm: If f(x) is the normal density with mean 0 and spread 1, then the gradient is

    f'(x) = -x f(x)

  • glogis: If f(x) is the logistic density with mean 0 and scale 1, then the gradient is

    f'(x) = 2 \exp(-x)^2 (1 + \exp(-x))^{-3} - \exp(-x)(1+\exp(-x))^{-2}

  • pcauchy: If f(x) =1 / [pi (1 + x^2)^2] is the cauchy density with mean 0 and scale 1, then the gradient is

    f'(x) = -2x / [pi (1 + x^2)^2]

These gradients are used in the Newton-Raphson algorithms in fitting cumulative link models with clm and cumulative link mixed models with clmm.

Value

a numeric vector of gradients.

Author(s)

Rune Haubo B Christensen

See Also

Gradients of densities are also implemented for the extreme value distribtion (gumbel) and the the log-gamma distribution (log-gamma).

Examples

x <- -5:5
gnorm(x)
glogis(x)
gcauchy(x)

ordinal

Regression Models for Ordinal Data

v2019.12-10
GPL (>= 2)
Authors
Rune Haubo Bojesen Christensen [aut, cre]
Initial release
2019-12-10

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.