"Error in compute_pca_impute_missing Function: 'could not find function estim_ncpPCA'"

Title: Error in compute_pca_impute_missing Function: "could not find function 'estim_ncpPCA'"

Description:
I encountered an error while using the compute_pca_impute_missing function in R. The error message states, "could not find function 'estim_ncpPCA'".

Code and Function Explanation:

compute_pca_impute_missing(pca_vars, dhs_all_df, save_model = FALSE, model_path = NULL)

Function

function(pca_vars, 
                                       dhs_all_df,
                                       save_model = F,
                                       model_path = NULL){
  
  pca_df <- dhs_all_df %>%
    dplyr::select(all_of(pca_vars)) %>%
    mutate_all(as.numeric) %>%
    mutate_all(. %>% scales::rescale(to = c(0,1)))
  
  # file:///Users/robmarty/Downloads/v70i01.pdf
  # Estimate number of dimensions; takes a while, so take a random sample
  N_use <- ceiling(nrow(pca_df)*0.1)
  
  ncomp <- pca_df %>%
    arrange(runif(n())) %>%
    head(N_use) %>%
    estim_ncpPCA()
  
  #ncomp <- estim_ncpPCA(pca_df)
  res.imp <- imputePCA(pca_df, ncp = ncomp$ncp)
  res.pca <- prcomp(res.imp$completeObs, scale = T)
  out <- res.pca$x[,1]*(-1)
  
  if(save_model){
    saveRDS(res.pca, model_path)
  }
  
  return(out)
}


This function computes Principal Component Analysis (PCA) and imputes missing values in a dataframe (dhs_all_df) based on specified variables (pca_vars). It internally utilizes the estim_ncpPCA function from the pcaMethods package for estimating the number of dimensions for PCA.

Error Message:

Error in estim_ncpPCA(.) : could not find function "estim_ncpPCA"

Request for Assistance:
I'm seeking guidance on resolving this error. Specifically, I would like to know how to ensure that the estim_ncpPCA function is accessible within my R environment.

Thank you for your assistance!

I don't see the estim_ncpPCA() function in pcaMethods but I do see it in missMDA. Do you need to load that package?