sg_spread <- read.csv("http://www.stat.ufl.edu/~winner/sta4210/mydata/shotgun_spread.csv", header=T) attach(sg_spread); names(sg_spread) regweight <- 1/(SD_range^2) ######## Note: there were 2 types of Cartridge, Analyze on Cartridge Type ### Ordinary Least Squares sg.mod1 <- lm(sqrtA[cartridge==2] ~ range[cartridge==2]) summary(sg.mod1) anova(sg.mod1) #### Weighted Least Squares sg.mod2 <- lm(sqrtA[cartridge==2] ~ range[cartridge==2], weight=regweight[cartridge==2]) summary(sg.mod2) anova(sg.mod2)