# remember, you might need to install packages
library(psych) # for the describe() command
library(expss) # for the cross_cases() command
Basic Statistics Lab
Load Libraries
Load Data
<- read.csv(file="Data/mydata.csv", header=T)
d names(d)
[1] "edeq12" "isolation" "support" "gad" "ethnicity" "education"
Univariate Plots: Histograms & Tables
table(d$ethnicity) #Update for HW!!!!!
Asian/Asian British - Indian, Pakistani, Bangladeshi, other
119
Black/Black British - Caribbean, African, other
23
Chinese/Chinese British
10
Middle Eastern/Middle Eastern British - Arab, Turkish, other
11
Mixed race - other
40
Mixed race - White and Black/Black British
20
Other ethnic group
10
Prefer not to say
23
White - British, Irish, other
948
table(d$education)
1 equivalent to not completing high school
343
2 equivalent to high school completion
352
3 equivalent to vocational/technical program completion
25
4 equivalent to AP/IB completion
147
5 undergraduate degree
146
6 graduate degree or higher
110
prefer not to say
81
hist(d$edeq12)
hist(d$isolation)
hist(d$support)
hist(d$gad)
Univariate Normality
Check skew and kurtosis.(how tall it is/cutoffs are -2 to +2, if skew or kurtosis are higher or lower than these vaules, i need to mention it in my writeup)
describe(d)
vars n mean sd median trimmed mad min max range skew kurtosis
edeq12 1 1204 1.89 0.73 1.75 1.83 0.74 1 4.0 3.0 0.67 -0.55
isolation 2 1204 2.15 0.84 2.00 2.12 1.11 1 3.5 2.5 0.15 -1.29
support 3 1204 3.57 0.95 3.67 3.63 0.99 1 5.0 4.0 -0.43 -0.56
gad 4 1204 2.05 0.91 1.71 1.96 0.85 1 4.0 3.0 0.67 -0.74
ethnicity* 5 1204 7.76 2.64 9.00 8.45 0.00 1 9.0 8.0 -1.89 1.86
education* 6 1204 3.05 1.98 2.00 2.85 1.48 1 7.0 6.0 0.61 -1.03
se
edeq12 0.02
isolation 0.02
support 0.03
gad 0.03
ethnicity* 0.08
education* 0.06
Bivariate Plots
Crosstabs
cross_cases(d, ethnicity, education)
education | |||||||
---|---|---|---|---|---|---|---|
1 equivalent to not completing high school | 2 equivalent to high school completion | 3 equivalent to vocational/technical program completion | 4 equivalent to AP/IB completion | 5 undergraduate degree | 6 graduate degree or higher | prefer not to say | |
ethnicity | |||||||
Asian/Asian British - Indian, Pakistani, Bangladeshi, other | 39 | 39 | 13 | 5 | 7 | 16 | |
Black/Black British - Caribbean, African, other | 10 | 6 | 4 | 1 | 1 | 1 | |
Chinese/Chinese British | 3 | 3 | 1 | 1 | 1 | 1 | |
Middle Eastern/Middle Eastern British - Arab, Turkish, other | 4 | 4 | 2 | 1 | |||
Mixed race - White and Black/Black British | 10 | 8 | 1 | 1 | |||
Mixed race - other | 20 | 11 | 4 | 4 | 1 | ||
Other ethnic group | 3 | 3 | 1 | 1 | 2 | ||
Prefer not to say | 7 | 6 | 1 | 1 | 8 | ||
White - British, Irish, other | 247 | 272 | 24 | 124 | 133 | 96 | 52 |
#Total cases | 343 | 352 | 25 | 147 | 146 | 110 | 81 |
Scatterplots
plot(d$edeq12, d$isolation,
main="Scatterplot of Eating Disorder Questionnare and Loneliness Scale",
xlab = "Eating Disorder Questionnare",
ylab = "Loneliness Scale")
plot(d$edeq12, d$support,
main="Scatterplot of Eating Disorder Questionnare and Social Support Measure",
xlab = "Eating Disorder Questionnare",
ylab = "Social Support Measure")
plot(d$edeq12, d$gad,
main="Scatterplot of Eating Disorder Questionnare and General Anxiety Disorder",
xlab = "Eating Disorder Questionnare",
ylab = "General Anxiety Disorder")
plot(d$isolation, d$support,
main="Scatterplot of Loneliness Scale and Social Support Measure",
xlab = "Loneliness Scale",
ylab = "Social Support Measure")
plot(d$isolation, d$gad,
main="Scatterplot of Loneliness Scale and General Anxiety Disorder",
xlab = "Loneliness Scale",
ylab = "General Anxiety Disorder")
plot(d$support, d$gad,
main="Scatterplot of Social Support Measure and General Anxiety Disorder",
xlab = "Social Support Measure",
ylab = "General Anxiety Disorder")
Boxplots
boxplot(data=d, edeq12~ethnicity,
main="Boxplot of Eating Disorder Questionnare and Race/Ethnicity
",
xlab = "Eating Disorder Questionnare",
ylab = "Race/Ethnicity")
boxplot(data=d, edeq12~education,
main="Boxplot of Eating Disorder Questionnare and Education Level",
xlab = "Eating Disorder Questionnare",
ylab = "Education Level")
Write-Up
Once again, you need to create a write-up reviewing the most important things you did here. Again, it should be suitable for inclusion in a manuscript. Make sure you include your review of skewness and kurtosis. I have given you two potential templates you can follow below, depending upon your needs – you should delete the other text in this section and only include your write-up.
If skew and kurtosis are good: We reviewed plots and descriptive statistics for our six chosen variables. All four of our continuous variables had skew and kurtosis within the accepted range (-2/+2).The categorial varaibles were ethnicity and education and the continuous varaibles were edeq12, isolation, support, and gad.