05-30-2012 02:14 AM
Hello, I would like to fit a complicated function: I used up to now NLIN
PROC NLIN DATA=DatSortK OUTEST=FitParam25;
parms beta0 = 95.0 to 99.0 by 1.0 beta1 = -5 to 0 by 1 beta2 = -0.01 to 0.01 by 0.01 ea = 10 to 100 by 10;
model Y = beta0 + (beta1 + beta2 * month) * month * EXP(ea/0.00199*(1/273-1/tempK));
OUTPUT OUT = FitValues25 P=P L95M=L95M U95M=U95M L95=L95 U95=U95 PARMS=beta0 beta1 beta2 R=R STDR=STDR;
My question: I know the measurement errors. They are about SD=0.5, So I would like to weight with 1/var = 1/0.25=4.
When I add the line _WEIGHT_ = 4, the sum of quares are changed: o.k.
The uncertainties of the fitted parameters do not change: I conclude that _WEIGHT_ gives the points a weight of 4,
but it does not change the measurement uncertainties, aht I intended.
(I think PROC REG with WEIGHT would do, but there I cannot apply such a complicated function?
05-30-2012 07:33 AM
You may want to look at PROC NLMIXED. You would specify the model similarly, but include a term for the measurement error. Take a look at exaomple 63.1 in the NLMIXED documentation, where a one-compartment model for PK data is fit. I think you could easily gin up your NLIN code to accommodate the measurement error.
05-30-2012 08:47 AM
Thank, I trid with a trivil example,
INPUT x y;
sort and followed by
PROC NLIN DATA=DatSort;
parms beta0 = 5.5 beta1 = 1.1;
model y = beta0 + beta1 * x;
PROC NLMIXED DATA=DatSort;
parms beta0 = 5.5 beta1 = 1.1 ;
pred = beta0 + beta1 * x;
w = 1;
model y ~ normal(pred,w);
outputs are different in the error, probably fit result
Parameter Estimate Std Error Approximate 95% Confidence Limits
beta0 4.0000 0.9759 1.8737 6.1263
beta1 8.88E-16 0.2182 -0.4755 0.4755
Parameter Estimate Error DF t Value Pr > |t| Alpha Lower Upper Gradient
beta0 4.0000 0.5976 14 6.69 <.0001 0.05 2.7182 5.2818 5.55E-12
beta1 7.89E-14 0.1336 14 0.00 1.0000 0.05 -0.2866 0.2866 2.66E-11
05-30-2012 09:19 AM
It has to be different: the mean square error from NLIN is 2.6667.
If this was the weight, the std errors in NLIN should be correct: and they are.
With w=2.6667 in NLMIXED as an input, the results agree with NLIN!
Problem SOLVED: Thanks a lot to SteveDenham!
P.S. In NLMIXED it seem not so easy to get the confidence bands, which are easily accessible in NLIN by
OUTPUT OUT = FitValues25 P=P L95M=L95M U95M=U95M L95=L95 U95=U95 PARMS=beta0 beta1 beta2 R=R