Liviu,
        Thanks for your comments.
        With continued study and experimentation, I have discovered the 
following:
        a. I need to rewrite the function to return a 1x1 as you suggested;     
        b. it seems that constrOptim() is the most appropriate routine to use 
on a nonlinear optimization problem with linear constraints on the regression 
parameters.

Thanks
Stu
> -----Original Message-----
> From: Liviu Andronic [mailto:landronim...@gmail.com]
> Sent: Tuesday, June 16, 2009 12:15 PM
> Cc: r-help@r-project.org
> Subject: Re: [R] Trouble with optim on a specific problem
> 
> Hello,
> 
> On 6/16/09, Stu @ AGS <s...@agstechnet.com> wrote:
> > Thanks for your response!
> >  No, my basic equation does not use matrices at all.  It takes scalar
> values and returns a scalar.
> >
> Not quite. Taking the example above, if you run the following:
> > with(observs , {1*x1*x2^2*x3^3})
> [1] 0.000e+00 4.267e+16 8.910e+15 2.293e+17 4.308e+16 1.207e+18
> 
> you get a vector 6x1. I may be wrong, but I would expect optim() or
> any other optimiser (nlminb, etc.) to expect that the objective
> function returns a 1x1 value. In my specific example, I arbitrarily
> chose values for the parameters: c[1]=1,c[2]=2,c[3]=3.
> 
> 
> >  What I am trying to accomplish is to find the "best-fit"
> coefficients to the equation as follows:
> >  y ~ c1 * x1 * x2^c2 * x3^c3
> >  where y, x1, x2, and x3 are observed data and c1, c2, and c3 are
> regression coefficients.
> >
> Here I'm slightly confused. If it is a regression that you are trying
> to do, and it seems non-linear, perhaps ?nls could help. I tried nls
> with your data, but it ended up with an error:
> 
> > nls( y ~ c1 * x1 * x2^c2 * x3^c3, data=observs, start=list(c1=0.66,
> c2=0.999, c3 = 0.064))
> Error in numericDeriv(form[[3]], names(ind), env) :
>   Missing value or an infinity produced when evaluating the model
> 
> 
> Best,
> Liviu

______________________________________________
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.

Reply via email to