Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Dirk Enzmann <dirk.enzmann@uni-hamburg.de> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Simplification of mata syntax to determine CI possible? |

Date |
Wed, 06 Jul 2011 12:57:59 +0200 |

* ---- start --------- mata: void propci(real scalar x, real scalar n, real scalar ci) { real rowvector pp real scalar k real rowvector lik real scalar ci_l real scalar ci_u real scalar i pp = range(0.000001,0.999999,1/99999) k = exp(1)^(-invchi2(1, ci/100)/2) lik = binomialp(n,x,pp) lik = lik/max(lik) ci_l = . ci_u = 0 for (i=1; i <= 100000; i++) { if (lik[i,1] > k & ci_l == .) { ci_l = pp[i,1] } else if (lik[i,1] > k & ci_u < pp[i,1]) { ci_u = pp[i,1] } else if (ci_u > 0 & lik[i,1] < k) { i = 100000 } } st_numscalar("r(ci_l)", ci_l) st_numscalar("r(ci_u)", ci_u) } end * ---- end -----------

# --- start R snippet ------- conf.int=range(pp[lik > k]) # --- end R snippet ------ I wonder whether something similar is possible using mata. ======================================== Dirk Enzmann email: dirk.enzmann@uni-hamburg.de ======================================== * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**st: Re: Simplification of mata syntax to determine CI possible?***From:*Dirk Enzmann <dirk.enzmann@uni-hamburg.de>

**st: RE: Simplification of mata syntax to determine CI possible?***From:*Nick Cox <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: Fwd: How to predict out of sample using OLS regression with lagged values** - Next by Date:
**RE: st: Creating household id for groups of persons** - Previous by thread:
**st: Fwd: How to predict out of sample using OLS regression with lagged values** - Next by thread:
**st: RE: Simplification of mata syntax to determine CI possible?** - Index(es):