bwt <- read.csv("~/Bwt.txt", sep="")
lm1<-lm(bwt~diameter, data=bwt)
#1
summary(lm1)
coef(lm1)
#bwt = -28657.916 + 55.122*diameter
#2
#95% confidence interval
c(55.122 - qt(0.975,df=105)*3.004, 55.122 + qt(0.975,df=105)*3.004)
#3
var(residuals(lm1))
#4
sd(residuals(lm1))
#5
summary(lm1)$r.squared
#76.224% of variance in bwt is explained by diameter
#6
as.numeric(sum(coef(lm1)*c(1,90)))
bwt_1<-data.frame(diameter=90)
predict(lm1, bwt_1,interval = "predict")
#7 & 8
plot(lm1)
#The two plots in the first row are the reqd plots
#9
body <- read.delim("~/Body.txt")
body$weight2<-body$weight * 2.2
body$height2<-body$height / 2.54
summary(body)
lm2<-lm(weight ~ height, data=body)
lm3<-lm(weight2 ~ height2, data=body)
coef(lm2)
coef(lm3)
#10
bwt$diameter2<-bwt$diameter/10
bwt$bwt2<-bwt$bwt / 1000
lm4<-lm(bwt2~diameter2, data=bwt)
summary(lm4)
coef(lm1)
coef(lm4)