This is the main high-level wrapper function for running focus group simulations. It creates agents, sets up the focus group, runs the simulation, and returns a comprehensive result object.
Usage
run_focus_group(
topic,
participants = 6,
turns_per_phase = c(Opening = 2, Icebreaker = 3, Engagement = 8, Exploration = 10,
Closing = 2),
demographics = NULL,
survey_responses = NULL,
conversation_flow = "desire_based",
llm_config = NULL,
seed = NULL,
msg_mode = c("roleflip", "flat"),
verbose = TRUE,
max_participant_responses = NULL
)Arguments
- topic
Character string describing the focus group topic
- participants
Integer number of participants (excluding moderator)
- turns_per_phase
Named list or vector specifying turns for each phase. Can be a named vector like c(Opening = 2, Icebreaker = 3, Engagement = 8, Exploration = 10, Closing = 2) or a named list.
- demographics
Optional data frame with participant demographics. If NULL, diverse demographics will be automatically generated.
- survey_responses
Optional data frame with survey responses. If NULL, responses will be automatically generated.
- conversation_flow
Character string specifying turn-taking mechanism: "round_robin", "probabilistic", or "desire_based". Default is "desire_based".
- llm_config
List with LLM configuration. If NULL, uses default configuration.
- seed
Optional integer. Seeds R's RNG, which governs speaker selection and other in-package sampling. It does NOT make the LLM output reproducible: at `temperature > 0` the provider samples server-side, beyond R's control.
- msg_mode
How each agent's turn is presented to the model. `"roleflip"` (default) gives each agent its own prior turns in the assistant role and others' turns as labeled user messages, which reduces self-repetition; `"flat"` reproduces the legacy single-user-message transcript. Recorded per run so the construction is explicit rather than an implicit default.
- verbose
Logical, whether to print progress messages
- max_participant_responses
Optional integer. Maximum participant responses per moderator question before the moderator advances.
Value
A list containing: * `focus_group`: The FocusGroup object * `conversation`: Data frame with the full conversation * `summary`: Conversation summary * `basic_stats`: Basic conversation statistics * `participants`: Information about participants
Examples
if (FALSE) { # \dontrun{
# Simple focus group on social media
result <- run_focus_group(
topic = "Social media impact on mental health",
participants = 6,
turns_per_phase = c(Opening = 2, Icebreaker = 3,
Engagement = 8, Exploration = 10, Closing = 2)
)
# Access the conversation
head(result$conversation)
# View summary
result$summary
} # }
