Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
joethorley committed Jan 8, 2024
1 parent 59c3214 commit 5cb5fdb
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions R/hcp.R
Original file line number Diff line number Diff line change
Expand Up @@ -301,31 +301,30 @@ hcp_weighted <- function(hcp, weight, value, method, nboot) {
return(hcp)
}

if(!multi) {
weight <- purrr::map_dbl(estimates, function(x) x$weight)
hcp <- purrr::map2(x, weight, .ssd_hcp_tmbfit,
value = value, ci = ci, level = level, nboot = nboot,
min_pboot = min_pboot,
data = data, rescale = rescale, weighted = weighted, censoring = censoring,
min_pmix = min_pmix, range_shape1 = range_shape1, range_shape2 = range_shape2,
parametric = parametric, fix_weights = fix_weights, average = average, control = control,
hc = hc, save_to = save_to, samples = samples, fun = fun)

# TODO: implement hcp_weighted
# TODO: perhaps rename average to unweighted
# TODO: better yet add weighted column...
return(hcp_average(hcp, weight, value, method, nboot))
if(multi) {
hcp <- .ssd_hcp_multi(
x, value, ci = ci, level = level, nboot = nboot,
min_pboot = min_pboot,
data = data, rescale = rescale, weighted = weighted, censoring = censoring,
min_pmix = min_pmix, range_shape1 = range_shape1, range_shape2 = range_shape2,
parametric = parametric, control = control, save_to = save_to, samples = samples,
fix_weights = fix_weights, hc = hc)
return(hcp)
}

hcp <- .ssd_hcp_multi(
x, value, ci = ci, level = level, nboot = nboot,
min_pboot = min_pboot,
data = data, rescale = rescale, weighted = weighted, censoring = censoring,
min_pmix = min_pmix, range_shape1 = range_shape1, range_shape2 = range_shape2,
parametric = parametric, control = control, save_to = save_to, samples = samples,
fix_weights = fix_weights, hc = hc)
weight <- purrr::map_dbl(estimates, function(x) x$weight)
hcp <- purrr::map2(x, weight, .ssd_hcp_tmbfit,
value = value, ci = ci, level = level, nboot = nboot,
min_pboot = min_pboot,
data = data, rescale = rescale, weighted = weighted, censoring = censoring,
min_pmix = min_pmix, range_shape1 = range_shape1, range_shape2 = range_shape2,
parametric = parametric, fix_weights = fix_weights, average = average, control = control,
hc = hc, save_to = save_to, samples = samples, fun = fun)

hcp
# TODO: implement hcp_weighted
# TODO: perhaps rename average to unweighted
# TODO: better yet add weighted column...
hcp_average(hcp, weight, value, method, nboot)
}

ssd_hcp_fitdists <- function(
Expand Down

0 comments on commit 5cb5fdb

Please sign in to comment.