1 Loading Libraries

#install.packages("apaTables")
#install.packages("kableExtra")

library(psych) # for the describe() command and the corr.test() command
library(apaTables) # to create our correlation table
library(kableExtra) # to create our correlation table

2 Importing Data

d <- read.csv(file="Data/projectdata.csv", header=T)

# For HW, import the your project dataset you cleaned previously; this will be the dataset you'll use throughout the rest of the semester

3 State Your Hypothesis

There will be a significant relationship between Positive Identity as a Person with a Disability, Independence, and Multidimensional Scale of Perceived Social Support. Specifically, all three variables will be positively related

4 Check Your Variables

str(d)
## 'data.frame':    773 obs. of  7 variables:
##  $ ResponseID      : chr  "R_12G7bIqN2wB2N65" "R_3lLnoV2mYVYHFvf" "R_1gTNDGWsqikPuEX" "R_2QLjdu3yoxqQ21c" ...
##  $ gender          : chr  "m" "f" "f" "f" ...
##  $ disability      : chr  "psychiatric" "other" "learning" "psychiatric" ...
##  $ pipwd           : num  2.33 2.33 3 2.93 3.33 ...
##  $ moa_independence: num  3.5 2.83 3.67 3.17 3.5 ...
##  $ belong          : num  3.6 2.4 3 3.3 2.7 3.8 2.6 3.8 2.4 3.1 ...
##  $ support         : num  5.17 2.67 4.5 3.92 5.67 ...
# Since we're focusing only on our continuous variables, we're going to subset them into their own dataframe. This will make some stuff we're doing later on easier.

d2 <- subset(d, select=c(pipwd, moa_independence, support))

# You can use the describe() command on an entire dataframe (d) or just on a single variable (d$pss)

describe(d2)
##                  vars   n mean   sd median trimmed  mad  min max range  skew
## pipwd               1 773 2.91 0.70   2.93    2.92 0.69 1.13   5  3.87  0.01
## moa_independence    2 773 3.48 0.46   3.50    3.53 0.49 1.50   4  2.50 -1.19
## support             3 773 5.31 1.23   5.58    5.44 1.11 0.00   7  7.00 -0.95
##                  kurtosis   se
## pipwd               -0.06 0.03
## moa_independence     1.78 0.02
## support              0.75 0.04
# also use histograms to examine your continuous variables
# Because we are looking at 3 variables, we will have 3 histograms.

hist(d$pipwd)

hist(d$moa_independence)

hist(d$support)

# last, use scatterplots to examine your continuous variables together, for each pairing
# because we are looking at 3 variables, we will have 3 pairings/plots. 

plot(d$pipwd, d$moa_independence)

plot(d$pipwd, d$support)

plot(d$moa_independence, d$support)

5 Check Your Assumptions

5.1 Pearson’s Correlation Coefficient Assumptions

  • Should have all measurements for each participant.
  • Variables should be continuous and normally distributed.
  • Outliers should be identified and removed.
  • Relationship between the variables should be linear.

5.1.1 Checking for Outliers

Note: For correlations, you will NOT screen out outliers or take any action based on what you see here. This is something you will simply check and then discuss in your write-up. We will learn how to removed outliers in later analyses.

# We are going to standardize (z-score) all of our 3 variables, and check them for outliers.

d2$pipwd <- scale(d2$pipwd, center=T, scale=T)
hist(d2$pipwd)

sum(d2$pipwd < -3 | d2$pipwd > 3)
## [1] 0
d2$moa_independence <- scale(d2$moa_independence, center=T, scale=T)
hist(d2$moa_independence)

sum(d2$moa_independence < -3 | d2$moa_independence > 3)
## [1] 12
d2$support <- scale(d2$support, center=T, scale=T)
hist(d2$support)

sum(d2$support < -3 | d2$support > 3)
## [1] 7

5.2 Issues with My Data

All of my variables meet all of the assumptions of Pearson’s correlation coefficient. However, all of my variables have outliers. Positive Identity has 334, Independence has 633, and social support has 731. Outliers can distort the relationship between two variables and sway the correlation in their direction. It seems like all my relationships were linear, which is good.

6 Run a Single Correlation

corr_output <- corr.test(d2$pipwd, d2$moa_independence)

7 View Single Correlation

corr_output
## Call:corr.test(x = d2$pipwd, y = d2$moa_independence)
## Correlation matrix 
##      [,1]
## [1,] 0.08
## Sample Size 
## [1] 773
## These are the unadjusted probability values.
##   The probability values  adjusted for multiple tests are in the p.adj object. 
##      [,1]
## [1,] 0.03
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option

8 Create a Correlation Matrix

corr_output_m <- corr.test(d2)

9 View Test Output

corr_output_m
## Call:corr.test(x = d2)
## Correlation matrix 
##                  pipwd moa_independence support
## pipwd             1.00             0.08    0.29
## moa_independence  0.08             1.00    0.09
## support           0.29             0.09    1.00
## Sample Size 
## [1] 773
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##                  pipwd moa_independence support
## pipwd             0.00             0.03    0.00
## moa_independence  0.03             0.00    0.02
## support           0.00             0.01    0.00
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option
# Remember to report the p-values from the matrix that are ABOVE the diagonal!

Remember, Pearson’s r is also an effect size! We don’t report effect sizes for non-sig correlations.

  • Strong: Between |0.50| and |1|
  • Moderate: Between |0.30| and |0.49|
  • Weak: Between |0.10| and |0.29|
  • Trivial: Less than |0.09|

10 Write Up Results

To test our hypothesis that Positive Identity for a Person with a Disability, Social Support, and Independence would be correlated with one another, we calculated a series of Pearson’s correlation coefficients. All of the variables with met the assumptions of the Pearson’s t-test, with all meeting the standards of normality. However, they did all contain outliers, which is just something to note and not something we are taking action on right now.

As predicted, we found that all three were significantly correlated (all ps < .05). The effect sizes of Positive Identity and Independence and Support and Independence were trivial (rs > .09; Cohen, 1988). However, positive identity and social support were weakly correlated (r > .29). However, all of them were positively correlated. Please refer to the correlation coefficients reported in Table 1.

Table 1: Means, standard deviations, and correlations with confidence intervals
Variable M SD 1 2
Positive Identity of a Person with a Disability 2.91 0.70
Independence 3.48 0.46 .08*
[.01, .15]
Support 5.31 1.23 .29** .09**
[.22, .35] [.02, .16]
Note:
M and SD are used to represent mean and standard deviation, respectively. Values in square brackets indicate the 95% confidence interval. The confidence interval is a plausible range of population correlations that could have caused the sample correlation.
* indicates p < .05
** indicates p < .01.

References

Cohen J. (1988). Statistical Power Analysis for the Behavioral Sciences. New York, NY: Routledge Academic.