# This program produces the output and tables for # Insurance Innovation Example, NKNW # Objective: # 1. Create indicator variables # 2. Comparison of two simple linear regression models # by combining into one glm # Created by C. Andy Tsao. 060508 t<-matrix(scan("CH11TA01.DAT"),ncol=3,byrow=T) dt<-data.frame(y=t[,1],x1=t[,2],firm=t[,3]) attach(dt) # Default dt data.frame # Load needed package if you haven't done so summary(dt); plot(dt); # pairs(dt) nf<-2*firm; x2<-as.factor(nf); mmr<-lm(y~x1*nf);summary(mmr) mmf<-lm(y~x1*x2);summary(mmf) plot(x1,y); plot(x2,y); coplot(y~x1|x2) par(mfrow=c(2,2));