Accessing estimated parameters from nlinfit for weighted regression
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Maximilian Bailey
am 15 Mär. 2022
Kommentiert: Torsten
am 17 Mär. 2022
Hello,
I am looking to perform a weighted, non-linear regression on some data. I am currently fitting the data using the nlinfit function. I have derived the analytical expression of the variance of the data as a function of the estimated parameters, and I would thus like to use the estimated beta parameters at each fitting step as inputs into my weighted function.
I.e., I essentially want argmin sum((ydata-F(beta,x)).^2./sigma(beta,x).^2)
However, according to the documentation, the weights will only accept the output of the fitted model as a vector. Is there a way to access the estimated parameters during the fitting procedure so that nlinfit can weight the data as desired?
Thank you for your time
(Edit: for now I have simply fitted the parameters using fminsearch for the above expression, but I was wondering if there is an option on nlinfit or otherwise that allows you to adjust the weights during the fitting process as described)
0 Kommentare
Akzeptierte Antwort
Torsten
am 15 Mär. 2022
Bearbeitet: Torsten
am 15 Mär. 2022
Use "lsqnonlin" and define the functions f_i as
f_i = (ydata_i - F(beta,xdata_i))/sigma(beta,xdata_i)
"lsqnonlin" is the solver best suited for this kind of problem.
But you can also use nlinfit with the weights returned from a function.
From the documentation of nlinfit:
Weights:
Observation weights, specified as the comma-separated pair consisting of 'Weights' and a vector of real positive weights or a function handle. You can use observation weights to down-weight the observations that you want to have less influence on the fitted model.
If W is a vector, then it must be the same size as Y.
If W is a function handle, then it must accept a vector of predicted response values as input, and return a vector of real positive weights as output.
4 Kommentare
Torsten
am 17 Mär. 2022
I think you only need your model function values y_i, evaluated with the xdata_i and the beta_i, to determine the weights in each step, and this is what nlinfit delivers.
But anyhow, nice to hear that the proposed method works out fine.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Nonlinear Regression finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!