Skip to content
Snippets Groups Projects
Commit a09c2ffe authored by dj44vuri's avatar dj44vuri
Browse files

modified chunks

parent 9c782c3a
No related branches found
No related tags found
No related merge requests found
......@@ -219,7 +219,7 @@ transform_util2 <- function() {
# Initialize the starting point for the first chunk
start_point <- 1
for (i in 1:chunks) {
for (i in seq_along(1:chunks)) {
# Calculate the end point for the current chunk
end_point <- start_point + chunk_size - 1
......@@ -228,11 +228,20 @@ transform_util2 <- function() {
end_point <- no_sim
}
# Run simulations for the current chunk
# Run estimations for the current chunk
output <- start_point:end_point %>% purrr::map(estimate_sim)
tictoc::tic(paste0("start_estimation of chunk",i))
output <- sim_data[[start_point]]:sim_data[[end_point]] %>%
purrr::map(
~ mixl::estimate(
model_spec = model_spec,
start_values = est,
availabilities = availabilities,
data = .x
)
)
tictoc::toc()
saveRDS(output,paste0("tmp_",i,".RDS"))
......@@ -248,9 +257,9 @@ transform_util2 <- function() {
# Break the loop if the end point reaches or exceeds no_sim
if (start_point > no_sim) break
}
output <- list() # Initialize the list to store all outputs
# Assuming the files are named in sequence as 'tmp_1.RDS', 'tmp_2.RDS', ..., 'tmp_n.RDS'
......@@ -280,10 +289,10 @@ tictoc::tic("start_estimation")
data = .x
)
)
tictoc::toc()
}
tictoc::toc()
coefs<-purrr::map(1:length(output),~summary(output[[.]])[["coefTable"]][c(1,8)] %>%
tibble::rownames_to_column() %>%
......
......@@ -20,6 +20,9 @@ simulate_choices <- function(data, utility, setspp, bcoeff, decisiongroups = c(0
} else {
# Execute the user-supplied `preprocess_function`
prepro_data <- preprocess_function()
if (!is.null(prepro_data) && (!is.data.frame(prepro_data) || !"ID" %in% names(prepro_data))) {
stop("The output of `preprocess_function` must be a data.frame with a column named 'ID'.")
}
cat("\n Preprocess function has been executed.\n")
}
} else {
......@@ -40,14 +43,6 @@ simulate_choices <- function(data, utility, setspp, bcoeff, decisiongroups = c(0
dplyr::transmute(!!formula.tools::lhs(equation) := !!formula.tools::rhs(equation) )
}
# Here one can add additional case-specific data
cat(" \n does sou_gis exist: ", exists("sou_gis"), "\n")
if (exists("sou_gis") && is.function(sou_gis)) {
sou_gis()
cat("\n source of gis has been done \n")
}
if(!exists("manipulations")) manipulations=list() ## If no user input on further data manipulations
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment