How to make slope 1in fitlm?

9 次查看(过去 30 天)
Hello there,
Is it possible to force slope to 1 in in the fitlm function.
Many thanks!
Mohammad
  1 个评论
the cyclist
the cyclist 2021-2-18
I think you need to post some more information about what you are trying to do. Are you asking if you can fit a model of the form
y = a + x
and estimate the value of the intercept a, using fitlm?

请先登录,再进行评论。

采纳的回答

the cyclist
the cyclist 2021-2-19
I don't believe you can do it with fitlm, but you can with fitnlm:
% Set seed for reproducibility
rng default
% Make up some data that obeys your model, with a little noise
x = (1:10)';
y = 7 + x + 0.05*randn(size(x));
% Tabulate the data. (fitnlm does not require this, but it is convenient)
tbl = table(x,y);
% Define the fit equation
f = @(F,x) F(1) + x;
% Define starting guess for parameter
b0 = 1;
% Fit the data
mdl = fitnlm(tbl,f,b0)
mdl =
Nonlinear regression model: y ~ F1 + x Estimated Coefficients: Estimate SE tStat pValue ________ ________ ______ __________ F1 7.0312 0.027984 251.26 1.2752e-18 Number of observations: 10, Error degrees of freedom: 9 Root Mean Squared Error: 0.0885 R-Squared: 0.999, Adjusted R-Squared 0.999 F-statistic vs. zero model: 2.11e+05, p-value = 5.55e-21

更多回答(2 个)

behnam ashtarayeh
behnam ashtarayeh 2021-2-19
Thanks for your answer. Yes, I exatly mean what you said. Is it possible to fit a model of form (y = a + x) using fitlm and estimate intercept (a)?

behnam ashtarayeh
behnam ashtarayeh 2021-2-19
Thanks a lot!
It solved my problem.

类别

Help CenterFile Exchange 中查找有关 Dimensionality Reduction and Feature Extraction 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by