View source: R/functions_estimate.R
1 | estimate_multipleBERPM(partitions, presence.tables, nodes, objects, effects, mean.priors, sd.priors, start.chains = NULL, burnin.1 = 30, thining.1 = 10, num.chains = 3, length.chains = 1000, burnin.2 = 30, neighborhood.partition = c(0.7, 0.3, 0, 0, 0, 0), neighborhood.augmentation = NULL, sizes.allowed = NULL, sizes.simulated = NULL, parallel = F, cpus = 1)
|
partitions |
Observed partitions. |
presence.tables |
Matrix indicating which actors were present for each observations (mandatory). |
nodes |
Data frame containing the nodes. |
objects |
Objects used for statistics calculation. A list with a vector "name" and a vector "object". |
effects |
Effects or sufficient statistics. A list with a vector "names" and a vector "objects". |
mean.priors |
Means of the normal distributions of prior parameters. |
sd.priors |
Standard deviations of the normal distributions of prior parameters. |
start.chains |
|
burnin.1 |
|
thining.1 |
|
num.chains |
|
length.chains |
|
burnin.2 |
|
neighborhood.partition |
|
neighborhood.augmentation |
|
sizes.allowed |
|
sizes.simulated |
|
parallel |
|
cpus |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (partitions, presence.tables, nodes, objects, effects,
mean.priors, sd.priors, start.chains = NULL, burnin.1 = 30,
thining.1 = 10, num.chains = 3, length.chains = 1000, burnin.2 = 30,
neighborhood.partition = c(0.7, 0.3, 0, 0, 0, 0), neighborhood.augmentation = NULL,
sizes.allowed = NULL, sizes.simulated = NULL, parallel = F,
cpus = 1)
{
num.effects <- length(effects$names)
z.obs <- rowSUms(computeStatistics_multiple(partitions, presence.tables,
nodes, effects, objects))
print("Observed statistics")
print(z.obs)
print("Burn-in")
print(burnin.1)
print("Thining")
print(thining.1)
if (is.null(start.chains)) {
start.chains <- list()
for (p in 1:num.effects) {
start.chains[[p]] <- rnorm(num.effects, mean = mean.priors,
sd = sd.priors)
}
}
if (is.null(neighborhood.augmentation)) {
neighborhood.augmentation <- rep(0.1, num.effects)
}
results_exchange <- draw_exchangealgorithm_multiple(partitions,
z.obs, presence.tables, nodes, objects, effects, mean.priors,
sd.priors, start.chains, burnin.1, thining.1, num.chains,
length.chains, burnin.2, neighborhood.partition, neighborhood.augmentation,
sizes.allowed, sizes.simulated, parallel, cpus)
results <- data.frame(effect = effects$names, object = effects$objects,
post.mean = results_exchange$post.mean, post.sd = results_exchange$post.sd)
print_results_bayesian(results)
return(list(results = results, all.chains = results_exchange$all.chains))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.