# Measuring the influence of one variable on another: Regression mydataframe <- read.delim("http://www.robin-beaumont.co.uk/virtualclassroom/book2data/regression1.dat", header=TRUE) names(mydataframe) mydataframe hba1c_model <- lm(HBA1C~fastingBG, data=mydataframe) summary(hba1c_model) Confint(hba1c_model, level=0.95) #standard scatterplot with line of best fit library(car) scatterplot(fastingBG~HBA1C, reg.line=lm, smooth=FALSE, spread=TRUE, boxplots=FALSE, span=0.5, data=mydataframe) # For CI and prediction intervals on the graph # use the UsingR package install.packages("UsingR", dependencies=TRUE) library(UsingR) # show.ci adds both CI and prediction lines simple.lm(mydataframe$fastingBG, mydataframe$HBA1C, show.ci=TRUE) # R squared CI install.packages("psychometric", dependencies=TRUE) library(psychometric) CI.Rsqlm(hba1c_model ) ### Influence measures influence.measures(hba1c_model) ### Residuals resid(hba1c_model) rstandard(hba1c_model) rstudent(hba1c_model) ### plotting residuals plot(resid(hba1c_model)) plot(rstandard(hba1c_model)) ## rownames for subsetting rownames(mydataframe) hba1c_model2 <- update(hba1c_model1, subset=(rownames(mydataframe) != 12)) summary(hba1c_model2)