QGlink.funcs: List of functions according to a distribution and a link...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/source.R

Description

Function yielding different functions (inverse-link, variance function, derivative of the inverse-link) according to a distribution and link function.

Usage

1
QGlink.funcs(name, n.obs = NULL, theta = NULL)

Arguments

name

Name of the distribution.link couple. See QGparams for a complete list of model available. (character)

n.obs

Optional parameter required for "binomN" distributions (number of "trials"). See QGparams. (numeric)

theta

Optional parameter required for "negbin" distributions (dispersion parameter). See QGparams. (numeric)

Details

This function takes the name of a distribution.link couple and yields several important functions such as the inverse-link function and its derivative, as well as the "distribution variance function".

The inverse-link function is the inverse function of the link function. For example, if the link function is the natural logarithm (typically for a Poisson distribution), then the inverse-link function is the exponential.

The distribution variance function is a function yielding the variance of the distribution for a given latent trait. For a Poisson distribution, the variance is equal to the mean, hence the variance function is equal to the inverse-link function. For a binomial distribution, the variance is N * p(l) * (1 - p(l)), where p is the inverse-link function.

For some distributions, such as "binomN" and "negbin", some extra-parameters are required.

Value

This function yields a list of function:

Author(s)

Pierre de Villemereuil & Michael B. Morrissey

See Also

QGparams, QGmvparams

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Getting the functions for a Poisson.log model
QGlink.funcs("Poisson.log")
# Note that because the variance is equal to the mean in a Poisson distribution
# and the derivative of exp is exp
# all functions are the same!

## Getting the functions for a binom1.probit model
QGlink.funcs("binom1.probit")

## The function QGparams automatically computes these functions
QGparams(mu = 0, var.p = 2, var.a = 1, model = "binom1.logit")
# Hence this is the same as using the custom.model argument with QGlink.funcs
QGparams(mu = 0, var.p = 2, var.a = 1, custom.model = QGlink.funcs("binom1.logit"))

## We can create our own custom set of functions
# Let's create a custom model exactly identical to QGlink.funcs("binom1.logit")
custom <- list(inv.link = function(x){plogis(x)},
               var.func = function(x){plogis(x) * (1 - plogis(x))},
               d.inv.link = function(x){dlogis(x)})
    
QGparams(mu = 0, var.p = 2, var.a = 1, custom.model = custom)

QGglmm documentation built on Jan. 7, 2020, 5:06 p.m.