You have been given the following data from an upset client whose data scientists have all quit before they provided a summary of the results of a study they had conducted. The study looked at the effects of gender (male coded 0), handedness (i.e., left hand dominant coded 0), and age group (younger coded 0) on IQ.

The client has no idea how the study was conducted. Using the data below determine the type of study run, analyze the data properly, and write up the study design and conclusions in a concise and clear fashion.

Weekly_Lab_6=read.csv("C:/Users/jcolu/OneDrive/Documents/Harrisburg/Summer 2018/ANLY 510/Weekly Lab 6.csv")
Weekly_Lab_6
##    Handedness Gender AgeGroup Block Repetition  IQ
## 1           0      0        0     0          0  95
## 2           1      1        0     0          0 101
## 3           1      0        1     0          0 102
## 4           0      1        1     0          0  97
## 5           1      0        0     1          0 120
## 6           0      1        0     1          0  99
## 7           0      0        1     1          0  96
## 8           1      1        1     1          0 111
## 9           0      0        0     0          1 100
## 10          1      1        0     0          1 100
## 11          1      0        1     1          1 107
## 12          0      1        1     1          1  97
## 13          1      0        0     1          1 116
## 14          0      1        0     1          1 101
## 15          0      0        1     0          1  95
## 16          1      1        1     0          1 112

Summarize data

str(Weekly_Lab_6)
## 'data.frame':    16 obs. of  6 variables:
##  $ Handedness: int  0 1 1 0 1 0 0 1 0 1 ...
##  $ Gender    : int  0 1 0 1 0 1 0 1 0 1 ...
##  $ AgeGroup  : int  0 0 1 1 0 0 1 1 0 0 ...
##  $ Block     : int  0 0 0 0 1 1 1 1 0 0 ...
##  $ Repetition: int  0 0 0 0 0 0 0 0 1 1 ...
##  $ IQ        : int  95 101 102 97 120 99 96 111 100 100 ...

Data needs to be factorized

Weekly_Lab_6$Handedness=factor(Weekly_Lab_6$Handedness)
Weekly_Lab_6$Gender=factor(Weekly_Lab_6$Gender)
Weekly_Lab_6$AgeGroup=factor(Weekly_Lab_6$AgeGroup)
Weekly_Lab_6$Block=factor(Weekly_Lab_6$Block)
Weekly_Lab_6$Repetition=factor(Weekly_Lab_6$Repetition)
str(Weekly_Lab_6)
## 'data.frame':    16 obs. of  6 variables:
##  $ Handedness: Factor w/ 2 levels "0","1": 1 2 2 1 2 1 1 2 1 2 ...
##  $ Gender    : Factor w/ 2 levels "0","1": 1 2 1 2 1 2 1 2 1 2 ...
##  $ AgeGroup  : Factor w/ 2 levels "0","1": 1 1 2 2 1 1 2 2 1 1 ...
##  $ Block     : Factor w/ 2 levels "0","1": 1 1 1 1 2 2 2 2 1 1 ...
##  $ Repetition: Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 2 2 ...
##  $ IQ        : int  95 101 102 97 120 99 96 111 100 100 ...

Analyze relationship between IQ & Handedness

bartlett.test(Weekly_Lab_6$IQ,Weekly_Lab_6$Handedness)
## 
##  Bartlett test of homogeneity of variances
## 
## data:  Weekly_Lab_6$IQ and Weekly_Lab_6$Handedness
## Bartlett's K-squared = 7.5206, df = 1, p-value = 0.0061

Analyze relationship between IQ & Age group

bartlett.test(Weekly_Lab_6$IQ,Weekly_Lab_6$AgeGroup)
## 
##  Bartlett test of homogeneity of variances
## 
## data:  Weekly_Lab_6$IQ and Weekly_Lab_6$AgeGroup
## Bartlett's K-squared = 0.38713, df = 1, p-value = 0.5338

Analyze relationship between IQ & Gender

bartlett.test(Weekly_Lab_6$IQ,Weekly_Lab_6$Gender)
## 
##  Bartlett test of homogeneity of variances
## 
## data:  Weekly_Lab_6$IQ and Weekly_Lab_6$Gender
## Bartlett's K-squared = 1.513, df = 1, p-value = 0.2187

Since the P-value of Handedeness & IQ reflects low correlation, use tapply to see the differences in variance.

tapply(Weekly_Lab_6$IQ, Weekly_Lab_6$Handedness,var)
##         0         1 
##  5.142857 54.267857

Since variance is very large, the smallest observation must have -1 substracted. Then, a model can be established using the log of IQ.

Weekly_Lab_6$IQModel=log(Weekly_Lab_6$IQ-93)
Model_Weekly_Lab_6=aov(Weekly_Lab_6$IQModel~Weekly_Lab_6$Repetition+Weekly_Lab_6$Repetition/Weekly_Lab_6$Block+Weekly_Lab_6$Handedness*Weekly_Lab_6$Gender*Weekly_Lab_6$AgeGroup)
library(xtable)
## Warning: package 'xtable' was built under R version 3.4.4
New_Data=xtable(Model_Weekly_Lab_6)
New_Data
## % latex table generated in R 3.4.3 by xtable 1.8-2 package
## % Tue Jun 12 20:42:50 2018
## \begin{table}[ht]
## \centering
## \begin{tabular}{lrrrrr}
##   \hline
##  & Df & Sum Sq & Mean Sq & F value & Pr($>$F) \\ 
##   \hline
## Weekly\_Lab\_6\$Repetition & 1 & 0.11 & 0.11 & 0.78 & 0.4175 \\ 
##   Weekly\_Lab\_6\$Handedness & 1 & 6.32 & 6.32 & 44.12 & 0.0012 \\ 
##   Weekly\_Lab\_6\$Gender & 1 & 0.04 & 0.04 & 0.28 & 0.6173 \\ 
##   Weekly\_Lab\_6\$AgeGroup & 1 & 0.19 & 0.19 & 1.31 & 0.3044 \\ 
##   Weekly\_Lab\_6\$Repetition:Weekly\_Lab\_6\$Block & 2 & 1.29 & 0.65 & 4.51 & 0.0760 \\ 
##   Weekly\_Lab\_6\$Handedness:Weekly\_Lab\_6\$Gender & 1 & 0.46 & 0.46 & 3.18 & 0.1344 \\ 
##   Weekly\_Lab\_6\$Handedness:Weekly\_Lab\_6\$AgeGroup & 1 & 0.29 & 0.29 & 2.04 & 0.2128 \\ 
##   Weekly\_Lab\_6\$Gender:Weekly\_Lab\_6\$AgeGroup & 1 & 0.62 & 0.62 & 4.34 & 0.0917 \\ 
##   Weekly\_Lab\_6\$Handedness:Weekly\_Lab\_6\$Gender:Weekly\_Lab\_6\$AgeGroup & 1 & 0.11 & 0.11 & 0.76 & 0.4221 \\ 
##   Residuals & 5 & 0.72 & 0.14 &  &  \\ 
##    \hline
## \end{tabular}
## \end{table}

Search for residuals.

qqnorm(Model_Weekly_Lab_6$residuals)

Review relationship between Handedness & IQ relationship.

tapply(Weekly_Lab_6$IQModel,Weekly_Lab_6$Handedness,mean)
##        0        1 
## 1.384326 2.640972

Relationhip between IQ & Gender

tapply(Weekly_Lab_6$IQModel,Weekly_Lab_6$Gender,mean)
##        0        1 
## 1.962304 2.062994

Relationhip between IQ & Age Group

tapply(Weekly_Lab_6$IQModel,Weekly_Lab_6$AgeGroup,mean)
##        0        1 
## 2.120868 1.904430

Conclusions:

Based on the findings of the studies presented above, it can be concluded that:

  1. People who are right handed have a higher IQ than left handed
  2. Males have a higher IQ than females.
  3. The canditates of Older age have a higher IQ than the younger candidates.