S-PLUS : Copyright (c) 1988, 1996 MathSoft, Inc. S : Copyright AT&T. Version 3.4 Release 1 for Sun SPARC, SunOS 5.3 : 1996 Working data will be in .Data > dat <- read.table("data", header = T) > # > # Read in the data. Columns are named by the words > # read off line 1 because of the header=T bit. > # > attach(dat) > postscript("xyplot.ps",onefile=F,horizontal=F) > plot(Transfers,Broken,xlab="Number of Transfers",ylab="Number Broken") > dev.off() Starting to make postscript file. Finished postscript file, executing command "lpr -h xyplot.ps &". null device 1 > postscript("xrootyplot.ps",onefile=F,horizontal=F) > plot(Transfers, sqrt(Broken),xlab="Number of Transfers",ylab="Square Root Transform") > dev.off() Starting to make postscript file. Finished postscript file, executing command "lpr -h xrootyplot.ps &". null device 1 > linfit <- lm( Broken ~ Transfers, data=dat) > # > # Regress Number Broken on Number of Transfers > # > summary(linfit) Call: lm(formula = Broken ~ Transfers, data = dat) Residuals: Min 1Q Median 3Q Max -2.2 -1.2 0.3 0.8 1.8 Coefficients: Value Std. Error t value Pr(>|t|) (Intercept) 10.2000 0.6633 15.3771 0.0000 Transfers 4.0000 0.4690 8.5280 0.0000 Residual standard error: 1.483 on 8 degrees of freedom Multiple R-Squared: 0.9009 F-statistic: 72.73 on 1 and 8 degrees of freedom, the p-value is 2.749e-05 Correlation of Coefficients: (Intercept) Transfers -0.7071 > # > # Print out a summary of the regression results. > # > rootlinfit <- lm( sqrt(Broken) ~ Transfers, data=dat) > # > # Regress Square Root of Number Broken on Number of Transfers > # > summary(rootlinfit) Call: lm(formula = sqrt(Broken) ~ Transfers, data = dat) Residuals: Min 1Q Median 3Q Max -0.3722 -0.1263 0.01059 0.1392 0.274 Coefficients: Value Std. Error t value Pr(>|t|) (Intercept) 3.2006 0.1010 31.6789 0.0000 Transfers 0.5254 0.0714 7.3538 0.0001 Residual standard error: 0.2259 on 8 degrees of freedom Multiple R-Squared: 0.8711 F-statistic: 54.08 on 1 and 8 degrees of freedom, the p-value is 7.965e-05 Correlation of Coefficients: (Intercept) Transfers -0.7071 > # > # Print out a summary of the regression results. > # > glmfit <- glm( Broken ~ Transfers, data=dat, family=poisson) > # > # This fits the model that log(E(Y)) is a linear function > # of Dose and that the variance is equal to the mean > # > summary(glmfit) Call: glm(formula = Broken ~ Transfers, family = poisson, data = dat) Deviance Residuals: Min 1Q Median 3Q Max -0.8105292 -0.2389281 -0.02029464 0.3299091 0.6074179 Coefficients: Value Std. Error t value (Intercept) 2.3529495 0.1317376 17.860883 Transfers 0.2638422 0.0792345 3.329891 (Dispersion Parameter for Poisson family taken to be 1 ) Null Deviance: 12.56868 on 9 degrees of freedom Residual Deviance: 1.813176 on 8 degrees of freedom Number of Fisher Scoring Iterations: 3 Correlation of Coefficients: (Intercept) Transfers -0.770864 > postscript("points_plus_curve.ps",onefile=F,horizontal=F) > plot(Transfers,Broken,xlab="Number of Transfers",ylab="Number Broken",ylim=c(7,24)) > d <- seq(0,3.1,length=200) > etalin <- coef(linfit)[1] + d*coef(linfit)[2] > lines(d,etalin) > etarootlin <- coef(rootlinfit)[1] + d*coef(rootlinfit)[2] > lines(d,etarootlin^2,lty=2) > etaglm <- coef(glmfit)[1] + d*coef(glmfit)[2] > p <- exp(etaglm) > lines(d,p,lty=3) > legend(0,20,lty=1:3,legend=c("OLS","OLS on Root Y","GLM")) > dev.off() Starting to make postscript file. Finished postscript file, executing command "lpr -h points_plus_curve.ps &". null device 1 > q() # end-of-file