Dear all,
I am currently trying to estimate the parameters of a limited dependent variable model, as introduced by Lesmond et al. (1999) (http://rfs.oxfordjournals.org/conten.../1113.abstract). I attached the model and the log-likelihood function (as jpgs) below.
I have the data for Rjt (R) and Rmt (MR) and would like to estimate alpha1, alpha2, beta, and sigma. I am using Stata 13 on Windows 7 and tried the following:
Please feel free to laugh heartily, as it is my first attempt at ml or any Stata programming at all. Right now, I am getting the following error:
I feel rather allright about my translation of the log-likelihood function into the program (but are happy about corrections). But for the model, I feel like I have no idea what I am doing. I read that the model needs to contain a separate equation (as identified by brackets) for every paramater that needs to be estimated, so that is what I tried to do. Any help is greatly appreciated!
I am currently trying to estimate the parameters of a limited dependent variable model, as introduced by Lesmond et al. (1999) (http://rfs.oxfordjournals.org/conten.../1113.abstract). I attached the model and the log-likelihood function (as jpgs) below.
I have the data for Rjt (R) and Rmt (MR) and would like to estimate alpha1, alpha2, beta, and sigma. I am using Stata 13 on Windows 7 and tried the following:
Code:
program myprog version 13.1 args lnfj a1 a2 b sigma quietly replace `lnfj' = ln((2*c(pi)*`sigma')^(-0.5)))-((R+`a1'-`b'*MR)^2)/(2*(`sigma')^2) if R<0 quietly replace `lnfj' = ln((2*c(pi)*`sigma')^(-0.5)))-((R+`a2'-`b'*MR)^2)/(2*(`sigma')^2) if R>0 quietly replace `lnfj' = ln(normalden((`a2'-`b'*MR)/`sigma')-normalden((`a1'-`b'*MR)/`sigma') if R=0 end ml model lf myprog (`a1'=`b'*MR R) (`a2'=`b'*MR R) (`b'=R`a1' MR) ()
Code:
. ml check Test 1: Calling myprog to check if it computes log likelihood and does not alter coefficient vector... FAILED; myprog returned error 132. Here is a trace of its execution: ------------------------------------------------------------------------------ -> myprog __00000E __00000F __00000G __00000H __00000I - `begin' = capture noisily version 13.1: myprog __00000E __00000F __00000G __00000H __00000I ---------------------------------------------------------------------------------------------------------------------------------------------------------------- begin myprog --- - version 13.1 - args lnfj a1 a2 b sigma - quietly replace `lnfj' = ln((2*c(pi)*`sigma')^(-0.5)))-((R+`a1'-`b'*MR)^2)/(2*`sigma') if R<0 = quietly replace __00000E = ln((2*c(pi)*__00000I)^(-0.5)))-((R+__00000F-__00000H*MR)^2)/(2*__00000I) if R<0 too many ')' or ']' ------------------------------------------------------------------------------------------------------------------------------------------------------------------ end myprog --- - `end' = set trace off ------------------------------------------------------------------------------ Fix myprog.
Comment