## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.2     ✓ purrr   0.3.4
## ✓ tibble  3.0.4     ✓ dplyr   1.0.2
## ✓ tidyr   1.1.2     ✓ stringr 1.4.0
## ✓ readr   1.4.0     ✓ forcats 0.5.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
## 
## Attaching package: 'kableExtra'
## The following object is masked from 'package:dplyr':
## 
##     group_rows
## Loading required package: Matrix
## 
## Attaching package: 'Matrix'
## The following objects are masked from 'package:tidyr':
## 
##     expand, pack, unpack
## Registered S3 methods overwritten by 'car':
##   method                          from
##   influence.merMod                lme4
##   cooks.distance.influence.merMod lme4
##   dfbeta.influence.merMod         lme4
##   dfbetas.influence.merMod        lme4
## ************
## Welcome to afex. For support visit: http://afex.singmann.science/
## - Functions for ANOVAs: aov_car(), aov_ez(), and aov_4()
## - Methods for calculating p-values with mixed(): 'KR', 'S', 'LRT', and 'PB'
## - 'afex_aov' and 'mixed' objects can be passed to emmeans() for follow-up tests
## - NEWS: library('emmeans') now needs to be called explicitly!
## - Get and set global package options with: afex_options()
## - Set orthogonal sum-to-zero contrasts globally: set_sum_contrasts()
## - For example analyses see: browseVignettes("afex")
## ************
## 
## Attaching package: 'afex'
## The following object is masked from 'package:lme4':
## 
##     lmer

#Data Preparation

##Load Data

## 
## ── Column specification ────────────────────────────────────────────────────────
## cols(
##   .default = col_double(),
##   t1_gender_4_TEXT = col_logical(),
##   t1_ethnicity_8_TEXT = col_character(),
##   t1_religion_11_TEXT = col_character(),
##   t1_job_and_industry_1 = col_character(),
##   t1_job_and_industry_2 = col_character(),
##   t1_debrief_purpose = col_character(),
##   t1_debrief_glitch = col_character(),
##   t1_debrief_else = col_character(),
##   t2_full_vid1_q1 = col_character(),
##   t2_full_vid2_q1 = col_character(),
##   t2_full_vid2_q2 = col_character(),
##   t2_full_vid3_q1 = col_character(),
##   t2_full_vid3_q2 = col_character(),
##   t2_full_vid4_q1 = col_character(),
##   t2_full_vid4_q2 = col_character(),
##   t2_full_vid5_q2 = col_character(),
##   t2_abr_introvid_q1 = col_character(),
##   t2_abr_exvid_q1 = col_character(),
##   t2_abr_exvid_q2 = col_character(),
##   t2_abr_strvid_q1 = col_character()
##   # ... with 15 more columns
## )
## ℹ Use `spec()` for the full column specifications.

How many people did we have?

d.study %>%
  group_by(condition)%>%
  summarise(n=n()) %>%
  kable(digits = 2, caption = "Participants Per Task")
## `summarise()` ungrouping output (override with `.groups` argument)
Participants Per Task
condition n
abr_intervention 112
active_control 107
full_intervention 105

======

#Confirmatory Analyses

##H1 - SFMM

Let’s tidy the data

d_sfmm <- d.study %>%
  select(subid_final, condition, sfmm_all9_t1_score, sfmm_all9_t2_score)%>%
  gather(item, score, contains("sfmm"))%>%
  separate(item, sep = "_", into = c("construct_name", "type", "time", "score_name"))%>%
  select(-construct_name, -score_name, -type)

Let’s change data to be numeric & factors (and appropriate contrasts)

#Make Rating Numeric

d_sfmm$score <- as.numeric(d_sfmm$score)

#Factor Condition
d_sfmm$condition <- as.factor(d_sfmm$condition)
contrasts(d_sfmm$condition)
##                   active_control full_intervention
## abr_intervention               0                 0
## active_control                 1                 0
## full_intervention              0                 1
contrasts(d_sfmm$condition) = cbind(dummy_full_vs_control = c(0,0,1), dummy_abridged_vs_control = c(1,0,0))
contrasts(d_sfmm$condition)
##                   dummy_full_vs_control dummy_abridged_vs_control
## abr_intervention                      0                         1
## active_control                        0                         0
## full_intervention                     1                         0
#Factor Time
d_sfmm$time <- as.factor(d_sfmm$time)
contrasts(d_sfmm$time)
##    t2
## t1  0
## t2  1
contrasts(d_sfmm$time) = cbind(dummy_t2_vs_t1 = c(0,1))
contrasts(d_sfmm$time)
##    dummy_t2_vs_t1
## t1              0
## t2              1
#Factor subject id

d_sfmm$subid_final <- as.factor(d_sfmm$subid_final)

Interaction

summary(lmer(score ~ time*condition + (1 | subid_final), data = d_sfmm))
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: score ~ time * condition + (1 | subid_final)
##    Data: d_sfmm
## 
## REML criterion at convergence: 1163.3
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.88861 -0.47875  0.06395  0.50270  2.50306 
## 
## Random effects:
##  Groups      Name        Variance Std.Dev.
##  subid_final (Intercept) 0.2523   0.5023  
##  Residual                0.1736   0.4167  
## Number of obs: 648, groups:  subid_final, 324
## 
## Fixed effects:
##                                                         Estimate Std. Error
## (Intercept)                                            4.717e+00  6.309e-02
## timedummy_t2_vs_t1                                    -1.807e-14  5.697e-02
## conditiondummy_full_vs_control                        -1.684e-01  8.965e-02
## conditiondummy_abridged_vs_control                    -1.014e-01  8.822e-02
## timedummy_t2_vs_t1:conditiondummy_full_vs_control      1.979e-01  8.095e-02
## timedummy_t2_vs_t1:conditiondummy_abridged_vs_control  2.391e-01  7.966e-02
##                                                               df t value
## (Intercept)                                            4.753e+02  74.760
## timedummy_t2_vs_t1                                     3.210e+02   0.000
## conditiondummy_full_vs_control                         4.753e+02  -1.878
## conditiondummy_abridged_vs_control                     4.753e+02  -1.150
## timedummy_t2_vs_t1:conditiondummy_full_vs_control      3.210e+02   2.445
## timedummy_t2_vs_t1:conditiondummy_abridged_vs_control  3.210e+02   3.001
##                                                       Pr(>|t|)    
## (Intercept)                                             <2e-16 ***
## timedummy_t2_vs_t1                                      1.0000    
## conditiondummy_full_vs_control                          0.0610 .  
## conditiondummy_abridged_vs_control                      0.2508    
## timedummy_t2_vs_t1:conditiondummy_full_vs_control       0.0150 *  
## timedummy_t2_vs_t1:conditiondummy_abridged_vs_control   0.0029 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##                               (Intr) tm_2__1 cndtndmmy_f__ cndtndmmy_b__
## tmdmmy_2__1                   -0.451                                    
## cndtndmmy_f__                 -0.704  0.318                             
## cndtndmmy_b__                 -0.715  0.323   0.503                     
## tmdmmy_t2_vs_t1:cndtndmmy_f__  0.318 -0.704  -0.451        -0.227       
## tmdmmy_t2_vs_t1:cndtndmmy_b__  0.323 -0.715  -0.227        -0.451       
##                               tmdmmy_t2_vs_t1:cndtndmmy_f__
## tmdmmy_2__1                                                
## cndtndmmy_f__                                              
## cndtndmmy_b__                                              
## tmdmmy_t2_vs_t1:cndtndmmy_f__                              
## tmdmmy_t2_vs_t1:cndtndmmy_b__  0.503

##Descriptives

d_sfmm %>%
  ungroup()%>%
  group_by(subid_final, condition, time) %>%
  summarise(mean_score = mean(score))%>%
  group_by(condition, time)%>%
  summarise(mean = mean(mean_score),
              sd = sd(mean_score)) %>%
  kable(digits = 2)
## `summarise()` regrouping output by 'subid_final', 'condition' (override with `.groups` argument)
## `summarise()` regrouping output by 'condition' (override with `.groups` argument)
condition time mean sd
abr_intervention t1 4.62 0.59
abr_intervention t2 4.85 0.62
active_control t1 4.72 0.61
active_control t2 4.72 0.67
full_intervention t1 4.55 0.69
full_intervention t2 4.75 0.73

##Intelligence Mindset

Let’s tidy the data

d_mindset_intelligence <- d.study %>%
  select(subid_final, condition, mndst_intelligence_t1_score, mndst_intelligence_t2_score)%>%
  gather(item, score, contains("intelligence"))%>%
  separate(item, sep = "_", into = c("construct_name", "type", "time", "score_name"))%>%
  select(-construct_name, -score_name, -type)

Let’s change data to be numeric & factors (and appropriate contrasts)

#Make Rating Numeric

d_mindset_intelligence$score <- as.numeric(d_mindset_intelligence$score)

#Factor Condition
d_mindset_intelligence$condition <- as.factor(d_mindset_intelligence$condition)
contrasts(d_mindset_intelligence$condition)
##                   active_control full_intervention
## abr_intervention               0                 0
## active_control                 1                 0
## full_intervention              0                 1
contrasts(d_mindset_intelligence$condition) = cbind(dummy_full_vs_control = c(0,0,1), dummy_abridged_vs_control = c(1,0,0))
contrasts(d_mindset_intelligence$condition)
##                   dummy_full_vs_control dummy_abridged_vs_control
## abr_intervention                      0                         1
## active_control                        0                         0
## full_intervention                     1                         0
#Factor Time
d_mindset_intelligence$time <- as.factor(d_mindset_intelligence$time)
contrasts(d_mindset_intelligence$time)
##    t2
## t1  0
## t2  1
contrasts(d_mindset_intelligence$time) = cbind(dummy_t2_vs_t1 = c(0,1))
contrasts(d_mindset_intelligence$time)
##    dummy_t2_vs_t1
## t1              0
## t2              1
#Factor subject id

d_mindset_intelligence$subid_final <- as.factor(d_mindset_intelligence$subid_final)

Analysis

#Analysis
summary(lmer(score ~ time*condition + (1 | subid_final), data = d_mindset_intelligence))
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: score ~ time * condition + (1 | subid_final)
##    Data: d_mindset_intelligence
## 
## REML criterion at convergence: 1436.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.3736 -0.3948 -0.0251  0.3622  4.2113 
## 
## Random effects:
##  Groups      Name        Variance Std.Dev.
##  subid_final (Intercept) 0.4666   0.6831  
##  Residual                0.2361   0.4859  
## Number of obs: 648, groups:  subid_final, 324
## 
## Fixed effects:
##                                                        Estimate Std. Error
## (Intercept)                                             3.62617    0.08104
## timedummy_t2_vs_t1                                      0.06542    0.06643
## conditiondummy_full_vs_control                         -0.09522    0.11515
## conditiondummy_abridged_vs_control                     -0.02126    0.11332
## timedummy_t2_vs_t1:conditiondummy_full_vs_control       0.13815    0.09440
## timedummy_t2_vs_t1:conditiondummy_abridged_vs_control   0.00266    0.09289
##                                                              df t value
## (Intercept)                                           445.54554  44.745
## timedummy_t2_vs_t1                                    321.00001   0.985
## conditiondummy_full_vs_control                        445.54554  -0.827
## conditiondummy_abridged_vs_control                    445.54554  -0.188
## timedummy_t2_vs_t1:conditiondummy_full_vs_control     321.00001   1.464
## timedummy_t2_vs_t1:conditiondummy_abridged_vs_control 321.00001   0.029
##                                                       Pr(>|t|)    
## (Intercept)                                             <2e-16 ***
## timedummy_t2_vs_t1                                       0.325    
## conditiondummy_full_vs_control                           0.409    
## conditiondummy_abridged_vs_control                       0.851    
## timedummy_t2_vs_t1:conditiondummy_full_vs_control        0.144    
## timedummy_t2_vs_t1:conditiondummy_abridged_vs_control    0.977    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##                               (Intr) tm_2__1 cndtndmmy_f__ cndtndmmy_b__
## tmdmmy_2__1                   -0.410                                    
## cndtndmmy_f__                 -0.704  0.288                             
## cndtndmmy_b__                 -0.715  0.293   0.503                     
## tmdmmy_t2_vs_t1:cndtndmmy_f__  0.288 -0.704  -0.410        -0.206       
## tmdmmy_t2_vs_t1:cndtndmmy_b__  0.293 -0.715  -0.206        -0.410       
##                               tmdmmy_t2_vs_t1:cndtndmmy_f__
## tmdmmy_2__1                                                
## cndtndmmy_f__                                              
## cndtndmmy_b__                                              
## tmdmmy_t2_vs_t1:cndtndmmy_f__                              
## tmdmmy_t2_vs_t1:cndtndmmy_b__  0.503

Let’s plot!

#Summarize
d_mindset_intelligence_summ <- d_mindset_intelligence %>%
  group_by(condition, time) %>%
  summarise(mean_rating = mean(score),
            ci_rating = ci(score))
## `summarise()` regrouping output by 'condition' (override with `.groups` argument)
#Change levels
d_mindset_intelligence_summ$time <- factor(d_mindset_intelligence_summ$time, levels = c("t1", "t2"))


#Plot
ggplot(d_mindset_intelligence_summ,
       aes(x=time,
           y=mean_rating, 
           fill = condition))+
  geom_bar(stat="identity", position = "dodge")+
  geom_errorbar(aes(ymin = (mean_rating - ci_rating), ymax = (mean_rating + ci_rating)),width = 0.2, position = position_dodge(width = 0.9))+
  labs(x = "", 
       y = "Agreement (adj)  \n 1 = Strongly disagree to 7 = Strongly agree",
       title = "Mindset -- Intelligence",
       caption = "95% confidence intervals") +
  ggthemes::theme_few()+
  coord_cartesian(ylim=c(1,7))+
  theme(plot.caption =element_text(size=10),
        axis.text=element_text(size=14),
        axis.title = element_text(size=14),
        #axis.text.x=element_blank(),
        title =  element_text(size=15))

##Descriptives

d_mindset_intelligence %>%
  ungroup()%>%
  group_by(subid_final, condition, time) %>%
  summarise(mean_score = mean(score))%>%
  group_by(condition, time)%>%
  summarise(mean = mean(mean_score),
              sd = sd(mean_score)) %>%
  kable(digits = 2)
## `summarise()` regrouping output by 'subid_final', 'condition' (override with `.groups` argument)
## `summarise()` regrouping output by 'condition' (override with `.groups` argument)
condition time mean sd
abr_intervention t1 3.60 0.87
abr_intervention t2 3.67 0.88
active_control t1 3.63 0.77
active_control t2 3.69 0.85
full_intervention t1 3.53 0.82
full_intervention t2 3.73 0.84

Personality

d_mindset_personality <- d.study %>%
  select(subid_final, condition, mndst_pers_t1_score, mndst_pers_t2_score)%>%
  gather(item, score, contains("pers"))%>%
  separate(item, sep = "_", into = c("construct_name", "type", "time", "score_name"))%>%
  select(-construct_name, -score_name, -type)

Let’s change data to be numeric & factors (and appropriate contrasts)

#Make Rating Numeric

d_mindset_personality$score <- as.numeric(d_mindset_personality$score)

#Factor Condition
d_mindset_personality$condition <- as.factor(d_mindset_personality$condition)
contrasts(d_mindset_personality$condition)
##                   active_control full_intervention
## abr_intervention               0                 0
## active_control                 1                 0
## full_intervention              0                 1
contrasts(d_mindset_personality$condition) = cbind(dummy_full_vs_control = c(0,0,1), dummy_abridged_vs_control = c(1,0,0))
contrasts(d_mindset_personality$condition)
##                   dummy_full_vs_control dummy_abridged_vs_control
## abr_intervention                      0                         1
## active_control                        0                         0
## full_intervention                     1                         0
#Factor Time
d_mindset_personality$time <- as.factor(d_mindset_personality$time)
contrasts(d_mindset_personality$time)
##    t2
## t1  0
## t2  1
contrasts(d_mindset_personality$time) = cbind(dummy_t2_vs_t1 = c(0,1))
contrasts(d_mindset_personality$time)
##    dummy_t2_vs_t1
## t1              0
## t2              1
#Factor subject id

d_mindset_personality$subid_final <- as.factor(d_mindset_personality$subid_final)

Analysis

#Analysis
summary(lmer(score ~ time*condition + (1 | subid_final), data = d_mindset_personality))
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: score ~ time * condition + (1 | subid_final)
##    Data: d_mindset_personality
## 
## REML criterion at convergence: 1670.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.0158 -0.3224 -0.0108  0.3458  4.9215 
## 
## Random effects:
##  Groups      Name        Variance Std.Dev.
##  subid_final (Intercept) 0.6872   0.8290  
##  Residual                0.3348   0.5786  
## Number of obs: 648, groups:  subid_final, 324
## 
## Fixed effects:
##                                                        Estimate Std. Error
## (Intercept)                                             4.10514    0.09773
## timedummy_t2_vs_t1                                      0.02921    0.07911
## conditiondummy_full_vs_control                         -0.09085    0.13887
## conditiondummy_abridged_vs_control                      0.10133    0.13666
## timedummy_t2_vs_t1:conditiondummy_full_vs_control       0.22079    0.11241
## timedummy_t2_vs_t1:conditiondummy_abridged_vs_control   0.15048    0.11062
##                                                              df t value
## (Intercept)                                           442.10832  42.004
## timedummy_t2_vs_t1                                    321.00000   0.369
## conditiondummy_full_vs_control                        442.10832  -0.654
## conditiondummy_abridged_vs_control                    442.10832   0.741
## timedummy_t2_vs_t1:conditiondummy_full_vs_control     321.00000   1.964
## timedummy_t2_vs_t1:conditiondummy_abridged_vs_control 321.00000   1.360
##                                                       Pr(>|t|)    
## (Intercept)                                             <2e-16 ***
## timedummy_t2_vs_t1                                      0.7122    
## conditiondummy_full_vs_control                          0.5133    
## conditiondummy_abridged_vs_control                      0.4588    
## timedummy_t2_vs_t1:conditiondummy_full_vs_control       0.0504 .  
## timedummy_t2_vs_t1:conditiondummy_abridged_vs_control   0.1747    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##                               (Intr) tm_2__1 cndtndmmy_f__ cndtndmmy_b__
## tmdmmy_2__1                   -0.405                                    
## cndtndmmy_f__                 -0.704  0.285                             
## cndtndmmy_b__                 -0.715  0.289   0.503                     
## tmdmmy_t2_vs_t1:cndtndmmy_f__  0.285 -0.704  -0.405        -0.204       
## tmdmmy_t2_vs_t1:cndtndmmy_b__  0.289 -0.715  -0.204        -0.405       
##                               tmdmmy_t2_vs_t1:cndtndmmy_f__
## tmdmmy_2__1                                                
## cndtndmmy_f__                                              
## cndtndmmy_b__                                              
## tmdmmy_t2_vs_t1:cndtndmmy_f__                              
## tmdmmy_t2_vs_t1:cndtndmmy_b__  0.503
d_mindset_personality %>%
  ungroup()%>%
  group_by(subid_final, condition, time) %>%
  summarise(mean_score = mean(score))%>%
  group_by(condition, time)%>%
  summarise(mean = mean(mean_score),
              sd = sd(mean_score)) %>%
  kable(digits = 2)
## `summarise()` regrouping output by 'subid_final', 'condition' (override with `.groups` argument)
## `summarise()` regrouping output by 'condition' (override with `.groups` argument)
condition time mean sd
abr_intervention t1 4.21 1.04
abr_intervention t2 4.39 1.06
active_control t1 4.11 1.02
active_control t2 4.13 1.03
full_intervention t1 4.01 0.98
full_intervention t2 4.26 0.92

Failure

d_mindset_failure <- d.study %>%
  select(subid_final, condition, mndst_fail_t1_score, mndst_fail_t2_score)%>%
  gather(item, score, contains("fail"))%>%
  separate(item, sep = "_", into = c("construct_name", "type", "time", "score_name"))%>%
  select(-construct_name, -score_name, -type)

Let’s change data to be numeric & factors (and appropriate contrasts)

#Make Rating Numeric

d_mindset_failure$score <- as.numeric(d_mindset_failure$score)

#Factor Condition
d_mindset_failure$condition <- as.factor(d_mindset_failure$condition)
contrasts(d_mindset_failure$condition)
##                   active_control full_intervention
## abr_intervention               0                 0
## active_control                 1                 0
## full_intervention              0                 1
contrasts(d_mindset_failure$condition) = cbind(dummy_full_vs_control = c(0,0,1), dummy_abridged_vs_control = c(1,0,0))
contrasts(d_mindset_failure$condition)
##                   dummy_full_vs_control dummy_abridged_vs_control
## abr_intervention                      0                         1
## active_control                        0                         0
## full_intervention                     1                         0
#Factor Time
d_mindset_failure$time <- as.factor(d_mindset_failure$time)
contrasts(d_mindset_failure$time)
##    t2
## t1  0
## t2  1
contrasts(d_mindset_failure$time) = cbind(dummy_t2_vs_t1 = c(0,1))
contrasts(d_mindset_failure$time)
##    dummy_t2_vs_t1
## t1              0
## t2              1
#Factor subject id

d_mindset_failure$subid_final <- as.factor(d_mindset_failure$subid_final)

Analysis

#Analysis
summary(lmer(score ~ time*condition + (1 | subid_final), data = d_mindset_failure))
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: score ~ time * condition + (1 | subid_final)
##    Data: d_mindset_failure
## 
## REML criterion at convergence: 1370.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.3046 -0.3711 -0.0822  0.2697  4.0540 
## 
## Random effects:
##  Groups      Name        Variance Std.Dev.
##  subid_final (Intercept) 0.3525   0.5937  
##  Residual                0.2378   0.4877  
## Number of obs: 648, groups:  subid_final, 324
## 
## Fixed effects:
##                                                         Estimate Std. Error
## (Intercept)                                             3.780374   0.074275
## timedummy_t2_vs_t1                                      0.090343   0.066674
## conditiondummy_full_vs_control                         -0.027993   0.105540
## conditiondummy_abridged_vs_control                      0.041055   0.103862
## timedummy_t2_vs_t1:conditiondummy_full_vs_control       0.049340   0.094740
## timedummy_t2_vs_t1:conditiondummy_abridged_vs_control  -0.007009   0.093234
##                                                               df t value
## (Intercept)                                           473.269933  50.897
## timedummy_t2_vs_t1                                    321.000005   1.355
## conditiondummy_full_vs_control                        473.269933  -0.265
## conditiondummy_abridged_vs_control                    473.269933   0.395
## timedummy_t2_vs_t1:conditiondummy_full_vs_control     321.000005   0.521
## timedummy_t2_vs_t1:conditiondummy_abridged_vs_control 321.000005  -0.075
##                                                       Pr(>|t|)    
## (Intercept)                                             <2e-16 ***
## timedummy_t2_vs_t1                                       0.176    
## conditiondummy_full_vs_control                           0.791    
## conditiondummy_abridged_vs_control                       0.693    
## timedummy_t2_vs_t1:conditiondummy_full_vs_control        0.603    
## timedummy_t2_vs_t1:conditiondummy_abridged_vs_control    0.940    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##                               (Intr) tm_2__1 cndtndmmy_f__ cndtndmmy_b__
## tmdmmy_2__1                   -0.449                                    
## cndtndmmy_f__                 -0.704  0.316                             
## cndtndmmy_b__                 -0.715  0.321   0.503                     
## tmdmmy_t2_vs_t1:cndtndmmy_f__  0.316 -0.704  -0.449        -0.226       
## tmdmmy_t2_vs_t1:cndtndmmy_b__  0.321 -0.715  -0.226        -0.449       
##                               tmdmmy_t2_vs_t1:cndtndmmy_f__
## tmdmmy_2__1                                                
## cndtndmmy_f__                                              
## cndtndmmy_b__                                              
## tmdmmy_t2_vs_t1:cndtndmmy_f__                              
## tmdmmy_t2_vs_t1:cndtndmmy_b__  0.503
d_mindset_failure %>%
  ungroup()%>%
  group_by(subid_final, condition, time) %>%
  summarise(mean_score = mean(score))%>%
  group_by(condition, time)%>%
  summarise(mean = mean(mean_score),
              sd = sd(mean_score)) %>%
  kable(digits = 2)
## `summarise()` regrouping output by 'subid_final', 'condition' (override with `.groups` argument)
## `summarise()` regrouping output by 'condition' (override with `.groups` argument)
condition time mean sd
abr_intervention t1 3.82 0.76
abr_intervention t2 3.90 0.85
active_control t1 3.78 0.72
active_control t2 3.87 0.75
full_intervention t1 3.75 0.72
full_intervention t2 3.89 0.79

Process

d_mindset_process <- d.study %>%
  select(subid_final, condition, mndst_process_t1_score, mndst_process_t2_score)%>%
  gather(item, score, contains("process"))%>%
  separate(item, sep = "_", into = c("construct_name", "type", "time", "score_name"))%>%
  select(-construct_name, -score_name, -type)

Let’s change data to be numeric & factors (and appropriate contrasts)

#Make Rating Numeric

d_mindset_process$score <- as.numeric(d_mindset_process$score)

#Factor Condition
d_mindset_process$condition <- as.factor(d_mindset_process$condition)
contrasts(d_mindset_process$condition)
##                   active_control full_intervention
## abr_intervention               0                 0
## active_control                 1                 0
## full_intervention              0                 1
contrasts(d_mindset_process$condition) = cbind(dummy_full_vs_control = c(0,0,1), dummy_abridged_vs_control = c(1,0,0))
contrasts(d_mindset_process$condition)
##                   dummy_full_vs_control dummy_abridged_vs_control
## abr_intervention                      0                         1
## active_control                        0                         0
## full_intervention                     1                         0
#Factor Time
d_mindset_process$time <- as.factor(d_mindset_process$time)
contrasts(d_mindset_process$time)
##    t2
## t1  0
## t2  1
contrasts(d_mindset_process$time) = cbind(dummy_t2_vs_t1 = c(0,1))
contrasts(d_mindset_process$time)
##    dummy_t2_vs_t1
## t1              0
## t2              1
#Factor subject id

d_mindset_failure$subid_final <- as.factor(d_mindset_failure$subid_final)

Analysis

#Analysis
summary(lmer(score ~ time*condition + (1 | subid_final), data = d_mindset_process))
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: score ~ time * condition + (1 | subid_final)
##    Data: d_mindset_process
## 
## REML criterion at convergence: 935.4
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.50450 -0.47464 -0.01444  0.51168  2.50823 
## 
## Random effects:
##  Groups      Name        Variance Std.Dev.
##  subid_final (Intercept) 0.2096   0.4578  
##  Residual                0.1095   0.3309  
## Number of obs: 648, groups:  subid_final, 324
## 
## Fixed effects:
##                                                        Estimate Std. Error
## (Intercept)                                             2.86248    0.05461
## timedummy_t2_vs_t1                                      0.06275    0.04524
## conditiondummy_full_vs_control                         -0.02439    0.07760
## conditiondummy_abridged_vs_control                      0.07502    0.07636
## timedummy_t2_vs_t1:conditiondummy_full_vs_control       0.08691    0.06428
## timedummy_t2_vs_t1:conditiondummy_abridged_vs_control  -0.04362    0.06326
##                                                              df t value
## (Intercept)                                           448.47592  52.417
## timedummy_t2_vs_t1                                    321.00001   1.387
## conditiondummy_full_vs_control                        448.47592  -0.314
## conditiondummy_abridged_vs_control                    448.47592   0.982
## timedummy_t2_vs_t1:conditiondummy_full_vs_control     321.00001   1.352
## timedummy_t2_vs_t1:conditiondummy_abridged_vs_control 321.00001  -0.690
##                                                       Pr(>|t|)    
## (Intercept)                                             <2e-16 ***
## timedummy_t2_vs_t1                                       0.166    
## conditiondummy_full_vs_control                           0.753    
## conditiondummy_abridged_vs_control                       0.326    
## timedummy_t2_vs_t1:conditiondummy_full_vs_control        0.177    
## timedummy_t2_vs_t1:conditiondummy_abridged_vs_control    0.491    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##                               (Intr) tm_2__1 cndtndmmy_f__ cndtndmmy_b__
## tmdmmy_2__1                   -0.414                                    
## cndtndmmy_f__                 -0.704  0.291                             
## cndtndmmy_b__                 -0.715  0.296   0.503                     
## tmdmmy_t2_vs_t1:cndtndmmy_f__  0.291 -0.704  -0.414        -0.208       
## tmdmmy_t2_vs_t1:cndtndmmy_b__  0.296 -0.715  -0.208        -0.414       
##                               tmdmmy_t2_vs_t1:cndtndmmy_f__
## tmdmmy_2__1                                                
## cndtndmmy_f__                                              
## cndtndmmy_b__                                              
## tmdmmy_t2_vs_t1:cndtndmmy_f__                              
## tmdmmy_t2_vs_t1:cndtndmmy_b__  0.503
d_mindset_process %>%
  ungroup()%>%
  group_by(subid_final, condition, time) %>%
  summarise(mean_score = mean(score))%>%
  group_by(condition, time)%>%
  summarise(mean = mean(mean_score),
              sd = sd(mean_score)) %>%
  kable(digits = 2)
## `summarise()` regrouping output by 'subid_final', 'condition' (override with `.groups` argument)
## `summarise()` regrouping output by 'condition' (override with `.groups` argument)
condition time mean sd
abr_intervention t1 2.94 0.53
abr_intervention t2 2.96 0.56
active_control t1 2.86 0.56
active_control t2 2.93 0.60
full_intervention t1 2.84 0.57
full_intervention t2 2.99 0.58

####Exercise Mindset

Let’s tidy the data

d_mindset_exercise <- d.study %>%
  select(subid_final, condition, mndst_exercise_t1_score, mndst_exercise_t2_score)%>%
  gather(item, score, contains("exercise"))%>%
  separate(item, sep = "_", into = c("construct_name", "type", "time", "score_name"))%>%
  select(-construct_name, -score_name, -type)

Let’s change data to be numeric & factors (and appropriate contrasts)

#Make Rating Numeric

d_mindset_exercise$score <- as.numeric(d_mindset_exercise$score)

#Factor Condition
d_mindset_exercise$condition <- as.factor(d_mindset_exercise$condition)
contrasts(d_mindset_exercise$condition)
##                   active_control full_intervention
## abr_intervention               0                 0
## active_control                 1                 0
## full_intervention              0                 1
contrasts(d_mindset_exercise$condition)= cbind(dummy_full_vs_control = c(0,0,1), dummy_abridged_vs_control = c(1,0,0))
contrasts(d_mindset_exercise$condition)
##                   dummy_full_vs_control dummy_abridged_vs_control
## abr_intervention                      0                         1
## active_control                        0                         0
## full_intervention                     1                         0
#Factor Time
d_mindset_exercise$time <- as.factor(d_mindset_exercise$time)
contrasts(d_mindset_exercise$time)
##    t2
## t1  0
## t2  1
contrasts(d_mindset_exercise$time) = cbind(dummy_t2_vs_t1 = c(0,1))
contrasts(d_mindset_exercise$time)
##    dummy_t2_vs_t1
## t1              0
## t2              1
#Factor subject id

d_mindset_exercise$subid_final <- as.factor(d_mindset_exercise$subid_final)

Analysis

#Analysis
summary(lmer(score ~ time*condition + (1 | subid_final), data = d_mindset_exercise))
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: score ~ time * condition + (1 | subid_final)
##    Data: d_mindset_exercise
## 
## REML criterion at convergence: 1795.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.7155 -0.4781 -0.0023  0.4637  2.8513 
## 
## Random effects:
##  Groups      Name        Variance Std.Dev.
##  subid_final (Intercept) 0.9279   0.9633  
##  Residual                0.3779   0.6147  
## Number of obs: 648, groups:  subid_final, 324
## 
## Fixed effects:
##                                                         Estimate Std. Error
## (Intercept)                                             4.666542   0.110470
## timedummy_t2_vs_t1                                     -0.097196   0.084047
## conditiondummy_full_vs_control                          0.002029   0.156970
## conditiondummy_abridged_vs_control                     -0.055828   0.154475
## timedummy_t2_vs_t1:conditiondummy_full_vs_control       0.220244   0.119425
## timedummy_t2_vs_t1:conditiondummy_abridged_vs_control   0.245768   0.117526
##                                                               df t value
## (Intercept)                                           426.597671  42.243
## timedummy_t2_vs_t1                                    321.000011  -1.156
## conditiondummy_full_vs_control                        426.597672   0.013
## conditiondummy_abridged_vs_control                    426.597672  -0.361
## timedummy_t2_vs_t1:conditiondummy_full_vs_control     321.000011   1.844
## timedummy_t2_vs_t1:conditiondummy_abridged_vs_control 321.000011   2.091
##                                                       Pr(>|t|)    
## (Intercept)                                             <2e-16 ***
## timedummy_t2_vs_t1                                      0.2484    
## conditiondummy_full_vs_control                          0.9897    
## conditiondummy_abridged_vs_control                      0.7180    
## timedummy_t2_vs_t1:conditiondummy_full_vs_control       0.0661 .  
## timedummy_t2_vs_t1:conditiondummy_abridged_vs_control   0.0373 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##                               (Intr) tm_2__1 cndtndmmy_f__ cndtndmmy_b__
## tmdmmy_2__1                   -0.380                                    
## cndtndmmy_f__                 -0.704  0.268                             
## cndtndmmy_b__                 -0.715  0.272   0.503                     
## tmdmmy_t2_vs_t1:cndtndmmy_f__  0.268 -0.704  -0.380        -0.191       
## tmdmmy_t2_vs_t1:cndtndmmy_b__  0.272 -0.715  -0.191        -0.380       
##                               tmdmmy_t2_vs_t1:cndtndmmy_f__
## tmdmmy_2__1                                                
## cndtndmmy_f__                                              
## cndtndmmy_b__                                              
## tmdmmy_t2_vs_t1:cndtndmmy_f__                              
## tmdmmy_t2_vs_t1:cndtndmmy_b__  0.503

Let’s plot!

#Summarize
d_mindset_exercise_summ <- d_mindset_exercise %>%
  group_by(condition, time) %>%
  summarise(mean_rating = mean(score),
            ci_rating = ci(score))
## `summarise()` regrouping output by 'condition' (override with `.groups` argument)
#Change levels
d_mindset_exercise_summ$time <- factor(d_mindset_exercise_summ$time, levels = c("t1", "t2"))


#Plot
ggplot(d_mindset_exercise_summ,
       aes(x=time,
           y=mean_rating, 
           fill = condition))+
  geom_bar(stat="identity", position = "dodge")+
  geom_errorbar(aes(ymin = (mean_rating - ci_rating), ymax = (mean_rating + ci_rating)),width = 0.2, position = position_dodge(width = 0.9))+
  labs(x = "", 
       y = "Agreement (adj)  \n 1 = Strongly disagree to 7 = Strongly agree",
       title = "Mindset -- Exercise",
       caption = "95% confidence intervals") +
  ggthemes::theme_few()+
  coord_cartesian(ylim=c(1,7))+
  theme(plot.caption =element_text(size=10),
        axis.text=element_text(size=14),
        axis.title = element_text(size=14),
        #axis.text.x=element_blank(),
        title =  element_text(size=15))

##Descriptives

d_mindset_exercise %>%
  ungroup()%>%
  group_by(subid_final, condition, time) %>%
  summarise(mean_score = mean(score))%>%
  group_by(condition, time)%>%
  summarise(mean = mean(mean_score),
              sd = sd(mean_score)) %>%
  kable(digits = 2)
## `summarise()` regrouping output by 'subid_final', 'condition' (override with `.groups` argument)
## `summarise()` regrouping output by 'condition' (override with `.groups` argument)
condition time mean sd
abr_intervention t1 4.61 1.15
abr_intervention t2 4.76 1.28
active_control t1 4.67 1.15
active_control t2 4.57 1.19
full_intervention t1 4.67 1.06
full_intervention t2 4.79 1.00


####Stress Mindset

Let’s tidy the data

d_mindset_stress <- d.study %>%
  select(subid_final, condition, mndst_stress_t1_score, mndst_stress_t2_score)%>%
  gather(item, score, contains("stress"))%>%
  separate(item, sep = "_", into = c("construct_name", "type", "time", "score_name"))%>%
  select(-construct_name, -score_name, -type)

Let’s change data to be numeric & factors (and appropriate contrasts)

#Make Rating Numeric

d_mindset_stress$score <- as.numeric(d_mindset_stress$score)

#Factor Condition
d_mindset_stress$condition <- as.factor(d_mindset_stress$condition)
contrasts(d_mindset_stress$condition)
##                   active_control full_intervention
## abr_intervention               0                 0
## active_control                 1                 0
## full_intervention              0                 1
contrasts(d_mindset_stress$condition) =cbind(dummy_full_vs_control = c(0,0,1), dummy_abridged_vs_control = c(1,0,0))
contrasts(d_mindset_stress$condition)
##                   dummy_full_vs_control dummy_abridged_vs_control
## abr_intervention                      0                         1
## active_control                        0                         0
## full_intervention                     1                         0
#Factor Time
d_mindset_stress$time <- as.factor(d_mindset_stress$time)
contrasts(d_mindset_stress$time)
##    t2
## t1  0
## t2  1
contrasts(d_mindset_stress$time) = cbind(dummy_t2_vs_t1 = c(0,1))
contrasts(d_mindset_stress$time)
##    dummy_t2_vs_t1
## t1              0
## t2              1
#Factor subject id

d_mindset_stress$subid_final <- as.factor(d_mindset_stress$subid_final)

Analysis

#Analysis
summary(lmer(score ~ time*condition + (1 | subid_final), data = d_mindset_stress))
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: score ~ time * condition + (1 | subid_final)
##    Data: d_mindset_stress
## 
## REML criterion at convergence: 1216.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.3928 -0.4316  0.0589  0.5032  3.2245 
## 
## Random effects:
##  Groups      Name        Variance Std.Dev.
##  subid_final (Intercept) 0.08469  0.2910  
##  Residual                0.29774  0.5457  
## Number of obs: 648, groups:  subid_final, 324
## 
## Fixed effects:
##                                                         Estimate Std. Error
## (Intercept)                                            1.831e+00  5.978e-02
## timedummy_t2_vs_t1                                    -4.673e-03  7.460e-02
## conditiondummy_full_vs_control                         4.677e-02  8.495e-02
## conditiondummy_abridged_vs_control                     8.657e-04  8.360e-02
## timedummy_t2_vs_t1:conditiondummy_full_vs_control      3.940e-01  1.060e-01
## timedummy_t2_vs_t1:conditiondummy_abridged_vs_control  3.529e-01  1.043e-01
##                                                               df t value
## (Intercept)                                            6.120e+02  30.621
## timedummy_t2_vs_t1                                     3.210e+02  -0.063
## conditiondummy_full_vs_control                         6.120e+02   0.551
## conditiondummy_abridged_vs_control                     6.120e+02   0.010
## timedummy_t2_vs_t1:conditiondummy_full_vs_control      3.210e+02   3.717
## timedummy_t2_vs_t1:conditiondummy_abridged_vs_control  3.210e+02   3.383
##                                                       Pr(>|t|)    
## (Intercept)                                            < 2e-16 ***
## timedummy_t2_vs_t1                                    0.950093    
## conditiondummy_full_vs_control                        0.582101    
## conditiondummy_abridged_vs_control                    0.991741    
## timedummy_t2_vs_t1:conditiondummy_full_vs_control     0.000238 ***
## timedummy_t2_vs_t1:conditiondummy_abridged_vs_control 0.000806 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##                               (Intr) tm_2__1 cndtndmmy_f__ cndtndmmy_b__
## tmdmmy_2__1                   -0.624                                    
## cndtndmmy_f__                 -0.704  0.439                             
## cndtndmmy_b__                 -0.715  0.446   0.503                     
## tmdmmy_t2_vs_t1:cndtndmmy_f__  0.439 -0.704  -0.624        -0.314       
## tmdmmy_t2_vs_t1:cndtndmmy_b__  0.446 -0.715  -0.314        -0.624       
##                               tmdmmy_t2_vs_t1:cndtndmmy_f__
## tmdmmy_2__1                                                
## cndtndmmy_f__                                              
## cndtndmmy_b__                                              
## tmdmmy_t2_vs_t1:cndtndmmy_f__                              
## tmdmmy_t2_vs_t1:cndtndmmy_b__  0.503

Let’s plot!

#Summarize
d_mindset_stress_summ <- d_mindset_stress %>%
  group_by(condition, time) %>%
  summarise(mean_rating = mean(score),
            ci_rating = ci(score))
## `summarise()` regrouping output by 'condition' (override with `.groups` argument)
#Change levels
d_mindset_stress_summ$time <- factor(d_mindset_stress_summ$time, levels = c("t1", "t2"))


#Plot
ggplot(d_mindset_stress_summ,
       aes(x=time,
           y=mean_rating, 
           fill = condition))+
  geom_bar(stat="identity", position = "dodge")+
  geom_errorbar(aes(ymin = (mean_rating - ci_rating), ymax = (mean_rating + ci_rating)),width = 0.2, position = position_dodge(width = 0.9))+
  labs(x = "", 
       y = "Agreement (adj)  \n 0 = Strongly disagree to 4 = Strongly agree",
       title = "Mindset -- Stress",
       caption = "95% confidence intervals") +
  ggthemes::theme_few()+
  coord_cartesian(ylim=c(0,4))+
  theme(plot.caption =element_text(size=10),
        axis.text=element_text(size=14),
        axis.title = element_text(size=14),
        #axis.text.x=element_blank(),
        title =  element_text(size=15))

##Descriptives

d_mindset_intelligence %>%
  ungroup()%>%
  group_by(subid_final, condition, time) %>%
  summarise(mean_score = mean(score))%>%
  group_by(condition, time)%>%
  summarise(mean = mean(mean_score),
              sd = sd(mean_score)) %>%
  kable(digits = 2)
## `summarise()` regrouping output by 'subid_final', 'condition' (override with `.groups` argument)
## `summarise()` regrouping output by 'condition' (override with `.groups` argument)
condition time mean sd
abr_intervention t1 3.60 0.87
abr_intervention t2 3.67 0.88
active_control t1 3.63 0.77
active_control t2 3.69 0.85
full_intervention t1 3.53 0.82
full_intervention t2 3.73 0.84

###All mindsets

##Plot

#Create tidy
d_mindset_all <- d.study %>%
  select(subid_final, condition, 
         mndst_pers_t1_score, mndst_pers_t2_score,
         mndst_process_t1_score, mndst_process_t2_score,
         mndst_fail_t1_score, mndst_fail_t2_score,
         mndst_exercise_t1_score, mndst_exercise_t2_score, 
         mndst_intelligence_t1_score, mndst_intelligence_t2_score, 
         mndst_stress_t1_score, mndst_stress_t2_score)%>%
  gather(item, score, contains("score"))%>%
  separate(item, sep = "_", into = c("mndst_name", "mndst_domain", "time", "score_name"))%>%
  select(-mndst_name, -score_name) %>%
  mutate(condition = ifelse(condition == "active_control", "Active Control",
                            ifelse(condition == "full_intervention", "Full Intervention",
                                   ifelse(condition == "abr_intervention", "Abridged Intervention", "Error"))))
  #mutate(time = ifelse(time == "t1", "Baseline", 
  #                     ifelse(time == "t2", "Post-Intervention", "error")))


#Summarize
d_meta_summ <- d_mindset_all %>%
  group_by(condition, mndst_domain, time) %>%
  summarise(mean_rating = mean(score),
            ci_rating = ci(score))
## `summarise()` regrouping output by 'condition', 'mndst_domain' (override with `.groups` argument)
#Create list of lines

d_hline <- d_meta_summ %>%
  filter((time == "Baseline") & (condition == "Active Control")) %>%
  ungroup() %>%
  select(mndst_domain) %>%
  mutate(hline = ifelse(mndst_domain == "Exercise Mindset", 4,
                        ifelse(mndst_domain == "Intelligence Mindset", 3.5,
                               ifelse(mndst_domain == "Stress Mindset", 2, "error"))))


d_hline$hline <- as.numeric(d_hline$hline)

#Change levels
#d_meta_summ$time <- factor(d_meta_summ$time, levels = c("Baseline", "Post-Intervention"))
d_meta_summ$condition <- factor(d_meta_summ$condition, levels = c( "Full Intervention", "Abridged Intervention", "Active Control"))


#Colors
group.colors <- c("Active Control" = "#D3D3D3",  "Abridged Intervention" = "#999999", "Full Intervention" = "#E69F00")

#Caption
caption <- "Note. Meta-mindset intervention, compared to the active control and the non-active control, lead to an increase in intelligence and stress mindset scores post-intervention compared to baseline. Horizontal grey line is midpoint of each scale (exercise mindset: 1 to 7; intelligence mindset: 1 to 6; stress mindset: 0 to 4). Participants received intervention or controls one week after baseline. Error bars represent 95% confidence intervals."


#Prep

wrap_strings <- function(vector_of_strings,width){as.character(sapply(vector_of_strings,FUN=function(x){paste(strwrap(x,width=width), collapse="\n")}))}
#function from here: https://stackoverflow.com/questions/7367138/text-wrap-for-plot-titles



#Plot
ggplot(d_meta_summ,
       aes(x=time,
           y=mean_rating, 
           col = condition))+
  geom_point(size=3) +
  geom_errorbar(data=d_meta_summ, aes(ymin = (mean_rating - ci_rating), ymax = (mean_rating + ci_rating)),width = 0.2, size = 1)+
  geom_line(aes(group = condition, color=condition), size = 1) +
  #geom_jitter(data=d_mindset_all, aes(x = time, y = score, col=condition),width=.1, height=.1,size=.6, alpha = 0.25) +
  #geom_hline(data= d_hline, aes(yintercept=hline), linetype = "dotted") +
  facet_grid(~mndst_domain, scales = "free_y") +
  scale_color_manual(values=group.colors)+
  scale_y_discrete(limits=c(1,2,3,4,5,6)) +
  coord_cartesian(ylim=c(1,6.2)) +
  scale_y_continuous(expand = c(0,0)) +
  theme_few() +
   labs(x = "Time", 
       y = "Mindset Score",
       title = "Figure 2\nStudy 4: Effect of Condition on Mindset Scores"
       #colour = "Condition",
       #linetype = "Significance"
   ) +
  theme(text = element_text(family = "Times New Roman"),
        plot.caption =element_text(size=10, hjust = 0),
        axis.text=element_text(size=12),
        axis.title = element_text(size=12),
        #axis.text.x=element_blank(),
        title =  element_text(size=12))  
## Warning: Continuous limits supplied to discrete scale.
## Did you mean `limits = factor(...)` or `scale_*_continuous()`?
## Scale for 'y' is already present. Adding another scale for 'y', which will
## replace the existing scale.

=======

#Summarize new variables (CMM and mindfulness) #In this questionnaire you will be shown a number of statements regarding mindsets. Please indicate your agreement with each statement by selecting the number that best represents your answer on the scale presented below the statement.

1. No matter what kind of mindset I have, I can always change it.

2. To be honest, you can’t really change your mindsets. (R)

3. I can develop my ability to control my mindsets.

4. I could learn to have more control over my mindsets.

5. When it is necessary to, I have a considerable amount of control over my mindset.

6. You can learn about new mindsets, but you can’t really change your basic ability to control your mindset. (R)

7. As much as I hate to admit it, you can’t teach an old dog new tricks. You can’t really change your mindsets about things in the world. (R)

8. You have certain mindsets about the world, and there is not much that can be done to really change that.(R)

9. Even in moments when it really matters, I can’t do much to change my mindset. (R)

10. How much I can control my mindset is something about me that I can’t change very much. (R)

Scale: Strongly disagree (1), Disagree (2), Somewhat disagree (3), Somewhat agree (4), Agree (5), Strongly Agree (6)

Scoring: Reverse score items 2, 6, 7, 8, 9 and 10. Then, compute the mean score of all the items. A higher score will indicate greater agreement that one’s mindset is controllable and changeable.

CMM

Scoring: Reverse score items 2, 6, 7, 8, 9 and 10. Then, compute the mean score of all the items. A higher score will indicate greater agreement that one’s mindset is controllable and changeable.

d.study <- d.study %>% 
  mutate(t2_cmm_2_reversed = 7 - t2_cmm_2_toreverse,
         t2_cmm_6_reversed = 7 - t2_cmm_6_toreverse,
         t2_cmm_7_reversed = 7 - t2_cmm_7_toreverse,
         t2_cmm_8_reversed = 7 - t2_cmm_8_toreverse,
         t2_cmm_9_reversed = 7 - t2_cmm_9_toreverse,
          t2_cmm_10_reversed = 7 - t2_cmm_10_toreverse) %>%
  mutate(cmm_t2_score = (t2_cmm_1 +
                                          t2_cmm_2_reversed + 
                                          t2_cmm_3 +
                                          t2_cmm_4 +
                                          t2_cmm_5 +
                                          t2_cmm_6_reversed +
                                          t2_cmm_7_reversed +
                                          t2_cmm_8_reversed +
                                          t2_cmm_9_reversed +
                                          t2_cmm_10_reversed)/10)
d.study <- d.study %>% 
  mutate(cmm_t2_score_6 = (t2_cmm_2_reversed + t2_cmm_6_reversed +
                                          t2_cmm_7_reversed +
                                          t2_cmm_8_reversed +
                                          t2_cmm_9_reversed +
                                          t2_cmm_10_reversed)/6)
d.study <- d.study %>% mutate(cmm_t2_score_4 = (t2_cmm_2_reversed + t2_cmm_7_reversed +
                                          t2_cmm_9_reversed +
                                          t2_cmm_10_reversed)/4)
#PANAS


d.study <- d.study %>%
  mutate(posaff_sum = (t2_fil_panas_1 +
                           t2_fil_panas_3 +
                           t2_fil_panas_5 +
                           t2_fil_panas_9 +
                           t2_fil_panas_10 +
                           t2_fil_panas_12 +
                           t2_fil_panas_14 +
                           t2_fil_panas_17 +
                           t2_fil_panas_19),
         negaff_sum = (t2_fil_panas_2 +
                         t2_fil_panas_4 +
                         t2_fil_panas_6 +
                           t2_fil_panas_7 +
                           t2_fil_panas_8 +
                           t2_fil_panas_11 +
                           t2_fil_panas_13 +
                           t2_fil_panas_15 +
                           t2_fil_panas_18 +
                           t2_fil_panas_20)) 

#missing item16 from the pos aff so max is 45 while max for neg is 50

####Self-efficacy (post)

Scoring: Compute the sum of the items. Higher scores indicate more self-efficacy.

d.study <- d.study %>%
  mutate(selfefficacy_score = (t2_fil_selfeff_1 +
                                 t2_fil_selfeff_2 +
                                 t2_fil_selfeff_3 +
                                 t2_fil_selfeff_4 +
                                 t2_fil_selfeff_5 +
                                 t2_fil_selfeff_6 +
                                 t2_fil_selfeff_7 +
                                 t2_fil_selfeff_8 +
                                 t2_fil_selfeff_9 +
                                 t2_fil_selfeff_10))
#mindfulness by factor than whole ffmq-15

#Observe 1, 6, 11
d.study <- d.study %>%
  mutate(ffmq_obs = t2_ffmq15_1 + t2_ffmq15_6 + t2_ffmq15_11/3)


#describe 2, 7R, 12
d.study <- d.study %>%
 mutate(t2_ffmq15_7_reversed = 6 - t2_ffmq15_7) %>%
   mutate(ffmq_des = t2_ffmq15_2 + t2_ffmq15_7_reversed + t2_ffmq15_12/3)


#acting with awareness 3R, 8R, 13R
d.study <- d.study %>%
 mutate(t2_ffmq15_3_reversed = 6 - t2_ffmq15_3,
        t2_ffmq15_8_reversed = 6 - t2_ffmq15_8,
        t2_ffmq15_13_reversed = 6 - t2_ffmq15_13) %>%
   mutate(ffmq_awa = t2_ffmq15_3_reversed + t2_ffmq15_8_reversed + t2_ffmq15_13_reversed/3)


#nonjudging 4R, 9R, 14R
d.study <- d.study %>%
 mutate(t2_ffmq15_4_reversed = 6 - t2_ffmq15_4,
        t2_ffmq15_9_reversed = 6 - t2_ffmq15_9,
        t2_ffmq15_14_reversed = 6 - t2_ffmq15_14) %>%
   mutate(ffmq_nj = t2_ffmq15_4_reversed + t2_ffmq15_9_reversed + t2_ffmq15_14_reversed/3)

#nonreactivity 5,10, 15
d.study <- d.study %>%
  mutate(ffmq_nr = t2_ffmq15_5 + t2_ffmq15_10 + t2_ffmq15_15/3)



#ffmq15-entire scale
d.study <- d.study %>%
  mutate(ffmq15_5f = ffmq_obs + ffmq_des + ffmq_awa + ffmq_nj + ffmq_nr)
#meta-awareness-observe factor only ffmq-39
 d.study <- d.study %>%
  mutate(MetAwa = t2_ffmq_1 + t2_ffmq_2 + t2_ffmq_3 + t2_ffmq_4 + t2_ffmq_5/5)
#create table with the expl variables (CMM and other mindsets)
library(tidyverse)

df <- d.study %>%
  select(ffmq15_5f, ffmq_obs, ffmq_des, ffmq_awa, ffmq_nj, ffmq_nr,  MetAwa, cmm_t2_score, mndst_intelligence_t2_score,  mndst_process_t2_score, mndst_exercise_t2_score, mndst_fail_t2_score, mndst_pers_t2_score, mndst_stress_t2_score, subid_final, condition, sfmm_all9_t2_score, cmm_t2_score_6, selfefficacy_score, posaff_sum, negaff_sum, cmm_t2_score_4) 

names(df)
##  [1] "ffmq15_5f"                   "ffmq_obs"                   
##  [3] "ffmq_des"                    "ffmq_awa"                   
##  [5] "ffmq_nj"                     "ffmq_nr"                    
##  [7] "MetAwa"                      "cmm_t2_score"               
##  [9] "mndst_intelligence_t2_score" "mndst_process_t2_score"     
## [11] "mndst_exercise_t2_score"     "mndst_fail_t2_score"        
## [13] "mndst_pers_t2_score"         "mndst_stress_t2_score"      
## [15] "subid_final"                 "condition"                  
## [17] "sfmm_all9_t2_score"          "cmm_t2_score_6"             
## [19] "selfefficacy_score"          "posaff_sum"                 
## [21] "negaff_sum"                  "cmm_t2_score_4"
names(df)
##  [1] "ffmq15_5f"                   "ffmq_obs"                   
##  [3] "ffmq_des"                    "ffmq_awa"                   
##  [5] "ffmq_nj"                     "ffmq_nr"                    
##  [7] "MetAwa"                      "cmm_t2_score"               
##  [9] "mndst_intelligence_t2_score" "mndst_process_t2_score"     
## [11] "mndst_exercise_t2_score"     "mndst_fail_t2_score"        
## [13] "mndst_pers_t2_score"         "mndst_stress_t2_score"      
## [15] "subid_final"                 "condition"                  
## [17] "sfmm_all9_t2_score"          "cmm_t2_score_6"             
## [19] "selfefficacy_score"          "posaff_sum"                 
## [21] "negaff_sum"                  "cmm_t2_score_4"
str(df)
## tibble [324 × 22] (S3: tbl_df/tbl/data.frame)
##  $ ffmq15_5f                  : num [1:324] 37.7 35 37 32.7 38.3 ...
##  $ ffmq_obs                   : num [1:324] 10.67 8.33 8.33 9.67 9.33 ...
##  $ ffmq_des                   : num [1:324] 6.33 8 8 7.33 6.33 ...
##  $ ffmq_awa                   : num [1:324] 4.33 6.67 4.67 3.33 8.67 ...
##  $ ffmq_nj                    : num [1:324] 5.67 5 7 3.67 7.67 ...
##  $ ffmq_nr                    : num [1:324] 10.67 7 9 8.67 6.33 ...
##  $ MetAwa                     : num [1:324] 16.8 14.8 15.6 16.8 18 12.6 16.8 19 18 7.2 ...
##  $ cmm_t2_score               : num [1:324] 3.4 3.2 3.2 3.2 3.3 3.4 3.1 3.3 3 3.2 ...
##  $ mndst_intelligence_t2_score: num [1:324] 3.25 3.5 3.25 3.75 3.62 ...
##  $ mndst_process_t2_score     : num [1:324] 2.86 2.43 2.29 3.43 3.86 ...
##  $ mndst_exercise_t2_score    : num [1:324] 3.6 4.24 4.24 4.32 7 3.64 4.92 5.2 5 4.8 ...
##  $ mndst_fail_t2_score        : num [1:324] 3.67 3.5 3.5 3.83 3.5 ...
##  $ mndst_pers_t2_score        : num [1:324] 4 3.75 3.75 4 4 ...
##  $ mndst_stress_t2_score      : num [1:324] 2.25 2.5 2.12 2.5 3.12 ...
##  $ subid_final                : num [1:324] 12 14 286 96 118 4 36 227 7 1 ...
##  $ condition                  : chr [1:324] "full_intervention" "abr_intervention" "active_control" "active_control" ...
##  $ sfmm_all9_t2_score         : num [1:324] 5.11 4.22 5 5.22 6 ...
##  $ cmm_t2_score_6             : num [1:324] 2.17 2.5 2.17 1.83 1.5 ...
##  $ selfefficacy_score         : num [1:324] 35 25 29 35 40 26 30 37 34 31 ...
##  $ posaff_sum                 : num [1:324] 37 26 33 39 42 16 37 39 40 43 ...
##  $ negaff_sum                 : num [1:324] 40 28 38 46 10 18 33 44 42 14 ...
##  $ cmm_t2_score_4             : num [1:324] 2.25 2.25 2 1.75 1.25 2.75 2 1.75 1.5 1.75 ...
head(df)
## # A tibble: 6 x 22
##   ffmq15_5f ffmq_obs ffmq_des ffmq_awa ffmq_nj ffmq_nr MetAwa cmm_t2_score
##       <dbl>    <dbl>    <dbl>    <dbl>   <dbl>   <dbl>  <dbl>        <dbl>
## 1      37.7    10.7      6.33     4.33    5.67   10.7    16.8          3.4
## 2      35       8.33     8        6.67    5       7      14.8          3.2
## 3      37       8.33     8        4.67    7       9      15.6          3.2
## 4      32.7     9.67     7.33     3.33    3.67    8.67   16.8          3.2
## 5      38.3     9.33     6.33     8.67    7.67    6.33   18            3.3
## 6      33.3     6.67     6        6.67    7       7      12.6          3.4
## # … with 14 more variables: mndst_intelligence_t2_score <dbl>,
## #   mndst_process_t2_score <dbl>, mndst_exercise_t2_score <dbl>,
## #   mndst_fail_t2_score <dbl>, mndst_pers_t2_score <dbl>,
## #   mndst_stress_t2_score <dbl>, subid_final <dbl>, condition <chr>,
## #   sfmm_all9_t2_score <dbl>, cmm_t2_score_6 <dbl>, selfefficacy_score <dbl>,
## #   posaff_sum <dbl>, negaff_sum <dbl>, cmm_t2_score_4 <dbl>
#add  health?
#scatter plots

# FFMQ15 and CMM
ggplot(df, aes(x=ffmq15_5f,
               y=cmm_t2_score_4)) +
  geom_point() +
  facet_wrap(~condition)

# MetAwa and CMM
ggplot(df, aes(x=MetAwa,
               y=cmm_t2_score)) +
 geom_point() +
  facet_wrap(~condition)

#Sfmm
ggplot(df, aes(x=sfmm_all9_t2_score,
               y=cmm_t2_score)) +
  geom_point() +
  facet_wrap(~condition)

#intelligence mindset
ggplot(df, aes(x=mndst_intelligence_t2_score,
               y=cmm_t2_score)) +
  geom_point() +
  facet_wrap(~condition)

#process mindset
ggplot(df, aes(x=mndst_process_t2_score,
               y=cmm_t2_score)) +
  geom_point() +
  facet_wrap(~condition)

#exercise mindset
ggplot(df, aes(x=mndst_exercise_t2_score,
               y=cmm_t2_score)) +
  geom_point() +
  facet_wrap(~condition)

#fail mindset
ggplot(df, aes(x=mndst_fail_t2_score,
               y=cmm_t2_score)) +
  geom_point() +
  facet_wrap(~condition)

#personality mindset
ggplot(df, aes(x=mndst_pers_t2_score,
               y=cmm_t2_score)) +
  geom_point() +
  facet_wrap(~condition)

#stress mindset
ggplot(df, aes(x=mndst_stress_t2_score,
               y=cmm_t2_score)) +
  geom_point() +
  facet_wrap(~condition)

#scatter plots with CMM 4 item
# FFMQ15 and CMM
ggplot(df, aes(x=ffmq15_5f,
               y=cmm_t2_score_4)) +
  geom_point() +
  facet_wrap(~condition)

# MetAwa and CMM
ggplot(df, aes(x=MetAwa,
               y=cmm_t2_score_4)) +
 geom_point() +
  facet_wrap(~condition)

#Sfmm
ggplot(df, aes(x=sfmm_all9_t2_score,
               y=cmm_t2_score_4)) +
  geom_point() +
  facet_wrap(~condition)

#intelligence mindset
ggplot(df, aes(x=mndst_intelligence_t2_score,
               y=cmm_t2_score_4)) +
  geom_point() +
  facet_wrap(~condition)

#process mindset
ggplot(df, aes(x=mndst_process_t2_score,
               y=cmm_t2_score_4)) +
  geom_point() +
  facet_wrap(~condition)

#exercise mindset
ggplot(df, aes(x=mndst_exercise_t2_score,
               y=cmm_t2_score_4)) +
  geom_point() +
  facet_wrap(~condition)

#fail mindset
ggplot(df, aes(x=mndst_fail_t2_score,
               y=cmm_t2_score_4)) +
  geom_point() +
  facet_wrap(~condition)

#personality mindset
ggplot(df, aes(x=mndst_pers_t2_score,
               y=cmm_t2_score_4)) +
  geom_point() +
  facet_wrap(~condition)

#stress mindset
ggplot(df, aes(x=mndst_stress_t2_score,
               y=cmm_t2_score_4)) +
  geom_point() +
  facet_wrap(~condition)

boxplot(df$cmm_t2_score) #few outliers with 10 item

boxplot(df$cmm_t2_score_6) # 6item more normal range

boxplot(df$cmm_t2_score_4) #4 item

controllability have normal distributions?

library("psych")
## 
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
#histograms
hist(df$cmm_t2_score_4)#**

hist(df$cmm_t2_score_6) #**

hist(df$ffmq15_5f)

hist(df$MetAwa)

hist(df$mndst_intelligence_t2_score)

hist(df$mndst_process_t2_score)

hist(df$sfmm_all9_t2_score)

hist(df$mndst_exercise_t2_score)

hist(df$mndst_fail_t2_score)

hist(df$mndst_pers_t2_score)

hist(df$mndst_stress_t2_score)

#descriptives of variables **
describe.by(df)
## Warning: describe.by is deprecated. Please use the describeBy function
## Warning in describeBy(x = x, group = group, mat = mat, type = type, ...): no
## grouping variable requested
##                             vars   n   mean    sd median trimmed    mad   min
## ffmq15_5f                      1 324  38.34  5.33  37.33   37.74   4.45 27.33
## ffmq_obs                       2 324   8.58  1.66   8.33    8.62   1.48  3.67
## ffmq_des                       3 324   7.78  1.74   7.67    7.69   1.48  3.33
## ffmq_awa                       4 324   7.21  2.39   7.00    7.16   2.97  2.33
## ffmq_nj                        5 324   6.61  2.49   6.00    6.45   2.47  2.33
## ffmq_nr                        6 324   8.16  1.93   8.17    8.20   1.73  2.33
## MetAwa                         7 324  15.49  2.77  15.60   15.58   2.67  6.20
## cmm_t2_score                   8 324   3.78  0.92   3.40    3.63   0.44  2.70
## mndst_intelligence_t2_score    9 324   3.70  0.85   3.62    3.63   0.56  1.00
## mndst_process_t2_score        10 324   2.96  0.58   3.00    2.96   0.64  1.43
## mndst_exercise_t2_score       11 324   4.71  1.17   4.52    4.70   1.01  1.48
## mndst_fail_t2_score           12 324   3.89  0.80   3.67    3.78   0.49  1.67
## mndst_pers_t2_score           13 324   4.26  1.01   4.12    4.18   0.56  1.00
## mndst_stress_t2_score         14 324   2.09  0.68   2.12    2.09   0.56  0.00
## subid_final                   15 324 162.50 93.67 162.50  162.50 120.09  1.00
## condition*                    16 324   1.98  0.82   2.00    1.97   1.48  1.00
## sfmm_all9_t2_score            17 324   4.77  0.67   4.78    4.79   0.66  2.33
## cmm_t2_score_6                18 324   3.05  1.41   2.50    2.89   0.99  1.00
## selfefficacy_score            19 324  31.48  4.41  31.00   31.50   4.45 20.00
## posaff_sum                    20 324  33.69  7.52  34.00   34.22   7.41  9.00
## negaff_sum                    21 324  25.89 11.69  27.00   25.53  15.57 10.00
## cmm_t2_score_4                22 324   3.05  1.44   2.50    2.91   1.11  1.00
##                                max  range  skew kurtosis   se
## ffmq15_5f                    58.33  31.00  1.18     1.86 0.30
## ffmq_obs                     11.67   8.00 -0.16    -0.37 0.09
## ffmq_des                     11.67   8.33  0.39    -0.03 0.10
## ffmq_awa                     11.67   9.33  0.13    -0.78 0.13
## ffmq_nj                      11.67   9.33  0.44    -0.59 0.14
## ffmq_nr                      11.67   9.33 -0.30     0.01 0.11
## MetAwa                       21.00  14.80 -0.34     0.00 0.15
## cmm_t2_score                  6.00   3.30  1.25     0.30 0.05
## mndst_intelligence_t2_score   6.00   5.00  0.59     1.88 0.05
## mndst_process_t2_score        4.00   2.57 -0.04    -0.51 0.03
## mndst_exercise_t2_score       7.00   5.52  0.00     0.08 0.06
## mndst_fail_t2_score           6.00   4.33  1.12     0.99 0.04
## mndst_pers_t2_score           7.00   6.00  0.70     1.61 0.06
## mndst_stress_t2_score         4.00   4.00  0.04     1.81 0.04
## subid_final                 324.00 323.00  0.00    -1.21 5.20
## condition*                    3.00   2.00  0.04    -1.51 0.05
## sfmm_all9_t2_score            6.00   3.67 -0.35     0.11 0.04
## cmm_t2_score_6                6.00   5.00  0.85    -0.51 0.08
## selfefficacy_score           40.00  20.00 -0.07    -0.53 0.25
## posaff_sum                   45.00  36.00 -0.64     0.02 0.42
## negaff_sum                   50.00  40.00  0.08    -1.29 0.65
## cmm_t2_score_4                6.00   5.00  0.77    -0.61 0.08
##kurtosis above 3 indicates tails may be heavier than normal - (.3)
  
### skewness between -.5 and .5 indicates fairly symmetrical - (1.25) - highly skewed - generally lower scores
#alpha cmm (std.alpha 83)

df.CMM.10 <- d.study %>%
  select(t2_cmm_1, t2_cmm_2_reversed, t2_cmm_3, t2_cmm_4, t2_cmm_5, t2_cmm_6_reversed, t2_cmm_7_reversed, t2_cmm_8_reversed, t2_cmm_9_reversed, t2_cmm_10_reversed)


#adjusting CMM items removing all items loading on second factor in cmm.10

df.CMM.6 <- df.CMM.10 %>% select(-t2_cmm_1, -t2_cmm_3, -t2_cmm_4, -t2_cmm_5)


#adjusting to create 4 item scale - removing items 1,3,4, 5, #6 and #8

df.CMM.4 <- df.CMM.10 %>% select(t2_cmm_2_reversed, t2_cmm_7_reversed, t2_cmm_9_reversed, t2_cmm_10_reversed)



library(corrr)

 - #inter item correlation
cor(df.CMM.6)
##                    t2_cmm_2_reversed t2_cmm_6_reversed t2_cmm_7_reversed
## t2_cmm_2_reversed         -1.0000000        -0.7742452        -0.8000453
## t2_cmm_6_reversed         -0.7742452        -1.0000000        -0.7408900
## t2_cmm_7_reversed         -0.8000453        -0.7408900        -1.0000000
## t2_cmm_8_reversed         -0.7327086        -0.8036319        -0.7412689
## t2_cmm_9_reversed         -0.7239716        -0.7189249        -0.7015721
## t2_cmm_10_reversed        -0.7498984        -0.7903516        -0.7412374
##                    t2_cmm_8_reversed t2_cmm_9_reversed t2_cmm_10_reversed
## t2_cmm_2_reversed         -0.7327086        -0.7239716         -0.7498984
## t2_cmm_6_reversed         -0.8036319        -0.7189249         -0.7903516
## t2_cmm_7_reversed         -0.7412689        -0.7015721         -0.7412374
## t2_cmm_8_reversed         -1.0000000        -0.7327862         -0.7664108
## t2_cmm_9_reversed         -0.7327862        -1.0000000         -0.7598499
## t2_cmm_10_reversed        -0.7664108        -0.7598499         -1.0000000
alpha(df.CMM.10) #suggests dropping no items will add to reliability, however 2 dropping 2 items (#3, and #5) would not lower reliability, adding (#1, #4) would remove .02. - possibly remove items (#3, and #5) or (#5 and #1), r.drop <.3 indicate low correlation with overall (this would sugegst removing (1,3,4, and 5)) - looking at reliability analysis reveals that removing items, 1, 3, 4, 5 will not reduce reliability very much -- later on  we see that it expands it - good reliability - low raw.r whih are item-total correlations still decent but lowest for nonreversed 
## 
## Reliability analysis   
## Call: alpha(x = df.CMM.10)
## 
##   raw_alpha std.alpha G6(smc) average_r S/N    ase mean   sd median_r
##       0.87      0.84    0.89      0.34 5.2 0.0093  3.8 0.92     0.14
## 
##  lower alpha upper     95% confidence boundaries
## 0.85 0.87 0.88 
## 
##  Reliability if an item is dropped:
##                    raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r
## t2_cmm_1                0.87      0.84    0.89      0.38 5.4   0.0085 0.113
## t2_cmm_2_reversed       0.83      0.80    0.87      0.31 4.1   0.0122 0.092
## t2_cmm_3                0.88      0.85    0.89      0.38 5.5   0.0084 0.110
## t2_cmm_4                0.88      0.85    0.89      0.38 5.6   0.0082 0.108
## t2_cmm_5                0.88      0.85    0.90      0.39 5.7   0.0084 0.108
## t2_cmm_6_reversed       0.83      0.81    0.87      0.31 4.1   0.0120 0.089
## t2_cmm_7_reversed       0.83      0.80    0.87      0.31 4.1   0.0120 0.094
## t2_cmm_8_reversed       0.84      0.81    0.87      0.32 4.2   0.0119 0.090
## t2_cmm_9_reversed       0.84      0.81    0.87      0.32 4.2   0.0118 0.096
## t2_cmm_10_reversed      0.83      0.81    0.87      0.31 4.1   0.0120 0.090
##                    med.r
## t2_cmm_1            0.23
## t2_cmm_2_reversed   0.12
## t2_cmm_3            0.25
## t2_cmm_4            0.27
## t2_cmm_5            0.28
## t2_cmm_6_reversed   0.13
## t2_cmm_7_reversed   0.12
## t2_cmm_8_reversed   0.13
## t2_cmm_9_reversed   0.13
## t2_cmm_10_reversed  0.13
## 
##  Item statistics 
##                      n raw.r std.r r.cor r.drop mean   sd
## t2_cmm_1           324  0.34  0.45  0.36   0.24  4.8 0.94
## t2_cmm_2_reversed  324  0.86  0.80  0.80   0.80  3.1 1.64
## t2_cmm_3           324  0.30  0.42  0.33   0.21  5.0 0.93
## t2_cmm_4           324  0.29  0.41  0.32   0.19  4.9 1.00
## t2_cmm_5           324  0.27  0.38  0.27   0.17  4.9 0.91
## t2_cmm_6_reversed  324  0.85  0.79  0.80   0.80  3.0 1.54
## t2_cmm_7_reversed  324  0.85  0.79  0.79   0.79  3.1 1.60
## t2_cmm_8_reversed  324  0.84  0.77  0.77   0.77  3.1 1.56
## t2_cmm_9_reversed  324  0.83  0.78  0.77   0.77  3.0 1.59
## t2_cmm_10_reversed 324  0.85  0.79  0.80   0.80  3.0 1.56
## 
## Non missing response frequency for each item
##                       1    2    3    4    5    6 miss
## t2_cmm_1           0.01 0.02 0.04 0.28 0.44 0.22    0
## t2_cmm_2_reversed  0.18 0.27 0.19 0.10 0.15 0.12    0
## t2_cmm_3           0.00 0.02 0.04 0.20 0.42 0.32    0
## t2_cmm_4           0.01 0.01 0.07 0.21 0.40 0.30    0
## t2_cmm_5           0.00 0.01 0.05 0.25 0.41 0.28    0
## t2_cmm_6_reversed  0.15 0.32 0.22 0.10 0.11 0.10    0
## t2_cmm_7_reversed  0.16 0.27 0.23 0.09 0.13 0.12    0
## t2_cmm_8_reversed  0.15 0.29 0.23 0.09 0.13 0.10    0
## t2_cmm_9_reversed  0.17 0.33 0.18 0.11 0.09 0.11    0
## t2_cmm_10_reversed 0.17 0.30 0.23 0.09 0.12 0.10    0
#r.drop which item-total, correlation without that item itself indicate low correlation owith rest of scale and <.3 suggest consider removal
alpha(df.CMM.6)#much higher reliability and internal consistency at .95 alpha afterremoving 1, 3, 4, 5
## 
## Reliability analysis   
## Call: alpha(x = df.CMM.6)
## 
##   raw_alpha std.alpha G6(smc) average_r S/N    ase mean  sd median_r
##       0.95      0.95    0.94      0.75  18 0.0045    3 1.4     0.74
## 
##  lower alpha upper     95% confidence boundaries
## 0.94 0.95 0.96 
## 
##  Reliability if an item is dropped:
##                    raw_alpha std.alpha G6(smc) average_r S/N alpha se   var.r
## t2_cmm_2_reversed       0.94      0.94    0.92      0.75  15   0.0055 0.00097
## t2_cmm_6_reversed       0.94      0.94    0.92      0.74  15   0.0057 0.00071
## t2_cmm_7_reversed       0.94      0.94    0.93      0.76  15   0.0054 0.00082
## t2_cmm_8_reversed       0.94      0.94    0.93      0.75  15   0.0055 0.00100
## t2_cmm_9_reversed       0.94      0.94    0.93      0.76  16   0.0051 0.00071
## t2_cmm_10_reversed      0.94      0.94    0.93      0.75  15   0.0056 0.00118
##                    med.r
## t2_cmm_2_reversed   0.74
## t2_cmm_6_reversed   0.74
## t2_cmm_7_reversed   0.75
## t2_cmm_8_reversed   0.75
## t2_cmm_9_reversed   0.76
## t2_cmm_10_reversed  0.74
## 
##  Item statistics 
##                      n raw.r std.r r.cor r.drop mean  sd
## t2_cmm_2_reversed  324  0.90  0.89  0.87   0.85  3.1 1.6
## t2_cmm_6_reversed  324  0.90  0.90  0.88   0.86  3.0 1.5
## t2_cmm_7_reversed  324  0.89  0.88  0.86   0.83  3.1 1.6
## t2_cmm_8_reversed  324  0.89  0.89  0.87   0.84  3.1 1.6
## t2_cmm_9_reversed  324  0.87  0.87  0.83   0.81  3.0 1.6
## t2_cmm_10_reversed 324  0.90  0.90  0.88   0.85  3.0 1.6
## 
## Non missing response frequency for each item
##                       1    2    3    4    5    6 miss
## t2_cmm_2_reversed  0.18 0.27 0.19 0.10 0.15 0.12    0
## t2_cmm_6_reversed  0.15 0.32 0.22 0.10 0.11 0.10    0
## t2_cmm_7_reversed  0.16 0.27 0.23 0.09 0.13 0.12    0
## t2_cmm_8_reversed  0.15 0.29 0.23 0.09 0.13 0.10    0
## t2_cmm_9_reversed  0.17 0.33 0.18 0.11 0.09 0.11    0
## t2_cmm_10_reversed 0.17 0.30 0.23 0.09 0.12 0.10    0
alpha(df.CMM.4) ### Reliability analysis
## 
## Reliability analysis   
## Call: alpha(x = df.CMM.4)
## 
##   raw_alpha std.alpha G6(smc) average_r S/N    ase mean  sd median_r
##       0.92      0.92     0.9      0.75  12 0.0071    3 1.4     0.75
## 
##  lower alpha upper     95% confidence boundaries
## 0.91 0.92 0.94 
## 
##  Reliability if an item is dropped:
##                    raw_alpha std.alpha G6(smc) average_r S/N alpha se   var.r
## t2_cmm_2_reversed       0.89      0.89    0.85      0.73 8.3   0.0104 0.00089
## t2_cmm_7_reversed       0.90      0.90    0.85      0.74 8.7   0.0099 0.00034
## t2_cmm_9_reversed       0.91      0.91    0.87      0.76 9.7   0.0090 0.00101
## t2_cmm_10_reversed      0.90      0.90    0.86      0.74 8.6   0.0100 0.00266
##                    med.r
## t2_cmm_2_reversed   0.74
## t2_cmm_7_reversed   0.75
## t2_cmm_9_reversed   0.75
## t2_cmm_10_reversed  0.72
## 
##  Item statistics 
##                      n raw.r std.r r.cor r.drop mean  sd
## t2_cmm_2_reversed  324  0.91  0.91  0.87   0.84  3.1 1.6
## t2_cmm_7_reversed  324  0.90  0.90  0.86   0.82  3.1 1.6
## t2_cmm_9_reversed  324  0.88  0.89  0.83   0.79  3.0 1.6
## t2_cmm_10_reversed 324  0.90  0.90  0.86   0.82  3.0 1.6
## 
## Non missing response frequency for each item
##                       1    2    3    4    5    6 miss
## t2_cmm_2_reversed  0.18 0.27 0.19 0.10 0.15 0.12    0
## t2_cmm_7_reversed  0.16 0.27 0.23 0.09 0.13 0.12    0
## t2_cmm_9_reversed  0.17 0.33 0.18 0.11 0.09 0.11    0
## t2_cmm_10_reversed 0.17 0.30 0.23 0.09 0.12 0.10    0
#variable correlations - CMM strong cor with intelligence, failure, personality, and ffmq, .2 for stress, strong 10 item and 6 item as expected, strong correlations with same 6 item but little les

cor.df <- df %>% select(cmm_t2_score, mndst_intelligence_t2_score, mndst_process_t2_score, mndst_exercise_t2_score, mndst_fail_t2_score, mndst_pers_t2_score, mndst_stress_t2_score, ffmq15_5f, MetAwa, cmm_t2_score_6, selfefficacy_score, posaff_sum, negaff_sum, cmm_t2_score_4)





cor.df <- cor(cor.df) ## CMM has med-strong correlations for intelligence, failure,pers, ffmq,  (neg association with pos/neg affect)

print(cor.df)# correlations between variables **
##                             cmm_t2_score mndst_intelligence_t2_score
## cmm_t2_score                 1.000000000                   0.4980558
## mndst_intelligence_t2_score  0.498055810                   1.0000000
## mndst_process_t2_score      -0.094740700                   0.1810352
## mndst_exercise_t2_score      0.131160900                   0.2499219
## mndst_fail_t2_score          0.667283008                   0.4320036
## mndst_pers_t2_score          0.564614591                   0.6684287
## mndst_stress_t2_score        0.206082087                   0.2630046
## ffmq15_5f                    0.618308306                   0.3819139
## MetAwa                      -0.005256606                   0.1258818
## cmm_t2_score_6               0.952440527                   0.4322670
## selfefficacy_score           0.287431561                   0.2737648
## posaff_sum                  -0.130889122                   0.1151058
## negaff_sum                  -0.635583384                  -0.2721320
## cmm_t2_score_4               0.944059574                   0.4214614
##                             mndst_process_t2_score mndst_exercise_t2_score
## cmm_t2_score                            -0.0947407              0.13116090
## mndst_intelligence_t2_score              0.1810352              0.24992194
## mndst_process_t2_score                   1.0000000              0.53762085
## mndst_exercise_t2_score                  0.5376208              1.00000000
## mndst_fail_t2_score                      0.1161936              0.19133976
## mndst_pers_t2_score                      0.1364244              0.18528674
## mndst_stress_t2_score                    0.2638673              0.19276511
## ffmq15_5f                                0.2093272              0.35009636
## MetAwa                                   0.1807367              0.10518023
## cmm_t2_score_6                          -0.2039079              0.04436655
## selfefficacy_score                       0.3775149              0.35701330
## posaff_sum                               0.5857798              0.49644524
## negaff_sum                              -0.1206436             -0.34669977
## cmm_t2_score_4                          -0.1981307              0.04900776
##                             mndst_fail_t2_score mndst_pers_t2_score
## cmm_t2_score                         0.66728301          0.56461459
## mndst_intelligence_t2_score          0.43200355          0.66842872
## mndst_process_t2_score               0.11619360          0.13642443
## mndst_exercise_t2_score              0.19133976          0.18528674
## mndst_fail_t2_score                  1.00000000          0.38026763
## mndst_pers_t2_score                  0.38026763          1.00000000
## mndst_stress_t2_score                0.39500577          0.20535604
## ffmq15_5f                            0.53206639          0.38638805
## MetAwa                               0.08867452          0.04213356
## cmm_t2_score_6                       0.61276266          0.47969513
## selfefficacy_score                   0.34144717          0.25067094
## posaff_sum                           0.08139726          0.02478875
## negaff_sum                          -0.52414531         -0.26671057
## cmm_t2_score_4                       0.61162301          0.46878145
##                             mndst_stress_t2_score  ffmq15_5f       MetAwa
## cmm_t2_score                           0.20608209  0.6183083 -0.005256606
## mndst_intelligence_t2_score            0.26300457  0.3819139  0.125881813
## mndst_process_t2_score                 0.26386728  0.2093272  0.180736671
## mndst_exercise_t2_score                0.19276511  0.3500964  0.105180233
## mndst_fail_t2_score                    0.39500577  0.5320664  0.088674522
## mndst_pers_t2_score                    0.20535604  0.3863880  0.042133559
## mndst_stress_t2_score                  1.00000000  0.1628913  0.027343666
## ffmq15_5f                              0.16289126  1.0000000  0.236757434
## MetAwa                                 0.02734367  0.2367574  1.000000000
## cmm_t2_score_6                         0.15816946  0.5523426 -0.107135029
## selfefficacy_score                     0.12576554  0.4773617  0.392697705
## posaff_sum                             0.13865123  0.1784645  0.401485553
## negaff_sum                            -0.14315856 -0.5561133  0.166435584
## cmm_t2_score_4                         0.14009778  0.5535466 -0.109644666
##                             cmm_t2_score_6 selfefficacy_score  posaff_sum
## cmm_t2_score                    0.95244053          0.2874316 -0.13088912
## mndst_intelligence_t2_score     0.43226703          0.2737648  0.11510584
## mndst_process_t2_score         -0.20390785          0.3775149  0.58577976
## mndst_exercise_t2_score         0.04436655          0.3570133  0.49644524
## mndst_fail_t2_score             0.61276266          0.3414472  0.08139726
## mndst_pers_t2_score             0.47969513          0.2506709  0.02478875
## mndst_stress_t2_score           0.15816946          0.1257655  0.13865123
## ffmq15_5f                       0.55234262          0.4773617  0.17846455
## MetAwa                         -0.10713503          0.3926977  0.40148555
## cmm_t2_score_6                  1.00000000          0.1156522 -0.29773353
## selfefficacy_score              0.11565215          1.0000000  0.52252851
## posaff_sum                     -0.29773353          0.5225285  1.00000000
## negaff_sum                     -0.66160617         -0.1643181  0.07395620
## cmm_t2_score_4                  0.98589374          0.1191795 -0.29273330
##                             negaff_sum cmm_t2_score_4
## cmm_t2_score                -0.6355834     0.94405957
## mndst_intelligence_t2_score -0.2721320     0.42146141
## mndst_process_t2_score      -0.1206436    -0.19813067
## mndst_exercise_t2_score     -0.3466998     0.04900776
## mndst_fail_t2_score         -0.5241453     0.61162301
## mndst_pers_t2_score         -0.2667106     0.46878145
## mndst_stress_t2_score       -0.1431586     0.14009778
## ffmq15_5f                   -0.5561133     0.55354656
## MetAwa                       0.1664356    -0.10964467
## cmm_t2_score_6              -0.6616062     0.98589374
## selfefficacy_score          -0.1643181     0.11917955
## posaff_sum                   0.0739562    -0.29273330
## negaff_sum                   1.0000000    -0.65322463
## cmm_t2_score_4              -0.6532246     1.00000000
#cor matrix with sig levels

library(Hmisc)
## Loading required package: lattice
## Loading required package: survival
## Loading required package: Formula
## 
## Attaching package: 'Hmisc'
## The following object is masked from 'package:psych':
## 
##     describe
## The following objects are masked from 'package:dplyr':
## 
##     src, summarize
## The following objects are masked from 'package:base':
## 
##     format.pval, units
cor.df.2 <- rcorr(as.matrix(cor.df))

print(cor.df.2) # s approaching or significant when looking a pvalues-process, fail, ffmq, and perapproach --intelligence not signifcant - pvales - sig values **
##                             cmm_t2_score mndst_intelligence_t2_score
## cmm_t2_score                        1.00                        0.72
## mndst_intelligence_t2_score         0.72                        1.00
## mndst_process_t2_score             -0.49                       -0.17
## mndst_exercise_t2_score            -0.05                        0.13
## mndst_fail_t2_score                 0.90                        0.68
## mndst_pers_t2_score                 0.78                        0.90
## mndst_stress_t2_score               0.19                        0.26
## ffmq15_5f                           0.82                        0.61
## MetAwa                             -0.50                       -0.35
## cmm_t2_score_6                      0.99                        0.69
## selfefficacy_score                  0.04                        0.11
## posaff_sum                         -0.66                       -0.38
## negaff_sum                         -0.92                       -0.68
## cmm_t2_score_4                      0.99                        0.69
##                             mndst_process_t2_score mndst_exercise_t2_score
## cmm_t2_score                                 -0.49                   -0.05
## mndst_intelligence_t2_score                  -0.17                    0.13
## mndst_process_t2_score                        1.00                    0.75
## mndst_exercise_t2_score                       0.75                    1.00
## mndst_fail_t2_score                          -0.27                    0.10
## mndst_pers_t2_score                          -0.28                    0.02
## mndst_stress_t2_score                         0.17                    0.18
## ffmq15_5f                                    -0.09                    0.32
## MetAwa                                        0.31                    0.07
## cmm_t2_score_6                               -0.55                   -0.11
## selfefficacy_score                            0.50                    0.54
## posaff_sum                                    0.84                    0.61
## negaff_sum                                    0.14                   -0.32
## cmm_t2_score_4                               -0.55                   -0.11
##                             mndst_fail_t2_score mndst_pers_t2_score
## cmm_t2_score                               0.90                0.78
## mndst_intelligence_t2_score                0.68                0.90
## mndst_process_t2_score                    -0.27               -0.28
## mndst_exercise_t2_score                    0.10                0.02
## mndst_fail_t2_score                        1.00                0.67
## mndst_pers_t2_score                        0.67                1.00
## mndst_stress_t2_score                      0.41                0.18
## ffmq15_5f                                  0.82                0.62
## MetAwa                                    -0.40               -0.45
## cmm_t2_score_6                             0.87                0.76
## selfefficacy_score                         0.19                0.04
## posaff_sum                                -0.45               -0.50
## negaff_sum                                -0.91               -0.70
## cmm_t2_score_4                             0.87                0.76
##                             mndst_stress_t2_score ffmq15_5f MetAwa
## cmm_t2_score                                 0.19      0.82  -0.50
## mndst_intelligence_t2_score                  0.26      0.61  -0.35
## mndst_process_t2_score                       0.17     -0.09   0.31
## mndst_exercise_t2_score                      0.18      0.32   0.07
## mndst_fail_t2_score                          0.41      0.82  -0.40
## mndst_pers_t2_score                          0.18      0.62  -0.45
## mndst_stress_t2_score                        1.00      0.14  -0.31
## ffmq15_5f                                    0.14      1.00  -0.17
## MetAwa                                      -0.31     -0.17   1.00
## cmm_t2_score_6                               0.18      0.78  -0.54
## selfefficacy_score                          -0.05      0.44   0.44
## posaff_sum                                  -0.06     -0.24   0.59
## negaff_sum                                  -0.31     -0.90   0.45
## cmm_t2_score_4                               0.17      0.78  -0.54
##                             cmm_t2_score_6 selfefficacy_score posaff_sum
## cmm_t2_score                          0.99               0.04      -0.66
## mndst_intelligence_t2_score           0.69               0.11      -0.38
## mndst_process_t2_score               -0.55               0.50       0.84
## mndst_exercise_t2_score              -0.11               0.54       0.61
## mndst_fail_t2_score                   0.87               0.19      -0.45
## mndst_pers_t2_score                   0.76               0.04      -0.50
## mndst_stress_t2_score                 0.18              -0.05      -0.06
## ffmq15_5f                             0.78               0.44      -0.24
## MetAwa                               -0.54               0.44       0.59
## cmm_t2_score_6                        1.00              -0.05      -0.73
## selfefficacy_score                   -0.05               1.00       0.59
## posaff_sum                           -0.73               0.59       1.00
## negaff_sum                           -0.89              -0.23       0.39
## cmm_t2_score_4                        1.00              -0.05      -0.72
##                             negaff_sum cmm_t2_score_4
## cmm_t2_score                     -0.92           0.99
## mndst_intelligence_t2_score      -0.68           0.69
## mndst_process_t2_score            0.14          -0.55
## mndst_exercise_t2_score          -0.32          -0.11
## mndst_fail_t2_score              -0.91           0.87
## mndst_pers_t2_score              -0.70           0.76
## mndst_stress_t2_score            -0.31           0.17
## ffmq15_5f                        -0.90           0.78
## MetAwa                            0.45          -0.54
## cmm_t2_score_6                   -0.89           1.00
## selfefficacy_score               -0.23          -0.05
## posaff_sum                        0.39          -0.72
## negaff_sum                        1.00          -0.89
## cmm_t2_score_4                   -0.89           1.00
## 
## n= 14 
## 
## 
## P
##                             cmm_t2_score mndst_intelligence_t2_score
## cmm_t2_score                             0.0037                     
## mndst_intelligence_t2_score 0.0037                                  
## mndst_process_t2_score      0.0739       0.5585                     
## mndst_exercise_t2_score     0.8638       0.6631                     
## mndst_fail_t2_score         0.0000       0.0077                     
## mndst_pers_t2_score         0.0009       0.0000                     
## mndst_stress_t2_score       0.5238       0.3789                     
## ffmq15_5f                   0.0003       0.0201                     
## MetAwa                      0.0682       0.2131                     
## cmm_t2_score_6              0.0000       0.0062                     
## selfefficacy_score          0.8853       0.7138                     
## posaff_sum                  0.0102       0.1858                     
## negaff_sum                  0.0000       0.0071                     
## cmm_t2_score_4              0.0000       0.0067                     
##                             mndst_process_t2_score mndst_exercise_t2_score
## cmm_t2_score                0.0739                 0.8638                 
## mndst_intelligence_t2_score 0.5585                 0.6631                 
## mndst_process_t2_score                             0.0021                 
## mndst_exercise_t2_score     0.0021                                        
## mndst_fail_t2_score         0.3575                 0.7442                 
## mndst_pers_t2_score         0.3313                 0.9348                 
## mndst_stress_t2_score       0.5518                 0.5485                 
## ffmq15_5f                   0.7659                 0.2670                 
## MetAwa                      0.2797                 0.8109                 
## cmm_t2_score_6              0.0413                 0.7049                 
## selfefficacy_score          0.0672                 0.0474                 
## posaff_sum                  0.0002                 0.0210                 
## negaff_sum                  0.6363                 0.2629                 
## cmm_t2_score_4              0.0415                 0.7097                 
##                             mndst_fail_t2_score mndst_pers_t2_score
## cmm_t2_score                0.0000              0.0009             
## mndst_intelligence_t2_score 0.0077              0.0000             
## mndst_process_t2_score      0.3575              0.3313             
## mndst_exercise_t2_score     0.7442              0.9348             
## mndst_fail_t2_score                             0.0088             
## mndst_pers_t2_score         0.0088                                 
## mndst_stress_t2_score       0.1493              0.5312             
## ffmq15_5f                   0.0003              0.0182             
## MetAwa                      0.1571              0.1026             
## cmm_t2_score_6              0.0000              0.0016             
## selfefficacy_score          0.5118              0.8949             
## posaff_sum                  0.1077              0.0685             
## negaff_sum                  0.0000              0.0056             
## cmm_t2_score_4              0.0000              0.0018             
##                             mndst_stress_t2_score ffmq15_5f MetAwa
## cmm_t2_score                0.5238                0.0003    0.0682
## mndst_intelligence_t2_score 0.3789                0.0201    0.2131
## mndst_process_t2_score      0.5518                0.7659    0.2797
## mndst_exercise_t2_score     0.5485                0.2670    0.8109
## mndst_fail_t2_score         0.1493                0.0003    0.1571
## mndst_pers_t2_score         0.5312                0.0182    0.1026
## mndst_stress_t2_score                             0.6257    0.2885
## ffmq15_5f                   0.6257                          0.5571
## MetAwa                      0.2885                0.5571          
## cmm_t2_score_6              0.5389                0.0011    0.0448
## selfefficacy_score          0.8585                0.1131    0.1148
## posaff_sum                  0.8338                0.4145    0.0249
## negaff_sum                  0.2866                0.0000    0.1082
## cmm_t2_score_4              0.5609                0.0010    0.0448
##                             cmm_t2_score_6 selfefficacy_score posaff_sum
## cmm_t2_score                0.0000         0.8853             0.0102    
## mndst_intelligence_t2_score 0.0062         0.7138             0.1858    
## mndst_process_t2_score      0.0413         0.0672             0.0002    
## mndst_exercise_t2_score     0.7049         0.0474             0.0210    
## mndst_fail_t2_score         0.0000         0.5118             0.1077    
## mndst_pers_t2_score         0.0016         0.8949             0.0685    
## mndst_stress_t2_score       0.5389         0.8585             0.8338    
## ffmq15_5f                   0.0011         0.1131             0.4145    
## MetAwa                      0.0448         0.1148             0.0249    
## cmm_t2_score_6                             0.8535             0.0033    
## selfefficacy_score          0.8535                            0.0276    
## posaff_sum                  0.0033         0.0276                       
## negaff_sum                  0.0000         0.4353             0.1716    
## cmm_t2_score_4              0.0000         0.8602             0.0034    
##                             negaff_sum cmm_t2_score_4
## cmm_t2_score                0.0000     0.0000        
## mndst_intelligence_t2_score 0.0071     0.0067        
## mndst_process_t2_score      0.6363     0.0415        
## mndst_exercise_t2_score     0.2629     0.7097        
## mndst_fail_t2_score         0.0000     0.0000        
## mndst_pers_t2_score         0.0056     0.0018        
## mndst_stress_t2_score       0.2866     0.5609        
## ffmq15_5f                   0.0000     0.0010        
## MetAwa                      0.1082     0.0448        
## cmm_t2_score_6              0.0000     0.0000        
## selfefficacy_score          0.4353     0.8602        
## posaff_sum                  0.1716     0.0034        
## negaff_sum                             0.0000        
## cmm_t2_score_4              0.0000
symnum(cor.df)
##                             cm_2_ mndst_n_2_ mndst_prc_2_ mndst_x_2_ mndst_f_2_
## cmm_t2_score                1                                                  
## mndst_intelligence_t2_score .     1                                            
## mndst_process_t2_score                       1                                 
## mndst_exercise_t2_score                      .            1                    
## mndst_fail_t2_score         ,     .                                  1         
## mndst_pers_t2_score         .     ,                                  .         
## mndst_stress_t2_score                                                .         
## ffmq15_5f                   ,     .                       .          .         
## MetAwa                                                                         
## cmm_t2_score_6              B     .                                  ,         
## selfefficacy_score                           .            .          .         
## posaff_sum                                   .            .                    
## negaff_sum                  ,                             .          .         
## cmm_t2_score_4              *     .                                  ,         
##                             mndst_prs_2_ mndst_s_2_ f M c_2__6 s p n c_2__4
## cmm_t2_score                                                               
## mndst_intelligence_t2_score                                                
## mndst_process_t2_score                                                     
## mndst_exercise_t2_score                                                    
## mndst_fail_t2_score                                                        
## mndst_pers_t2_score         1                                              
## mndst_stress_t2_score                    1                                 
## ffmq15_5f                   .                       1                      
## MetAwa                                                1                    
## cmm_t2_score_6              .                       .   1                  
## selfefficacy_score                                  . .        1           
## posaff_sum                                            .        . 1         
## negaff_sum                                          .   ,          1       
## cmm_t2_score_4              .                       .   B          , 1     
## attr(,"legend")
## [1] 0 ' ' 0.3 '.' 0.6 ',' 0.8 '+' 0.9 '*' 0.95 'B' 1
#correlogram


library(corrplot)
## corrplot 0.84 loaded
corrplot(cor.df) #visualize variable relations **

print(cor.df)
##                             cmm_t2_score mndst_intelligence_t2_score
## cmm_t2_score                 1.000000000                   0.4980558
## mndst_intelligence_t2_score  0.498055810                   1.0000000
## mndst_process_t2_score      -0.094740700                   0.1810352
## mndst_exercise_t2_score      0.131160900                   0.2499219
## mndst_fail_t2_score          0.667283008                   0.4320036
## mndst_pers_t2_score          0.564614591                   0.6684287
## mndst_stress_t2_score        0.206082087                   0.2630046
## ffmq15_5f                    0.618308306                   0.3819139
## MetAwa                      -0.005256606                   0.1258818
## cmm_t2_score_6               0.952440527                   0.4322670
## selfefficacy_score           0.287431561                   0.2737648
## posaff_sum                  -0.130889122                   0.1151058
## negaff_sum                  -0.635583384                  -0.2721320
## cmm_t2_score_4               0.944059574                   0.4214614
##                             mndst_process_t2_score mndst_exercise_t2_score
## cmm_t2_score                            -0.0947407              0.13116090
## mndst_intelligence_t2_score              0.1810352              0.24992194
## mndst_process_t2_score                   1.0000000              0.53762085
## mndst_exercise_t2_score                  0.5376208              1.00000000
## mndst_fail_t2_score                      0.1161936              0.19133976
## mndst_pers_t2_score                      0.1364244              0.18528674
## mndst_stress_t2_score                    0.2638673              0.19276511
## ffmq15_5f                                0.2093272              0.35009636
## MetAwa                                   0.1807367              0.10518023
## cmm_t2_score_6                          -0.2039079              0.04436655
## selfefficacy_score                       0.3775149              0.35701330
## posaff_sum                               0.5857798              0.49644524
## negaff_sum                              -0.1206436             -0.34669977
## cmm_t2_score_4                          -0.1981307              0.04900776
##                             mndst_fail_t2_score mndst_pers_t2_score
## cmm_t2_score                         0.66728301          0.56461459
## mndst_intelligence_t2_score          0.43200355          0.66842872
## mndst_process_t2_score               0.11619360          0.13642443
## mndst_exercise_t2_score              0.19133976          0.18528674
## mndst_fail_t2_score                  1.00000000          0.38026763
## mndst_pers_t2_score                  0.38026763          1.00000000
## mndst_stress_t2_score                0.39500577          0.20535604
## ffmq15_5f                            0.53206639          0.38638805
## MetAwa                               0.08867452          0.04213356
## cmm_t2_score_6                       0.61276266          0.47969513
## selfefficacy_score                   0.34144717          0.25067094
## posaff_sum                           0.08139726          0.02478875
## negaff_sum                          -0.52414531         -0.26671057
## cmm_t2_score_4                       0.61162301          0.46878145
##                             mndst_stress_t2_score  ffmq15_5f       MetAwa
## cmm_t2_score                           0.20608209  0.6183083 -0.005256606
## mndst_intelligence_t2_score            0.26300457  0.3819139  0.125881813
## mndst_process_t2_score                 0.26386728  0.2093272  0.180736671
## mndst_exercise_t2_score                0.19276511  0.3500964  0.105180233
## mndst_fail_t2_score                    0.39500577  0.5320664  0.088674522
## mndst_pers_t2_score                    0.20535604  0.3863880  0.042133559
## mndst_stress_t2_score                  1.00000000  0.1628913  0.027343666
## ffmq15_5f                              0.16289126  1.0000000  0.236757434
## MetAwa                                 0.02734367  0.2367574  1.000000000
## cmm_t2_score_6                         0.15816946  0.5523426 -0.107135029
## selfefficacy_score                     0.12576554  0.4773617  0.392697705
## posaff_sum                             0.13865123  0.1784645  0.401485553
## negaff_sum                            -0.14315856 -0.5561133  0.166435584
## cmm_t2_score_4                         0.14009778  0.5535466 -0.109644666
##                             cmm_t2_score_6 selfefficacy_score  posaff_sum
## cmm_t2_score                    0.95244053          0.2874316 -0.13088912
## mndst_intelligence_t2_score     0.43226703          0.2737648  0.11510584
## mndst_process_t2_score         -0.20390785          0.3775149  0.58577976
## mndst_exercise_t2_score         0.04436655          0.3570133  0.49644524
## mndst_fail_t2_score             0.61276266          0.3414472  0.08139726
## mndst_pers_t2_score             0.47969513          0.2506709  0.02478875
## mndst_stress_t2_score           0.15816946          0.1257655  0.13865123
## ffmq15_5f                       0.55234262          0.4773617  0.17846455
## MetAwa                         -0.10713503          0.3926977  0.40148555
## cmm_t2_score_6                  1.00000000          0.1156522 -0.29773353
## selfefficacy_score              0.11565215          1.0000000  0.52252851
## posaff_sum                     -0.29773353          0.5225285  1.00000000
## negaff_sum                     -0.66160617         -0.1643181  0.07395620
## cmm_t2_score_4                  0.98589374          0.1191795 -0.29273330
##                             negaff_sum cmm_t2_score_4
## cmm_t2_score                -0.6355834     0.94405957
## mndst_intelligence_t2_score -0.2721320     0.42146141
## mndst_process_t2_score      -0.1206436    -0.19813067
## mndst_exercise_t2_score     -0.3466998     0.04900776
## mndst_fail_t2_score         -0.5241453     0.61162301
## mndst_pers_t2_score         -0.2667106     0.46878145
## mndst_stress_t2_score       -0.1431586     0.14009778
## ffmq15_5f                   -0.5561133     0.55354656
## MetAwa                       0.1664356    -0.10964467
## cmm_t2_score_6              -0.6616062     0.98589374
## selfefficacy_score          -0.1643181     0.11917955
## posaff_sum                   0.0739562    -0.29273330
## negaff_sum                   1.0000000    -0.65322463
## cmm_t2_score_4              -0.6532246     1.00000000
#scatterplot with fitted line cmm x ffmq
ggplot(df, aes(x = cmm_t2_score_4, y = ffmq15_5f)) +
  geom_point() +
  stat_smooth()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

#scatterplot with fitted line cmm x mindset
ggplot(df, aes(x = cmm_t2_score_4, y = sfmm_all9_t2_score)) +
  geom_point() +
  stat_smooth()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

df.lm.4.ffmq <- lm(ffmq15_5f ~ cmm_t2_score_4, data=df)  # build linear regression model on full data
print(df.lm.4.ffmq)
## 
## Call:
## lm(formula = ffmq15_5f ~ cmm_t2_score_4, data = df)
## 
## Coefficients:
##    (Intercept)  cmm_t2_score_4  
##         32.084           2.052
ggplot(df, aes(cmm_t2_score_4, ffmq15_5f)) +
  geom_point() +
  stat_smooth(method = lm)
## `geom_smooth()` using formula 'y ~ x'

summary(df.lm.4.ffmq)
## 
## Call:
## lm(formula = ffmq15_5f ~ cmm_t2_score_4, data = df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -14.0634  -2.7395   0.1322   2.4069  13.9366 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     32.0838     0.5800   55.32   <2e-16 ***
## cmm_t2_score_4   2.0522     0.1721   11.93   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.449 on 322 degrees of freedom
## Multiple R-squared:  0.3064, Adjusted R-squared:  0.3043 
## F-statistic: 142.3 on 1 and 322 DF,  p-value: < 2.2e-16
df.lm.4.ex <- lm(cmm_t2_score_4 ~ mndst_exercise_t2_score, data=df)  # build linear regression model on full data
#EFA - looking for theoretically meaningful subdimensions of latent construct optimally - using principle components analysis 
df.CMM.4.pca <- princomp(df.CMM.4)
summary(df.CMM.4.pca)
## Importance of components:
##                           Comp.1     Comp.2     Comp.3     Comp.4
## Standard deviation     2.8737674 0.91540784 0.76143123 0.72041275
## Proportion of Variance 0.8100353 0.08219208 0.05686723 0.05090536
## Cumulative Proportion  0.8100353 0.89222741 0.94909464 1.00000000
plot(df.CMM.4.pca) #scree plot

cor(df.CMM.4)
##                    t2_cmm_2_reversed t2_cmm_7_reversed t2_cmm_9_reversed
## t2_cmm_2_reversed          1.0000000         0.8000453         0.7239716
## t2_cmm_7_reversed          0.8000453         1.0000000         0.7015721
## t2_cmm_9_reversed          0.7239716         0.7015721         1.0000000
## t2_cmm_10_reversed         0.7498984         0.7412374         0.7598499
##                    t2_cmm_10_reversed
## t2_cmm_2_reversed           0.7498984
## t2_cmm_7_reversed           0.7412374
## t2_cmm_9_reversed           0.7598499
## t2_cmm_10_reversed          1.0000000
#summary suggest one factor lookin at variances PCA - adds little to variance continuing past maybe 2 - control and change (#check varimax - oblimique) - assumes factors are orthogonal - factanal uses max likelihood
CMM.4.fa1 <- factanal(df.CMM.4, factors = 1)

print(CMM.4.fa1) #test hypothesis that 1 factor is sufficient - factanal uses max likelihood, not recommended for efa - yes
## 
## Call:
## factanal(x = df.CMM.4, factors = 1)
## 
## Uniquenesses:
##  t2_cmm_2_reversed  t2_cmm_7_reversed  t2_cmm_9_reversed t2_cmm_10_reversed 
##              0.212              0.238              0.310              0.255 
## 
## Loadings:
##                    Factor1
## t2_cmm_2_reversed  0.888  
## t2_cmm_7_reversed  0.873  
## t2_cmm_9_reversed  0.831  
## t2_cmm_10_reversed 0.863  
## 
##                Factor1
## SS loadings      2.986
## Proportion Var   0.746
## 
## Test of the hypothesis that 1 factor is sufficient.
## The chi square statistic is 16.15 on 2 degrees of freedom.
## The p-value is 0.000312
#summary suggest one factor lookin at variances PCA - adds little to variance continuing past maybe 2 - control and change (#check oblique) - factors correlated? - asssumes factors are orthogonal - below using promax - 
CMM.4.fa1.pro <- factanal(df.CMM.4, factors = 1, rotation = "promax")

print(CMM.4.fa1.pro) #test hypothesis that 1 factor is sufficient - factanal uses max likelihood, not recommended for efa
## 
## Call:
## factanal(x = df.CMM.4, factors = 1, rotation = "promax")
## 
## Uniquenesses:
##  t2_cmm_2_reversed  t2_cmm_7_reversed  t2_cmm_9_reversed t2_cmm_10_reversed 
##              0.212              0.238              0.310              0.255 
## 
## Loadings:
##                    Factor1
## t2_cmm_2_reversed  0.888  
## t2_cmm_7_reversed  0.873  
## t2_cmm_9_reversed  0.831  
## t2_cmm_10_reversed 0.863  
## 
##                Factor1
## SS loadings      2.986
## Proportion Var   0.746
## 
## Test of the hypothesis that 1 factor is sufficient.
## The chi square statistic is 16.15 on 2 degrees of freedom.
## The p-value is 0.000312

#summary suggest one factor lookin at variances PCA - adds little to variance continuing past maybe 2 - control and change (#check oblique) - factors correlated? - factors are orthogonal - below using promax - an oblique rotation, which allows for factors to be correlated. we suggest control and changing underlying factors are correlated. #critieria reached with 2 factors Using logic like that in the preceding quote, Thurstone (1947) first proposed and argued for five # criteria that needed to be met for simple structure to be achieved: # 1. Each variable should produce at least one zero loading on some factor. # 2. Each factor should have at least as many zero loadings as there are factors. # 3. Each pair of factors should have variables with significant loadings on one # and zero loadings on the other. # 4. Each pair of factors should have a large proportion of zero loadings on both factors # (if there are say four or more factors total). # 5. Each pair of factors should have only a few complex variables.

#Items suggested retaining with factor loading above .8, were all the reverse scored items -2 factor structure (hints at the theoretical and conceptual approach to phenomena, a metamindset getting at control and change of mindsets) #Factor 2 - lower but all above .52 # 1. No matter what kind of mindset I have, I can always change it. # 3. I can develop my ability to control my mindsets. # 4. I could learn to have more control over my mindsets. # 5. When it is necessary to, I have a considerable amount of control over my mindset.

#Factor 1- principical component - most variance explained al l load .8+ # 2.To be honest, you can’t really change your mindsets. (R) # 6. You can learn about new mindsets, but you can’t really change your basic ability to control your mindset. (R) # 7. As much as I hate to admit it, you can’t teach an old dog new tricks. You can’t really change your mindsets about things in the world. (R) # 8. You have certain mindsets about the world, and there is not much that can be done to really change that.(R) # 9. Even in moments when it really matters, I can’t do much to change my mindset. (R) # 10. How much I can control my mindset is something about me that I can’t change very much. (R)

#using Princial Axis Factor analysis w psych package continue exploring this should be doneusing CFA in new sample
#maximizes variance from factors

CMM.PAF.4 <- factor.pa(df.CMM.4, nfactors = 1, rotate = "promax")
## Warning: factor.pa is deprecated. Please use the fa function with fm=pa
print(CMM.PAF.4)
## Factor Analysis using method =  pa
## Call: factor.pa(r = df.CMM.4, nfactors = 1, rotate = "promax")
## Unstandardized loadings (pattern matrix) based upon covariance matrix
##                     PA1   h2   u2   H2   U2
## t2_cmm_2_reversed  0.88 0.78 0.22 0.78 0.22
## t2_cmm_7_reversed  0.87 0.75 0.25 0.75 0.25
## t2_cmm_9_reversed  0.83 0.69 0.31 0.69 0.31
## t2_cmm_10_reversed 0.87 0.76 0.24 0.76 0.24
## 
##                 PA1
## SS loadings    2.99
## Proportion Var 0.75
## 
##  Standardized loadings (pattern matrix)
##                    V  PA1   h2   u2
## t2_cmm_2_reversed  1 0.88 0.78 0.22
## t2_cmm_7_reversed  2 0.87 0.75 0.25
## t2_cmm_9_reversed  3 0.83 0.69 0.31
## t2_cmm_10_reversed 4 0.87 0.76 0.24
## 
##                 PA1
## SS loadings    2.98
## Proportion Var 0.75
## 
## Mean item complexity =  1
## Test of the hypothesis that 1 factor is sufficient.
## 
## The degrees of freedom for the null model are  6  and the objective function was  3.01 with Chi Square of  964.56
## The degrees of freedom for the model are 2  and the objective function was  0.05 
## 
## The root mean square of the residuals (RMSR) is  0.02 
## The df corrected root mean square of the residuals is  0.04 
## 
## The harmonic number of observations is  324 with the empirical chi square  2.26  with prob <  0.32 
## The total number of observations was  324  with Likelihood Chi Square =  16.44  with prob <  0.00027 
## 
## Tucker Lewis Index of factoring reliability =  0.955
## RMSEA index =  0.149  and the 90 % confidence intervals are  0.088 0.22
## BIC =  4.87
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                    PA1
## Correlation of (regression) scores with factors   0.96
## Multiple R square of scores with factors          0.92
## Minimum correlation of possible factor scores     0.85
#other EFA using minsres


EFA.model.CMM.4 <- fa(df.CMM.4)


EFA.model.CMM.4$loadings
## 
## Loadings:
##                    MR1  
## t2_cmm_2_reversed  0.885
## t2_cmm_7_reversed  0.867
## t2_cmm_9_reversed  0.833
## t2_cmm_10_reversed 0.870
## 
##                  MR1
## SS loadings    2.986
## Proportion Var 0.747
#factor loadings
fa.diagram(EFA.model.CMM.4)

head(df.CMM.4)
## # A tibble: 6 x 4
##   t2_cmm_2_reversed t2_cmm_7_reversed t2_cmm_9_reversed t2_cmm_10_reversed
##               <dbl>             <dbl>             <dbl>              <dbl>
## 1                 3                 3                 1                  2
## 2                 2                 2                 2                  3
## 3                 1                 2                 2                  3
## 4                 1                 2                 2                  2
## 5                 1                 1                 2                  1
## 6                 3                 3                 2                  3
#this function shows individuals scores on factor
EFA.model.CMM.4$scores
##                 MR1
##   [1,] -0.480961809
##   [2,] -0.520250325
##   [3,] -0.710337968
##   [4,] -0.892304416
##   [5,] -1.236821254
##   [6,] -0.167612291
##   [7,] -0.733384093
##   [8,] -0.833599842
##   [9,] -1.054854806
##  [10,] -0.825478647
##  [11,] -0.249362989
##  [12,]  0.629758330
##  [13,]  0.713731689
##  [14,] -0.520250325
##  [15,]  0.366992191
##  [16,] -0.733384093
##  [17,] -0.996150232
##  [18,] -0.861137096
##  [19,]  0.780557458
##  [20,]  0.230166985
##  [21,] -0.861137096
##  [22,]  1.961733433
##  [23,]  0.343946066
##  [24,] -0.729754026
##  [25,]  1.961733433
##  [26,]  1.295745882
##  [27,] -0.864767163
##  [28,]  0.629758330
##  [29,] -0.520250325
##  [30,] -0.005061901
##  [31,]  1.304818084
##  [32,] -1.015566290
##  [33,] -1.074270864
##  [34,] -0.884183221
##  [35,] -0.570833703
##  [36,] -1.186237876
##  [37,] -0.453424555
##  [38,]  1.961733433
##  [39,] -0.368994797
##  [40,]  1.295745882
##  [41,] -0.520250325
##  [42,]  0.710558022
##  [43,] -0.520250325
##  [44,]  0.943107848
##  [45,]  1.164362812
##  [46,]  1.295745882
##  [47,]  1.961733433
##  [48,]  1.164362812
##  [49,] -0.884183221
##  [50,] -0.307116556
##  [51,] -0.036229221
##  [52,] -0.520250325
##  [53,] -0.662928257
##  [54,] -0.643512199
##  [55,] -0.520250325
##  [56,]  1.961733433
##  [57,]  0.126321169
##  [58,] -0.167612291
##  [59,] -0.349578739
##  [60,] -0.380746059
##  [61,]  1.771645789
##  [62,]  0.041891411
##  [63,]  1.830350363
##  [64,]  1.485833525
##  [65,]  0.176904547
##  [66,]  0.203490794
##  [67,] -1.186237876
##  [68,] -0.833599842
##  [69,] -0.218195669
##  [70,]  0.375113386
##  [71,]  1.295745882
##  [72,] -1.236821254
##  [73,]  0.428375824
##  [74,] -0.547787578
##  [75,] -0.833599842
##  [76,]  1.648383915
##  [77,] -1.186237876
##  [78,] -0.539666383
##  [79,] -1.015566290
##  [80,] -0.570833703
##  [81,]  1.961733433
##  [82,]  0.265825434
##  [83,] -1.186237876
##  [84,] -0.864767163
##  [85,]  1.961733433
##  [86,] -0.884183221
##  [87,] -0.721632831
##  [88,]  1.477712330
##  [89,]  0.176904547
##  [90,] -1.046733611
##  [91,] -0.884183221
##  [92,] -0.814183784
##  [93,] -1.205653934
##  [94,]  0.819845974
##  [95,] -0.450250888
##  [96,] -0.662928257
##  [97,] -1.236821254
##  [98,] -0.702216773
##  [99,]  1.648383915
## [100,] -0.702216773
## [101,]  1.961733433
## [102,]  0.529542581
## [103,] -0.059275346
## [104,] -0.408283313
## [105,]  1.133195492
## [106,] -0.988029037
## [107,] -0.884183221
## [108,] -0.032599155
## [109,]  1.295745882
## [110,] -0.694095577
## [111,] -0.218195669
## [112,]  0.652804455
## [113,] -0.512129129
## [114,] -0.694095577
## [115,] -0.996150232
## [116,]  1.961733433
## [117,]  0.257704239
## [118,] -0.036229221
## [119,] -0.055645279
## [120,]  1.617216595
## [121,] -0.167612291
## [122,] -1.186237876
## [123,] -0.388867255
## [124,]  1.102484571
## [125,]  0.629758330
## [126,] -0.702216773
## [127,] -0.598370956
## [128,] -0.290874165
## [129,] -0.911720474
## [130,] -0.911720474
## [131,] -1.023687486
## [132,] -1.368204324
## [133,] -0.923471736
## [134,] -0.911720474
## [135,] -0.167612291
## [136,] -1.186237876
## [137,] -0.547787578
## [138,]  0.792308720
## [139,] -0.167612291
## [140,]  0.204441801
## [141,] -1.015566290
## [142,] -0.702216773
## [143,] -0.721632831
## [144,] -0.718002764
## [145,] -0.671049452
## [146,] -0.140075037
## [147,]  1.295745882
## [148,]  1.295745882
## [149,] -0.915350541
## [150,]  1.961733433
## [151,] -0.094933795
## [152,] -0.539666383
## [153,]  1.295745882
## [154,] -1.236821254
## [155,] -0.570833703
## [156,] -0.780337405
## [157,] -1.236821254
## [158,] -0.257484185
## [159,]  0.467207940
## [160,] -0.752800151
## [161,] -0.330162681
## [162,] -0.229946931
## [163,] -0.195149545
## [164,] -0.036229221
## [165,]  1.295745882
## [166,] -1.186237876
## [167,] -0.760921346
## [168,] -0.702216773
## [169,] -0.512129129
## [170,] -0.590249761
## [171,]  1.164362812
## [172,] -0.388867255
## [173,]  0.394985844
## [174,] -0.892304416
## [175,] -0.547787578
## [176,]  1.609095399
## [177,] -0.598370956
## [178,] -1.023687486
## [179,] -1.368204324
## [180,] -1.046733611
## [181,]  1.164362812
## [182,] -0.036229221
## [183,] -1.074270864
## [184,] -1.368204324
## [185,] -0.694095577
## [186,]  1.961733433
## [187,] -0.856645967
## [188,] -0.570833703
## [189,] -0.872888358
## [190,] -0.884183221
## [191,] -0.131953842
## [192,] -0.028108026
## [193,] -1.368204324
## [194,] -0.330162681
## [195,]  0.819845974
## [196,] -0.036229221
## [197,]  0.285241492
## [198,] -1.004271428
## [199,]  1.295745882
## [200,] -1.046733611
## [201,]  1.961733433
## [202,]  1.295745882
## [203,]  1.164362812
## [204,] -0.298995361
## [205,] -0.198779611
## [206,]  0.223857859
## [207,] -0.357699935
## [208,] -0.598370956
## [209,] -1.023687486
## [210,] -0.643512199
## [211,] -0.067396541
## [212,]  1.295745882
## [213,]  1.071317251
## [214,] -0.570833703
## [215,] -0.539666383
## [216,]  0.153858422
## [217,]  1.133195492
## [218,]  0.475329136
## [219,]  1.648383915
## [220,] -0.733384093
## [221,]  0.394529444
## [222,] -0.520250325
## [223,] -0.702216773
## [224,] -0.117028913
## [225,]  0.145737227
## [226,]  1.771645789
## [227,] -0.187028349
## [228,]  0.629758330
## [229,] -0.996150232
## [230,] -0.702216773
## [231,] -0.067396541
## [232,]  1.961733433
## [233,] -0.298995361
## [234,]  1.961733433
## [235,]  1.295745882
## [236,]  1.961733433
## [237,] -0.218195669
## [238,]  1.961733433
## [239,] -0.179363553
## [240,]  0.629758330
## [241,]  1.961733433
## [242,] -0.570833703
## [243,] -0.167612291
## [244,] -0.923471736
## [245,] -0.198779611
## [246,]  0.224314258
## [247,] -0.710337968
## [248,] -0.570833703
## [249,]  1.295745882
## [250,]  1.779766985
## [251,]  1.961733433
## [252,]  1.458296271
## [253,] -0.005061901
## [254,]  0.185025743
## [255,]  0.304657550
## [256,]  1.427128951
## [257,]  1.295745882
## [258,]  1.961733433
## [259,]  1.961733433
## [260,]  0.181395676
## [261,]  1.295745882
## [262,] -0.047524084
## [263,]  0.095153849
## [264,]  0.288871559
## [265,] -0.539666383
## [266,] -0.044350417
## [267,]  0.249583043
## [268,]  0.355697328
## [269,] -0.380746059
## [270,] -0.067396541
## [271,] -0.679170648
## [272,] -0.570833703
## [273,]  1.961733433
## [274,] -0.294504232
## [275,] -0.520250325
## [276,] -0.349578739
## [277,]  1.779766985
## [278,] -0.702216773
## [279,]  0.394985844
## [280,] -0.923471736
## [281,]  1.961733433
## [282,] -0.923471736
## [283,] -1.186237876
## [284,]  1.961733433
## [285,]  0.819845974
## [286,]  0.022475353
## [287,] -0.682800714
## [288,] -0.539666383
## [289,] -0.131953842
## [290,] -0.578954898
## [291,] -0.520250325
## [292,] -0.276900243
## [293,] -0.408283313
## [294,]  1.427128951
## [295,] -0.721632831
## [296,] -1.074270864
## [297,]  1.001812422
## [298,] -0.547787578
## [299,]  1.295745882
## [300,]  0.475329136
## [301,] -0.492713071
## [302,] -0.861137096
## [303,]  1.961733433
## [304,] -0.884183221
## [305,] -0.036229221
## [306,] -0.915350541
## [307,] -0.988029037
## [308,] -1.074270864
## [309,] -1.074270864
## [310,] -0.198779611
## [311,]  0.347576132
## [312,]  0.982396364
## [313,]  0.041891411
## [314,] -0.671049452
## [315,] -0.520250325
## [316,] -0.660705597
## [317,] -0.996150232
## [318,] -0.671049452
## [319,] -0.733384093
## [320,] -0.543296449
## [321,]  0.145737227
## [322,]  1.961733433
## [323,] -0.721632831
## [324,]  0.629758330
summary(EFA.model.CMM.4$scores)
##       MR1         
##  Min.   :-1.3682  
##  1st Qu.:-0.7216  
##  Median :-0.2927  
##  Mean   : 0.0000  
##  3rd Qu.: 0.6298  
##  Max.   : 1.9617
#feel for distribution of factor scores
summary(df.CMM.4)
##  t2_cmm_2_reversed t2_cmm_7_reversed t2_cmm_9_reversed t2_cmm_10_reversed
##  Min.   :1.00      Min.   :1.000     Min.   :1.000     Min.   :1.000     
##  1st Qu.:2.00      1st Qu.:2.000     1st Qu.:2.000     1st Qu.:2.000     
##  Median :3.00      Median :3.000     Median :2.500     Median :3.000     
##  Mean   :3.12      Mean   :3.108     Mean   :2.972     Mean   :2.997     
##  3rd Qu.:5.00      3rd Qu.:4.000     3rd Qu.:4.000     3rd Qu.:4.000     
##  Max.   :6.00      Max.   :6.000     Max.   :6.000     Max.   :6.000
plot(density(EFA.model.CMM.4$scores))

describe(df.CMM.4)
## df.CMM.4 
## 
##  4  Variables      324  Observations
## --------------------------------------------------------------------------------
## t2_cmm_2_reversed 
##        n  missing distinct     Info     Mean      Gmd 
##      324        0        6    0.962     3.12    1.845 
## 
## lowest : 1 2 3 4 5, highest: 2 3 4 5 6
##                                               
## Value          1     2     3     4     5     6
## Frequency     57    87    63    32    47    38
## Proportion 0.176 0.269 0.194 0.099 0.145 0.117
## --------------------------------------------------------------------------------
## t2_cmm_7_reversed 
##        n  missing distinct     Info     Mean      Gmd 
##      324        0        6    0.959    3.108    1.784 
## 
## lowest : 1 2 3 4 5, highest: 2 3 4 5 6
##                                               
## Value          1     2     3     4     5     6
## Frequency     51    89    75    30    41    38
## Proportion 0.157 0.275 0.231 0.093 0.127 0.117
## --------------------------------------------------------------------------------
## t2_cmm_9_reversed 
##        n  missing distinct     Info     Mean      Gmd 
##      324        0        6     0.95    2.972    1.754 
## 
## lowest : 1 2 3 4 5, highest: 2 3 4 5 6
##                                               
## Value          1     2     3     4     5     6
## Frequency     55   107    58    37    30    37
## Proportion 0.170 0.330 0.179 0.114 0.093 0.114
## --------------------------------------------------------------------------------
## t2_cmm_10_reversed 
##        n  missing distinct     Info     Mean      Gmd 
##      324        0        6    0.954    2.997    1.731 
## 
## lowest : 1 2 3 4 5, highest: 2 3 4 5 6
##                                               
## Value          1     2     3     4     5     6
## Frequency     54    97    73    28    40    32
## Proportion 0.167 0.299 0.225 0.086 0.123 0.099
## --------------------------------------------------------------------------------
describe(df$cmm_t2_score_4)
## df$cmm_t2_score_4 
##        n  missing distinct     Info     Mean      Gmd      .05      .10 
##      324        0       21    0.994    3.049    1.587     1.25     1.50 
##      .25      .50      .75      .90      .95 
##     2.00     2.50     4.00     5.50     6.00 
## 
## lowest : 1.00 1.25 1.50 1.75 2.00, highest: 5.00 5.25 5.50 5.75 6.00
#does CMM differ by condition? CMM data does not seem normally distributed so will use Kruskal-Wallis test suggested for comparison of means using continuous and categorical data  - non par

str(df)
## tibble [324 × 22] (S3: tbl_df/tbl/data.frame)
##  $ ffmq15_5f                  : num [1:324] 37.7 35 37 32.7 38.3 ...
##  $ ffmq_obs                   : num [1:324] 10.67 8.33 8.33 9.67 9.33 ...
##  $ ffmq_des                   : num [1:324] 6.33 8 8 7.33 6.33 ...
##  $ ffmq_awa                   : num [1:324] 4.33 6.67 4.67 3.33 8.67 ...
##  $ ffmq_nj                    : num [1:324] 5.67 5 7 3.67 7.67 ...
##  $ ffmq_nr                    : num [1:324] 10.67 7 9 8.67 6.33 ...
##  $ MetAwa                     : num [1:324] 16.8 14.8 15.6 16.8 18 12.6 16.8 19 18 7.2 ...
##  $ cmm_t2_score               : num [1:324] 3.4 3.2 3.2 3.2 3.3 3.4 3.1 3.3 3 3.2 ...
##  $ mndst_intelligence_t2_score: num [1:324] 3.25 3.5 3.25 3.75 3.62 ...
##  $ mndst_process_t2_score     : num [1:324] 2.86 2.43 2.29 3.43 3.86 ...
##  $ mndst_exercise_t2_score    : num [1:324] 3.6 4.24 4.24 4.32 7 3.64 4.92 5.2 5 4.8 ...
##  $ mndst_fail_t2_score        : num [1:324] 3.67 3.5 3.5 3.83 3.5 ...
##  $ mndst_pers_t2_score        : num [1:324] 4 3.75 3.75 4 4 ...
##  $ mndst_stress_t2_score      : num [1:324] 2.25 2.5 2.12 2.5 3.12 ...
##  $ subid_final                : num [1:324] 12 14 286 96 118 4 36 227 7 1 ...
##  $ condition                  : chr [1:324] "full_intervention" "abr_intervention" "active_control" "active_control" ...
##  $ sfmm_all9_t2_score         : num [1:324] 5.11 4.22 5 5.22 6 ...
##  $ cmm_t2_score_6             : num [1:324] 2.17 2.5 2.17 1.83 1.5 ...
##  $ selfefficacy_score         : num [1:324] 35 25 29 35 40 26 30 37 34 31 ...
##  $ posaff_sum                 : num [1:324] 37 26 33 39 42 16 37 39 40 43 ...
##  $ negaff_sum                 : num [1:324] 40 28 38 46 10 18 33 44 42 14 ...
##  $ cmm_t2_score_4             : num [1:324] 2.25 2.25 2 1.75 1.25 2.75 2 1.75 1.5 1.75 ...

#changing data to factors and proper contrasts for conditions in CMM

Let’s tidy the data

d.cmm.4 <- df %>%
  select(subid_final, condition, cmm_t2_score_4)%>%
  gather(item, score, contains("cmm"))%>%
  separate(item, sep = "_", into = c("construct_name", "type", "time", "score_name"))%>%
  select(-construct_name, -score_name, -type)

Let’s change data to be numeric & factors (and appropriate contrasts)

#Make Rating Numeric

d.cmm.4$score <- as.numeric(df$cmm_t2_score_4)

#Factor Condition
d.cmm.4$condition <- as.factor(d.cmm.4$condition)
contrasts(d.cmm.4$condition)
##                   active_control full_intervention
## abr_intervention               0                 0
## active_control                 1                 0
## full_intervention              0                 1
contrasts(d.cmm.4$condition) = cbind(dummy_full_vs_control = c(0,0,1), dummy_abridged_vs_control = c(1,0,0))
contrasts(d.cmm.4$condition)
##                   dummy_full_vs_control dummy_abridged_vs_control
## abr_intervention                      0                         1
## active_control                        0                         0
## full_intervention                     1                         0
#Factor subject id

d.cmm.4$subid_final <- as.factor(d.cmm.4$subid_final)
levels(d.cmm.4$condition)
## [1] "abr_intervention"  "active_control"    "full_intervention"
library(dplyr)


#summary by condition - for CMM.4
group_by(d.cmm.4, condition) %>%
  summarise( count = n(), mean = mean(score),
             sd = sd(score),
             median = median(score),
             IQR = IQR(score))
## `summarise()` ungrouping output (override with `.groups` argument)
## # A tibble: 3 x 6
##   condition         count  mean    sd median   IQR
##   <fct>             <int> <dbl> <dbl>  <dbl> <dbl>
## 1 abr_intervention    112  3.16  1.50   2.75  2.25
## 2 active_control      107  3.00  1.42   2.5   2.25
## 3 full_intervention   105  2.98  1.40   2.5   1.5
##mean for full intervention is lowest
##use lm to determine if there is a difference in cmm by condition - evidence suggests - no?

cmm.lm <- lm(d.cmm.4$score ~ d.cmm.4$condition)

summary(cmm.lm)
## 
## Call:
## lm(formula = d.cmm.4$score ~ d.cmm.4$condition)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.0023 -1.1607 -0.4786  0.8789  3.0214 
## 
## Coefficients:
##                                            Estimate Std. Error t value Pr(>|t|)
## (Intercept)                                 3.00234    0.13928  21.556   <2e-16
## d.cmm.4$conditiondummy_full_vs_control     -0.02377    0.19791  -0.120    0.904
## d.cmm.4$conditiondummy_abridged_vs_control  0.15838    0.19476   0.813    0.417
##                                               
## (Intercept)                                ***
## d.cmm.4$conditiondummy_full_vs_control        
## d.cmm.4$conditiondummy_abridged_vs_control    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.441 on 321 degrees of freedom
## Multiple R-squared:  0.003219,   Adjusted R-squared:  -0.002992 
## F-statistic: 0.5183 on 2 and 321 DF,  p-value: 0.5961
#non parametric model diff between condition on cmm? - NO

kruskal.test(cmm_t2_score_4 ~ condition, data = df)
## 
##  Kruskal-Wallis rank sum test
## 
## data:  cmm_t2_score_4 by condition
## Kruskal-Wallis chi-squared = 0.89637, df = 2, p-value = 0.6388
kruskal.test(score ~ condition, data = d.cmm.4)
## 
##  Kruskal-Wallis rank sum test
## 
## data:  score by condition
## Kruskal-Wallis chi-squared = 0.89637, df = 2, p-value = 0.6388
#variable correlations - CMM strong cor with intelligence, failure, personality, and ffmq, .2 for stress, strong 10 item and 6 item as expected, strong correlations with same 6 item but little les

library(corrplot)
library(corrr)

cor.df <- df %>% select(cmm_t2_score, mndst_intelligence_t2_score, mndst_process_t2_score, mndst_exercise_t2_score, mndst_fail_t2_score, mndst_pers_t2_score, mndst_stress_t2_score, ffmq15_5f, MetAwa, cmm_t2_score_6, cmm_t2_score_4, selfefficacy_score, posaff_sum, negaff_sum)





cor.df <- cor(cor.df, method = "pearson")

print(cor.df)# correlations between variables ** #strong cor with int, pers, mindfulness, pos and neg aff
##                             cmm_t2_score mndst_intelligence_t2_score
## cmm_t2_score                 1.000000000                   0.4980558
## mndst_intelligence_t2_score  0.498055810                   1.0000000
## mndst_process_t2_score      -0.094740700                   0.1810352
## mndst_exercise_t2_score      0.131160900                   0.2499219
## mndst_fail_t2_score          0.667283008                   0.4320036
## mndst_pers_t2_score          0.564614591                   0.6684287
## mndst_stress_t2_score        0.206082087                   0.2630046
## ffmq15_5f                    0.618308306                   0.3819139
## MetAwa                      -0.005256606                   0.1258818
## cmm_t2_score_6               0.952440527                   0.4322670
## cmm_t2_score_4               0.944059574                   0.4214614
## selfefficacy_score           0.287431561                   0.2737648
## posaff_sum                  -0.130889122                   0.1151058
## negaff_sum                  -0.635583384                  -0.2721320
##                             mndst_process_t2_score mndst_exercise_t2_score
## cmm_t2_score                            -0.0947407              0.13116090
## mndst_intelligence_t2_score              0.1810352              0.24992194
## mndst_process_t2_score                   1.0000000              0.53762085
## mndst_exercise_t2_score                  0.5376208              1.00000000
## mndst_fail_t2_score                      0.1161936              0.19133976
## mndst_pers_t2_score                      0.1364244              0.18528674
## mndst_stress_t2_score                    0.2638673              0.19276511
## ffmq15_5f                                0.2093272              0.35009636
## MetAwa                                   0.1807367              0.10518023
## cmm_t2_score_6                          -0.2039079              0.04436655
## cmm_t2_score_4                          -0.1981307              0.04900776
## selfefficacy_score                       0.3775149              0.35701330
## posaff_sum                               0.5857798              0.49644524
## negaff_sum                              -0.1206436             -0.34669977
##                             mndst_fail_t2_score mndst_pers_t2_score
## cmm_t2_score                         0.66728301          0.56461459
## mndst_intelligence_t2_score          0.43200355          0.66842872
## mndst_process_t2_score               0.11619360          0.13642443
## mndst_exercise_t2_score              0.19133976          0.18528674
## mndst_fail_t2_score                  1.00000000          0.38026763
## mndst_pers_t2_score                  0.38026763          1.00000000
## mndst_stress_t2_score                0.39500577          0.20535604
## ffmq15_5f                            0.53206639          0.38638805
## MetAwa                               0.08867452          0.04213356
## cmm_t2_score_6                       0.61276266          0.47969513
## cmm_t2_score_4                       0.61162301          0.46878145
## selfefficacy_score                   0.34144717          0.25067094
## posaff_sum                           0.08139726          0.02478875
## negaff_sum                          -0.52414531         -0.26671057
##                             mndst_stress_t2_score  ffmq15_5f       MetAwa
## cmm_t2_score                           0.20608209  0.6183083 -0.005256606
## mndst_intelligence_t2_score            0.26300457  0.3819139  0.125881813
## mndst_process_t2_score                 0.26386728  0.2093272  0.180736671
## mndst_exercise_t2_score                0.19276511  0.3500964  0.105180233
## mndst_fail_t2_score                    0.39500577  0.5320664  0.088674522
## mndst_pers_t2_score                    0.20535604  0.3863880  0.042133559
## mndst_stress_t2_score                  1.00000000  0.1628913  0.027343666
## ffmq15_5f                              0.16289126  1.0000000  0.236757434
## MetAwa                                 0.02734367  0.2367574  1.000000000
## cmm_t2_score_6                         0.15816946  0.5523426 -0.107135029
## cmm_t2_score_4                         0.14009778  0.5535466 -0.109644666
## selfefficacy_score                     0.12576554  0.4773617  0.392697705
## posaff_sum                             0.13865123  0.1784645  0.401485553
## negaff_sum                            -0.14315856 -0.5561133  0.166435584
##                             cmm_t2_score_6 cmm_t2_score_4 selfefficacy_score
## cmm_t2_score                    0.95244053     0.94405957          0.2874316
## mndst_intelligence_t2_score     0.43226703     0.42146141          0.2737648
## mndst_process_t2_score         -0.20390785    -0.19813067          0.3775149
## mndst_exercise_t2_score         0.04436655     0.04900776          0.3570133
## mndst_fail_t2_score             0.61276266     0.61162301          0.3414472
## mndst_pers_t2_score             0.47969513     0.46878145          0.2506709
## mndst_stress_t2_score           0.15816946     0.14009778          0.1257655
## ffmq15_5f                       0.55234262     0.55354656          0.4773617
## MetAwa                         -0.10713503    -0.10964467          0.3926977
## cmm_t2_score_6                  1.00000000     0.98589374          0.1156522
## cmm_t2_score_4                  0.98589374     1.00000000          0.1191795
## selfefficacy_score              0.11565215     0.11917955          1.0000000
## posaff_sum                     -0.29773353    -0.29273330          0.5225285
## negaff_sum                     -0.66160617    -0.65322463         -0.1643181
##                              posaff_sum negaff_sum
## cmm_t2_score                -0.13088912 -0.6355834
## mndst_intelligence_t2_score  0.11510584 -0.2721320
## mndst_process_t2_score       0.58577976 -0.1206436
## mndst_exercise_t2_score      0.49644524 -0.3466998
## mndst_fail_t2_score          0.08139726 -0.5241453
## mndst_pers_t2_score          0.02478875 -0.2667106
## mndst_stress_t2_score        0.13865123 -0.1431586
## ffmq15_5f                    0.17846455 -0.5561133
## MetAwa                       0.40148555  0.1664356
## cmm_t2_score_6              -0.29773353 -0.6616062
## cmm_t2_score_4              -0.29273330 -0.6532246
## selfefficacy_score           0.52252851 -0.1643181
## posaff_sum                   1.00000000  0.0739562
## negaff_sum                   0.07395620  1.0000000
corrplot(cor.df) #visualize variable relations **

corrplot(cor.df, method="number", type="lower")

corrplot.mixed(cor.df)

#diff cor method, rounded

cor.r.df <-round(cor(cor.df),2)

cor.r.df ## pay attention to cmm4
##                             cmm_t2_score mndst_intelligence_t2_score
## cmm_t2_score                        1.00                        0.72
## mndst_intelligence_t2_score         0.72                        1.00
## mndst_process_t2_score             -0.49                       -0.17
## mndst_exercise_t2_score            -0.05                        0.13
## mndst_fail_t2_score                 0.90                        0.68
## mndst_pers_t2_score                 0.78                        0.90
## mndst_stress_t2_score               0.19                        0.26
## ffmq15_5f                           0.82                        0.61
## MetAwa                             -0.50                       -0.35
## cmm_t2_score_6                      0.99                        0.69
## cmm_t2_score_4                      0.99                        0.69
## selfefficacy_score                  0.04                        0.11
## posaff_sum                         -0.66                       -0.38
## negaff_sum                         -0.92                       -0.68
##                             mndst_process_t2_score mndst_exercise_t2_score
## cmm_t2_score                                 -0.49                   -0.05
## mndst_intelligence_t2_score                  -0.17                    0.13
## mndst_process_t2_score                        1.00                    0.75
## mndst_exercise_t2_score                       0.75                    1.00
## mndst_fail_t2_score                          -0.27                    0.10
## mndst_pers_t2_score                          -0.28                    0.02
## mndst_stress_t2_score                         0.17                    0.18
## ffmq15_5f                                    -0.09                    0.32
## MetAwa                                        0.31                    0.07
## cmm_t2_score_6                               -0.55                   -0.11
## cmm_t2_score_4                               -0.55                   -0.11
## selfefficacy_score                            0.50                    0.54
## posaff_sum                                    0.84                    0.61
## negaff_sum                                    0.14                   -0.32
##                             mndst_fail_t2_score mndst_pers_t2_score
## cmm_t2_score                               0.90                0.78
## mndst_intelligence_t2_score                0.68                0.90
## mndst_process_t2_score                    -0.27               -0.28
## mndst_exercise_t2_score                    0.10                0.02
## mndst_fail_t2_score                        1.00                0.67
## mndst_pers_t2_score                        0.67                1.00
## mndst_stress_t2_score                      0.41                0.18
## ffmq15_5f                                  0.82                0.62
## MetAwa                                    -0.40               -0.45
## cmm_t2_score_6                             0.87                0.76
## cmm_t2_score_4                             0.87                0.76
## selfefficacy_score                         0.19                0.04
## posaff_sum                                -0.45               -0.50
## negaff_sum                                -0.91               -0.70
##                             mndst_stress_t2_score ffmq15_5f MetAwa
## cmm_t2_score                                 0.19      0.82  -0.50
## mndst_intelligence_t2_score                  0.26      0.61  -0.35
## mndst_process_t2_score                       0.17     -0.09   0.31
## mndst_exercise_t2_score                      0.18      0.32   0.07
## mndst_fail_t2_score                          0.41      0.82  -0.40
## mndst_pers_t2_score                          0.18      0.62  -0.45
## mndst_stress_t2_score                        1.00      0.14  -0.31
## ffmq15_5f                                    0.14      1.00  -0.17
## MetAwa                                      -0.31     -0.17   1.00
## cmm_t2_score_6                               0.18      0.78  -0.54
## cmm_t2_score_4                               0.17      0.78  -0.54
## selfefficacy_score                          -0.05      0.44   0.44
## posaff_sum                                  -0.06     -0.24   0.59
## negaff_sum                                  -0.31     -0.90   0.45
##                             cmm_t2_score_6 cmm_t2_score_4 selfefficacy_score
## cmm_t2_score                          0.99           0.99               0.04
## mndst_intelligence_t2_score           0.69           0.69               0.11
## mndst_process_t2_score               -0.55          -0.55               0.50
## mndst_exercise_t2_score              -0.11          -0.11               0.54
## mndst_fail_t2_score                   0.87           0.87               0.19
## mndst_pers_t2_score                   0.76           0.76               0.04
## mndst_stress_t2_score                 0.18           0.17              -0.05
## ffmq15_5f                             0.78           0.78               0.44
## MetAwa                               -0.54          -0.54               0.44
## cmm_t2_score_6                        1.00           1.00              -0.05
## cmm_t2_score_4                        1.00           1.00              -0.05
## selfefficacy_score                   -0.05          -0.05               1.00
## posaff_sum                           -0.73          -0.72               0.59
## negaff_sum                           -0.89          -0.89              -0.23
##                             posaff_sum negaff_sum
## cmm_t2_score                     -0.66      -0.92
## mndst_intelligence_t2_score      -0.38      -0.68
## mndst_process_t2_score            0.84       0.14
## mndst_exercise_t2_score           0.61      -0.32
## mndst_fail_t2_score              -0.45      -0.91
## mndst_pers_t2_score              -0.50      -0.70
## mndst_stress_t2_score            -0.06      -0.31
## ffmq15_5f                        -0.24      -0.90
## MetAwa                            0.59       0.45
## cmm_t2_score_6                   -0.73      -0.89
## cmm_t2_score_4                   -0.72      -0.89
## selfefficacy_score                0.59      -0.23
## posaff_sum                        1.00       0.39
## negaff_sum                        0.39       1.00
#pmatrix

library(ggcorrplot)

p.mat.df <- cor_pmat(cor.df)


ggcorrplot(cor.df)

ggcorrplot(cor.df, p.mat = p.mat.df) ##pmatrix of correllogram - X = nonsig at <.05 - 

#CMM4 sig relationship with intel, process, fail, pers, mindfulness, metaAwa,pos, neg aff
#use corrplot for p-matrix, last coeff seemd high using ggplot

corp3 <- cor.mtest(cor.df, conf.level = .95)
corrplot(cor.df, p.mat = corp3$p, sig.level = .05)

#scatter plots with fitted lines - simple linear models with mindfulness and mindsets (Y ~ X=CMM)

#scatterplot with fitted line cmm x ffmq
ggplot(df, aes(x = cmm_t2_score_4, y = ffmq15_5f)) +
  geom_point() +
  stat_smooth()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

#scatterplot with fitted line cmm x sfmm mindset
ggplot(df, aes(x = cmm_t2_score_4, y = sfmm_all9_t2_score)) +
  geom_point() +
  stat_smooth()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

#intelligence
ggplot(df, aes(x = cmm_t2_score_4, y = mndst_intelligence_t2_score)) +
  geom_point() +
  stat_smooth()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

#exercise
ggplot(df, aes(x = cmm_t2_score_4, y = mndst_exercise_t2_score)) +
  geom_point() +
  stat_smooth()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

#fail
ggplot(df, aes(x = cmm_t2_score_4, y = mndst_fail_t2_score)) +
  geom_point() +
  stat_smooth()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

#pers
ggplot(df, aes(x = cmm_t2_score_4, y = mndst_pers_t2_score)) +
  geom_point() +
  stat_smooth()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

#stress
ggplot(df, aes(x = cmm_t2_score_4, y = mndst_stress_t2_score)) +
  geom_point() +
  stat_smooth()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

#process
ggplot(df, aes(x = cmm_t2_score_4, y = mndst_process_t2_score)) +
  geom_point() +
  stat_smooth()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

#Metawareness
ggplot(df, aes(x = cmm_t2_score_4, y = MetAwa)) +
  geom_point() +
  stat_smooth()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

#self-eff
ggplot(df, aes(x = cmm_t2_score_4, y = selfefficacy_score)) +
  geom_point() +
  stat_smooth()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

#pos aff
ggplot(df, aes(x = cmm_t2_score_4, y = posaff_sum)) +
  geom_point() +
  stat_smooth()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

#neg aff
ggplot(df, aes(x = cmm_t2_score_4, y = negaff_sum)) +
  geom_point() +
  stat_smooth()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

#simple linear models with mindfulness and mindsets and other variables
 ##build linear regression variables for summary statistics -

#mindfulness
df.lm.4.ffmq <- lm(ffmq15_5f ~ cmm_t2_score_4, data=df)  

#failure
df.lm.4.fail<- lm(mndst_fail_t2_score ~ cmm_t2_score_4, data=df) 

#intelligence
df.lm.4.int<- lm(mndst_intelligence_t2_score ~ cmm_t2_score_4, data=df)

#persistence
df.lm.4.pers<- lm(mndst_pers_t2_score ~ cmm_t2_score_4, data=df)

#process
df.lm.4.proc<- lm(mndst_process_t2_score ~ cmm_t2_score_4, data=df)  

#exercise
df.lm.4.exer<- lm(mndst_exercise_t2_score ~ cmm_t2_score_4, data=df) 

#stress
df.lm.4.str<- lm(mndst_stress_t2_score ~ cmm_t2_score_4, data=df)

#sfmm
df.lm.4.sfmm <- lm(sfmm_all9_t2_score ~ cmm_t2_score_4, data=df)

#metaawa
df.lm.4.met <- lm(MetAwa ~ cmm_t2_score_4, data=df)

#self-eff
df.lm.4.eff <- lm(selfefficacy_score ~ cmm_t2_score_4, data=df)

#posaff
df.lm.4.pos <- lm(posaff_sum ~ cmm_t2_score_4, data=df)

#negaff
df.lm.4.neg <- lm(negaff_sum ~ cmm_t2_score_4, data=df)
#summary of models - sig predictor linear models CMM predicts ffmq, fail, int, pers, proc, str, metAwa, self-eff

#sig
summary(df.lm.4.ffmq)
## 
## Call:
## lm(formula = ffmq15_5f ~ cmm_t2_score_4, data = df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -14.0634  -2.7395   0.1322   2.4069  13.9366 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     32.0838     0.5800   55.32   <2e-16 ***
## cmm_t2_score_4   2.0522     0.1721   11.93   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.449 on 322 degrees of freedom
## Multiple R-squared:  0.3064, Adjusted R-squared:  0.3043 
## F-statistic: 142.3 on 1 and 322 DF,  p-value: < 2.2e-16
summary(df.lm.4.fail)
## 
## Call:
## lm(formula = mndst_fail_t2_score ~ cmm_t2_score_4, data = df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.88909 -0.36720 -0.03387  0.29947  2.21750 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     2.85626    0.08232   34.70   <2e-16 ***
## cmm_t2_score_4  0.33881    0.02442   13.87   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6314 on 322 degrees of freedom
## Multiple R-squared:  0.3741, Adjusted R-squared:  0.3721 
## F-statistic: 192.4 on 1 and 322 DF,  p-value: < 2.2e-16
summary(df.lm.4.int)
## 
## Call:
## lm(formula = mndst_intelligence_t2_score ~ cmm_t2_score_4, data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.3739 -0.2493  0.0010  0.3756  2.1883 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     2.93710    0.10100   29.08  < 2e-16 ***
## cmm_t2_score_4  0.24988    0.02996    8.34  2.2e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.7747 on 322 degrees of freedom
## Multiple R-squared:  0.1776, Adjusted R-squared:  0.1751 
## F-statistic: 69.55 on 1 and 322 DF,  p-value: 2.202e-15
summary(df.lm.4.pers)
## 
## Call:
## lm(formula = mndst_pers_t2_score ~ cmm_t2_score_4, data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.1527 -0.3021  0.0805  0.4143  2.5881 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     3.25947    0.11654  27.968   <2e-16 ***
## cmm_t2_score_4  0.32926    0.03457   9.523   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8939 on 322 degrees of freedom
## Multiple R-squared:  0.2198, Adjusted R-squared:  0.2173 
## F-statistic: 90.69 on 1 and 322 DF,  p-value: < 2.2e-16
summary(df.lm.4.proc)
## 
## Call:
## lm(formula = mndst_process_t2_score ~ cmm_t2_score_4, data = df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.31301 -0.38885 -0.04165  0.34901  1.27830 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     3.19885    0.07390  43.286  < 2e-16 ***
## cmm_t2_score_4 -0.07952    0.02192  -3.627 0.000333 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.5668 on 322 degrees of freedom
## Multiple R-squared:  0.03926,    Adjusted R-squared:  0.03627 
## F-statistic: 13.16 on 1 and 322 DF,  p-value: 0.000333
summary(df.lm.4.str)
## 
## Call:
## lm(formula = mndst_stress_t2_score ~ cmm_t2_score_4, data = df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.28656 -0.27528  0.02818  0.31885  1.83692 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     1.88899    0.08797  21.474   <2e-16 ***
## cmm_t2_score_4  0.06626    0.02610   2.539   0.0116 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6747 on 322 degrees of freedom
## Multiple R-squared:  0.01963,    Adjusted R-squared:  0.01658 
## F-statistic: 6.447 on 1 and 322 DF,  p-value: 0.01159
summary(df.lm.4.met)
## 
## Call:
## lm(formula = MetAwa ~ cmm_t2_score_4, data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -9.1900 -1.8541  0.0931  1.7553  6.1384 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     16.1296     0.3599  44.822   <2e-16 ***
## cmm_t2_score_4  -0.2113     0.1068  -1.979   0.0486 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.76 on 322 degrees of freedom
## Multiple R-squared:  0.01202,    Adjusted R-squared:  0.008954 
## F-statistic: 3.918 on 1 and 322 DF,  p-value: 0.04862
summary(df.lm.4.eff)
## 
## Call:
## lm(formula = selfefficacy_score ~ cmm_t2_score_4, data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -12.097  -3.092  -0.183   3.183   9.183 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     30.3604     0.5721  53.064   <2e-16 ***
## cmm_t2_score_4   0.3656     0.1697   2.154    0.032 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.389 on 322 degrees of freedom
## Multiple R-squared:  0.0142, Adjusted R-squared:  0.01114 
## F-statistic:  4.64 on 1 and 322 DF,  p-value: 0.03199
summary(df.lm.4.pos)
## 
## Call:
## lm(formula = posaff_sum ~ cmm_t2_score_4, data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -20.180  -4.300   0.334   4.466  15.820 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     38.3605     0.9389  40.858  < 2e-16 ***
## cmm_t2_score_4  -1.5302     0.2785  -5.494 8.01e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7.202 on 322 degrees of freedom
## Multiple R-squared:  0.08569,    Adjusted R-squared:  0.08285 
## F-statistic: 30.18 on 1 and 322 DF,  p-value: 8.012e-08
summary(df.lm.4.neg)
## 
## Call:
## lm(formula = negaff_sum ~ cmm_t2_score_4, data = df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -25.4406  -5.5408   0.5393   6.5960  16.7659 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     42.0739     1.1554   36.41   <2e-16 ***
## cmm_t2_score_4  -5.3066     0.3428  -15.48   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 8.863 on 322 degrees of freedom
## Multiple R-squared:  0.4267, Adjusted R-squared:  0.4249 
## F-statistic: 239.7 on 1 and 322 DF,  p-value: < 2.2e-16
#nonsig - interesting that only variables cmm did not significantly predict was exercise and sfmm
summary(df.lm.4.exer)
## 
## Call:
## lm(formula = mndst_exercise_t2_score ~ cmm_t2_score_4, data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.2946 -0.6702 -0.1503  0.7572  2.3744 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     4.58593    0.15204   30.16   <2e-16 ***
## cmm_t2_score_4  0.03971    0.04511    0.88    0.379    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.166 on 322 degrees of freedom
## Multiple R-squared:  0.002402,   Adjusted R-squared:  -0.0006964 
## F-statistic: 0.7752 on 1 and 322 DF,  p-value: 0.3793
summary(df.lm.4.sfmm)
## 
## Call:
## lm(formula = sfmm_all9_t2_score ~ cmm_t2_score_4, data = df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.42687 -0.50363  0.03594  0.48038  1.27041 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     4.69898    0.08782   53.51   <2e-16 ***
## cmm_t2_score_4  0.02449    0.02605    0.94    0.348    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6736 on 322 degrees of freedom
## Multiple R-squared:  0.002737,   Adjusted R-squared:  -0.0003604 
## F-statistic: 0.8836 on 1 and 322 DF,  p-value: 0.3479
##looking at data descriptives again by cond
describe.by(df, df$condition) #outcome variables by condition # abr > active control > full intervention
## Warning: describe.by is deprecated. Please use the describeBy function
## 
##  Descriptive statistics by group 
## group: abr_intervention
##                             vars   n   mean    sd median trimmed    mad   min
## ffmq15_5f                      1 112  38.58  4.94  37.67   38.05   3.95 30.67
## ffmq_obs                       2 112   8.49  1.78   8.33    8.49   1.98  3.67
## ffmq_des                       3 112   8.01  1.64   7.67    7.90   1.48  4.33
## ffmq_awa                       4 112   7.29  2.40   7.00    7.29   2.47  2.33
## ffmq_nj                        5 112   6.60  2.22   6.33    6.46   2.47  2.33
## ffmq_nr                        6 112   8.18  1.81   8.33    8.22   1.98  2.33
## MetAwa                         7 112  15.41  2.76  15.00   15.48   2.67  7.20
## cmm_t2_score                   8 112   3.86  0.99   3.40    3.72   0.59  2.80
## mndst_intelligence_t2_score    9 112   3.67  0.88   3.50    3.65   0.56  1.00
## mndst_process_t2_score        10 112   2.96  0.56   3.00    2.96   0.64  1.71
## mndst_exercise_t2_score       11 112   4.76  1.28   4.62    4.78   1.16  1.48
## mndst_fail_t2_score           12 112   3.90  0.85   3.67    3.80   0.49  1.67
## mndst_pers_t2_score           13 112   4.39  1.06   4.12    4.31   0.56  1.38
## mndst_stress_t2_score         14 112   2.18  0.68   2.12    2.16   0.46  0.00
## subid_final                   15 112 157.51 95.02 159.50  156.89 123.80  1.00
## condition*                    16 112   1.00  0.00   1.00    1.00   0.00  1.00
## sfmm_all9_t2_score            17 112   4.85  0.62   4.89    4.85   0.66  3.33
## cmm_t2_score_6                18 112   3.15  1.48   2.67    3.00   1.24  1.17
## selfefficacy_score            19 112  31.68  4.49  30.50   31.74   3.71 20.00
## posaff_sum                    20 112  33.31  7.56  34.50   33.87   6.67 11.00
## negaff_sum                    21 112  24.68 11.58  25.00   24.09  16.31 10.00
## cmm_t2_score_4                22 112   3.16  1.50   2.75    3.03   1.11  1.25
##                                max  range  skew kurtosis   se
## ffmq15_5f                    58.33  27.67  1.18     1.81 0.47
## ffmq_obs                     11.67   8.00 -0.06    -0.53 0.17
## ffmq_des                     11.67   7.33  0.53    -0.23 0.16
## ffmq_awa                     11.67   9.33  0.02    -0.70 0.23
## ffmq_nj                      11.67   9.33  0.47    -0.39 0.21
## ffmq_nr                      11.67   9.33 -0.41     0.73 0.17
## MetAwa                       21.00  13.80 -0.36     0.40 0.26
## cmm_t2_score                  6.00   3.20  1.09    -0.23 0.09
## mndst_intelligence_t2_score   6.00   5.00  0.21     1.17 0.08
## mndst_process_t2_score        4.00   2.29 -0.03    -0.58 0.05
## mndst_exercise_t2_score       7.00   5.52 -0.13    -0.20 0.12
## mndst_fail_t2_score           6.00   4.33  0.85     0.73 0.08
## mndst_pers_t2_score           7.00   5.62  0.65     0.58 0.10
## mndst_stress_t2_score         4.00   4.00  0.07     1.98 0.06
## subid_final                 320.00 319.00  0.04    -1.21 8.98
## condition*                    1.00   0.00   NaN      NaN 0.00
## sfmm_all9_t2_score            6.00   2.67 -0.07    -0.57 0.06
## cmm_t2_score_6                6.00   4.83  0.80    -0.74 0.14
## selfefficacy_score           40.00  20.00 -0.07    -0.39 0.42
## posaff_sum                   45.00  34.00 -0.68     0.07 0.71
## negaff_sum                   48.00  38.00  0.24    -1.25 1.09
## cmm_t2_score_4                6.00   4.75  0.74    -0.80 0.14
## ------------------------------------------------------------ 
## group: active_control
##                             vars   n   mean    sd median trimmed    mad   min
## ffmq15_5f                      1 107  38.40  5.47  37.33   37.87   4.45 27.33
## ffmq_obs                       2 107   8.63  1.69   8.67    8.70   1.48  4.33
## ffmq_des                       3 107   7.71  1.81   7.67    7.65   1.98  3.33
## ffmq_awa                       4 107   7.25  2.53   7.00    7.20   2.97  2.33
## ffmq_nj                        5 107   6.59  2.77   6.00    6.48   2.97  2.33
## ffmq_nr                        6 107   8.22  2.09   8.00    8.27   2.47  2.33
## MetAwa                         7 107  15.61  2.71  15.60   15.67   2.97  8.00
## cmm_t2_score                   8 107   3.73  0.84   3.30    3.60   0.44  2.80
## mndst_intelligence_t2_score    9 107   3.69  0.85   3.62    3.62   0.56  1.00
## mndst_process_t2_score        10 107   2.93  0.60   2.86    2.93   0.64  1.43
## mndst_exercise_t2_score       11 107   4.57  1.19   4.52    4.58   0.89  1.68
## mndst_fail_t2_score           12 107   3.87  0.75   3.67    3.78   0.49  2.17
## mndst_pers_t2_score           13 107   4.13  1.03   4.00    4.09   0.37  1.00
## mndst_stress_t2_score         14 107   1.83  0.67   1.88    1.88   0.56  0.00
## subid_final                   15 107 168.17 95.72 165.00  169.05 127.50  3.00
## condition*                    16 107   1.00  0.00   1.00    1.00   0.00  1.00
## sfmm_all9_t2_score            17 107   4.72  0.67   4.78    4.75   0.82  2.33
## cmm_t2_score_6                18 107   2.98  1.39   2.50    2.83   1.24  1.17
## selfefficacy_score            19 107  31.86  4.25  32.00   31.97   4.45 21.00
## posaff_sum                    20 107  34.09  7.98  35.00   34.83   7.41  9.00
## negaff_sum                    21 107  26.38 12.14  27.00   26.11  14.83 10.00
## cmm_t2_score_4                22 107   3.00  1.42   2.50    2.86   1.11  1.00
##                                max  range  skew kurtosis   se
## ffmq15_5f                    56.67  29.33  1.05     1.23 0.53
## ffmq_obs                     11.67   7.33 -0.35    -0.45 0.16
## ffmq_des                     11.67   8.33  0.31    -0.13 0.18
## ffmq_awa                     11.67   9.33  0.18    -0.96 0.24
## ffmq_nj                      11.67   9.33  0.43    -0.90 0.27
## ffmq_nr                      11.67   9.33 -0.29    -0.33 0.20
## MetAwa                       21.00  13.00 -0.17    -0.60 0.26
## cmm_t2_score                  6.00   3.20  1.28     0.50 0.08
## mndst_intelligence_t2_score   6.00   5.00  0.60     2.08 0.08
## mndst_process_t2_score        4.00   2.57 -0.16    -0.43 0.06
## mndst_exercise_t2_score       7.00   5.32 -0.05    -0.08 0.12
## mndst_fail_t2_score           6.00   3.83  1.14     0.98 0.07
## mndst_pers_t2_score           7.00   6.00  0.36     2.28 0.10
## mndst_stress_t2_score         4.00   4.00 -0.51     1.04 0.07
## subid_final                 323.00 320.00 -0.06    -1.38 9.25
## condition*                    1.00   0.00   NaN      NaN 0.00
## sfmm_all9_t2_score            6.00   3.67 -0.52     0.28 0.06
## cmm_t2_score_6                6.00   4.83  0.82    -0.59 0.13
## selfefficacy_score           40.00  19.00 -0.27    -0.37 0.41
## posaff_sum                   45.00  36.00 -0.81     0.20 0.77
## negaff_sum                   50.00  40.00  0.01    -1.39 1.17
## cmm_t2_score_4                6.00   5.00  0.72    -0.72 0.14
## ------------------------------------------------------------ 
## group: full_intervention
##                             vars   n   mean    sd median trimmed    mad   min
## ffmq15_5f                      1 105  38.03  5.62  37.00   37.38   4.45 27.67
## ffmq_obs                       2 105   8.63  1.48   8.33    8.64   1.48  4.67
## ffmq_des                       3 105   7.60  1.75   7.67    7.51   1.98  3.67
## ffmq_awa                       4 105   7.08  2.26   6.67    7.04   2.97  2.33
## ffmq_nj                        5 105   6.64  2.47   6.00    6.51   2.47  2.33
## ffmq_nr                        6 105   8.08  1.89   8.00    8.11   1.98  2.33
## MetAwa                         7 105  15.43  2.87  15.80   15.56   2.97  6.20
## cmm_t2_score                   8 105   3.74  0.92   3.40    3.60   0.44  2.70
## mndst_intelligence_t2_score    9 105   3.73  0.84   3.62    3.63   0.56  1.00
## mndst_process_t2_score        10 105   2.99  0.58   3.00    2.98   0.64  1.71
## mndst_exercise_t2_score       11 105   4.79  1.00   4.52    4.72   0.89  1.88
## mndst_fail_t2_score           12 105   3.89  0.79   3.67    3.77   0.25  2.83
## mndst_pers_t2_score           13 105   4.26  0.92   4.12    4.15   0.56  2.25
## mndst_stress_t2_score         14 105   2.27  0.61   2.12    2.20   0.37  1.00
## subid_final                   15 105 162.05 90.66 167.00  161.49 111.19  4.00
## condition*                    16 105   1.00  0.00   1.00    1.00   0.00  1.00
## sfmm_all9_t2_score            17 105   4.75  0.73   4.78    4.76   0.66  2.56
## cmm_t2_score_6                18 105   3.01  1.36   2.50    2.87   0.99  1.00
## selfefficacy_score            19 105  30.87  4.47  30.00   30.78   5.93 22.00
## posaff_sum                    20 105  33.70  7.03  34.00   33.91   7.41 16.00
## negaff_sum                    21 105  26.69 11.33  28.00   26.48  13.34 10.00
## cmm_t2_score_4                22 105   2.98  1.40   2.50    2.84   1.11  1.00
##                                max  range  skew kurtosis   se
## ffmq15_5f                    58.33  30.67  1.31     2.29 0.55
## ffmq_obs                     11.67   7.00  0.00    -0.27 0.14
## ffmq_des                     11.67   8.00  0.41     0.06 0.17
## ffmq_awa                     11.67   9.33  0.17    -0.76 0.22
## ffmq_nj                      11.67   9.33  0.39    -0.59 0.24
## ffmq_nr                      11.67   9.33 -0.21    -0.36 0.18
## MetAwa                       21.00  14.80 -0.45    -0.02 0.28
## cmm_t2_score                  6.00   3.30  1.33     0.52 0.09
## mndst_intelligence_t2_score   6.00   5.00  1.04     2.25 0.08
## mndst_process_t2_score        4.00   2.29  0.11    -0.72 0.06
## mndst_exercise_t2_score       7.00   5.12  0.48     0.16 0.10
## mndst_fail_t2_score           6.00   3.17  1.39     1.07 0.08
## mndst_pers_t2_score           7.00   4.75  1.26     1.77 0.09
## mndst_stress_t2_score         4.00   3.00  1.03     1.17 0.06
## subid_final                 324.00 320.00  0.02    -1.09 8.85
## condition*                    1.00   0.00   NaN      NaN 0.00
## sfmm_all9_t2_score            6.00   3.44 -0.33     0.00 0.07
## cmm_t2_score_6                6.00   5.00  0.89    -0.30 0.13
## selfefficacy_score           40.00  18.00  0.12    -0.78 0.44
## posaff_sum                   45.00  29.00 -0.34    -0.55 0.69
## negaff_sum                   47.00  37.00 -0.02    -1.23 1.11
## cmm_t2_score_4                6.00   5.00  0.82    -0.41 0.14
describe.by(d.cmm.4, d.cmm.4$condition) ##cmm score by condition
## Warning: describe.by is deprecated. Please use the describeBy function
## 
##  Descriptive statistics by group 
## group: abr_intervention
##              vars   n   mean    sd median trimmed    mad  min max  range skew
## subid_final*    1 112 157.51 95.02 159.50  156.89 123.80 1.00 320 319.00 0.04
## condition*      2 112   1.00  0.00   1.00    1.00   0.00 1.00   1   0.00  NaN
## time*           3 112   1.00  0.00   1.00    1.00   0.00 1.00   1   0.00  NaN
## score           4 112   3.16  1.50   2.75    3.03   1.11 1.25   6   4.75 0.74
##              kurtosis   se
## subid_final*    -1.21 8.98
## condition*        NaN 0.00
## time*             NaN 0.00
## score           -0.80 0.14
## ------------------------------------------------------------ 
## group: active_control
##              vars   n   mean    sd median trimmed    mad min max range  skew
## subid_final*    1 107 168.17 95.72  165.0  169.05 127.50   3 323   320 -0.06
## condition*      2 107   2.00  0.00    2.0    2.00   0.00   2   2     0   NaN
## time*           3 107   1.00  0.00    1.0    1.00   0.00   1   1     0   NaN
## score           4 107   3.00  1.42    2.5    2.86   1.11   1   6     5  0.72
##              kurtosis   se
## subid_final*    -1.38 9.25
## condition*        NaN 0.00
## time*             NaN 0.00
## score           -0.72 0.14
## ------------------------------------------------------------ 
## group: full_intervention
##              vars   n   mean    sd median trimmed    mad min max range skew
## subid_final*    1 105 162.05 90.66  167.0  161.49 111.19   4 324   320 0.02
## condition*      2 105   3.00  0.00    3.0    3.00   0.00   3   3     0  NaN
## time*           3 105   1.00  0.00    1.0    1.00   0.00   1   1     0  NaN
## score           4 105   2.98  1.40    2.5    2.84   1.11   1   6     5 0.82
##              kurtosis   se
## subid_final*    -1.09 8.85
## condition*        NaN 0.00
## time*             NaN 0.00
## score           -0.41 0.14
##boxplots by condition for CMM
boxplot( score ~ condition, data = d.cmm.4)

boxplot(cmm_t2_score_4 ~ condition, data = df)

boxplot(df$cmm_t2_score_4 ~ df$condition, main = "Boxplot", xlab = "Group condition", ylab = "CMM")

#looking at different mediation models --really this is just controlling for next variable?

model_sfmx <- lm(sfmm_all9_t2_score ~ cmm_t2_score_4, data = df)
model_mx <- lm(MetAwa ~ cmm_t2_score_4, data = df)
model_mxmm <- lm(ffmq15_5f ~ cmm_t2_score_4, data = df)
model_sfxm <- lm(sfmm_all9_t2_score ~ cmm_t2_score_4 + MetAwa, data = df) ##or high MA moderates the predictino of cmm to sfmm?
model_sfxmm <- lm(sfmm_all9_t2_score ~ cmm_t2_score_4 + ffmq15_5f, data = df) ## the impact of cmm on sfmm is mediated by mindfulness

summary(model_sfmx)
## 
## Call:
## lm(formula = sfmm_all9_t2_score ~ cmm_t2_score_4, data = df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.42687 -0.50363  0.03594  0.48038  1.27041 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     4.69898    0.08782   53.51   <2e-16 ***
## cmm_t2_score_4  0.02449    0.02605    0.94    0.348    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6736 on 322 degrees of freedom
## Multiple R-squared:  0.002737,   Adjusted R-squared:  -0.0003604 
## F-statistic: 0.8836 on 1 and 322 DF,  p-value: 0.3479
summary(model_mx)
## 
## Call:
## lm(formula = MetAwa ~ cmm_t2_score_4, data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -9.1900 -1.8541  0.0931  1.7553  6.1384 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     16.1296     0.3599  44.822   <2e-16 ***
## cmm_t2_score_4  -0.2113     0.1068  -1.979   0.0486 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.76 on 322 degrees of freedom
## Multiple R-squared:  0.01202,    Adjusted R-squared:  0.008954 
## F-statistic: 3.918 on 1 and 322 DF,  p-value: 0.04862
summary(model_mxmm)
## 
## Call:
## lm(formula = ffmq15_5f ~ cmm_t2_score_4, data = df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -14.0634  -2.7395   0.1322   2.4069  13.9366 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     32.0838     0.5800   55.32   <2e-16 ***
## cmm_t2_score_4   2.0522     0.1721   11.93   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.449 on 322 degrees of freedom
## Multiple R-squared:  0.3064, Adjusted R-squared:  0.3043 
## F-statistic: 142.3 on 1 and 322 DF,  p-value: < 2.2e-16
summary(model_sfxm)
## 
## Call:
## lm(formula = sfmm_all9_t2_score ~ cmm_t2_score_4 + MetAwa, data = df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.15737 -0.38741  0.02108  0.38119  1.65434 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     3.02789    0.21427  14.131  < 2e-16 ***
## cmm_t2_score_4  0.04639    0.02377   1.951   0.0519 .  
## MetAwa          0.10360    0.01233   8.401 1.45e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6109 on 321 degrees of freedom
## Multiple R-squared:  0.1825, Adjusted R-squared:  0.1774 
## F-statistic: 35.82 on 2 and 321 DF,  p-value: 9.053e-15
summary(model_sfxmm) 
## 
## Call:
## lm(formula = sfmm_all9_t2_score ~ cmm_t2_score_4 + ffmq15_5f, 
##     data = df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.43103 -0.44074  0.05335  0.46897  1.49210 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     3.579505   0.277401  12.904  < 2e-16 ***
## cmm_t2_score_4 -0.047113   0.030490  -1.545    0.123    
## ffmq15_5f       0.034892   0.008224   4.243 2.89e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6565 on 321 degrees of freedom
## Multiple R-squared:  0.05569,    Adjusted R-squared:  0.0498 
## F-statistic: 9.465 on 2 and 321 DF,  p-value: 0.0001014
#looking at different mediation models

model_yxi <- lm(mndst_intelligence_t2_score ~ cmm_t2_score_4, data = df)
model_mxi <- lm(MetAwa ~ cmm_t2_score_4, data = df)
model_yxmi <- lm(mndst_intelligence_t2_score ~ cmm_t2_score_4 + MetAwa, data = df)
model_yxmmi <- lm(mndst_intelligence_t2_score~ cmm_t2_score_4 + ffmq15_5f, data = df)

summary(model_yxi)
## 
## Call:
## lm(formula = mndst_intelligence_t2_score ~ cmm_t2_score_4, data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.3739 -0.2493  0.0010  0.3756  2.1883 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     2.93710    0.10100   29.08  < 2e-16 ***
## cmm_t2_score_4  0.24988    0.02996    8.34  2.2e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.7747 on 322 degrees of freedom
## Multiple R-squared:  0.1776, Adjusted R-squared:  0.1751 
## F-statistic: 69.55 on 1 and 322 DF,  p-value: 2.202e-15
summary(model_mxi)
## 
## Call:
## lm(formula = MetAwa ~ cmm_t2_score_4, data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -9.1900 -1.8541  0.0931  1.7553  6.1384 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     16.1296     0.3599  44.822   <2e-16 ***
## cmm_t2_score_4  -0.2113     0.1068  -1.979   0.0486 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.76 on 322 degrees of freedom
## Multiple R-squared:  0.01202,    Adjusted R-squared:  0.008954 
## F-statistic: 3.918 on 1 and 322 DF,  p-value: 0.04862
summary(model_yxmi)
## 
## Call:
## lm(formula = mndst_intelligence_t2_score ~ cmm_t2_score_4 + MetAwa, 
##     data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.4749 -0.2793  0.0459  0.3426  2.1235 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     2.07284    0.26715   7.759 1.15e-13 ***
## cmm_t2_score_4  0.26120    0.02964   8.814  < 2e-16 ***
## MetAwa          0.05358    0.01538   3.485 0.000561 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.7616 on 321 degrees of freedom
## Multiple R-squared:  0.2076, Adjusted R-squared:  0.2027 
## F-statistic: 42.05 on 2 and 321 DF,  p-value: < 2.2e-16
summary(model_yxmmi) 
## 
## Call:
## lm(formula = mndst_intelligence_t2_score ~ cmm_t2_score_4 + ffmq15_5f, 
##     data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.7777 -0.2644  0.0137  0.3360  2.4602 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    1.837682   0.321424   5.717 2.48e-08 ***
## cmm_t2_score_4 0.179557   0.035329   5.082 6.34e-07 ***
## ffmq15_5f      0.034267   0.009529   3.596 0.000374 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.7607 on 321 degrees of freedom
## Multiple R-squared:  0.2095, Adjusted R-squared:  0.2045 
## F-statistic: 42.53 on 2 and 321 DF,  p-value: < 2.2e-16
#looking at different moderation models

model_sfxc <- lm(sfmm_all9_t2_score ~ condition, data = df)
model_sfmxc <- lm(cmm_t2_score_4 ~ condition, data = df)
model_sfmcxc <- lm(sfmm_all9_t2_score ~ condition + cmm_t2_score_4, data = df)

summary(model_sfxc)
## 
## Call:
## lm(formula = sfmm_all9_t2_score ~ condition, data = df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.38318 -0.49429  0.03472  0.47619  1.28349 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 4.85417    0.06359  76.341   <2e-16 ***
## conditionactive_control    -0.13766    0.09097  -1.513    0.131    
## conditionfull_intervention -0.10813    0.09141  -1.183    0.238    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6729 on 321 degrees of freedom
## Multiple R-squared:  0.007887,   Adjusted R-squared:  0.001705 
## F-statistic: 1.276 on 2 and 321 DF,  p-value: 0.2806
summary(model_sfmxc)
## 
## Call:
## lm(formula = cmm_t2_score_4 ~ condition, data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.0023 -1.1607 -0.4786  0.8789  3.0214 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                  3.1607     0.1361  23.217   <2e-16 ***
## conditionactive_control     -0.1584     0.1948  -0.813    0.417    
## conditionfull_intervention  -0.1821     0.1957  -0.931    0.353    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.441 on 321 degrees of freedom
## Multiple R-squared:  0.003219,   Adjusted R-squared:  -0.002992 
## F-statistic: 0.5183 on 2 and 321 DF,  p-value: 0.5961
summary(model_sfmcxc)
## 
## Call:
## lm(formula = sfmm_all9_t2_score ~ condition + cmm_t2_score_4, 
##     data = df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.37196 -0.49005  0.04423  0.49385  1.27238 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 4.78361    0.10412  45.942   <2e-16 ***
## conditionactive_control    -0.13412    0.09110  -1.472    0.142    
## conditionfull_intervention -0.10407    0.09157  -1.136    0.257    
## cmm_t2_score_4              0.02232    0.02608   0.856    0.393    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6732 on 320 degrees of freedom
## Multiple R-squared:  0.01015,    Adjusted R-squared:  0.0008734 
## F-statistic: 1.094 on 3 and 320 DF,  p-value: 0.3517

does CMM moderate the effect of condition on mindsets (sfmm main +)?

Compute the interaction term XZ=X*Z. Fit a multiple regression model with X, Z, and XZ as predictors. Test whether the regression coefficient for XZ is significant or not. Interpret the moderation effect. Display the moderation effect graphically.

#computer interaction term XZ=X*Z

xz<- df$sfmm_all9_t2_score * df$cmm_t2_score_4 #interaction term using x = sfmm z (moderator) = cmm

summary(lm(df$mndst_intelligence_t2_score ~ df$sfmm_all9_t2_score + df$cmm_t2_score_4 + xz)) #using x, z, and xz as predictors
## 
## Call:
## lm(formula = df$mndst_intelligence_t2_score ~ df$sfmm_all9_t2_score + 
##     df$cmm_t2_score_4 + xz)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.4284 -0.2498  0.0367  0.3420  2.5953 
## 
## Coefficients:
##                       Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            3.99000    0.81262   4.910 1.45e-06 ***
## df$sfmm_all9_t2_score -0.18745    0.16072  -1.166  0.24436    
## df$cmm_t2_score_4     -0.47105    0.23232  -2.028  0.04343 *  
## xz                     0.13968    0.04508   3.098  0.00212 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.7439 on 320 degrees of freedom
## Multiple R-squared:  0.2464, Adjusted R-squared:  0.2394 
## F-statistic: 34.88 on 3 and 320 DF,  p-value: < 2.2e-16
# p <.01 suggests there is a sig moderation effect - in other words there is a significant relationship such that sf is moderated by cmm to predict intelligence mindset - the relation between sfmm and int mindset significantly depends on different levels of CMM
#plug in some other mindsets for same model does CMM moderate relationship of SFMM and mindsets?

#computer interaction term XZ=X*Z

xzmi <- df$sfmm_all9_t2_score * df$cmm_t2_score_4 #interaction term using x = sfmm z (moderator) = cmm

summary(lm(df$mndst_stress_t2_score~ df$sfmm_all9_t2_score + df$cmm_t2_score_4 + xzmi)) #using x, z, and xz as predictors
## 
## Call:
## lm(formula = df$mndst_stress_t2_score ~ df$sfmm_all9_t2_score + 
##     df$cmm_t2_score_4 + xzmi)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.6149 -0.3212  0.0230  0.3241  1.7569 
## 
## Coefficients:
##                       Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            4.48866    0.67644   6.636 1.38e-10 ***
## df$sfmm_all9_t2_score -0.49342    0.13379  -3.688 0.000265 ***
## df$cmm_t2_score_4     -1.10680    0.19339  -5.723 2.40e-08 ***
## xzmi                   0.22816    0.03753   6.080 3.42e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6192 on 320 degrees of freedom
## Multiple R-squared:  0.1795, Adjusted R-squared:  0.1718 
## F-statistic: 23.33 on 3 and 320 DF,  p-value: 1.103e-13
# the relationship between sfmm and mindsets (process, exercise, fail, pers, stress)  significantly depends on different levels of CMM
#computer interaction term XZ=X*Z

xzm<- df$cmm_t2_score * df$ffmq15_5f #interaction term using x = sfmm z (moderator) = cmm

summary(lm(df$sfmm_all9_t2_score ~ df$cmm_t2_score_4 + df$ffmq15_5f + xzm)) #using x, z, and xz as predictors
## 
## Call:
## lm(formula = df$sfmm_all9_t2_score ~ df$cmm_t2_score_4 + df$ffmq15_5f + 
##     xzm)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.52471 -0.35698  0.06422  0.36317  1.93081 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        6.50386    0.40254  16.157  < 2e-16 ***
## df$cmm_t2_score_4 -0.54987    0.06101  -9.012  < 2e-16 ***
## df$ffmq15_5f      -0.08843    0.01527  -5.790 1.68e-08 ***
## xzm                0.02254    0.00245   9.202  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.5847 on 320 degrees of freedom
## Multiple R-squared:  0.2533, Adjusted R-squared:  0.2463 
## F-statistic: 36.18 on 3 and 320 DF,  p-value: < 2.2e-16
# p <.0001 suggests there is a sig moderation effect - in other words there is a significant relationship such that the relationship between CMM and mindset (intelligence, process, exercise, fail, pers, stress, sfmm ) significantly depends on different levels of mindfulness 
#plug in some other mindsets for same model does mindfulness moderate relationship of CMM and mindsets?