Dear all,
I have run the codes in the paper "lclogit: A Stata command for fitting latent-class conditional logit models via the expectation-maximization algorithm", and would like to determine belonging class of each individuals.
Here is the code that I have used
I have tried many ways with lclogitpr pr, pr, but can not get belonging class of each individuals.
Coud you please give me some instruction for this?
Thanks and best regards,
Quoc Cuong Nguyen
I have run the codes in the paper "lclogit: A Stata command for fitting latent-class conditional logit models via the expectation-maximization algorithm", and would like to determine belonging class of each individuals.
Here is the code that I have used
Code:
use http://fmwww.bc.edu/repec/bocode/t/traindata.dta set seed 1234567890 by pid, sort: egen _x1=sum(round(rnormal(0.5),1)) list in 1/12, sepby(gid) forvalues c = 2/10 { quietly lclogit y price contract local wknown tod seasonal, group(gid) id(pid) nclasses(`c') membership(_x1) seed(1234567890) matrix b = e(b) matrix ic = nullmat(ic) \ `e(nclasses)', `e(ll)', `=colsof(b)', `e(caic)', `e(bic)' } matrix colnames ic = "Classes" "LLF" "Nparam" "CAIC" "BIC" matlist ic, name(columns) lclogit y price contract local wknown tod seasonal, group(gid) id(pid) nclasses(5) membership(_x1) seed(1234567890) lclogitpr pr, pr generate byte class = . forvalues c = 1/`e(nclasses)' { quietly replace class = `c' if cpmax==cp`c' } forvalues c = 1/`e(nclasses)' { quietly summarize pr if class == `c' & y==1 local n=r(N) local a=r(mean) quietly summarize pr`c' if class == `c' & y==1 local b=r(mean) matrix pr = nullmat(pr) \ `n', `c', `a', `b' } matrix colnames pr = "Obs" "Class" "Uncond_Pr" "Cond_PR" matlist pr, name(columns)
Coud you please give me some instruction for this?
Thanks and best regards,
Quoc Cuong Nguyen
Comment