[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Please help with maximum likelihood (method lf)

From   "Katia Bobulova" <>
Subject   Re: st: Please help with maximum likelihood (method lf)
Date   Mon, 3 Nov 2008 07:16:30 -0500

Dear Marteen and Nick,

thank you very much for your suggestions.

Marteen, I tried to split my likelihood, but I am still receiving the
message that few variables are specified.

Nick, I set trace on, but I am absolutely not able to decode the
output, maybe it is too advanced for me.
The only thing that I have understood is that there is an error
198....but I don't have idea of how to solve it.

Thanks again,


2008/11/3 Nick Cox <>:
> In addition earlier posts advised the use of -set trace- and queried the
> use of colons.
> If Katia searches the archives, she will find several attempts to help
> her.
> Nick
> Maarten buis
> One thing that strikes me is that you haven't specified a dependent
> variable.
> Other than that I would split up the likelihood in smaller parts, with
> a bunch of -tempvars- (-doubles- of course), like so:
> tempvar part1 part2 part3 part4 part5
> gen double `part1' = (((`m')*(`g')+(`mu')*(`e')*(`eh')*(`p'))^bo)
> gen double `part2' = (((`m')*(`mg')+(`mu')*(`e')*(`eh')*(`mp'))^bq)
> gen double `part3' = (((`mu')*(`e')*(`eh')*(`p'))^so)
> gen double `part4' = (((`mu')*(`e')*(`eh')*(`mp'))^sq)
> gen double `part5' = (((`mu')*(`me'))^n))
> etc
> replace `lnf' = ln((`a')*(`d')* \\\
> `part1'*`part2'*`part3'*`part4'*`part5'+...)
> I would change part1 part2 etc in more substantively meaningful names.
> For example, I often create temprorary variables called num and denom
> (for the numerator and the denominator of a fraction). This does not
> change your likelihood, but it makes the code easier to read and debug.
> The third bit of advise I can give you is to start debugging a very
> much simplified version of your likelihood. Often when you restrict
> parameters of these likelihoods to certain values, the model collapses
> to a much simpler special cases (for which a official Stata command may
> exist). Debug your program for such a special case (and check against
> the result from the official Stata equivalent if it exists), and than
> add one by one the additional parameters to your model.
> Katia Bobulova
>> I am trying to perform a maximum likelihood that it is a little bit
>> complicate for me.
>> I specified the model and after that I used the command ml check to
>> control that everything was fine, but I received the message that
>> there are too few variables specified.
>> Could you please help me to understand what is wrong with my model? I
>> really need help!
>> Following my program:
>> program define myprogram
>> version 10.0
>> args lnf a d m e g p
>> tempvar eh  mu ma me md mg mp
>> quietly gen double `eh'=0.7*`e'
>> quietly gen double `mu'=1-`m'
>> quietly gen double `ma'=1-`a'
>> quietly gen double `me'=1-`e'
>> quietly gen double `md'=1-`d'
>> quietly gen double `mg'=1-`g'
>> quietly gen double `mp'=1-`p'
>> quietly replace
> `lnf'=ln((`a')*(`d')*((((`m')*(`g')+(`mu')*(`e')*(`eh')*(`p'))^bo)*(((`m
> ')*(`mg')+(`mu')*(`e')*(`eh')*(`mp'))^bq)*(((`mu')*(`e')*(`eh')*(`p'))^s
> o)*(((`mu')*(`e')*(`eh')*(`mp'))^sq)*(((`mu')*(`me'))^n))+(`a')*(`md')*(
> (((`mu')*(`e')*(`eh')*(`p'))^bo)*(((`mu')*(`e')*(`eh')*(`mp'))^bq)*(((`m
> ')*(`g')+(`mu')*(`e')*(`eh')*(`p'))^so)*(((`m')*(`mg')+(`mu')*(`e')*(`eh
> ')*(`mp'))^sq)*(((`mu')*(`me'))^n))+(`ma')*((((`e')*(`eh')*(`p'))^bo)*((
> (`e')*(`eh')*(`mp'))^bq)*(((`e')*(`eh')*(`p'))^so)*(((`e')*(`eh')*(`mp')
> )^sq)*((`me')^n))
>> end
>> ml model lf myprogram (a:) (d:) (m:) (e:) (g:) (p:)
>> ml check
>> After this I receive the error message.
> *
> *   For searches and help try:
> *
> *
> *
*   For searches and help try:

© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index