# mc_variance_function: Variance Functions In mcglm: Multivariate Covariance Generalized Linear Models

## Description

Compute the variance function and its derivatives with respect to regression, dispersion and power parameters.

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10``` ```mc_variance_function(mu, power, Ntrial, variance, inverse, derivative_power, derivative_mu) mc_power(mu, power, inverse, derivative_power, derivative_mu) mc_binomialP(mu, power, inverse, Ntrial, derivative_power, derivative_mu) mc_binomialPQ(mu, power, inverse, Ntrial, derivative_power, derivative_mu) ```

## Arguments

 `mu` a numeric vector. In general the output from `mc_link_function`. `power` a numeric value (`power` and `binomialP`) or a vector (`binomialPQ`) of the power parameters. `Ntrial` number of trials, useful only when dealing with binomial response variables. `variance` a string specifying the name (```power, binomialP or binomialPQ```) of the variance function. `inverse` logical. Compute the inverse or not. `derivative_power` logical if compute (TRUE) or not (FALSE) the derivatives with respect to the power parameter. `derivative_mu` logical if compute (TRUE) or not (FALSE) the derivative with respect to the mu parameter.

## Details

The function `mc_variance_function` computes three features related with the variance function. Depending on the logical arguments, the function returns V^{1/2} and its derivatives with respect to the parameters power and mu, respectivelly. The output is a named list, completely informative about what the function has been computed. For example, if `inverse = FALSE`, ```derivative_power = TRUE``` and `derivative_mu = TRUE`. The output will be a list, with three elements: V_sqrt, D_V_sqrt_power and D_V_sqrt_mu.

## Value

A list with from one to four elements depends on the arguments.

## Author(s)

Wagner Hugo Bonat, [email protected]

## Source

Bonat, W. H. and Jorgensen, B. (2016) Multivariate covariance generalized linear models. Journal of Royal Statistical Society - Series C X(X):XX–XX.

`mc_link_function`.
 ```1 2 3 4 5 6 7``` ```x1 <- seq(-1, 1, l = 5) X <- model.matrix(~x1) mu <- mc_link_function(beta = c(1, 0.5), X = X, offset = NULL, link = "logit") mc_variance_function(mu = mu\$mu, power = c(2, 1), Ntrial = 1, variance = "binomialPQ", inverse = FALSE, derivative_power = TRUE, derivative_mu = TRUE) ```