dataset = matrix(rnorm(300),100,3)
# assign random weights to observations
weight = sample(1:20,100,replace = TRUE)
# spherize the dataset with observational weights
res = wsph(dataset,weight)
# spherized data matrix considering the observation weights
res$data_wsph
# The spherzied data matrix has a zero weighted sample mean for each column
1/sum(weight)*t(as.matrix(weight))%*%as.matrix(res$data_wsph)
# The spherzied data matrix has a weighted covariance that equals identity matrix
1/sum(weight)*t(as.matrix(res$data_wsph))%*%diag(weight)%*%as.matrix(res$data_wsph)
Run the code above in your browser using DataLab