Skip to content

Instantly share code, notes, and snippets.

@marutter
Created September 9, 2010 15:04
Show Gist options
  • Save marutter/571983 to your computer and use it in GitHub Desktop.
Save marutter/571983 to your computer and use it in GitHub Desktop.
(b1 <- sum((x-mean(x))*(y-mean(y)))/sum((x-mean(x))^2))
(b0 <- mean(y)-b1*mean(x))
yhat <- b0+b1*x
e <- y-yhat
SSE <- sum(e^2)
MSE <- SSE/(length(y)-2)
plot(faithful$waiting,faithful$eruptions,main="Old Faithful",xlab="Wait time (minutes)",
ylab="Eruption duration (minutes)")
plot(iris$Sepal.Width,iris$Sepal.Length,main="Can we predict lenght from width?",
xlab="Sepal width",ylab="Sepal lentgh")
plot(iris$Sepal.Width,iris$Sepal.Length,main="Can we predict lenght from width?",
xlab="Sepal width",ylab="Sepal lentgh",pch=as.numeric(iris$Species))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment