Statistics - Maple Programming Help

Home : Support : Online Help : Statistics and Data Analysis : Statistics Package : Estimation : Statistics/Likelihood

Statistics

 Likelihood
 compute likelihood function of a random variable and data set

 Calling Sequence Likelihood(R, V, options)

Parameters

 R - algebraic; a random variable or distribution V - name or rtable; data sample options - (optional) equation(s) of the form option=value where option is one of samplesize, ignore, normalize, or weights; specify options for the Likelihood function

Description

 • The Likelihood function computes the likelihood function of a random variable R evaluated on a data set V.
 • The first parameter R can be a distribution (see Statistics[Distribution]), a random variable, or an algebraic expression involving random variables (see Statistics[RandomVariable]).
 • The second parameter V can be an Array of data samples or a symbol representing an Array of data samples (in which case the option samplesize must be specified).

Options

 The options argument can contain one or more of the options shown below.
 • samplesize=deduce or posint -- If this option is set to 'deduce' (default) the likelihood function attempts to automatically determine the number of data samples provided in V.  This parameter must be specified if the number of samples in V is not immediately detectable.
 • ignore=truefalse -- This option is used to specify how to handle non-numeric data. If ignore is set to true all non-numeric items in data will be ignored.
 • normalize=truefalse -- This option selects whether factors that do not depend on the value of the parameters can be omitted. The default is normalize = true, meaning that such factors can be omitted; selecting normalize = false means they are included.
 • weights=rtable -- Vector of weights (one-dimensional rtable). If weights are given, the Likelihood function will scale each data point to have given weight. Note that the weights provided must have type realcons and the results are floating-point, even if the problem is specified with exact values. Both the data array and the weights array must have the same number of elements.

Examples

 > $\mathrm{with}\left(\mathrm{Statistics}\right):$

Calculate the general likelihood function from the Normal distribution.

 > $\mathrm{assume}\left(0<\mathrm{σ}\right)$
 > $\mathrm{Likelihood}\left(\mathrm{Normal}\left(\mathrm{μ},\mathrm{σ}\right),A,\mathrm{samplesize}=4\right)$
 $\frac{{{ⅇ}}^{{-}\frac{{1}}{{2}}{}\frac{{\left({{A}}_{{1}}{-}{\mathrm{μ}}\right)}^{{2}}}{{{\mathrm{σ~}}}^{{2}}}}{}{{ⅇ}}^{{-}\frac{{1}}{{2}}{}\frac{{\left({{A}}_{{2}}{-}{\mathrm{μ}}\right)}^{{2}}}{{{\mathrm{σ~}}}^{{2}}}}{}{{ⅇ}}^{{-}\frac{{1}}{{2}}{}\frac{{\left({{A}}_{{3}}{-}{\mathrm{μ}}\right)}^{{2}}}{{{\mathrm{σ~}}}^{{2}}}}{}{{ⅇ}}^{{-}\frac{{1}}{{2}}{}\frac{{\left({{A}}_{{4}}{-}{\mathrm{μ}}\right)}^{{2}}}{{{\mathrm{σ~}}}^{{2}}}}}{{{\mathrm{σ~}}}^{{4}}}$ (1)

Sample a random variable with Normal distribution.

 > $N≔\mathrm{RandomVariable}\left(\mathrm{Normal}\left(5,1\right)\right):$
 > $S≔\mathrm{Sample}\left(N,4\right):$

Attempt to compute the likelihood function of this sample.

 > $\mathrm{Likelihood}\left(\mathrm{Normal}\left(\mathrm{μ},1\right),S\right)$
 ${{ⅇ}}^{{-}\frac{{1}}{{2}}{}{\left({4.52065806636344}{-}{\mathrm{μ}}\right)}^{{2}}}{}{{ⅇ}}^{{-}\frac{{1}}{{2}}{}{\left({5.78417369973330}{-}{\mathrm{μ}}\right)}^{{2}}}{}{{ⅇ}}^{{-}\frac{{1}}{{2}}{}{\left({4.49951342516818}{-}{\mathrm{μ}}\right)}^{{2}}}{}{{ⅇ}}^{{-}\frac{{1}}{{2}}{}{\left({4.50894910106650}{-}{\mathrm{μ}}\right)}^{{2}}}$ (2)

If we want to get a measure of the likelihood of some fully specified normal distributions for a given sample, we need to include the $\mathrm{normalize}=\mathrm{false}$. Otherwise, since there are no parameters in the distribution, all factors are omitted and we always get the answer $1$.

 > $\mathrm{Likelihood}\left(\mathrm{Normal}\left(5.0,1.0\right),S\right),\mathrm{Likelihood}\left(\mathrm{Normal}\left(4.8,1.2\right),S\right)$
 ${1}{,}{1}$ (3)
 > $\mathrm{Likelihood}\left(\mathrm{Normal}\left(5.0,1.0\right),S,'\mathrm{normalize}=\mathrm{false}'\right),\mathrm{Likelihood}\left(\mathrm{Normal}\left(4.8,1.2\right),S,'\mathrm{normalize}=\mathrm{false}'\right)$
 ${0.0129856344759522}{,}{0.00799276640176335}$ (4)

Insert missing data into the array and recompute.

 > ${S}_{4}≔\mathrm{undefined}:$
 > $\mathrm{Likelihood}\left(\mathrm{Normal}\left(\mathrm{μ},1\right),S\right)$
 ${{ⅇ}}^{{-}\frac{{1}}{{2}}{}{\left({4.52065806636344}{-}{\mathrm{μ}}\right)}^{{2}}}{}{{ⅇ}}^{{-}\frac{{1}}{{2}}{}{\left({5.78417369973330}{-}{\mathrm{μ}}\right)}^{{2}}}{}{{ⅇ}}^{{-}\frac{{1}}{{2}}{}{\left({4.49951342516818}{-}{\mathrm{μ}}\right)}^{{2}}}{}{{ⅇ}}^{{-}\frac{{1}}{{2}}{}{\left({\mathrm{HFloat}}{}\left({\mathrm{undefined}}\right){-}{\mathrm{μ}}\right)}^{{2}}}$ (5)
 > $\mathrm{Likelihood}\left(\mathrm{Normal}\left(\mathrm{μ},1\right),S,\mathrm{ignore}=\mathrm{true}\right)$
 ${{ⅇ}}^{{-}\frac{{1}}{{2}}{}{\left({4.52065806636344}{-}{\mathrm{μ}}\right)}^{{2}}}{}{{ⅇ}}^{{-}\frac{{1}}{{2}}{}{\left({5.78417369973330}{-}{\mathrm{μ}}\right)}^{{2}}}{}{{ⅇ}}^{{-}\frac{{1}}{{2}}{}{\left({4.49951342516818}{-}{\mathrm{μ}}\right)}^{{2}}}$ (6)

Consider a weighted structure.

 > $S≔\mathrm{Sample}\left(N,4\right):$
 > $W≔⟨2,2,0,0⟩:$
 > $\mathrm{Likelihood}\left(\mathrm{Normal}\left(\mathrm{μ},1\right),S,\mathrm{weights}=W\right)$
 ${\left({{ⅇ}}^{{-}\frac{{1}}{{2}}{}{\left({5.23782835292544}{-}{\mathrm{μ}}\right)}^{{2}}}\right)}^{{2}}{}{\left({{ⅇ}}^{{-}\frac{{1}}{{2}}{}{\left({4.85175935951542}{-}{\mathrm{μ}}\right)}^{{2}}}\right)}^{{2}}$ (7)

Compatibility

 • The V parameter was updated in Maple 16.
 • The normalize option was introduced in Maple 16.
 • For more information on Maple 16 changes, see Updates in Maple 16.