Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- gm.search <- function (counts.observed, graph.init, forward, backward, score)
- {
- n = ncol(counts.observed)
- cliques.init = maximal.cliques(as.igraph(graph.init))
- score.init = calculate.score(score, counts.observed, n, cliques.init) # <- error
- # Error in `[<-`(`*tmp*`, seq_along(tmp), k, value = tmp) :
- # subscript out of bounds
- # 4 loglin(table, cliques) at assignment2.R#65
- # 3 bic(counts.observed, nnodes, cliques) at assignment2.R#52
- # 2 calculate.score(score, counts.observed, n, cliques.init) at assignment2.R#8
- # 1 gm.search(table(coronary.dat), matrix(0, 6, 6), forward = T,
- # backward = T, score = "bic")
- # ...
- }
- calculate.score <- function (score, counts, nnodes, cliques) {
- if (score == "aic") {
- return (aic(counts.observed, cliques))
- } else if (score == "bic") {
- return (bic(counts.observed, nnodes, cliques))
- } else {
- stop ("Invalid score parameter. Only 'aic' or 'bic' supported.")
- }
- }
- aic <- function (counts, cliques)
- {
- return (loglin(table, cliques) + 2 * dim(cliques))
- }
- bic <- function (counts, nnodes, cliques)
- {
- return (loglin(table, cliques) + log2(nnodes) * dim(cliques))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement