similar to: Named parameters in optim()

Displaying 20 results from an estimated 20000 matches similar to: "Named parameters in optim()"

2009 Sep 08
1
optim() argument scoping: passing parameter values into user's subfunction
Dear useRs, I have a complicated function to be optimized with optim(), and whose parameters are passed to another function within its evaluation. This function allows for the parameters to enter as arguments to various probability distribution functions. However, I am violating some scoping convention, as somewhere within the hierarchy of calls a variable is not visible. I will give a
2006 Aug 08
1
Fitting data with optim or nls--different time scales
Hi, I have a system of ODE's I can solve with lsoda. Model=function(t,x,parms) { #parameter definitions lambda=parms[1]; beta=parms[2]; d = parms[3]; delta = parms[4]; p=parms[5]; c=parms[6] xdot[1] = lambda - (d*x[1])- (beta*x[3]*x[1]) xdot[2] = (beta*x[3]*x[1]) - (delta*x[2]) xdot[3] = (p*x[2]) - (c*x[3]) return(list(xdot)) } I want
2006 Apr 20
2
nlminb( ) : one compartment open PK model
All, I have been able to successfully use the optim( ) function with "L-BFGS-B" to find reasonable parameters for a one-compartment open pharmacokinetic model. My loss function in this case was squared error, and I made no assumptions about the distribution of the plasma values. The model appeared to fit pretty well. Out of curiosity, I decided to try to use nlminb( ) applied to a
2008 Oct 29
2
how to restrict a parameter in optim()
Dear all, I'm trying to estimate some parameters with the optim() function but I need to restrict one parameter and I have not found how to do it. Could you help me please? my program is basically fn<-function(s) initial<-function(r) { cst<-r[1] cst1<-r[2] beta<-r[3] rho<-r[4] p1<-r[5] return(-sum()) } parms<-c() m0<-optim() I need to specify
2005 Jun 29
2
MLE with optim
Hello, I tried to fit a lognormal distribution by using optim. But sadly the output seems to be incorrect. Who can tell me where the "bug" is? test = rlnorm(100,5,3) logL = function(parm, x,...) -sum(log(dlnorm(x,parm,...))) start = list(meanlog=5, sdlog=3) optim(start,logL,x=test)$par Carsten. [[alternative HTML version deleted]]
2005 Jul 19
2
Michaelis-menten equation
Dear R users: I encountered difficulties in michaelis-menten equation. I found that when I use right model definiens, I got wrong Km vlaue, and I got right Km value when i use wrong model definiens. The value of Vd and Vmax are correct in these two models. #-----right model definiens-------- PKindex<-data.frame(time=c(0,1,2,4,6,8,10,12,16,20,24),
2007 Sep 12
3
Passing parameters to 'optim' fn function
Hi again! I'm using the 'optim' method to fix the parameters of a model. I have written the function to be minimised and another function which returns the gradient of the error. Now my problem is that, in order to compute that gradient, it would be extremely convenient to be able to pass some parameters to the gradient function. I don't see how to do it given the fixed syntax
2012 Jul 18
1
Defining a variable outside of optim or differential equation solver.
This is applicable to either using optim or the differential equation solver or any similar solver Suppose I want to use the differential equation solver and this is my code d<-y[2] vdpol<-function(t,y) { list(c(1, d, 3, 4 ) } stiff<-ode(y=rep(0,4),times=c(0,1),func=dvdpol,parms=1) The thing is I want d to be composed of one of state variables in the
2010 Sep 09
5
Help on simple problem with optim
Dear all, I ran into problems with the function "optim" when I tried to do an mle estimation of a simple lognormal regression. Some warning message poped up saying NANs have been produced in the optimization process. But I could not figure out which part of my code has caused this. I wonder if anybody would help. The code is in the following and the data is in the attachment. da <-
2005 Dec 04
1
Understanding nonlinear optimization and Rosenbrock's banana valley function?
GENERAL REFERENCE ON NONLINEAR OPTIMIZATION? What are your favorite references on nonlinear optimization? I like Bates and Watts (1988) Nonlinear Regression Analysis and Its Applications (Wiley), especially for its key insights regarding parameter effects vs. intrinsic curvature. Before I spent time and money on several of the refences cited on the help pages for "optim",
2011 Apr 28
1
DLSODA error
Dear R-users, I'm running an MLE procedure where some ODEs are solved for each iteration in the maximization process. I use mle2 for the Maximum likelihood and deSolve for the ODEs. The problem is that somewhere along the way the ODE solver crashes and I get the following error message: DLSODA- Warning..Internal T (=R1) and H (=R2) are such that in the machine, T + H = T on the next
2012 May 01
0
Optim (fct): Parameters=LowerBounds
There's no reason that the optimum cannot be at the bounds. Bounded problems really do sometimes have solutions on those bounds. Compute the unconstrained gradient of your objective function at the bounds and see if the function is reduced when going across the bounds. The function here is assumed to be the neg. LL that one is MINIMIZING. There are many aspects of R, optimization in
2012 Nov 28
1
generating sets of parameters, when some parameters are vectors
Hello, I'm trying to generate N lists of randomly selected parameter values. Some of the parameters are vectors while other are single values. I've tried to use the approach below but it doesn't work for parameter x, which should be a vector. Thanks in advance! James #Define names of parameters in the list, parms<- list( x=c(0,0), y=0) #Create N sets of randomly selected
2011 Sep 22
1
Error in as.vector(data) optim() / fkf()
Dear R users, When running the program below I receive the following error message: fit <- optim(parm, objective, yt = tyield, hessian = TRUE) Error in as.vector(data) : no method for coercing this S4 class to a vector I can't figure out what the problem is exactly. I imagine that it has something to do with "tyield" being a matrix. Any help on explaining what's going on
2007 Jan 03
1
optim
Hi! I'm trying to figure out how to use optim... I get some really strange results, so I guess I got something wrong. I defined the following function which should be minimized: errorFunction <- function(localShifts,globalShift,fileName,experimentalPI,lambda) { lambda <- 1/sqrt(147) # error <- abs(errHuber(localShifts,globalShift, #
2001 Aug 28
2
fitting a mixture of distributions with optim and max log likelihood ?
hi Suppose I have a mixture of 2 distributions generated by rtwonormals <- function(npnt,m1,s1,m2,s2,p2){ rv<-vector(npnt,mode="numeric") for( i in seq(1:npnt)){ if(runif(1,0,1)<=p2){ rv[i]<-rnorm(1,m2,s2) } else{ rv[i]<-rnorm(1,m1,s1) } } return(rv) } x <- rtwonormals(50000,0,100,500,500,0.05) #and I try to fit these with (based on thread: [R]
2009 Nov 29
1
optim or nlminb for minimization, which to believe?
I have constructed the function mml2 (below) based on the likelihood function described in the minimal latex I have pasted below for anyone who wants to look at it. This function finds parameter estimates for a basic Rasch (IRT) model. Using the function without the gradient, using either nlminb or optim returns the correct parameter estimates and, in the case of optim, the correct standard
2019 May 02
2
R optim(method="L-BFGS-B"): unexpected behavior when working with parent environments
Dear all, when using optim() for a function that uses the parent environment, I see the following unexpected behavior: makeFn <- function(){ ??? xx <- ret <- NA ??? fn <- function(x){ ?????? if(!is.na(xx) && x==xx){ ?????????? cat("x=", xx, ", ret=", ret, " (memory)", fill=TRUE, sep="") ?????????? return(ret) ?????? } ?????? xx
2006 Aug 26
1
problems with loop
Dear all, I am trying to evaluate the optimisation behaviour of a function. Originally I have optimised a model with real data and got a set of parameters. Now I am creating simulated data sets based on these estimates. With these simulations I am estimating the parameters again to see how variable the estimation is. To this end I have written a loop which should generate a new simulated data
2019 May 03
2
R optim(method="L-BFGS-B"): unexpected behavior when working with parent environments
On 03/05/2019 10:31, Serguei Sokol wrote: > On 02/05/2019 21:35, Florian Gerber wrote: >> Dear all, >> >> when using optim() for a function that uses the parent environment, I >> see the following unexpected behavior: >> >> makeFn <- function(){ >> ???? xx <- ret <- NA >> ???? fn <- function(x){ >> ??????? if(!is.na(xx)