Load Data Package
install.packages("https://cran.rstudio.com/bin/windows/contrib/4.1/faraway_1.0.7.zip", repos = NULL)
## 將程式套件安載入 'C:/Users/user/Documents/R/win-library/4.1'
## (因為 'lib' 沒有被指定)
## package 'faraway' successfully unpacked and MD5 sums checked
Load Data Library
library(faraway)
## Warning: 套件 'faraway' 是用 R 版本 4.1.3 來建造的
library(lattice)
##
## 載入套件:'lattice'
## 下列物件被遮斷自 'package:faraway':
##
## melanoma
Load Data
data("hormone")
Data Structure
str(hormone)
## 'data.frame': 26 obs. of 3 variables:
## $ androgen : num 3.9 4 3.8 3.9 2.9 3.2 4.6 4.3 3.1 2.7 ...
## $ estrogen : num 1.8 2.3 2.3 2.5 1.3 1.7 3.4 3.1 1.8 1.5 ...
## $ orientation: Factor w/ 2 levels "g","s": 2 2 2 2 2 2 2 2 2 2 ...
Sex Orientation 分布
table(hormone$orientation)
##
## g s
## 15 11
Gay 15 people Straight 11 people
Gay 和 Straight 在androgen and estrogen的mean
with(hormone, aggregate(hormone[, 1:2], by = list(orientation), FUN = mean))
## Group.1 androgen estrogen
## 1 g 2.500000 3.24
## 2 s 3.518182 2.10
Gay 和 Straight 在androgen and estrogen的sd
with(hormone, aggregate(hormone[, 1:2], by = list(orientation), FUN = sd))
## Group.1 androgen estrogen
## 1 g 0.9227289 1.2443013
## 2 s 0.7208581 0.6899275
Gay and Straight 在 androgen 上的分布
densityplot(~ androgen, groups = orientation, data = hormone, xlab = 'androgen level', lty = c(1,2), plot.points = F, type = "g", , main = 'androgen (s = 虛線, g = 實線)')
qq(orientation ~ androgen, data = hormone, type = c('r', 'g'), pch = '.', aspect = 1, xlab = 'Gay', ylab = 'Straight', main = 'Androgen')
Average Straight man has higher level of androgen than Gay man Gay and Straight 在 estrogen 上的分布
densityplot(~ estrogen, groups = orientation, data = hormone, xlab = 'estrogen level', lty = c(1,2), plot.points = F, type = "g", , main = 'estrogen (s = 虛線, g = 實線)')
qq(orientation ~ estrogen, data = hormone, type = c('r', 'g'), pch = '.', aspect = 1, xlab = 'Gay', ylab = 'Straight', main = 'Estrogen')
Average Straight man has lower level of estrogen than Gay man Gay and Straight/ estrogen and androgen relation
xyplot(androgen ~ estrogen | orientation, data = hormone, xlab = 'estrogen', ylab = 'androgen',
type = c("g", "p", "r"), cex = 0.1, layout = c(4, 1))
Straight man has higher ratio of androgen/estrogen than Gay man Androgen is related to regulating the development and maintenance of male characteristics
As Estrogen is responsible for the development and regulation of the female reproductive system and secondary sex characteristics
Thus the result of Straight man averaging higher Androgen and Gay man averaging higher Estrogen might explain the different behavior and orientation preferences