simulate_burnin_single: Find the burn-in step

Description Usage Arguments Author(s) Examples

View source: R/functions_burninthining.R

Description

Function used to find appropriate burn-in step.

Usage

1
simulate_burnin_single(partition, theta, nodes, effects, objects, num.steps, neighborhood, sizes.allowed, sizes.simulated)

Arguments

partition

Observed partition.

theta

Initial model parameters

nodes

Data frame containing the nodes.

effects

Effects or sufficient statistics. A list with a vector "names" and a vector "objects".

objects

Objects used for statistics calculation. A list with a vector "name" and a vector "object".

num.steps

Number of samples wanted.

neighborhood

Way of choosing partitions: probability vector (probability actors swap, probability merge/division, probability single actor move).

sizes.allowed

Vector of group sizes allowed in sampling.

sizes.simulated

Vector of group sizes allowed in the Markov chain but not necessraily sampled.

Author(s)

Marion Hoffman

Examples

 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
##---- 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 (partition, theta, nodes, effects, objects, num.steps,
    neighborhood, sizes.allowed, sizes.simulated)
{
    num.effects <- length(effects$names)
    print("Neighborhood: ")
    print(neighborhood)
    chain <- draw_Metropolis_single(theta, partition, nodes,
        effects, objects, 1, 1, num.steps, neighborhood, sizes.allowed,
        sizes.simulated, return.all.partitions = F)
    allmeans <- matrix(0, nrow(chain$draws), num.effects)
    allmeans[1, ] <- chain$draws[1, ]
    for (d in 2:nrow(chain$draws)) {
        allmeans[d, ] <- colMeans(chain$draws[1:d, ])
    }
    smoothedmeans <- allmeans
    for (eff in 1:num.effects) {
        lo <- loess(y ~ x, data.frame(x = 1:nrow(chain$draws),
            y = allmeans[, eff]))
        smoothedmeans[!is.na(smoothedmeans[, eff]), eff] <- lo$fitted
    }
    return(list(draws = chain$draws, moving.means = allmeans,
        moving.means.smoothed = smoothedmeans))
  }

isci1102/ERPM documentation built on Jan. 18, 2022, 12:25 a.m.