# NOT RUN {
## CRAN-purpose small computation
# set a seed for reproducibility
set.seed(11)
# small data with identity covariance
pdim <- 10
dat.small <- matrix(rnorm(5*pdim), ncol=pdim)
# run the code
out.small <- CovEst.2010RBLW(dat.small)
# visualize
opar <- par(no.readonly=TRUE)
par(mfrow=c(1,3), pty="s")
image(diag(pdim)[,pdim:1], main="true cov")
image(cov(dat.small)[,pdim:1], main="sample cov")
image(out.small$S[,pdim:1], main="estimated cov")
par(opar)
# }
# NOT RUN {
## want to see how delta is determined according to
# the number of observations we have.
nsamples = seq(from=5, to=200, by=5)
nnsample = length(nsamples)
# we will record two values; rho and norm difference
vec.rho = rep(0, nnsample)
vec.normd = rep(0, nnsample)
for (i in 1:nnsample){
dat.norun <- matrix(rnorm(nsamples[i]*pdim), ncol=pdim) # sample in R^5
out.norun <- CovEst.2010RBLW(dat.norun) # run with default
vec.rho[i] = out.norun$rho
vec.normd[i] = norm(out.norun$S - diag(5),"f") # Frobenius norm
}
# let's visualize the results
opar <- par(mfrow=c(1,2))
plot(nsamples, vec.rho, lwd=2, type="b", col="red", main="estimated rhos")
plot(nsamples, vec.normd, lwd=2, type="b", col="blue",main="Frobenius error")
par(opar)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab