[R] Need help calculating the sum of the index function
Ablaye Ngalaba
@b|@yeng@|@b@ @end|ng |rom gm@||@com
Mon Feb 8 18:21:53 CET 2021
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]]
More information about the R-help
mailing list