Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- num.funds <- c(1, 5, 10, 15, 20, 25, 30, 50, 100)
- for(i in num.funds) {
- simulate <- function(i) {
- repeat{
- start <- dataset[sample(nrow(dataset), 1, replace=TRUE),] #starting fund
- t <- start$Vintage:(start$Vintage + 4) #5 years
- matches <- which(dataset$Vintage %in% t) #constraints
- x <- dataset[sample(matches, min(length(matches),i), replace = FALSE), ]
- if(nrow(x) ==i) {
- x <- x %>% mutate(EqualWeight = 1 / i)
- x <- ungroup(x)
- return(x)
- } else {
- x <- 0
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement