使用 lm() 的线性回归系数 y=mx+c 在幅度上与我预期的不同

Coefficients of linear regression y=mx+c using lm() differ in magnitude from what I expect

ddd = lm('USER ID' ~ 'CREATED ON')  
summary(ddd) 

第二张图片中直线的斜率应该是大约。 (6000-0)/(2017-2016)=6000 但如第一张图所示的斜率为 2.204e-04。这有什么意义?

(USER ID 和 CREATED ON 与用户数和时间相同,如图所示)

I generated plot using plot(Data1$'CREATED ON', Data1$'USER ID', cex = 0.5, xlab = "Time", ylab = "No.Of Users") then abline(lm('USER ID'~'CREATED ON', Data1), col=4).

At time = 2017, No.of Users ~ 6000 and At time = 2016 No.of Users ~ 0 so slope must be (6000 - 0)/(2017-2016) = 6000, but the slope shown is in 10^-4 magnitude.

CREATED ON column is a Date Time type. class(CREATED ON) gives output "POSIXct" "POSIXt"

勾选 as.integer(Data1$'CREATED ON')。 Date 和 DateTime 对象是可以很大的整数。


一般来说,为什么不直接提取模型矩阵来查看列是什么?

model.matrix.lm(ddd)

这立即暴露了问题。使用此模型矩阵计算回归系数。