Skip to content

Commit b6ba99d

Browse files
committed
rename parameter_type to relation
for clarity
1 parent b0d88ee commit b6ba99d

4 files changed

Lines changed: 31 additions & 42 deletions

File tree

src/frontend/fit/summary.jl

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,13 @@ function sem_summary(
9393
sorted_columns = [:to, :estimate, :param, :value_fixed, :start]
9494
loading_columns = sort_partially(sorted_columns, columns)
9595
header_cols = copy(loading_columns)
96-
replace!(header_cols, :parameter_type => :type)
9796

9897
for var in partable.latent_vars
9998
indicator_indices = findall(
10099
(partable.columns[:from] .== var) .&
101-
(partable.columns[:parameter_type] .== :) .&
100+
(partable.columns[:relation] .== :) .&
102101
(partable.columns[:to] .∈ [partable.observed_vars]),
103102
)
104-
loading_array = reduce(
105-
hcat,
106-
check_round(partable.columns[c][indicator_indices]; digits = digits) for
107-
c in loading_columns
108-
)
109103

110104
printstyled(var; color = secondary_color)
111105
print("\n")
@@ -122,7 +116,7 @@ function sem_summary(
122116
printstyled("Directed Effects: \n"; color = color)
123117

124118
regression_indices = findall(
125-
(partable.columns[:parameter_type] .== :) .& (
119+
(partable.columns[:relation] .== :) .& (
126120
(
127121
(partable.columns[:to] .∈ [partable.observed_vars]) .&
128122
(partable.columns[:from] .∈ [partable.observed_vars])
@@ -138,7 +132,7 @@ function sem_summary(
138132
),
139133
)
140134

141-
sorted_columns = [:from, :parameter_type, :to, :estimate, :param, :value_fixed, :start]
135+
sorted_columns = [:from, :relation, :to, :estimate, :param, :value_fixed, :start]
142136
regression_columns = sort_partially(sorted_columns, columns)
143137

144138
regression_array = reduce(
@@ -147,7 +141,6 @@ function sem_summary(
147141
c in regression_columns
148142
)
149143
regression_columns[2] = Symbol("")
150-
replace!(regression_columns, :parameter_type => :type)
151144

152145
print("\n")
153146
pretty_table(
@@ -161,11 +154,11 @@ function sem_summary(
161154
printstyled("Variances: \n"; color = color)
162155

163156
variance_indices = findall(
164-
(partable.columns[:parameter_type] .== :) .&
157+
(partable.columns[:relation] .== :) .&
165158
(partable.columns[:to] .== partable.columns[:from]),
166159
)
167160

168-
sorted_columns = [:from, :parameter_type, :to, :estimate, :param, :value_fixed, :start]
161+
sorted_columns = [:from, :relation, :to, :estimate, :param, :value_fixed, :start]
169162
variance_columns = sort_partially(sorted_columns, columns)
170163

171164
variance_array = reduce(
@@ -174,7 +167,6 @@ function sem_summary(
174167
c in variance_columns
175168
)
176169
variance_columns[2] = Symbol("")
177-
replace!(variance_columns, :parameter_type => :type)
178170

179171
print("\n")
180172
pretty_table(
@@ -188,11 +180,11 @@ function sem_summary(
188180
printstyled("Covariances: \n"; color = color)
189181

190182
variance_indices = findall(
191-
(partable.columns[:parameter_type] .== :) .&
183+
(partable.columns[:relation] .== :) .&
192184
(partable.columns[:to] .!= partable.columns[:from]),
193185
)
194186

195-
sorted_columns = [:from, :parameter_type, :to, :estimate, :param, :value_fixed, :start]
187+
sorted_columns = [:from, :relation, :to, :estimate, :param, :value_fixed, :start]
196188
variance_columns = sort_partially(sorted_columns, columns)
197189

198190
variance_array = reduce(
@@ -201,7 +193,6 @@ function sem_summary(
201193
c in variance_columns
202194
)
203195
variance_columns[2] = Symbol("")
204-
replace!(variance_columns, :parameter_type => :type)
205196

206197
print("\n")
207198
pretty_table(
@@ -213,15 +204,13 @@ function sem_summary(
213204
print("\n")
214205

215206
mean_indices = findall(
216-
(partable.columns[:parameter_type] .== :) .&
217-
(partable.columns[:from] .== Symbol("1")),
207+
(partable.columns[:relation] .== :) .& (partable.columns[:from] .== Symbol("1")),
218208
)
219209

220210
if length(mean_indices) > 0
221211
printstyled("Means: \n"; color = color)
222212

223-
sorted_columns =
224-
[:from, :parameter_type, :to, :estimate, :param, :value_fixed, :start]
213+
sorted_columns = [:from, :relation, :to, :estimate, :param, :value_fixed, :start]
225214
variance_columns = sort_partially(sorted_columns, columns)
226215

227216
variance_array = reduce(
@@ -230,7 +219,6 @@ function sem_summary(
230219
c in variance_columns
231220
)
232221
variance_columns[2] = Symbol("")
233-
replace!(variance_columns, :parameter_type => :type)
234222

235223
print("\n")
236224
pretty_table(

src/frontend/specification/ParameterTable.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ end
1818
# optionally pre-allocate data for nrows
1919
empty_partable_columns(nrows::Integer = 0) = Dict{Symbol, Vector}(
2020
:from => fill(Symbol(), nrows),
21-
:parameter_type => fill(Symbol(), nrows),
21+
:relation => fill(Symbol(), nrows),
2222
:to => fill(Symbol(), nrows),
2323
:free => fill(true, nrows),
2424
:value_fixed => fill(NaN, nrows),
@@ -93,7 +93,7 @@ end
9393

9494
function Base.show(io::IO, partable::ParameterTable)
9595
relevant_columns =
96-
[:from, :parameter_type, :to, :free, :value_fixed, :start, :estimate, :se, :param]
96+
[:from, :relation, :to, :free, :value_fixed, :start, :estimate, :se, :param]
9797
shown_columns = filter!(
9898
col -> haskey(partable.columns, col) && length(partable.columns[col]) > 0,
9999
relevant_columns,
@@ -118,7 +118,7 @@ end
118118
# Iteration --------------------------------------------------------------------------------
119119
ParameterTableRow = @NamedTuple begin
120120
from::Symbol
121-
parameter_type::Symbol
121+
relation::Symbol
122122
to::Symbol
123123
free::Bool
124124
value_fixed::Any
@@ -127,7 +127,7 @@ end
127127

128128
Base.getindex(partable::ParameterTable, i::Integer) = (
129129
from = partable.columns[:from][i],
130-
parameter_type = partable.columns[:parameter_type][i],
130+
relation = partable.columns[:relation][i],
131131
to = partable.columns[:to][i],
132132
free = partable.columns[:free][i],
133133
value_fixed = partable.columns[:value_fixed][i],
@@ -171,8 +171,8 @@ function sort_vars!(partable::ParameterTable)
171171
]
172172

173173
is_regression = [
174-
(partype == :) && (from != Symbol("1")) for (partype, from) in
175-
zip(partable.columns[:parameter_type], partable.columns[:from])
174+
(rel == :) && (from != Symbol("1")) for
175+
(rel, from) in zip(partable.columns[:relation], partable.columns[:from])
176176
]
177177

178178
to = partable.columns[:to][is_regression]
@@ -454,7 +454,7 @@ function lavaan_param_values!(
454454
for (from, to, type, id) in zip(
455455
[
456456
view(partable.columns[k], partable_mask) for
457-
k in [:from, :to, :parameter_type, :param]
457+
k in [:from, :to, :relation, :param]
458458
]...,
459459
)
460460
lav_ind = nothing

src/frontend/specification/RAMMatrices.jl

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,34 +176,34 @@ function RAMMatrices(
176176
col_ind = r.from != Symbol("1") ? positions[r.from] : nothing
177177

178178
if !r.free
179-
if (r.parameter_type == :) && (r.from == Symbol("1"))
179+
if (r.relation == :) && (r.from == Symbol("1"))
180180
push!(constants, RAMConstant(:M, row_ind, r.value_fixed))
181-
elseif r.parameter_type == :
181+
elseif r.relation == :
182182
push!(
183183
constants,
184184
RAMConstant(:A, CartesianIndex(row_ind, col_ind), r.value_fixed),
185185
)
186-
elseif r.parameter_type == :
186+
elseif r.relation == :
187187
push!(
188188
constants,
189189
RAMConstant(:S, CartesianIndex(row_ind, col_ind), r.value_fixed),
190190
)
191191
else
192-
error("Unsupported parameter type: $(r.parameter_type)")
192+
error("Unsupported parameter type: $(r.relation)")
193193
end
194194
else
195195
par_ind = params_index[r.param]
196-
if (r.parameter_type == :) && (r.from == Symbol("1"))
196+
if (r.relation == :) && (r.from == Symbol("1"))
197197
push!(M_ind[par_ind], row_ind)
198-
elseif r.parameter_type == :
198+
elseif r.relation == :
199199
push!(A_ind[par_ind], row_ind + (col_ind - 1) * n_node)
200-
elseif r.parameter_type == :
200+
elseif r.relation == :
201201
push!(S_ind[par_ind], row_ind + (col_ind - 1) * n_node)
202202
if row_ind != col_ind
203203
push!(S_ind[par_ind], col_ind + (row_ind - 1) * n_node)
204204
end
205205
else
206-
error("Unsupported parameter type: $(r.parameter_type)")
206+
error("Unsupported parameter type: $(r.relation)")
207207
end
208208
end
209209
end
@@ -300,7 +300,8 @@ end
300300
### Additional Functions
301301
############################################################################################
302302

303-
function matrix_to_parameter_type(matrix::Symbol)
303+
# return the `from □ to` variables relation symbol (□) given the name of the source RAM matrix
304+
function matrix_to_relation(matrix::Symbol)
304305
if matrix == :A
305306
return :
306307
elseif matrix == :S
@@ -318,7 +319,7 @@ end
318319

319320
partable_row(c::RAMConstant, position_names::AbstractDict) = (
320321
from = position_names[c.index[2]],
321-
parameter_type = matrix_to_parameter_type(c.matrix),
322+
relation = matrix_to_relation(c.matrix),
322323
to = position_names[c.index[1]],
323324
free = false,
324325
value_fixed = c.value,
@@ -348,7 +349,7 @@ function partable_row(
348349

349350
return (
350351
from = from,
351-
parameter_type = matrix_to_parameter_type(matrix),
352+
relation = matrix_to_relation(matrix),
352353
to = to,
353354
free = true,
354355
value_fixed = 0.0,

src/frontend/specification/StenoGraphs.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function ParameterTable(
4343

4444
columns = empty_partable_columns(n)
4545
from = columns[:from]
46-
parameter_type = columns[:parameter_type]
46+
relation = columns[:relation]
4747
to = columns[:to]
4848
free = columns[:free]
4949
value_fixed = columns[:value_fixed]
@@ -56,9 +56,9 @@ function ParameterTable(
5656
from[i] = edge.src.node
5757
to[i] = edge.dst.node
5858
if edge isa DirectedEdge
59-
parameter_type[i] = :
59+
relation[i] = :
6060
elseif edge isa UndirectedEdge
61-
parameter_type[i] = :
61+
relation[i] = :
6262
else
6363
throw(
6464
ArgumentError(

0 commit comments

Comments
 (0)