You are on page 1of 5

Assessment – 4

Name: Preamji

Reg.no: 20BCE1776

Regression

1. The following table shows the age (X) and blood pressure (Y) of 8 persons

X 52 63 45 36 72 65 47 25

Y 62 53 51 25 79 43 60 33

Fit a linear model with R studio. Also find the expected blood pressure of a person who is 49
years old.
a1 = c(52,63,45,36,72,65,47,25)
b1 = c(62,53,51,25,79,43,60,33)
model = lm(a1~b1)
model
summary(model)
a = data.frame(b1=49)
result = predict(model,a)
result
plot(a1,b1, col = "blue", main = "Age & BP", abline(lm(a1~b1)), cex = 1.3, pch = 16, xlab =
"Age", ylab = "BP")

Output:
> a1 = c(52,63,45,36,72,65,47,25)
> b1 = c(62,53,51,25,79,43,60,33)
> model = lm(a1~b1)
> model

Call:
lm(formula = a1 ~ b1)

Coefficients:
(Intercept) b1
17.6999 0.6488

> summary(model)

Call:
lm(formula = a1 ~ b1)

Residuals:
Min 1Q Median 3Q Max
-14.109 -6.849 -1.853 5.014 19.403

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 17.6999 14.1381 1.252 0.2572
b1 0.6488 0.2657 2.442 0.0503 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 12.04 on 6 degrees of freedom


Multiple R-squared: 0.4985, Adjusted R-squared: 0.4149
F-statistic: 5.964 on 1 and 6 DF, p-value: 0.05033

> a = data.frame(b1=49)
> result = predict(model,a)
> result
1
49.48965
> plot(a1,b1, col = "blue", main = "Age & BP", abline(lm(a1~b1)), cex = 1.3, pch = 16, xlab =
"Age", ylab = "BP")
>
>

2. The following table gives the aptitude test scores and productivity indices of 10 workers
selected at random.

Aptitude 60 62 65 70 72 48 53 73 65 82
Score

Productivity 68 60 62 80 85 40 52 62 60 81
Index

Fit the linear model with R studio, Also estimate the (i) productivity index of a worker whose
test score is 92 (ii) test score of a worker whose productivity index is 75.
apt <- c(60,62,65,70,72,48,53,73,65,82)

prod <- c(68,60,62,80,85,40,52,62,60,81)

model1 <- lm(prod~apt)

a <- data.frame(apt=92)

result1 <- predict(model1,a)

result1

model2 <- lm(apt~prod)

a <- data.frame(prod=75)

result2 <-predict(model2,a)

result2

plot(apt,prod, col = "blue", main = "Aptitude Score(X) & Productivity Index(Y)",


abline(lm(apt~prod)), cex = 1.3, pch = 16, xlab = "Aptitude", ylab = "Productivity")

Output:

> apt <- c(60,62,65,70,72,48,53,73,65,82)

> prod <- c(68,60,62,80,85,40,52,62,60,81)

> model1 <- lm(prod~apt)

> a <- data.frame(apt=92)

> result1 <- predict(model1,a)

> result1

96.5302

> model2 <- lm(apt~prod)

> a <- data.frame(prod=75)

> result2 <-predict(model2,a)

> result2

70.9589

> plot(apt,prod, col = "blue", main = "Aptitude Score(X) & Productivity Index(Y)",
abline(lm(apt~prod)), cex = 1.3, pch = 16, xlab = "Aptitude", ylab = "Productivity")

>

>
Output:

> apt <- c(60,62,65,70,72,48,53,73,65,82)

> prod <- c(68,60,62,80,85,40,52,62,60,81)

> model1 <- lm(prod~apt)

> a <- data.frame(apt=92)

> result1 <- predict(model1,a)

> result1

96.5302

> model2 <- lm(apt~prod)

> a <- data.frame(prod=75)

> result2 <-predict(model2,a)

> result2

70.9589

> plot(apt,prod, col = "blue", main = "Aptitude Score(X) & Productivity Index(Y)",
abline(lm(apt~prod)), cex = 1.3, pch = 16, xlab = "Aptitude", ylab = "Productivity")

>

>

You might also like