Question

In a small-scale regression study, we collected data on the number of children in a family...

In a small-scale regression study, we collected data on the number of children in a family Xi and the number of hours per week spent shopping Yi. The following data were obtained:

i 1 2 3 4 5 6
Xi 2 6 3 1 1 9
Yi 13 17 12 12 9 22

Assume we performed a simple linear regression of Yi on Xi, i.e. E(Yi) = ?0 + ?1Xi

(a) By hand compute X?X, X?Y, (X?X)-1, b, Y^(means Y-hat), and e. What are the dimensions of each matrix?

(b) Create a simple linear regression in R(R-program) and write down the fitted equation and the value of MSE. Interpret the coefficient b1.

(c) Use the MSE value to compute (Var(b))^(means Var(b) with a hat over it). From this matrix find estimates for Var(b0), Var(b1), and Cov(b0, b1).

(d) Construct a 95% confidence interval for ?1. Use the matrix formula from Chapter 6. Interpret this interval.

(e) Construct a 95% confidence interval for E(Yh) and a 95% prediction interval for Yh(new) at Xh = 4.

(f) In R reproduce parts (a), (c), (d), and (e). When recreating the results from parts (d) and (e), compute the confidence intervals and prediction intervals two ways:

•Using matrix notation

•Using either the confint or predict functions

Also compute the hat matrix H. What is the dimension of H? Also use H to compute Y and compare to the result in part (a).

Template for R parts of problem below.

# Type in children (x) and hours (y) as vectors. Set n to be the length

children <-

hours <-

n <-

##############################

########## Part (b) ##########

##############################

# Create a simple linear regression Y ~ X

fit <-

# Circle the value used to find MSE

summary(fit)

MSE <- # Type a number or use sigma() function

##############################

########## Part (f) ##########

##############################

# Create X and Y matrices.

ones <-

X <-

X # Displays matrix X

Y <-

Y # Displays matrix Y

# Display the dimensions of each of the X and Y matrices. See Chapter 5 Notes

# Calculate X'X, X'Y, (X'X)^(-1), and b.

XX <-

XY <-

XXinv <-

b <-

Yhat <-

e <-

# Display matrices (don't change)

XX

XY

XXinv

b

Yhat

e

# Calculate the variance-covariance matrix Var(b) two different ways

# 1: using MSE and XXinv

# 2: using the vcov function

Var.b1 <- # Method 1

Var.b1 # Displays matrix

Var.b2 <- # Method 2

Var.b2 # Displays matrix

# Construct a 95% confidence interval for beta1 two different ways

# 1: using matrix notation

# 2: using the confint function

beta1.lower <- # Method 1 lower

beta1.upper <- # Method 1 upper

c(beta1.lower, beta1.upper) # Displays interval (don't change)

beta1.int <- # Method 2

beta1.int # Displays interval

# Construct a 95% confidence interval for E(Y) when children=4 two different ways

# 1: using matrix notation

# 2: using the predict function

Xh <- # Enter vector Xh

Yh <- # Compute vector Yh using matrices

EY.lower <- # Method 1 lower

EY.upper <- # Method 1 upper

c(EY.lower, EY.upper) # Displays interval (don't change)

EY.int <- # Method 2

EY.int # Displays interval

# Construct a 95% prediction interval for Y when children=4 two different ways

# 1: using matrix notation

# 2: using the predict function

Y.lower <- # Method 1 lower

Y.upper <- # Method 1 upper

c(Y.lower, Y.upper) # Displays interval (don't change)

Y.int <- # Method 2

EY.int # Displays interval

# Compute the Hat matrix, H and Yhat. Find the dimension of H

H <-

H # Displays matrix

Yhat <-

Yhat

Homework Answers

Answer #1

x'x is (2x2), x'y is (2x1) and (x'x)-1 is 2x2 matrix

y b yhat e sse sigma2 varb
13 9.0714286 11.850649 1.1493506 7.7077922 2.5692641 1.1011132 -0.183519
17 1.3896104 17.409091 -0.409091 -0.183519 0.0500506
12 13.24026 -1.24026
12 10.461039 1.538961
9 10.461039 -1.461039
22 21.577922 0.4220779

regression equation y=b0+b1*x=9.0714+1.3896x

SE(b1)=sqrt(0.05)= 0.2236

95% confidence interval for b1=1.3896t(0.05/2,errror df=4)*SE(b1)=1.38962.7764*0.2236=1.38960.6208=

(0.7688, 2.0104)

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
A researcher collected the following data on years of education (X) and number of children (Y)...
A researcher collected the following data on years of education (X) and number of children (Y) for a sample of married adults: X Y 12 2 14 1 17 0 10 3 8 5 9 3 12 4 14 2 18 0 16 2 a. Draw a scatterplot of the data. b. Calculate the correlation between education and number of children for this sample of 10 married adults. c. Interpret the correlation between education and number of children. d. Is...
*Answer all questions using R-Script* Question 1 Using the built in CO2 data frame, which contains...
*Answer all questions using R-Script* Question 1 Using the built in CO2 data frame, which contains data from an experiment on the cold tolerance of Echinochloa crus-galli; find the following. a) Assign the uptake column in the dataframe to an object called "x" b) Calculate the range of x c) Calculate the 28th percentile of x d) Calculate the sample median of x e) Calculate the sample mean of x and assign it to an object called "xbar" f) Calculate...
I. Solve the following problem: For the following data: 1, 1, 2, 2, 3, 3, 3,...
I. Solve the following problem: For the following data: 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 5, 6 n = 12 b) Calculate 1) the average or average 2) quartile-1 3) quartile-2 or medium 4) quartile-3 5) Draw box diagram (Box & Wisker) II. PROBABILITY 1. Answer the questions using the following contingency table, which collects the results of a study to 400 customers of a store where you want to analyze the payment method. _______B__________BC_____ A...
1. A city official claims that the proportion of all commuters who are in favor of...
1. A city official claims that the proportion of all commuters who are in favor of an expanded public transportation system is 50%. A newspaper conducts a survey to determine whether this proportion is different from 50%. Out of 225 randomly chosen commuters, the survey finds that 90 of them reply yes when asked if they support an expanded public transportation system. Test the official’s claim at α = 0.05. 2. A survey of 225 randomly chosen commuters are asked...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • Two teaching methods and their effects on science test scores are being reviewed. A random sample...
    asked 1 minute ago
  • Please submit an original 50 word response to the summary below: The organization in which I...
    asked 10 minutes ago
  • A community generates 75,000 lb/day of solid waste that is deposited in a municipal landfill. The...
    asked 25 minutes ago
  • Suppose the sale price of a used car can be predicted by a function f(x, y)...
    asked 55 minutes ago
  • Which of the following is the most effective approach to delinquency prevention: psychosocial development or punishment?...
    asked 1 hour ago
  • You are testing the null hypothesis that there is no linear relationship between two​ variables, X...
    asked 1 hour ago
  • Using Microsoft Excel functions: 1. A machine will cost $50,000 to purchase. Annual operating cost will...
    asked 1 hour ago
  • Please, edit for clarity and conciseness, for grammar, capitalization, punctuation, abbreviation, number style, word division, and...
    asked 1 hour ago
  • Suppose your body was able to use chemical energy in gasoline. How far could you pedal...
    asked 2 hours ago
  • Consider why persons with disabilities are considered a vulnerable population. Share with others experiences you may...
    asked 2 hours ago
  • find the explicit particular solution of the initial value problem 2*x^1/2(dy/dx)=(cos^2)*y y(4)=pi/4 differntial equations
    asked 2 hours ago
  • Soma recorded in the table the height of each player on the basketball team Basketball Players’...
    asked 2 hours ago