Skip to content

Commit

Permalink
Remove box-constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
Kss2k committed Nov 20, 2024
1 parent fc316a5 commit 141d45a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 44 deletions.
36 changes: 1 addition & 35 deletions R/model_parameters_da.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,9 @@ createTheta <- function(model, start = NULL) {
lavLabelsCov = lavLabelsCov,
currentLabels = allLabels)

isDiagThetaDelta <- as.vector(isDiag(M$thetaDelta))
isDiagThetaEpsilon <- as.vector(isDiag(M$thetaEpsilon))
isDiagPhi <- as.vector(isDiag(M$phi))
isDiagA <- as.vector(isDiag(M$A))
isDiagPsi <- as.vector(isDiag(M$psi))

isDiagMatrices <- c("thetaDelta" = isDiagThetaDelta,
"thetaEpsilon" = isDiagThetaEpsilon,
"phi" = isDiagPhi,
"A" = isDiagA,
"psi" = isDiagPsi)
diagMatrices <- c("thetaDelta" = thetaDelta,
"thetaEpsilon" = thetaEpsilon,
"phi" = phi, "A" = A, "psi" = psi)
diagParams <- names(diagMatrices)
diagFreeParams <- c(diagParams[is.na(diagMatrices) & isDiagMatrices],
listThetaCov$diagFreeParams)

list(theta = theta, lenThetaMain = length(thetaMain),
lenThetaLabel = length(thetaLabel),
totalLenThetaLabel = length(totalThetaLabel),
diagFreeParams = diagFreeParams,
lenThetaCov = length(thetaCov), lavLabels = lavLabels)
}

Expand All @@ -106,18 +87,8 @@ createThetaCovModel <- function(covModel, start = NULL) {
lavLabelsCov <- createLavLabelsCov(M, subset = is.na(thetaCov))
thetaCov <- thetaCov[is.na(thetaCov)]
thetaCov <- fillThetaIfStartNULL(start = start, theta = thetaCov)

isDiagPhi <- as.vector(isDiag(M$phi))
isDiagA <- as.vector(isDiag(M$A))
isDiagPsi <- as.vector(isDiag(M$psi))

isDiagMatrices <- c("phi" = isDiagPhi, "A" = isDiagA, "psi" = isDiagPsi)
diagMatrices <- c("phi" = phi, "A" = A, "psi" = psi)
diagParams <- names(diagMatrices)
diagFreeParams <- diagParams[is.na(diagMatrices) & isDiagMatrices]

list(theta = thetaCov, lavLabels = lavLabelsCov,
diagFreeParams=diagFreeParams)
list(theta = thetaCov, lavLabels = lavLabelsCov)
}


Expand Down Expand Up @@ -238,14 +209,9 @@ fillSymmetric <- function(mat, values) {

# Set bounds for parameters to (0, Inf)
getParamBounds <- function(model, lowest = 0, varParams=NULL) {
namePattern <- paste0("lambdaX[0-9]*$|lambdaY[0-9]*$|",
"thetaDelta[0-9]*$|thetaEpsilon[0-9]*$|",
"phi[0-9]*$|psi[0-9]*$|^A[0-9]*$")
lower <- rep(-Inf, model$freeParams)
upper <- rep(Inf, model$freeParams)
names(lower) <- names(upper) <- names(model$theta)
lower[grepl(namePattern, names(lower)) &
names(lower) %in% varParams] <- lowest
list(lower = lower, upper = upper)
}

Expand Down
9 changes: 0 additions & 9 deletions R/utils_da.R
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,3 @@ getEtaRowLabelOmega <- function(label) {
getXiRowLabelOmega <- function(label) {
stringr::str_split_1(label, "~")[[2]]
}


isDiag <- function(M) {
if (is.null(M)) return(M)
Y <- as.logical.matrix(M)
Y[TRUE] <- FALSE
diag(Y) <- TRUE
Y
}

0 comments on commit 141d45a

Please sign in to comment.