@@ -89,3 +89,37 @@ function nonunique(values::AbstractVector)
8989 end
9090 return res
9191end
92+
93+ # check that a model only has a single lossfun
94+ function check_single_lossfun (model:: AbstractSemSingle ; throw_error)
95+ if (length (model. loss. functions) > 1 ) & throw_error
96+ @error " The model has $(length (sem. loss. functions)) loss functions.
97+ Only a single loss function is supported."
98+ end
99+ return isone (length (model. loss. functions))
100+ end
101+
102+ # check that all models use the same single loss function
103+ function check_single_lossfun (models:: AbstractSemSingle... ; throw_error)
104+ uniform = true
105+ lossfun = models[1 ]. loss. functions[1 ]
106+ L = typeof (lossfun)
107+ for (i, model) in enumerate (models)
108+ uniform &= check_single_lossfun (model; throw_error = throw_error)
109+ cur_lossfun = model. loss. functions[1 ]
110+ if ! isa (cur_lossfun, L) & throw_error
111+ @error " Loss function for group #$i model is $(typeof (cur_lossfun)) , expected $L .
112+ Heterogeneous loss functions are not supported."
113+ end
114+ uniform &= isa (cur_lossfun, L)
115+ end
116+ return uniform
117+ end
118+
119+ check_single_lossfun (model:: SemEnsemble ; throw_error) =
120+ check_single_lossfun (model. sems... ; throw_error)
121+
122+ # sclaing corrections for fit measures and multigroup models
123+ dof_correction (:: SemFIML ) = 0
124+ dof_correction (:: SemML ) = - 1
125+ dof_correction (:: SemWLS ) = - 1
0 commit comments