Statistics
LogLikelihood
compute log likelihood function of a random variable and data set
Calling Sequence
Parameters
Description
Options
Examples
LogLikelihood(R, V, options)
R
-
algebraic; a random variable or distribution
V
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 LogLikelihood function
The LogLikelihood function computes the log likelihood function of a random variable R evaluated on a dataset 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).
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 log 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 V will be ignored.
normalize=truefalse -- This option selects whether terms that do not depend on the value of the parameters can be omitted. The default is normalize = true, meaning that such terms can be omitted; selecting normalize = false means they are included.
weights=rtable -- Vector of weights (one-dimensional rtable). If weights are given, the LogLikelihood 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.
with⁡Statistics:
Calculate the general log likelihood function from the ChiSquare distribution.
LogLikelihood⁡ChiSquare⁡ν,A,samplesize=4
ln⁡A1ν2−1Γ⁡ν2+ln⁡A2ν2−1Γ⁡ν2+ln⁡A3ν2−1Γ⁡ν2+ln⁡A4ν2−1Γ⁡ν2−2⁢ln⁡2⁢ν
Sample a random variable with Normal distribution.
N≔RandomVariable⁡Normal⁡5,1:
S≔Sample⁡N,4:
Attempt to compute the log likelihood function of this sample.
LogLikelihood⁡Normal⁡μ,1,S
19.3132942923314⁢μ−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 normalize=false. Otherwise, since there are no parameters in the distribution, all terms are omitted and we always get the answer 0.
LogLikelihood⁡Normal⁡5.0,1.0,S,LogLikelihood⁡Normal⁡4.8,1.2,S
0,0
LogLikelihood⁡Normal⁡5.0,1.0,S,normalize=false,LogLikelihood⁡Normal⁡4.8,1.2,S,normalize=false
−4.34391155881307,−4.82921832924692
Insert missing data into the array and recompute.
S4≔undefined:
Float⁡undefined⁢μ−2⁢μ2
LogLikelihood⁡Normal⁡μ,1,S,ignore=true
14.8043451912649⁢μ−32⁢μ2
Consider a weighted structure.
W≔2,2,0,0:
LogLikelihood⁡Normal⁡μ,1,S,weights=W
23.4067863122709⁢μ−2⁢μ2
See Also
Statistics[Computation]
Download Help Document