I am writing a program that allows the user to specify a seed for reproducibility. This is an extract of a much larger program I am writing. For illustration purposes, let us say I would like to split the data into n (e.g., 10) equal-size folds. The program would be:
Is it possible to have the option of setting a seed but not define a default value? In other words, I would like the program to split the data in any way it likes when a seed has not been specified but still allow the option to set a seed for reproducibility?
Please note that splitting folds is not the focus of this topic. I am sure there are ways to set a seed for splitting data but this is not of interest for this topic.
Code:
sysuse auto, clear capture program drop myprogram program define myprogram syntax [, folds(int 10) seed(int 1)] set seed `seed' // seed to reproduce the splitting of the data capture drop foldid qui xtile foldid = uniform() , nq(`folds') end myprogram, seed(1)
Please note that splitting folds is not the focus of this topic. I am sure there are ways to set a seed for splitting data but this is not of interest for this topic.
Comment