abmantz/lrgs

Error in example notebook

AIAdventures opened this issue · 1 comments

Running the ipython notebook in a jupyter.
Seem to be getting the below error.

xx <- rnorm(100, c(-15,0,15), 1)
yy <- xx + rnorm(length(xx)) + rnorm(length(xx), 0, 3)
xx <- xx + rnorm(length(xx))
M = list()
for (i in 1:length(xx)) M[[i]] <- matrix(c(1,0,0,1), 2, 2)
nmc = 10
post = Gibbs.regression(xx, yy, M, nmc, dirichlet=TRUE, trace='bsgmta', mention.every=1)
plot(xx, yy, col=post$G[,nmc]) # plot clusters at the last iteration
m <- lm(yy~xx)

Error in Gibbs.regression(xx, yy, M, nmc, dirichlet = TRUE, trace = "bsgmta", : Gibbs.regression: dimensionality of M is wrong.
Traceback:

  1. Gibbs.regression(xx, yy, M, nmc, dirichlet = TRUE, trace = "bsgmta",
    . mention.every = 1)
  2. stop("Gibbs.regression: dimensionality of M is wrong."

Please help.
MAny thanks,
Andrew

Hi Andrew,

It looks like the code in the notebook (and in the GitHub README) is from an old version where M was supposed to be a list rather than a 3D array. The same example in the .Rd file appears to be up to date. Can you try out the code there to verify that it works? In other words, replace

M = list()
for (i in 1:length(xx)) M[[i]] <- matrix(c(1,0,0,1), 2, 2)

with

M <- array(0, dim=c(2,2,length(xx)))
M[1,1,] <- 1
M[2,2,] <- 1

Assuming that's fine (it works for me), I'll update the notebook and README code.