Try setting
options(error=recover)
before the offending call to constrOptim. When you hit the error you
can inspect the objects in constrOptim that cause the problem. E.g.,
constrOptim(theta=1:3, f=function(x)sum((x-1.5)^2),
grad=function(x)2*(x-1.5), ui=cbind(c(1,1,1), c(1.75,1.3,2)),
ci=c(1.1,1.1,1.1))
Error in ui %*% theta : non-conformable arguments
Enter a frame number, or 0 to exit
1: constrOptim(theta = 1:3, f = function(x) sum((x - 1.5)^2), grad =
function(x) 2 * (x - 1.5), ui = cbind(c(1, 1, 1), c(1.75, 1.3, 2)), ci = c(1.1,
1.1, 1.1))
Selection: 1
Called from: top level
Browse[1] str(ui)
num [1:3, 1:2] 1 1 1 1.75 1.3 2
Browse[1] str(theta)
int [1:3] 1 2 3
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf
Of Stefano de Pretis
Sent: Friday, December 07, 2012 1:23 PM
To: r-help@r-project.org
Subject: [R] 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 calculate that product in the command
line:
UI %*% startparams
[,1]
[1,] 2.297217e+05
[2,] 1.699765e+05
[3,] 2.037806e+05
[4,] 6.535699e+00
[5,] 1.014253e+01
[6,] 4.215988e+00
[7,] -2.297217e+05
[8,] -1.699765e+05
[9,] -2.037806e+05
[10,] -6.535699e+00
[11,] -1.014253e+01
[12,] -4.215988e+00
In fact, dimensions of UI and startparams are compatible in terms of the
scalar
product:
dim(UI)
[1] 12 6
dim(as.matrix(startparams))
[1] 6 1
Thanks in advance,
Stefano
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.