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;
RUN;
works fine.
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.
Any idea?
(I think PROC REG with WEIGHT would do, but there I cannot apply such a complicated function?
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.
Steve Denham
Thank, I trid with a trivil example,
DATA DatOrg;
INPUT x y;
CARDS;
1 3
1 5
2 2
2 6
3 5
3 3
4 6
4 2
5 5
5 3
6 2
6 6
7 3
7 5
;
RUN;
sort and followed by
PROC NLIN DATA=DatSort;
parms beta0 = 5.5 beta1 = 1.1;
model y = beta0 + beta1 * x;
RUN;
PROC NLMIXED DATA=DatSort;
parms beta0 = 5.5 beta1 = 1.1 ;
pred = beta0 + beta1 * x;
w = 1;
model y ~ normal(pred,w);
RUN;
outputs are different in the error, probably fit result
Approx
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
Standard
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
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
...still trying.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.