Reputation: 11
We are supposed to find the 90% confidence interval for a 74 year old man.
x <- c(58, 69, 43, 39, 63, 52, 47, 31, 74, 36)
y <- c(189, 235, 193, 177, 154, 191, 213, 165, 198, 181)
(where x is age and y is cholesterol level)
i used:
correlation <- cor.test(x, y, conf.level = 0.90)
and that gives me this:
data: x and y t = 1.2656, df = 8, p-value = 0.2413 alternative hypothesis: true correlation is not equal to 0 90 percent confidence interval: -0.1857867 0.7839057 sample estimates: cor 0.4084309
and when i asked people in my class what values they were getting all of them told me (203.2717, 205.5591) Where am I going wrong, the corr.test is telling me -0.1857867 0.7839057.
also the next portion of the assignment is asking us to calculate a 90% prediction interval for a 74 year olds, how would i do this in r studio? thanks a lot!
Upvotes: 0
Views: 445
Reputation: 5897
df <- data.frame(
x = c(58, 69, 43, 39, 63, 52, 47, 31, 74, 36),
y = c(189, 235, 193, 177, 154, 191, 213, 165, 198, 181)
)
predict.lm(
lm(y~x, data = df),
newdata = data.frame(x = 74),
interval = "confidence",
level = 0.90
)
# fit lwr upr
# 1 204.42 178.99 229.85
Upvotes: 1