# NOT RUN {
# -------------------------------------------------------------------
# Example with Spherical Laplace Distribution
#
# Given a fixed set of parameters, generate samples and acquire MLEs.
# Especially, we will see the evolution of estimation accuracy.
# -------------------------------------------------------------------
## DEFAULT PARAMETERS
true.mu = c(1,0,0,0,0)
true.sig = 1
## GENERATE A RANDOM SAMPLE OF SIZE N=1000
big.data = rsplaplace(1000, true.mu, true.sig)
## ITERATE FROM 50 TO 1000 by 10
idseq = seq(from=50, to=1000, by=10)
nseq = length(idseq)
hist.mu = rep(0, nseq)
hist.sig = rep(0, nseq)
for (i in 1:nseq){
small.data = big.data[1:idseq[i]] # data subsetting
small.MLE = mle.splaplace(small.data) # compute MLE
hist.mu[i] = acos(sum(small.MLE$mu*true.mu)) # difference in mu
hist.sig[i] = small.MLE$sigma
}
## VISUALIZE
opar <- par(no.readonly=TRUE)
par(mfrow=c(1,2))
plot(idseq, hist.mu, "b", pch=19, cex=0.5,
main="difference in location", xlab="sample size")
plot(idseq, hist.sig, "b", pch=19, cex=0.5,
main="scale parameter", xlab="sample size")
abline(h=true.sig, lwd=2, col="red")
par(opar)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab