Skip to content

Commit 3ddc4a5

Browse files
Alexey Stukalovalyst
authored andcommitted
SemImply: vars and params API
1 parent 97673e4 commit 3ddc4a5

File tree

4 files changed

+31
-30
lines changed

4 files changed

+31
-30
lines changed

src/StructuralEquationModels.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ include("observed/missing.jl")
5050
include("frontend/specification/Sem.jl")
5151
include("frontend/specification/documentation.jl")
5252
# imply
53+
include("imply/abstract.jl")
5354
include("imply/RAM/symbolic.jl")
5455
include("imply/RAM/generic.jl")
5556
include("imply/empty.jl")

src/imply/RAM/generic.jl

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -202,37 +202,10 @@ end
202202
### Recommended methods
203203
############################################################################################
204204

205-
params(imply::RAM) = params(imply.ram_matrices)
206-
nparams(imply::RAM) = nparams(imply.ram_matrices)
207-
208205
function update_observed(imply::RAM, observed::SemObserved; kwargs...)
209206
if n_man(observed) == size(imply.Σ, 1)
210207
return imply
211208
else
212209
return RAM(; observed = observed, kwargs...)
213210
end
214211
end
215-
216-
############################################################################################
217-
### additional functions
218-
############################################################################################
219-
220-
function check_acyclic(A::AbstractMatrix)
221-
# check if the model is acyclic
222-
acyclic = isone(det(I - A))
223-
224-
# check if A is lower or upper triangular
225-
if istril(A)
226-
@info "A matrix is lower triangular"
227-
return LowerTriangular(A)
228-
elseif istriu(A)
229-
@info "A matrix is upper triangular"
230-
return UpperTriangular(A)
231-
else
232-
if acyclic
233-
@info "Your model is acyclic, specifying the A Matrix as either Upper or Lower Triangular can have great performance benefits.\n" maxlog =
234-
1
235-
end
236-
return A
237-
end
238-
end

src/imply/RAM/symbolic.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,6 @@ end
220220
### Recommended methods
221221
############################################################################################
222222

223-
params(imply::RAMSymbolic) = params(imply.ram_matrices)
224-
nparams(imply::RAMSymbolic) = nparams(imply.ram_matrices)
225-
226223
function update_observed(imply::RAMSymbolic, observed::SemObserved; kwargs...)
227224
if n_man(observed) == size(imply.Σ, 1)
228225
return imply

src/imply/abstract.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
vars(imply::SemImply) = vars(imply.ram_matrices)
3+
observed_vars(imply::SemImply) = observed_vars(imply.ram_matrices)
4+
latent_vars(imply::SemImply) = latent_vars(imply.ram_matrices)
5+
6+
nvars(imply::SemImply) = nvars(imply.ram_matrices)
7+
nobserved_vars(imply::SemImply) = nobserved_vars(imply.ram_matrices)
8+
nlatent_vars(imply::SemImply) = nlatent_vars(imply.ram_matrices)
9+
10+
params(imply::SemImply) = params(imply.ram_matrices)
11+
nparams(imply::SemImply) = nparams(imply.ram_matrices)
12+
13+
function check_acyclic(A::AbstractMatrix)
14+
# check if the model is acyclic
15+
acyclic = isone(det(I-A))
16+
17+
# check if A is lower or upper triangular
18+
if istril(A)
19+
@info "A matrix is lower triangular"
20+
return LowerTriangular(A)
21+
elseif istriu(A)
22+
@info "A matrix is upper triangular"
23+
return UpperTriangular(A)
24+
else
25+
if acyclic
26+
@info "Your model is acyclic, specifying the A Matrix as either Upper or Lower Triangular can have great performance benefits.\n" maxlog=1
27+
end
28+
return A
29+
end
30+
end

0 commit comments

Comments
 (0)