Compute the variance function and its derivatives with respect to regression, dispersion and power parameters.
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)
mu | a numeric vector. In general the output from
|
---|---|
power | a numeric value ( |
Ntrial | number of trials, useful only when dealing with binomial response variables. |
variance | a string specifying the name ( |
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. |
Bonat, W. H. and Jorgensen, B. (2016) Multivariate covariance generalized linear models. Journal of Royal Statistical Society - Series C 65:649--675.
A list with from one to four elements depends on the arguments.
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.
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)#> $V_sqrt #> 5 x 5 diagonal matrix of class "ddiMatrix" #> [,1] [,2] [,3] [,4] [,5] #> [1,] 0.382466 . . . . #> [2,] . 0.3846942 . . . #> [3,] . . 0.3791238 . . #> [4,] . . . 0.3668165 . #> [5,] . . . . 0.3491967 #> #> $D_V_sqrt_p #> 5 x 5 diagonal matrix of class "ddiMatrix" #> [,1] [,2] [,3] [,4] [,5] #> [1,] -0.09065917 . . . . #> [2,] . -0.07441352 . . . #> [3,] . . -0.05938248 . . #> [4,] . . . -0.04620587 . #> [5,] . . . . -0.03516643 #> #> $D_V_sqrt_q #> 5 x 5 diagonal matrix of class "ddiMatrix" #> [,1] [,2] [,3] [,4] [,5] #> [1,] -0.1862757 . . . . #> [2,] . -0.2186738 . . . #> [3,] . . -0.2489444 . . #> [4,] . . . -0.2754662 . #> [5,] . . . . -0.2970639 #> #> $D_V_sqrt_mu #> [1] 0.10792045 -0.03313504 -0.18624891 -0.35165473 -0.52998085 #>