popApplyTwDEMC: popApplyTwDEMC

Description Usage Arguments Value Author(s) See Also Examples

Description

Applying a function across all chains of one population for each case.

Usage

1
popApplyTwDEMC(x, nPop, FUN, ...)

Arguments

x

a matrix with columns chains or array with last dimension chain

nPop

number of populations

FUN

function to apply to population submatrix

...

further arguemtns to FUN

Value

array with last dimenstion correponding to population

Author(s)

Thomas Wutzler

See Also

popMeansTwDEMC subChains.twDEMC

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
data(twdemcEx1)
ex1c <- concatPops(twdemcEx1)
# mean logDen for each case, i.e. step, by population
nPop=getNPops(ex1c)
#mtrace(popApplyTwDEMC)
# applied to a matrix: pops in columns
popApplyTwDEMC( ex1c$logDen[,1,], nPop=nPop, apply, 1, mean )
# applied to a 3d array: pops in 3rd dimension
tmp <- popApplyTwDEMC( ex1c$logDen, nPop=nPop, apply, 1:2, mean )
str(tmp)

# stack logDen of block 1 for each population
tmp <- popApplyTwDEMC( ex1c$logDen[,1,], nPop=nPop, as.vector )
str(tmp)
#stack param columns by population
str(ex1c$parms)	#26 cases, 2 parameters, 2*4=8 chains
tmp <- popApplyTwDEMC( ex1c$parms, nPop=nPop, function(x){ 
                abind::abind(twMisc::twListArrDim(x),along=1) })
all.equal( c(nrow(ex1c$parms)*4, 2,2), dim(tmp))

twDEMC documentation built on May 2, 2019, 5:38 p.m.