02-01-2016 08:17 AM
I have a problem estimating a nlin function on weighted data which basically comes down to the problem below:
Consider the following data where clearly y =x² and z aresome weights. Bij adapting the standard proc nlin to include the weights:
data STARTDATA; input x y z ; datalines ; 1 2 0.1 2 4 0.2 3 9 0.2 4 16 0.5 ; PROC SQL; CREATE VIEW WORK.SORTTempTableSorted AS SELECT T.y, T.x, T.z FROM WORK.STARTDATA as T; PROC NLIN DATA=WORK.SORTTempTableSorted MAXITER=100 CONVERGE=1E-05 SINGULAR=1E-08 MAXSUBIT=30; _WEIGHT_ = z; MODEL y = x ** b ; PARMS b=0.01; RUN;
The parameter b is estimated correctly as 2. However the SSE is minimized to the first weight which is 0.1 and is not further decreased to 0.
This makes the R² (here 1) wrongly estimated.
How can I correct my example such that the SSE can be smaller than the first weight?
Thanks in advance
02-01-2016 10:34 AM
Why do you think the results are wrong? I just ran your program with plots turned on, and everything looks fine for the fit. Taking out the weight statement gives a different confidence region, different SE, etc.,as expected. I think you just have a coincidence about the "0.1". For instance, I ran:
data b; set startdata;
pred = x**2;
SS = (y - pred)**2;
WSS = z*SS;
proc means data=b sum;
var SS WSS;
To manually get the sum of squares, weighted and unweighted, based on your parameter estimate. Weighted SS = 0.1, just like the NLIN output. If you run NLIN without the weight, you get SS = 1.0. This is what you get manually (above). I think everything is fine. By the way, put a plots=all option in your NLIN statement for good graphs.
02-01-2016 10:44 AM
Need further help from the community? Please ask a new question.