loglik.RdThis function calculates the log-likelihood at some parameter values given the random sample and distribution.
loglik(x, dist = "dnorm", param = list(mean = 0, sd = 1))numeric vector.
density name for the distribution in the form dxxx. By default it's value is dnorm but can be used any density.
list with the parameter values at which can be calculated the log-likelihood.
# For Poisson distribution
x <- rpois(n=50, lambda=4.5)
loglik(x, dist='dpois', param=list(lambda=4))
#> [1] -110.2329
loglik(x, dist='dpois', param=list(lamb=4.5))
#> [1] -109.0851
loglik(x, dist='dpois', param=list(lambda=5))
#> [1] -110.695
# For normal distribution
y <- rnorm(n=100, mean=170, sd=10)
loglik(y, dist='dnorm', param=list(mean=170, sd=10))
#> [1] -373.7708
# Un ejemplo invocando los datos de este paquete
data(condom)
dim(condom)
#> [1] 153 4
data(misdatos)
misdatos
#> estatura peso
#> 1 158 65
#> 2 178 71
#> 3 169 66