Added computePopulationLogml.R
This commit is contained in:
parent
981361ff44
commit
8abd467ca6
1 changed files with 24 additions and 0 deletions
24
R/computePopulationLogml.R
Normal file
24
R/computePopulationLogml.R
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
computePopulationLogml <- function(pops, adjprior, priorTerm) {
|
||||
# Palauttaa length(pops)*1 taulukon, jossa on laskettu korikohtaiset
|
||||
|
||||
x <- size(COUNTS, 1)
|
||||
y <- size(COUNTS, 2)
|
||||
z <- length(pops)
|
||||
|
||||
popLogml <- squeeze(
|
||||
sum(
|
||||
sum(
|
||||
reshape(
|
||||
lgamma(
|
||||
repmat(adjprior, c(1, 1, length(pops))) +
|
||||
COUNTS[, , pops]
|
||||
),
|
||||
c(x, y, z)
|
||||
),
|
||||
1
|
||||
),
|
||||
2
|
||||
)
|
||||
) - sum(lgamma(1 + SUMCOUNTS[pops, ]), 2) - priorTerm
|
||||
return(popLogml)
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue