File: plotProbe.Rd

package info (click to toggle)
r-cran-semtools 0.5.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,204 kB
  • sloc: makefile: 2
file content (153 lines) | stat: -rw-r--r-- 4,790 bytes parent folder | download
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/probeInteraction.R
\name{plotProbe}
\alias{plotProbe}
\title{Plot a latent interaction}
\usage{
plotProbe(object, xlim, xlab = "Indepedent Variable",
  ylab = "Dependent Variable", legend = TRUE, legendArgs = list(), ...)
}
\arguments{
\item{object}{A \code{list}, typically the result of probing a latent 2-way
or 3-way interaction obtained from the \code{\link[=probe2WayMC]{probe2WayMC()}},
\code{\link[=probe2WayRC]{probe2WayRC()}}, \code{\link[=probe3WayMC]{probe3WayMC()}}, or
\code{\link[=probe3WayRC]{probe3WayRC()}} functions.}

\item{xlim}{The vector of two numbers: the minimum and maximum values of the
independent variable}

\item{xlab}{The label of the x-axis}

\item{ylab}{The label of the y-axis}

\item{legend}{\code{logical}. If \code{TRUE} (default), a legend is printed.}

\item{legendArgs}{\code{list} of arguments passed to \code{\link[=legend]{legend()}}
function if \code{legend=TRUE}.}

\item{\dots}{Any additional argument for the \code{\link[=plot]{plot()}} function}
}
\value{
None. This function will plot the simple main effect only.
}
\description{
This function will plot the line graphs representing the simple effect of
the independent variable given the values of the moderator. For multigroup
models, it will only generate a plot for 1 group, as specified in the
function used to obtain the first argument.
}
\note{
If the \code{object} does not contain simple intercepts (i.e., if the
\code{object$SimpleIntcept} element is \code{NULL}), then all simple
intercepts are arbitrarily set to zero in order to plot the simple slopes.
This may not be consistent with the fitted model, but was (up until version
0.5-7) the default behavior when the y-intercept was fixed to 0. In this case,
although the relative steepness of simple slopes can still meaningfully be
compared, the relative vertical positions of lines at any point along the
\emph{x}-axis should not be interpreted.
}
\examples{

library(lavaan)

dat2wayMC <- indProd(dat2way, 1:3, 4:6)

model1 <- "
f1 =~ x1 + x2 + x3
f2 =~ x4 + x5 + x6
f12 =~ x1.x4 + x2.x5 + x3.x6
f3 =~ x7 + x8 + x9
f3 ~ f1 + f2 + f12
f12 ~~ 0*f1
f12 ~~ 0*f2
x1 ~ 0*1
x4 ~ 0*1
x1.x4 ~ 0*1
x7 ~ 0*1
f1 ~ NA*1
f2 ~ NA*1
f12 ~ NA*1
f3 ~ NA*1
"

fitMC2way <- sem(model1, data = dat2wayMC, meanstructure = TRUE)
result2wayMC <- probe2WayMC(fitMC2way, nameX = c("f1", "f2", "f12"),
                            nameY = "f3", modVar = "f2", valProbe = c(-1, 0, 1))
plotProbe(result2wayMC, xlim = c(-2, 2))


dat3wayMC <- indProd(dat3way, 1:3, 4:6, 7:9)

model3 <- "
f1 =~ x1 + x2 + x3
f2 =~ x4 + x5 + x6
f3 =~ x7 + x8 + x9
f12 =~ x1.x4 + x2.x5 + x3.x6
f13 =~ x1.x7 + x2.x8 + x3.x9
f23 =~ x4.x7 + x5.x8 + x6.x9
f123 =~ x1.x4.x7 + x2.x5.x8 + x3.x6.x9
f4 =~ x10 + x11 + x12
f4 ~ f1 + f2 + f3 + f12 + f13 + f23 + f123
f1 ~~ 0*f12
f1 ~~ 0*f13
f1 ~~ 0*f123
f2 ~~ 0*f12
f2 ~~ 0*f23
f2 ~~ 0*f123
f3 ~~ 0*f13
f3 ~~ 0*f23
f3 ~~ 0*f123
f12 ~~ 0*f123
f13 ~~ 0*f123
f23 ~~ 0*f123
x1 ~ 0*1
x4 ~ 0*1
x7 ~ 0*1
x10 ~ 0*1
x1.x4 ~ 0*1
x1.x7 ~ 0*1
x4.x7 ~ 0*1
x1.x4.x7 ~ 0*1
f1 ~ NA*1
f2 ~ NA*1
f3 ~ NA*1
f12 ~ NA*1
f13 ~ NA*1
f23 ~ NA*1
f123 ~ NA*1
f4 ~ NA*1
"

fitMC3way <- sem(model3, data = dat3wayMC, std.lv = FALSE,
                 meanstructure = TRUE)
result3wayMC <- probe3WayMC(fitMC3way, nameX = c("f1", "f2", "f3", "f12",
                                                 "f13", "f23", "f123"),
                            nameY = "f4", modVar = c("f1", "f2"),
                            valProbe1 = c(-1, 0, 1), valProbe2 = c(-1, 0, 1))
plotProbe(result3wayMC, xlim = c(-2, 2))

}
\references{
Schoemann, A. M., & Jorgensen, T. D. (2021). Testing and interpreting
latent variable interactions using the \code{semTools} package.
\emph{Psych, 3}(3), 322--335. \doi{10.3390/psych3030024}
}
\seealso{
\itemize{
\item \code{\link[=indProd]{indProd()}} For creating the indicator products with no
centering, mean centering, double-mean centering, or residual centering.
\item \code{\link[=probe2WayMC]{probe2WayMC()}} For probing the two-way latent interaction
when the results are obtained from mean-centering, or double-mean centering
\item \code{\link[=probe3WayMC]{probe3WayMC()}} For probing the three-way latent interaction
when the results are obtained from mean-centering, or double-mean centering
\item \code{\link[=probe2WayRC]{probe2WayRC()}} For probing the two-way latent interaction
when the results are obtained from residual-centering approach.
\item \code{\link[=probe3WayRC]{probe3WayRC()}} For probing the two-way latent interaction
when the results are obtained from residual-centering approach.
}
}
\author{
Sunthud Pornprasertmanit (\email{psunthud@gmail.com})

Terrence D. Jorgensen (University of Amsterdam; \email{TJorgensen314@gmail.com})
}