ch1problem19-rcode

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

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

View Full Document Right Arrow Icon
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")
Background image of page 1
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 &lt;- 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=&quot;blue&quot;) #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

Ask a homework question - tutors are online