Skip to content

Commit

Permalink
add a conveged attr
Browse files Browse the repository at this point in the history
  • Loading branch information
philchalmers committed Jul 25, 2024
1 parent a7ea869 commit cde51fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
14 changes: 11 additions & 3 deletions R/RCI.R
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,16 @@ RCI <- function(mod_pre, predat, postdat,
fs_post <- fscores(mod_post, response.pattern = postdat, ...)
diff <- fs_post[,1] - fs_pre[,1]
if(Fisher){
fs_pre[,2] <- 1/sqrt(testinfo(mod_pre, Theta = fs_pre[,1]))
fs_post[,2] <- 1/sqrt(testinfo(mod_post, Theta = fs_post[,1]))
fs_pre[,2L] <- 1/sqrt(testinfo(mod_pre, Theta = fs_pre[,1]))
fs_post[,2L] <- 1/sqrt(testinfo(mod_post, Theta = fs_post[,1]))
}
pse <- sqrt(fs_pre[,2]^2 + fs_post[,2]^2)
z <- diff/pse
converge_pre <- converge_post <- rep(TRUE, length(z))
converge_pre[attr(fs_pre, 'failed2converge')] <- FALSE
converge_post[attr(fs_post, 'failed2converge')] <- FALSE
ret <- data.frame(pre.score=fs_pre[,1], post.score=fs_post[,1], diff,
converged=converge_pre & converge_post,
SEM=pse, z=z,
p=pnorm(abs(z), lower.tail = FALSE)*2)
} else {
Expand All @@ -196,7 +200,11 @@ RCI <- function(mod_pre, predat, postdat,
joint <- do.call(rbind, joint)
SEs <- do.call(rbind, lapply(fs_acov, \(x) sqrt(diag(x))))
z <- diff/SEs
ret <- data.frame(diff=diff, joint, z=z,
converge_pre <- converge_post <- rep(TRUE, length(z))
converge_pre[attr(fs_pre, 'failed2converge')] <- FALSE
converge_post[attr(fs_post, 'failed2converge')] <- FALSE
ret <- data.frame(diff=diff, converged=converge_pre & converge_post,
joint, z=z,
p=pnorm(abs(z), lower.tail = FALSE)*2)
}
}
Expand Down
1 change: 1 addition & 0 deletions R/fscores.internal.R
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ setMethod(
whc <- which(converge_info_mat != 1)
warning(paste0("The following factor score estimates failed to converge successfully:\n ",
paste0(whc, collapse=',')), call.=FALSE)
attr(scoremat, 'failed2converge') <- whc
}
return(scoremat)
} else {
Expand Down

0 comments on commit cde51fb

Please sign in to comment.