Hi, I am just curious as to what's the proper way to fit a curve to data and also take into account the variance of the data. Consider this example here https://au.mathworks.com/help/stats/examples/curve-fitting-and-distribution-fitting.html?prodcode=ML&requestedDomain=www.mathworks.com, where they measure concentration at different times. They plot this as a time vs concentration scatter plot and can fit a curve using nlinfit.
I want to know what if I take multiple concentrations measurements for each time. Can I still use nlinfit for this? How can I preserve the variance of concentration in my curve?

 채택된 답변

John D'Errico
John D'Errico 2016년 10월 4일
편집: John D'Errico 2016년 10월 4일

0 개 추천

It is just a weighted nonlinear least squares then. If nlinfit accepts weights (the standard deviation for each data point would be the appropriate weight) then it is simple. A quick check of the help reveals this:
[BETA,R,J,COVB,MSE] = nlinfit(X,Y,MODELFUN,BETA0,OPTIONS,...,'Weights',W)
nlinfit can accept an optional parameter name/value pair that specifies
the observation weights:
'Weights' A vector of real positive weights the same size as Y,
each element of which specifies an observation weight.
Reducing the weight of an observation reduces the
influence of that observation on the fitted model.
This can also be specified as a function handle that
accepts a vector of predicted response values and
returns a vector of real positive weights as output.
Default is no weights.
Always a good idea to read the help.

댓글 수: 4

Star Strider
Star Strider 2016년 10월 4일
I always use inverse-variance weighting, so the weight vector would be 1/variance.
John D'Errico
John D'Errico 2016년 10월 7일
Sloppy of me. Yes, large uncertainty in a point should yield small weights.
yier Wang
yier Wang 2022년 7월 5일
So how do you define weight using standard deviation of data? 1/standard deviation?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

질문:

2016년 10월 4일

댓글:

2022년 7월 5일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by