Skip to content

Commit

Permalink
Bug in rgeneric estimating signs of covariance elements wrongly
Browse files Browse the repository at this point in the history
  • Loading branch information
haziqj committed May 29, 2024
1 parent 009d3cf commit f6f198e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions R/20-rgeneric.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,9 @@ inla_sem <- function(
lambda <- theta[idx_lam]
beta <- theta[idx_beta]
sd_e <- sqrt(exp(theta[idx_theta])) # sd_e = sd_e ^ 2 (item sd)
u <- 1 / (1 + exp(-theta[idx_rho]))
rho <- 2 * u - 1
rho <- INLAvaan:::theta_to_rho(theta[idx_rho])
sd_z <- sqrt(exp(theta[idx_psi])) # sd_z = sd_z ^ 2 (latent sd)
lvrho <- 1 / (1 + exp(-theta[idx_lvrho]))
lvrho <- INLAvaan:::theta_to_rho(theta[idx_lvrho])

list(
lambda = lambda,
Expand Down Expand Up @@ -131,7 +130,7 @@ inla_sem <- function(
front <- Lambda %*% solve(IminB)
}
Sigma <- front %*% tcrossprod(Psi, front) + Theta
Sigma <- Sigma + diag(1e-10, nrow(Sigma)) # for stability
Sigma <- Sigma + diag(1e-7, nrow(Sigma)) # for stability
solve(Sigma)
}

Expand Down

0 comments on commit f6f198e

Please sign in to comment.