Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to create a canfusion matrix after mlogit?

    I have a categorical variable "n_produttore": A-B-C-D-E-F and the output of multinomial logit . "mlogit"
    how to create the confusion matrix? I test this code, but doesn't work

    predict prob* egen pred_max = rowmax(prob*)

    g pred_choice = . forvalues i = 1/6 { replace pred_choice = i' if (pred_max == probi') }
    local produttore_lab: value label n_produttore
    label values pred_choice `produttore_lab'
    tab pred_choice n_produttore




  • #2
    Elisa,

    Please reformat your post so that each statement in your code is on a separate line. (Use the "source" icon, all the way at the left of the advanced editor, if necessary). Please also indicate what "doesn't work" means (i.e., what error did you receive).

    At first glance, I can see that you are missing leading single quotes around the macro i:

    Code:
    forvalues i=1/6 {
       replace pred_choice=`i' if pred_max==prob`i'
    }
    Regards,
    Joe

    Comment


    • #3
      Cross-posted (and answered) at:

      http://stackoverflow.com/questions/2...x-after-mlogit

      Please read the FAQ for this forum's policy on cross-posting.
      You should:

      1. Read the FAQ carefully.

      2. "Say exactly what you typed and exactly what Stata typed (or did) in response. N.B. exactly!"

      3. Describe your dataset. Use list to list data when you are doing so. Use input to type in your own dataset fragment that others can experiment with.

      4. Use the advanced editing options to appropriately format quotes, data, code and Stata output. The advanced options can be toggled on/off using the A button in the top right corner of the text editor.

      Comment

      Working...
      X