Question

Question 3. For each of the following data sets use R to i) sketch a scatterplot and the line of best fit. ii) calculate the

0 0
Add a comment Improve this question Transcribed image text
Answer #1

For Data Set 1=

d1 <- read.csv("C:/Users/pcc/Desktop/d1.csv")

>   View(d1)

> x=d1$x

> y=d1$y

> y

[1] -1 0 1 0 -1 0 1 0 -1 0 1 0 -1

## To plot scatter plot ##

> plot(x,y)

## To Add line nest fit ##

> l1=lm(y~x,data=d1)

> l1

 > abline(l1)

> -1.0 -0.5 0.0 0.5 1.0 - Á - No * O No Oo

The Scatter plot shows there is no relation between x and y

## Correlation = ##
> cor(x,y)
 [1] 0
The correlation between X and Y is 0.Hene there is no relation between x and y
 
## Covariance ##
> cov(y,x)
[1] 0

Here both variables constant,Because the coefficient is zero.

r square = 2.863e-32

### For data 2 = ###
> x= c(1,2,3,4,5,6,7)

y=c(5.1,8.0,15.5,10.3,18.7,25.3,22.5)
> l2=lm(y~x)
> l2

## to plot and add regression line ##
> plot(x,y)  
> abline(l2)

5 10 15 20 و 25 N - کیا -The Scatter plot shows there is strong positive correlation between the two variable.

> cor(x,y)
[1] 0.9152279

From the correlation we observe that, there is strong positive correlation between the two variable.


> cov(x,y)
[1] 15

Here both variables tend to increase or decrease together,Because the coefficient is positive.

## r square ##

R square = 0.8376

r square imply that,Means the 83.76 % of variation explain by our explainatory variable to our dependent variable.

For data Set 3 =

> x=1:8
> x
[1] 1 2 3 4 5 6 7 8
> y=c(5.1,8.0,15.5,10.3,18.7,25.3,22.5,0)
> l3=lm(y~x)
> plot(x,y)
> abline(l3)

0 5 10 15 20 و 25 4 بی ۔ 5 ه ة ا

Here the Scatter plot shows there is low positive correlation between the two variable.

> cor(x,y)
[1] 0.2468258

Here the Scatter plot shows there is low positive correlation between the two variable.
> cov(x,y)
[1] 5.328571

Here both variables tend to increase or decrease together,Because the coefficient is positive.


> summary(l2)

r squre = 0.0692

r square imply that ,the 6.92 % of variation explain by our explainatory variable to our dependent variable.

 
 
Add a comment
Know the answer?
Add Answer to:
Question 3. For each of the following data sets use R to i) sketch a scatterplot...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT