search for: loglikelihoods

Displaying 20 results from an estimated 162 matches for "loglikelihoods".

Did you mean: loglikelihood
2011 May 12
1
Maximization of a loglikelihood function with double sums
Dear R experts, Attached you can find the expression of a loglikelihood function which I would like to maximize in R. So far, I have done maximization with the combined use of the mathematical programming language AMPL (www.ampl.com) and the solver SNOPT (http://www.sbsi-sol-optimize.com/manuals/SNOPT%20Manual.pdf). With these tools, maximization is carried out in a few seconds. I wonder if that
2011 Apr 15
3
GLM output for deviance and loglikelihood
It has always been my understanding that deviance for GLMs is defined by; D = -2(loglikelihood(model) - loglikelihood(saturated model)) and this can be calculated by (or at least usually is); D = -2(loglikelihood(model)) As is done so in the code for 'polr' by Brian Ripley (in the package 'MASS') where the -loglikehood is minimised using optim; res <-
2008 Jul 09
1
Loglikelihood for x factorial?
Hi Rers, I have a silly question. I don't know how to express the loglikelihood function of 1/(x!) where x=x1,x2,....xn in R. Could anyone give me a hint? Thank you in advance. Chunhao Tu
2011 Mar 14
0
nlysystemfit and loglikelihood values
Dear R-help, The documentation for systemfit shows that logLik() can be used to obtain loglikelihood values from linear systems estimated by systemfit(). It seems to me that logLik() cannot be used for nlsystemfit(). Does anyone know of any other packages that might let me obtain the loglikelihood of a model estimated with nlsystemfit()? Kind regards, Alex Olssen
2010 Dec 07
1
Using nlminb for maximum likelihood estimation
I'm trying to estimate the parameters for GARCH(1,1) process. Here's my code: loglikelihood <-function(theta) { h=((r[1]-theta[1])^2) p=0 for (t in 2:length(r)) { h=c(h,theta[2]+theta[3]*((r[t-1]-theta[1])^2)+theta[4]*h[t-1]) p=c(p,dnorm(r[t],theta[1],sqrt(h[t]),log=TRUE)) } -sum(p) } Then I use nlminb to minimize the function loglikelihood: nlminb(
2006 Mar 31
1
loglikelihood and lmer
Dear R users, I am estimating Poisson mixed models using glmmPQL (MASS) and lmer (lme4). We know that glmmPQL do not provide the correct loglikelihood for such models (it gives the loglike of a 'pseudo' or working linear mixed model). I would like to know how the loglike is calculated by lmer. A minor question is: why do glmmPQL and lmer give different degrees-of-freedom for the same
2011 Jun 08
2
Results of CFA with Lavaan
I've just found the lavaan package, and I really appreciate it, as it seems to succeed with models that were failing in sem::sem. I need some clarification, however, in the output, and I was hoping the list could help me. I'll go with the standard example from the help documentation, as my problem is much larger but no more complicated than that. My question is, why is there one latent
2012 Nov 30
2
NA return to NLM routine
Hello, I am trying to understand a small quirk I came across in R. The following code results in an error: k <- c(2, 1, 1, 5, 5) f <- c(1, 1, 1, 3, 2) loglikelihood <- function(theta,k,f){ if( theta<1 && theta>0 ) return(-1*sum(log(choose(k,f))+f*log(theta)+(k-f)*log(1-theta))) return(NA) } nlm(loglikelihood ,0.5, k, f ) Running this code results in: Error
2007 May 24
3
Problem with numerical integration and optimization with BFGS
Hi R users, I have a couple of questions about some problems that I am facing with regard to numerical integration and optimization of likelihood functions. Let me provide a little background information: I am trying to do maximum likelihood estimation of an econometric model that I have developed recently. I estimate the parameters of the model using the monthly US unemployment rate series
2009 Jun 06
0
loglikelihood and AIC
Hi,  I tried fitting loglinear model using the glm(catspec). The data used is FHtab. . An independence model was fitted. Here summary() and fitmacro( ) give different values for AIC.   I understand that fitmacro( ) takes the likelilhood ratio L2(deviance) to calculate AIC and uses the formula AIC= L2- d.f(deviance)*2 and this AIC is used for comparison of nested models. (Am I right?)   The value
2008 May 22
1
Computing Maximum Loglikelihood With "nlm" Problem
Hi, I tried to compute maximum likelihood under gamma distribution, using nlm function. The code is this: __BEGIN__ vsamples<- c(103.9, 88.5, 242.9, 206.6, 175.7, 164.4) mlogl <- function(alpha, x) { if (length(alpha) > 1) stop("alpha must be scalar") if (alpha <= 0) stop("alpha must be positive") return(- sum(dgamma(x, shape = alpha, log = TRUE)))
2008 Jul 17
0
How to compute loglikelihood of Lognormal distribution
Hi, I am trying to learn lognormal mixture models with EM. I was wondering how does one compute the log likelihood. The current implementation I have is as follows, which perform really bad in learning the mixture models. __BEGIN__ # compute probably density of lognormal. dens <- function(lambda, theta, k){ temp<-NULL meanl=theta[1:k] sdl=theta[(k+1):(2*k)]
2009 Oct 27
1
Poisson dpois value is too small for double precision thus corrupts loglikelihood
Hi - I have a likelihood function that involves sums of two possions: L = a*dpois(Xi,theta1)*dpois(Yi,theta2)+b*(1-c)*a*dpois(Xi,theta1+theta3)*dpois(Yi,theta2) where a,b,c,theta1,theta2,theta3 are parameters to be estimated. (Xi,Yi) are observations. However, Xi and Yi are usually big (> 20000). This causes dpois to returns 0 depending on values of theta1, theta2 and theta3. My first
2008 Apr 18
2
rzinb (VGAM) and dnbinom in optim
Dear R-help gurus (and T.Yee, the VGAM maintainer) - I've been banging my head against the keyboard for too long now, hopefully someone can pick up on the errors of my ways... I am trying to use optim to fit a zero-inflated negative binomial distribution. No matter what I try I can't get optim to recognize my initial parameters. I think the problem is that dnbinom allows either
2011 Apr 10
1
MLE where loglikelihood function is a function of numerical solutions
Hi there, I'm trying to solve a ML problem where the likelihood function is a function of two numerical procedures and I'm having some problems figuring out how to do this. The log-likelihood function is of the form L(c,psi) = 1/T sum [log (f(c, psi)) - log(g(c,psi))], where c is a 2xT matrix of data and psi is the parameter vector. f(c, psi) is the transition density which can be
2001 Aug 01
1
glm() with non-integer responses
A question about the inner workings of glm() and dpois(): Suppose I call glm(y ~ x, family=poisson, weights = w) where y contains NON-INTEGER (but still nonnegative) values. (a) Does glm() still correctly maximise the weighted Poisson loglikelihood ? (i.e. the function given by the same formal expression as the weighted loglikelihood of independent Poisson variables Y_i except that the
2003 May 25
2
assign() won't work
Hey everyone, I've been searching the mail lists, and I can't find a real discussion about my problem. Here it is: I have created a loop fitting various time series models to my data. I labeled each one of the outputs by using the assign and paste statements, i.e. assign(paste("group","subgroup",i),arima(...)). Works great, but here's what I need... I want to
2010 Jul 08
2
Using nlm or optim
Hello, I am trying to use nlm to estimate the parameters that minimize the following function: Predict<-function(M,c,z){ + v = c*M^z + return(v) + } M is a variable and c and z are parameters to be estimated. I then write the negative loglikelihood function assuming normal errors: nll<-function(M,V,c,z,s){ n<-length(Mean) logl<- -.5*n*log(2*pi) -.5*n*log(s) -
2007 Mar 15
1
expm() within the Matrix package
Hi Could anybody give me a bit of advice on some code I'm having trouble with? I've been trying to calculate the loglikelihood of a function iterated over a data of time values and I seem to be experiencing difficulty when I use the function expm(). Here's an example of what I am trying to do y<-c(5,10) #vector of 2 survival times p<-Matrix(c(1,0),1,2) #1x2 matrix
2011 Nov 16
0
Maximum likelihood for censored geometric distribution
Hi all, I need to check for a difference between treatment groups in the parameter of the geometric distribution, but with a cut-off (i.e. right censored). In my experiment I stimulated animals to see whether I got a response, and stopped stimulating if the animal responded OR if I had stimulated 10 times. Since the response could only be to a stimulation, the distribution of response times