Displaying 20 results from an estimated 7000 matches similar to: "question on optim() fn."
2012 May 08
1
optim question
Hello,
I used optim to find the MLE estimates of some parameters. See the code
below. It works for data1(x). but It did not work for data2 and the error
says" L-BFGS-B needs finite values of 'fn' ".
data2: c(x, 32) that is, if I added the number 32 at the end of data1.
The error appears "non-finite function value" etc.
Any comments or suggestions?
Thanks!
2011 Sep 02
5
Hessian Matrix Issue
Dear All,
I am running a simulation to obtain coverage probability of Wald type
confidence intervals for my parameter d in a function of two parameters
(mu,d).
I am optimizing it using "optim" method "L-BFGS-B" to obtain MLE. As, I
want to invert the Hessian matrix to get Standard errors of the two
parameter estimates. However, my Hessian matrix at times becomes
2009 Jul 01
2
Difficulty in calculating MLE through NLM
Hi R-friends,
Attached is the SAS XPORT file that I have imported into R using following code
library(foreign)
mydata<-read.xport("C:\\ctf.xpt")
print(mydata)
I am trying to maximize logL in order to find Maximum Likelihood Estimate (MLE) of 5 parameters (alpha1, beta1, alpha2, beta2, p) using NLM function in R as follows.
# Defining Log likelihood - In the function it is noted as
2012 Jan 12
2
Function accepted by optim but not mle2 (?)
Dear Sir/ Madam,
I'm having trouble de-bugging the following - which works perfectly
well with optim or optimx - but not with mle2.
I'd be really grateful if someone could show me what is wrong. Many
thanks in advance. JSC:
gompertz<- function (x,t=data)
{
a3<-x[1]
b3<-x[2]
shift<-data[1]
h.t<-a3*exp(b3*(t-shift))
2011 Jun 14
1
Using MLE Method to Estimate Regression Coefficients
Good Afternoon,
I am relatively new to R and have been trying to figure out how to estimate regression coefficients using the MLE method. Some background: I am trying to examine scenarios in which certain estimators might be preferred to others, starting with MLE. I understand that MLE will (should) produce the same results as Ordinary Least Squares if the assumption of normality holds. That
2009 Oct 30
3
Fast optimizer
Hi,
I'm using optim with box constraints to MLE on about 100 data points.
It goes quite slow even on 4GB machine. I'm wondering if R has any
faster implementation? Also, if I'd like to impose
equality/nonequality constraints on parameters, which package I should
use? Any help would be appreciated. Thank you.
rc
2011 Oct 21
2
How to use gev.fit (package ismev) under box constraints?
[This email is either empty or too large to be displayed at this time]
2008 Jun 24
2
L-BFGS-B needs finite values of 'fn'
Hi,
When I run the following code,
r <- c(3,4,4,3,5,4,5,9,8,11,12,13)
n <- rep(15,12)
x <- c(0, 1.1, 1.3, 2.0, 2.2, 2.8, 3.7, 3.9, 4.4, 4.8, 5.9, 6.8)
x <- log10(x)
fr <- function(c, alpha, beta) {
P <- c + (1-c) * pnorm(alpha + beta * x)
P <- pmax(pmin(P,1),0)
-(sum(log(choose(n,r))) + sum(r * log(P)) + sum((n -r)* log(1-P)))
}
fit <- mle((fr), start = list(c
2010 Sep 07
5
question on "optim"
Hey, R users
I do not know how to describe my question. I am a new user for R and write the
following?code for a dynamic labor economics?model and use OPTIM to get
optimizations and parameter values. the following code does not work due to
the?equation:
?? wden[,i]<-dnorm((1-regw[,i])/w[5])/w[5]
where w[5]?is one of the parameters (together with vector a, b and other
elements in vector
2011 Sep 27
2
Error in optim function.
I'm trying to calculate the maximum likelihood estimate for a binomial
distribution. Here is my code:
y <- c(2, 4, 2, 4, 5, 3)
n <- length(y)
binomial.ll <- function (pi, y, n) { ## define log-likelihood
output <- y*log(pi)+(n-y)*(log(1-pi))
return(output)
}
binomial.mle <- optim(0.01, ## starting value
binomial.ll,
2007 Oct 24
1
vectorized mle / optim
Hi the list,
I would need some advice on something that looks like a FAQ: the
possibility of providing vectors to optim() function.
Here is a stupid and short example summarizing the problem:
-------------------------------- example 1 ------------ 8<
----------------------
library(stats4)
data <- rnorm(100,0,1)
lik1 <- function(m, v, data) {
N <- length(data)
lik.mean <-
2016 Oct 08
4
optim(…, method=‘L-BFGS-B’) stops with an error message while violating the lower bound
Hello:
The development version of Ecdat on R-Forge contains a vignette
in which optim(?, method=?L-BFGS-B?) stops with an error message while
violating the lower bound.
To see all the details, try the following:
install.packages("Ecdat", repos="http://R-Forge.R-project.org")
Then do "help(pac=Ecdat)" -> "User guides, package
2010 Oct 01
3
maximum likelihood problem
I am trying to figure out how to run maximum likelihood in R. Here is my
situation:
I have the following equation:
equation<-(1/LR-(exp(-k*T)*LM)*(1-exp(-k)))
LR, T, and LM are vectors of data. I want to R to change the value of k
to maximize the value of equation.
My attempts at optim and optimize have been unsuccessful. Are these the
recommended functions that I should use to maximize
2016 Oct 08
4
optim(…, method=‘L-BFGS-B’) stops with an error message while violating the lower bound
Hi, Mark et al.:
Thanks, Mark.
Three comments:
1. Rvmmin was one of the methods I tried after Ravi
directed me to optimx. It returned NAs for essentially everything. See
my email of this subject stamped 4:43 PM Central time = 21:43 UTC.
2. It would be interesting to know if the current
algorithm behind optim and optimx with
2009 Oct 07
1
2 questions about mle() /optim() function in stats4
Dear All,
There are two things about mle() that I wasn't so sure.
1) can mle() handle vector based parameter? say
ll<-function(theta=rep(1,20)){..............}
I tried such function, it worked for "optim" but not for "mle".
2) is there a general suggestion for the maximum number of parameters
allowed to use in mle() or optim()?
Thank you.
Regards,
MJO
2016 Oct 09
1
optim(?, method=?L-BFGS-B?) stops with an error
I'll not copy all the previous material on this thread to avoid overload.
The summary is that all the methods Spencer has tried have some issues.
The bad news: This is not uncommon with optimization methods, in part because the problems are "hard",
in part because getting them implemented and linked to an interfacing approach like R is very tedious
and prone to omissions and
2012 Oct 11
2
model selection with spg and AIC (or, convert list to fitted model object)
Dear R Help,
I have two nested negative log-likelihood functions that I am optimizing
with the spg function [BB package]. I would like to perform model
selection on these two objective functions using AIC (and possibly
anova() too). However, the spg() function returns a list and I need a
fitted model object for AIC(), ICtab() [bbmle package], or anova().
How can I perform AIC-based model
2013 Oct 09
1
Version of L-BFGS-B used in optim etc
Hi.
I just noticed the paper by Morales and Nocedal
Remark on "Algorithm 778: L-BFGS-B: Fortran Subroutines for Large-Scale
Bound Constrained Optimization". TOMS 2011; 38(1): 7
http://www.ece.northwestern.edu/~morales/PSfiles/acm-remark.pdf
which describes a couple of improvements (speed and accuracy) to the
original Netlib code which AFAICT is that still used by optim()
via f2c.
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) -
2011 Aug 29
3
gradient function in OPTIMX
Dear R users
When I use OPTIM with BFGS, I've got a significant result without an error
message. However, when I use OPTIMX with BFGS( or spg), I've got the
following an error message.
----------------------------------------------------------------------------------------------------
> optimx(par=theta0, fn=obj.fy, gr=gr.fy, method="BFGS",
>