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 PIPWD (Positive Identity as a Person With a Disability, Maturity, a Marker of Adulthood, and Support. Specifically, all three of these variables will have a significant positive correlation with one another.

4 Check Your Variables

str(d)
## 'data.frame':    768 obs. of  7 variables:
##  $ ResponseID      : chr  "R_12G7bIqN2wB2N65" "R_3lLnoV2mYVYHFvf" "R_1gTNDGWsqikPuEX" "R_2QLjdu3yoxqQ21c" ...
##  $ disability      : chr  "psychiatric" "other" "learning" "psychiatric" ...
##  $ income          : chr  "rather not say" "rather not say" "1 low" "rather not say" ...
##  $ support         : num  5.17 2.67 4.5 3.92 5.67 ...
##  $ pipwd           : num  2.33 2.33 3 2.93 3.33 ...
##  $ moa_independence: num  3.5 2.83 3.67 3.17 3.5 ...
##  $ moa_maturity    : num  3.67 2 4 3.67 4 ...
# 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, support, moa_maturity))

# 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 768 2.91 0.70   2.93    2.92 0.69 1.13   5  3.87  0.01
## support         2 768 5.32 1.22   5.58    5.44 1.11 0.00   7  7.00 -0.95
## moa_maturity    3 768 3.59 0.40   3.67    3.64 0.49 2.00   4  2.00 -0.97
##              kurtosis   se
## pipwd           -0.07 0.03
## support          0.75 0.04
## moa_maturity     0.78 0.01
# 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$support)

hist(d$moa_maturity)

# 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$support)

plot(d$support, d$moa_maturity)

plot(d$pipwd, d$moa_maturity)

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$support <- scale(d2$support, center=T, scale=T)
hist(d2$support)

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

sum(d2$moa_maturity < -3 | d2$moa_maturity > 3)
## [1] 11

5.2 Issues with My Data

One of my variables meet all of the assumptions of Pearson’s correlation coefficient. All of my variables were within the normal range of skew and kurtosis (-2,+2). Outliers can distort the relationship between two variables and sway the correlation in their direction. Two of my variables, Maturity and Support, have outliers in their data. Any correlations with Maturity and Support should be evaluated carefully due to these risks.

6 Run a Single Correlation

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

7 View Single Correlation

corr_output
## Call:corr.test(x = d2$pipwd, y = d2$support)
## Correlation matrix 
##      [,1]
## [1,] 0.29
## Sample Size 
## [1] 768
## These are the unadjusted probability values.
##   The probability values  adjusted for multiple tests are in the p.adj object. 
##      [,1]
## [1,]    0
## 
##  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 support moa_maturity
## pipwd         1.00    0.29         0.05
## support       0.29    1.00         0.09
## moa_maturity  0.05    0.09         1.00
## Sample Size 
## [1] 768
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##              pipwd support moa_maturity
## pipwd         0.00    0.00         0.16
## support       0.00    0.00         0.02
## moa_maturity  0.16    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 there will be a significant relationship between Positive Identity as a Person With a Disability (PIPWD), Maturity, and Support. Specifically, all three of these variables will have a significant positive correlation with one another, we calculated a series of Pearson’s correlation coefficients. One of the variables (PIPWD) met the required assumptions of the test, with it meeting the standards of normality and contained no outliers . Two variables, Support and Maturity, had outliers (7 and 11, respectively); so any significant results involving Support and Maturity should be evaluated carefully.

We found partial support for our hypothesis, being that two of the three correlations were significant (PIPWD and Support, and Support and Maturity; ps < 0.05). The correlation between PIPWD and Maturity was not significant (p=0.16). The effect sizes for the correlation between PIPWD and Support was weak (r > 0.10; Cohen, 1988). Two of the effect sizes of the correlations were trivial (PIPWD and Maturity and Support and Maturity) (r<0.09). Additionally, PIPWD was found to have a positive relationship with Support. Please refer to the correlations in table I.

Table 1: Means, standard deviations, and correlations with confidence intervals
Variable M SD 1 2
PIPWD 2.91 0.70
Support 5.32 1.22 .29**
[.22, .35]
Maturity 3.59 0.40 .05 .09*
[-.02, .12] [.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.