Displaying 20 results from an estimated 4000 matches similar to: "optim: problem with additional arguments (PR#493)"
2008 Oct 22
1
optim bug/help?
In the documentation for 'optim' it gives the following function:
fr <- function(x) { ## Rosenbrock Banana function
x1 <- x[1]
x2 <- x[2]
100 * (x2 - x1 * x1)^2 + (1 - x1)^2
}
optim(c(-1.2,1), fr)
When I run this code I get:
$par
[1] 1.000260 1.000506
I am sure I am missing something but why isn't 1,1 a better answer? If I plug 1,1 in the function it seems
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
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:
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
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]
2004 Jul 14
0
Re: [R] constrOptim and function with additional parameters? (PR#7089)
Okay, looking at the docs, then it's not a bug, since the "..."
argument is not actually documented as "other arguments passed to f or
grad". However, that *is* how it's document in `optim', so one can
see how this might cause some confusion.
Now, it's not clear to me which other arguments need to be passed to
`optim' except perhaps `hessian'. Am
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 ...
2004 Jul 14
0
Re: [R] constrOptim and function with additional parameters? (PR#7088)
I've moved this from r-help to r-bugs. If you reply, please be
careful that replies go to the right place: r-bugs if your comment is
specifically about the bug (and it contains the PR# in the subject
that will be added when this is cc'd to r-devel), r-devel if general
discussion, not both.
On Wed, 14 Jul 2004 10:01:45 -0400, "Roger D. Peng" <rpeng@jhsph.edu>
wrote :
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",
2010 Sep 17
0
question on OPTIMX with installing and using
Dear R users
I have tried to install the optimx but met problems.
I have gone to the website you suggested:
https://r-forge.r-project.org/R/?group_id=395
and tried to install it with the following method:
install.packages("optimx", repos="http://R-Forge.R-project.org")
I have received the following information:
package 'numDeriv' successfully unpacked and MD5
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 15
1
hessian fails for box-constrained problems when close to boundary?
Hi
I am trying to recover the hessian of a problem optimised with
box-constraints. The problem is that in some cases, my estimates are very
close to the boundary, which will make optim(..., hessian=TRUE) or
optimHessian() fail, as they do not follow the box-constraints, and hence
estimate the function in the unfeasible parameter space.
As a simple example (my problem is more complex though,
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 =
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 Apr 29
2
Optim and hessian
Hi, my name is Marcel R. Lopes. My problem is,
I made a code to calculate the estimates of a Cox model with random effects.
Used to optimize the R command for this. The estimates were calculated
correctly, but the Hessian matrix does not have good values. The same thing
was done in SAS and gave good results for the Hessian Matrix. Where is the
problem in R? As the Hessian is calculated?. How
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
2007 May 29
1
Help with optim
Dear Friends,
I'm using the optim command to maximize a likelihood function. My optim command is as follows
estim.out <- optim(beta, loglike, X=Xmain, Y=Y, hessian=T, method="BFGS", control=c(fnscale=-1, trace=1, REPORT=1))
Setting the report=1, gives me the likelihood function value (if i'm correct) at each step. The output from running this is as follows
initial value
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
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]]
2010 Nov 23
1
office 2003 setup: can't run msi
With wine 1-3-7 I have the following errors when running
wine msiexec /i stdp11.msi to install office 2003
err:msi:remove_tracked_tempfiles failed to delete L"C:\\users\\fra\\Temp\\msi28.tmp\\Microsoft.Office.Interop.Word.dll"
err:msi:remove_tracked_tempfiles failed to delete L"C:\\users\\fra\\Temp\\msi26.tmp\\Microsoft.Office.Interop.Publisher.dll"