context("CopyReference") test_that("copyReference",{ skip_on_cran() expect_equal({ set.seed(601231) n <- 10000 z <- c(rep(0,n/2),rep(1,n/2)) k <- 4 gamma <- rgamma(n,shape=k,scale=1/k) rate <- gamma*exp(1*z) #simulate random follow-up time for subject if they remain in study fullFupTime <- 1+0.1*runif(n) #simulate time at which they might drop out, between 0 and 1 dropOutTime <- runif(n) y1 <- rpois(n, lambda=rate*dropOutTime) #generate count for second period assuming they remain on randomised treatment y2 <- rpois(n, lambda=rate*(fullFupTime-dropOutTime)) #generate another outcome that occurs if patient is on placebo in second period, #using the copy reference assumption upsi1 <- dropOutTime*exp(0) upsi2 <- (fullFupTime-dropOutTime)*exp(0) y2placebo <- rnbinom(n, size=(k+y1), prob=((k+upsi1)/(k+upsi1+upsi2))) #model dropout process, conditional on y1 do_xb <- -1+1*log(y1+1) do_pr <- exp(do_xb)/(1+exp(do_xb)) do <- 1*(runif(n)