Announcement

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

  • Margins(plot) on conditional probability after running cmp routine (equation 1)

    Dear all, David Roodman

    I need help regarding the plotting of the first equation of my cmp routine, developed by Roodman (2011). After performing the cmp routine I experience ssome problems with plotting the first equation (purchase yes/no), which is conditional on the second equation of add_to_cart (yes/no). I read online that the margins command might be unable to calculate the marginal effects for equation 1. However, I was wondering if there is a possible workaround or that I am missing something. I need to plot the relations as the interaction effects I use are quite complex to explain in words (thesis). Please help me further understand this routine. I already tried options such as condition(0 ., eq(cart_use) but I just ccant' get Stata to get marginal effects. See below my cmp command and 1 of the margins/marginsplot I try to run (simplified version):

    Code:
    // Full model with interaction and quadratic effects (all effects)
    cmp (purchased_eq: purchased = i.availability_desired_size category_variety_log_mean ///
    i.collection#c.category_variety_log_mean ///
    i.size_range_width_cat#c.category_variety_log_mean ///
    i.collection_ind##c.category_variety_squared ///
    i.size_range_width_cat##c.category_variety_squared ///
    i.review_category selling_price_c i.sale_cat i.day_of_week ///
    back_in_stock precipitation sales_promo platform top_brand) ///
    (cart_use: add_to_cart = category_variety_log_mean size_range_availability_log_medi ///
    size_range_availability_squared ///
    i.size_range_width_cat#c.category_variety_log_mean ///
    i.collection#c.category_variety_log_mean ///
    i.size_range_width_cat##c.category_variety_squared ///
    i.collection_ind##c.category_variety_squared ///
    i.review_category selling_price_c i.sale_cat i.day_of_week ///
    back_in_stock precipitation sales_promo platform top_brand) ///
    , ind($cmp_probit*add_to_cart $cmp_probit) qui
    estimates store model5
    estat ic

    /// loading the output of the full model
    estimates restore model5

    margins, at(category_variety_log_mean=(-0.9848438(0.1)0.5584728)) predict(pr equation(purchased_eq)) post
    marginsplot, recast(line) xline(0) xtitle("category_variety_log_mean")

    Thanks in advance!!

  • #2
    This is a lot to try to understand. Can you develop a minimum working example (MWE) of your issue?

    "experience ssome problems" is vague. What actually happens?

    Also, margins runs on top of predict. So can you narrow down to whether you are able to predict the quantity you want?

    Comment


    • #3
      Hi David Roodman , i am sorry for the chaos, I was a bit lost yesterday and am also not that experienced with Stata/statistics. In general I would like to visualize the relations of both my equations, which I already fixed for cart use (i think).

      Basically, I want to visualize (among other things):
      - cat_var and purchase do not follow a inverted U-shaped relation, (want to show that it is linear)
      - interaction of cat_var with col (binary) and srw (3 cat) (strenghtening and weakening).
      - Relation of sra and purchase

      Specifically, i am not sure what the syntax for margins would be in my case (bivariate probit model). I tried different options following the help cmp command but I repeatedly get (not esitmable) because I think that it might be impossible or that I am using an incorrect syntax.

      A simplified code of my cmp syntax and two options I tried:
      Code:
      cmp (purchased = i.ads c.cat_var i.col#cat_var i.srw#c.cat_var cat_var^2#i.col ///
      cat_var^2#i.srw)
      (add_to_cart = c.cat_var c.sra c.sra^2 i.col#cat_var i.srw#c.cat_var ///
      c.cat_var^2#col.i c.cat_var^2#i.srw) ///
      , ind($cmp_probit*add_to_cart $cmp_probit)
      
      margins, at(cat_var = (-0.9848438(0.1)0.5584728) srw=(1 2 3)) ///
       predict(pr eq(purchased) condition(0 ., eq(add_to_cart))) force
      I also do not completely understand how to get the 'net effect' of the col variable. I would like to say somehting about that as col has a negative effect in add_to_cart equation but positive in purchase. You would say:
      Code:
      margins, dydx(col) predict(pr eq(purchased) post
      or

      Code:
      preserve
      replace add_to_cart=1
      replace purchased=1
      margins, dydx(collection_ind) expression(exp(predict(lnl))) force
      restore
      Basically, I need some help understanding predict and margins as I need to somehow visualize the relations cause they are quite complex to describe in words.
      It would be greatly appreciated if you could help me.

      Thank you

      Comment

      Working...
      X