setwd('U:/public_html/588/Class16/')
data <- read.csv("meadowfoam.csv")
plot(data)
attach(data)
lm1 <- lm(FLOWERS ~ TIME + INTENS) # here, time is numerical variable
summary(lm1)
fctime <- factor(TIME)
lm2 <- lm(FLOWERS ~ fctime + INTENS) # here, time is categorical variable
summary(lm2)
lm3 <- lm(FLOWERS ~ fctime*INTENS) # "interaction" model
summary(lm3)
# this will produce a Book plot
plot(FLOWERS ~ INTENS, pch = TIME) # use different characters for different levels of TIME
chars = c(1,16)
plot(FLOWERS ~ INTENS, pch = chars[TIME]) # this uses the fact that TIME = 1 or 2
abline(a=71.3 , b= -0.04047, lty =2) # these numbers are from lm2 fit
abline(a=71.3 + 12.16 , b= -0.04047, lty =1) # this is for TIME = 2
plot(lm2$fit, lm2$res)
detach(data)