# NOT RUN {
### ----<< Example 1 >>---- : 30 points in R^2
# }
# NOT RUN {
set.seed(123)
X <- rmvnorm(n = 30,mean = c(0,0)) # from package 'mvtnorm'
ojaRank(X)
ojaRank(X, x = c(100,100))
ojaRank(X, x = ojaMedian(X, alg="exact")) # close to zero
# The following two return the same (only in different time)
ojaRank(X)
t(apply(X, 1, function(y){ojaRank(X,y)}))
# but the following two do not (due to different subsampling).
# 1)
set.seed(123); ojaRank(X, p = 0.9, silent = TRUE)
# 2)
set.seed(123)
t(apply(X, 1, function(y){ojaRank(X, y, p = 0.9, silent = TRUE)}))
# In 1) one subsample for all ranks is drawn, whereas in 2)
# a different sample for each rank is drawn.
# }
# NOT RUN {
### ----<< Example 2 >>---- : three points in R^3: only one hyperplane
# The following commands return the same result.
# }
# NOT RUN {
ojaRank(X = diag(rep(1, 3)), x = c(0,0,0))
ojaRank(X = diag(rep(1, 3)), x = c(-100,-110,-5550))
hyperplane(X = diag(rep(1,3)))[1:3]
# }
# NOT RUN {
### ----<< Example 3 >>---- : 300 points in R^7
# Subsampling is done.
# The following example might take a bit longer:
# }
# NOT RUN {
set.seed(123)
X <- rmvnorm(n = 300, mean = rep(0, 7))
system.time(or <- ojaRank(x = 1:7, X = X))
# PLEASE NOTE: The computation of the Oja rank is based on a
# random sub-sample of less than 1% of all possible hyperplanes.
#
# user system elapsed
# 18.47 0.00 18.47
print(or,d=4)
# [1] 7.733 6.613 6.839 7.383 18.237 21.851 23.700
# }
# NOT RUN {
### ----<< Example 4 >>---- : univariate ranks
# }
# NOT RUN {
ojaRank(1:10)
ojaRank(X = 1:10, x = 5.5)
# }
Run the code above in your browser using DataLab