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
0 answers

Strangely different results doing Box Cox transform with R Optim and with MASS package

using optim in R, We don't uderstand why We have not the same result than lambda Box Cox in Mass package ? Is the problem whith the linear model ? Please find the code below. Do you have any idea? Thanks a lot for your help. Have a nice…
user3619937
  • 85
  • 2
  • 6
0
votes
0 answers

Copula-GARCH model in python

I'm trying to do a copula GARCH model with data from 5 indexes (SP500, STXE600, Nikkei, FTS100 and PHLXGOLD). My data is already in a dataframe and I modeled the 4 GARCH model I will work with: GARCH-n (GARCH model with normal distribution):…
0
votes
0 answers

No module named 'statsmodels.genmod.penalties'

Can anyone help me? The root problem is that i have recently installed statsmodels library in JupyterNotebook. Now when i try to execute my code it says there is no module named statsmodels.genmod.penalties. I think i am importing L1 penalty in the…
0
votes
0 answers

Python implmentation of Marginal Maximum Likelihood estimate based 2-PL Dichotomous IRT

I am looking for implementations of simple Marginal Maximum Likelihood Estimate based 2-PL IRT Item estimation in Python. Any relevant Python libraries that do this (similar to snowIRT module in Jamovi)? I have looked into py-irt and it seems to do…
204
  • 433
  • 1
  • 5
  • 19
0
votes
0 answers

Implementing 2-PL IRT Module in Python from scratch

I am trying to implement a 2-PL dichotomous IRT Model for my dataset from scratch in Python. Here is my code so far: def get_data_matrix(num_students, num_items): data = np.random.randint(0, 2, size=(num_students, num_items)) return…
204
  • 433
  • 1
  • 5
  • 19
0
votes
0 answers

Efficient log-likelihood calculation in depmixS4 package

I want to calculate log likelihood for my model but don't know how to do it efficiently. Here is my code that does what I need, but it's slow up <- rnorm(300,mean = 1,sd = 1) dw <- rnorm(300,mean = -1,sd = 1) test <-…
mr.T
  • 181
  • 2
  • 13
0
votes
1 answer

Is there any vectorized equivalent of pmvnorm?

I am trying to optimize my code which takes as argument four vectors X1, X2, X3, X4 and a correlation matrix R. First, for each observation I compute F(X3,X4)+F(X1,X2)-F(X2,X3)-F(X1,X4) where F corresponds to the function below: F <-…
0
votes
0 answers

Newton Raphson Method for Several Variables

so I made an R code to estimate parameters (alpha1, alpha2, beta1, and beta2). Here's my code: library(base) library(pracma) library(readxl) x <- asuransiOhlssonaft$freq.claim z <- asuransiOhlssonaft$z t<-length(x) t_seq <- seq(1, t, 1) x_bar <-…
0
votes
0 answers

log likelihood function of linear regression with ordinal endogenous variable and sample selection

I want to estimate a linear regression with an ordinal endogenous variable and endogenous sample selection. Wooldridge (2010) describes a two-step procedure to do that. I would also like to estimate it using an ML approach but I find it difficult to…
Nikos
  • 1
0
votes
1 answer

How to save global of maximum log-likelihood data from loop?

I am doing this: ## Example data library(poLCA) data(gss82) f <- cbind(PURPOSE,ACCURACY,UNDERSTA,COOPERAT)~1 mlmat <- matrix(NA,nrow=500,ncol=4) ## Do repreat 500 times LCA for best llik for (i in 1:500) { gss.lc <-…
Bruce
  • 79
  • 7
0
votes
1 answer

Vectorizing S4 Class in R

I am trying to compute a log-likelihood, where the likelihood is a convolution of two distributions, and the distribution parameters depend on the value of that data point. More formally, I believe my data follows a likelihood which is the sum of…
0
votes
1 answer

Rounding error in density functions of R-programming language

Using R I am trying to compute the likelihoods of a vector of values. Some of these values are way off into the tails of the distributions. Rounding error appears to be causing the results to be rounded to zero, making my code throw an error when…
BasMts
  • 3
  • 2
0
votes
0 answers

Is there any mistake of my code for a sum of log(|det|)?

import numpy as np import torch import torch.nn as nn import torch.nn.functional as F class InvConv(nn.Module): """Invertible 1x1 Convolution for 2D inputs. Originally described in Glow (https://arxiv.org/abs/1807.03039). Does not support…
0
votes
0 answers

Is it possible to run the R function nleqslv in parallel?

I'm implementing the code for an extension of the Cox model in R and I need to find the roots of an estimating equation (derivative of the log-likelihood = 0). I managed to get the solution with the nleqslv function of the homonymous package but the…
0
votes
0 answers

Calculating Likelihood for Latent Profile Analysis

It is my understanding that for latent class analysis (LCA) the log likelihood can be calculated by summing the log likelihoods for each case (combination of values of the categorical predictors). For example if we have X1, X2, and X3 as binary…