1

A sample of 40 psychology students at a large southwestern university took four subtests (Vocabulary, Similarities, Block Design, and Picture Completion) of the Wechsler (1981) Adult Intelligence Scale-Revised. The researchers also used Magnetic Resonance Imaging (MRI) to determine the brain size of the subjects.
Source: Willerman, L., Schultz, R., Rutledge, J.N., & Bigler, E. (1991), In Vivo Brain Size and Intelligence, Intelligence, 15, 223-228.

Column 1: Subject ID
Column 2: Gender ID
Column 3: Full scale IQ
Column 4: Verbal IQ
Column 5: Performance IQ
Column 6: Body weight in pounds
Column 7: Height in inches
Column 8: Totol pixel counts from 18 MRI scans

Use appropriate graphical analysis to answer the following questions.
Are there gender differences in the three IQ scores?
Is the relationship between height and weight gender dependent?
Is the relationship between IQ and brainsize (as measured by MRIcount) gender dependent?
ANS: 以上三題皆是

dir<-'http://titan.ccunix.ccu.edu.tw/~psycfs/dataM/Data/brainsize.txt'
dta<-read.table(dir,h=T)
d<-cbind(aggregate(FSIQ ~ Gender, data = dta, mean),aggregate(VIQ ~ Gender, data = dta, mean)$VIQ,aggregate(PIQ ~ Gender, data = dta, mean)$PIQ)
colnames(d)<-c("Gender","FSIQ","VIQ","PIQ")
g<-reshape(d,v.names="score",times=colnames(d)[2:4],ids=row.names(d),varying=list(2:4), direction="long")
dotplot(score ~ Gender, groups = time, data = g,type="b",auto.key = list(points = T, lines = T, columns = 3),main="Mean Score of Three IQs")

xyplot(Weight~Height,data=dta,groups =Gender,type=c("p","r"),par.settings=standard.theme(color = F),
       auto.key = list(points = T, lines = T, space="right"),xlab="Height (in inches)",ylab="Weight(in pounds)",
       main="Weight vs. Height given Gender")

xyplot(FSIQ~MRICount,data=dta,groups =Gender,type=c("p","r"),par.settings=standard.theme(color = F),
       auto.key = list(points = T, lines = T, space="right"),xlab="MRICount",ylab="FSIQ",
       main="FSIQ vs. MRICount given Gender")

2

The heights of 26 boys in Oxford, UK, were measured on nine occasions over two years, starting at 12 years old. Draw the graph below.
Source: Harrison, G.A., & Bush, G. (1990). On correlations between adjacent velocities and accerlations in longitudinal growth data. Annals of Human Biology, 17(1), 55-57.
Column 1: Boy ID
Column 2: Age in months relative to an annual origin of January 1
Column 3: Height measurement in cm
Column 4: Measurement occasion ID

dir<-"http://titan.ccunix.ccu.edu.tw/~psycfs/dataM/Data/boyHeights.txt"
dta<-read.table(dir,h=T)
dta$age<-dta$age+13
xyplot(dta$ht~dta$age,xlab="Age (in year)",ylab ="Height (in cm)",cex=1,pch=1,type="b",groups=dta$sbj,lwd=1.2,lty=3)

3

The data set concerns student evaluation of instructor’s beauty and teaching quality for several courses at the University of Texas. The teaching evaluatons were done at the end of the semester, and the beauty judgments were made later, by six students who had not attended the classes and were not aware of the course evaluations.
Source: Hamermesh, D.S., & Parker, A.M. (2005). Beauty in the classroom: instructor’s pulchritude and putative pedagogical productivity.a Economics and Education Review, 24, 369-376. Reported in Gelman, A., & Hill, J. (2006). Data analysis using regression and hierarchical/multilevel models. p. 51.
Column 1: Course evaluation score
Column 2: Beauty score
Column 3: Gender of professor, 1 = Female, 0 = Male
Column 4: Pofessor age in years
Column 5: Minority status of professor, 1 = Minority, 0 = Others
Column 6: Tenure status of professor, 1 = Tenured, 0 = No
Column 7: Course ID

dir<-"http://titan.ccunix.ccu.edu.tw/~psycfs/dataM/Data/beautyCourseEval.txt"
dta<-read.table(dir,h=T)
xyplot(eval~beauty,data=dta,ylab="Average teaching evaluation",xlab="Beauty",col="black",type=c("r","p"))

xyplot(eval~beauty|as.factor(courseID),data=dta,type=c("r","p"),par.settings=simpleTheme(col.line="black"))

4

Use trellis graphics to explore various ways to display the sample data from the National Longitudinal Survey of Youth.

除了少數族群的男性之外,其餘種族與性別組合似乎在兩個科目上都有雙峰的傾向。

dir<-'http://titan.ccunix.ccu.edu.tw/~psycfs/dataM/Data/nlsy86long.csv'
dta<-read.csv(dir,h=T)
densityplot(~read|race,data=dta,group=sex,type=c("r","p"),plot.points = FALSE,auto.key = list(lines = T))

densityplot(~math|race,data=dta,group=sex,type=c("r","p"),plot.points = FALSE,auto.key = list(lines = T))

隨著年齡增加,數學的平均成績越來越高,而多數族群的數學分數一直比少數族群好,然而性別卻沒有一致的優勢。

m0 <- aggregate(math ~ race+year, data = dta, mean)
xyplot(math ~ year, groups = race, data = m0, type="b",
        par.settings = standard.theme(color = F),
        auto.key = list(points = T, lines = T, columns = 2) )

m0 <- aggregate(math ~ sex+year, data = dta, mean)
xyplot(math ~ year, groups = sex, data = m0, type="b",
        par.settings = standard.theme(color = F),
        auto.key = list(points = T, lines = T, columns = 2) )

5

Eight different physical measurements of 30 French girls were recorded from 4 to 15 years old. Explore various ways to display the data.
Source: Sempe, M., et al. (1987). Multivariate and longitudinal data on growing children: Presentation of the French auxiological survey. In J. Janssen, et al. (1987). Data analysis. The Ins and Outs of solving real problems (pp. 3-6). New York: Plenum Press.
Column 1: Weight in grams
Column 2: Height in mms
Column 3: Head to butt length in mms
Column 4: Head circumference in mms
Column 5: Chest circumference in mms
Column 6: Arm length in mms
Column 7: Calf length in mms
Column 8: Pelvis circumference in mms
Column 9: Age in years
Column 10: Girl ID

dir<-'http://titan.ccunix.ccu.edu.tw/~psycfs/dataM/Data/girlsGrowth.txt'
dta<-read.table(dir,h=T)
xyplot(Ht/10~age,data=dta,xlab="Age (in year)",ylab ="Height (in cm)",type=c("b"),groups=id,lwd=1.2,lty=3)

boxplot(Ht/10~age,data=dta,xlab="Age (in year)",ylab ="Height (in cm)")

boxplot(Wt/100~age,data=dta,xlab="Age (in year)",ylab ="Weight (in Kg)")

m<-aggregate(Wt~age,data=dta,mean)
xyplot(Wt/100~age,data=m,xlab="Age (in year)",ylab ="Weight (in Kg)",type=c("b","r"),par.settings = standard.theme(color = F))

6

our manager gave you a sales data on sevral products in a SAS format. Your task is to summarize and report the data in tables and graphs.
Source: Gupta, S. K. (2006). Data Management and Reporting Made Easy with SAS Learning Edition 2.0
Recode the region variable (1 to 4) by “Nothern”, “Southern”, “Eastern” and “Western”; the district variable (1 - 5) by “North East”, “South East”, “South West”, “North West”, “Central West”; the quater variable (1-4) by “1st”, “2nd”, “3rd”, “4th”; and the month variable (1-12) by “Jan”, “Feb”, etc. Set negative sales values to zero.

fLoc <- 'http://titan.ccunix.ccu.edu.tw/~psycfs/dataM/Data/sales.sas7bdat'
dta <- read.sas7bdat(fLoc)
xyplot(quantity~month|product,data=dta,groups=year,type="b",auto.key = list(space = "right"),layout = c(1, 3))

m<-aggregate(quantity~product+district,data=dta,sum)
barchart(quantity~product|(as.factor(district)),data=m,main="Quantity of each Product in different district",layout=c(3,1))