rmcelreath/rethinking

extract.samples: potential bug when n = 1

Opened this issue · 0 comments

rxg commented

Given a fit model (based on Howell exposition) extracting a sample of n = 1 produces a data frame with different shape than n > 1.

xx <- extract.samples(m_adults, n = 1)
str(xx)
'data.frame': 3 obs. of 1 variable:

Compare to:

xx <- extract.samples(m_adults, n = 2)
str(xx)
'data.frame': 2 obs. of 3 variables:

I expected the first to produce a data frame of "1 obs. of 3 variables" rather than "3 obs. of 1 variable"

This leads to strange behaviour using link and sim when n = 1, though n = 2 seems to behave as expected.