Hi everyone,

I've checked the forum and I can't seem to find an answer to my question.

Due to the percentage of missing data (2 - 18%) I have in the survey data I'm using, I'm wanting to use Maximum Likelihood (or FIML) after running my complete case analysis first. However, I can't seem to get the code to work despite reading much literature.

I have read various instructions and have the following code:

Code:
tab prog, gen(pr)
global y1 "pr1"
global y2 "pr2"
global y3 "pr3"
capture program drop lfmlogit
program lfmlogit
version 10.1
args lnf xb1 xb2
tempvar p1 p2 p3
quietly {
gen double `p1' = 1/(1+exp(`xb1')+exp(`xb2'))
gen double `p2' = exp(`xb1')/(1+exp(`xb1')+exp(`xb2'))
gen double `p3' = exp(`xb2')/(1+exp(`xb1')+exp(`xb2'))
replace `lnf' = $y1*ln(`p1') + $y2*ln(`p2') + $y3*ln(`p3')
}
end
ml model lf lfmlogit (eq1:sugar2 = gender schlyear2 ses ethnic2 year) (eq2: gender schlyear2 ses ethnic2 year) 
l maximize
But unfortunately this code is retuned
Code:
pr1 not found
r(111);

Note the complete case model was
Code:
mlogit sugar2  i.gender i.schlyear2 i.ses i.ethnic2 year, base(0) rrr
The dependent variable sugar2 has three categories, with the higher the number indicating more sugary drinks consumed.

Can anyone help?

Best wishes and thanks in advance

Emily