Displaying 20 results from an estimated 136 matches for "constroptim".
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 functi...
2009 Jun 03
1
Using constrOptim() function
...have the following code (with a separate source file for the
function):
rm(list=ls())
source('mySourceFile')
x=read.csv("myFile.csv",head=TRUE,sep=",")
beta_i=c(1,1,1,1,1,1,-1)
ui=rbind(c(1,0,0,0,0,0,0),c(0,1,0,0,0,0,0),c(0,0,1,0,0,0,0),c(0,0,0,0,0,0,-1))
ci=c(0,0,0,0)
constrOptim(beta_i, myFunction, NULL, ui, ci, mu = 1e-04, control = list(),
method = "Nelder-Mead", outer.iterations = 100, outer.eps = 1e-05)
I am getting this error:
Error in f(theta, ...) : argument "x" is missing, with no default
If I replace myFunction with myFunction(beta,x) I g...
2010 Jun 17
2
constrOptim( ): conflict between help page and code
There is a contradiction between what the help page says and what constrOptim actually
does with the constraints. The issue is what happens on the boundary.
The help page says
The feasible region is defined by ?ui %*% theta - ci >= 0?,
but the R code for constrOptim reads
if (any(ui %*% theta - ci <= 0))
stop("initial value not feasible")
T...
2011 Dec 20
1
constrOptim and problem with derivative
Dear List,
I am using constrOptim to solve the following
fr1 <- function(x) {
b0 <- x[1]
b1 <- x[2]
((1/(1+exp(-b0+b1))+(1/(1+exp(-b0)))+(1/(1+exp(-b0-b1)))))/3
}
As you can see, my objective function is
((1/(1+exp(-b0+b1))+(1/(1+exp(-b0)))+(1/(1+exp(-b0-b1)))))/3 and I would
like to solve for both b0 and b1....
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 t...
2006 Feb 01
1
output hessian matrix in constrOptim
Hi,
Is there any way to get the hessian matrix from the "constrOptim" function without supplying gradient function? Thanks.
---------------------------------
Bring words and photos together (easily) with
[[alternative HTML version deleted]]
2012 Dec 07
1
Error using constrOptim in constraint definition
Hello,
I'm trying to run constrOptim. It returns to me an error about the fact that constraints arguments (ui and ci) are non compatibles:
> optout= constrOptim(startparams, f=ImpulseSS, grad=grImpulse, ui=UI, ci=CI, data=gexp[k,], t=t)
Error in ui %*% theta : non-conformable arguments
I would like to point out that I can calcul...
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 and score functions are:
likelihood = function(theta,data)
{...
2008 Jan 18
1
constrOptim with method SANN
Hi Everyone,
I'm trying to minimize a function using constrOptim with
the simulated annealing method SANN.
If I understand constrOptim well, it basically passes most
of its arguments to optim while somehow enforcing the constraints.
My problem is, that since SANN does not need gradients,
when using optim with SANN, the gr argument of optim is
used to specify a...
2011 Dec 21
1
constrOptim and further arguments
Dear List,
I have the code below, where I am using the constrained optimisation
package, 'constrOptim.nl' to find the values of two values, b0 and b1.
I have no problems when I enter further variable information DIRECTLY into
the functions, fn, and heq. In this instance I require fn to have -0.0075
appended to it, and in the case of heq, h[1] has -0.2.
library(alabama)
fn<-function(x)
((...
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
w...
2007 Aug 01
1
constrOptim
Hi,
I'm having trouble using the constrOptim function to generate the
9-component vector argmin of the function ELfsds:
ELfsds <- function(pvechat){
LG=0
for(i in 1:9){
LG=LG+log(pvechat[i])
}
return(-LG)
}
with accompanying gradient function:
gradfunc <- function(thetavec){
g=1/(9*thetavec)
return(g)
}
The constraints on t...
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),...
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 u...
2004 Apr 27
1
constrOptim does ineq, not eq, but who do ?
Hi everybody,
please, could you give me help ? I scanned the help archives and didn't
found hints...
I want to solve a large sparse linear system subjected to an inequality
constrains (all solutions positive) and an equality constrain (all
solutions sum to 1), thus I tried to fool constrOptim using:
x[1] + 0 + ... + 0 >= 0
...
0 + 0 + ... + x[n] >= 0
x[1] + x[2] + ... + x[n] >= 1
-x[1] - x[2] - ... - x[n] >= -1
in minimization: min( dist(A*x - b) )
But, since the initial guess x0 must be in the fasiable region and NOT in
the boundaries (due to trick I only...
2004 Oct 05
1
constrOptim convergence
Hello, I got a question with the R function constrOptim.
>From the R help, it says that the return values of "constrOptim" are the
same as "optim". For the return value "convergence" of the function
"optim", the values should be 0, 1, 10, 51 and 52. See
http://www.maths.lth.se/help/R/.R/library/stats/html/opti...
2010 Mar 17
1
constrOptim - error: initial value not feasible
...2("C:/Users/Herb/Desktop/Opti/NORM.csv")
fkt<- function(x){
a<-c(0)
s<-c(0)
#Minimizing square error
for(j in 1:107){
s<-(test[j,2] - (x[1] * test[j,3]) - (x[2] * test[j,4]) - (x[3]*test[j,5]) -
(x[4]*test[j,6]) - (x[5]*test[j,7]))^2
a<- a+s}
a<-as.double(a)
return(a)}
constrOptim(c(0,0,0.5,0,0.5), fkt, NULL, ui=rbind(c(1,1,1,1,1)), ci=c(1)
It works perfekt in the previews way, adding a second constraint, to
simulize the equal to 1 constraint, it doesn't work anymore:
constrOptim(c(0,0,0.5,0,0.5), fkt, NULL,
ui=rbind(c(1,1,1,1,1),c(-1,-1,-1,-1,-1)), ci=c(1,-1))
the er...
2004 Jul 14
0
Re: [R] constrOptim and function with additional parameters? (PR#7088)
...ug (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 :
>Actually, I think this is a bug. Take a look at this part of constrOptim:
This is the problem all right, but it's a little tricky to fix. The
problem is that "..." is documented as being additional parameters to
pass through to optim(). You don't want to pass all of those to f(),
only the ones that don't match optim()'s arg list. (And that...
2004 Jul 14
0
Re: [R] constrOptim and function with additional parameters? (PR#7089)
...ct
> 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 :
>
>
>>Actually, I think this is a bug. Take a look at this part of constrOptim:
>
>
> This is the problem all right, but it's a little tricky to fix. The
> problem is that "..." is documented as being additional parameters to
> pass through to optim(). You don't want to pass all of those to f(),
> only the ones that don't match opti...
2007 Aug 02
1
constraint in constrOptim
I'm using the function constrOptim together with the "SANN" method and
my objective function (f) has two parameters. One of the parameters
needs be into (2^(-10), 2^4) range and the other into (2^(-2), 2^12)
range. How can I do it using constrOptim??
Thank you
André Rossi
Alertas do Yahoo! Mail em seu celular....