Save a predefined Stan model file to a local text file for editing. These
files can then be used in prepare_model()
by specifying the model_file
argument.
Arguments
- model
Character. Type of model to use, must be one of "first_diff" (First Differences), "gam" (General Additive Model), "gamye" (General Additive Model with Year Effect), or "slope" (Slope model).
- model_variant
Character. Model variant to use, must be one of "nonhier" (Non-hierarchical), "hier" (Hierarchical; default), or "spatial" (Spatially explicit).
- dir
Character. Directory where file should be saved.
- overwrite
Logical. Whether to overwrite an existing copy of the model file.
See also
Other modelling functions:
run_model()
,
save_model_run()
Examples
# Save the Slope model in temp directory
copy_model_file(model = "slope", model_variant = "spatial", dir = tempdir())
#> Copying model file slope_spatial_bbs_CV.stan to /tmp/RtmpcrTot2/slope_spatial_bbs_CV_COPY.stan
#> [1] "/tmp/RtmpcrTot2/slope_spatial_bbs_CV_COPY.stan"
# Overwrite an existing copy
copy_model_file(model = "slope", model_variant = "spatial", dir = tempdir(),
overwrite = TRUE)
#> Copying model file slope_spatial_bbs_CV.stan to /tmp/RtmpcrTot2/slope_spatial_bbs_CV_COPY.stan
#> [1] "/tmp/RtmpcrTot2/slope_spatial_bbs_CV_COPY.stan"
# Clean up
unlink(file.path(tempdir(), "slope_spatial_bbs_CV_COPY.stan"))