search for: nll

Displaying 18 results from an estimated 18 matches for "nll".

Did you mean: all
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) - (1/(2*s))*sum((V-Predict(Mean,c,z))^2) return(-logl) } When I put the Mean and Variance (variables with 136 observations) into this function, and estimates for c,z, and s, it outputs the estimate for the normal ne...
2007 Jan 10
2
problems with optim, "for"-loops and machine precision
Dear R experts, I have been encountering problems with the "optim" routine using "for" loops. I am determining the optimal parameters of several nested models by minimizing the negative Log-Likelihood (NLL) of a dataset. The aim is to find the model which best describes the data. To this end, I am simulating artificial data sets based on the model with the least number of parameters (6) and the parameters determined with the field data. For each artificial set I estimate the parameters of the mo...
2006 Aug 26
1
problems with loop
...ta set each time. However, the optimisation algorithm, which works fine if only one data set is used, does not recognise the simulated data in the loop. Can anyone tell me where the error is? The code is below. Thanks for your help Simon # The loop in which nothing works anymore. The NLL in the optim function appears not to recognise the "new" data set. The functions used by this loop are given below. sim.estim=function(r) { res=matrix(nrow=r,ncol=5) for (s in 1:r) { new=new.set() Min=optim(c(0.5,0.5,0.01,0.1),NLL,method="L-B...
2006 Aug 09
1
scaling constant in optim("L-BFGS-B")
Hi all, I am trying to find estimates for 7 parameters of a model which should fit real data. I have a function for the negative log likelihood (NLL) of the data. With optim(method="L-BFGS-B",lower=0) I am now minimizing the NLL to find the best fitting parameters. My problem is that the algorithm does not converge for certain data sets. I have read that one should scale the fn (i.e. the NLL in my case), however I am having troub...
2012 Jul 05
3
Maximum Likelihood Estimation Poisson distribution mle {stats4}
...nual/R-devel/library/stats4/html/mle.html *In the example provided with the help * > od <- options(digits = 5) > x <- 0:10 *#generating Poisson counts* > y <- c(26, 17, 13, 12, 20, 5, 9, 8, 5, 4, 8) *#generating the > frequesncies* > ## Easy one-dimensional MLE: > nLL <- function(lambda) -sum(stats::dpois(y, lambda, log=TRUE)) *#they > define the Poisson negative loglikelihood* > fit0 <- mle(nLL, start = list(lambda = 5), nobs = NROW(y)) * #they > estimate the Poisson parameter using mle* > fit0 *#they call the output* Call: mle(minuslogl =...
2008 May 23
1
maximizing the gamma likelihood
...<- fixed function(p) { op[!fixed] <- p shape <- exp(op[1]) scale <- exp(op[2]) a <- length(data)*shape*log(scale) b <- (shape-1)*sum(log(data)) c <- -1.0*scale*sum(data) -(a + b + c) } } vsamples<- c(14.7, 18.8, 14, 15.9, 9.7, 12.8) nLL <- make.negloglik(vsamples) temp <- optim(c(scale=1,shape=1), nLL, method="BFGS")[["par"]] estimates <- log(temp) print(estimates) check <- estimates[1]/mean(vsamples) print(check)
2003 Dec 11
0
Re: [R] chisq.test freezing on certain inputs (PR#5701)
...if (x >= dummy) { goto L160; } sumprb = x; y = x; y is never checked for zero and later on L150: if (lsm) { goto L155; } /* Decrement entry in row L, column M */ j = nll * (ii + nll); if (j == 0) { goto L154; } --nll; y = y * j / (double) ((id - nll) * (ia - nll)); sumprb += y; if (sumprb >= dummy) { goto L159; } if (! lsp) {...
2003 Dec 11
2
chisq.test freezing on certain inputs
Hello everybody, I'm running R 1.8.1 on both Linux and OS X compiled with gcc 3.2.2 and 3.3, respectively. The following call seems to freeze the interpreter on both systems: > chisq.test(matrix(c(233, 580104, 3776, 5786104), 2, 2), simulate.p.value=TRUE) By freeze, I mean, the function call never returns (running > 10 hours so far), the process is unresponsive to SIGINT (but I
2011 Oct 17
1
simultaneously maximizing two independent log likelihood functions using mle2
...edation example from Ben Bolker's book, Ecological Data and Models in R (p. 268-270). library(emdbook) data(ReedfrogFuncresp) attach(ReedfrogFuncresp) # Holling Type II Equation holling2.pred = function(N0, a, h, P, T) { a * N0 * P * T/(1 + a * h * N0) } # Negative log likelihood function NLL.holling2 = function(a, h, P = 1, T = 1) { -sum(dbinom(Killed, prob = a * T * P/(1 + a * h * Initial), size = Initial, log = TRUE)) } # MLE statement FFR.holling2 = mle2(NLL.holling2, start = list(a = 0.012, h = 0.84), data = list(T = 14, P = 3)) I have my negative log likelihood function...
2012 Nov 25
5
bbmle "Warning: optimization did not converge"
I am using the Ben bolker's R package "bbmle" to estimate the parameters of a binomial mixture distribution via Maximum Likelihood Method. For some data sets, I got the following warning messages: *Warning: optimization did not converge (code 1: ) There were 50 or more warnings (use warnings() to see the first 50)* Also, warnings() results the following: *In 0:(n - x) : numerical
2019 Apr 24
1
Bug in "stats4" package - "confint" method
..., which retrieves their value from the global environment (whenever they still exist). Sample code: > ## Avoid printing to unwarranted accuracy > od <- options(digits = 5) > x <- 0:10 > y <- c(26, 17, 13, 12, 20, 5, 9, 8, 5, 4, 8) > > ## Easy one-dimensional MLE: > nLL <- function(lambda, y) -sum(stats::dpois(y, lambda, log = TRUE)) > fit0 <- mle(nLL, start = list(lambda = 5), fixed=list(y=y), nobs = NROW(y)) > confint(fit0) Profiling... 2.5 % 97.5 % 9.6524 13.6716 > rm(y) > confint(fit0) Profiling... Error in eval(expr, p) : object 'y...
2012 Oct 05
2
problem with convergence in mle2/optim function
...################### library(bbmle) library(combinat) # define multinomial distribution dmnom2 <- function(x,prob,log=FALSE) { r <- lgamma(sum(x) + 1) + sum(x * log(prob) - lgamma(x + 1)) if (log) r else exp(r) } # vector of time points tv <- 1:20 # Negative log likelihood function NLL.func <- function(p1, p2, mu1, mu2, y){ t <- y$tv n1 <- y$n1 n2 <- y$n2 n3 <- y$n3 P1 <- (p1*((-1 + exp(sqrt((mu1 + mu2 + p1 + p2)^2 - 4*(mu2*p1 + mu1*(mu2 + p2)))*t))*((-mu2)*(mu2 - p1 + p2) + mu1*(mu2 + 2*p2)) - mu2*sqrt((mu1 + mu2 + p1 + p2)^2 - 4*(...
2012 Sep 27
0
problems with mle2 convergence and with writing gradient function
...hastic simulation: library(bbmle) library(combinat) # define multinomial distribution dmnom2 <- function(x,prob,log=FALSE) { r <- lgamma(sum(x) + 1) + sum(x * log(prob) - lgamma(x + 1)) if (log) r else exp(r) } # vector of time points tv <- 1:20 # Negative log likelihood function NLL.func <- function(p1, p2, mu1, mu2, y){ t <- y$tv n1 <- y$n1 n2 <- y$n2 n3 <- y$n3 P1 <- (p1*((-1 + exp(sqrt((mu1 + mu2 + p1 + p2)^2 - 4*(mu2*p1 + mu1*(mu2 + p2)))*t))*((-mu2)*(mu2 - p1 + p2) + mu1*(mu2 + 2*p2)) - mu2*sqrt((mu1 + mu2 + p1 + p2)^2 - 4*(...
2009 May 20
1
Non-linear regression with latent variable
Hi Can anyone please suggest me a package where I can estimate a non-linear regression model? One of the independent variables is latent or unobserved. I have an indicator variable for this unobserved variable; however the relationship is known to be non-linear also. In terms of equations my problem is y=f(latent, fixed) q=g(latent) where q is the indicator variable For me both f and g are
2012 Jul 17
0
Maximum Likelihood estimation of KB distribution
...;-sum(log(dens)) return(-KBLL2) } * since there is an infinite convergent series in this PMF, I decided to specify a maximum value as imax instead of infinity without loss of any information, and n is the binomial trials. Please tell me whether the declared negative loglikelihood (NLL) is correct for this distribution? ***I couldn't get the result of this paper(http://aps.ecnu.edu.cn/EN/abstract/abstract8722.shtml) with my NLL Thanks in advance. -- View this message in context: http://r.789695.n4.nabble.com/Maximum-Likelihood-estimation-of-KB-distribution-tp4636782.htm...
2011 Aug 22
1
Using the ConText editor?
In my orgainzation, the people resonsible for the network are not that keen on setting up new software, so when I asked them to set up emacs or some other common R editor, I was told to have a look at ConText. This editor is avaliable in the network, and there is some R support. Special commands are highlighted and such, but the most important part, sending commands writtten in a ConText window
2007 Apr 04
1
Icecast2 Server Load tests
Hello: Ed Zaleski ran some remarkable and very impressive load tests on icecast reported on www.icecast.org (Home page). What wasn't mentioned in the test specifications was the type of internet line that was used which totally influences bandwidth and subesequent overall load characteristics. Questions: 1. Was it a T1 line, Verizon FIOS, or cable internet, or what? 2. What were the
2011 Jun 22
3
Documenting variables, dataframes and files?
Every now and then I realize that my attempts to document what all dataframes consist of are unsufficient. So far, I have been writing notes in an external file. Are there any better ways to do this within R? One possibility could be to set up the data as packages, but I would like to have a solution on a lower level, closer to data. I can't find any pointers in the standard manuals.