statistic#

View page source

Some Statistical Function Definitions#

Notation#

y#

If \(z\) is not present, we are computing residual and statistical density for \(y\) or \(\log( y + \eta )\).

z#

If \(z\) is present, we are computing the residual and statistical density for \(z - y\) or \(\log( z + \eta ) - \log ( y + \eta )\). This is used for smoothing difference of model_variables with respect to age and time.

mu#

In the linear case, \(\mu\) denotes the expected value for \(y\) or the difference between \(y\) and \(z\). In the log case, it denotes the expected value for \(\log( y + \eta )\) or the difference between \(\log( y + \eta )\) and \(\log( z + \eta )\).

delta#

If the density is Linear , this is the standard deviation for \(y\) or \(z - y\), If the density is Log Scaled , this is the standard deviation for \(\log( y + \eta )\) or \(\log( z + \eta ) - \log ( y + \eta )\). Note that \(\delta\) has a different definition for different cases:

  1. For data cases, other than binomial, \(\delta\) is define by the transformed standard deviation delta \(\delta_i( \theta )\).

  2. For value prior cases, \(\delta\) is defined by the transformed standard deviation delta_j , delta_j ,

  3. For difference prior cases, \(\delta\) is the same as the prior table standard deviation sigma_ij , sigma_ij .

eta#

We use \(\eta\) to denote the offset in log transform for the corresponding entry in the data or prior table.

nu#

We use \(\nu\) to denote the degrees of freedom in Student’s-t for the corresponding entry in the data or prior table.

d#

We use \(d\) to denote the density_id for the corresponding entry in the data or prior table. In an abuse of notation, we write \(\eta[d]\), \(\nu[d]\) for the offset and degrees corresponding to the same entry in the data or prior table.

Weighted Residual Function, R#

Value#

If the density is uniform , the weighted residual function for values is

\[R(y, \mu, \delta, d) = 0\]

If the density is Linear , the weighted residual function for values is

\[R(y, \mu, \delta, d) = \frac{y - \mu}{\delta}\]

If the density is Log Scaled , the weighted residual function for values is

\[R(y, \mu, \delta, d) = \frac{ \log( y + \eta[d] ) - \log( \mu + \eta[d] ) }{ \delta }\]

Note that, for both the linear and log case, \(\mu\) has the same units as \(y\).

Difference#

If the density is uniform, the weighted residual function for differences is

\[R(z, y, \mu, \delta, d) = 0\]

If the density is Linear , the weighted residual function for differences is

\[R(z, y, \mu, \delta, d) = \frac{z - y - \mu}{\delta}\]

Note that, in the linear case, all the arguments (except \(d\)) have the same units. If the density is Log Scaled , the weighted residual function for differences is

\[R(z, y, \mu, \delta, d) = \frac{ \log(z + \eta[d] ) - \log( y + \eta[d] ) - \mu }{ \delta }\]

Note that in the log case, \(z, y\) and \(\eta\) have the same units while \(\mu\) and \(\delta\) are in log space.

Log-Density Function, D#

In the discussion below, log scaling refers to scaling the argument to the density function and log-density refers to taking the log of the result of the density function.

Uniform#

If the density is uniform , the log-density function for values \(D(y, \mu, \delta, d)\), and for differences \(D(z, y, \mu, \delta, d)\), are both defined by \(D = 0\).

Binomial#

The binomial density can only used for the likelihood of data values (not for variable priors). The corresponding log-density function \(D(y, \mu, \delta, d)\) is defined by

\[D = \log \left[ {n \choose k} \mu^k (1- \mu )^{n-k} \right]\]
  1. Here \(n\) is the sample size for this data value \(y\) , \(k = n y\) is the success count, and \(\mu\) is the average integrand corresponding to \(y\) .

  2. The standard deviation for \(k\) is \(\sqrt{n \mu (1 - \mu)}\) . Dividing by \(n\) and dropping the \((1 - \mu)\) term, the weight residuals for this distribution are computed using \(\delta = \sqrt{\mu / n}\) .

  3. If the average integrand for binomial data is zero, you will get a message saying that the corresponding standard deviation is not greater than zero.

Gaussian#

If the density name is gaussian , the log-density functions for values \(D(y, \mu, \delta, d)\), and for differences \(D(z, y, \mu, \delta, d)\), are defined by

\[D = - \log \left( \delta \sqrt{2 \pi} \right) - \frac{1}{2} R^2\]

where \(D\) and \(R\) have the same arguments; see Weighted Residual Function, R .

Censored Gaussian#

If the density name is cen_gaussian , the log-density function is not defined for differences. The log-density function for values \(y > 0\) is the same as for the gaussian case. The log-density function for the values \(y \leq 0\), is defined by

\[D(y, \mu, \delta, d) = \log ( \R{erfc}[ \mu / ( \delta \sqrt{2} ) ] ) - \log(2)\]

where \(\R{erfc}\) is the complementary error function; see the Gaussian case for the censored density where the censoring value is \(c = 0\).

Log-Gaussian#

If the density name is log_gaussian , the log-density function for values is

\[D(y, \mu, \delta, d) = - \log \left[ \delta \sqrt{2 \pi} \right] - \frac{1}{2} R(y, \mu, \delta, d)^2\]

The log-density function for differences is

\[D(z, y, \mu, \delta, d) = - \log \left( \delta \sqrt{2 \pi} \right) - \frac{1}{2} R(z, y, \mu, \delta, d)^2\]

Censored Log-Gaussian#

If the density name is cen_log_gaussian , the log-density function is not defined for differences. The log-density function for values \(y > 0\) is the same as for the log_gaussian case. The log-density function for the values \(y \leq 0\), is defined by

\[D(y, \mu, \delta, d) = \log ( \R{erfc}[ ( \mu - \eta ) / ( \delta \sqrt{2} ) ] ) - \log(2)\]

where we the arguments to \(\delta\) are the same as in the log Gaussian case and \(\R{erfc}\) is the complementary error function; see the Gaussian case for the censored density where the censoring value is \(c = \eta\).

Laplace#

If the density name is laplace , the log-density functions for values \(D(y, \mu, \delta, d)\), and for differences \(D(z, y, \mu, \delta, d)\), are defined by

\[D = - \log \left( \delta \sqrt{2} \right) - \sqrt{2} | R |\]

where \(D\) and \(R\) have the same arguments.

Censored Laplace#

If the density name is cen_laplace , the log-density function is not defined for differences. The log-density function for values \(y > 0\) is the same as for the laplace case. The log-density function for the values \(y \leq 0\), is defined by

\[D(y, \mu, \delta, d) = - \mu \sqrt{2} / \delta - \log(2)\]

where \(\R{erfc}\) is the complementary error function; see the Gaussian case for the censored density where the censoring value is \(c = 0\).

Log-Laplace#

If the density name is log_laplace , the log-density function for values is

\[D(y, \mu, \delta, d) = - \log \left[ \delta \sqrt{2} \right] - \sqrt{2} \left| R(y, \mu, \delta, d) \right|\]

The log-density function for differences is

\[D(z, y, \mu, \delta, d) = - \log \left( \delta \sqrt{2} \right) - \sqrt{2} \left| R(z, y, \mu, \delta, d) \right|\]

Censored Log-Laplace#

If the density name is cen_log_laplace , the log-density function is not defined for differences. The log-density function for values \(y > 0\) is the same as for the log_laplace case. The log-density function for the values \(y \leq 0\), is defined by

\[D(y, \mu, \delta, d) = - ( \mu - \eta ) \sqrt{2} / \delta - \log(2)\]

where we the arguments to \(\delta\) are the same as in the log Laplace case. See the Laplace case for the censored density where the censoring value is \(c = \eta\).

Student’s-t#

If the density name is students , the log-density functions for values \(D(y, \mu, \delta, d)\), and for differences \(D(z, y, \mu, \delta, d)\), are defined by

\[D = \log \left( \frac{ \Gamma( ( \nu + 1 ) / 2 ) }{ \sqrt{ \nu \pi } \Gamma( \nu / 2 ) } \right) - \frac{\nu + 1}{2} \log \left( 1 + R^2 / ( \nu - 2 ) \right)\]

where \(D\) and \(R\) have the same arguments and we have abbreviated \(\nu[d]\) using just \(\nu\).

Log-Student’s-t#

If the density name is log_students , the log-density functions for values \(D(y, \mu, \delta, d)\), and for differences \(D(z, y, \mu, \delta, d)\), are defined by

\[D = \log \left( \frac{ \Gamma( ( \nu + 1 ) / 2 ) }{ \sqrt{ \nu \pi } \Gamma( \nu / 2 ) } \right) - \frac{\nu + 1}{2} \log \left( 1 + R^2 / ( \nu - 2 ) \right)\]

where \(D\) and \(R\) have the same arguments.