data<- read.csv('C:/Users/ILAN/Downloads/disaster (1).csv')
View(data)
\[ #(path A) justify = i + a*frame \]```
\[ #(Direct effect) donate = i + c' * frame + b * justify \] ’’’
\[ #(Total effect) donate = i + c*frame \]’’’
\[ # (Mediation) c = c' + a*b \]’’’
source(‘C:/Users/ILAN/OneDrive - ort braude college of engineering/Desktop/Technion/שנה א/סמסטר ב/יישום רב משתני/HW/HW 1/process (1).R’) process(data=data, y=“donate”, x=“frame”, m=“justify”, model=4,total=1, seed= 31216)
\[ justify = 2.8 + 0.134 * frame \]
\[ donate = 7.235 + 0.212 * frame -0.9533 * justify \] \[ indirect = (a*b) = -0.128 \]
\[ (c = c' + a*b) ... 0.0839 = 0.212 + (-0.128) \] #b \[ direct effect = 0.212 # the direct effect is non- significant as p value higher than 0.05. \]
\[ indirect effect = -0.128 # the indirect effect is non - significant as the confidence interval include the value zero. \]
\[ the total effect = 0.0839 # the direct effect is non- significant as p value higher than 0.05. \]
$$ The mediation analysis revealed that the experimental framing
(frame) did not have a statistically significant total
effect (c = 0.0839, p = .645) or direct effect (c’ = 0.2120, p = .119)
on donation behavior (donate). Furthermore, the indirect
effect of framing on donations through justifications
(justify) was not statistically significant. Consequently,
the hypothesized mediation model was not supported.
However, a highly significant component of the model emerged: regardless of experimental framing, individuals’ justifications exerted a powerful and statistically significant negative direct effect on their willingness to donate (b = -0.9533, p < .001). This indicates that while the framing manipulation failed to systematically alter justification mechanisms (a = 0.1344, p = .295\(), the cognitive process of generating justifications remains a critical, independent barrier to charitable giving.\)$
#c install.packages(“lavaan”) library(lavaan) model = ’
justify ~ a * frame donate ~ c_tag * frame + b*justify
#indirect effect indirect := a*b
#total effect total := c_tag + (a*b)
’ fit = sem(model, data = data, se = “bootstrap”, bootstrap = 5000)
summary(fit) parameterestimates(fit)
fit = sem(Model, data, se = “bootstrap”, bootstrap = 1000) summary(fit, std=T, rsquare=T) parameterestimates(fit)
reg1=lm(donate~frame,data=data) summary(reg1)
reg2=lm(justify~frame,data=data) summary(reg2)
reg3=lm(donate~justify+frame,data=data) summary(reg3)
’’’ \[ direct effect = 0.212 # the direct effect is non- significant as p value higher than 0.05 (p = 0.114) . \]
\[ indirect effect = -0.128 the indirect effect is non- significant as p value higher than 0.05 (p = 0.298). \]
\[ total effect = 0.084 the total effect is non- significant as p value higher than 0.05 (0.642). \]
#d $$
There are minor differences between the outputs generated by the
lavaan library and the standard ordinary least squares
(OLS) regression models (lm).
While the unstandardized regression coefficients (Estimates) remain
identical across both methods, differences emerge within the Standard
Errors (SE), corresponding z/t-values, and p-values. For instance, the
standard error for Path b is 0.073 in the OLS regression but drops to
0.067 in lavaan.
These differences stem from two methodological factors:
lm) relies on parametric
assumptions, assuming a perfectly normal distribution in the population
to calculate standard errors mathematically. Conversely, the
lavaan model explicitly utilized the non-parametric
se = "bootstrap" argument. It empirically simulated the
standard errors by resampling the dataset 5,000 times (resulting in
4,962 successful draws), leading to more robust and accurate standard
errors that do not assume normality.lavaan utilize the standard normal z-distribution for
significance testing, leading to slight variations in the resulting
\(p\)-values.Conclusion: Using the lavaan library is
highly preferable for mediation analysis. Standard regression calculates
individual paths independently and lacks a built-in mechanism to compute
or test the significance of the integrated indirect effect (\(a \times b\)). lavaan
estimates the entire system of equations simultaneously and provides a
bootstrapping procedure, which is the scientific standard for testing
mediation because product terms (\(a \times
b\)) are inherently non-normal. $$