({{, (RefLink[VarianceEstimatorFunction, paclet:ref/VarianceEstimatorFunction]) 
is an option for (RefLink[LinearModelFit, paclet:ref/LinearModelFit]) and (RefLink[NonlinearModelFit, paclet:ref/NonlinearModelFit]) which specifies the variance estimator to use.}})

OpenersNotesSection(Spacer1)Details

(RefLink[VarianceEstimatorFunction, paclet:ref/VarianceEstimatorFunction]) defines the function for estimating the error variance scale for linear and nonlinear models with assumed normally distributed errors.

With the setting (RefLink[VarianceEstimatorFunction, paclet:ref/VarianceEstimatorFunction])->f, the variance scale is estimated by f[res,w] where res={(Subscript[y, 1])-(Subscript[(OverHat[y]), 1]),(Subscript[y, 2])-(Subscript[(OverHat[y]), 2]),…} is the list of residuals and w is the list of weights, as specified by the setting for the (RefLink[Weights, paclet:ref/Weights]) option.

The default setting (RefLink[Automatic, paclet:ref/Automatic]) estimates the variance scale by ∑(((Subscript[w, i])((Subscript[y, i])-(Subscript[(OverHat[y]), i])))^2)/(n-p) where (Subscript[w, i]) is the weight for the i(^th) data point, (Subscript[y, i])-(Subscript[(OverHat[y]), i]) is the i(^th) residual, n is the number of data elements, and p is the number of parameters in the model.

With (RefLink[VarianceEstimatorFunction, paclet:ref/VarianceEstimatorFunction])->(1&) and (RefLink[Weights, paclet:ref/Weights])->{1/((Subscript[Δy, 1])^2),1/((Subscript[Δy, 2])^2),…}, (Subscript[Δy, i]) is treated as the known uncertainty of measurement (Subscript[y, i]) and parameter standard errors are effectively computed only from the weights. »

OpenersPrimaryExamplesSection(Spacer1)Examples  (5)

OpenersExampleSection0(Spacer1)Basic 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"]

OpenersExampleSection1(Spacer1)Scope  (2)

Define the estimate within the (RefLink[FittedModel, paclet:ref/FittedModel]):

lm=LinearModelFit[Range[10]^2,x,x]

lm["EstimatedVariance",VarianceEstimatorFunction->(20&)]

lm["EstimatedVariance",VarianceEstimatorFunction->(Mean[#^2]&)]

Use with a nonlinear model:

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[#]]&)]

OpenersExampleSection3(Spacer1)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]

OpenersExampleSection4(Spacer1)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]

Use the default estimator:

lm[{"ParameterErrors","ParameterConfidenceIntervals"}]

Assume unit error scale:

lm[{"ParameterErrors","ParameterConfidenceIntervals"},VarianceEstimatorFunction->(1&)]

Estimate by mean squared error:

lm[{"ParameterErrors","ParameterConfidenceIntervals"},VarianceEstimatorFunction->(Mean[#^2]&)]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[LinearModelFit, paclet:ref/LinearModelFit])  ▪  (RefLink[NonlinearModelFit, paclet:ref/NonlinearModelFit])  ▪  (RefLink[DispersionEstimatorFunction, paclet:ref/DispersionEstimatorFunction])  ▪  (RefLink[Weights, paclet:ref/Weights])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Statistical Model Analysis, paclet:guide/StatisticalModelAnalysis])}})}})