I am using Stata 17 to estimate the impact of variable X on a probability P.
I run a regression of the log odds ratio on the variable X.
I would like to get the predicted probability for different years.
I cannot obtain similar confidence intervals when I use predictnl or margin.
Code:
gen log_odds_ratio = ln(P/(1-P)) reg log_odds_ratio X margins if year == 2010 , expression(exp(predict(xb))/(1+exp(predict(xb))))
Code:
gen log_odds_ratio = ln(P/(1-P)) reg log_odds_ratio X predictnl pred_prob=exp(predict(xb))/(1+exp(predict(xb))) , var(variance) egen tot_var = total(variance) if year == 2010 count if year == 2010 gen standard_error= 1/r(N)*sqrt(tot_var)
I'm confused since the standard error of the average probability should be 1/n sqrt(sum(Variances)).
Any idea what I might doing wrong?
Thanks a lot,
Best,
Nicholas
0 Response to Equivalence between margins and predictnl
Post a Comment