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

◆ ordered_logistic_lpmf() [1/3]

template<bool propto, typename T_y_cl , typename T_loc_cl , typename T_cuts_cl , require_all_prim_or_rev_kernel_expression_t< T_y_cl, T_loc_cl, T_cuts_cl > * = nullptr>
return_type_t< T_y_cl, T_loc_cl, T_cuts_cl > stan::math::ordered_logistic_lpmf ( const T_y_cl &  y,
const T_loc_cl &  lambda,
const T_cuts_cl &  cuts 
)
inline

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 lambda 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_loclambda type.
T_cutCut-point type.
Parameters
yArray of integers
lambdaVector of continuous lambda variables.
cutsPositive increasing vector of cutpoints.
Returns
Log probability of outcome given lambda 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 70 of file ordered_logistic_lpmf.hpp.