Announcement

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

  • Vector of variable names inside an expression - what's the correct syntax?

    Hi,

    I am trying to replicate this CRE probit model discussed in here:

    https://www.statalist.org/forums/forum/general-stata-discussion/general/1346297-average-marginal-effects-from-chamberlain-mundlak-device-cre

    I would like to include several variables for which to compute margins. E.g. what would be equivalent for 'lhinc' and 'kids':

    Code:
    margins, dydx(lhinc kids) force
    I tried this:

    Code:
    margins, expression(normalden(xb()*(1/sqrt(1 + e(sigma_u)^2)))*(_b[lhinc kids])*(1/sqrt(1 + e(sigma_u)^2))) force
    but that does not work. Any ideas?

  • #2
    Replying to the heading of your post, you can recall several variables with a local.
    E.g.
    Code:
    local variables hiv kcal
    sum `variables'
    Variable | Obs Mean Std. Dev. Min Max
    -------------+---------------------------------------------------------
    hiv | 3,808 1.951523 4.340811 .1 28.4
    kcal | 2,895 137.7782 118.5634 1 744


    Comment


    • #3
      Thanks Rebecca!

      I know that. That's what I originally had. It didn't work and the error message would be: "hivkcal invalid name (r198)".

      By inserting the variable names separately like I had in my example, I would get: "[hiv kcal] not found (r111)".

      My guess is that expression function requires some special syntax, which I have not been able to figure out yet.

      Antti

      Comment

      Working...
      X