Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ ordered_logistic_lpmf() [2/3]

template<bool propto, typename T_y , typename T_loc , typename T_cut , require_all_not_nonscalar_prim_or_rev_kernel_expression_t< T_y, T_loc, T_cut > * = nullptr>
return_type_t< T_loc, T_cut > stan::math::ordered_logistic_lpmf ( const T_y &  y,
const T_loc &  lambda,
const T_cut &  c 
)

Returns the (natural) log probability of the specified array of integers given the vector of continuous locations and specified cutpoints in an ordered logistic model.

Typically the continuous location will be the dot product of a vector of regression coefficients and a vector of predictors for the outcome

\[ \frac{\partial }{\partial \lambda} = \begin{cases}\\ -\mathrm{logit}^{-1}(\lambda - c_1) & \mbox{if } k = 1,\\ -(((1-e^{c_{k-1}-c_{k-2}})^{-1} - \mathrm{logit}^{-1}(c_{k-2}-\lambda)) + ((1-e^{c_{k-2}-c_{k-1}})^{-1} - \mathrm{logit}^{-1}(c_{k-1}-\lambda))) & \mathrm{if } 1 < k < K, \mathrm{and}\\ \mathrm{logit}^{-1}(c_{K-2}-\lambda) & \mathrm{if } k = K. \end{cases} \]

\[ \frac{\partial }{\partial \lambda} = \begin{cases} -\mathrm{logit}^{-1}(\lambda - c_1) & \text{if } k = 1,\\ -(((1-e^{c_{k-1}-c_{k-2}})^{-1} - \mathrm{logit}^{-1}(c_{k-2}-\lambda)) + ((1-e^{c_{k-2}-c_{k-1}})^{-1} - \mathrm{logit}^{-1}(c_{k-1}-\lambda))) & \text{if } 1 < k < K, \text{ and}\\ \mathrm{logit}^{-1}(c_{K-2}-\lambda) & \text{if } k = K. \end{cases} \]

Template Parameters
proptoTrue if calculating up to a proportion.
T_yY variable type (integer or array of integers).
T_locLocation type.
T_cutCut-point type.
Parameters
yArray of integers
lambdaVector of continuous location variables.
cPositive increasing vector of cutpoints.
Returns
Log probability of outcome given location and cutpoints.
Exceptions
std::domain_errorIf the outcome is not between 1 and the number of cutpoints plus 2; if the cutpoint vector is empty; if the cutpoint vector contains a non-positive, non-finite value; or if the cutpoint vector is not sorted in ascending order.
std::invalid_argumentIf y and lambda are different lengths.

Definition at line 75 of file ordered_logistic_lpmf.hpp.