Skip to content

Instantly share code, notes, and snippets.

@marutter
Created November 29, 2010 18:38
Show Gist options
  • Select an option

  • Save marutter/720343 to your computer and use it in GitHub Desktop.

Select an option

Save marutter/720343 to your computer and use it in GitHub Desktop.
x <- c(1,2,3,4,5,15)
y <- c(3.1,5.9,9.3,11.8,15.1,1)
plot(x,y)
res <- lm(y~x)
summary(res)
abline(res)
res1 <- lm(y~x,subset=c(-6))
summary(res1)
yhat.6.6 <- predict(res1,data.frame(x=15))
y[6]-yhat.6.6
hatvalues(res)
sum(hatvalues(res))
res$res[6]
res$res[6]/(1-hatvalues(res)[6])
plot(hatvalues(res))
rstudent(res)
cooks.distance(res)
plot(res,4)
plot(res,5)
data <- read.csv("manhours.csv",header=T)
attach(data)
library(MASS)
res <- stepAIC(lm(hours~(ocup+sqfoot+wings+cap+rooms)^2+check+service),k=log(25),direction="both")
summary(res)
hatvalues(res)
plot(res,4)
plot(res,5)
res <- stepAIC(lm(hours~(ocup+sqfoot+wings+cap+rooms)^2+check+service,subset=c(-24)),k=log(24),direction="both")
summary(res)
plot(res,4)
plot(res,5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment