Professional Documents
Culture Documents
>x
[1] 5
> x=6
>x
[1] 6
> x<-8
> x<-9x
> x<-8
> x<-9
>x
[1] 9
> x+2
[1] 11
> x-4
[1] 5
> x*4
[1] 36
> x/3
[1] 3
> q()
> x/3
[1] 3
> y<-40
> x+y
[1] 49
> x-y
[1] -31
> x*y
[1] 360
> x/y
[1] 0.225
> x<-c(2,3,4,5,6)
>x
[1] 2 3 4 5 6
> y<-c(12,20,16,4,8)
>y
[1] 12 20 16 4 8
> x<-c(2,6,4,8,10)
>x
[1] 2 6 4 8 10
>y
[1] 12 20 16 4 8
> mean(x)
[1] 6
> mean(y)
[1] 12
>
> sd(x)
[1] 3.162278
> sd(y)
[1] 6.324555
> Cor(x,y)
> cor(x,y)
[1] -0.5
> cov(x,y)
[1] -10
> fit<-lm(y~x)
> fit
Call:
lm(formula = y ~ x)
Coefficients:
(Intercept) x
18 -1
> summary(fit)
Call:
lm(formula = y ~ x)
Residuals:
1 2 3 4 5
Coefficients:
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> predict(fit)
1 2 3 4 5
16 12 14 10 8
> plot(x,y)
> > > abline(fit)
>
> plot(x,y)
> abline(fit)
>
> predict(fit)
1 2 3 4 5
16 12 14 10 8
> plot(x,y)
> abline(fit)
>