Regression Postestimation Commands in Stata: margins, pt. 1

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 พ.ย. 2024

ความคิดเห็น • 25

  • @joy6404
    @joy6404 ปีที่แล้ว

    Hi Alan, your video is great! Thank you! I am having trouble producing interaction plots after using FIML method treating missing values. I would greatly appreciate your advice on it.

  • @ingridbautistapenuela7432
    @ingridbautistapenuela7432 4 ปีที่แล้ว

    so great video!!! very understanding! Greetings from Chile

  • @alexanderlewzey1102
    @alexanderlewzey1102 8 ปีที่แล้ว +2

    Fantastic video, much appreciated!

    • @smilex3
      @smilex3  8 ปีที่แล้ว

      I'm glad you found this video useful.

  • @zumasuma5489
    @zumasuma5489 6 ปีที่แล้ว +1

    Wow! More more more! Greetings from Germany

  • @ekeomageorge8979
    @ekeomageorge8979 ปีที่แล้ว

    Thank you so much for this video. Although my question is 9 years late how about interacting two dummies

    • @smilex3
      @smilex3  ปีที่แล้ว

      Ekeoma, if you interact two dummy variables you produce four outcome groups. You can use Stata's factor notation to do this in different types of models. See help fvvarlist for detail.
      Here is a quick (and analytically meaningless) example that creates a dummy variable and then uses it in a regression model interacted with another dummy variable. I have included a covariate as well. The plotted results show the relationship between displacement and fuel efficiency across the four groups defined by the interaction term.
      Hopefully, this gives you some ideas on how to set up your model.
      sysuse auto, clear
      * Create dummy variable for this example
      sum weight, meanonly
      gen weightdum=weight>=r(mean)
      * This is the interaction to be estimated
      tab weightdum foreign, nolabel
      * Use regress with factor notation (see help fvvarlist)
      regress mpg displacement i.weightdum##i.foreign
      margins weightdum#foreign, at(displacement=(75(25)200))
      marginsplot, noci scheme(s2color)

  • @tewoderosmeleaku6627
    @tewoderosmeleaku6627 4 ปีที่แล้ว

    Do you possible to have the data you use it? Thanks it’s very important topic and how we can do margins for multivariate probit?

    • @smilex3
      @smilex3  4 ปีที่แล้ว

      The data are available from different places, but this is a good place to download subsets of the General Social Survey: gssdataexplorer.norc.org/ The margins & marginsplot commands can be used after many estimating routines including regression, logit, & probit models. It is used the same way for each different type of model.

    • @tewoderosmeleaku6627
      @tewoderosmeleaku6627 4 ปีที่แล้ว

      @@smilex3 If it is possible to have the data please send to my email address it is teddiyo.21@gmail.com

  • @kritivikram2732
    @kritivikram2732 5 ปีที่แล้ว

    Hi Alan, thanks for this video! P.S. You taught me 10 years ago :)

  • @mar355
    @mar355 8 ปีที่แล้ว

    c.educ##c.educ is like generating a quadratic effect? That is, its the same as gen edu2=educ*educ???
    You did this because you assume that educ and prestige did not have a linear relationship but a quadratic one?
    I can you all this margin commands after a logistic regression as well, right? It would be great if you do a video explaining margins (post estimations commands) for logistic regressions.
    Thank you very much!
    Marvin

    • @smilex3
      @smilex3  8 ปีที่แล้ว +1

      +Marvin Aliaga Yes, that model was testing for a quadratic relationship. It is best to use factor notation so you can use margins and Stata can keep track of all your variables. This is particularly important with quadratics and logistic (or other limited dependent variables). When you use margins after a logistic regression, margins reports probabilities, which are easy to interpret. Then, you can use marginsplot to visualize the model. This is a real strength of Stata.
      Best,
      Alan

  • @bRabbit120793
    @bRabbit120793 4 ปีที่แล้ว

    Hello, I have a question can I use the "margins at" command for values that are not in the sample? Let's say the max. education level in the sample is 10 years and I want to know the potential effect of 15 years, can I use "margins, at (15)" for that ?

    • @smilex3
      @smilex3  4 ปีที่แล้ว +1

      Hi Tony, yes, this can be cautiously done, but be careful. Making predictive estimates outside the range of the data used in your model can produce nonsensical results. For example, based on General Social Survey data I can show you a model indicating an average decrease in sexual frequency of 1.2 times per year for each year of aging. This model probably works pretty well near the middle of the distribution of age, about 48 years old. This model includes respondents between the ages of 18 and 89 and may provide some information about octogenarians, but is not useful at all when examining people who are 100 years old!
      Here is another example that demonstrates that you can use values outside of the range of your data in the margins command, but also produces nonsensical results. I used the auto dataset included with Stata to estimate a fuel efficiency model relating MPG to the weight of cars. Then, I used margins to estimate the average MPG for an M1 Abrams tank that weighs approximately 120,000 lbs., clearly outside the range of my data! Run this little program to see the results.
      Best,
      Alan
      sysuse auto, clear
      /* Estimate a simple model */
      regress mpg c.weight##c.weight
      /* Get some reasonable bounds for weight */
      estat summarize
      /* Margins within the range of the data */
      margins, at(weight=(1800(200)5000))
      marginsplot, recast(line) recastci(rarea) scheme(s1mono)
      /* Margins outside the range using the weight of an M1 Abrams tank */
      margins, at(weight=120000)

    • @bRabbit120793
      @bRabbit120793 4 ปีที่แล้ว

      Thank you Alan for the quick and competent answer

    • @smilex3
      @smilex3  4 ปีที่แล้ว

      @@bRabbit120793 👍

  • @criticalthought7307
    @criticalthought7307 4 ปีที่แล้ว

    how do you do this for multiple independent variables?

    • @smilex3
      @smilex3  4 ปีที่แล้ว +2

      Hi Jodi,
      Yes, you can have two or more IV's in your model and can use them to estimate the marginal effects. It requires some thought about what you want to see from your model. I have provided some Stata code below that may give you some ideas about how to do this.
      sysuse auto, clear
      regress mpg weight displacement
      estat summarize
      margins, at(weight=(1800(200)4800))
      marginsplot, recast(line) noci name(m1a, replace)
      margins, at(displacement=(100(50)400))
      marginsplot, recast(line) noci name(m1b, replace)
      margins, at(weight=(1800(500)4500) displacement=(100(100)400))
      marginsplot, recast(line) noci name(m2, replace)
      regress mpg c.weight##c.displacement
      margins, at(weight=(1800(500)4500) displacement=(100(100)400))
      marginsplot, recast(line) noci name(m3, replace)

  • @JohnVandivier
    @JohnVandivier 8 ปีที่แล้ว

    intro theme song was awesome

    • @smilex3
      @smilex3  8 ปีที่แล้ว

      "The White Collar Holler" by the great Stan Rogers. Traditional music. My favorite song by Rogers is "Northwest Passage". I think Pierre Trudeau called it the unofficial national anthem of Canada!

  • @wagnersantos7748
    @wagnersantos7748 4 ปีที่แล้ว

    Hi, I'm facing a problem on marginsplot ti my study. Is it possible to send you an e-mail with my problem? I thank you very much!!!

    • @smilex3
      @smilex3  4 ปีที่แล้ว

      Sure, send me your problem and I can see if I have an answer or can send you in the right direction.

    • @wagnersantos7748
      @wagnersantos7748 4 ปีที่แล้ว

      @@smilex3 Hi Alan, I have answered you two times, but I don't know why my message is being erased.