vb_bind_gr: Gradient of the negative log-likelihood for potentially...

Description Usage Arguments Value Examples

View source: R/vb_bind_gr.R

Description

vb_bind_gr returns the parameter gradients of negative log-likelihood for the von Bertalanffy model. Equality constraints across sexes can be implemented for any combination of parameters using the binding argument.

Usage

1
vb_bind_gr(theta, binding, data, distribution)

Arguments

theta

A parameter vector of the same length as the maximum of binding. Unconstrained parameters take the order: lnlinfF, lnlinfM, lnkF, lnkM, lnnt0F, lnnt0M, lnsigmaF, lnsigmaM.

binding

A (4x2) parameter index matrix with rows named (in order): "lnlinf", "lnk", "lnnt0", "lnsigma" and the left column for the female parameter index and right column for male parameter index. Used to impose arbitrary equality constraints across the sexes (see Examples).

data

A data.frame with columns: "age", "length" and "weights". "weights" are set to 1 or 0 for known females or males, respectively; proportions otherwise.

distribution

Character with options: "normal" or "lognormal".

Value

Vector of parameter gradients:

Examples

1
2
3
4
5
6
7
8
9
## Unconstrained model 
binding <- matrix(c(1:8), ncol = 2, byrow = TRUE)
rownames(binding) <- c("lnlinf", "lnk", "lnnt0", "lnsigma")
colnames(binding) <- c("female", "male")
## starting values 
start.par <- c(rep(log(25), 2), rep(log(0.2), 2), rep(log(3), 2), rep(log(1), 2))
vb_bind_gr(theta = start.par, binding = binding,
           data = data.frame(age = rep(1, 2), length = rep(10, 2), weights = c(1, 0)),
           distribution = "lognormal")

lhmixr documentation built on May 2, 2019, 11:05 a.m.

Related to vb_bind_gr in lhmixr...