Example 11.1 Obstetricians sometimes order tests for es- triol levels from 24-hour urine specimens taken from preg- nant women who are near term, because level of estriol has been found to be related to infant birthweight. The test can provide indirect evidence of an abnormally small fetus. The relationship between estriol level and birthweight can be quantified by fitting a regression line that relates the two variables. Data is given in Table 11.1 on page 429.

MATLAB: An Introduction with Applications
6th Edition
ISBN:9781119256830
Author:Amos Gilat
Publisher:Amos Gilat
Chapter1: Starting With Matlab
Section: Chapter Questions
Problem 1P
icon
Related questions
Question

Please finish the R code to conduct the hypothesis testing. I need the code for the p-value for the F test, tstat, and the p value for tstat. Write the conclusion to the hypothesis testing once completed. 

# Example 11.1
# simple linear regression
# H0: B=0 (there is no linear correlation)
# H1: B≠0 (there is a linear correlation)
data <- data.frame(estriol=c(7,9,9,12,14,16,16,14,16,16,17,19,21,24,15,16,17,25,27,15,15,15,16,19,18,17,18,20,22,25,24),
birthweight=c(25,25,25,27,27,27,24,30,30,31,30,31,30,28,32,32,32,32,34,34,34,35,35,34,35,36,37,38,40,39,43))
linear <- lm(birthweight~estriol, data = data)
summary(linear)
# This gives the results for a and b and the F statistic. 
# Call:
#   lm(formula = birthweight ~ estriol, data = data)

# Residuals:
#   Min      1Q  Median      3Q     Max 
# -8.1200 -2.0381 -0.0381  3.3537  6.8800 

# Coefficients:
#   Estimate Std. Error t value Pr(>|t|)    
# (Intercept)  21.5234     2.6204   8.214 4.68e-09 ***
#   estriol       0.6082     0.1468   4.143 0.000271 ***
#   ---
#   Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

# Residual standard error: 3.821 on 29 degrees of freedom
# Multiple R-squared:  0.3718,    Adjusted R-squared:  0.3501 
# F-statistic: 17.16 on 1 and 29 DF,  p-value: 0.0002712

xbar <- mean(data$estriol)
ybar <- mean(data$birthweight)

Lxx <- sum((data$estriol - xbar)^2)
Lxx
# 677.4194
Lxy <- sum((data$estriol - xbar)*(data$birthweight - ybar))
Lxy
# 412
b <- Lxy/Lxx
b
# 0.6081905
a <- ybar - b*xbar
a
# 21.52343

yhat <- a + b*data$estriol

totalSS <- sum((data$birthweight - ybar)^2)
totalSS
# 674
#250.5745 + 423.4255
regSS <- sum((yhat-ybar)^2)
regSS
# 250.5745
resSS <- sum((data$birthweight - yhat)^2)
resSS
# 423.4255
k <- 1
n <- 31
regMS <- regSS/k
regMS
# 250.5745
resMS <- resSS/(n-k-1)
resMS
# 14.60088
Fstat <- regMS/resMS
Fstat
# 17.1616
summary(aov(linear))
# Df Sum Sq Mean Sq F value   Pr(>F)    
# estriol      1  250.6   250.6   17.16 0.000271 ***
# Residuals   29  423.4    14.6                     
# ---
# Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Example 11.1 Obstetricians sometimes order tests for es-
triol levels from 24-hour urine specimens taken from preg-
nant women who are near term, because level of estriol has
been found to be related to infant birthweight. The test
can provide indirect evidence of an abnormally small fetus.
The relationship between estriol level and birthweight can
be quantified by fitting a regression line that relates the
two variables. Data is given in Table 11.1 on page 429.
Transcribed Image Text:Example 11.1 Obstetricians sometimes order tests for es- triol levels from 24-hour urine specimens taken from preg- nant women who are near term, because level of estriol has been found to be related to infant birthweight. The test can provide indirect evidence of an abnormally small fetus. The relationship between estriol level and birthweight can be quantified by fitting a regression line that relates the two variables. Data is given in Table 11.1 on page 429.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
MATLAB: An Introduction with Applications
MATLAB: An Introduction with Applications
Statistics
ISBN:
9781119256830
Author:
Amos Gilat
Publisher:
John Wiley & Sons Inc
Probability and Statistics for Engineering and th…
Probability and Statistics for Engineering and th…
Statistics
ISBN:
9781305251809
Author:
Jay L. Devore
Publisher:
Cengage Learning
Statistics for The Behavioral Sciences (MindTap C…
Statistics for The Behavioral Sciences (MindTap C…
Statistics
ISBN:
9781305504912
Author:
Frederick J Gravetter, Larry B. Wallnau
Publisher:
Cengage Learning
Elementary Statistics: Picturing the World (7th E…
Elementary Statistics: Picturing the World (7th E…
Statistics
ISBN:
9780134683416
Author:
Ron Larson, Betsy Farber
Publisher:
PEARSON
The Basic Practice of Statistics
The Basic Practice of Statistics
Statistics
ISBN:
9781319042578
Author:
David S. Moore, William I. Notz, Michael A. Fligner
Publisher:
W. H. Freeman
Introduction to the Practice of Statistics
Introduction to the Practice of Statistics
Statistics
ISBN:
9781319013387
Author:
David S. Moore, George P. McCabe, Bruce A. Craig
Publisher:
W. H. Freeman