Announcement

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

  • Writing STATA code for estimation of theta in log-likelihood in median regression

    Hello,
    I want to use MLE to estimate theta for Inverse hyperbolic sine transformation in case of median regression. From Pence 2006, the likelihood function is:

    Click image for larger version

Name:	Screenshot 2023-03-27 at 12.44.13 AM.png
Views:	1
Size:	20.0 KB
ID:	1707255

    As of now, my code gives an error: could not calculate numerical derivatives -- discontinuous region with missing values encountered. Here is my code


    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(2/_N) - ln(abs((normalden((`y' - `mu')/`sigma')) - ln(`sigma'))) - 1 - (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 max

    Any help to fix this would be appreciated!

Working...
X