x=scan() 0 -1 -23 1.4 0 -1 -15 0.3 0 -1 -15 1.4 0 -1 -14 1.6 0 -1 -13 1.65 0 -1 -12 1.49 0 -1 -10.5 1.25 0 -1 -8 1.7 0 -1 -6 1.1 0 -1 -3 1.5 0 -1 -1 2.1 0 -1 -1 2.3 0 -1 -0.5 1.6 0 -1 1 1.1 0 -1 1 1.7 0 -1 1.5 2.2 0 -1 2 2.3 0 -1 4 3.2 0 -1 5 2 0 -1 5.5 2.35 0 -1 9.5 2.3 0 -1 10 2.1 0 -1 11 2.6 0 -1 12 2.4 0 -1 13 2.5 0 -1 15 2.9 0 -1 15 2.3 0 -1 19 2.7 0 -1 20 2.5 0 -1 20.5 2.9 0 -1 22 2.8 0 -1 23 2.9 0 -1 23 3 0 -1 23 3.1 0 -1 33 4.2 0 -1 36 3.4 0 -1 37 3.3 0 -1 40 2.65 0 -1 41 4.2 0 -1 41.5 4.3 0 -1 48 3.3 1 0 -17.5 1.4 1 0 -5 0.55 1 0 -5 0.9 1 0 -4 0.6 1 0 1 1 1 0 2 1 1 0 3 1.3 1 0 3 1.1 1 0 5 1.05 1 0 5 0.35 1 0 8 0.7 1 0 9 1 1 0 9 1.25 1 0 10 2 1 0 11 1.8 1 0 11.5 1.5 1 0 12 1.7 1 0 18 1.2 1 0 20 1.3 1 0 22 1.3 1 0 22 1.8 1 0 22.5 1.2 1 0 26 1.2 1 0 30 1.3 1 0 32 1.4 1 0 32 2.5 1 0 39 1.8 1 0 41 1.3 1 0 42 2.2 1 0 42 1.5 1 0 44 1.4 1 0 53 1.7 1 0 56 1.8 1 1 -16 0.4 1 1 -12 0.6 1 1 -9 0.7 1 1 -8.5 0.4 1 1 -8.5 0.55 1 1 -2 0.7 1 1 -1 0.8 1 1 6 1 1 1 19 0.8 1 1 21 0.7 1 1 23 0.75 1 1 25 0.9 1 1 28 0.8 1 1 32 0.55 1 1 38 0.8 1 1 40 1 ## fluoride = x[seq(1,360,4)] natural = x[seq(2,360,4)] deprivation = x[seq(3,360,4)] decay.score = x[seq(4,360,4)] type=fluoride+(natural==1) ds=data.frame(fluoride,natural,deprivation,decay.score,type) head(ds) plot(ds$deprivation,ds$decay.score, ylim=c(0,5),col=type+1,pch=19) fit0=lm(decay.score~deprivation,data=subset(ds,type==0)) points( ds$deprivation[ds$type==0], fit0$fitted.values, col=1, type="l" ) fit1=lm(decay.score~deprivation,data=subset(ds,type==1)) points( ds$deprivation[ds$type==1], fit1$fitted.values, col=2,type="l" ) fit2=lm(decay.score~deprivation,data=subset(ds,type==2)) points( ds$deprivation[ds$type==2], fit2$fitted.values, col=3,type="l" ) fit.all=lm(decay.score~deprivation+,data=subset(ds,type==2)) mult.fit=glm(ds$decay.score~ds$deprivation+as.factor(ds$type),family=poisson) summary(mult.fit) plot(ds$deprivation,mult.fit$fitted.values,col=ds$type+1,pch=19,cex=0.5) points(ds$deprivation,ds$decay.score,col=ds$type+1) add.fit=glm(ds$decay.score~ds$deprivation+as.factor(ds$type)+ ds$deprivation*as.factor(ds$type) , family=gaussian) summary(add.fit) ds$dep = ds$deprivation + 35 add.fit=glm(ds$decay.score~ds$dep+as.factor(ds$type)+ ds$dep*as.factor(ds$type) , family=gaussian) summary(add.fit) add.fit=glm(ds$decay.score~ds$dep+ ds$dep*as.factor(ds$type) , family=gaussian) summary(add.fit)