library(readxl)
library(mediation) #Mediation package
## Warning: package 'mediation' was built under R version 4.0.4
## Loading required package: MASS
## Warning: package 'MASS' was built under R version 4.0.5
## Loading required package: Matrix
## Warning: package 'Matrix' was built under R version 4.0.5
## Loading required package: mvtnorm
## Loading required package: sandwich
## Registered S3 methods overwritten by 'tibble':
##   method     from  
##   format.tbl pillar
##   print.tbl  pillar
## mediation: Causal Mediation Analysis
## Version: 4.5.0
library(rockchalk) #Graphing simple slopes; moderation
## Warning: package 'rockchalk' was built under R version 4.0.4
## 
## Attaching package: 'rockchalk'
## The following object is masked from 'package:MASS':
## 
##     mvrnorm
library(multilevel) #Sobel Test
## Warning: package 'multilevel' was built under R version 4.0.4
## Loading required package: nlme
library(bda) #Another Sobel Test option
## Warning: package 'bda' was built under R version 4.0.5
## Loading required package: boot
## bda v15 (Bin Wang, 2021)
library(MeMoBootR)
## Loading required package: diagram
## Loading required package: shape
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 4.0.5
library(gvlma) #Testing Model Assumptions 
library(stargazer) #Handy regression tables
## 
## Please cite as:
##  Hlavac, Marek (2018). stargazer: Well-Formatted Regression and Summary Statistics Tables.
##  R package version 5.2.2. https://CRAN.R-project.org/package=stargazer
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following object is masked from 'package:nlme':
## 
##     collapse
## The following object is masked from 'package:rockchalk':
## 
##     summarize
## The following object is masked from 'package:MASS':
## 
##     select
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(car)
## Loading required package: carData
## Registered S3 methods overwritten by 'car':
##   method                          from
##   influence.merMod                lme4
##   cooks.distance.influence.merMod lme4
##   dfbeta.influence.merMod         lme4
##   dfbetas.influence.merMod        lme4
## 
## Attaching package: 'car'
## The following object is masked from 'package:dplyr':
## 
##     recode
## The following object is masked from 'package:boot':
## 
##     logit
LEEP_covid <- read.csv("C:/Users/u6032404/OneDrive/backup 9.9.19/MJ/LEEP/QOL/LEEP_covidbig.csv")

LEEP_covid$Fear_seizure<-Recode(LEEP_covid$Fear_seizure, recodes="'Increased'=1;else=0",as.numeric=T)

LEEP_covid$health_conditions<-Recode(LEEP_covid$health_conditions, recodes="'Increased'=1;else=0",as.numeric=T)

#LEEP_covid[LEEP_covid=="No change"]<-0
LEEP_covid[LEEP_covid=="Not applicable"]<-"No change"
#LEEP_covid[LEEP_covid=="Decreased"]<- -1
#LEEP_covid[LEEP_covid=="Increased"]<- 1

#LEEP_covid[]<-lapply(LEEP_covid, function(x) as.numeric(as.character(x)))
  
LEEP_covid<-LEEP_covid %>% 
  filter(!Financial%in%c("Decline to answer", "Don’t know"))


LEEP_covid$f_3<-Recode(LEEP_covid$Financial
,recodes="'You have money to pay the bills, but only because you have to cut back on things.'=2;'You have enough money to pay the bills, but little spare money to buy extra or special things.'= 3;'You are having difficulty paying the bills, no matter what you do.'=1;'After paying the bills, you still have enough money for special things that you want.'= 3 ",as.numeric=T)

LEEP_covid$f_2<-Recode(LEEP_covid$Financial
,recodes="'You are having difficulty paying the bills, no matter what you do.'=0; else = 1 ",as.numeric=T)

Access PHC

LEEP_covid$Access_physicalhealthcare = as.factor(LEEP_covid$Access_physicalhealthcare)
LEEP_covid$Access_physicalhealthcare<-relevel(LEEP_covid$Access_physicalhealthcare, ref = "No change")

saved = mediation1(y = "Fear_seizure", #DV
                   x = "Access_physicalhealthcare", #IV
                   m = "f_3",  #Mediator
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                                    (Intercept)
## (Intercept)                          1.0000000
## Access_physicalhealthcareDecreased  -0.3790685
## Access_physicalhealthcareIncreased  -0.1405875
## f_3                                 -0.9169822
##                                    Access_physicalhealthcareDecreased
## (Intercept)                                                -0.3790685
## Access_physicalhealthcareDecreased                          1.0000000
## Access_physicalhealthcareIncreased                          0.2407239
## f_3                                                         0.1566061
##                                    Access_physicalhealthcareIncreased
## (Intercept)                                               -0.14058753
## Access_physicalhealthcareDecreased                         0.24072387
## Access_physicalhealthcareIncreased                         1.00000000
## f_3                                                       -0.02725982
##                                            f_3
## (Intercept)                        -0.91698224
## Access_physicalhealthcareDecreased  0.15660609
## Access_physicalhealthcareIncreased -0.02725982
## f_3                                 1.00000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.5875 -0.2361 -0.2361  0.4125  0.7639 
## 
## Coefficients:
##                                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                         0.23611    0.03813   6.192 2.41e-09 ***
## Access_physicalhealthcareDecreased  0.35139    0.06381   5.507 9.03e-08 ***
## Access_physicalhealthcareIncreased  0.16389    0.09184   1.785   0.0755 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4576 on 251 degrees of freedom
## Multiple R-squared:  0.1084, Adjusted R-squared:  0.1013 
## F-statistic: 15.26 on 2 and 251 DF,  p-value: 5.589e-07
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.5000 -0.4306  0.5000  0.5694  0.8500 
## 
## Coefficients:
##                                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                         2.43056    0.06674  36.417   <2e-16 ***
## Access_physicalhealthcareDecreased -0.28056    0.11168  -2.512   0.0126 *  
## Access_physicalhealthcareIncreased  0.06944    0.16074   0.432   0.6661    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8009 on 251 degrees of freedom
## Multiple R-squared:  0.029,  Adjusted R-squared:  0.02127 
## F-statistic: 3.749 on 2 and 251 DF,  p-value: 0.02487
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.6781 -0.3488 -0.1912  0.4795  0.8088 
## 
## Coefficients:
##                                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                         0.42766    0.09487   4.508 1.01e-05 ***
## Access_physicalhealthcareDecreased  0.32928    0.06412   5.136 5.66e-07 ***
## Access_physicalhealthcareIncreased  0.16936    0.09118   1.858   0.0644 .  
## f_3                                -0.07881    0.03579  -2.202   0.0286 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4541 on 250 degrees of freedom
## Multiple R-squared:  0.1253, Adjusted R-squared:  0.1149 
## F-statistic: 11.94 on 3 and 250 DF,  p-value: 2.467e-07
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] 0.3513889 0.1638889
## [1] 0.3292782 0.1693618
## [1]  0.022110655 -0.005472934
#Sobel test
saved$z.score; saved$p.value
## [1]  1.5863461 -0.3872429
## [1] 0.1126608 0.6985764
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##         original        bias    std. error
## t1*  0.022110655 -2.931684e-05  0.01438052
## t2* -0.005472934 -2.270169e-05  0.01392926
#bootstrapped CI
saved$boot.ci
## $Access_physicalhealthcareDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0060,  0.0503 )  
## Calculations and Intervals on Original Scale
## 
## $Access_physicalhealthcareIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0328,  0.0219 )  
## Calculations and Intervals on Original Scale
LEEP_covid$Access_physicalhealthcare = as.factor(LEEP_covid$Access_physicalhealthcare)
LEEP_covid$Access_physicalhealthcare<-relevel(LEEP_covid$Access_physicalhealthcare, ref = "No change")

saved = mediation1(y = "health_conditions", #DV
                   x = "Access_physicalhealthcare", #IV
                   m = "f_3",  #Mediator
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                                    (Intercept)
## (Intercept)                          1.0000000
## Access_physicalhealthcareDecreased  -0.3790685
## Access_physicalhealthcareIncreased  -0.1405875
## f_3                                 -0.9169822
##                                    Access_physicalhealthcareDecreased
## (Intercept)                                                -0.3790685
## Access_physicalhealthcareDecreased                          1.0000000
## Access_physicalhealthcareIncreased                          0.2407239
## f_3                                                         0.1566061
##                                    Access_physicalhealthcareIncreased
## (Intercept)                                               -0.14058753
## Access_physicalhealthcareDecreased                         0.24072387
## Access_physicalhealthcareIncreased                         1.00000000
## f_3                                                       -0.02725982
##                                            f_3
## (Intercept)                        -0.91698224
## Access_physicalhealthcareDecreased  0.15660609
## Access_physicalhealthcareIncreased -0.02725982
## f_3                                 1.00000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.5250 -0.1667 -0.1667  0.4750  0.8333 
## 
## Coefficients:
##                                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                         0.16667    0.03618   4.606 6.52e-06 ***
## Access_physicalhealthcareDecreased  0.35833    0.06054   5.919 1.06e-08 ***
## Access_physicalhealthcareIncreased  0.26667    0.08714   3.060  0.00245 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4342 on 251 degrees of freedom
## Multiple R-squared:  0.1307, Adjusted R-squared:  0.1237 
## F-statistic: 18.86 on 2 and 251 DF,  p-value: 2.33e-08
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.5000 -0.4306  0.5000  0.5694  0.8500 
## 
## Coefficients:
##                                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                         2.43056    0.06674  36.417   <2e-16 ***
## Access_physicalhealthcareDecreased -0.28056    0.11168  -2.512   0.0126 *  
## Access_physicalhealthcareIncreased  0.06944    0.16074   0.432   0.6661    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8009 on 251 degrees of freedom
## Multiple R-squared:  0.029,  Adjusted R-squared:  0.02127 
## F-statistic: 3.749 on 2 and 251 DF,  p-value: 0.02487
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.6545 -0.3278 -0.1025  0.3847  0.8975 
## 
## Coefficients:
##                                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                         0.44041    0.08890   4.954 1.34e-06 ***
## Access_physicalhealthcareDecreased  0.32674    0.06008   5.438 1.28e-07 ***
## Access_physicalhealthcareIncreased  0.27449    0.08544   3.213 0.001487 ** 
## f_3                                -0.11263    0.03354  -3.358 0.000907 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4256 on 250 degrees of freedom
## Multiple R-squared:  0.1682, Adjusted R-squared:  0.1582 
## F-statistic: 16.85 on 3 and 250 DF,  p-value: 5.322e-10
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] 0.3583333 0.2666667
## [1] 0.3267356 0.2744879
## [1]  0.031597713 -0.007821216
#Sobel test
saved$z.score; saved$p.value
## [1]  1.9566968 -0.4109563
## [1] 0.05038313 0.68110458
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##         original        bias    std. error
## t1*  0.031597713  6.550328e-04  0.01701040
## t2* -0.007821216 -9.775035e-05  0.02041062
#bootstrapped CI
saved$boot.ci
## $Access_physicalhealthcareDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0024,  0.0643 )  
## Calculations and Intervals on Original Scale
## 
## $Access_physicalhealthcareIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0477,  0.0323 )  
## Calculations and Intervals on Original Scale

Access MCH

LEEP_covid$Access_mentalhealthcare = as.factor(LEEP_covid$Access_mentalhealthcare)
LEEP_covid$Access_mentalhealthcare<-relevel(LEEP_covid$Access_mentalhealthcare, ref = "No change")

saved = mediation1(y = "Fear_seizure", #DV
                   x = "Access_mentalhealthcare", #IV
                   m = "f_3",  #Mediator
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                                  (Intercept) Access_mentalhealthcareDecreased
## (Intercept)                        1.0000000                       -0.3590530
## Access_mentalhealthcareDecreased  -0.3590530                        1.0000000
## Access_mentalhealthcareIncreased  -0.2134940                        0.2614006
## f_3                               -0.9116476                        0.1101616
##                                  Access_mentalhealthcareIncreased         f_3
## (Intercept)                                           -0.21349397 -0.91164757
## Access_mentalhealthcareDecreased                       0.26140061  0.11016156
## Access_mentalhealthcareIncreased                       1.00000000  0.05094917
## f_3                                                    0.05094917  1.00000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.4835 -0.2647 -0.2647  0.5165  0.7353 
## 
## Coefficients:
##                                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                       0.26471    0.04048   6.539 3.44e-10 ***
## Access_mentalhealthcareDecreased  0.21881    0.06393   3.422 0.000725 ***
## Access_mentalhealthcareIncreased  0.21678    0.09946   2.179 0.030225 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4721 on 251 degrees of freedom
## Multiple R-squared:  0.0511, Adjusted R-squared:  0.04354 
## F-statistic: 6.758 on 2 and 251 DF,  p-value: 0.001384
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.4338 -0.4338  0.5662  0.5662  0.7582 
## 
## Coefficients:
##                                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                       2.43382    0.06925  35.144   <2e-16 ***
## Access_mentalhealthcareDecreased -0.19207    0.10938  -1.756   0.0803 .  
## Access_mentalhealthcareIncreased -0.13753    0.17016  -0.808   0.4197    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8076 on 251 degrees of freedom
## Multiple R-squared:  0.01266,    Adjusted R-squared:  0.004795 
## F-statistic: 1.609 on 2 and 251 DF,  p-value: 0.202
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.6011 -0.3970 -0.2125  0.5611  0.7875 
## 
## Coefficients:
##                                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                       0.48929    0.09746   5.021  9.8e-07 ***
## Access_mentalhealthcareDecreased  0.20109    0.06365   3.159  0.00178 ** 
## Access_mentalhealthcareIncreased  0.20409    0.09854   2.071  0.03937 *  
## f_3                              -0.09228    0.03651  -2.528  0.01210 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4671 on 250 degrees of freedom
## Multiple R-squared:  0.07475,    Adjusted R-squared:  0.06364 
## F-statistic: 6.732 on 3 and 250 DF,  p-value: 0.0002196
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] 0.2188106 0.2167756
## [1] 0.2010877 0.2040853
## [1] 0.01772286 0.01269035
#Sobel test
saved$z.score; saved$p.value
## [1] 1.3715653 0.7203926
## [1] 0.1701988 0.4712833
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##       original        bias    std. error
## t1* 0.01772286 -0.0001085637  0.01301741
## t2* 0.01269035 -0.0013473399  0.01907658
#bootstrapped CI
saved$boot.ci
## $Access_mentalhealthcareDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0077,  0.0433 )  
## Calculations and Intervals on Original Scale
## 
## $Access_mentalhealthcareIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0234,  0.0514 )  
## Calculations and Intervals on Original Scale
LEEP_covid$Access_mentalhealthcare = as.factor(LEEP_covid$Access_mentalhealthcare)
LEEP_covid$Access_mentalhealthcare<-relevel(LEEP_covid$Access_mentalhealthcare, ref = "No change")

saved = mediation1(y = "health_conditions", #DV
                   x = "Access_mentalhealthcare", #IV
                   m = "f_3",  #Mediator
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                                  (Intercept) Access_mentalhealthcareDecreased
## (Intercept)                        1.0000000                       -0.3590530
## Access_mentalhealthcareDecreased  -0.3590530                        1.0000000
## Access_mentalhealthcareIncreased  -0.2134940                        0.2614006
## f_3                               -0.9116476                        0.1101616
##                                  Access_mentalhealthcareIncreased         f_3
## (Intercept)                                           -0.21349397 -0.91164757
## Access_mentalhealthcareDecreased                       0.26140061  0.11016156
## Access_mentalhealthcareIncreased                       1.00000000  0.05094917
## f_3                                                    0.05094917  1.00000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.4815 -0.1691 -0.1691  0.5275  0.8309 
## 
## Coefficients:
##                                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                       0.16912    0.03771   4.485 1.11e-05 ***
## Access_mentalhealthcareDecreased  0.30341    0.05955   5.095 6.87e-07 ***
## Access_mentalhealthcareIncreased  0.31236    0.09264   3.372 0.000865 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4397 on 251 degrees of freedom
## Multiple R-squared:  0.1083, Adjusted R-squared:  0.1012 
## F-statistic: 15.25 on 2 and 251 DF,  p-value: 5.625e-07
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.4338 -0.4338  0.5662  0.5662  0.7582 
## 
## Coefficients:
##                                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                       2.43382    0.06925  35.144   <2e-16 ***
## Access_mentalhealthcareDecreased -0.19207    0.10938  -1.756   0.0803 .  
## Access_mentalhealthcareIncreased -0.13753    0.17016  -0.808   0.4197    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8076 on 251 degrees of freedom
## Multiple R-squared:  0.01266,    Adjusted R-squared:  0.004795 
## F-statistic: 1.609 on 2 and 251 DF,  p-value: 0.202
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.6337 -0.3375 -0.1026  0.3816  0.8974 
## 
## Coefficients:
##                                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                       0.45493    0.08977   5.068 7.83e-07 ***
## Access_mentalhealthcareDecreased  0.28086    0.05862   4.791 2.85e-06 ***
## Access_mentalhealthcareIncreased  0.29621    0.09076   3.264 0.001254 ** 
## f_3                              -0.11743    0.03362  -3.492 0.000566 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4302 on 250 degrees of freedom
## Multiple R-squared:  0.1498, Adjusted R-squared:  0.1396 
## F-statistic: 14.68 on 3 and 250 DF,  p-value: 7.735e-09
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] 0.3034098 0.3123638
## [1] 0.2808552 0.2962138
## [1] 0.02255458 0.01615008
#Sobel test
saved$z.score; saved$p.value
## [1] 1.5198901 0.7584666
## [1] 0.1285386 0.4481717
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##       original        bias    std. error
## t1* 0.02255458 -0.0002216568  0.01566331
## t2* 0.01615008 -0.0002443843  0.02310018
#bootstrapped CI
saved$boot.ci
## $Access_mentalhealthcareDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0079,  0.0535 )  
## Calculations and Intervals on Original Scale
## 
## $Access_mentalhealthcareIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0289,  0.0617 )  
## Calculations and Intervals on Original Scale

Cancell MH

LEEP_covid$Q8.4 = as.factor(LEEP_covid$Q8.4)
LEEP_covid$Q8.4<-relevel(LEEP_covid$Q8.4, ref = "No")

saved = mediation1(y = "Fear_seizure", #DV
                   x = "Q8.4", #IV
                   m = "f_3",  #Mediator
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##             (Intercept)     Q8.4Yes         f_3
## (Intercept)   1.0000000 -0.29765406 -0.91985452
## Q8.4Yes      -0.2976541  1.00000000  0.06331635
## f_3          -0.9198545  0.06331635  1.00000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.5158 -0.2767 -0.2767  0.4842  0.7233 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.27673    0.03723   7.432 1.66e-12 ***
## Q8.4Yes      0.23906    0.06088   3.927 0.000111 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4695 on 252 degrees of freedom
## Multiple R-squared:  0.05765,    Adjusted R-squared:  0.05391 
## F-statistic: 15.42 on 1 and 252 DF,  p-value: 0.0001113
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.3899 -0.3899  0.6101  0.6101  0.7158 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   2.3899     0.0642  37.226   <2e-16 ***
## Q8.4Yes      -0.1057     0.1050  -1.007    0.315    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8095 on 252 degrees of freedom
## Multiple R-squared:  0.004009,   Adjusted R-squared:  5.661e-05 
## F-statistic: 1.014 on 1 and 252 DF,  p-value: 0.3148
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.6409 -0.4121 -0.2173  0.5539  0.7827 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.50948    0.09376   5.434  1.3e-07 ***
## Q8.4Yes      0.22876    0.06026   3.796 0.000184 ***
## f_3         -0.09739    0.03609  -2.699 0.007435 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4638 on 251 degrees of freedom
## Multiple R-squared:  0.08422,    Adjusted R-squared:  0.07693 
## F-statistic: 11.54 on 2 and 251 DF,  p-value: 1.601e-05
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] 0.2390599
## [1] 0.2287635
## [1] 0.01029644
#Sobel test
saved$z.score; saved$p.value
## [1] 0.8913799
## [1] 0.3727254
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##       original       bias    std. error
## t1* 0.01029644 0.0005171643  0.01207756
#bootstrapped CI
saved$boot.ci
## $Q8.4Yes
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0139,  0.0335 )  
## Calculations and Intervals on Original Scale
saved = mediation1(y = "health_conditions", #DV
                   x = "Q8.4", #IV
                   m = "f_3",  #Mediator
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##             (Intercept)     Q8.4Yes         f_3
## (Intercept)   1.0000000 -0.29765406 -0.91985452
## Q8.4Yes      -0.2976541  1.00000000  0.06331635
## f_3          -0.9198545  0.06331635  1.00000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.4421 -0.2327 -0.2327  0.5579  0.7673 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.23270    0.03596   6.471 5.05e-10 ***
## Q8.4Yes      0.20940    0.05880   3.561 0.000442 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4535 on 252 degrees of freedom
## Multiple R-squared:  0.04791,    Adjusted R-squared:  0.04413 
## F-statistic: 12.68 on 1 and 252 DF,  p-value: 0.0004416
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.3899 -0.3899  0.6101  0.6101  0.7158 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   2.3899     0.0642  37.226   <2e-16 ***
## Q8.4Yes      -0.1057     0.1050  -1.007    0.315    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8095 on 252 degrees of freedom
## Multiple R-squared:  0.004009,   Adjusted R-squared:  5.661e-05 
## F-statistic: 1.014 on 1 and 252 DF,  p-value: 0.3148
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.6082 -0.3495 -0.1538  0.3918  0.8462 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.54188    0.08938   6.063 4.89e-09 ***
## Q8.4Yes      0.19572    0.05744   3.407 0.000764 ***
## f_3         -0.12936    0.03440  -3.760 0.000211 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4421 on 251 degrees of freedom
## Multiple R-squared:  0.09869,    Adjusted R-squared:  0.0915 
## F-statistic: 13.74 on 2 and 251 DF,  p-value: 2.172e-06
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] 0.2094009
## [1] 0.1957236
## [1] 0.01367723
#Sobel test
saved$z.score; saved$p.value
## [1] 0.9422588
## [1] 0.3460602
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##       original       bias    std. error
## t1* 0.01367723 0.0006369633  0.01527829
#bootstrapped CI
saved$boot.ci
## $Q8.4Yes
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0169,  0.0430 )  
## Calculations and Intervals on Original Scale

Fear Health Care

LEEP_covid$Fear_healthcare = as.factor(LEEP_covid$Fear_healthcare)
LEEP_covid$Fear_healthcare<-relevel(LEEP_covid$Fear_healthcare, ref = "No change")

saved = mediation1(y = "Fear_seizure", #DV
                   x = "Fear_healthcare", #IV
                   m = "f_3",  #Mediator
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                          (Intercept) Fear_healthcareDecreased
## (Intercept)                1.0000000              -0.11972559
## Fear_healthcareDecreased  -0.1197256               1.00000000
## Fear_healthcareIncreased  -0.3662152               0.21699247
## f_3                       -0.9199859              -0.03568507
##                          Fear_healthcareIncreased         f_3
## (Intercept)                            -0.3662152 -0.91998591
## Fear_healthcareDecreased                0.2169925 -0.03568507
## Fear_healthcareIncreased                1.0000000  0.15451053
## f_3                                     0.1545105  1.00000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.6184 -0.2649 -0.2649  0.3816  0.7778 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               0.26490    0.03704   7.151 9.38e-12 ***
## Fear_healthcareDecreased -0.04268    0.09511  -0.449    0.654    
## Fear_healthcareIncreased  0.35352    0.06402   5.522 8.35e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4552 on 251 degrees of freedom
## Multiple R-squared:  0.1178, Adjusted R-squared:  0.1108 
## F-statistic: 16.76 on 2 and 251 DF,  p-value: 1.475e-07
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.5185 -0.4238  0.4815  0.5762  0.8553 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               2.42384    0.06518  37.187   <2e-16 ***
## Fear_healthcareDecreased  0.09468    0.16736   0.566   0.5721    
## Fear_healthcareIncreased -0.27910    0.11265  -2.478   0.0139 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.801 on 251 degrees of freedom
## Multiple R-squared:  0.0289, Adjusted R-squared:  0.02116 
## F-statistic: 3.735 on 2 and 251 DF,  p-value: 0.02521
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.7028 -0.2961 -0.2224  0.4446  0.8133 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               0.44354    0.09390   4.724 3.86e-06 ***
## Fear_healthcareDecreased -0.03570    0.09456  -0.378   0.7061    
## Fear_healthcareIncreased  0.33295    0.06438   5.172 4.75e-07 ***
## f_3                      -0.07370    0.03564  -2.068   0.0397 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4522 on 250 degrees of freedom
## Multiple R-squared:  0.1326, Adjusted R-squared:  0.1222 
## F-statistic: 12.74 on 3 and 250 DF,  p-value: 8.907e-08
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] -0.04267844  0.35352039
## [1] -0.03570071  0.33295040
## [1] -0.006977731  0.020569988
#Sobel test
saved$z.score; saved$p.value
## [1] -0.4945204  1.5164961
## [1] 0.6209387 0.1293940
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##         original        bias    std. error
## t1* -0.006977731  1.405698e-04  0.01342352
## t2*  0.020569988 -2.381353e-05  0.01450935
#bootstrapped CI
saved$boot.ci
## $Fear_healthcareDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0334,  0.0192 )  
## Calculations and Intervals on Original Scale
## 
## $Fear_healthcareIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0078,  0.0490 )  
## Calculations and Intervals on Original Scale
# partial med
saved = mediation1(y = "health_conditions", #DV
                   x = "Fear_healthcare", #IV
                   m = "f_3",  #Mediator
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                          (Intercept) Fear_healthcareDecreased
## (Intercept)                1.0000000              -0.11972559
## Fear_healthcareDecreased  -0.1197256               1.00000000
## Fear_healthcareIncreased  -0.3662152               0.21699247
## f_3                       -0.9199859              -0.03568507
##                          Fear_healthcareIncreased         f_3
## (Intercept)                            -0.3662152 -0.91998591
## Fear_healthcareDecreased                0.2169925 -0.03568507
## Fear_healthcareIncreased                1.0000000  0.15451053
## f_3                                     0.1545105  1.00000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.5395 -0.1920 -0.1920  0.4605  0.8079 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               0.19205    0.03570   5.379 1.71e-07 ***
## Fear_healthcareDecreased  0.14128    0.09167   1.541    0.125    
## Fear_healthcareIncreased  0.34742    0.06170   5.631 4.80e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4387 on 251 degrees of freedom
## Multiple R-squared:  0.1124, Adjusted R-squared:  0.1053 
## F-statistic: 15.89 on 2 and 251 DF,  p-value: 3.178e-07
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.5185 -0.4238  0.4815  0.5762  0.8553 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               2.42384    0.06518  37.187   <2e-16 ***
## Fear_healthcareDecreased  0.09468    0.16736   0.566   0.5721    
## Fear_healthcareIncreased -0.27910    0.11265  -2.478   0.0139 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.801 on 251 degrees of freedom
## Multiple R-squared:  0.0289, Adjusted R-squared:  0.02116 
## F-statistic: 3.735 on 2 and 251 DF,  p-value: 0.02521
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.6667 -0.2798 -0.1280  0.3333  0.8720 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               0.46138    0.08937   5.162 4.98e-07 ***
## Fear_healthcareDecreased  0.15180    0.09000   1.687   0.0929 .  
## Fear_healthcareIncreased  0.31641    0.06128   5.164 4.95e-07 ***
## f_3                      -0.11112    0.03392  -3.276   0.0012 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4305 on 250 degrees of freedom
## Multiple R-squared:  0.1489, Adjusted R-squared:  0.1387 
## F-statistic: 14.58 on 3 and 250 DF,  p-value: 8.809e-09
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] 0.1412804 0.3474207
## [1] 0.1518006 0.3164077
## [1] -0.01052021  0.03101304
#Sobel test
saved$z.score; saved$p.value
## [1] -0.533832  1.919949
## [1] 0.59345778 0.05486434
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##        original        bias    std. error
## t1* -0.01052021 -0.0003103916  0.01701795
## t2*  0.03101304  0.0003561664  0.01708586
#bootstrapped CI
saved$boot.ci
## $Fear_healthcareDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0436,  0.0231 )  
## Calculations and Intervals on Original Scale
## 
## $Fear_healthcareIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0028,  0.0641 )  
## Calculations and Intervals on Original Scale
# partial med

use PHC

LEEP_covid$Use_health_care = as.factor(LEEP_covid$Use_health_care)
LEEP_covid$Use_health_care<-relevel(LEEP_covid$Use_health_care
, ref = "No change")

saved = mediation1(y = "Fear_seizure", #DV
                   x = "Use_health_care", #IV
                   m = "f_3",  #Mediator
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                          (Intercept) Use_health_careDecreased
## (Intercept)                1.0000000               -0.3639382
## Use_health_careDecreased  -0.3639382                1.0000000
## Use_health_careIncreased  -0.2989987                0.2792444
## f_3                       -0.9192819                0.1486415
##                          Use_health_careIncreased        f_3
## (Intercept)                            -0.2989987 -0.9192819
## Use_health_careDecreased                0.2792444  0.1486415
## Use_health_careIncreased                1.0000000  0.1328529
## f_3                                     0.1328529  1.0000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.5135 -0.2587 -0.2587  0.4865  0.7413 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               0.25874    0.03920   6.600 2.42e-10 ***
## Use_health_careDecreased  0.25477    0.06713   3.795 0.000185 ***
## Use_health_careIncreased  0.22775    0.08646   2.634 0.008962 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4688 on 251 degrees of freedom
## Multiple R-squared:  0.06434,    Adjusted R-squared:  0.05688 
## F-statistic: 8.629 on 2 and 251 DF,  p-value: 0.0002374
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.4755 -0.4755  0.5245  0.5245  0.8378 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                2.4755     0.0669  37.002   <2e-16 ***
## Use_health_careDecreased  -0.2728     0.1146  -2.381   0.0180 *  
## Use_health_careIncreased  -0.3134     0.1476  -2.124   0.0347 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8 on 251 degrees of freedom
## Multiple R-squared:  0.03114,    Adjusted R-squared:  0.02342 
## F-statistic: 4.034 on 2 and 251 DF,  p-value: 0.01886
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.6125 -0.3801 -0.2156  0.5002  0.7844 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               0.46239    0.09881   4.680 4.71e-06 ***
## Use_health_careDecreased  0.23233    0.06734   3.450 0.000658 ***
## Use_health_careIncreased  0.20197    0.08654   2.334 0.020406 *  
## f_3                      -0.08227    0.03669  -2.242 0.025832 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4651 on 250 degrees of freedom
## Multiple R-squared:  0.08278,    Adjusted R-squared:  0.07177 
## F-statistic: 7.521 on 3 and 250 DF,  p-value: 7.734e-05
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] 0.2547723 0.2277452
## [1] 0.2323284 0.2019663
## [1] 0.02244383 0.02577892
#Sobel test
saved$z.score; saved$p.value
## [1] 1.56109 1.46682
## [1] 0.1185024 0.1424251
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##       original        bias    std. error
## t1* 0.02244383 -0.0004272486  0.01494527
## t2* 0.02577892 -0.0007923517  0.01796777
#bootstrapped CI
saved$boot.ci
## $Use_health_careDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0064,  0.0522 )  
## Calculations and Intervals on Original Scale
## 
## $Use_health_careIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0086,  0.0618 )  
## Calculations and Intervals on Original Scale
# partial med
saved = mediation1(y = "health_conditions", #DV
                   x = "Use_health_care", #IV
                   m = "f_3",  #Mediator
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                          (Intercept) Use_health_careDecreased
## (Intercept)                1.0000000               -0.3639382
## Use_health_careDecreased  -0.3639382                1.0000000
## Use_health_careIncreased  -0.2989987                0.2792444
## f_3                       -0.9192819                0.1486415
##                          Use_health_careIncreased        f_3
## (Intercept)                            -0.2989987 -0.9192819
## Use_health_careDecreased                0.2792444  0.1486415
## Use_health_careIncreased                1.0000000  0.1328529
## f_3                                     0.1328529  1.0000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.5405 -0.1678 -0.1678  0.4595  0.8322 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               0.16783    0.03642   4.608 6.46e-06 ***
## Use_health_careDecreased  0.30514    0.06237   4.893 1.78e-06 ***
## Use_health_careIncreased  0.37271    0.08033   4.640 5.62e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4355 on 251 degrees of freedom
## Multiple R-squared:  0.1253, Adjusted R-squared:  0.1184 
## F-statistic: 17.98 on 2 and 251 DF,  p-value: 5.024e-08
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.4755 -0.4755  0.5245  0.5245  0.8378 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                2.4755     0.0669  37.002   <2e-16 ***
## Use_health_careDecreased  -0.2728     0.1146  -2.381   0.0180 *  
## Use_health_careIncreased  -0.3134     0.1476  -2.124   0.0347 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8 on 251 degrees of freedom
## Multiple R-squared:  0.03114,    Adjusted R-squared:  0.02342 
## F-statistic: 4.034 on 2 and 251 DF,  p-value: 0.01886
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.6617 -0.3217 -0.1132  0.4016  0.8869 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               0.42595    0.09100   4.681 4.69e-06 ***
## Use_health_careDecreased  0.27669    0.06202   4.461 1.23e-05 ***
## Use_health_careIncreased  0.34004    0.07970   4.266 2.82e-05 ***
## f_3                      -0.10427    0.03379  -3.086  0.00226 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4283 on 250 degrees of freedom
## Multiple R-squared:  0.1574, Adjusted R-squared:  0.1473 
## F-statistic: 15.57 on 3 and 250 DF,  p-value: 2.575e-09
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] 0.3051408 0.3727084
## [1] 0.2766948 0.3400353
## [1] 0.02844605 0.03267305
#Sobel test
saved$z.score; saved$p.value
## [1] 1.826068 1.690143
## [1] 0.06783997 0.09100051
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##       original        bias    std. error
## t1* 0.02844605  0.0009175431  0.01682361
## t2* 0.03267305 -0.0005004971  0.02132520
#bootstrapped CI
saved$boot.ci
## $Use_health_careDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0054,  0.0605 )  
## Calculations and Intervals on Original Scale
## 
## $Use_health_careIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0086,  0.0750 )  
## Calculations and Intervals on Original Scale
# partial med

use MHC

LEEP_covid$Use_mental_health_care = as.factor(LEEP_covid$Use_mental_health_care)
LEEP_covid$Use_mental_health_care<-relevel(LEEP_covid$Use_mental_health_care
, ref = "No change")

saved = mediation1(y = "Fear_seizure", #DV
                   x = "Use_mental_health_care", #IV
                   m = "f_3",  #Mediator
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                                 (Intercept) Use_mental_health_careDecreased
## (Intercept)                       1.0000000                      -0.3225374
## Use_mental_health_careDecreased  -0.3225374                       1.0000000
## Use_mental_health_careIncreased  -0.2353129                       0.2088484
## f_3                              -0.9239681                       0.1196383
##                                 Use_mental_health_careIncreased        f_3
## (Intercept)                                          -0.2353129 -0.9239681
## Use_mental_health_careDecreased                       0.2088484  0.1196383
## Use_mental_health_careIncreased                       1.0000000  0.1083908
## f_3                                                   0.1083908  1.0000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.6087 -0.2830 -0.2830  0.5278  0.7170 
## 
## Coefficients:
##                                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                      0.28302    0.03735   7.577 6.82e-13 ***
## Use_mental_health_careDecreased  0.18920    0.06691   2.828  0.00507 ** 
## Use_mental_health_careIncreased  0.32568    0.10508   3.099  0.00216 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.471 on 251 degrees of freedom
## Multiple R-squared:  0.05534,    Adjusted R-squared:  0.04781 
## F-statistic: 7.351 on 2 and 251 DF,  p-value: 0.0007895
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.4403 -0.4402  0.5597  0.5597  0.8696 
## 
## Coefficients:
##                                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                      2.44025    0.06376  38.273   <2e-16 ***
## Use_mental_health_careDecreased -0.21803    0.11420  -1.909   0.0574 .  
## Use_mental_health_careIncreased -0.30982    0.17935  -1.727   0.0853 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.804 on 251 degrees of freedom
## Multiple R-squared:  0.02159,    Adjusted R-squared:  0.01379 
## F-statistic: 2.769 on 2 and 251 DF,  p-value: 0.06465
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.7076 -0.3215 -0.2341  0.5083  0.7660 
## 
## Coefficients:
##                                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                      0.49650    0.09676   5.131 5.79e-07 ***
## Use_mental_health_careDecreased  0.17013    0.06677   2.548  0.01143 *  
## Use_mental_health_careIncreased  0.29857    0.10472   2.851  0.00472 ** 
## f_3                             -0.08748    0.03664  -2.388  0.01769 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4667 on 250 degrees of freedom
## Multiple R-squared:  0.0764, Adjusted R-squared:  0.06532 
## F-statistic: 6.893 on 3 and 250 DF,  p-value: 0.0001773
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] 0.1892034 0.3256768
## [1] 0.1701293 0.2985729
## [1] 0.01907401 0.02710392
#Sobel test
saved$z.score; saved$p.value
## [1] 1.417221 1.325344
## [1] 0.1564184 0.1850571
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##       original        bias    std. error
## t1* 0.01907401 -0.0001448414  0.01365651
## t2* 0.02710392 -0.0003375116  0.02154129
#bootstrapped CI
saved$boot.ci
## $Use_mental_health_careDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0075,  0.0460 )  
## Calculations and Intervals on Original Scale
## 
## $Use_mental_health_careIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0148,  0.0697 )  
## Calculations and Intervals on Original Scale
# partial med
saved = mediation1(y = "health_conditions", #DV
                   x = "Use_health_care", #IV
                   m = "f_3",  #Mediator
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                          (Intercept) Use_health_careDecreased
## (Intercept)                1.0000000               -0.3639382
## Use_health_careDecreased  -0.3639382                1.0000000
## Use_health_careIncreased  -0.2989987                0.2792444
## f_3                       -0.9192819                0.1486415
##                          Use_health_careIncreased        f_3
## (Intercept)                            -0.2989987 -0.9192819
## Use_health_careDecreased                0.2792444  0.1486415
## Use_health_careIncreased                1.0000000  0.1328529
## f_3                                     0.1328529  1.0000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.5405 -0.1678 -0.1678  0.4595  0.8322 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               0.16783    0.03642   4.608 6.46e-06 ***
## Use_health_careDecreased  0.30514    0.06237   4.893 1.78e-06 ***
## Use_health_careIncreased  0.37271    0.08033   4.640 5.62e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4355 on 251 degrees of freedom
## Multiple R-squared:  0.1253, Adjusted R-squared:  0.1184 
## F-statistic: 17.98 on 2 and 251 DF,  p-value: 5.024e-08
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.4755 -0.4755  0.5245  0.5245  0.8378 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                2.4755     0.0669  37.002   <2e-16 ***
## Use_health_careDecreased  -0.2728     0.1146  -2.381   0.0180 *  
## Use_health_careIncreased  -0.3134     0.1476  -2.124   0.0347 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8 on 251 degrees of freedom
## Multiple R-squared:  0.03114,    Adjusted R-squared:  0.02342 
## F-statistic: 4.034 on 2 and 251 DF,  p-value: 0.01886
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.6617 -0.3217 -0.1132  0.4016  0.8869 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               0.42595    0.09100   4.681 4.69e-06 ***
## Use_health_careDecreased  0.27669    0.06202   4.461 1.23e-05 ***
## Use_health_careIncreased  0.34004    0.07970   4.266 2.82e-05 ***
## f_3                      -0.10427    0.03379  -3.086  0.00226 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4283 on 250 degrees of freedom
## Multiple R-squared:  0.1574, Adjusted R-squared:  0.1473 
## F-statistic: 15.57 on 3 and 250 DF,  p-value: 2.575e-09
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] 0.3051408 0.3727084
## [1] 0.2766948 0.3400353
## [1] 0.02844605 0.03267305
#Sobel test
saved$z.score; saved$p.value
## [1] 1.826068 1.690143
## [1] 0.06783997 0.09100051
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##       original        bias    std. error
## t1* 0.02844605 -0.0004792670  0.01608376
## t2* 0.03267305 -0.0003574007  0.01981415
#bootstrapped CI
saved$boot.ci
## $Use_health_careDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0026,  0.0604 )  
## Calculations and Intervals on Original Scale
## 
## $Use_health_careIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0058,  0.0719 )  
## Calculations and Intervals on Original Scale
# partial med

Social_isolation

LEEP_covid$Social_isolation = as.factor(LEEP_covid$Social_isolation)
LEEP_covid$Social_isolation<-relevel(LEEP_covid$Social_isolation
, ref = "No change")

saved = mediation1(y = "Fear_seizure", #DV
                   x = "Social_isolation", #IV
                   m = "f_3",  #Mediator
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                           (Intercept) Social_isolationDecreased
## (Intercept)                 1.0000000               -0.25911444
## Social_isolationDecreased  -0.2591144                1.00000000
## Social_isolationIncreased  -0.4184725                0.38080791
## f_3                        -0.8789790                0.02045341
##                           Social_isolationIncreased         f_3
## (Intercept)                             -0.41847255 -0.87897897
## Social_isolationDecreased                0.38080791  0.02045341
## Social_isolationIncreased                1.00000000  0.06905238
## f_3                                      0.06905238  1.00000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.4800 -0.4800 -0.2708  0.5200  0.7879 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                0.27083    0.04807   5.634  4.7e-08 ***
## Social_isolationDecreased -0.05871    0.09504  -0.618  0.53728    
## Social_isolationIncreased  0.20917    0.06391   3.273  0.00122 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.471 on 251 degrees of freedom
## Multiple R-squared:  0.05556,    Adjusted R-squared:  0.04804 
## F-statistic: 7.383 on 2 and 251 DF,  p-value: 0.000766
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.4167 -0.4167  0.5833  0.7040  0.7040 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                2.41667    0.08275  29.203   <2e-16 ***
## Social_isolationDecreased -0.05303    0.16362  -0.324    0.746    
## Social_isolationIncreased -0.12067    0.11004  -1.097    0.274    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8108 on 251 degrees of freedom
## Multiple R-squared:  0.004808,   Adjusted R-squared:  -0.003122 
## F-statistic: 0.6063 on 2 and 251 DF,  p-value: 0.5461
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.6068 -0.4112 -0.2138  0.4910  0.8501 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                0.50718    0.09956   5.094  6.9e-07 ***
## Social_isolationDecreased -0.06390    0.09389  -0.681  0.49676    
## Social_isolationIncreased  0.19737    0.06328   3.119  0.00203 ** 
## f_3                       -0.09780    0.03621  -2.701  0.00739 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4652 on 250 degrees of freedom
## Multiple R-squared:  0.08234,    Adjusted R-squared:  0.07133 
## F-statistic: 7.477 on 3 and 250 DF,  p-value: 8.193e-05
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] -0.05871212  0.20916667
## [1] -0.0638985  0.1973654
## [1] 0.005186382 0.011801242
#Sobel test
saved$z.score; saved$p.value
## [1] 0.3020391 0.9610729
## [1] 0.7626223 0.3365155
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##        original       bias    std. error
## t1* 0.005186382 2.140873e-04  0.01678141
## t2* 0.011801242 5.100572e-05  0.01194803
#bootstrapped CI
saved$boot.ci
## $Social_isolationDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0279,  0.0379 )  
## Calculations and Intervals on Original Scale
## 
## $Social_isolationIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0117,  0.0352 )  
## Calculations and Intervals on Original Scale
# partial med
saved = mediation1(y = "health_conditions", #DV
                   x = "Social_isolation", #IV
                   m = "f_3",  #Mediator
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                           (Intercept) Social_isolationDecreased
## (Intercept)                 1.0000000               -0.25911444
## Social_isolationDecreased  -0.2591144                1.00000000
## Social_isolationIncreased  -0.4184725                0.38080791
## f_3                        -0.8789790                0.02045341
##                           Social_isolationIncreased         f_3
## (Intercept)                             -0.41847255 -0.87897897
## Social_isolationDecreased                0.38080791  0.02045341
## Social_isolationIncreased                1.00000000  0.06905238
## f_3                                      0.06905238  1.00000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.4640 -0.4640 -0.1146  0.5360  0.8854 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                0.11458    0.04454   2.573   0.0107 *  
## Social_isolationDecreased  0.18845    0.08806   2.140   0.0333 *  
## Social_isolationIncreased  0.34942    0.05922   5.900 1.17e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4364 on 251 degrees of freedom
## Multiple R-squared:  0.1218, Adjusted R-squared:  0.1148 
## F-statistic: 17.41 on 2 and 251 DF,  p-value: 8.284e-08
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.4167 -0.4167  0.5833  0.7040  0.7040 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                2.41667    0.08275  29.203   <2e-16 ***
## Social_isolationDecreased -0.05303    0.16362  -0.324    0.746    
## Social_isolationIncreased -0.12067    0.11004  -1.097    0.274    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8108 on 251 degrees of freedom
## Multiple R-squared:  0.004808,   Adjusted R-squared:  -0.003122 
## F-statistic: 0.6063 on 2 and 251 DF,  p-value: 0.5461
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.62412 -0.37702 -0.04251  0.37588  0.95749 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                0.41316    0.09109   4.536 8.91e-06 ***
## Social_isolationDecreased  0.18190    0.08590   2.118 0.035193 *  
## Social_isolationIncreased  0.33451    0.05789   5.778 2.24e-08 ***
## f_3                       -0.12355    0.03313  -3.729 0.000238 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4256 on 250 degrees of freedom
## Multiple R-squared:  0.1681, Adjusted R-squared:  0.1581 
## F-statistic: 16.84 on 3 and 250 DF,  p-value: 5.38e-10
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] 0.1884470 0.3494167
## [1] 0.1818952 0.3345085
## [1] 0.006551817 0.014908192
#Sobel test
saved$z.score; saved$p.value
## [1] 0.3119543 1.0188957
## [1] 0.7550753 0.3082525
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##        original       bias    std. error
## t1* 0.006551817 0.0017829679  0.02024823
## t2* 0.014908192 0.0008849292  0.01530608
#bootstrapped CI
saved$boot.ci
## $Social_isolationDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0349,  0.0445 )  
## Calculations and Intervals on Original Scale
## 
## $Social_isolationIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.016,  0.044 )  
## Calculations and Intervals on Original Scale
# partial med

Control_over_life

LEEP_covid$Control_over_life = as.factor(LEEP_covid$Control_over_life)
LEEP_covid$Control_over_life<-relevel(LEEP_covid$Control_over_life
, ref = "No change")

saved = mediation1(y = "Fear_seizure", #DV
                   x = "Control_over_life", #IV
                   m = "f_3",  #Mediator
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                            (Intercept) Control_over_lifeDecreased
## (Intercept)                  1.0000000                 -0.4097094
## Control_over_lifeDecreased  -0.4097094                  1.0000000
## Control_over_lifeIncreased  -0.3226105                  0.3110107
## f_3                         -0.9081582                  0.1400393
##                            Control_over_lifeIncreased        f_3
## (Intercept)                                -0.3226105 -0.9081582
## Control_over_lifeDecreased                  0.3110107  0.1400393
## Control_over_lifeIncreased                  1.0000000  0.1579175
## f_3                                         0.1579175  1.0000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.5000 -0.4762 -0.2397  0.5238  0.7603 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 0.23967    0.04265   5.620 5.07e-08 ***
## Control_over_lifeDecreased  0.23652    0.06257   3.780 0.000196 ***
## Control_over_lifeIncreased  0.26033    0.09838   2.646 0.008656 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4691 on 251 degrees of freedom
## Multiple R-squared:  0.06291,    Adjusted R-squared:  0.05545 
## F-statistic: 8.426 on 2 and 251 DF,  p-value: 0.0002873
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.4959 -0.4959  0.5041  0.5041  0.9286 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 2.49587    0.07262  34.369   <2e-16 ***
## Control_over_lifeDecreased -0.23872    0.10654  -2.241   0.0259 *  
## Control_over_lifeIncreased -0.42444    0.16752  -2.534   0.0119 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.7988 on 251 degrees of freedom
## Multiple R-squared:  0.03409,    Adjusted R-squared:  0.02639 
## F-statistic: 4.429 on 2 and 251 DF,  p-value: 0.01287
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.5886 -0.4148 -0.1980  0.5026  0.8020 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 0.44595    0.10106   4.413 1.52e-05 ***
## Control_over_lifeDecreased  0.21679    0.06269   3.458 0.000639 ***
## Control_over_lifeIncreased  0.22525    0.09884   2.279 0.023509 *  
## f_3                        -0.08265    0.03677  -2.248 0.025478 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4654 on 250 degrees of freedom
## Multiple R-squared:  0.08147,    Adjusted R-squared:  0.07045 
## F-statistic: 7.392 on 3 and 250 DF,  p-value: 9.171e-05
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] 0.2365211 0.2603306
## [1] 0.2167906 0.2252509
## [1] 0.01973047 0.03507964
#Sobel test
saved$z.score; saved$p.value
## [1] 1.513479 1.612531
## [1] 0.1301581 0.1068465
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##       original        bias    std. error
## t1* 0.01973047 -0.0001077263  0.01310425
## t2* 0.03507964 -0.0006944995  0.02141036
#bootstrapped CI
saved$boot.ci
## $Control_over_lifeDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0058,  0.0455 )  
## Calculations and Intervals on Original Scale
## 
## $Control_over_lifeIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0062,  0.0777 )  
## Calculations and Intervals on Original Scale
# partial med
saved = mediation1(y = "health_conditions", #DV
                   x = "Control_over_life", #IV
                   m = "f_3",  #Mediator
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                            (Intercept) Control_over_lifeDecreased
## (Intercept)                  1.0000000                 -0.4097094
## Control_over_lifeDecreased  -0.4097094                  1.0000000
## Control_over_lifeIncreased  -0.3226105                  0.3110107
## f_3                         -0.9081582                  0.1400393
##                            Control_over_lifeIncreased        f_3
## (Intercept)                                -0.3226105 -0.9081582
## Control_over_lifeDecreased                  0.3110107  0.1400393
## Control_over_lifeIncreased                  1.0000000  0.1579175
## f_3                                         0.1579175  1.0000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.5000 -0.4571 -0.1405  0.5429  0.8595 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 0.14050    0.03962   3.546 0.000466 ***
## Control_over_lifeDecreased  0.31665    0.05812   5.448 1.22e-07 ***
## Control_over_lifeIncreased  0.35950    0.09139   3.934 0.000108 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4358 on 251 degrees of freedom
## Multiple R-squared:  0.1242, Adjusted R-squared:  0.1172 
## F-statistic:  17.8 on 2 and 251 DF,  p-value: 5.908e-08
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.4959 -0.4959  0.5041  0.5041  0.9286 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 2.49587    0.07262  34.369   <2e-16 ***
## Control_over_lifeDecreased -0.23872    0.10654  -2.241   0.0259 *  
## Control_over_lifeIncreased -0.42444    0.16752  -2.534   0.0119 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.7988 on 251 degrees of freedom
## Multiple R-squared:  0.03409,    Adjusted R-squared:  0.02639 
## F-statistic: 4.429 on 2 and 251 DF,  p-value: 0.01287
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.6122 -0.3794 -0.0877  0.4112  0.9123 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 0.40187    0.09306   4.318 2.27e-05 ***
## Control_over_lifeDecreased  0.29165    0.05772   5.052 8.43e-07 ***
## Control_over_lifeIncreased  0.31506    0.09101   3.462 0.000631 ***
## f_3                        -0.10472    0.03386  -3.093 0.002209 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4285 on 250 degrees of freedom
## Multiple R-squared:  0.1565, Adjusted R-squared:  0.1464 
## F-statistic: 15.46 on 3 and 250 DF,  p-value: 2.955e-09
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] 0.3166470 0.3595041
## [1] 0.2916471 0.3150557
## [1] 0.02499990 0.04444839
#Sobel test
saved$z.score; saved$p.value
## [1] 1.755331 1.901340
## [1] 0.07920273 0.05725747
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##       original       bias    std. error
## t1* 0.02499990 0.0006859288  0.01517873
## t2* 0.04444839 0.0005592214  0.02510059
#bootstrapped CI
saved$boot.ci
## $Control_over_lifeDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0054,  0.0541 )  
## Calculations and Intervals on Original Scale
## 
## $Control_over_lifeIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0053,  0.0931 )  
## Calculations and Intervals on Original Scale
# partial med

Alcohol_consumption

LEEP_covid$Alcohol_consumption = as.factor(LEEP_covid$Alcohol_consumption)
LEEP_covid$Alcohol_consumption<-relevel(LEEP_covid$Alcohol_consumption
, ref = "No change")

saved = mediation1(y = "Fear_seizure", #DV
                   x = "Control_over_life", #IV
                   m = "f_3",  #Alcohol_consumption
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                            (Intercept) Control_over_lifeDecreased
## (Intercept)                  1.0000000                 -0.4097094
## Control_over_lifeDecreased  -0.4097094                  1.0000000
## Control_over_lifeIncreased  -0.3226105                  0.3110107
## f_3                         -0.9081582                  0.1400393
##                            Control_over_lifeIncreased        f_3
## (Intercept)                                -0.3226105 -0.9081582
## Control_over_lifeDecreased                  0.3110107  0.1400393
## Control_over_lifeIncreased                  1.0000000  0.1579175
## f_3                                         0.1579175  1.0000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.5000 -0.4762 -0.2397  0.5238  0.7603 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 0.23967    0.04265   5.620 5.07e-08 ***
## Control_over_lifeDecreased  0.23652    0.06257   3.780 0.000196 ***
## Control_over_lifeIncreased  0.26033    0.09838   2.646 0.008656 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4691 on 251 degrees of freedom
## Multiple R-squared:  0.06291,    Adjusted R-squared:  0.05545 
## F-statistic: 8.426 on 2 and 251 DF,  p-value: 0.0002873
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.4959 -0.4959  0.5041  0.5041  0.9286 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 2.49587    0.07262  34.369   <2e-16 ***
## Control_over_lifeDecreased -0.23872    0.10654  -2.241   0.0259 *  
## Control_over_lifeIncreased -0.42444    0.16752  -2.534   0.0119 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.7988 on 251 degrees of freedom
## Multiple R-squared:  0.03409,    Adjusted R-squared:  0.02639 
## F-statistic: 4.429 on 2 and 251 DF,  p-value: 0.01287
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.5886 -0.4148 -0.1980  0.5026  0.8020 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 0.44595    0.10106   4.413 1.52e-05 ***
## Control_over_lifeDecreased  0.21679    0.06269   3.458 0.000639 ***
## Control_over_lifeIncreased  0.22525    0.09884   2.279 0.023509 *  
## f_3                        -0.08265    0.03677  -2.248 0.025478 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4654 on 250 degrees of freedom
## Multiple R-squared:  0.08147,    Adjusted R-squared:  0.07045 
## F-statistic: 7.392 on 3 and 250 DF,  p-value: 9.171e-05
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] 0.2365211 0.2603306
## [1] 0.2167906 0.2252509
## [1] 0.01973047 0.03507964
#Sobel test
saved$z.score; saved$p.value
## [1] 1.513479 1.612531
## [1] 0.1301581 0.1068465
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##       original       bias    std. error
## t1* 0.01973047 0.0001760663  0.01289569
## t2* 0.03507964 0.0001375395  0.02185977
#bootstrapped CI
saved$boot.ci
## $Control_over_lifeDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0057,  0.0448 )  
## Calculations and Intervals on Original Scale
## 
## $Control_over_lifeIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0079,  0.0778 )  
## Calculations and Intervals on Original Scale
# partial med
saved = mediation1(y = "health_conditions", #DV
                   x = "Alcohol_consumption", #IV
                   m = "f_3",  #Mediator
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                              (Intercept) Alcohol_consumptionDecreased
## (Intercept)                    1.0000000                  -0.19297893
## Alcohol_consumptionDecreased  -0.1929789                   1.00000000
## Alcohol_consumptionIncreased  -0.3189562                   0.19966599
## f_3                           -0.9269606                   0.05085172
##                              Alcohol_consumptionIncreased         f_3
## (Intercept)                                    -0.3189562 -0.92696060
## Alcohol_consumptionDecreased                    0.1996660  0.05085172
## Alcohol_consumptionIncreased                    1.0000000  0.14383279
## f_3                                             0.1438328  1.00000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.4333 -0.2560 -0.2560  0.5893  0.7440 
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                   0.25595    0.03542   7.225 5.98e-12 ***
## Alcohol_consumptionDecreased  0.17738    0.09101   1.949   0.0524 .  
## Alcohol_consumptionIncreased  0.15476    0.07085   2.184   0.0299 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4591 on 251 degrees of freedom
## Multiple R-squared:  0.02783,    Adjusted R-squared:  0.02009 
## F-statistic: 3.593 on 2 and 251 DF,  p-value: 0.02894
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.4286 -0.4286  0.5714  0.5714  0.8571 
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                   2.42857    0.06204  39.146   <2e-16 ***
## Alcohol_consumptionDecreased -0.12857    0.15938  -0.807   0.4206    
## Alcohol_consumptionIncreased -0.28571    0.12408  -2.303   0.0221 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8041 on 251 degrees of freedom
## Multiple R-squared:  0.0212, Adjusted R-squared:  0.0134 
## F-statistic: 2.718 on 2 and 251 DF,  p-value: 0.06795
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.5985 -0.3104 -0.1834  0.5286  0.8166 
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                   0.56441    0.09224   6.119 3.62e-09 ***
## Alcohol_consumptionDecreased  0.16105    0.08902   1.809 0.071621 .  
## Alcohol_consumptionIncreased  0.11847    0.06994   1.694 0.091517 .  
## f_3                          -0.12701    0.03521  -3.608 0.000373 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4485 on 250 degrees of freedom
## Multiple R-squared:  0.07594,    Adjusted R-squared:  0.06485 
## F-statistic: 6.848 on 3 and 250 DF,  p-value: 0.0001883
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] 0.1773810 0.1547619
## [1] 0.1610506 0.1184723
## [1] 0.01633030 0.03628956
#Sobel test
saved$z.score; saved$p.value
## [1] 0.7599302 1.8900763
## [1] 0.44729632 0.05874776
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##       original      bias    std. error
## t1* 0.01633030 0.001525506  0.02070314
## t2* 0.03628956 0.001046134  0.02036596
#bootstrapped CI
saved$boot.ci
## $Alcohol_consumptionDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0258,  0.0554 )  
## Calculations and Intervals on Original Scale
## 
## $Alcohol_consumptionIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0047,  0.0752 )  
## Calculations and Intervals on Original Scale
# partial med

Anger

LEEP_covid$Anger = as.factor(LEEP_covid$Anger)
LEEP_covid$Anger<-relevel(LEEP_covid$Anger
, ref = "No change")

saved = mediation1(y = "Fear_seizure", #DV
                   x = "Anger", #IV
                   m = "f_3",  #Alcohol_consumption
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                (Intercept) AngerDecreased AngerIncreased        f_3
## (Intercept)      1.0000000     -0.1272399     -0.3789119 -0.9192986
## AngerDecreased  -0.1272399      1.0000000      0.2083025 -0.0124896
## AngerIncreased  -0.3789119      0.2083025      1.0000000  0.1567983
## f_3             -0.9192986     -0.0124896      0.1567983  1.0000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.4706 -0.3108 -0.3108  0.5294  0.6892 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     0.31081    0.03936   7.897 8.93e-14 ***
## AngerDecreased  0.02252    0.11165   0.202   0.8403    
## AngerIncreased  0.15978    0.06516   2.452   0.0149 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4788 on 251 degrees of freedom
## Multiple R-squared:  0.0238, Adjusted R-squared:  0.01602 
## F-statistic:  3.06 on 2 and 251 DF,  p-value: 0.04865
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.4762 -0.4392  0.5608  0.5608  0.8353 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     2.43919    0.06591  37.007   <2e-16 ***
## AngerDecreased  0.03700    0.18698   0.198   0.8433    
## AngerIncreased -0.27448    0.10913  -2.515   0.0125 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8019 on 251 degrees of freedom
## Multiple R-squared:  0.02672,    Adjusted R-squared:  0.01896 
## F-statistic: 3.445 on 2 and 251 DF,  p-value: 0.03342
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.5797 -0.3715 -0.2582  0.5543  0.7418 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     0.53940    0.09896   5.450  1.2e-07 ***
## AngerDecreased  0.02599    0.11050   0.235   0.8142    
## AngerIncreased  0.13405    0.06529   2.053   0.0411 *  
## f_3            -0.09372    0.03730  -2.513   0.0126 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4738 on 250 degrees of freedom
## Multiple R-squared:  0.04784,    Adjusted R-squared:  0.03642 
## F-statistic: 4.187 on 3 and 250 DF,  p-value: 0.00648
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] 0.02252252 0.15977742
## [1] 0.02599012 0.13405408
## [1] -0.003467595  0.025723346
#Sobel test
saved$z.score; saved$p.value
## [1] -0.1833709  1.7112102
## [1] 0.85450704 0.08704232
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##         original        bias    std. error
## t1* -0.003467595  0.0005726274  0.01835025
## t2*  0.025723346 -0.0005162771  0.01518155
#bootstrapped CI
saved$boot.ci
## $AngerDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0400,  0.0319 )  
## Calculations and Intervals on Original Scale
## 
## $AngerIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0035,  0.0560 )  
## Calculations and Intervals on Original Scale
# partial med
saved = mediation1(y = "health_conditions", #DV
                   x = "Anger", #IV
                   m = "f_3",  #Mediator
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                (Intercept) AngerDecreased AngerIncreased        f_3
## (Intercept)      1.0000000     -0.1272399     -0.3789119 -0.9192986
## AngerDecreased  -0.1272399      1.0000000      0.2083025 -0.0124896
## AngerIncreased  -0.3789119      0.2083025      1.0000000  0.1567983
## f_3             -0.9192986     -0.0124896      0.1567983  1.0000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.4941 -0.2297 -0.2297  0.5059  0.8571 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     0.22973    0.03669   6.261 1.64e-09 ***
## AngerDecreased -0.08687    0.10408  -0.835    0.405    
## AngerIncreased  0.26439    0.06075   4.352 1.96e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4464 on 251 degrees of freedom
## Multiple R-squared:  0.08123,    Adjusted R-squared:  0.07391 
## F-statistic:  11.1 on 2 and 251 DF,  p-value: 2.411e-05
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.4762 -0.4392  0.5608  0.5608  0.8353 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     2.43919    0.06591  37.007   <2e-16 ***
## AngerDecreased  0.03700    0.18698   0.198   0.8433    
## AngerIncreased -0.27448    0.10913  -2.515   0.0125 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8019 on 251 degrees of freedom
## Multiple R-squared:  0.02672,    Adjusted R-squared:  0.01896 
## F-statistic: 3.445 on 2 and 251 DF,  p-value: 0.03342
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.6260 -0.2795 -0.1662  0.3740  0.9165 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     0.50600    0.09146   5.533 7.95e-08 ***
## AngerDecreased -0.08268    0.10212  -0.810 0.418902    
## AngerIncreased  0.23330    0.06034   3.866 0.000141 ***
## f_3            -0.11326    0.03447  -3.286 0.001163 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4379 on 250 degrees of freedom
## Multiple R-squared:  0.1193, Adjusted R-squared:  0.1087 
## F-statistic: 11.29 on 3 and 250 DF,  p-value: 5.729e-07
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] -0.08687259  0.26438792
## [1] -0.08268178  0.23329961
## [1] -0.004190811  0.031088312
#Sobel test
saved$z.score; saved$p.value
## [1] -0.1890014  1.9413821
## [1] 0.85009174 0.05221194
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##         original       bias    std. error
## t1* -0.004190811 0.0008750419  0.01974461
## t2*  0.031088312 0.0002494828  0.01678639
#bootstrapped CI
saved$boot.ci
## $AngerDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0438,  0.0336 )  
## Calculations and Intervals on Original Scale
## 
## $AngerIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0021,  0.0637 )  
## Calculations and Intervals on Original Scale
# partial med

Anger

LEEP_covid$Anxiety = as.factor(LEEP_covid$Anxiety)
LEEP_covid$Anxiety<-relevel(LEEP_covid$Anxiety
, ref = "No change")

saved = mediation1(y = "Fear_seizure", #DV
                   x = "Anxiety", #IV
                   m = "f_3",  #Alcohol_consumption
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                  (Intercept) AnxietyDecreased AnxietyIncreased         f_3
## (Intercept)        1.0000000      -0.20786434       -0.4949983 -0.87283021
## AnxietyDecreased  -0.2078643       1.00000000        0.3664018 -0.02413748
## AnxietyIncreased  -0.4949983       0.36640176        1.0000000  0.12675203
## f_3               -0.8728302      -0.02413748        0.1267520  1.00000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.4897 -0.4897 -0.2235  0.5103  0.8750 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       0.22353    0.05013   4.459 1.24e-05 ***
## AnxietyDecreased -0.09853    0.10683  -0.922    0.357    
## AnxietyIncreased  0.26613    0.06313   4.215 3.48e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4622 on 251 degrees of freedom
## Multiple R-squared:  0.09053,    Adjusted R-squared:  0.08328 
## F-statistic: 12.49 on 2 and 251 DF,  p-value: 6.733e-06
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.5417 -0.4706  0.5294  0.7517  0.7517 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       2.47059    0.08719  28.335   <2e-16 ***
## AnxietyDecreased  0.07108    0.18582   0.383    0.702    
## AnxietyIncreased -0.22231    0.10981  -2.024    0.044 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8039 on 251 degrees of freedom
## Multiple R-squared:  0.02182,    Adjusted R-squared:  0.01403 
## F-statistic: 2.799 on 2 and 251 DF,  p-value: 0.06274
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.5912 -0.4285 -0.1805  0.4901  0.9123 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       0.42450    0.10189   4.166 4.27e-05 ***
## AnxietyDecreased -0.09275    0.10600  -0.875  0.38242    
## AnxietyIncreased  0.24804    0.06313   3.929  0.00011 ***
## f_3              -0.08134    0.03600  -2.260  0.02469 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4584 on 250 degrees of freedom
## Multiple R-squared:  0.1087, Adjusted R-squared:  0.09804 
## F-statistic: 10.17 on 3 and 250 DF,  p-value: 2.426e-06
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] -0.09852941  0.26612576
## [1] -0.0927476  0.2480420
## [1] -0.005781813  0.018083805
#Sobel test
saved$z.score; saved$p.value
## [1] -0.3456858  1.4320971
## [1] 0.7295789 0.1521160
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##         original        bias    std. error
## t1* -0.005781813 -0.0002973666  0.01468639
## t2*  0.018083805 -0.0004429578  0.01231334
#bootstrapped CI
saved$boot.ci
## $AnxietyDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0343,  0.0233 )  
## Calculations and Intervals on Original Scale
## 
## $AnxietyIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0056,  0.0427 )  
## Calculations and Intervals on Original Scale
# partial med
saved = mediation1(y = "health_conditions", #DV
                   x = "Anxiety", #IV
                   m = "f_3",  #Mediator
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                  (Intercept) AnxietyDecreased AnxietyIncreased         f_3
## (Intercept)        1.0000000      -0.20786434       -0.4949983 -0.87283021
## AnxietyDecreased  -0.2078643       1.00000000        0.3664018 -0.02413748
## AnxietyIncreased  -0.4949983       0.36640176        1.0000000  0.12675203
## f_3               -0.8728302      -0.02413748        0.1267520  1.00000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.45517 -0.45517 -0.08235  0.54483  0.91765 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       0.08235    0.04688   1.757   0.0802 .  
## AnxietyDecreased  0.16765    0.09990   1.678   0.0946 .  
## AnxietyIncreased  0.37282    0.05904   6.315 1.22e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4322 on 251 degrees of freedom
## Multiple R-squared:  0.1387, Adjusted R-squared:  0.1318 
## F-statistic:  20.2 on 2 and 251 DF,  p-value: 7.322e-09
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.5417 -0.4706  0.5294  0.7517  0.7517 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       2.47059    0.08719  28.335   <2e-16 ***
## AnxietyDecreased  0.07108    0.18582   0.383    0.702    
## AnxietyIncreased -0.22231    0.10981  -2.024    0.044 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8039 on 251 degrees of freedom
## Multiple R-squared:  0.02182,    Adjusted R-squared:  0.01403 
## F-statistic: 2.799 on 2 and 251 DF,  p-value: 0.06274
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.59317 -0.37207 -0.02383  0.40683  0.97617 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       0.35547    0.09419   3.774 0.000201 ***
## AnxietyDecreased  0.17550    0.09799   1.791 0.074493 .  
## AnxietyIncreased  0.34824    0.05836   5.967 8.23e-09 ***
## f_3              -0.11055    0.03328  -3.322 0.001027 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4238 on 250 degrees of freedom
## Multiple R-squared:  0.1751, Adjusted R-squared:  0.1652 
## F-statistic: 17.69 on 3 and 250 DF,  p-value: 1.921e-10
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] 0.1676471 0.3728195
## [1] 0.1755045 0.3482436
## [1] -0.007857484  0.024575893
#Sobel test
saved$z.score; saved$p.value
## [1] -0.364080  1.674327
## [1] 0.71579826 0.09406633
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##         original        bias    std. error
## t1* -0.007857484 -0.0002871044  0.01899441
## t2*  0.024575893  0.0001067671  0.01516643
#bootstrapped CI
saved$boot.ci
## $AnxietyDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0448,  0.0297 )  
## Calculations and Intervals on Original Scale
## 
## $AnxietyIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0053,  0.0542 )  
## Calculations and Intervals on Original Scale
# partial med

Time_spent_outside

LEEP_covid$Time_spent_outside = as.factor(LEEP_covid$Time_spent_outside)
LEEP_covid$Time_spent_outside<-relevel(LEEP_covid$Time_spent_outside
, ref = "No change")

saved = mediation1(y = "Fear_seizure", #DV
                   x = "Time_spent_outside", #IV
                   m = "f_3",  #Alcohol_consumption
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                             (Intercept) Time_spent_outsideDecreased
## (Intercept)                   1.0000000                  -0.4120435
## Time_spent_outsideDecreased  -0.4120435                   1.0000000
## Time_spent_outsideIncreased  -0.2758743                   0.4302437
## f_3                          -0.8821143                   0.1016056
##                             Time_spent_outsideIncreased         f_3
## (Intercept)                                 -0.27587431 -0.88211432
## Time_spent_outsideDecreased                  0.43024368  0.10160563
## Time_spent_outsideIncreased                  1.00000000 -0.02487482
## f_3                                         -0.02487482  1.00000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.5169 -0.3636 -0.2323  0.4832  0.7677 
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                  0.23232    0.04711   4.931 1.49e-06 ***
## Time_spent_outsideDecreased  0.28453    0.06847   4.155 4.46e-05 ***
## Time_spent_outsideIncreased  0.13131    0.07449   1.763   0.0792 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4688 on 251 degrees of freedom
## Multiple R-squared:  0.06437,    Adjusted R-squared:  0.05692 
## F-statistic: 8.635 on 2 and 251 DF,  p-value: 0.0002362
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.4546 -0.4546  0.5454  0.5960  0.7865 
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                  2.40404    0.08103  29.669   <2e-16 ***
## Time_spent_outsideDecreased -0.19056    0.11777  -1.618    0.107    
## Time_spent_outsideIncreased  0.05051    0.12812   0.394    0.694    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8062 on 251 degrees of freedom
## Multiple R-squared:  0.0161, Adjusted R-squared:  0.008257 
## F-statistic: 2.053 on 2 and 251 DF,  p-value: 0.1305
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.6286 -0.3616 -0.1774  0.5024  0.8226 
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                  0.45368    0.09895   4.585 7.19e-06 ***
## Time_spent_outsideDecreased  0.26698    0.06810   3.921 0.000114 ***
## Time_spent_outsideIncreased  0.13596    0.07372   1.844 0.066322 .  
## f_3                         -0.09208    0.03631  -2.536 0.011824 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4638 on 250 degrees of freedom
## Multiple R-squared:  0.08784,    Adjusted R-squared:  0.07689 
## F-statistic: 8.025 on 3 and 250 DF,  p-value: 3.98e-05
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] 0.2845307 0.1313131
## [1] 0.2669844 0.1359636
## [1]  0.017546251 -0.004650436
#Sobel test
saved$z.score; saved$p.value
## [1]  1.2944384 -0.3629553
## [1] 0.1955140 0.7166382
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##         original        bias    std. error
## t1*  0.017546251 -0.0003245128  0.01385420
## t2* -0.004650436 -0.0006542688  0.01271356
#bootstrapped CI
saved$boot.ci
## $Time_spent_outsideDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0093,  0.0450 )  
## Calculations and Intervals on Original Scale
## 
## $Time_spent_outsideIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0289,  0.0209 )  
## Calculations and Intervals on Original Scale
# partial med
saved = mediation1(y = "health_conditions", #DV
                   x = "Time_spent_outside", #IV
                   m = "f_2",  #Mediator
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                             (Intercept) Time_spent_outsideDecreased
## (Intercept)                   1.0000000                 -0.50239125
## Time_spent_outsideDecreased  -0.5023912                  1.00000000
## Time_spent_outsideIncreased  -0.3654503                  0.42921992
## f_2                          -0.7792455                  0.09378542
##                             Time_spent_outsideIncreased         f_2
## (Intercept)                                 -0.36545028 -0.77924551
## Time_spent_outsideDecreased                  0.42921992  0.09378542
## Time_spent_outsideIncreased                  1.00000000 -0.03928856
## f_2                                         -0.03928856  1.00000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.3820 -0.3333 -0.2323  0.6180  0.7677 
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                  0.23232    0.04633   5.015 1.01e-06 ***
## Time_spent_outsideDecreased  0.14970    0.06733   2.223   0.0271 *  
## Time_spent_outsideIncreased  0.10101    0.07325   1.379   0.1691    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.461 on 251 degrees of freedom
## Multiple R-squared:  0.02011,    Adjusted R-squared:  0.0123 
## F-statistic: 2.576 on 2 and 251 DF,  p-value: 0.0781
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.8485  0.1515  0.1919  0.2586  0.2809 
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                  0.80808    0.04102  19.699   <2e-16 ***
## Time_spent_outsideDecreased -0.08898    0.05962  -1.492    0.137    
## Time_spent_outsideIncreased  0.04040    0.06486   0.623    0.534    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4082 on 251 degrees of freedom
## Multiple R-squared:  0.01655,    Adjusted R-squared:  0.008715 
## F-statistic: 2.112 on 2 and 251 DF,  p-value: 0.1231
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.5489 -0.3169 -0.1878  0.4698  0.8122 
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                  0.41981    0.07249   5.791 2.09e-08 ***
## Time_spent_outsideDecreased  0.12905    0.06632   1.946  0.05279 .  
## Time_spent_outsideIncreased  0.11038    0.07189   1.536  0.12593    
## f_2                         -0.23202    0.06990  -3.319  0.00104 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.452 on 250 degrees of freedom
## Multiple R-squared:  0.06147,    Adjusted R-squared:  0.05021 
## F-statistic: 5.458 on 3 and 250 DF,  p-value: 0.001194
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] 0.1496992 0.1010101
## [1] 0.1290545 0.1103845
## [1]  0.020644717 -0.009374387
#Sobel test
saved$z.score; saved$p.value
## [1]  1.3124978 -0.5870426
## [1] 0.1893522 0.5571751
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##         original        bias    std. error
## t1*  0.020644717 -0.0005421994  0.01593103
## t2* -0.009374387  0.0011115771  0.01487974
#bootstrapped CI
saved$boot.ci
## $Time_spent_outsideDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0100,  0.0524 )  
## Calculations and Intervals on Original Scale
## 
## $Time_spent_outsideIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0396,  0.0187 )  
## Calculations and Intervals on Original Scale
# partial med

Smoking

LEEP_covid$Smoking = as.factor(LEEP_covid$Smoking)
LEEP_covid$Smoking<-relevel(LEEP_covid$Smoking
, ref = "No change")

saved = mediation1(y = "Fear_seizure", #DV
                   x = "Smoking", #IV
                   m = "f_2",  #Alcohol_consumption
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                  (Intercept) SmokingDecreased SmokingIncreased         f_2
## (Intercept)        1.0000000       -0.1457478      -0.35039269 -0.84242410
## SmokingDecreased  -0.1457478        1.0000000       0.19446056 -0.06435430
## SmokingIncreased  -0.3503927        0.1944606       1.00000000  0.07272218
## f_2               -0.8424241       -0.0643543       0.07272218  1.00000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.5000 -0.3148 -0.3148  0.5000  0.6852 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       0.31481    0.03755   8.384  3.7e-15 ***
## SmokingDecreased  0.03134    0.10097   0.310  0.75653    
## SmokingIncreased  0.18519    0.06979   2.653  0.00847 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4779 on 251 degrees of freedom
## Multiple R-squared:  0.02748,    Adjusted R-squared:  0.01973 
## F-statistic: 3.546 on 2 and 251 DF,  p-value: 0.0303
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.8846  0.1154  0.2037  0.2037  0.2727 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       0.79630    0.03215  24.770   <2e-16 ***
## SmokingDecreased  0.08832    0.08644   1.022    0.308    
## SmokingIncreased -0.06902    0.05975  -1.155    0.249    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4092 on 251 degrees of freedom
## Multiple R-squared:  0.01169,    Adjusted R-squared:  0.003817 
## F-statistic: 1.485 on 2 and 251 DF,  p-value: 0.2285
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.6138 -0.3281 -0.2829  0.5427  0.7170 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       0.43936    0.06920   6.349 1.01e-09 ***
## SmokingDecreased  0.04515    0.10047   0.449   0.6535    
## SmokingIncreased  0.17439    0.06948   2.510   0.0127 *  
## f_2              -0.15641    0.07321  -2.137   0.0336 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4746 on 250 degrees of freedom
## Multiple R-squared:  0.04492,    Adjusted R-squared:  0.03346 
## F-statistic: 3.919 on 3 and 250 DF,  p-value: 0.009256
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] 0.03133903 0.18518519
## [1] 0.04515282 0.17438936
## [1] -0.01381379  0.01079582
#Sobel test
saved$z.score; saved$p.value
## [1] -0.8491232  0.9396464
## [1] 0.3958127 0.3473990
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##        original        bias    std. error
## t1* -0.01381379 -0.0006443372  0.01463090
## t2*  0.01079582 -0.0004925975  0.01173633
#bootstrapped CI
saved$boot.ci
## $SmokingDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0418,  0.0155 )  
## Calculations and Intervals on Original Scale
## 
## $SmokingIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0117,  0.0343 )  
## Calculations and Intervals on Original Scale
# partial med
saved = mediation1(y = "health_conditions", #DV
                   x = "Smoking", #IV
                   m = "f_3",  #Mediator
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                  (Intercept) SmokingDecreased SmokingIncreased        f_3
## (Intercept)       1.00000000      -0.09718209       -0.3374368 -0.9237714
## SmokingDecreased -0.09718209       1.00000000        0.1906931 -0.0487776
## SmokingIncreased -0.33743681       0.19069307        1.0000000  0.1445891
## f_3              -0.92377141      -0.04877760        0.1445891  1.0000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.4849 -0.2716 -0.2716  0.5151  0.8846 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       0.27160    0.03548   7.655 4.17e-13 ***
## SmokingDecreased -0.15622    0.09541  -1.637  0.10280    
## SmokingIncreased  0.21324    0.06595   3.234  0.00139 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4516 on 251 degrees of freedom
## Multiple R-squared:  0.05955,    Adjusted R-squared:  0.05205 
## F-statistic: 7.946 on 2 and 251 DF,  p-value: 0.0004507
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.5385 -0.4074  0.4615  0.5926  0.8636 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       2.40741    0.06299  38.218   <2e-16 ***
## SmokingDecreased  0.13105    0.16939   0.774   0.4398    
## SmokingIncreased -0.27104    0.11708  -2.315   0.0214 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8018 on 251 degrees of freedom
## Multiple R-squared:  0.02696,    Adjusted R-squared:  0.0192 
## F-statistic: 3.477 on 2 and 251 DF,  p-value: 0.03241
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.6180 -0.3193 -0.2022  0.4992  0.9387 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       0.55368    0.09081   6.097 4.07e-09 ***
## SmokingDecreased -0.14086    0.09362  -1.505 0.133671    
## SmokingIncreased  0.18149    0.06532   2.778 0.005876 ** 
## f_3              -0.11717    0.03484  -3.363 0.000893 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4426 on 250 degrees of freedom
## Multiple R-squared:  0.1002, Adjusted R-squared:  0.08945 
## F-statistic: 9.284 on 3 and 250 DF,  p-value: 7.64e-06
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] -0.1562203  0.2132435
## [1] -0.1408646  0.1814852
## [1] -0.01535570  0.03175838
#Sobel test
saved$z.score; saved$p.value
## [1] -0.7242038  1.8521009
## [1] 0.46894066 0.06401134
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##        original       bias    std. error
## t1* -0.01535570 0.0008544169  0.01931083
## t2*  0.03175838 0.0006172557  0.01762197
#bootstrapped CI
saved$boot.ci
## $SmokingDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0541,  0.0216 )  
## Calculations and Intervals on Original Scale
## 
## $SmokingIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0034,  0.0657 )  
## Calculations and Intervals on Original Scale
# partial med

Hobbies

LEEP_covid$Hobbies = as.factor(LEEP_covid$Hobbies)
LEEP_covid$Hobbies<-relevel(LEEP_covid$Hobbies
, ref = "No change")

saved = mediation1(y = "Fear_seizure", #DV
                   x = "Hobbies", #IV
                   m = "f_2",  #Alcohol_consumption
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                  (Intercept) HobbiesDecreased HobbiesIncreased         f_2
## (Intercept)        1.0000000       -0.3841555      -0.33168047 -0.83017603
## HobbiesDecreased  -0.3841555        1.0000000       0.29394179  0.08710680
## HobbiesIncreased  -0.3316805        0.2939418       1.00000000  0.05207872
## f_2               -0.8301760        0.0871068       0.05207872  1.00000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.4375 -0.3529 -0.3381  0.6471  0.6619 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       0.33813    0.04095   8.257 8.57e-15 ***
## HobbiesDecreased  0.09937    0.07293   1.363    0.174    
## HobbiesIncreased  0.01481    0.07904   0.187    0.852    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4828 on 251 degrees of freedom
## Multiple R-squared:  0.007529,   Adjusted R-squared:  -0.0003788 
## F-statistic: 0.9521 on 2 and 251 DF,  p-value: 0.3873
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.8201  0.1799  0.1799  0.2353  0.2656 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       0.82014    0.03476  23.592   <2e-16 ***
## HobbiesDecreased -0.08577    0.06191  -1.385    0.167    
## HobbiesIncreased -0.05544    0.06710  -0.826    0.409    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4099 on 251 degrees of freedom
## Multiple R-squared:  0.008355,   Adjusted R-squared:  0.0004532 
## F-statistic: 1.057 on 2 and 251 DF,  p-value: 0.3489
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.5572 -0.3146 -0.3088  0.6058  0.6912 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       0.471836   0.072891   6.473 5.04e-10 ***
## HobbiesDecreased  0.085388   0.072649   1.175    0.241    
## HobbiesIncreased  0.005774   0.078542   0.074    0.941    
## f_2              -0.163028   0.073783  -2.210    0.028 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4791 on 250 degrees of freedom
## Multiple R-squared:  0.02654,    Adjusted R-squared:  0.01486 
## F-statistic: 2.272 on 3 and 250 DF,  p-value: 0.08073
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] 0.09937050 0.01481168
## [1] 0.085387807 0.005773755
## [1] 0.013982697 0.009037925
#Sobel test
saved$z.score; saved$p.value
## [1] 1.0958940 0.7124979
## [1] 0.2731252 0.4761565
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##        original        bias    std. error
## t1* 0.013982697 -7.037632e-05  0.01413970
## t2* 0.009037925 -1.143448e-04  0.01308951
#bootstrapped CI
saved$boot.ci
## $HobbiesDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0137,  0.0418 )  
## Calculations and Intervals on Original Scale
## 
## $HobbiesIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0165,  0.0348 )  
## Calculations and Intervals on Original Scale
# partial med
saved = mediation1(y = "health_conditions", #DV
                   x = "Hobbies", #IV
                   m = "f_3",  #Mediator
                   cvs = NULL, #Any covariates
                   df = LEEP_covid
)

####view data screening####
#outlier information is in the DF
#View(saved$datascreening$fulldata)


#additivity
saved$datascreening$correl
##                  (Intercept) HobbiesDecreased HobbiesIncreased         f_3
## (Intercept)        1.0000000       -0.3230484      -0.28966744 -0.91377080
## HobbiesDecreased  -0.3230484        1.0000000       0.29739629  0.10530253
## HobbiesIncreased  -0.2896674        0.2973963       1.00000000  0.08756083
## f_3               -0.9137708        0.1053025       0.08756083  1.00000000
#linearity
saved$datascreening$linearity

#normality
saved$datascreening$normality

#homogs
saved$datascreening$homogen

####view the analysis####
summary(saved$model1) #c path
## 
## Call:
## lm(formula = allformulas$eq1, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.4531 -0.3922 -0.2158  0.5469  0.7842 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       0.21583    0.03844   5.615 5.19e-08 ***
## HobbiesDecreased  0.23730    0.06845   3.467  0.00062 ***
## HobbiesIncreased  0.17633    0.07419   2.377  0.01821 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4531 on 251 degrees of freedom
## Multiple R-squared:  0.05305,    Adjusted R-squared:  0.04551 
## F-statistic: 7.031 on 2 and 251 DF,  p-value: 0.001069
summary(saved$model2) #a path
## 
## Call:
## lm(formula = allformulas$eq2, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.4388 -0.4389  0.5612  0.5612  0.7656 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       2.43885    0.06844  35.637   <2e-16 ***
## HobbiesDecreased -0.20447    0.12188  -1.678   0.0947 .  
## HobbiesIncreased -0.18395    0.13209  -1.393   0.1650    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8068 on 251 degrees of freedom
## Multiple R-squared:  0.01456,    Adjusted R-squared:  0.006707 
## F-statistic: 1.854 on 2 and 251 DF,  p-value: 0.1587
summary(saved$model3) #b and c' path
## 
## Call:
## lm(formula = allformulas$eq3, data = finaldata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.6047 -0.3007 -0.1469  0.4538  0.8531 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       0.51524    0.09251   5.569 6.59e-08 ***
## HobbiesDecreased  0.21219    0.06731   3.153 0.001815 ** 
## HobbiesIncreased  0.15375    0.07282   2.111 0.035729 *  
## f_3              -0.12277    0.03466  -3.542 0.000474 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4431 on 250 degrees of freedom
## Multiple R-squared:  0.0983, Adjusted R-squared:  0.08748 
## F-statistic: 9.085 on 3 and 250 DF,  p-value: 9.912e-06
saved$total.effect; saved$direct.effect; saved$indirect.effect
## [1] 0.2372977 0.1763295
## [1] 0.2121948 0.1537467
## [1] 0.02510283 0.02258278
#Sobel test
saved$z.score; saved$p.value
## [1] 1.469089 1.253453
## [1] 0.1418087 0.2100408
#bootstrapped indirect
saved$boot.results
## 
## ORDINARY NONPARAMETRIC BOOTSTRAP
## 
## 
## Call:
## boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
##     formula3 = allformulas$eq3, x = x, med.var = m)
## 
## 
## Bootstrap Statistics :
##       original       bias    std. error
## t1* 0.02510283 0.0011196984  0.01844536
## t2* 0.02258278 0.0003513311  0.01789637
#bootstrapped CI
saved$boot.ci
## $HobbiesDecreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0122,  0.0601 )  
## Calculations and Intervals on Original Scale
## 
## $HobbiesIncreased
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootresults, conf = conf_level, type = "norm", 
##     index = i)
## 
## Intervals : 
## Level      Normal        
## 95%   (-0.0128,  0.0573 )  
## Calculations and Intervals on Original Scale
# partial med