Question
Answer question 1 below. Let Y > 0 be a continuous random variable representing time from regimen start to bone-marrow transplant. Everyone does not survive
Answer question 1 below.
Let Y > 0 be a continuous random variable representing time from regimen start to bone-marrow transplant. Everyone does not survive long enough to get the transplant. Let X > 0 be a continuous random variable representing time from regimen start to death. We can assume X Y and model time to death as X Exp(rate = ) and time to transplant as Y Exp(rate = ). Where Exp(rate = ) denotes the exponential distribution with density f(z | ) = ez for z > 0 and 0 elsewhere - with > 0.
1. ) Assume that we have = 1/10 and = 1/15. Use the rexp() function in R for i = 1, 2, . . . , 10000 in simulating death and transplant times for 10,000 patients Xi Exp(1/10) and Yi Exp(1/15). Show R code in your answer.
What is the proportion of simulated patients who receive transplant before death?
The code should be similar in similar form to the code below, but using the rexp function instead of rbinom and gamma
set.seed(1)
x = rbinom( n = 1000, size = 1, prob = .5 )
y = x*rgamma(1000, 5, 1)
hist(y, breaks = 10, freq=F, col='white',
main='Marginal Distribution of Y, f(y)')
marginal_density = function(x){
.5*( x == 0) + .5*dgamma(x, 5, 1)
}
curve(dgamma(x, 5, 1), add=T, col='red', lwd=2)
curve(marginal_density(x), add=T, col='blue', lwd=2)
legend('topright', col = c('red', 'blue'),
bty='n', lty=c(1,1), lwd=c(2,2),
legend = c('Gamma Density', 'Mixture Gamma Density'))
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started