Fitting linear log regression with fitlm function

I would like to fit y = log(x) + k using fitlm (linear regression). How can I specify such a model? This is linear regression so would like to use fitlm function and not the fitnlm. Thanks!

답변 (1개)

Star Strider
Star Strider 2017년 11월 6일
편집: Star Strider 2017년 11월 6일
Try this:
mdl = fitlm(log(x), y);
It assumes a linear model (slope and intercept), so this is all that is necessary.
NOTE This will work providing that ‘x’ is real and positive. (I mention that for clarity.)

댓글 수: 2

Spirit
Spirit 2017년 11월 7일
Thanks StarStrider. I could do this way but this prevents me from using standard fitlm postprocessing functions say plot(mdl) for example. It plots a linear function as the actual regression is happening on log(x) vs. y.
I'd like to get a regression fit to y ~ log(x) + y using fitlm. I'd this should be possible as this still falls under the realm of linear regression.
Best, Shriram
I’m lost.
Good luck!

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

카테고리

도움말 센터File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

질문:

2017년 11월 6일

댓글:

2017년 11월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by