Copy and paste your R code and output into a word document to submit to Canvas.
ID: 3357201 • Letter: C
Question
Copy and paste your R code and output into a word document to submit to Canvas. Follow these instructions to import the necessary dataset:
Before opening the dataset needed for this problem, you’ll need to call the “car” package (if you didn’t install this package on your computer for Lab 6, see the Lab 6 Handout for directions on how to install it). Run the following line of code:
> library(car)
Now you can import the “Wong” dataset and use it to answer the question below. Name the data frame with your UT EID:
> my_eid <- Wong
The Wong dataset contains data from a study by Wong, Monette, and Weiner (2001) on a sample of patients who fell into comas after sustaining traumatic brain injuries. After waking, Wong and colleagues administered various intelligence tests, including the performance IQ (“piq”) and verbal IQ (“viq”) tests, both measured on the same scale with higher numbers indicating higher intelligence.
You want to see if there is a difference between performance IQ and verbal IQ for coma patients who are 30 years or older. Create a subset of this dataset that contains patients who are at least 30 years old and call it “Patients30.” (1pt)
> Patients30 <- ...
Run the appropriate analysis to answer your question, including all steps for full credit. (4pt)
Explanation / Answer
I am pasting the R code and output below. The R code is accompanied with comment lines, where I have provided a brief explanation of the R commands that I have used in the code.
The R code is as given below.
# INSTALLING THE 'CAR' PACKAGE
install.packages("car")
# LOADING THE 'CAR' PACKAGE INTO THE SYSTEM AND LOADING THE DATASET
library(car)
my_eid=Wong
# SUBSETTING THE DATASET TO EXTRACT THE PATIENTS WHO ARE 30 YEARS OR OLDER
Patients30=subset(my_eid,age >= 30,select=c(age,piq,viq))
# PAIRED T-TEST ON THE "PIQ" AND "VIQ" SCORES OF THE EXTRACTED PATIENTS
attach(Patients30)
t.test(piq,viq,paired=T,alternative="two.sided")
The output that I have obtained after carrying out the paired t-test on the "piq" and "viq" scores of the patients who are 30 years or older is as given below.
Paired t-test
data: piq and viq
t = -8.4121, df = 132, p-value = 5.756e-14
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-8.794636 -5.445966
sample estimates:
mean of the differences
-7.120301
From the output of the paired t-test, we see that the p-value is less than alpha = level of significance = 0.05. Hence, we reject the null hypothesis (H0 : no difference between piq and viq scores of patients who are 30 years or older) and conclude that THERE IS A DIFFERENCE between the performance IQ and verbal IQ scores for coma patients who are 30 years or older.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.