@@ -144,16 +144,6 @@ lav_partable_flat <- function(FLAT = NULL, # nolint
144
144
categorical <- TRUE
145
145
}
146
146
147
- # std.lv = TRUE, group.equal includes "loadings"
148
- # if(ngroups > 1L && std.lv && "loadings" %in% group.equal) {
149
- # suggested by Michael Hallquist
150
- # in 0.6.3, we gave a warning,
151
- # warning("lavaan WARNING: std.lv = TRUE forces all variances to be unity",
152
- # " in all groups, despite group.equal = \"loadings\"")
153
- # in >0.6.4, we free the lv variances in all but the first group,
154
- # }
155
-
156
-
157
147
# do we have any EFA lv's? they need special treatment if auto.efa = TRUE
158
148
if (! is.null(FLAT $ efa ) && auto.efa ) {
159
149
lv.names.efa <- unique(FLAT $ lhs [FLAT $ op == " =~" &
@@ -783,24 +773,33 @@ lav_partable_flat <- function(FLAT = NULL, # nolint
783
773
784
774
# specific changes per group
785
775
for (g in 2 : ngroups ) {
786
- # label
787
- # label[group == g] <- paste(label[group == 1], ".g", g, sep="")
788
-
789
- # free/fix intercepts
776
+ # free/fix intercepts latent variables
790
777
if (meanstructure ) {
791
778
int.idx <- which(op == " ~1" &
792
779
lhs %in% lv.names.noc &
793
780
user == 0L &
794
781
group == g )
795
782
if (int.lv.free == FALSE && g > 1 &&
796
- (" intercepts" %in% group.equal ||
797
- " thresholds" %in% group.equal ) &&
783
+ (" intercepts" %in% group.equal ) &&
798
784
! (" means" %in% group.equal )) {
799
785
free [int.idx ] <- 1L
800
786
ustart [int.idx ] <- as.numeric(NA )
801
787
}
802
788
}
803
789
790
+ # free intercept indicators if equal thresholds (new in 0.6-20)
791
+ if (meanstructure && length(ov.names.ord ) > 0L ) {
792
+ ord.idx <- which(op == " ~1" &
793
+ lhs %in% ov.names.ord &
794
+ user == 0L &
795
+ group == g )
796
+ if (int.lv.free == FALSE && g > 1 &&
797
+ " thresholds" %in% group.equal ) {
798
+ free [ord.idx ] <- 1L
799
+ ustart [ord.idx ] <- as.numeric(NA )
800
+ }
801
+ }
802
+
804
803
# latent variances if std.lv = TRUE (new in 0.6-4)
805
804
if (std.lv && " loadings" %in% group.equal &&
806
805
! " lv.variances" %in% group.equal ) {
@@ -842,21 +841,29 @@ lav_partable_flat <- function(FLAT = NULL, # nolint
842
841
}
843
842
}
844
843
845
- # latent response scaling
846
- if (auto.delta && parameterization == " delta" ) {
847
- if (any(op == " ~*~" & group == g ) &&
848
- (" thresholds" %in% group.equal )) {
849
- delta.idx <- which(op == " ~*~" & group == g )
850
- free [delta.idx ] <- 1L
851
- ustart [delta.idx ] <- as.numeric(NA )
852
- }
853
- } else if (parameterization == " theta" ) {
854
- if (any(op == " ~*~" & group == g ) &&
855
- (" thresholds" %in% group.equal )) {
856
- var.ord.idx <- which(op == " ~~" & group == g &
857
- lhs %in% ov.names.ord & lhs == rhs )
858
- free [var.ord.idx ] <- 1L
859
- ustart [var.ord.idx ] <- as.numeric(NA )
844
+ # latent response scaling -- categorical only
845
+ # - if thresholds are equal -> free scalings/residual variances
846
+ # - but not for binary indicators!
847
+ if (length(ov.names.ord ) > 0L ) {
848
+ nth <- sapply(ov.names.ord ,
849
+ function (x ) sum(lhs == x & op == " |" & group == 1L ))
850
+ ov.names.ord.notbinary <- ov.names.ord [nth > 1L ]
851
+ if (auto.delta && parameterization == " delta" ) {
852
+ if (any(op == " ~*~" & group == g ) &&
853
+ (" thresholds" %in% group.equal )) {
854
+ delta.idx <- which(op == " ~*~" & group == g &
855
+ lhs %in% ov.names.ord.notbinary )
856
+ free [delta.idx ] <- 1L
857
+ ustart [delta.idx ] <- as.numeric(NA )
858
+ }
859
+ } else if (parameterization == " theta" ) {
860
+ if (any(op == " ~*~" & group == g ) &&
861
+ (" thresholds" %in% group.equal )) {
862
+ var.ord.idx <- which(op == " ~~" & group == g &
863
+ lhs %in% ov.names.ord.notbinary & lhs == rhs )
864
+ free [var.ord.idx ] <- 1L
865
+ ustart [var.ord.idx ] <- as.numeric(NA )
866
+ }
860
867
}
861
868
}
862
869
0 commit comments