I am given two data sets containing dates and losses (in some currency). I have to determine the maximum likelihood estimates of the parameters of loglogistic distribution.

I googled and found a paper that gives me the "MMLE" for sigma in (2.4).

1 Is that good enough to substitute for MLE? It seems to follow the same procedure of getting the MLE that I recall from introductory statistics.

2 To estimate sigma, it looks like I will have to censor s values from sample. How do I determine a value for s?

Exact instructions:


  1. For each loss data set [given elsewhere],
    determine the maximum likelihood estimates of the parameters of each of the following models:
    a. Loglogistic distribution


  1. For each model in no. 1, perform the following goodness-of-fit tests:
    a. Kolmogorov-Smirnov test b. Anderson-Darling test c. Chi-square goodness-of-fit test

  2. The following must be included in your report:
    a) Word file (hard copy): Complete solution: discussion of the likelihood (or loglikelihood) function for each model, discussion of the goodness-of-fit tests for each model Computation of VaR and TVaR b) Excel file (by email): Implementation of the formulas obtained in 3.a "

  • $\begingroup$ How are you parameterizing the loglogistic? $\endgroup$ – Avraham Jan 23 '15 at 7:32
  • $\begingroup$ Why do you need a paper for this? The PDF of the log-logistic distribution is on the Wikipedia page. It would be easy to implement the MLE for $\alpha$ and $\beta$. $\endgroup$ – tchakravarty Jan 23 '15 at 7:34
  • $\begingroup$ @Avraham As described in the paper? There's a formula to estimate sigma (pdf is different in paper. I guess wiki uses alpha instead of sigma or something). It relies on an estimate of beta. There's a procedure for beta which I haven't read yet $\endgroup$ – BCLC Jan 23 '15 at 11:23
  • $\begingroup$ @fgnu Tell me then. What are the MLEs of each? I think the point of the paper is that there is no closed form. There are however approximations that lead to closed form solutions, at least for sigma. Such reasoning doesn't apply to beta apparently so there's another procedure, but I haven't read it yet. $\endgroup$ – BCLC Jan 23 '15 at 11:25
  • $\begingroup$ @BCLC Sorry, don't understand at all what the question is. You have asked for the MLE of the log-logistic distribution. That is given in my answer below. Why do you need a closed form solution? The set of MLEs that can be computed in closed form is minuscule (and only relevant for theoretical purposes). Further, the paper refers to estimation of the parameters under a different sampling scheme than random sampling. Is that the sampling scheme you are interested in? Your question shows no indication of that. $\endgroup$ – tchakravarty Jan 23 '15 at 11:29

If you are looking to fit a log-logistic distribution to your data, it is fairly straightforward to do so. In the example below, I am using the function dllog to get at the density of the log-logistic for a given set of values of the shape and scale parameter, but it is no trouble to write the PDF code yourself as well.

(Log-)Likelihood & MLE

The density of log-logistic distributed a random variable has the probability density function [PDF]: $$ f(X_i; \alpha, \beta) = \dfrac{\left(\tfrac{\beta}{\alpha}\right)\left(\tfrac{X_i}{\alpha}\right)^{\beta - 1}}{\left(1+ \left(\tfrac{X_i}{\alpha}\right)^{\beta}\right)^2} $$ where $\alpha$ and $\beta$ are the scale and shape parameters respectively.

For a given sample of data $X_1, \ldots, X_N$, this implies that the log-likelihood of the sample is: $$ \ell_N(\alpha, \beta \mid X_1, \ldots, X_N) = \sum_{i=1}^N \log f(X_i; \alpha, \beta) $$

The MLE of the parameters given the sample of the data, is given by the maximizer of the log-likelihood: $$ \hat{\alpha}_{MLE}, \hat{\beta}_{MLE} = \arg\max_{\alpha, \beta}\ell_N(\alpha, \beta \mid X_1, \ldots, X_N) $$

Computing & optimizing the log-likelihood

In the code below:
0. I have used the function rllog to generate a random sample from a log-logistic distribution with parameters c(5, 6).
1. The function fnLLLL computes the (negative) log-likelihood of the data.
2. The function fnLLLL uses the function dllog from the FAdist package to compute the PDF of the log-logistic distribution, $f$.
3. optim computes the values of $\alpha$, and $\beta$ that minimize the negative log-likelihood, and the values c(2, 3) are the intial values for the optimizer. Those optimized values are $5.132758$ & $5.654340$, and the optimized value of the negative log-likelihood function is $9239.179$.

# simulate some log-logistic data
vY = rllog(n = 1000, shape = 5, scale = 6)

# log-likelihood function
fnLLLL = function(vParams, vData) {
  # uses the density function of the log-logistic function from FAdist
  return(-sum(log(dllog(vData, shape = vParams[1], scale = vParams[2]))))

# optimize it
optim(c(2, 3), fnLLLL, vData = vY)

This gives:

> optim(c(2, 3), fnLLLL, vData = vY)
[1] 5.132758 5.654340

[1] 9239.179

function gradient 
      57       NA 

[1] 0

  • $\begingroup$ so shape =5 and scale = 6 are initial values or something? so in my case I let vY = the data given to me rather than what you gave me (which I guess is simulation of values from loglogistic with shape=5 and scale=6?) ? thanks, but I have to show the derivations. Those are R codes right? Does R have a specific formula (closed or not), on which the commands are based, for the parameters? $\endgroup$ – BCLC Jan 23 '15 at 11:29
  • $\begingroup$ btw, what are the 2 and 3 in optim? also initial values? what about the 9239.179? Is that the max of the log likelihood function? $\endgroup$ – BCLC Jan 23 '15 at 11:55
  • $\begingroup$ Added exact instructions. Oh hmmm...I guess I don't need a closed form, but I do need to discuss the loglikelihood function. So I just quote the article about the loglikelihood function and then use R to estimate the parameters. $\endgroup$ – BCLC Jan 23 '15 at 12:01

I asked above for the parametrization, as in Actuarial Science (at least in the US) the loglogistic (Fisk) is usually parameterized: $$ \begin{align} f(x) &= \frac{\gamma\left(\frac{x}{\theta}\right)^\gamma}{x + \left[1 + \left(\frac{x}{\theta}\right)^\gamma\right]^2}\\ F(x) &= \frac{\left(\frac{x}{\theta}\right)^\gamma}{1 + \left(\frac{x}{\theta}\right)^\gamma} \end{align} $$

Therefore: $$ LL(x) = \ln\gamma + \gamma\left(\ln x - \ln\theta\right) - \ln x - 2\ln\left(1 + \left(\frac{x}{\theta}\right)^\gamma\right) $$

As above, create an error function for this (well, negative log likelihood) similar to:

NLL_LGLG <- function(pars, X) {
  gamma <- pars[[1]]
  theta <- pars[[2]]
  LL <- log(gamma) + gamma * (log(X) - log(theta)) - log(X) -
        2 * log(1 + (X / theta) ^ gamma)

You can use deriv3 if you want to use gradient based methods like L_BFGS (or calculate it by hand if speed is of the essence), but plugging the above and your data into optim or nloptr should be what you want. If you don't want to roll your own logliklihoods, and this parameterization is the one you want, you can find dllogis in the actuar package on CRAN.

  • 1
    $\begingroup$ (+1) Aside: Is "roll your own loglikelihoods" a common colloquialism? I've never heard it, but I absolutely love it. $\endgroup$ – Sycorax says Reinstate Monica Jan 28 '15 at 0:52
  • $\begingroup$ @user777 It is a colloquialism which means "build your own." It originally comes from "roll your own cigarettes" as opposed to buying pre-rolled packs, but for decades it has been co-opted to other areas. See urban dictionary entry or this entry at techrepublic for a couple of examples 8-) $\endgroup$ – Avraham Jan 28 '15 at 0:58
  • $\begingroup$ And here I was hoping that it was somehow a D&D reference... $\endgroup$ – Sycorax says Reinstate Monica Jan 28 '15 at 0:59
  • $\begingroup$ No, sorry. We have plenty of d4, d6, d8, d10, d12, and d20s, but no physical dllogis. I'd love to see how an implementation though :D $\endgroup$ – Avraham Jan 28 '15 at 1:01
  • $\begingroup$ In my mind, command dlogis generates random deviates. $\endgroup$ – Sycorax says Reinstate Monica Jan 28 '15 at 1:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.