Type: Package
Title: Likelihood Exploration
Version: 0.1.0
Maintainer: Ben Barnard <ben_barnard@outlook.com>
Description: Provides likelihood functions as defined by Fisher (1922) <doi:10.1098/rsta.1922.0009> and a function that creates likelihood functions from density functions. The functions are meant to aid in education of likelihood based methods.
License: GPL-2
LazyData: TRUE
RoxygenNote: 6.0.1
Suggests: covr
Imports: lazyeval, plyr
URL: https://likelihoodExplore.bearstatistics.com
NeedsCompilation: no
Packaged: 2017-11-14 14:52:30 UTC; ben_barnard
Author: Ben Barnard [aut, cre]
Repository: CRAN
Date/Publication: 2017-11-14 15:51:01 UTC

Likelihood Exploration

Description

A package of likelihood functions as defined by Fisher <doi:10.1098/rsta.1922.0009> and a function that creates likelihood functions from density functions. The functions are meant to aid in education of likelihood based methods.


Beta Log Likelihood Function

Description

The log likelihood of a beta density with data, x, shape1, shape2 and ncp parameters.

Usage

likbeta(x, shape1, shape2, ncp = 0, log = TRUE)

Arguments

x

vector of quantiles.

shape1

non-negative parameters of the Beta distribution.

shape2

non-negative parameters of the Beta distribution.

ncp

non-centrality parameter.

log

logical; if TRUE, probabilities p are given as log(p).

Details

The log likelihood is the log of a function of parameters given the data.

Value

A numeric scalar for the log likelihood of the beta density given the data where shape1, shape2, and ncp can be held constant or if vector were given vector will be returned.

Examples

likbeta(x = rbeta(n = 2, shape1 = 3, shape2 = 4),
        shape1 = 3, shape2 = 4)

Binomial Log Likelihood Function

Description

The log likelihood of a binomial density with data, x, size and prob parameters.

Usage

likbinom(x, size, prob, log = TRUE)

Arguments

x

vector of quantiles.

size

number of trials (zero or more).

prob

probability of success on each trial.

log

logical; if TRUE, probabilities p are given as log(p).

Details

The log likelihood is the log of a function of parameters given the data.

Value

A numeric scalar for the log likelihood of the binomial density given the data where size and prob can be held constant or if vector were given vector will be returned.

Examples

likbinom(x = rbinom(n = 2, size = 3, prob = .4),
        size = 3, prob = .4)

Cauchy Log Likelihood Function

Description

The log likelihood of a Cauchy density with data, x, location and scale parameters.

Usage

likcauchy(x, location = 0, scale = 1, log = TRUE)

Arguments

x

vector of quantiles.

location

location and scale parameters.

scale

location and scale parameters.

log

logical; if TRUE, probabilities p are given as log(p).

Details

The log likelihood is the log of a function of parameters given the data.

Value

A numeric scalar for the log likelihood of the Cauchy density given the data where location and scale can be held constant or if vector were given vector will be returned.

Examples

likcauchy(x = rcauchy(n = 2))

Chi-Squared Log Likelihood Function

Description

The log likelihood of a chi-squared density with data, x, df and ncp parameters.

Usage

likchisq(x, df, ncp = 0, log = TRUE)

Arguments

x

vector of quantiles.

df

degrees of freedom (non-negative, but can be non-integer).

ncp

non-centrality parameter (non-negative).

log

logical; if TRUE, probabilities p are given as log(p).

Details

The log likelihood is the log of a function of parameters given the data.

Value

A numeric scalar for the log likelihood of the chi-squared density given the data where df and ncp can be held constant or if vector were given vector will be returned.

Examples

likchisq(x = rchisq(n = 2, df = 4),
        df = 4)

Log Likelihood Function Maker

Description

Function that creates a log likelihood function given a density function density.

Usage

likelihood(density, ...)

Arguments

density

density function used

...

other options

Details

The log likelihood is the log of a function of parameters given the data.

Value

A function that is the log likelihood function from density function density.

Examples

likelihood(dnorm, x = rnorm(100))


Exponential Log Likelihood Function

Description

The log likelihood of a exponential density with data, x, rate parameter.

Usage

likexp(x, rate = 1, log = TRUE)

Arguments

x

vector of quantiles.

rate

vector of rates.

log

logical; if TRUE, probabilities p are given as log(p).

Details

The log likelihood is the log of a function of parameters given the data.

Value

A numeric scalar for the log likelihood of the exponential density given the data where rate can be held constant or if vector were given vector will be returned.

Examples

likexp(x = rexp(n = 2))

F Log Likelihood Function

Description

The log likelihood of a F density with data, x, df1, df2 and ncp parameters.

Usage

likf(x, df1, df2, ncp, log = TRUE)

Arguments

x

vector of quantiles.

df1

degrees of freedom. Inf is allowed.

df2

degrees of freedom. Inf is allowed.

ncp

non-centrality parameter. If omitted the central F is assumed.

log

logical; if TRUE, probabilities p are given as log(p).

Details

The log likelihood is the log of a function of parameters given the data.

Value

A numeric scalar for the log likelihood of the f density given the data where df1, df2, and ncp can be held constant or if vector were given vector will be returned.

Examples

likf(x = rf(n = 2, df1 = 3, df2 = 4),
        df1 = 3, df2 = 4)

Gamma Log Likelihood Function

Description

The log likelihood of a gamma density with data, x, shape, rate and scale parameters.

Usage

likgamma(x, shape, rate = 1, scale = 1/rate, log = TRUE)

Arguments

x

vector of quantiles.

shape

shape and scale parameters. Must be positive, scale strictly.

rate

an alternative way to specify the scale.

scale

shape and scale parameters. Must be positive, scale strictly.

log

logical; if TRUE, probabilities/densities p are returned as log(p).

Details

The log likelihood is the log of a function of parameters given the data.

Value

A numeric scalar for the log likelihood of the gamma density given the data where shape, scale, and rate can be held constant or if vector were given vector will be returned.

Examples

likgamma(x = rgamma(n = 2, shape = 3),
        shape = 3)

Geometric Log Likelihood Function

Description

The log likelihood of a geometric density with data, x, prob parameter.

Usage

likgeom(x, prob, log = TRUE)

Arguments

x

vector of quantiles representing the number of failures in a sequence of Bernoulli trials before success occurs.

prob

probability of success in each trial. 0 < prob <= 1.

log

logical; if TRUE, probabilities p are given as log(p).

Details

The log likelihood is the log of a function of parameters given the data.

Value

A numeric scalar for the log likelihood of the geometric density given the data where prob can be held constant or if vector were given vector will be returned.

Examples

likgeom(x = rgeom(n = 2, prob = .4),
        prob = .4)

Hypergeometric Log Likelihood Function

Description

The log likelihood of a hypergeometric density with data, x, m, n and k parameters.

Usage

likhyper(x, m, n, k, log = TRUE)

Arguments

x

vector of quantiles representing the number of white balls drawn without replacement from an urn which contains both black and white balls.

m

the number of white balls in the urn.

n

the number of black balls in the urn.

k

the number of balls drawn from the urn.

log

logical; if TRUE, probabilities p are given as log(p).

Details

The log likelihood is the log of a function of parameters given the data.

Value

A numeric scalar for the log likelihood of the hypergeometric density given the data where m, n, and k can be held constant or if vector were given vector will be returned.

Examples

likhyper(x = rhyper(nn = 2, m = 3, n = 4, k = 2),
        m = 3, n = 4, k = 2)

Log Normal Log Likelihood Function

Description

The log likelihood of a log normal density with data, x, meanlog and sdlog parameters.

Usage

liklnorm(x, meanlog = 0, sdlog = 1, log = TRUE)

Arguments

x

vector of quantiles.

meanlog

mean and standard deviation of the distribution on the log scale with default values of 0 and 1 respectively.

sdlog

mean and standard deviation of the distribution on the log scale with default values of 0 and 1 respectively.

log

logical; if TRUE, probabilities p are given as log(p).

Details

The log likelihood is the log of a function of parameters given the data.

Value

A numeric scalar for the log likelihood of the log normal density given the data where meanlog and sdlog can be held constant or if vector were given vector will be returned.

Examples

liklnorm(x = rlnorm(n = 2))

Logistic Log Likelihood Function

Description

The log likelihood of a logistic density with data, x, location and scale parameters.

Usage

liklogis(x, location = 0, scale = 1, log = TRUE)

Arguments

x

vector of quantiles.

location

location and scale parameters.

scale

location and scale parameters.

log

logical; if TRUE, probabilities p are given as log(p).

Details

The log likelihood is the log of a function of parameters given the data.

Value

A numeric scalar for the log likelihood of the logistic density given the data where location and scale can be held constant or if vector were given vector will be returned.

Examples

liklogis(x = rlogis(n = 2))

Multinomial Log Likelihood Function

Description

The log likelihood of a multinomial density with data, x, size and prob parameters.

Usage

likmultinom(x, size = NULL, prob, log = TRUE)

Arguments

x

vector of length K of integers in 0:size.

size

integer, say N, specifying the total number of objects that are put into K boxes in the typical multinomial experiment. For dmultinom, it defaults to sum(x).

prob

numeric non-negative vector of length K, specifying the probability for the K classes; is internally normalized to sum 1. Infinite and missing values are not allowed.

log

logical; if TRUE, log probabilities are computed.

Details

The log likelihood is the log of a function of parameters given the data.

Value

A numeric scalar for the log likelihood of the multinomial density given the data where size and prob can be held constant or if vector were given vector will be returned.

Examples

likmultinom(x = rmultinom(n = 2, size = 3, prob = .4),
        size = 3, prob = .4)

Negative Binomial Log Likelihood Function

Description

The log likelihood of a negative binomial density with data, x, size, prob and mu parameters.

Usage

liknbinom(x, size, prob, mu, log = TRUE)

Arguments

x

vector of (non-negative integer) quantiles.

size

target for number of successful trials, or dispersion parameter (the shape parameter of the gamma mixing distribution). Must be strictly positive, need not be integer.

prob

probability of success in each trial. 0 < prob <= 1.

mu

alternative parametrization via mean: see ‘Details’.

log

logical; if TRUE, probabilities p are given as log(p).

Details

The log likelihood is the log of a function of parameters given the data.

Value

A numeric scalar for the log likelihood of the negative binomial density given the data where size, prob, and mu can be held constant or if vector were given vector will be returned.

Examples

liknbinom(x = rnbinom(n = 2, size = 3, prob = .4),
        size = 3, prob = .4)

Normal Log Likelihood Function

Description

The log likelihood of a normal density with data, x, mean and sd parameters.

Usage

liknorm(x, mean = 0, sd = 1, log = TRUE)

Arguments

x

vector of quantiles.

mean

vector of means.

sd

vector of standard deviations.

log

logical; if TRUE, probabilities p are given as log(p).

Details

The log likelihood is the log of a function of parameters given the data.

Value

A numeric scalar for the log likelihood of the normal density given the data where mean and sd can be held constant or if vector were given vector will be returned.

Examples

liknorm(x = rnorm(n = 2))

Poisson Log Likelihood Function

Description

The log likelihood of a Poisson density with data, x, lambda parameter.

Usage

likpois(x, lambda, log = TRUE)

Arguments

x

vector of (non-negative integer) quantiles.

lambda

vector of (non-negative) means.

log

logical; if TRUE, probabilities p are given as log(p).

Details

The log likelihood is the log of a function of parameters given the data.

Value

A numeric scalar for the log likelihood of the Poisson density given the data where lambda can be held constant or if vector were given vector will be returned.

Examples

likpois(x = rpois(n = 2, lambda = 4),
        lambda = 4)

Student's t Log Likelihood Function

Description

The log likelihood of a Student's t density with data, x, df and ncp parameters.

Usage

likt(x, df, ncp, log = TRUE)

Arguments

x

vector of quantiles.

df

degrees of freedom (> 0, maybe non-integer). df = Inf is allowed.

ncp

non-centrality parameter \delta; currently except for rt(), only for abs(ncp) <= 37.62. If omitted, use the central t distribution.

log

logical; if TRUE, probabilities p are given as log(p).

Details

The log likelihood is the log of a function of parameters given the data.

Value

A numeric scalar for the log likelihood of the Student's t density given the data where df and ncp can be held constant or if vector were given vector will be returned.

Examples

likt(x = rt(n = 2, df = 4),
        df = 4)

Uniform Log Likelihood Function

Description

The log likelihood of a uniform density with data, x, min and max parameters.

Usage

likunif(x, min = 0, max = 1, log = TRUE)

Arguments

x

vector of quantiles.

min

lower and upper limits of the distribution. Must be finite.

max

lower and upper limits of the distribution. Must be finite.

log

logical; if TRUE, probabilities p are given as log(p).

Details

The log likelihood is the log of a function of parameters given the data.

Value

A numeric scalar for the log likelihood of the uniform density given the data where min and max can be held constant or if vector were given vector will be returned.

Examples

likunif(x = runif(n = 2))

Weibull Log Likelihood Function

Description

The log likelihood of a Weibull density with data, x, shape and scale parameters.

Usage

likweibull(x, shape, scale = 1, log = TRUE)

Arguments

x

vector of quantiles.

shape

shape and scale parameters, the latter defaulting to 1.

scale

shape and scale parameters, the latter defaulting to 1.

log

logical; if TRUE, probabilities p are given as log(p).

Details

The log likelihood is the log of a function of parameters given the data.

Value

A numeric scalar for the log likelihood of the Weibull density given the data where shape and scale can be held constant or if vector were given vector will be returned.

Examples

likweibull(x = rweibull(n = 2, shape = 3),
        shape = 3)

Wilcoxon Rank Sum Log Likelihood Function

Description

The log likelihood of a Wilcoxon rank sum density with data, x, m and n parameters.

Usage

likwilcox(x, m, n, log = TRUE)

Arguments

x

vector of quantiles.

m

numbers of observations in the first and second sample, respectively. Can be vectors of positive integers.

n

numbers of observations in the first and second sample, respectively. Can be vectors of positive integers.

log

logical; if TRUE, probabilities p are given as log(p).

Details

The log likelihood is the log of a function of parameters given the data.

Value

A numeric scalar for the log likelihood of the Wilcoxon rank sum density given the data where m and n can be held constant or if vector were given vector will be returned.

Examples

likwilcox(x = rwilcox(nn = 2, m = 3, n = 4),
        m = 3, n = 4)

mirror server hosted at Truenetwork, Russian Federation.