[Rd] constrOptim (PR#8158)

murdoch@stats.uwo.ca murdoch at stats.uwo.ca
Tue Sep 27 18:44:30 CEST 2005


On 9/27/2005 12:20 PM, hbren at stat.tamu.edu wrote:
> I tested both 2.2.0 Beta and 2.1.1 Patched. The problem I reported is
> still there. I gurantee that there is no error in my codes. I identified
> there is something wrong in "optim" or the accociated internal function.
> It turns out that the error message
> 
> Error: subscript out of bounds
> 
> shows up when the dimension of parameter is high. Also it happens even
> when the dimension is low but if you run it more times.
> 
> Attached please find the R program with the data file I used for the
> optimization objective function.

When I try your code I get this:

 > 
a=constrOptim(points,target3,NULL,ui=con1,ci=con2,control=list(fnscale=-1), 
value=value,at=at)
Error: subscript out of bounds
 > traceback()
6: f(theta, ...)
5: R(theta, theta.old, ...)
4: fn(par, ...)
3: function (par)
    fn(par, ...)(c(1995, 2253.7, 2057))
2: optim(theta.old, fun, gradient, control = control, method = method,
        ...)
1: constrOptim(points, target3, NULL, ui = con1, ci = con2, control = 
list(fnscale = -1),
        value = value, at = at)

This says that the error occurs in your target3 function (which is 
called f at this point).

So despite your guarantee, I think the bug is in your code, not in R.

Duncan Murdoch

> Thanks,
> 
> 
>> On 9/26/2005 6:19 PM, hbren at stat.tamu.edu wrote:
>>> Full_Name: Haobo Ren
>>> Version: 2.1.1
>>> OS: Windows 2000
>>> Submission from: (NULL) (192.11.226.116)
>>>
>>>
>>> When running constrOptim, there is error message
>>>
>>> Error: subscript out of bounds
>>>
>>
>> Please test this in the latest beta version, (available from
>> http://cran.r-project.org/bin/windows/base/rdevel.html) and if you still
>> see the problem, put together a reproducible example.  (If you are
>> unable to install the beta, please do post the example.)
>>
>> Make it as simple as you can, so you're sure it's not an error in your
>> own code.  If you need to use simulated data, call set.seed() first so
>> we can reproduce the results.
>>
>> Thursday is code freeze; if you can post the relevant information enough
>> before that there's a good chance this could be fixed before the next
>> release.
>>
>> Duncan Murdoch
>>



More information about the R-devel mailing list