Announcement

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

  • Two-piece Normal Distribution

    The overall variance and skewness of Two-piece Normal (TPN) is given by:

    𝑉(𝑥) = 𝜎1 𝜎2 + (1 − 𝑘2)(𝜎2 − 𝜎1)2

    𝛾(𝑥) = 𝑘(𝜎2 − 𝜎1)[(2𝑘2 − 1)(𝜎2 − 𝜎1)^2 + 𝜎1𝜎2]

    where 𝑘 =\sqrt(2/pi)

    For given values of 𝑉(𝑥) and 𝛾(𝑥), two variances (𝜎1 and 𝜎2) could be estimated. How can I set up this nonlinear simultaneous equations problem in STATA? Any help?

    Note: I have tried methods suggested here (https://www.stata.com/support/faqs/p...ear-equations/), but am constantly getting error.

    Regards,

  • #2
    Jameel Ahmed

    Like this?
    Code:
    clear*
    scalar _sigma= 2
    scalar _skew=  .3
     program nlfaq
            syntax varlist(min=1 max=1) [if], at(name)
    
            tempname A B 
            scalar `A' = `at'[1, 1]
            scalar `B' = `at'[1, 2]
    
            tempvar yh
            gen double `yh' = (1 - 2/_pi) * (`B' - `A')^2 + `B'*`A' + 1 - scalar(_sigma)  in 1
            replace `yh' =  sqrt(2/_pi)*(`B' - `A') *(( (4/_pi) -1) * (`B' - `A')^2 + `B'*`A') - scalar(_skew)  in 2
            replace `varlist' = `yh'
    
     end
    
     set obs 2
     gen double y = 0 
     replace y = 1 in 1
     set trace off
     nl faq @ y, parameters(A B ) initial(A 1 B 1)

    Comment


    • #3
      Scott Merryman .. Thanks. Much appreciated

      Comment

      Working...
      X