Rforch1-2 - > predict(reg, newdata=data.frame(ht=70),...

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

View Full Document Right Arrow Icon
R for Chapters 1-2 Running List of Functions Applied to the Data Set, class.data: > attach(class.data) > plot(ht,wt) ## scatter plot of these two variables using our data > reg < - lm(wt ~ ht) ## fits the linear regression model with “wt” explained as a linear function of “ht” > reg ## displays the coefficients of the Least Squares Fit > summary(reg) ## displays summary information about the fit > plot(ht,wt) > abline(lm( wt ~ ht)) ## includes the fitted line on the scatterplot (Leave the previous plot on the screen when doing this.) > wt ## the observed response value for each predictor value in the data > fitted.values(reg) ## the fitted values (vertical distance to the line) at each predictor value in the data > residuals(reg) ## the residual value (observed minus fitted) at each predictor value in the data > confint(reg) ## gives 95% C.I. For each of the intercept and the slope in our model > confint(reg, level=.98) ## gives a 98% confidence interval for each of the intercept and the slope
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: > predict(reg, newdata=data.frame(ht=70), se.fit=TRUE, interval=confidence) ## fitted value at ht=70 ## this estimates the average wt at ht=70, includes a 95% confidence interval for this average ## plus the se of this estimate (se.fit) and residual.scale=sqrt(MSE) > predict(reg, newdata=data.frame(ht=70), se.fit=TRUE, interval=confidence, level=.98) ## same as previous ## only with 98% confidence interval for the average > predict(reg, newdata=data.frame(ht=70), se.fit=TRUE, interval=predict) ## predicted value of a new wt at ht=70 ## includes a 95% prediction interval for this new response, the se of this predicted new response ## is sqrt( se.fit^2 + residual.scale^2) , the prediction interval confidence level is changed as ## shown in the previous example. > anova(reg) ## provides the ANOVA Table for the analysis of this simple linear model > cor(ht,wt) ## gives the Pearson correlation coefficient for the two variables included...
View Full Document

This note was uploaded on 07/08/2011 for the course STA 4211 taught by Professor Randles during the Spring '08 term at University of Florida.

Ask a homework question - tutors are online