How can I simulate the data for the variable Y in R,.suppose I have Y1=rpois(n,u), Y2= ruinf(n,0,1) , z=y1+y2 and a=0.5 and then I want to simulate the data for the same variable as Y=Y={log(Z-a) if Z-a>0 log(e) if z-a<=0}. then how will i do it?
1 Answer
$\begingroup$
$\endgroup$
1
genY <- function(z) {
if (z > 0.5){
Y = log10(z-0.5)
}
else{
Y = log10(2.71828)
}
}
Y = {}
for (z in runif(10000, 0, 1)){
y = genY(z);
Y = c(Y, y)
}
Is this what you need?
-
$\begingroup$ I don't think it's difficult, just read the manual and try it yourself. $\endgroup$– hxhcCommented Jul 18, 2017 at 2:00