# R code to analyze the cornmeal data # using polynomial regression # reading the file off the web: # (This may not work in some implementations of R) cornmeal.data <- read.table(file = url("http:/www.stat.sc.edu/~hitchcock/stat701/cornmealdata.txt"), header=FALSE, col.names = c('sucrpct', 'diameter')) # Or, save the data file into a directory and # use the full path name: cornmeal.data <- read.table(file = "y:/My Documents/teaching/stat_701/cornmealdata.txt", header=FALSE, col.names = c('sucrpct', 'diameter')) # attaching the data frame: attach(cornmeal.data) # Scatterplot to check the shape of the regression relationship: plot(sucrpct, diameter) # Centering the X variable and # creating a quadratic term: csucrpct <- sucrpct - mean(sucrpct); csucrpctsq <- csucrpct^2; # fitting the regression model: corn.reg <- lm(diameter ~ csucrpct + csucrpctsq) # getting the summary regression output: # (This includes the overall F* = 15.41) summary(corn.reg) # getting the ANOVA table: anova(corn.reg)