0% found this document useful (0 votes)
50 views6 pages

20BME1070 Final Fat Lab Answers 2 PDF

The document describes several methods for analyzing correlations between variables: 1. It calculates the Pearson correlation coefficient and performs a correlation test between heights and weights, finding a strong positive correlation. 2. It fits a linear regression model between heights and weights and finds the intercept and slope of the line of best fit. 3. It calculates Spearman's rank correlation coefficients between heights and weights, weights and age, and heights and age, finding very strong correlations between each.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views6 pages

20BME1070 Final Fat Lab Answers 2 PDF

The document describes several methods for analyzing correlations between variables: 1. It calculates the Pearson correlation coefficient and performs a correlation test between heights and weights, finding a strong positive correlation. 2. It fits a linear regression model between heights and weights and finds the intercept and slope of the line of best fit. 3. It calculates Spearman's rank correlation coefficients between heights and weights, weights and age, and heights and age, finding very strong correlations between each.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

NOTE:OUTPUT ARE GIVEN IN BOLD LETTERS AND CODE IN NORMAL LETTERS.

ANSWER:

Method-1

a. > heights=c(62,64,65,69,70,71,72,74)

> weights=c(126,125,139,145,165,152,180,208)

> cor(heights,weights)

[1] 0.9031822

Method -2

> cor.test(heights,weights,method="pearson")

Pearson's product-moment correlation


data: heights and weights

t = 5.1539, df = 6, p-value = 0.002107

alternative hypothesis: true correlation is not equal to 0

95 percent confidence interval:

0.5460272 0.9825274

sample estimates:

cor

0.9031822

b. > model=lm(heights~weights)

>model

Call:

lm(formula = heights ~ weights)

Coefficients:

(Intercept) weights

47.4610 0.1349

So, intercept is 47.4610 and the slope is 0.1349.

The equation is X=0.1349Y+47.4610

X--→height, Y-→Weight

So if Y is 250 kg, find X=?

X=0.1349*250+47.4610=81.186 cm.

c. > heights=c(62,64,65,69,70,71,72,74)

> weights=c(126,125,139,145,165,152,180,208)

> age=c(30,35,36,37,38,50,61,76)

> cor.test(heights,weights,method='spearman')
Spearman's rank correlation rho

data: heights and weights

S = 4, p-value = 0.001141

alternative hypothesis: true rho is not equal to 0

sample estimates:

rho

0.952381

> cor.test(weights,age,method='spearman')

Spearman's rank correlation rho

data: weights and age

S = 4, p-value = 0.001141

alternative hypothesis: true rho is not equal to 0

sample estimates:

rho

0.952381

> cor.test(age,heights,method='spearman')

Spearman's rank correlation rho

data: age and heights

S = 0, p-value = 4.96e-05
alternative hypothesis: true rho is not equal to 0

sample estimates:

rho

Answer:

a. > x=c(1:20)

> y=5*x

>y

[1] 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95

[20] 100

> plot(x,y)
- Plot of Y ON X

b. > a=c(1:5)

>a

[1] 1 2 3 4 5

> a=seq(1,5)

>a

[1] 1 2 3 4 5

> a=c(1,2,3,4,5)

>a

[1] 1 2 3 4 5

c. > a=c(1,2,3)

> rep(a,3) # a vector is repeated 3 times

[1] 1 2 3 1 2 3 1 2 3
d. > n=c(2,3,5)

> s=c("A","B","C")

> b=c("Apple","Boy","Cat")

> df=data.frame(n,s,b)

> df

ns b

1 2 A Apple

2 3 B Boy

3 5 C Cat

> k=c("Mohan","Ram","Krishna")

> df1=cbind(df,k)

> df1

ns b k

1 2 A Apple Mohan

2 3 B Boy Ram

3 5 C Cat Krishna

>

e. > exp(15)+2^5+log10(200)

[1] 3269052

You might also like