Wednesday, January 20, 2021

calculating linear regression using R

 

> # calculating the impact of digital marketing campaign cost on sales
> campaign<-c(24,26,28,29)
> sales<-c(134,145,167,172)
> realtion<-lm(campaign~sales)
> print(relation)

Call:
lm(formula = x ~ y)

Coefficients:
(Intercept)            y  
    33.8312      -0.1052  

> print(summary(relation))

Call:
lm(formula = x ~ y)

Residuals:
      1       2       3       4       5 
 -9.568  23.642   3.747  -6.148 -11.674 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)
(Intercept)  33.8312    16.3441   2.070    0.130
y            -0.1052     0.6855  -0.154    0.888

Residual standard error: 16.72 on 3 degrees of freedom
Multiple R-squared:  0.007795,	Adjusted R-squared:  -0.3229 
F-statistic: 0.02357 on 1 and 3 DF,  p-value: 0.8877

No comments:

Post a Comment