pdf("ex0701.pdf") # Read in data from ASCII formatted (Fixed With File) ex0701dat <- read.fwf("http://www.stat.ufl.edu/~winner/data/biostat/ex0701.dat", width=c(8,8,8,8), col.names=c("subject","cl_cr","cl_g_s","cl_g_m")) # Create a dataset (frame) from input data ex0701 <- data.frame(ex0701dat) # Attach the dataset for analysis attach(ex0701) # Fit the simple linear regression model with dependent variable = cl_g_m (multiple dose gemfibrozil clearance) # and independent variable = cl_cr (cretinine clearance) cl_g_m.reg <- lm(cl_g_m ~ cl_cr) # Plot the data and regression line (Note you enter X first, then Y in plot statement) plot(cl_cr,cl_g_m) abline(cl_g_m.reg) # Print out the estimates, standard errors and t-tests, R-Square, and F-test summary(cl_g_m.reg) # Print out the ANOVA table (Sums of Squares and degrees of freedom) anova(cl_g_m.reg) # Compute the correlation coefficient cor(cl_g_m,cl_cr) # Test whether the population correlation coefficient is 0 (Identical to t-test for slope of regression line) cor.test(cl_g_m,cl_cr) dev.off()