Announcement

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

  • Getting predicted values excluding some of the coefficients

    Hi everyone,

    I am using an event-study methodology to estimate child penalty. My regression is as follows: reg y _Ieventtime* i.age i.syear. The dependent variable is monthly income. Independent variables include age dummies (20-45), year dummies (1984-2020), and event time dummies (from -5 to 10) which indicate the period five years before childbirth to 10 years after childbirth. To estimate the penalty, I need to get the predicted outcome by omitting the event time dummy. Is there a way of getting the predicted value only for some of the coefficients (in my case, excluding the coefficient of the event time dummy variable)?

  • #2
    Code:
    foreach v of varlist _Ieventtime* {
        clonevar orig_`v' = `v'
        replace `v' = 0
    }
    predict prediction_no_event_time_vars
    foreach v of varlist _Ievnttime* {
        replace `v' = orig_`v'
        drop orig_`v'
    }
    Note: As no example data was provided, this code is contested. It may contain typos or other errors, and may be totally unsuitable for the actual data set you have. In the future, when requesting help with code, always show example data. And always use the -dataex- command to do that. If you are running version 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    When asking for help with code, always show example data. When showing example data, always use -dataex-.
    Last edited by Clyde Schechter; 28 Mar 2023, 10:59.

    Comment

    Working...
    X