X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=pkg%2FR%2FsampleIO.R;h=753e00d3ee1c86ab6f04e609072b1adfe6bd4e36;hb=cc0418ff24f8b6485a2a553cf97ba8afd4d21a7d;hp=5e458377dd1bd523ebf0c93ea2afe86b1f788c4b;hpb=cbd88fe5729bf206a784238a2637aa60e697fcdc;p=morpheus.git diff --git a/pkg/R/sampleIO.R b/pkg/R/sampleIO.R index 5e45837..753e00d 100644 --- a/pkg/R/sampleIO.R +++ b/pkg/R/sampleIO.R @@ -51,7 +51,7 @@ generateSampleIO = function(n, p, β, b, link) { index = c(index, rep(i, classes[i])) newXblock = cbind( MASS::mvrnorm(classes[i], zero_mean, id_sigma), 1 ) - arg_link = newXblock%*%β[,i] + arg_link = newXblock %*% β probas = if (link == "logit") { @@ -61,8 +61,10 @@ generateSampleIO = function(n, p, β, b, link) else #"probit" pnorm(arg_link) probas[is.nan(probas)] = 1 #overflow of exp(x) + probas = rowSums(p * probas) X = rbind(X, newXblock) - Y = c( Y, vapply(probas, function(p) (rbinom(1,1,p)), 1) ) + Y = c( Y, vapply(probas, function(p) (ifelse(p >= .5, 1, 0)), 1) ) + #Y = c( Y, vapply(probas, function(p) (rbinom(1,1,p)), 1) ) } shuffle = sample(n) # Returned X should not contain an intercept column (it's an argument of estimation