Question

In: Statistics and Probability

Answer IN R CODE please. Using the data below, Create a scatterplot of y vs x...

Answer IN R CODE please. Using the data below,

Create a scatterplot of y vs x (show this) and fit it a simple linear regression model using y as the response and plot the regression line (with the data). Show this as well. Test whether x is a significant predictor and create a 95% CI around the slope coefficient. What does the coefficient of determinations represent?

For x=20, create a CI for E(Y|X=20). Show this.

For x=150, can you use the model to estimate E(Y|X=150). Discuss.

Does the model appear to be linear with respect to x. Explain. Discuss, and if not, provide alternative model and repeat steps 1-6.

y

x

1

311.8481

30.77326

2

440.9428

32.40036

3

41.6744

13.89724

4

417.7435

30.82836

5

177.3642

21.17247

6

639.0727

41.70052

7

179.9235

20.52949

8

19.64963

16.78782

9

1030.218

47.05621

10

211.6078

24.73312

11

468.797

33.30568

12

281.9641

27.20706

13

360.4149

28.98507

14

626.3254

33.98696

15

692.872

40.61913

16

840.8116

44.14024

17

71.51774

14.71966

18

97.75643

18.69047

19

251.0697

26.53534

20

81.51288

19.51529

21

270.3445

28.00065

22

1221.873

49.81578

23

110.3152

20.3347

24

595.4412

38.29436

25

126.2188

13.26268

26

11.15999

16.73084

27

230.5542

24.64804

28

77.3025

15.99319

29

1117.463

48.8532

30

122.5684

18.10108

31

932.665

44.75007

32

911.0599

44.23208

33

255.6625

24.33537

34

810.0097

41.18667

35

210.4745

20.06741

36

9.884425

11.10681

37

75.98362

11.67823

38

153.6595

20.20392

39

578.7254

38.05732

40

93.28379

12.89079

41

378.1102

27.82776

42

203.9408

25.8318

43

837.9018

43.87759

44

44.45671

11.49288

45

1145.79

48.94833

46

1073.485

47.3091

47

431.1394

30.53461

48

343.5504

28.65658

49

810.0665

41.25828

Please provide all relevant work in R code. The commands, the output and any interpretations/conclusions that are necessary.

Solutions

Expert Solution

now code :

### we have to do regression analysis : here y is dependent and x is independent :

y
x

### Create a scatterplot of y vs x (show this) and
## fit it a simple linear regression model using y as the
## response and plot the regression line (with the data)

## scatter plot :
plot(x,y , main = "scatter plot")

## fit regression model :
reg = lm(y~x)
reg

## estimated regression equation : yhat = -420.37 + ( 28.97*x)

summary(reg)

#### Q) Test whether x is a significant predictor and create
## a 95% CI around the slope coefficient.

## to test for coefficient of x : slope
## to test : Ho : β1 = 0 vs H1 : β1 ≠ 0

## test statistics : t = (b1 - β1) / se b1

b1 = 28.975
seb1 = 1.111

t = b1 / seb1
t

## p value = 2e-16

## Decision : we reject Ho if p value is less than alpha value using p value approach
## here p value is less than alpha value hence it is significant .

## Conclusion : slope is significant at given alpha level . that is x is significant .

#### Q1) 95 % confidence interval for slope :

## β1 = ( b1 ± t critical value * seb1 )

t_critical = abs(qt(0.05/2,47))
t_critical

lower_level = 28.975 - ( 2.011741*1.111 )
lower_level
upper_level = 28.975 + ( 2.011741*1.111 )
upper_level
## 95 % confidence interval for β1 = (26.739955 ,31.210044)

#### Q ) What does the coefficient of determinations represent?
## Answer : The coefficient of determination (denoted by R2) is a key output of regression
## analysis. It is interpreted as the proportion of the variance in the dependent variable
## that is predictable from the independent variable. it is lies in 0 to 1 .
  

#### Q ) For x=20, create a CI for E(Y|X=20). Show this. we can use direct command :

new.dat = data.frame(x=20)

predict(reg , newdata= new.dat ,interval = "confidence")

## lower limit = 126.2353 and upper limit = 192.0172

#### Q) For x=150, can you use the model to estimate E(Y|X=150). Discuss.

new.dat1 = data.frame(x=150)

predict(reg , newdata= new.dat1 ,interval = "confidence")

## Lower limit = 3653.956 , upper limit = 4197.698

#### Q) Does the model appear to be linear with respect to x. Explain. Discuss,

## to test : Ho : overall model is not linear vs H1 : overall model is singificant .

## test statistics = F = 680.5 and p value = 0

## Decision : we reject Ho if p value is less than alpha value using p value approach
## here p value is less than alpha value we reject Ho

## Conclusion ; there is enough evidence to conclude that overall model is significant .


Related Solutions

Answer IN R CODE to get the following. Using the data below, Create a scatterplot of...
Answer IN R CODE to get the following. Using the data below, Create a scatterplot of y vs x Fit a simple linear regression model using y as the response and plot the regression line (with the data) Test whether x is a significant predictor and create a 95% CI around the slope coefficient. Report and interpret the coefficient of determination. For x=20, create a CI for E(Y|X=20). For x=150, can you use the model to estimate E(Y|X=150)? Discuss. Does...
Using the following data, X- 3,6,9,12, 15, 18 Y - 6,10,15,24,21,20 a Create a scatterplot. b...
Using the following data, X- 3,6,9,12, 15, 18 Y - 6,10,15,24,21,20 a Create a scatterplot. b Find the least-squares line. c Plot the line on the diagram. d Predict: Y if X is 10. Y if X is 17
The Book of R (Question 20.2) Please answer using R code. Continue using the survey data...
The Book of R (Question 20.2) Please answer using R code. Continue using the survey data frame from the package MASS for the next few exercises. The survey data set has a variable named Exer , a factor with k = 3 levels describing the amount of physical exercise time each student gets: none, some, or frequent. Obtain a count of the number of students in each category and produce side-by-side boxplots of student height split by exercise. Assuming independence...
Data from 5.7: Problem Set 5.7: Scatterplot in SPSS Criterion: Create a scatterplot using SPSS. Data:...
Data from 5.7: Problem Set 5.7: Scatterplot in SPSS Criterion: Create a scatterplot using SPSS. Data: Dr T wanted to see if mindfulness training is related to stress levels. He recruited 10 participants to undergo mindfulness training and examined their reported stress levels on the DRT Stress Inventory. These were his results: Minutes of Mindfulness Training DRT Stress Inventory Score 61 8 122 6 201 3 133 9 55 7 329 1 10 9 1 10 93 7 144 5...
Answer the following bootstrap question by showing the R code : A set of data X...
Answer the following bootstrap question by showing the R code : A set of data X contains the following numbers: 119.7 104.1 92.8 85.4 108.6 93.4 67.1 88.4 101.0 97.2 95.4 77.2 100.0 114.2 150.3 102.3 105.8 107.5 0.9 94.1 We generated n = 20 observations Xi = 10 Wi+100, where Wi has a contaminated normal distribution with proportion of contamination 20% and σc = 4. Suppose we are interested in testing: H0 : μ = 90 versus H1 :...
*Please provide r studio file/code* Question: Test the equality of means of populations X,Y,Z using ANOVA:...
*Please provide r studio file/code* Question: Test the equality of means of populations X,Y,Z using ANOVA: set.seed(88) dta <- data.frame(v = c(2+2*rnorm(100), 3+3*rnorm(100), 4+4*rnorm(100)), id = rep(c("x","y","z"),c(100,100,100)))
Answer the correlation questions using the data below. Use α = 0.05. x y 7.1 4.8...
Answer the correlation questions using the data below. Use α = 0.05. x y 7.1 4.8 5.9 3.1 4.9 6.1 3.9 4.5 5.1 5.9 6.6 5.1 4.9 5.9 a) Compute the correlation. r =   b) Compute the appropriate test statistic(s) for H1: ρ > 0. critical value =  ; test statistic =   Decision:  ---Select--- Reject H0 Fail to reject H0 c) Compute the corresponding effect size(s) and indicate magnitude(s). If not appropriate, input and/or select "na" below. effect size =  ;  ---Select--- na trivial...
Answer the correlation questions using the data below. Use α = 0.05. x y 3.1 3.9...
Answer the correlation questions using the data below. Use α = 0.05. x y 3.1 3.9 5.9 7.1 6.1 4.9 7.2 4.5 5.1 5.9 6.6 5.1 4.9 5.9 a) Compute the correlation. r =   b) Compute the appropriate test statistic(s) for H1: ρ > 0. critical value =  ; test statistic =   Decision:  ---Select--- Reject H0 Fail to reject H0 c) Compute the corresponding effect size(s) and indicate magnitude(s). If not appropriate, input and/or select "na" below. effect size =  ;  ---Select--- na trivial...
answer the following questions using rhe x-y data set below: X: 2, 6, 5, 4, 8,...
answer the following questions using rhe x-y data set below: X: 2, 6, 5, 4, 8, 4, 1 Y: 18, 51, 43, 32, 65, 34, 7 use the regression equation to predict a value of y when x=3
I need the code in SAS and R and outputs please 2. The data below come...
I need the code in SAS and R and outputs please 2. The data below come from a study investigating a method of measuring body composition, and give the body fat percentage (% fat), age and sex for 18 adults aged between 23 and 61 years. Source: Mazess, R.B., Peppler, W.W., and Gibbons, M. (1984) Total body composition by dual-photon (153GD) absorptiometry. American Journal of Clinical Nutrition, 40, 834-839. age % fat sex 23 9.5 male 23 27.9 female 27...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT