similar to: optim bug/help?

Displaying 20 results from an estimated 1000 matches similar to: "optim bug/help?"

2023 Aug 03
3
feature request: optim() iteration of functions that return multiple values
Dear all, I have used optim a lot in contexts where it would useful to be able to iterate function myfun that, in addition to the primary objective to be minimized ('minimize.me'), could return other values such as alternative metrics of the minimization, informative intermediate values from the calculations, etc. myfun <- function() { ... return(list(minimize.me = minimize.me, R2 =
2003 Oct 29
1
constrOptim doesn´t send arguments to optim!(?)
Hi, I think that there something wrong with the 'constrOptim' max/minimization function because she doesn?t send extra arguments to 'optim' call. Fact: When I use optim in a f(x,theta)-like function, everything goes ok. But using constrOptim with the same function leads to error... Proof: Make a small change in the 'Rosenbrock Banana function' (taken from the Examples
2011 Jun 24
4
How to capture console output in a numeric format
Hi, I would like to know how to capture the console output from running an algorithm for further analysis. I can capture this using capture.output() but that yields a character vector. I would like to extract the actual numeric values. Here is an example of what I am trying to do. fr <- function(x) { ## Rosenbrock Banana function on.exit(print(f)) x1 <- x[1] x2 <- x[2]
2023 Aug 05
1
feature request: optim() iteration of functions that return multiple values
For a solution that does not require any change to the original function being optimized, the following one-liner could be used, which converts existing functions to functions that return only the first element: returnFirst <- function(fun) function(...) do.call(fun,list(...))[[1]] Example: fr <- function(x) { ## Rosenbrock Banana function x1 <- x[1] x2 <- x[2] ans
2004 Jul 14
2
constrOptim and function with additional parameters?
How can I use a function with some additional input parameters in constrOptim? For example, something like fr <- function(x,a) { ## Rosenbrock Banana function x1 <- x[1] x2 <- x[2] a * (x2 - x1 * x1)^2 + (1 - x1)^2 } where the optimum is to be found w.r.t. x. Calling optim(c(-1.2,1), fr, NULL, a=100) works as expected, but I fail to provide the a=100 in the constrained case:
2000 Mar 17
1
optim: problem with additional arguments (PR#493)
The R function "optim" fails when a function requires additional arguments, if the option "hessian=T" is specified. I am using R Version 1.0.0 on Windows 98. Here is an example of the Rosenbrock Banana function from the optim help example, with the function and gradient modified to take an additonal argument. Note that the call to optim works fine unless a hessian is
2009 Oct 20
1
Buglet in optim() SANN
I think SANN method in optim() is failing to report that it has not converged. Here is an example genrose.f<- function(x, gs=NULL){ # objective function ## One generalization of the Rosenbrock banana valley function (n parameters) n <- length(x) if(is.null(gs)) { gs=100.0 } fval<-1.0 + sum (gs*(x[1:(n-1)]^2 - x[2:n])^2 + (x[2:n] - 1)^2) return(fval) }
2012 Nov 05
1
relative convergence in 'optim'
Dear list, I have a question related to the correct interpretation of the relative convergence criterion used by 'optim'. In the help of the function is it written that: "reltol:Relative convergence tolerance. The algorithm stops if it is unable to reduce the value by a factor of reltol * (abs(val) + reltol) at a step." and I was wondering if the previous criterion is
2009 Nov 18
1
bug in '...' of constrOptim (PR#14071)
Dear all, There appears to be a bug in how constrOptim handles ... arguments that are suppose to be passed to optim, according to the documentation. This means you can't get the hessian to be returned, for example (so this is a real problem, and not just a question of mistaken documentation). Looking at the code, it appears that a call to the user-defined f includes the ..., when the ...
2011 Jan 12
1
extracting more information from optim in R?
Dear All, I am in the process of translating some of my functions into C and one such function sometimes get stuck when I applied optim. The pure R codes work fine but the translated C codes occasionally get stuck and I like to find out why. Is it possible to extract the parameters of function calculated in each step of the Nelder-Simplex algorithm, the trace option only produce the value of
2012 Feb 28
2
Valor Max Fun
Buenos días.Soy más bien nuevo en R, necesito saber ¿cómo encuentro el valor que maximiza una función? Existe alguna función de R que hace eso.Muchas gracias [[alternative HTML version deleted]]
2007 Apr 23
4
Estimates at each iteration of optim()?
I am trying to maximise a complicated loglikelihood function with the "optim" command. Is there some way to get to know the estiamtes at each iteration? When I put "control=list(trace=TRUE)" as an option in "optim", I just got the initial and final values of the loglikelihood, number of iterations and whether the routine has converged or not. I need to know the
2013 May 15
1
Problem with convergence in optim
Hello to all, I have been using an optim with the following call: optim(param_ini,fun_errores2,Precio_mercado=Precio,anos_pagosE2=anos_pagos,control=list(maxit=10000,reltol=1e-16)) depending on the intial values I'm getting the same solution but once I get the convergence message=10 (no convergence) and for the others I get convergence message = 0 Solution1: $par beta1
2012 Mar 29
1
how to increase speed for function?/time efficiency of below function
i am using sarima() function as below ___________________________________________________________________________________________ sarima=function(data,p,d,q,P=0,D=0,Q=0,S=-1,tol=.001){ n=length(data) constant=1:n xmean=matrix(1,n,1) if (d>0 & D>0) fitit=arima(data, order=c(p,d,q), seasonal=list(order=c(P,D,Q), period=S),
2009 Dec 18
1
Numerical Integration
Dear @ll. I have to calculate numerical integrals for triangular and trapezoidal figures. I know you can calculate the exactly, but I want to do it this way to learn how to proceed with more complicated shapes. The code I'm using is the following: integrand<-function(x) { print(x) if(x<fx[1]) return(0) if(x>=fx[1] && x<fx[2]) return((x-fx[1])/(fx[2]-fx[1]))
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",
2007 Oct 13
1
R API - optim
I am trying to use the R API to call optim functions (nmmin, vmmin, lbfgsb, etc.) through a C program but I couldn't find the shared library to link under the R-2.6.0 build which is compiled under Linux (REL5). main.cpp:35: undefined reference to `Rf_initEmbeddedR(int, char**)' main.cpp:41: undefined reference to `nmmin' Thanks in advance for any help. ------------------------
2009 Apr 22
3
Help using spg optimization in BB package
i'm trying to use the BB package to minimize the sum of the squared deviations for 2 vectors. The only thing am having trouble with is defining the project constraint. I got the upper and lower bounds to work but i am not sure how to create a constraint that the sum of x must be 1. Any help would be greatly appreciated. -- View this message in context:
2017 Mar 03
2
Bug in nlm()
Dear all, I have found a bug in nlm() and would like to submit a report on this. Since nlm() is in the stats-package, which is maintained by the R Core team, bug reports should be submitted to R's Bugzilla. However, I'm not a member of Bugzilla. Could anyone be so kind to add me to R's Bugzilla members or let me know to whom I should send the bug report? Thank you in advance. Kind
2009 Nov 02
2
a prolem with constrOptim
Hi, I apologize for the long message but the problem I encountered can't be stated in a few lines. I am having some problems with the function constrOptim. My goal is to maximize the likelihood of product of K multinomials, each with four catagories under linear constraints on the parameter values. I have found that the function does not work for many data configurations. #The likelihood