if (Infusion.getOption("example_maxtime")>20) {
#### Toy bivariate gaussian model, three parameters, no projections
#
myrnorm2 <- function(mu1,mu2,s2,sample.size) {
sam1 <- rnorm(n=sample.size,mean=mu1,sd=sqrt(s2))
sam2 <- rnorm(n=sample.size,mean=mu2,sd=sqrt(s2))
s <- c(sam1,sam2)
e_mu <- mean(s)
e_s2 <- var(s)
c(mean=e_mu,var=e_s2,kurt=sum((s-e_mu)^4)/e_s2^2)
}
#
## pseudo-sample, standing for the actual data to be analyzed:
set.seed(123)
Sobs <- myrnorm2(mu1=4,mu2=2,s2=1,sample.size=40) ##
#
## build reference table
parsp <- init_reftable(lower=c(mu1=2.8,mu2=1,s2=0.2),
upper=c(mu1=5.2,mu2=3,s2=3),
nUnique=600)
parsp <- cbind(parsp,sample.size=40)
simuls <- add_reftable(Simulate="myrnorm2",par.grid=parsp)
## Inferring the summary-likelihood surface...
densv <- infer_SLik_joint(simuls,stat.obs=Sobs)
slik_j <- MSL(densv) ## find the maximum of the log-likelihood surface
## plots
plot2Dprof(slik_j,gridSteps=21,
## alternative syntaxes for non-default 'pars':
# pars = c("mu1","mu2"), # => all combinations of given elements
# pars = list("s2",c("mu1","mu2")), # => combinations via expand.grid()
# pars = matrix(c("mu1","mu2","s2","mu1"), ncol=2), # => each row of matrix
xylabs=list(
mu1=expression(paste(mu[1])),
mu2=expression(paste(mu[2])),
s2=expression(paste(sigma^2))
))
# One could also add (e.g.)
# cluster_args=list(spec=4, type="FORK"),
# when longer computations are requested.
}
if (Infusion.getOption("example_maxtime")>40) {
#### Older example with primitive workflow
data(densv)
slik <- infer_surface(densv) ## infer a log-likelihood surface
slik <- MSL(slik) ## find the maximum of the log-likelihood surface
plot1Dprof(slik,pars="s2",gridSteps=40,xlabs=list(s2=expression(paste(sigma^2))))
}
Run the code above in your browser using DataLab