MATLAB: Does changing the weights of the x-data and y-data with the same factor not affect the confidence interval in the Curve Fitting Toolbox

cftoolCurve Fitting Toolboxweight

When I chose x, y, w as my x-data, y-data and weights respectively, I receive p1and p2 values with some confidence interval using the CFTOOL function.
When I change the weights by a factor of 10 (i.e w =10*w, meaning that I am more certain about my data), I again receive the same p1 and p2 values with the same confidence interval.
I expect the confidence interval to change.

Best Answer

The weights can be used to define the relative precision of the various points. However, there is no provision to specify that you know the variance of each point, and that the weights are exactly equal to the reciprocals of those variances. The CFTOOL function still estimates the residual variance and uses it in the computation of the coefficient standard errors, even if you have weights.
It is common in statistics to specify weights W to minimize
sum( W(i) * (y(i)-yfit(i)).^2 )
For example, suppose y(i) is the average of n(i) measurements. That means that if the individual measurements have variance v, then the ith average of y(i) has variance v/n(i). The n values are used as the weights. To estimate v such that the n values are proportional to the inverses of the y(i) variances, it cannot be assumed that the variances are exactly equal to the n values.
The weights are used in computing the confidence intervals, but the weights are not taken as known precisions (inverse variances) of the data, they are taken as proportional to them. We still estimate an overall variance factor.
The GLMFIT function in the Statistics Toolbox does treat the variances as known for some distributions. For instance, the code below makes it clear that the weights are being used:
% Generate x and y, with noise variance decreasing as a function of x
x =.3 + 10*rand(100,1);
noise = randn(100,1)./x;
y = 5 + 2*x + 5*noise;
scatter(x,y);
xx = linspace(0,10);
% Fit a straight line ignoring the weights
f1 = fit(x,y,'poly1')
line(xx,f1(xx),'color','r');
% Use weights this time, and notice that the confidence intervals for the
% slope get narrower
f2 = fit(x,y,'poly1','weight',x)
line(xx,f2(xx),'color','g')
legend('Data','Unweighted fit','Weighted fit','location','SE')