-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdemo_bain.Rmd
81 lines (59 loc) · 3.46 KB
/
demo_bain.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Evaluating informative hypotheses using `bain`
The YouTube video below demonstrates how to evaluate informative hypotheses using `bain`. If you want to follow along, please execute the code below in your own RStudio session.
If you need to install R before completing this tutorial,
I recommend following [this tutorial](https://cjvanlissa.github.io/worcs/articles/setup.html).
## Background
A popular theory in psychology to explain social behavior is the Theory of Reasoned Action (TORA) of Ajzen and Fishbein (1980). TORA states that behavior is predicted by behavioral intention, which is in turn predicted by the attitude toward the behavior and the subjective norm about the behavior.
## Data
We examine a synthetic data set based on results found by Reinecke (1998). The behavior under investigation is condom use by 16-24 year adolescents. The dependent variable ‘condom use’ is measured on a 5-point Likert-type scale (How often do you...), and the behavioral intention on a similar 5-point scale (In general do you intend to...). There are three attitude items about condom use (e.g., using a condom is awkward), three normative items (e.g., I think most of my friends would use...), all measured on a 5-point Likert-type scale.
```{r, message = FALSE, eval = FALSE}
library(foreign)
df <- read.spss("toradata.sav", to.data.frame = TRUE, use.value.labels = FALSE)
```
```{r, echo = FALSE}
library(foreign)
df <- read.spss("TCSM_student/toradata.sav", to.data.frame = TRUE, use.value.labels = FALSE)
```
## Specifying the model
We have 3 indicators for attitude and norm, and observed variables for intention and behavior. We construct a measurement model for the latent variables attitude and norm.
Then, we specify a model based on TORA, with attitude and norms both predicting behavorial intention and behavior.
```{r}
library(lavaan)
# Model syntax
model <- 'attit =~ attit1 + attit2 + attit3
norm =~ norm1 + norm2 + norm3
intent ~ attit + norm
behavior ~ intent + attit + norm'
# Estimate the model
fit <- sem(model, data = df)
# Examine model fit
fitmeasures(fit, fit.measures = c("npar", "chisq", "df", "rmsea", "cfi", "tli", "srmr"))
```
## Examine model results
Let's plot the model results, so we get an idea of the parameter values.
```{r}
library(tidySEM)
lo <- get_layout("", "", "", "behavior", "", "", "",
"", "", "", "intent", "", "", "",
"", "attit", "", "", "", "norm", "",
"attit1", "attit2", "attit3", "", "norm1", "norm2", "norm3",
rows = 4)
graph_sem(fit, layout = lo, angle = 179)
```
Furthermore, let's see which parameters are available for `bain` to specify hypotheses about:
```{r}
get_estimates(fit, standardize = TRUE)
```
## Specifying informative hypotheses
The TORA model precludes direct paths between attitude and norm and actual
behavior; the effect should be mediated totally by the behavioral intention.
Let's specify two competing hypotheses: One representing the "strict" version
of TORA, and one that also includes direct effects from attitudes and norms
on behavior. We can refer to the `get_estimates()` parameters by name.
```{r}
library(bain)
bain(fit, "(behavior~intent, intent~attit, intent~norm) > 0 &
(behavior~attit, behavior~norm) = 0;
(behavior~intent, intent~attit, intent~norm) > 0 &
(behavior~attit, behavior~norm) > 0")
```