Beruflich Dokumente
Kultur Dokumente
> ## x = commerce_sales
> ## y = online_advertising
> x = c(368,340,665,954,331,556,376)
> y = c(1.7,1.5,2.8,5,1.3,2.2,1.3
+ y = c(1.7,1.5,2.8,5,1.3,2.2,1.3)
Error: unexpected symbol in:
"y = c(1.7,1.5,2.8,5,1.3,2.2,1.3
y"
> y = c(1.7,1.5,2.8,5,1.3,2.2,1.3)
> relation = lm(x~y)
> relation
Call:
lm(formula = x ~ y)
Coefficients:
(Intercept) y
125.8 171.5
> summary(relation)
Call:
lm(formula = x ~ y)
Residuals:
1 2 3 4 5 6 7
-49.33 -43.03 59.06 -29.16 -17.74 52.94 27.26
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 125.83 39.55 3.182 0.024484 *
y 171.47 15.39 11.139 0.000102 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> a = data.frame(x,y)
>a
x y
1 368 1.7
2 340 1.5
3 665 2.8
4 954 5.0
5 331 1.3
6 556 2.2
7 376 1.3
> s = data.frame(y = 5)
> result = predict(relation,y)
Error in eval(predvars, data, env) :
numeric 'envir' arg not of length one
> result = predict(relation,s)
> result
1
983.1627
> s = data.frame(y = 6)
> result = predict(relation,s)
> result
1
1154.628
> ## graph plot
>
> plot(y,x,col ="black" , main ="x and y regression" , abline(relation) , xlab =
"online_advertising" , ylab = "commerce_sales")