Skip to content

Commit 26eea6a

Browse files
committed
rename parameter_type to relation
for clarity
1 parent 4a96244 commit 26eea6a

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],
@@ -168,8 +168,8 @@ function sort_vars!(partable::ParameterTable)
168168
]
169169

170170
is_regression = [
171-
(partype == :) && (from != Symbol("1")) for (partype, from) in
172-
zip(partable.columns[:parameter_type], partable.columns[:from])
171+
(rel == :) && (from != Symbol("1")) for
172+
(rel, from) in zip(partable.columns[:relation], partable.columns[:from])
173173
]
174174

175175
to = partable.columns[:to][is_regression]
@@ -451,7 +451,7 @@ function lavaan_param_values!(
451451
for (from, to, type, id) in zip(
452452
[
453453
view(partable.columns[k], partable_mask) for
454-
k in [:from, :to, :parameter_type, :param]
454+
k in [:from, :to, :relation, :param]
455455
]...,
456456
)
457457
lav_ind = nothing

src/frontend/specification/RAMMatrices.jl

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

179179
if !r.free
180-
if (r.parameter_type == :) && (r.from == Symbol("1"))
180+
if (r.relation == :) && (r.from == Symbol("1"))
181181
push!(constants, RAMConstant(:M, row_ind, r.value_fixed))
182-
elseif r.parameter_type == :
182+
elseif r.relation == :
183183
push!(
184184
constants,
185185
RAMConstant(:A, CartesianIndex(row_ind, col_ind), r.value_fixed),
186186
)
187-
elseif r.parameter_type == :
187+
elseif r.relation == :
188188
push!(
189189
constants,
190190
RAMConstant(:S, CartesianIndex(row_ind, col_ind), r.value_fixed),
191191
)
192192
else
193-
error("Unsupported parameter type: $(r.parameter_type)")
193+
error("Unsupported parameter type: $(r.relation)")
194194
end
195195
else
196196
par_ind = params_index[r.param]
197-
if (r.parameter_type == :) && (r.from == Symbol("1"))
197+
if (r.relation == :) && (r.from == Symbol("1"))
198198
push!(M_ind[par_ind], row_ind)
199-
elseif r.parameter_type == :
199+
elseif r.relation == :
200200
push!(A_ind[par_ind], row_ind + (col_ind - 1) * n_node)
201-
elseif r.parameter_type == :
201+
elseif r.relation == :
202202
push!(S_ind[par_ind], row_ind + (col_ind - 1) * n_node)
203203
if row_ind != col_ind
204204
push!(S_ind[par_ind], col_ind + (row_ind - 1) * n_node)
205205
end
206206
else
207-
error("Unsupported parameter type: $(r.parameter_type)")
207+
error("Unsupported parameter type: $(r.relation)")
208208
end
209209
end
210210
end
@@ -301,7 +301,8 @@ end
301301
### Additional Functions
302302
############################################################################################
303303

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

320321
partable_row(c::RAMConstant, position_names::AbstractDict) = (
321322
from = position_names[c.index[2]],
322-
parameter_type = matrix_to_parameter_type(c.matrix),
323+
relation = matrix_to_relation(c.matrix),
323324
to = position_names[c.index[1]],
324325
free = false,
325326
value_fixed = c.value,
@@ -349,7 +350,7 @@ function partable_row(
349350

350351
return (
351352
from = from,
352-
parameter_type = matrix_to_parameter_type(matrix),
353+
relation = matrix_to_relation(matrix),
353354
to = to,
354355
free = true,
355356
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)