ch1problem19-rcode

# ch1problem19-rcode - #Fit the regression line lm.ch1pr19<...

This preview shows page 1. Sign up to view the full content.

Sheet1 Page 1 # Code for Chapter 1 -- Problem 19 #Read in the data (remember: use right slash if in Windows) ch1pr19.dat <- read.table("YOUR PATH/CH01PR19.txt") #NOTE: It is beter to use real titles like "ACT" and "GPA" for the #variable names instead of the generic "y" and "x" below. names(ch1pr19.dat) <- c("y","x") attach(ch1pr19.dat) #Plot the data plot(x,y,xlab="ACT Test Score",ylab="Post-Freshman Year GPA",main="Problem 19")
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: #Fit the regression line lm.ch1pr19 <- lm(y ~ x) #Find the coefficients lm.ch1pr19\$coef #or summary(lm.ch1pr19) #Add a regression line to the previous plot abline(lm.ch1pr19,col="blue") #Get the prediction when x=30 predict(lm.ch1pr19,newdata=data.frame(x=30)) #compute this quantity by typing in the numbers to make sure you #understand what you are doing...
View Full Document

## This note was uploaded on 06/16/2009 for the course STAT 540 taught by Professor Staff during the Spring '08 term at Colorado State.

Ask a homework question - tutors are online