I would like to do structural equation modeling (SEM) with a latent variable (denoted "UNKOWNlatent" in the example below) in Python using the semopy package. All parameters should be constraint be greater than zero.
Two questions:
Below is an example script to reproduce the error(s). [It is using the univariate_regression_many data from semopy for the sake of a simple example with readily available data even though I don't want to do conduct univariate regression.]
from semopy import Model
from semopy.examples import univariate_regression_many
desc ="""
UNKOWNlatent =~ a + b * x1 + c * x2 + d * x3
DEFINE(param) a
DEFINE(param) b
DEFINE(param) c
DEFINE(param) d
CONSTRAINT(a > 0)
CONSTRAINT(b > 0)
CONSTRAINT(c > 0)
CONSTRAINT(d > 0)
"""
data = univariate_regression_many.get_data()
print(desc)
mod = Model(desc)
res_opt = mod.fit(data)
estimates = mod.inspect()
print(estimates)
To 1. After adding start values (using, e.g., START(1.0) a b c ) for each parameter the algorithm converges.
To 2. Parameters for constants (i.e., intercepts) seem to be only allowed when using the class "ModelMeans".