I'd really like to be able to solve the following problem:

Given observed data x(1)....x(n) and a known fixed 'target' T, solve for parameters a0, a1, & a2, which minimise:

{ T - sum[i=1 to n] exp(a0+a1*x(i)+a2*x(i)^2)*x(i) }^2

with the restriction that the sum of the exp(a0+a1*x(i)+a2*x(i)^2) terms equals n,

i.e. the mean of the exp(a0+a1*x(i)+a2*x(i)^2) terms equals 1.

I've tried PROC MODEL and PROC NLIN in SAS v9.4 but with no luck.

I'm now attempting to try with PROC OPTMODEL

My OPTMODEL test code is as follows:

* Create data with known parameters;

data d1;

do i = 1 to 100;

x=ranuni(4245);

w1=exp(1.0253056-3*x+0.4*x**2);* Weighting variable;

output;

end;

run;

proc means data=d1 n mean;var w1;run; * Mean weight of 1;

proc means data=d1 n mean;var x;run;

proc means data=d1 n mean;var x;weight w1;run; * Target (T)=0.2736;

proc optmodel;

set OBS;

num x{OBS};

read data d1 into OBS = [i] x ;

var a0 init 1, a1 init -2, a2 init 0.5;

con restrict: sum {i in OBS} exp(a0 + a1*x[i] + a2*x[i]**2) = sum{i in OBS} 1;

min objective = (0.2736 - sum {i in OBS} (exp(a0 + a1*x[i] + a2*x[i]**2)*x[i]))**2;

solve with nlp / tech=ip ms seed=21 MSMAXSTARTS=5000 msbndrange=50;

print a0 a1 a2;

quit;run;

The model does not converge anywhere near the a0, a1 & a2 values used in the 'd1' data step, even when initiated at values very close to those actually used.

What am I doing wrong? I suspect it's the way the objective function is specified....but just a hunch.

Any help gratefully received!