Announcement

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

  • How to manipulate coefficients in saved .ster model estimates

    Hi everyone,

    I am aware that it is possible to save model estimates using
    Code:
    estimates save my_logistic_regression
    to generate for example, a my_logistic_regression.ster file that can then be used in a separate dataset. However, I would like to edit the coefficients of the model by shrinking them (multiplying them by a particular coefficient that I have obtained from internal validation) and also editing the constant term. I am happy to calculate the new values of the coefficients manually (its a simple multiplication), and derive the new constant using some basic code, but I cannot figure out how "edit" the stored coefficients and constant in the .ster file. I would very much value your advice.

    Best
    Markos


  • #2
    Code:
    estimates use my_logistic_regression
    manipulation
    ereturn post
    estimates save my_logistic_regression, replace
    See

    Code:
    help ereturn post
    or

    Code:
    ssc describe erepost

    Comment


    • #3
      Hi Andrew Musau , I have tried the following
      Code:
      estimates use my_logistic_regression
      matrix b = e(b)
      matrix b[1,1]=0.08 //this changes just the first coefficient to 0.08
      ereturn post b
      estimates save my_logistic_model_2
      but after the last line I get the error "last estimates not found". It does seem at least that the manipulation is working as if I run
      Code:
      matrix list e(b)
      after
      Code:
      ereturn post b
      , it gives the correct updated matrix....?

      Comment


      • #4
        I think I worked it out after seeing another Stata post from Joseph Coveney.
        Code:
        cap prog drop my_program
        prog my_program, eclass
        estimates use my_logistic_regression
        matrix A = e(b)
        matrix A[1,1] = 0.08
        ereturn repost b = A
        estimates save logistic_model_2
        end
        
        my_program
        It then seems to work just like the original stored estimates.

        Comment

        Working...
        X