Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Passo 1: dados
- x <- c(10, 20, 30)
- y <- c(20, 25, 45)
- x2 <- x^2
- #Passo 2: plotando os dados
- plot(y, type="l", lwd=2, col="blue",
- xlab="Obs.", ylim=c(0,50))
- lines(x, type="l", lwd=2, col="red",
- xlab="Obs.")
- lines(x, type="p", lwd=2, col="black")
- lines(y, type="p", lwd=2, col="black")
- legend("topleft", c("x", "y"), lwd=2, col=c("blue", "red"))
- plot(x, y, type="p", lwd=2, col="black", main="Scatter Plot",
- pch=16, xlim=c(0,50), ylim=c(0, 50))
- abline(lm(y~x), lwd=2, col="red")
- #Passo 3: estimando y = b1 + b2x
- mod <- lm(y~x)
- summary(mod)
- yhay <- fitted.values(mod)
- sum((y - yhay)^2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement