I would like to generate random, non-normal variables using the nonnormvar1 function from SimMultiCorrData. This function works just fine on its own and outputs a continuous variable:
nonnormvar1(method = "Fleishman", means = 50, vars = 10,
skews = 3, skurts = 14, n=100)
But when I 'mapply' nonnormvar1 in my own function, I get rows of lists of data as my output:
my_func <- function(sample_pairs, sig_pairs, nnorm_pairs) {
return(sapply(1:nrow(sample_pairs), function(i) {
mapply(nonnormvar1, method = "Fleishman",
means = mu, vars = sig_pairs[i, ],
skews = nnorm_pairs[i,1], skurts = nnorm_pairs[i,2],
n = sample_pairs[i], seed = 123)
}))
}
samples <- matrix(c(rep(c(100, 100), 6), rep(c(50, 50), 6)),
ncol = 2, byrow = TRUE)
sigs <- matrix(c(rep(c(2, 2), 6), rep(c(35, 35), 6)),
ncol = 2, byrow = TRUE)
nnrom <- matrix(c(rep(c(0, 0), 4), rep(c(2, 4), 4), rep(c(1, 5), 4)),
ncol = 2, byrow = TRUE)
my_func(samples, sigs, nnrom)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[1,] List,4 List,4 List,4 List,4 List,4 List,4 List,4 List,4 List,4 List,4 List,4 List,4
[2,] List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,1
[3,] List,11 List,11 List,11 List,11 List,11 List,11 List,11 List,11 List,11 List,11 List,11 List,11
Ideally I want 12 dataframes of two variables each that I can calculate a statistic over. I'm sure there's something obvious that I'm missing but I don't see it.
Aucun commentaire:
Enregistrer un commentaire