Announcement

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

  • How can I get theta for Inverse hyperbolic sine transformation by mle?

    Hi,everyone
    I want to use mle to estimate theta for Inverse hyperbolic sine transformation , I have written the likelihood function as follows:
    Click image for larger version

Name:	1.jpg
Views:	1
Size:	8.9 KB
ID:	1527123

    Because the y in myresearch is profit ,and it has negative values.So I want to use mle to estimate the theta and some mistakes arised. it shows "= is not a valid command name" after `y'=asinh(`theta' * $ML_y) / `theta'.Here is my code:

    ----------------------- copy starting from the next line -----------------------
    Code:
    sysuse auto.dta
    
    cap program drop mylf
    program define mylf       
        args  lnf mu sigma  theta
        `y'=asinh(`theta' * $ML_y) / `theta'
        quietly replace `lnf' = ln(normalden((`y' - `mu')/`sigma')) - ln(`sigma') - (1/2)*ln(1+(($ML_y)^2) * ((`theta')^2))
    end
    
    reg price mpg rep78 headroom trunk
    matrix b=e(b)
    matrix b=b,0
    
    ml model lf mylf ( price = mpg rep78 headroom trunk)(sigma:)(theta:)
    ml check
    ml init b,copy skip
    ml max
    ------------------ copy up to and including the previous line ------------------
    I wonder if you can figure out mistakes in my code,many thanks in advance

  • #2
    A couple of quick remarks: In

    Code:
    `y'=asinh(`theta' * $ML_y) / `theta'
    Should this be

    Code:
    local y   asinh(`theta' * $ML_y) / `theta'
    The following code runs:

    Code:
    sysuse auto.dta
    
    cap program drop mylf
    program define mylf       
        args  lnf mu sigma  theta
        local y   asinh(`theta' * $ML_y) / `theta'
        quietly replace `lnf' = ln(normalden((`y' - `mu')/`sigma')) - ln(`sigma') - (1/2)*ln(1+(($ML_y)^2) * ((`theta')^2))
    end
    
    reg price mpg rep78 headroom trunk
    matrix b=e(b)
    matrix b=b,0
    
    ml model lf mylf ( price = mpg rep78 headroom trunk)(sigma:)(theta:)
    ml check
    * ml init b,copy skip
    ml max
    The ml init line is commented out because leaving it in led to an error

    Code:
    . ml init b,copy skip
    initial vector: matrix must be dimension 7
    r(503);
    The results of running the code (with the line commented out):

    Code:
    initial:       log likelihood = -843.43942
    rescale:       log likelihood = -843.43942
    rescale eq:    log likelihood =  -754.6528
    Iteration 0:   log likelihood =  -754.6528  (not concave)
    Iteration 1:   log likelihood = -684.47831  (not concave)
    Iteration 2:   log likelihood = -637.72835  (not concave)
    Iteration 3:   log likelihood = -634.69412  (not concave)
    Iteration 4:   log likelihood = -632.40265  (not concave)
    Iteration 5:   log likelihood = -630.39139  
    Iteration 6:   log likelihood = -619.16139  
    Iteration 7:   log likelihood = -614.18974  (not concave)
    Iteration 8:   log likelihood = -613.68869  
    Iteration 9:   log likelihood = -613.61111  
    Iteration 10:  log likelihood =   -613.611  
    Iteration 11:  log likelihood =   -613.611  
    
                                                    Number of obs     =         69
                                                    Wald chi2(4)      =       0.01
    Log likelihood =   -613.611                     Prob > chi2       =     1.0000
    
    ------------------------------------------------------------------------------
           price |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    eq1          |
             mpg |  -.0231133   .2348256    -0.10   0.922    -.4833631    .4371364
           rep78 |   .0699242    .710734     0.10   0.922    -1.323089    1.462937
        headroom |  -.0674762   .6864197    -0.10   0.922    -1.412834    1.277882
           trunk |   .0147577    .150134     0.10   0.922    -.2794995    .3090149
           _cons |   6.579106   60.24232     0.11   0.913    -111.4937    124.6519
    -------------+----------------------------------------------------------------
    sigma        |
           _cons |   .2020261   2.052022     0.10   0.922    -3.819863    4.223916
    -------------+----------------------------------------------------------------
    theta        |
           _cons |   1.543306   15.67519     0.10   0.922     -29.1795    32.26611
    ------------------------------------------------------------------------------
    I have not checked whether your likelihood expression is correct for your model specification.

    Comment


    • #3
      Mank thanks ,I will check again.

      Comment


      • #4
        Hello, Bing, I am using a similar approach for my dataset, how did you derive your likelihood function? I am referring to Pence (2006) and it is slightly different

        Comment

        Working...
        X