0

I have a data structured as follows:

  • A is the count of positive cases in a cohort
  • B is the total count of the cohort minus A.
  • C is a binary variable
  • D- F are normally distributed continuous variables
  • G is 6 level factor

I am using MCMCglmm package in R to analyse this data to find which of the variables C - G affect A and B.

I have done this successfully using lme4's glmer function with success but now I wish to add more random effects which I have been advised will be better handled by the MCMC optimised variation. However, given the following function call

MCMCmod1 <- MCMCglmm(cbind(A, B) ~ C + D + E + F,
                     random = G,
                     prior = prior,
                     family ="multinomial2",
                     data = g)

(I appreciate the family may not be correct in this case)

Where

prior = list(R = list(V = 1, n = 0, fix = 1),
             G = list(
               G1 = list(V = 1, n = 1),
               G2 = list(V = 1, n = 1),
               G3 = list(V = 1, n = 1),
               G4 = list(V = 1, n = 1),
               G5 = list(V = 1, n = 1)))

I get the following error

Error in `[<-.data.frame`(`*tmp*`, , response.names, value = c(0, 0, 0,  :
missing values are not allowed in subscripted assignments of data frames

However, when I check my variables there are 100% no NAs.

Any ideas on the steps I can take to try to debug this?

JakeCowton
  • 1,374
  • 5
  • 15
  • 35
  • Have you got any empty factors? – Scott Warchal Jun 30 '16 at 16:58
  • By that do you mean is there an empty field for one of the rows in one of the factor type features? – JakeCowton Jun 30 '16 at 17:33
  • I mean that if you created your factors and then subset your data, you might have a factor label that is empty. i.e `x <- factor(c("A", "B", "C")) ; y <- x[2:3]`. Now `y` contains 2 elements yet there are still three factor levels, and non of the elements belong to factor "A". This can sometimes cause your error message. – Scott Warchal Jul 01 '16 at 10:24
  • No this is not the case. Thanks for the suggestion though. – JakeCowton Jul 01 '16 at 12:39
  • I don't have experience of using this package, but I have a feeling that `G` is used to specify the 'G-structure' of the model, so using this as a variable name as well might be causing a problem. – David_B Jul 07 '16 at 19:24
  • The variable names in the question are different from what I'm actually using, but nice idea. – JakeCowton Jul 07 '16 at 20:00

0 Answers0