Advertisement
Guest User

Untitled

a guest
May 30th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. num.funds <- c(1, 5, 10, 15, 20, 25, 30, 50, 100)
  2. for(i in num.funds) {
  3. simulate <- function(i) {
  4. repeat{
  5. start <- dataset[sample(nrow(dataset), 1, replace=TRUE),] #starting fund
  6. t <- start$Vintage:(start$Vintage + 4) #5 years
  7. matches <- which(dataset$Vintage %in% t) #constraints
  8. x <- dataset[sample(matches, min(length(matches),i), replace = FALSE), ]
  9. if(nrow(x) ==i) {
  10. x <- x %>% mutate(EqualWeight = 1 / i)
  11. x <- ungroup(x)
  12. return(x)
  13. } else {
  14. x <- 0
  15. }
  16. }
  17.  
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement