簡單線性回歸

R 的行銷分析機器學習

Verena Pflieger

Data Scientist at INWT Statistics

R 的行銷分析機器學習

R 的行銷分析機器學習
simpleLM <- lm(futureMargin ~ margin, data = clvData1)
summary(simpleLM)
Call:
lm(formula = futureMargin ~ margin, data = clvData1)
Residuals:
    Min      1Q  Median      3Q     Max 
-56.055  -9.258   0.727  10.060  49.869 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) 12.63068    0.49374   25.58   <2e-16 ***
margin       0.64543    0.01467   43.98   <2e-16 ***

Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 14.24 on 4189 degrees of freedom
Multiple R-squared:  0.3159,    Adjusted R-squared:  0.3158 
F-statistic:  1935 on 1 and 4189 DF,  p-value: < 2.2e-16
R 的行銷分析機器學習
ggplot(clvData1, aes(margin, futureMargin)) +
  geom_point() +
  geom_smooth(method = lm, se = FALSE) +
  xlab("Margin year 1") +
  ylab("Margin year 2")

R 的行銷分析機器學習

簡單線性回歸的假設

  • x 與 y 的線性關係
  • x 無量測誤差(弱外生)
  • 誤差獨立
  • 誤差期望為 0
  • 預測誤差變異數恆定(同質變異)
  • 誤差常態分佈
R 的行銷分析機器學習

一起來練習吧!

R 的行銷分析機器學習

Preparing Video For Download...