# --------------------------------------------------------------------- # Program: Bivariate1.S # Author: Steven M. Boker # Date: Thu Oct 7 12:46:36 EST 2004 # # Bivariate data # # --------------------------------------------------------------------- # --------------------------------------------------------------------- # Scatterplots graphsheet(height=6.4,width=6.4) plot(edaStudent$ztest, edaStudent$hscgpa, xlab="Entrance Exam (Z-Score)", ylab="High School Core GPA", type='p', pch=2) graphsheet(height=6.4,width=6.4) xyplot(hscgpa ~ ztest, data = edaStudent, aspect=1, xlab="Entrance Exam (Z-Score)", ylab="High School Core GPA") graphsheet(height=6.4,width=6.4) xyplot(ztest ~ jitter(as.numeric(sex),5), data = edaStudent, aspect=1, xlab="Sex", ylab="Entrance Exam (Z-Score)") # --------------------------------------------------------------------- # Scatterplots conditioned on a factor graphsheet(height=6.4,width=7.5) xyplot(hscgpa ~ ztest | sex, data = edaStudent, aspect=1, xlab="Entrance Exam (Z-Score)", ylab="High School Core GPA") # --------------------------------------------------------------------- # Scatterplots conditioned on a continuous variable graphsheet(height=6.4,width=7.5) xyplot(hscgpa ~ ztest | cut(pposths,6), data = edaStudent, aspect=1, main="HSCGPA vs. ZTEST \n Cut by Probability of Post HS in Neighborhood", xlab="Entrance Exam (Z-Score)", ylab="High School Core GPA") # --------------------------------------------------------------------- # Estimating a linear model tLM <- lm(hscgpa ~ ztest, data=edaStudent) summary(tLM) # --------------------------------------------------------------------- # Plotting a regression line graphsheet(height=6.4,width=6.4) xyplot(hscgpa ~ ztest, data = edaStudent, panel = function(x, y) { panel.xyplot(x, y) panel.abline(lm(hscgpa ~ ztest, data = edaStudent)) }, aspect=1, xlab="Entrance Exam (Z-Score)", ylab="High School Core GPA")