-
Notifications
You must be signed in to change notification settings - Fork 0
/
analysis.Rmd
114 lines (77 loc) · 2.53 KB
/
analysis.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
---
title: "CTN Openness"
author: "Deb Lindsay"
date: "`r Sys.Date()`"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(
echo = TRUE,
message = FALSE,
warning = FALSE
)
#required packages
library(tidyverse)
library(Hmisc) #correlations
library(car) #VIF assumptions & allows type II Anova
library(relaimpo) #calculates the R2 & Beta2 for the regression
library(effectsize) #calculate the Beta2 effect size
#import the clean data set
data <-
read_csv("clean_data.csv")
```
## Assumptions for running regressions
Linear Regression Assumptions
- Normality of predictors (Shapiro Wilkes test)
- Use shapiro.test()
- Should be non-significant (there is no skewedness)
```{r Shapiro Wilk}
#Openness
shapiro.test(data$openness)
#non-normal
data %>%
ggplot()+
geom_density(aes(openness))
#CTN Overall
shapiro.test(data$CTN_overall)
#CTN Deep
#CTN Experience
#CTN Emotional
#CTN Presence
```
# Hypothesis 1 - Positive relationship between trait openness and overall CTN.
```{r H1 }
#Linear regression predicting openness from CTN
# Openness ~ CTN
#outcome variable ~ predictor variable
# lm() to run the linear regression
h1_model <-
lm(openness_z ~ CTN_overall_z, data = data)
# Anova() to calculate the F value and significance
Anova(h1_model)
# summary() to calculate the variance accounted for by the model (in this case the single variable CTN overall)
summary(h1_model)
#effect size (Beta sq)
effectsize(h1_model)
#plot relationship
data %>%
ggplot(aes(x = CTN_overall_z, y = openness_z)) +
geom_jitter() +
geom_smooth(method = "lm")
```
```{r H2}
# Muiltiple Linear regression predicting openness from all four dimensions of DEEP CTN
# Openness ~ Deep + Experience + Emotional + Presence
#outcome variable ~ predictor variables (use + to add additional predictors)
# lm() to run the linear regression
h2_model <-
lm(openness_z ~ CTN_Deep_z + CTN_Exp_z + CTN_Emo_z + CTN_Pres_z, data = data)
# Anova() to calculate the variance accounted for by CTN
#use Type II to calcaulte the variance equally among variables (otherwise the model will calculate the variance by the order they are in the model)
Anova(h2_model, Type = "II")
# calc.relimpo() to calculate the unique variance & effect size (Beta sq)
# type = lmg gives teh unique R2 (variance) of each variable in the model
calc.relimp(h2_model, type = "lmg")
# plot effect sizes
# create table
```