jeudi 2 juillet 2020

How can I use if syntax for a binomial distributed matrix?

I want to know if it's possible to use if syntax for a binomial distributed matrix? If so, how to use it?

Here is part of my codes

b = 200
y_it <- matrix(rnorm(N*T, mean = 8.16, sd = 0.96), nrow = T, ncol = N)
c_i1 <- rbinom(N, 1, 0.80)
c_it <- matrix(rep(t(c_i1), T), ncol = N, byrow = TRUE)
if (c_it == 0){
  c <- b*y_it
}

And it shows a warning message:

Warning message:
In if (c_it == 0) { :
  the condition has length > 1 and only the first element will be used

And I cannot really get what I want(c, in this case). How can I solve this problem?

Aucun commentaire:

Enregistrer un commentaire