PRJConditional—predicted probs for a conditional logit

Use this forum to post complete RATS "procedures". Please be sure to include instructions on using the procedure and detailed references where applicable.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

PRJConditional—predicted probs for a conditional logit

Unread post by TomDoan »

This computes the predicted probabilities for a conditional logit model for an input collection of attributes for the choices.

Code: Select all

*
* @PRJConditional( options )
* computes predicted probabilities for a conditional logit.
* This should be only be used after doing DDV with TYPE=CONDITIONAL.
*
* Options:
*  ATTRIBUTES=RECTANGULAR of attributes for the choices being examined. This should
*    be a choices x regressors array, where each row has the attributes for one
*    choice.
*  LABELS=VECTOR[STRINGS] with labels for the choices.
*  TITLE=title for output
*
* Revision Schedule:
*  07/2008 Written by Tom Doan, Estima.
*
procedure PRJConditional
option rect          attributes
option vect[strings] labels
option string        title
*
local vector z p
*
compute z=attributes*%beta
compute p=%exp(z)/%sum(%exp(z))
report(action=define)
if %defined(title)
   report(atrow=1,atcol=1,span) title
else
   report(atrow=1,atcol=1,span) "Predicted Probabilities"
do i=1,%rows(z)
   if %defined(labels)
      report(atrow=i+1,atcol=1) labels(i) p(i)
   else
      report(atrow=i+1,atcol=1) "Choice "+i p(i)
end do i
report(action=format,picture="*.####")
report(action=show)
end
Post Reply