is an option for LinearModelFit and NonlinearModelFit which specifies the variance estimator to use.
VarianceEstimatorFunction
is an option for LinearModelFit and NonlinearModelFit which specifies the variance estimator to use.
Details
- VarianceEstimatorFunction defines the function for estimating the error variance scale for linear and nonlinear models with assumed normally distributed errors.
- With the setting VarianceEstimatorFunction->f, the variance scale is estimated by f[res,w] where res={y1-
,y2-
,…} is the list of residuals and w is the list of weights, as specified by the setting for the Weights option. - The default setting Automatic estimates the variance scale by
where
is the weight for the
th data point,
is the
th residual,
is the number of data elements, and
is the number of parameters in the model. - With VarianceEstimatorFunction->(1&) and Weights->{1/Δy12,1/Δy22,…}, Δyi is treated as the known uncertainty of measurement yi and parameter standard errors are effectively computed only from the weights. »
Examples
open all close allBasic Examples (1)
Use the default unbiased estimate of error variance:
lm = LinearModelFit[Range[10] ^ 2, x, x]lm["EstimatedVariance"]Assume a known error variance:
LinearModelFit[Range[10] ^ 2, x, x, VarianceEstimatorFunction -> (5&)]["EstimatedVariance"]Estimate the variance by the mean squared error:
LinearModelFit[Range[10] ^ 2, x, x, VarianceEstimatorFunction -> (Mean[# ^ 2]&)]["EstimatedVariance"]Scope (2)
Define the estimate within the FittedModel:
lm = LinearModelFit[Range[10] ^ 2, x, x]lm["EstimatedVariance", VarianceEstimatorFunction -> (20&)]lm["EstimatedVariance", VarianceEstimatorFunction -> (Mean[# ^ 2]&)]data = {{0, 1}, {1, 0}, {3, 2}, {5, 4}};nlm = NonlinearModelFit[data, Log[a + b x ^ 2], {a, b}, x]Estimate the variance by the mean absolute error:
nlm["EstimatedVariance", VarianceEstimatorFunction -> (Mean[Abs[#]]&)]Applications (1)
Fit a nonlinear model using measurement errors as weights:
data = {{2.8, 1.8, 4.5}, {1.8, 2.2, 2.7}, {0.6, 4.6, 0.6}, {2.8, 4.1, 2.6}, {3., 0.1, 3.7}};Δys = {.1, .15, .12, .2, .08};Estimate the common error scale by 1:
nlm = NonlinearModelFit[data, a x Exp[b Sin[y]], {a, b}, {x, y}, Weights -> 1 / Δys ^ 2, VarianceEstimatorFunction -> (1&)]Obtain standard errors for the parameters:
nlm["ParameterErrors"]Compare with estimates using the default variance estimate:
nlm["ParameterErrors", VarianceEstimatorFunction -> Automatic]Properties & Relations (1)
Error estimates and confidence intervals involve variance estimates:
data = {{0, 1}, {1, 1.5}, {3, 2}, {5, 10}};lm = LinearModelFit[data, x, x]lm[{"ParameterErrors", "ParameterConfidenceIntervals"}]lm[{"ParameterErrors", "ParameterConfidenceIntervals"}, VarianceEstimatorFunction -> (1&)]Estimate by mean squared error:
lm[{"ParameterErrors", "ParameterConfidenceIntervals"}, VarianceEstimatorFunction -> (Mean[# ^ 2]&)]Related Guides
History
Text
Wolfram Research (2008), VarianceEstimatorFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/VarianceEstimatorFunction.html.
CMS
Wolfram Language. 2008. "VarianceEstimatorFunction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/VarianceEstimatorFunction.html.
APA
Wolfram Language. (2008). VarianceEstimatorFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/VarianceEstimatorFunction.html
BibTeX
@misc{reference.wolfram_2026_varianceestimatorfunction, author="Wolfram Research", title="{VarianceEstimatorFunction}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/VarianceEstimatorFunction.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_varianceestimatorfunction, organization={Wolfram Research}, title={VarianceEstimatorFunction}, year={2008}, url={https://reference.wolfram.com/language/ref/VarianceEstimatorFunction.html}, note=[Accessed: 13-June-2026]}