Latent spline/piecewise regression model on cross sectional data
Attachment | Size |
---|---|
Spline regression model | 11.65 KB |
For my research, I would like to estimate the association between two latent variables using a spline/piecewise regression model with a single knot. The model should estimate two separate linear regression lines and the knot location (see attached image).
The two latent variables are anxiety and negative affectivity and both are measured with 7 indicators on a 1-5 Likert Scale.
On this forum, I read some topics about spline models in a growth model context, but I do not know whether such models can easily be transformed to spline models suitable for estimating associations between two latent variables using cross-sectional data.
I found an article by Jeffrey Harring (https://journals.sagepub.com/doi/pdf/10.1177/0013164413504295) that explains the mathematics of estimating such a model.
Is it possible to program this model in OpenMx?
Best wishes,
Paul
Yes I think so
Cheers
Mike
Log in or register to post comments
In reply to Yes I think so by AdminNeale
Thanks!
I have no experience in specifying my own fit functions. Does this mean that I have to write an R function to compute the likelihood according to equations 16 and 17 in the paper?
I am also unsure how to add the non-linear regression parameters (e.g. knot location, two separate regression coefficients for the association between the two latent variables; see equation 4) to my model using either the mxMatrix or mxPath notation.
I greatly appreciate any help with these issues.
Best wishes,
Paul
Log in or register to post comments
In reply to Thanks! by PaulTwin
MxFitFunctionR or MxFitFunctionAlgebra
You could write an arbitrary R function to evaluate the likelihood, and put an MxFitFunctionR into your MxModel. Alternately, if it's possible to express that function as an MxAlgebra, then you could do that, and use an MxFitFunctionAlgebra. The latter will be faster, but MxAlgebras aren't as general as R.
Log in or register to post comments
In reply to Thanks! by PaulTwin
suggestion
Log in or register to post comments
In reply to suggestion by AdminRobK
Please ignore my previous comment
Log in or register to post comments
In reply to Please ignore my previous comment by PaulTwin
Glad to hear. Sorry for the
Log in or register to post comments
In reply to Glad to hear. Sorry for the by AdminRobK
A quick question
My code cannot work on his project directly. But I think it is possible to address the linear-linear piecewise relationship between latent variables in OpenMx. Suppose he wants to estimate the knot of one latent variable "depression" and the relationship between two latent variables "depression" and "negative". We then need to use mxMatrix() to create an extra parameter for it. Then we need two mxAlgebra()'s to express "depression - knot" and "abs(depression - knot)" as the attached formula; then mxPath() to specify the path from "first" and "second" to "depression". I am not sure about the lines starting with "?". Do you have any advice on them? Thanks in advance.
bilinearSER <- mxModel("Linear linear Piecewise SER", type = "RAM",
manifestVars = manifests,
latentVars = c("negative", "depression"),
## Latent and residual variances
mxPath(from = "negative", arrows = 2, free = T, values = 1, labels = "varNegative"),
mxPath(from = "depression", arrows = 2, free = T, values = 1, labels = "varDepression"),
mxPath(from = manifests[1:7], arrows = 2, free = T, values = 1,
labels = paste0("negative error", 1:7)),
mxPath(from = manifests[8:16], arrows = 2, free = T, values = 1,
labels = paste0("depression error", 1:9)),
mxPath(from = "negative", to = manifests[1:7], arrows = 1, free = c(F, rep(T, 6)),
values = 1, labels = c("labelNegative", 1:7)),
mxPath(from = "depression", to = manifests[8:16], arrows = 1, free = c(F, rep(T, 8)),
values = 1, labels = c("labelDepression", 1:9)),
mxMatrix("Full", 1, 1, free = T, values = 10,
labels = "knot", name = "knot"),
?mxAlgebra(depression - knot, name = "first"),
?mxAlgebra(abs(depression - knot), name = "second"),
?mxPath(from = "negative", to = , free = T, labels = "first[1,1]"),
?mxPath(from = "negative", to = , free = T, labels = "second[1,1]"),
mxData(dat, type = "raw")
)
Log in or register to post comments
Great!
Log in or register to post comments