Displaying 20 results from an estimated 2000 matches similar to: "Help using spg optimization in BB package"
2008 Apr 23
1
BB - a new package for solving nonlinear system of equations and for optimization with simple constraints
Hi,
We (Paul Gilbert and I) have just released a new R package on CRAN called
"BB" (stands for Barzilai-Borwein) that provides functionality for solving
large-scale (and small-scale) nonlinear system of equations. Until now, R
didn't have any functionality for solving nonlinear systems. We hope that
this package fills that need.
We also have an implementation of the
2009 Jul 02
2
constrained optimisation in R.
i want to estimate parameters with maximum likelihood method with contraints (contant numbers).
for example
sum(Ai)=0 and sum(Bi)=0
i have done it without the constraints but i realised that i have to use the contraints.
Without constraints(just a part-not complete):
skellamreg_LL=function(parameters,z,design)
{
n=length(z);
mu=parameters[1];
H=parameters[2];
Apar=parameters[3:10];
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
2009 Apr 23
6
Stuck using constrOptim
Trying to use constrOptim to minimize the sum of squared deviations. I put
the objective function in as: sum((x %*% Y - Z)^2) so i'm trying to get
values for x to minimize the sum of the squared deviations between the
product of x and Y and Z.
Anyways i have no problem using this when x is a 3x1 test variable. it
works great with the constraints and everything. when i actually use it on
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
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]
2009 Feb 24
2
Tracing gradient during optimization
Hi everyone,
I am currently using the function optim() to maximize/minimize functions and
I would like to see more output of the optimization procedure, in particular
the numerical gradient of the parameter vector during each iteration.
The documentation of optim() describes that the trace parameter should allow
one to trace the progress of the optimization.
I use the following command:
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
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 ...
2009 Sep 11
1
constrOptim parameters
Dear R wizards: I am playing (and struggling) with the example in the
constrOptim function. simple example. let's say I want to constrain my
variables to be within -1 and 1. I believe I want a whole lot of
constraints where ci is -1 and ui is either -1 or 1. That is, I have 2*N
constraints. Should the following work?
N=10
x= rep(1:N)
ci= rep(-1, 2*N)
ui= c(rep(1, N), rep(-1, N))
2009 Apr 15
2
issue with L-BFGS-B in optim (optim just hangs)
Dear R-Help List,
I am using optim, with method=L-BFGS-B, to maximize a likelihood inside
a large simulation exercise. This runs fine for most simulated data
sets, but for some reason, about 1 out of 100 times, optim will just hang.
Using a dumb approach to the problem (i.e. printing the parameter values
each time the function being maximized is evaluated), I tracked down
when this happens,
2011 Sep 07
1
Imposing Feller condition using project constraint in spg
Dear R-users,
I'm running a maximization problem in which I want to impose a condition on
the relationship between 2 parameters.
The condition is that w[4] = (1+eps)/(2*w[1]), or equivalently w[4]*w[1] =
(1+eps)/2 , where eps is some small positive constant.
I've been trying to formulate a function that takes care of this, but I
can't really make it work so any suggestions would be
2009 May 06
2
NLMINB() produces NaN!
I am having the same problem as one Rebecca Sela(see bellow).
On 21/12/2007 12:07 AM, Rebecca Sela wrote:
>* I am trying to optimize a likelihood function using NLMINB. After running without a problem for quite a few iterations (enough that my intermediate output extends further than I can scroll back), it tries a vector of parameter values NaN. This has happened with multiple Monte Carlo
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
2018 May 05
1
adding overall constraint in optim()
Hi,
You can use the projectLinear argument in BB::spg to optimize with linear equality/inequality constraints.
Here is how you implement the constraint that all parameters sum to 1.
require(BB)
spg(par=p0, fn=myFn, project="projectLinear", projectArgs=list(A=matrix(1, 1, length(p0)), b=1, meq=1))
Hope this is helpful,
Ravi
[[alternative HTML version deleted]]
2007 Jun 20
4
finding roots of multivariate equation
Hello,
I want to find the roots of an equation in two variables. I am aware of the
uniroot function, which can do this for a function with a single variable (as I
understand it...) but cannot find a function that does this for an equation
with more than one variable. I am looking for something implementing similar
to a Newton-Raphson algorithm.
Thanks.
--
Bill Shipley
North American Editor for
2012 Sep 17
2
Constraint Optimization with constrOptim
Hi,
I am having trouble using constrOptim. My target is to do a portfolio optimization and there some constraints have to be fulfilled.
1) The weight of each share of the portfolio has to be greater than 0
2) The sum of these weights has to be 1
I am able to fulfill either the first or the second constraint but not both.
One simple way would be to fulfill the first constraint by using optim as
2009 Oct 15
4
Generating a stochastic matrix with a specified second dominant eigenvalue
Hi,
Given a positive integer N, and a real number \lambda such that 0 < \lambda
< 1, I would like to generate an N by N stochastic matrix (a matrix with
all the rows summing to 1), such that it has the second largest eigenvalue
equal to \lambda (Note: the dominant eigenvalue of a stochastic matrix is
1).
I don't care what the other eigenvalues are. The second eigenvalue is
2009 Aug 02
1
Inaccurate complex arithmetic of R (Matlab is accurate)
Dear All,
Hans Borchers and I have been trying to compute "exact" derivatives in R using the idea of complex-step derivatives that Hans has proposed. This is a really, really cool idea. It gives "exact" derivatives with only a minimal effort (same as that involved in computing first-order forward-difference derivative).
Unfortunately, we cannot implement this in R as the
2006 Nov 29
2
How to solve differential equations with a delay (time lag)?
Hi,
I would like to solve a system of coupled ordinary differential equations,
where there is a delay (time lag) term. I would like to use the "lsoda"
function "odesolve" package. However, I am not sure how to specify the
delay term using the syntax allowed by odesolve.
Here is an example of the kind of problem that I am trying to solve:
> library(odesolve)