search for: mysim

Displaying 3 results from an estimated 3 matches for "mysim".

Did you mean: msim
2023 Jan 27
3
implicit loop for nested list
> > I am looking for a more elegant way to write below code. > > #Simulation results have different dimensions > mysim <- lapply(1:10, function(y) { > two.mat <- matrix(rnorm(4), nrow = 2) > four.mat <- matrix(rnorm(16), nrow = 4) > list(two.mat = two.mat, four.mat = four.mat) #results with different dimensions > }) > > #Collect different components of simulation results > #I...
2023 Jan 27
1
implicit loop for nested list
I would use replicate() to do an operation with random numbers repeatedly: ``` mysim <- replicate(10, { two.mat <- matrix(rnorm(4), 2, 2) four.mat <- matrix(rnorm(16), 4, 4) list(two.mat = two.mat, four.mat = four.mat) }) ``` which should give you a matrix-list. You can slice this matrix-list just like normal, then cbind it in one step: ``` two.mat <- do.c...
2011 May 04
1
hurdle, simulated power
...321315 0.910293501 zero_trt -0.200134813 Three of the four look right (ie, converging to population values), but the count_trt is stuck at zero, regardless of sample size (when it should be ~ -0.20). Does anyone see what's wrong? Thanks for any input. cheers, Dave mysim <- function(n, beta0, beta1, alpha0, alpha1, theta){ trt <- c(rep(0,n), rep(1,n)) ### mean function logit model p0 <- exp(alpha0 + alpha1*trt)/(1 + exp(alpha0 + alpha1*trt)) ### 0 / 1 based on p0 y1 <- as.numeric(runif(n)>p0) ### mean function count portion mu <- exp(beta0...