save_proposal: Save User Proposal

View source: R/proposal_info.R

save_proposalR Documentation

Save User Proposal

Description

This function stores proposals generated by the build_proposal() function in R's internal data directory. It is useful when users want to reuse a proposal across multiple R sessions.

Usage

save_proposal(proposal, proposal_name)

Arguments

proposal

list representing an optimized proposal generated using the build_proposal() function.

proposal_name

string specifying the name under which the proposal will be saved.

Value

This function will produce an error if the proposal is not generated by the build_proposal() function. Otherwise, it successfully saves the proposal without returning any value upon completion.

Examples

# First, let's create a proposal to sample from a standard normal distribution
f_normal <- function(x) { 0.3989423 * exp( -0.5 * x^2) }
normal_proposal = build_proposal(f = f_normal, modes = 0, lower = -Inf, upper = Inf, steps = 1000)
print(normal_proposal)

# Then, we can save this proposal in R's internal data directory using `save_proposal()`
# with the name "normal"
save_proposal(normal_proposal, "normal")

# To make sure the `normal_proposal` has been stored in R's internal data directory,
# we can print all saved proposals using `print_proposals()`
print_proposals()



stors documentation built on April 3, 2025, 6:16 p.m.