Need help calculating the sum of the index function

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Need help calculating the sum of the index function

Ablaye Ngalaba
Hello;


q=3 #dimension of variable Y
R=c(5,4,3);# Number of partition of each component of variable Y
if(length(R) != q) stop("The size of R must be equal to q")
n=25 # Sample size
N=c(25,50,100,200,300,400,500,1000) #different sample sizes

 # Creation of an n11 list containing the sizes of the different groups
  n11=list()
  for (i in 1:q){
    n11[[i]]=rep(as.integer(n/R[i]),R[i])
    n11[[i]][R[i]]=n-((R[i]-1)*n11[[i]][1])
  }




The present code calculates the sum of the indicator function (the
indicator function gives 1 if Y belongs to the partition R=c(5,4,3);#
Number of partition of each component of variable Y and takes the value 0
otherwise).


In my case I want to calculate the sum of the indicator function for i
=1,...,n , with the indicator function which takes the value 1 if Y==l and
0 if Y!=l. Y is a random variable with a value in F = {1,...,q} and l
belongs to F = {1,...,q}.

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.