R programs for observed case simulation