{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

R Code for HW6

# R Code for HW6 - R Code for HW6 Sta108 Fall 2007 Utts...

This preview shows pages 1–2. Sign up to view the full content.

1 # R Code for HW6 Sta108, Fall 2007, Utts ### Problem 8.4 Data = read.table ( "~/Documents/School/Sta108utts/CH01PR27.txt" ) names ( Data )= c ( "Mass" , "Age" ) #(a) x1 = Data \$ Age - mean ( Data \$ Age ) x1sq = x1 ^ 2 Data = cbind ( Data , x1 , x1sq ) #fit a quadratic model (8.2) Quad = lm ( Mass ~ x1 + x1sq , data = Data ) summary ( Quad ) #plot fitted quadratic model plot ( Data \$ x1 , Data \$ Mass , main = "Polynomial Model" , xlab = "Age(centered)" , ylab = "Mass" , pch = 19 ) #create (x,y) points for quadratic model x = seq (- 20 , 20 , by = .1 ) y = 82.935749 - 1.183958 * x + 0.014840 * x ^ 2 lines ( x , y , col = "blue" ) #(b) #Test for regression relation. #See F-statistic in summary(). summary ( Quad ) qf ( 1 - 0.05 , 2 , 57 ) #F-value F(1-alpha, p-1, n-p) #(e) #Test: Ho: Beta2 = 0, Ha: Beta2 not= 0. #See t-statistic in summary(). qt ( 1 - 0.025 , 57 ) #t-value t(1-alpha/2, n-p) #(g) cor ( Data \$ Age , Data \$ Age ^ 2 ) cor ( x1 , x1sq ) ### Problem 8.16 Data = read.table ( "~/Documents/School/Sta108utts/GPA.txt" , header = TRUE ) #(b) #Fit model (8.33) Fit = lm ( GPA ~ ACT + Major , data = Data ) Fit #(c) #Test: Ho: Beta2 = 0, Ha: Beta2 not= 0.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 2

R Code for HW6 - R Code for HW6 Sta108 Fall 2007 Utts...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online