search for: minuslogl

Displaying 20 results from an estimated 42 matches for "minuslogl".

2006 Jun 23
1
How to use mle or similar with integrate?
Hi I have the following formula (I hope it is clear - if no, I can try to do better the next time) h(x, a, b) = integral(0 to pi/2) ( ( integral(D/sin(alpha) to Inf) ( ( f(x, a, b) ) dx ) dalpha ) and I want to do an mle with it. I know how to use mle() and I also know about integrate(). My problem is to give the parameter values a and b to the
2007 Feb 14
0
environment confusion
...39;s sufficiently interested I can post the package somewhere -- with the package installed, it's only a few steps to reproduce the example. I end up, deep in the process of trying to compute a likelihood profile, with the following situation: I want to evaluate "call": call mle2(minuslogl = function (lmu = NULL, ltheta = NULL) { if (!is.null(parameters)) { pars <- unlist(as.list(match.call())[-1]) for (i in seq(along = parameters)) { assign(vars[i], mmats[[i]] %*% pars[vpos[[i]]]) } } arglist1 <- lapply(arglist1, eval, envir = da...
2005 Jan 10
1
mle() and with()
...sing mle() from the stats4 package. Here's what I would have thought would work: -------------- library(stats4) ## simulate values r = rnorm(1000,mean=2) ## very basic neg. log likelihood function mll <- function(mu,logsigma) { -sum(dnorm(r,mean=mu,sd=exp(logsigma),log=TRUE)) } mle(minuslogl=mll,start=list(mu=1,logsigma=0)) r2 = rnorm(1000,mean=3) ## second "data set" with(list(r=r2), mle(minuslogl=mll,start=list(mu=1,logsigma=0)) ) ------------- but this doesn't work -- it fits to the original data set, not the new one --- presumably because mll() picks up i...
2011 Aug 05
0
[Bug 14647] profile.mle can not get correct result
Thank you very much. now, i call mle(minuslogl=loglik, start=start, method <<- method, fixed=list()) in the mle.wrap() function, and the profile.mle() worked. however, it created a variable named "method" in user workspace. if there had been a variable with same name, then the value of that variable would be destroyed. Is th...
2007 Feb 08
0
strategies for incorporating a data= argument
...in lm, nls, nlme, etc., that would allow the log-likelihood function to be evaluated with different sets of data. (Peter's advice was to use closures, writing a function-to-generate-likelihood-functions such as fn0 <- function(x) { function(mu,sd) { -sum(dnorm(x,mu,sd,log=TRUE) } } mle(minuslogl=fn0(x),...) My feeling is that this will be somewhat mysterious to the intermediate R users who are my target audience.) I have three thoughts on how to allow different data sets to be substituted in the same objective function, and I'm not sure which is best. 1. passed in ... as in opt...
2005 Jul 21
1
About object of class mle returned by user defined functions
...optim.method = "BFGS", ## optim method optim.lower = numeric(length(initial.para)) + 0.00001, optim.upper = numeric(length(initial.para)) + Inf, ...) { require(stats4) ## Create a string with the log likelihood definition minusLogLikelihood.txt <- paste("function( ", paste(names(initial.para), collapse = ", "), " ) {", "isi <- eval(", deparse(sub...
2008 Sep 04
1
pass data to log-likelihood function
Hi there, When I do bootstrap on a maximum likelihood estimation, I try the following code, however, I get error: Error in minuslogl(alpha = 0, beta = 0) : object "x" not found It seems that mle() only get data from workspace, other than the boot.fun(). My question is how to pass the data to mle() in my case. I really appreciated to any suggestions. Best wishes, Jinsong #-----------code start here--------------- x...
2008 Jul 26
4
parametric bootstrap
Hi I am trying to find a parametric bootstrap confidence interval and when I used the boot function I get zero bias and zero st.error? What could be my mistake? Thank you and take care. Laila [[alternative HTML version deleted]]
2006 Jan 19
1
nls profiling with algorithm="port" may violate bounds (PR#8508)
...fint(m1)) ---------------- for what it's worth, the logic appears to be OK in mle in the stats4 library: -------------- library(stats4) mfun <- function(a,b,s) { if (a<0 || b<0 || s<0) stop("bounds violated") -sum(dnorm(y,a*x/(1+a*b*x),sd=s,log=TRUE)) } m2 = mle(minuslogl=mfun, start=list(a=1,b=1,s=0.1), method="L-BFGS-B",lower=c(0.002,0.002,0.002)) confint(m2) m2b = mle(minuslogl=mfun, fixed=list(b=0),start=list(a=1,s=0.1), method="L-BFGS-B",lower=c(0.002,0.002,0.002)) ## set boundary slightly above zero to avoid ## boundary ca...
2009 Jan 18
1
about power.law.fit
Dear all, I'm using igraph for some analysis about the network I have. I have a question about the function "power.law.fit". I wonder if there is any test for checking whether the "power.law.fit" is good for the input, i.e., under which situation, could we use this function to get a reliable result. I'm afraid even I input a random graph without any property of
2007 Apr 09
1
R:Maximum likelihood estimation using BHHH and BFGS
...cEcon}*. I have documented some of my attempts below ((a) package name (b) usage (c) my attempt and corresponding error). In all humility I apologise for any bad coding, and ask if anyone can *direct me in finding these estimators*. Yours sincerely. *(1a) mle{stats4} (b) Usage: mle(minuslogl, start = formals(minuslogl), method = "BFGS", fixed = list(), ...) (For this I use the negative of the log-likelihood function,bn)* *(c) >mle(start=list(psi=1,alpha=0),fn, method="BFGS",fixed=list(c=c))* Error in optim(start, f, method = method, hessian = TRUE, ...)...
2004 Jun 10
1
overhaul of mle
...nable expectation since it *is* specified as a list). The fundamental problem is that optim() loses names of the parameter vector somewhere. Example: x = runif(200) y = 1+x+x^2+rnorm(200,sd=0.05) fn <- function(a,b,z=2,c,d) { -sum(dnorm(y,mean=a+c*x+d*x^2,sd=exp(b),log=TRUE)) } m1 = mle(minuslogl=fn,start=list(a=1,b=1,c=1,d=1)) ## fails with "missing argument" warning, about wrong argument m1 = mle(minuslogl=fn,start=list(a=1,b=1,c=1,d=1),fixed=list(z=2)) ## works m2 = mle(minuslogl=fn,start=list(a=1,d=1,c=1,b=1),fixed=list(z=2)) ## fails -- coeffs returned in wrong order TO DO:...
2005 Sep 06
2
(no subject)
...;-function(alfa,beta) + {n<-24 + x<-data2 + -n*log(alfa)-n*log(beta)+alfa*sum(x^beta)-(beta-1)*sum(log(x))} > est<-mle(minuslog=ll, start=list(alfa=10, beta=1)) There were 50 or more warnings (use warnings() to see the first 50) > summary(est) Maximum likelihood estimation Call: mle(minuslogl = ll, start = list(alfa = 10, beta = 1)) Coefficients: Estimate Std. Error alfa 0.002530163 0.0006828505 beta 0.641873010 0.0333072184 -2 log L: 511.6957 > library(stats4) > ll<-function(alfa,beta) + {n<-24 + x<-data2 + -n*log(alfa)-n*log(beta)+alfa*sum(x^beta)-(beta-1)*...
2018 May 28
2
to R Core T: mle function in 32bits not respecting the constrain
...he CRAN. When doing the check, there is an example that has an error running in the 32 bits version. The problem comes from the mle function, using it with a lower constrain. In 64 bits version it works fine but when I put it in the R 32 bits it fails. (same numbers, all equal!) The call is: *mle(minuslogl = p.est,start = beta,method = "L-BFGS-B",lower=llim*reduction)* lower = -0.01570427 The optimizer (optim function in 32 bits) display: -0.015704 -loglik 48.690236 -0.015704 -loglik 48.690236 -0.017704 -loglik 1.#QNAN0 And it is not respecting the lower constrain. Could anyone explain...
2009 Aug 31
2
interactions and stall or memory shortage
...hat worked for a single pair of interactions, when I try to evaluate two pairs of interactions( flowers*gopher, flowers*rockiness) my computer runs out of memory, and the larger desktop I use just doesn't go anywhere after about 20 minutes. Is it really that big a calculation? to start: mle2(minuslogl = Lily_sum$seedlings ~ dnbinom(mu = a, size = k), start = list(a = 10, k = 1)) then: i2<-interaction(Lily_sum$flowers, Lily_sum$gopher) i3<-interaction(Lily_sum$flowers, Lily_sum$rockiness) mle2(Lily_sum$seedlings ~ dnbinom(mu = a, size = k), start=list(a=10,k=1) ,parameters=list(a~i3+i2+L...
2006 Jun 06
2
How to create list of objects?
...f <- list() f$IP <- mle(...) f$NE <- mle(...) but when I say: > summary(f) I get: Length Class Mode IP 0 mle list NE 0 mle list I don't get the output I would have, i.e. the one from > summary(f$IP) summary(f$IP) Maximum likelihood estimation Call: mle(minuslogl = IPNeglogPoisL, method = "L-BFGS-B", fixed = list(), control = list(maxit = 1e+08, factr = 1e-20)) Coefficients: Estimate Std. Error a 1242.0185506 44.92341097 b 0.8802538 0.01685811 -2 log L: 145.3509 What I want to do is something like: AICs <- AIC(logLik(f)) an...
2012 Jul 05
3
Maximum Likelihood Estimation Poisson distribution mle {stats4}
...LE: > 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 = nLL, start = list(lambda = 5), nobs = NROW(y)) Coefficients: lambda 11.545 * #this is their estimated Lambda Vallue.* *Now my question is in a Poisson distribution the Maximum Likelihood estimator of the mean parameter lambda is the sample mean, so if we calculate the sample mean of tha...
2004 Jul 14
1
Running the optimization on the subset of parameters
Dear all, I'd like to find a minimum of (-loglik) function which is a function of k parameters. I'd like to run the minimization algorithm for the different subsets of the parameters and assign the fixed values to the complementary subset. How should I define my (-loglik) function such that it can be passed to the optim or other optimization function? Much thanks for any suggestions.
2005 Sep 12
1
fit data with gammadistribution
...if i try using the method mle() i get stock and i don't know, how to make it work. can anybody help me? thank you very much, indeed. Nadja I tried so fare ll<-function(lambda,alfa) {n<-24 x<-data2 -n*alfa*log(lambda)+n*log(gamma(alfa))-(alfa-1)*sum(log(x))+lambda*sum(x) est<-mle(minuslogl=ll,start=list(lambda=29827.51,alfa=0.4954725)) summary(est) NaN's are produced with optim, i just don't know how to avoid this!
2009 Feb 01
2
Extracting Coefficients and Such from mle2 Output
...mmary of "a"? > x <- 0:10 > y <- c(26, 17, 13, 12, 20, 5, 9, 8, 5, 4, 8) > LL <- function(ymax=15, xhalf=6) + -sum(stats::dpois(y, lambda=ymax/(1+x/xhalf), log=TRUE)) > a <- mle2(LL, fixed=list(xhalf=6)) > summary(a) Maximum likelihood estimation Call: mle2(minuslogl = LL, fixed = list(xhalf = 6)) Coefficients: Estimate Std. Error z value Pr(z) ymax 19.2881 1.7115 11.269 < 2.2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 -2 log L: 60.39244 Tom -- View this messa...