File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -59,23 +59,34 @@ function SemWLS(;
5959 meanstructure = false ,
6060 kwargs... ,
6161)
62- ind = CartesianIndices ( obs_cov ( observed) )
63- ind = filter (x -> (x[1 ] >= x[2 ]), ind )
64- s = obs_cov (observed)[ind ]
62+ n_obs = n_man ( observed)
63+ tril_ind = filter (x -> (x[1 ] >= x[2 ]), CartesianIndices ( obs_cov (observed)) )
64+ s = obs_cov (observed)[tril_ind ]
6565
6666 # compute V here
6767 if isnothing (wls_weight_matrix)
68- D = duplication_matrix (n_man (observed) )
68+ D = duplication_matrix (n_obs )
6969 S = inv (obs_cov (observed))
7070 S = kron (S, S)
7171 wls_weight_matrix = 0.5 * (D' * S * D)
72+ else
73+ size (wls_weight_matrix) == (length (tril_ind), length (tril_ind)) ||
74+ DimensionMismatch (
75+ " wls_weight_matrix has to be of size $(length (tril_ind)) ×$(length (tril_ind)) " ,
76+ )
7277 end
7378
7479 if meanstructure
7580 if isnothing (wls_weight_matrix_mean)
7681 wls_weight_matrix_mean = inv (obs_cov (observed))
82+ else
83+ size (wls_weight_matrix_mean) == (n_obs, n_obs) || DimensionMismatch (
84+ " wls_weight_matrix_mean has to be of size $(n_obs) ×$(n_obs) " ,
85+ )
7786 end
7887 else
88+ isnothing (wls_weight_matrix_mean) ||
89+ @warn " Ignoring wls_weight_matrix_mean since meanstructure is disabled"
7990 wls_weight_matrix_mean = nothing
8091 end
8192 HE = approximate_hessian ? ApproximateHessian : ExactHessian
You can’t perform that action at this time.
0 commit comments