mediation.analysis.fnc

Target

Performs analysis of "causal" mediation mediation library, following the procedure defined by Baron RM, Kenny DA (1986). "The Moderator-Mediator Variable Distinction in Social Psychological Research: Conceptual, Strategic, and Statistical Considerations." Journal ofPersonality and Social Psychology, 51 (6), 1173-1182. 1

mediation.analysis.fnc

Starting from mediation package jobs database (Job Search Intervention Study).

We want to test a model of mediation to demonstrate that the effect of the independent variable (attending or not subject to a program for the unemployed) on the values ​​of the dependent depress2 (depression values ​​unemployed) treat is mediated by the Variable mediator job_seek (perceived self-efficacy in the search for employment).

The user must create a list (in this example (mediation) with at least 3 elements: dv (the dependent variable on which you want to evaluate the effect), iv (independent variable on which the direct and indirect effect will be evaluated through the mediating variable) and m (mediator variable).

If you want the model also contains other variables these should be included in item 4 of the list with the name of covariate.

If a test of interaction of the independent variable and the mediator is desired it can be included in the function call with vi.m.interaction = T argument.

If a covariate mediation modulated is desired include mod.med argument, which should be a list with the name of the moderator variable ant two values ​​on which you want to test modulation. If no one is included, the user must include NA as unique value. In this case the function will do it on the first and third quartiles of the moderator variable (Q1 vs Q3).

BASIC MEDIATION

mediation=list(dv='depress2',iv='treat',m='job_seek')

mediation.analysis.fnc(jobs,mediation)

Two figures are created automatically. The left presents the estimated two regression models values and estimates for mediation parameters: ACME (Average Mediation Causal Effects), ADE (Average Direct Effect) and the total effect. The figure on the right, offers bootstrap confidence intervals calculated for the three effects. As we can see, all intervals contain the value 0 thus conclude that none of the estimated effects are given.

res_mediacion

MEDIATION WITH TREATMENT MEDIATIOR INTERACTION

mediation=list(dv='depress2',iv='treat',m='job_seek')

mediation.analysis.fnc(jobs,mediation, vi.m.interaction=T)

MEDIATION WITH COVARIATES

mediation=list(dv='depress2',iv='treat',m='job_seek',

covariate=c('age','econ_hard'))

mediation.analysis.fnc(jobs,mediation)

MODULATED MEDIATION WITH AND WITHOUD CUT POINTS

When the investigator suspects the effect of mediation can be modulated by a covariate variable measured before treatment may carry out an analysis of moderate mediation by that variable.

Next we assume that the age variable can lead to different parameter values estimated mediation as the subject is 20 or 60 years. To this list we must include the mod.med argument with the name of the variable and the two values that you want to test modulation. If you do not specify any value (then including the NA value) function will do it on the first and third quartile of the variable (if this is numeric) or on the first two levels if the variable is a factor.

mediation=list(dv='depress2',iv='treat',m='job_seek')

mediation.analysis.fnc(jobs,mediation,

mod.med= list(age=c(20,60)))

mediation.analysis.fnc(jobs,mediation,

mod.med=list(age=NA))

mediation.analysis.fnc(jobs,mediation,

mod.med=list(sex=NA))

MODULATED MEDIATION WITH COVARIATES

mediation=list(dv='depress2',iv='treat',m='job_seek',

covariate=c('age','econ_hard'))

mediation.analysis.fnc(jobs,mediation,

mod.med=list(age=NA))

mediation.analysis.fnc(jobs,mediation,

mod.med=list(age=c(20,60)))

MIXED MODEL MEDIATION ANALYSIS

If you want to make an mixed model mediation analysis, you must include the random argument with the name of the variable that controls the higher hierarchical level.

We will use the example of the hierarchical model we used in the section of hierarchical models where researching the mathematics achievement of a certain number of students (first hierarchical level) attending different schools (second-tier) from certain variables of first and second level.

We load the databases needed to estimate the model of mediation again. It is highly advisable that you go to the section of hierarchical models to not only understand the process of reading and processing of data. It is also mandatory to understand the concept of hierarchical regression as explained in this section.

schools= read.file.fnc('jerarquico.colegios.Rdata')

students= read.file.fnc('jerarquico.alumnos.Rdata')

students=merge.data.fnc(students,schools, add.var=T,

pairing.var='School')

students= centering.variable.fnc(students, variable='SES')

We propose a mediation model where the dependent variable math achievement is affected by the type of to school (Sector public or Catholic) as a direct effect and a mediation effect through the child-centered (c.SES) socioeconomic status.

mediation=list(dv='MathAch', iv='Sector', m='c.SES')

mediation.analysis.fnc(students, mediation=mediation,

random='School')

#------------------------------------------------------------------

# ANALISIS DE MEDIACIÓN

#------------------------------------------------------------------

$vd

[1] "MathAch"

$vi

[1] "Sector"

$m

[1] "c.SES"

$estimacion.mediadora.dependiente

[1] "Lineal jerarquico"

$estimacion.vd.dependiente

[1] "Lineal jerarquico"

$Mediacion.Average.Causal.Mediation.Effects

Causal Mediation Analysis

Quasi-Bayesian Confidence Intervals

Mediator Groups: School

Outcome Groups: School

Output Based on Overall Averages Across Groups

Estimate 95% CI Lower 95% CI Upper p-value

ACME 0.707 0.415 1.023 0

ADE 2.065 1.425 2.744 0

Total Effect 2.772 2.071 3.493 0

Prop. Mediated 0.253 0.157 0.367 0

Sample Size Used: 7185

Simulations: 1000

We see that there is an indirect effect of Sector variable (variable second-level) on student performance in mathematics through the variable socioeconomic level of the student. Also there is a direct effect of the Sector variable.

MEDIATION WITH FACTORS WITH J LEVELS

If independent variable has more than two levels by default the fuction compare first vs second levels. If other comparison is needed the user must include compare argument with the names or numbers of levels to compare.

mediation=list(dv='cong_mesg', m='emo', iv='cond')

mediation.analysis.fnc(framing, mediation, compare=3:4)