How to | Fit Models with Measurement Errors
Particularly in the physical sciences, it is common to use measurement errors as weights to incorporate measured variation into the fitting. Weights have a relative effect on the parameter estimates, but an error variance still needs to be estimated in weighted regression, and this impacts error estimates for results. The VarianceEstimatorFunction and Weights options to LinearModelFit and NonlinearModelFit can be used to get the desired results when weights are from measurement errors.
You can use NonlinearModelFit to fit this data to a logarithmic function of the predictors. Using the Weights option, normally distributed variability based on the measurement errors can be incorporated into the fitting. Each data point is weighted by , where is the measurement error for that data point.
When using Weights alone, the variance scale is estimated using the default method. Error estimates will depend on both the weights and the estimated variance scale. However, if the weights are from measurement errors, you would want error estimates to depend solely on the weights.
You can query the FittedModel output object, nlm, for results about the fitting.
For a such a weighted fitting, the scale of the error variance needs to be estimated to obtain standard errors for the parameter estimates. The typical estimate, which is used by linear and nonlinear models by default, involves a weighted sum of squares.
It is important to note that weights do not change the fitting or error estimates. For example, multiplying all weights by a constant increases the estimated variance, but does not change the parameter estimates or standard errors.
To treat the weights as being computed from measurement errors, you can use the VarianceEstimatorFunction option in addition to Weights. VarianceEstimatorFunction explicitly defines the variance scale estimator that is used. For measurement errors, you want standard errors to be computed only from the weights and so the variance estimate should be the constant 1:
The results from nlmvar1 all incorporate the weights and variance estimate consistent with weights coming from measurement errors. While weights have an impact on parameter estimates, the variance estimate itself does not. It is possible to override the variance estimate defined at the time of the fitting to get the measurement error results from nlm.