To create a piecewise SEM model in R, you will need to install the piecewiseSEM
package.
Here is an example code to build a piecewise SEM model:
main.r1041 chars32 lines
In this example, y
is the response variable and x1
, x2
, x3
, x4
, and x5
are the predictor variables. We also have three thresholds (10 and 20) applied to x3
. The path_matrix
describes the hypothesized relationships between the variables, and the method
argument specifies whether to use the bootstrap method for standard errors.
The piecewise_model
function will estimate the model coefficients and generate a summary.
gistlibby LogSnag