You are on page 1of 2

x<-c(1,2,3,4,5)

> y<-c(2,3,5,4,6)

>x

[1] 1 2 3 4 5

> cov(x,y)

[1] 2.25

> sd(x)

[1] 1.581139

> sd(y)

[1] 1.581139

> cor(x,y)

[1] 0.9

> lm(y~x)

Call:

lm(formula = y ~ x)

Coefficients:

(Intercept) x

1.3 0.9

> plot(x,y)

> plot(x,y,lwd=10,col="blue")

> abline(lm(y~x))

> points(3,4)

> points(3,4,lwd=5;col="red")

Error: inesperado ';' in "points(3,4,lwd=5;"

> points(3,4,lwd=5,col="red")

> crid(col="green")
Error in crid(col = "green") : no se pudo encontrar la función "crid"

> grid(col="green")

> predict(lm(y~x))

1 2 3 4 5

2.2 3.1 4.0 4.9 5.8

> residuals(lm(y~x))

1 2 3 4 5

-0.2 -0.1 1.0 -0.9 0.2

> summary(lm(y~x))

Call:

lm(formula = y ~ x)

Residuals:

1 2 3 4 5

-0.2 -0.1 1.0 -0.9 0.2

Coefficients:

Estimate Std. Error t value Pr(>|t|)

(Intercept) 1.3000 0.8347 1.558 0.2172

x 0.9000 0.2517 3.576 0.0374 *

---

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.7958 on 3 degrees of freedom

Multiple R-squared: 0.81, Adjusted R-squared: 0.7467

F-statistic: 12.79 on 1 and 3 DF, p-value: 0.03739

You might also like