Announcement

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

  • HELP predicting dependent variable at various level of an independent variable

    Hello all, I am running a fix-effect model and I'd like to predict dependent variable at various level of mortality and in particular proportionate levels of the mortality.

    the code are as follows:

    xtset id year

    xtreg lgdp lgphysicapital TFP DalysIDA edu_aug_labor2554 edu_aug_labor5564 institutionalquality wfpop,fe cluster(id)

    Among them, DALY is a health variable that refers to mortality. I tried margins command to construct a scenario of GDP change by using GDP with a constant mortality rate minus GDP when the mortality rate is reduced to 95%.


    margins, at(DalysIDA = gen(DalysIDA))

    scalar mean_original = r(b)[1,1]

    margins, at(DalysIDA = gen(DalysIDA*0.95))

    scalar mean_reduced = r(b)[1,1]

    scalar mean_difference = mean_reduced - mean_original

    display "The average predicted value of GDP in the original Daly's IDA: " mean_original
    display "The predicted average GDP value after reducing Daly's IDA by 5%: " mean_reduced
    display "Change in the average predicted value: " mean_difference


    However, there are some issues, such as only being able to predict a mean value for the entire model, rather than predicting a value for all observations. Secondly, the predicted value, i.e., GDP, is very small, only $1

    Therefore, any suggestions on how to improve the prediction method would be greatly appreciated.



  • #2
    Yuping:
    welcome to this forum.
    See if -predict,xb- is what you're looking for.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Originally posted by Carlo Lazzaro View Post
      Yuping:
      welcome to this forum.
      See if -predict,xb- is what you're looking for.
      Hi Carlo,

      Thanks for your welcome and positive response. I tried predict before as follows:

      predict lgdp_original, xb

      * Create a copy of DalysIDA with a 5% reduction.

      clonevar DalysIDA_orig = DalysIDA // keep original value
      replace DalysIDA = DalysIDA * 0.95 // reduce 5%

      replace DalysIDA = DalysIDA *0.6

      * create new scenario
      predict lgdp_new, xb

      * calculate the change
      gen lgdp_change = lgdp_new - lgdp_original

      * Restore the original value of Daly's IDA
      replace DalysIDA = DalysIDA_orig
      drop DalysIDA_orig

      *
      drop lgdp_original lgdp_new

      *results
      summarize lgdp_change

      gen original_GDP=exp(lgdp_change)

      unfortunately, the results still quite small nearly 1$ for each observation. I have no idea on where the problem lies. Do you have any further thoughts on my code?

      Comment


      • #4
        Yuping:
        as per FAQ, posting an example/excerpt of your data may help. Thanks.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment

        Working...
        X