Q1:Are there gender differences in the three IQ scores?
讀取資料
dta <- read.table("C:/Users/PARENTCARECHILDREN/Desktop/2020-04-13-In-Class-4-Trellis/brainsize.txt", header = T)
head(dta)## Sbj Gender FSIQ VIQ PIQ Weight Height MRICount
## 1 1 Female 133 132 124 118 64.5 816932
## 2 2 Male 140 150 124 NA 72.5 1001121
## 3 3 Male 139 123 150 143 73.3 1038437
## 4 4 Male 133 129 128 172 68.8 965353
## 5 5 Female 137 132 134 147 65.0 951545
## 6 6 Female 99 90 110 146 69.0 928799
畫盒狀圖,跑t-test
##
## Welch Two Sample t-test
##
## data: FSIQ by Gender
## t = -0.40267, df = 37.892, p-value = 0.6895
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -18.68639 12.48639
## sample estimates:
## mean in group Female mean in group Male
## 111.9 115.0
##
## Welch Two Sample t-test
##
## data: VIQ by Gender
## t = -0.77262, df = 36.973, p-value = 0.4447
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -21.010922 9.410922
## sample estimates:
## mean in group Female mean in group Male
## 109.45 115.25
##
## Welch Two Sample t-test
##
## data: PIQ by Gender
## t = -0.1598, df = 37.815, p-value = 0.8739
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -15.72079 13.42079
## sample estimates:
## mean in group Female mean in group Male
## 110.45 111.60
Ans:There are no gender differences in the three IQ scores.
Q2:Is the relationship between height and weight gender dependent?
了解分布和回歸線
dta$Gender <- as.character(dta$Gender)
Male <- subset(dta, dta$Gender=="Male")
Female <- subset(dta, dta$Gender=="Female")
lm(formula =Weight ~ Height, Male)##
## Call:
## lm(formula = Weight ~ Height, data = Male)
##
## Coefficients:
## (Intercept) Height
## -6.279 2.420
##
## Call:
## lm(formula = Weight ~ Height, data = Female)
##
## Coefficients:
## (Intercept) Height
## -131.940 4.092
##
## Call:
## lm(formula = Weight + Height ~ Gender, data = dta)
##
## Residuals:
## Min 1Q Median 3Q Max
## -37.817 -16.567 2.983 13.308 38.035
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 202.965 4.462 45.490 < 2e-16 ***
## GenderMale 34.852 6.483 5.376 4.74e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 19.95 on 36 degrees of freedom
## (2 observations deleted due to missingness)
## Multiple R-squared: 0.4453, Adjusted R-squared: 0.4299
## F-statistic: 28.9 on 1 and 36 DF, p-value: 4.743e-06
Ans:身高&體種的關係,會因性別而有差異
Q3:Is the relationship between IQ and brainsize (as measured by MRIcount) gender dependent?
了解分布和回歸線
##
## Call:
## lm(formula = FSIQ + MRICount ~ Gender, data = dta)
##
## Residuals:
## Min 1Q Median 3Q Max
## -74893 -34603 -7286 19996 128676
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 862767 12502 69.008 < 2e-16 ***
## GenderMale 92204 17681 5.215 6.77e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 55910 on 38 degrees of freedom
## Multiple R-squared: 0.4171, Adjusted R-squared: 0.4018
## F-statistic: 27.19 on 1 and 38 DF, p-value: 6.774e-06
Ans:IQ&大腦體積的關係,會因性別而有差異