Skip to content

Commit

Permalink
Change the function name
Browse files Browse the repository at this point in the history
  • Loading branch information
statwangz committed Oct 12, 2023
1 parent 7d26d9b commit 9b10fe9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export(getELBO)
export(getImportance)
export(initSF)
export(predictFX)
export(softImputeCV)
export(softImputeCV_sparse)
export(softImputeCrossVal)
export(softImputeCrossValSparse)
export(updateMFAIR)
exportClasses(MFAIR)
exportClasses(MFAIRSingleFactor)
Expand Down
22 changes: 10 additions & 12 deletions R/softImputeCV.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
#' @return A list containing the cross-validation results.
#' @export
#'
softImputeCV <- function(Y, rank_max = NULL, lambda_range = NULL,
nfold = 10, para_length = 100) {
N <- dim(Y)[1]
M <- dim(Y)[2]
softImputeCrossVal <- function(Y, rank_max = NULL, lambda_range = NULL,
nfold = 10, para_length = 100) {
N <- nrow(Y)
M <- ncol(Y)
# Report settings
message("Info: Matrix dimension: ", N, " * ", M)
message("Info: Number of cv folds: ", nfold)
Expand Down Expand Up @@ -103,10 +103,10 @@ softImputeCV <- function(Y, rank_max = NULL, lambda_range = NULL,
#' @return A list containing the cross-validation results.
#' @export
#'
softImputeCV_sparse <- function(Y, rank_max = NULL, lambda_range = NULL,
nfold = 10, para_length = 100) {
N <- dim(Y)[1]
M <- dim(Y)[2]
softImputeCrossValSparse <- function(Y, rank_max = NULL, lambda_range = NULL,
nfold = 10, para_length = 100) {
N <- nrow(Y)
M <- ncol(Y)
# Report settings
message("Info: Matrix dimension: ", N, " * ", M)
message("Info: Number of cv folds: ", nfold)
Expand Down Expand Up @@ -152,9 +152,6 @@ softImputeCV_sparse <- function(Y, rank_max = NULL, lambda_range = NULL,
j = idx_all[train_idx, 2],
x = Y@x[train_idx] - train_mean
)
# Y_test <- Incomplete(i = idx_all[-train_idx, 1],
# j = idx_all[-train_idx, 2],
# x = Y@x[-train_idx])

for (j in seq(from = para_length, to = 1, by = -1)) {
if (j == para_length) {
Expand All @@ -170,10 +167,11 @@ softImputeCV_sparse <- function(Y, rank_max = NULL, lambda_range = NULL,
)
}

# The prediction corresponding to the test set
Y_hat <- impute(
si_fit,
i = idx_all[-train_idx, 1], j = idx_all[-train_idx, 2]
) + train_mean # The prediction cooresponding to the test set
) + train_mean
test_err[i, j] <- sqrt(mean((Y@x[-train_idx] - Y_hat)^2))
}
}
Expand Down
6 changes: 3 additions & 3 deletions man/softImputeCV.Rd → man/softImputeCrossVal.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9b10fe9

Please sign in to comment.