Questions tagged [log-likelihood]

Only questions related to the implementation and usage of the mathematical function - log-Likelihood should use this tag.

Given a sample and a parametric family of distributions (i.e., a set of distributions indexed by a parameter) that could have generated the sample, the Likelihood is a function that associates to each parameter the probability (or probability density) of observing the given sample.

The log-Likelihood a function which is the natural logarithm of the Likelihood function

For many applications, the log-Likelihood, is more convenient to work with as compared to the Likelihood. This is because we are generally interested in where the Likelihood reaches its maximum value. Since the logarithm is a strictly increasing function, the logarithm of a function achieves its maximum value at the same points as the function itself, hence the log-likelihood can be used in place of the likelihood for maximum likelihood estimation and related techniques.

Finding the maximum of a function often involves taking the derivative of a function and solving for the parameter being maximized, and this is often easier when the function being maximized is a log-likelihood rather than the original likelihood function, because the probability of the conjunction of several independent variables is the product of probabilities of the variables and solving an additive equation is usually easier than a multiplicative one.

232 questions
0
votes
1 answer

Implementing a particular approach to calculating a log-likelihood using matrix operations

I cam across a mathematical expression for log-likelihood in a CrossValidated.com answer and am unclear how I should implement in R. I'm not sure if SO can represent MathML the same as CV, but this is the first equation in the second (not accepted)…
IRTFM
  • 258,963
  • 21
  • 364
  • 487
0
votes
1 answer

How do you code the likelihood of the normal distribution kernel in R manually?

Specifically, how do you code the product of the differences of x and mu, precision matrix, and transpose of the differences of x and mu. Is my code below correct? Thanks in advance. (colSums(dat-mu_mat)%*%solve(sigma)%*%colSums(dat-mu_mat)) where…
0
votes
0 answers

Why Isn't my Manual Log-Likelihood Function for the MVN Working?

I am not getting the correct likelihood calculation with my code. Any help would be greatly appreciated. loglik_mvn<-function(n,d,x,mu_mat,sigma){ …
0
votes
0 answers

Problem with normalizing a function with likelihood

I have a problem with the following code. In the evidence part, the value is very small so, in the end, the probabilities are not calculated. I need to normalize it, but in which part should it be? The code in MATLAB is: clear all; close all;…
0
votes
0 answers

Maximising log likelihood for two parameters

I have two parameters I'd like to maximise the log likelihood for and get the optimal parameter values. The code here calculates an ODE system, from which I will use two trajectories as x and y data: import numpy as np from scipy.integrate import…
0
votes
0 answers

How do I adjust logloss for class imbalance in binary classification for machine learning?

I'm working on a machine learning project where I need to perform binary classification. I want to minimize the logloss (binary cross entropy loss) of my model. However, the dataset I'm using is split between the two classes 50/50, but the true…
0
votes
0 answers

Normal Distribution for two groups mean estimation

Two groups i=1,2 mean estimate for normal distribution. I would like to find the gradient and the hessian of the log-likelihood using R for the two groups. The log-likelihood function: loglik=expression(log(( 1/sqrt(2*pi*sigmasq)*exp(y-mu)^2/…
0
votes
0 answers

R GLM weights implementation /interpretation

Implementing a GLM in R with weights. I am wondering whether this quote from R Documentation of GLM Non-NULL weights can be used to indicate that different observations have different dispersions (with the values in weights being inversely…
0
votes
0 answers

Non-linear Likelihood Ratio Test in R

Consider following example data: x2 <- rnorm(100) x3 <- rnorm(100) e <- rnorm(100) b1 <- 1; b2 <- 2; b3 <- 2; ys <- b1 + b2*x2 + b3*x3 + e y <- ys > 0 Here, I want to implement the likelihood ratio test for the following non-linear…
0
votes
0 answers

KeyError: 0 when calculate likelihood in EM algorithm

I have a model EM algorithm. The model should select random columns and then calculate the likelihood. For example, the dataset has 39 attributes, the model selects 19 attributes only and displays likelihood. define several functions…
0
votes
0 answers

Mahalanobis distance in fastslam?

I'm very new to slam in general. I have a question regarding if the Maximum likelihood methods in the fastslam algorithm utilise mahalanobis distance, because according to this text: http://robots.stanford.edu/papers/Thrun03g.pdf , it states at page…
EyedBread
  • 11
  • 3
0
votes
0 answers

how to compare 2 distribution with log-liklihood ratio with compare_distributions(d1, d2)

I want to compare power law distribution with log-normal using likelihood ratio test.I use power law package and use the code below with continuous data set of one variable.According to clauset et al.(2009) If this p-value is small ( p < 0.1) then…
Neda Fathi
  • 13
  • 4
0
votes
1 answer

parameter optimisation in Hawkes Point Process in R

I have a data set with 1,000 of people some of which know each other and others do not. I am trying to predict using a hawkes point process which individuals (or nodes) will adopt a behaviour. The issue is I am attempting to optimise the…
LPM
  • 3
  • 1
0
votes
1 answer

Error in optimize in R for generating distribution parameters for a log-likelihood function

I am trying to calculate distribution parameters to calculate log-likelihood values. Whilst "optim" seems to work for the function defined below, it obviously changes the output every time I change the starting value. I am trying to use "optimize"…
kayp
  • 1
  • 2
0
votes
0 answers

rstan: Compute log likelihood in generated quantitites block

Here is some data: # simulate data set.seed(123) nsubj = 20 nitem = 300 b1 = -0.025 b2 = -0.157 sigma = 0.1 library(truncnorm) x1 = rep(rtruncnorm(nitem, a=0, mean=4.185, sd=1.765), nsubj) x2 = rep(rtruncnorm(nitem, a=0, mean=3.734, sd=2.228),…
hyhno01
  • 177
  • 8