Skip to content

Commit d57a5eb

Browse files
committed
1. seed is now random unless user defined. 2. In case of NA in Y z0_start
and levels are regenerated for type=mixed to ensure PD of z0.slice(0) in cpp copula function
1 parent a2f2dc3 commit d57a5eb

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

R/estimate.R

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ estimate <- function(Y,
207207
iter = 5000,
208208
impute = FALSE,
209209
progress = TRUE,
210-
seed = 1,
210+
seed = NULL,
211211
...){
212212

213213
# temporary warning until missing data is fully implemented
@@ -220,10 +220,10 @@ estimate <- function(Y,
220220
}
221221
}
222222

223-
# removed per CRAN (8/12/21)
224-
#old <- .Random.seed
225-
226-
set.seed(seed)
223+
## Random seed unless user provided
224+
if(!is.null(seed) ) {
225+
set.seed(seed)
226+
}
227227

228228
# delta rho ~ beta(delta/2, delta/2)
229229
delta <- delta_solve(prior_sd)
@@ -506,11 +506,17 @@ estimate <- function(Y,
506506

507507
} else {
508508

509-
## If z0_Start has missing, fill with rnorm
510-
Y_missing <- ifelse(is.na(Y), 1, 0)
511-
rank_vars$z0_start[is.na(rank_vars$z0_start)] <- rnorm(sum(Y_missing))
512-
513-
Y <- na.omit(Y)
509+
## check if Y contains NA
510+
contains_na <- any(is.na(Y))
511+
if( contains_na ) {
512+
Y <- na.omit(Y)
513+
## Reassign values when NA are present
514+
temp_helper <- rank_helper(Y)
515+
rank_vars$z0_start <- temp_helper$z0_start
516+
rank_vars$levels <- temp_helper$levels
517+
warning("Observed variables contain missings:\n No imputation, cases are deleted listwise." )
518+
}
519+
514520

515521
post_samp <- .Call(
516522
"_BGGM_copula",

man/estimate.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)