# setwd("/Volumes/AlBook2/Fall04/BockCh4/") setwd("/Volumes/Ruby2/Class-G4two/Fall04/BockCh4/") ### on PCs, set working directory (above) uses things like "C:/folder/..." ### ### below, read.table is a quick way to read tab-delimited data; ### ### the data become columns identified as Table41DATA$column-name ### Table41Data <- read.table("Table4-1.dat", header=TRUE, fill=TRUE) ### below frames up the Ponzo part of the data and illustrates some ### ### canned R regression (from the lm---linear models---object) ### PonzoData <- data.frame(Table41Data$Age, Table41Data$Age^2, Table41Data$N, Table41Data$PonzoM) PonzoRegression <- lm(Table41Data.PonzoM ~ Table41Data.Age + Table41Data.Age.2, PonzoData, weights = Table41Data.N) summary(PonzoRegression) anova(PonzoRegression) ### note that the ANOVA above is not the same as that in Bock (p. 184) ### ### because the within-age part of the data is not used here ### coefficients(PonzoRegression) fitted.values(PonzoRegression) residuals(PonzoRegression) ### repeat some of the above for the Poggendorff data: ### PoggendorffData <- data.frame(Table41Data$Age, Table41Data$Age^2, Table41Data$N, Table41Data$PoggendorffM) PoggendorffRegression <- lm(Table41Data.PoggendorffM ~ Table41Data.Age + Table41Data.Age.2, PoggendorffData, weights = Table41Data.N) summary(PoggendorffRegression) anova(PoggendorffRegression)