{smcl} {* 22may2006}{...} {cmd:help mata mm_cebinomial()} {hline} {title:Title} {p 4 23 2} {bf:mm_cebinomial() -- Conditional expectation of a binomial distributed random variable} {title:Syntax} {p 8 23 2} {it:real matrix} {cmd:mm_cebinomial(}{it:n}{cmd:,} {it:k}{cmd:,} {it:p}{cmd:)} {pstd} where {it:n}: {it:real matrix n} {it:k}: {it:real matrix k} {it:p}: {it:real matrix p} {title:Description} {pstd}{cmd:mm_cebinomial()} returns the expected value of a binomial distributed random variable conditional on the variable being equal to {it:k} or larger. That is, {cmd:mm_cebinomial()} returns {phang2} E({it:X}|{it:X}>={it:k}) {pstd} where {phang2} {it:X} ~ B({it:n}, {it:p}) {pstd} and {it:n} is the number of trials and {it:p} is the success probability. {pstd} When {it:n}, {it:k}, and {it:p} are not scalar, {cmd:mm_cebinomial()} returns element-by-element results. {it:n}, {it:k}, and {it:p} are required to be r-conformable (see help {helpb m6_glossary:[M-6] glossary}). {title:Remarks} {pstd}The expectation of {it:X} ~ B({it:n}, {it:p}) conditional on {it:X}>={it:k} may be written as {phang2} E({it:X}|{it:X}>={it:k}) = {it:k} + [ P({it:X}>={it:k}+1) + ... + P({it:X}={it:n}) ] / P({it:X}>={it:k}) {pstd} where P({it:X}>={it:k}) is the probability of {it:k} or more successes, which is computed as {opt Binomial(n, k, p)} (see {helpb mf_normal:[M-5] normal()}). {title:Conformability} {pstd}{cmd:mm_cebinomial(}{it:n}{cmd:,}{it:k}{cmd:,}{it:p}{cmd:)} requires {it:n}, {it:k}, and {it:p} be r-conformable (see help {helpb m6_glossary:[M-6] glossary}). Returned is a matrix of max(argument rows) rows and max(argument columns) columns containing element-by-element calculated results. {title:Diagnostics} {pstd} {cmd:mm_cebinomial()} returns missing if any of the arguments are missing. {pstd} {cmd:mm_cebinomial()} returns missing if arguments are out of range ({it:p}>1, {it:p}<0, {it:n}<=0, {it:k}<0, or {it:k}>{it:n}) or if {it:n} or {it:k} are non-integer. {title:Source code} {pstd} {help moremata_source##mm_cebinomial:mm_cebinomial.mata} {title:Author} {pstd} Ben Jann, ETH Zurich, jann@soz.gess.ethz.ch {title:Also see} {psee} Online: help for {bf:{help mf_normal:[M-5] normal()}}, {bf:{help moremata}}