Sampling
When building any model in finance, we may have very large datasets on which model building will be very time-consuming. Once the model is built, if we need to tweak the model again, it is going to be a time-consuming process because of the volume of data. So it is better to get the random or proportionate sample of the population data on which model building will be easier and less time-consuming. So in this section, we are going to discuss how to select a random sample and a stratified sample from the data. This will play a critical role in building the model on sample data drawn from the population data.
Random sampling
Select the sample where all the observation in the population has an equal chance. It can be done in two ways, one without replacement and the other with replacement.
A random sample without replacement can be done by executing the following code:
> RandomSample <- Sampledata[sample(1:nrow(Sampledata), 10, >+ replace=FALSE),]
This generates the following...