0
$\begingroup$

I am doing a non linear model fit. I know how the fit variance is computed when I do NOT assign weights to the fit, for example:

ClearAll["Global`*"]
data = {{0, 1}, {1, 0}, {3, 2}, {5, 4}, {6, 4}, {7, 5}};
nlm = NonlinearModelFit[data, Log[a + b x^2], {a, b}, x];
mle = Append[nlm["BestFitParameters"], \[Sigma] -> nlm["EstimatedVariance"]^0.5]
nlm["CovarianceMatrix"]
(*Construct the log likelihood function*)logL = LogLikelihood[NormalDistribution[0,\[Sigma]], data[[All, 2]] - Log[a + b data[[All, 1]]^2]];
(*Get maximum likelihood estimates*)
sol = NMaximize[{logL, \[Sigma] > 0 && a > 0 && b > 0}, {a, b, \[Sigma]}]
(*Adjust estimator of \[Sigma] so that the estimator of \[Sigma]^2 is \unbiased*)
n = Length[data]; p = 2;(*Number of fixed parameters to be estimated:a and b*)
sigma = \[Sigma] Sqrt[n/(n - p)] /. sol[[2]];
sol[[2, 3]] = \[Sigma] -> sigma

I would like to know how the variance is estimated considering also the option Weights, for example:

ClearAll["Global`*"]
data = {{0, 1}, {1, 0}, {3, 2}, {5, 4}, {6, 4}, {7, 5}};
weight  = {1,2,3,4,5,6}
nlm = NonlinearModelFit[data, Log[a + b x^2], {a, b}, x, Weights->1/weight^2];
mle = Append[nlm["BestFitParameters"], \[Sigma] -> nlm["EstimatedVariance"]^0.5]
nlm["CovarianceMatrix"]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.