Re: Correct errors on fit parameter ?

*To*: mathgroup at smc.vnet.net*Subject*: [mg55460] Re: Correct errors on fit parameter ?*From*: Bill Rowe <readnewsciv at earthlink.net>*Date*: Thu, 24 Mar 2005 03:42:02 -0500 (EST)*Sender*: owner-wri-mathgroup at wolfram.com

Bruyndonckx P wrote: >Is there an easy way to obtain the correct statistical error on >fitted parameters ? >I tried the following simple example : >x=Range[5]; y=x^2; yerror={10,10,10,10,10} >NonlinearRegress[Transpose[{x, y}], a + b*xx + c*xx^2, {xx}, {a, >b, c}, Weights -> 1/yerror^2, RegressionReport -> {ParameterCITable}] >The asymptotic error and confidence intervals are of the order of >10^-15 !!!!. Obviously the weights (errors or uncertainty on the >data) are not taken into account when computing the error on the >parameter. It seems that the SE is only based on the residuals, which >are nearly 0 is this case because the fit is perfect. Changing the >value of the errors has no impact on the standard errors of the fit >parameters. For a weighted regression problem, the estimated variance is given by summing w(f[x]-y)^2 where w is the weight, f is the fitted function, x the independent observation and y the dependent observation. When you set the problem up so that f[x]-y is zero, then clearly the value of the weights no longer matters. That is the problem isn't with NonlinearRegress or Regress. The problem is with the way you chose to test things. This is easily seen in the following: First load the packages and create some test data In[1]:= << "Statistics`" data = Table[{x, 2*x + 3 + Random[NormalDistribution[0, 1]]}, {x, 5}]; w = Array[1 & , 5]; Now doing the regression with the weights set to w In[4]:= EstimatedVariance/.Regress[data, {1, x}, x, Weights -> w] Out[4]= 0.1917229712282517 Now do the same problem with the weights set to 10 w In[5]:= EstimatedVariance/.Regress[data, {1, x}, x, Weights -> 10*w] Out[5]= 1.9172297122825148 Clearly, the value of w does affect the computed estimated variance Here, I've used Regress to keep things simple. Weights are used in NonlinearRegress in the same manner. BTW, the problem you set up is for a polynominal fit and isn't a non-linear problem. Linear vs non-linear is determined by the way the coefficients to be found enter the problem, not the way the dependent variable is used. Also, using the set of basis functions ,x^n, for a polynominal problem is known to be numerically unstable. If you are trying to fit polynomials to your data, you would be better served by the package Statistics`PolynomialFit` rather than Regress or NonlinearRegress. -- To reply via email subtract one hundred and four