Page 1 of 1

PRJConditional—predicted probs for a conditional logit

Posted: Thu Jul 10, 2008 1:58 pm
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