Help with Linear Regression
이전 댓글 표시
I'm trying to conduct a simple linear regression fitting using fitlm, but the results that is provided when I plot the curve with the original data and the linear equation line found through fitlm is really off. I'm just using the first 20 data points from the list
mdl = fitlm(time(1:20),price(1:20))
mdl =
Linear regression model:
y ~ 1 + x1
Estimated Coefficients:
Estimate SE tStat pValue
__________ _______ _______ _________
(Intercept) 2.4736e+05 42743 5.7871 1.748e-05
x1 -5.7654 0.99663 -5.7849 1.756e-05
Number of observations: 20, Error degrees of freedom: 18
Root Mean Squared Error: 0.0178
R-squared: 0.65, Adjusted R-Squared 0.631
F-statistic vs. constant model: 33.5, p-value = 1.76e-05
Then I prepped for plot using.
x=time(1:20)
y1=2.4736e+05+(x*-5.7654)
plot(time(1:20),price(1:20),x,y1)
I would get this plot attached. I've also attached the data. Please help with a better fit or explanation as to why it is so far off. I'm not sure what I'm doing incorrectly.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!