-2

I am having trouble running a Levene Test on an Anova. I keep getting the following error:

'Error in y - meds[group] : non-conformable arrays'

Here is what I have:

MiniP$Education <- as.factor(MiniP$US_DEGR)
MiniP$Sex <- as.factor(MiniP$SEXM1F2)
leveneTest(Immigration~Education*Sex, data = MiniP)

Sex has 2 levels, Male and Female, and education has 5 levels, ranging from HS Dropout to Grad School.

For males by education level, I have (68, 286, 44, 123, 66) and for females by education level, I have (92, 330, 69, 118, 75). I've tried setting my predictors to numeric and to factors.

I get that reproducible examples are helpful, but after reading the documentation shared in the comments, it appears that you need to include a data frame to make the example reproducible (understandably). However, the dataset that I am using has over 1200 cases. So I don't know how to provide that here. The code that I have isn't broken, it works on other datasets and variables, but for some reason, it won't work on this equation. I've tried setting my predictors to numeric and to factors.

ksnider
  • 31
  • 4
  • What are the dimensions of the arrays? (not the number of factors, the actual dimension of the arrays in R). Also, try running only this part `Immigration~Education*Sex` to see if the dimension mismatch is there. – Daniel Oct 15 '17 at 06:14
  • I'm not sure what you mean by the dimensions of the arrays... As for the model alone, I've run it like this model3a <- lm(Immigration ~ Sex*Education, data = MiniP) Anova(model3a, type = 3) # Omnibus effects (F-tests) summary(model3a) # regression coefficients All of that ran just fine, and I got results. Additionally, I've run a describeBy() and while there are unequal n's, everything else looks ok-ish as far as I can tell. – ksnider Oct 15 '17 at 06:20
  • Call `nrow` and `ncol` with each one of your matrices to know their sizes, then update your questions with that info – Daniel Oct 15 '17 at 06:30
  • @ksnider Put aditional info in your question (not in the comments), i.e. edit your question: https://stackoverflow.com/posts/46752189/edit Please read https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – jogo Oct 15 '17 at 07:04

1 Answers1

3

Here was the answer

MiniP$Immigration <- as.numeric(MiniP$Immigration)

I'm not sure why, as it was already a numeric variable to begin with (a scored scale), but given the trouble I had finding an answer to my question, I wanted to share this here in case others had the same problem. Turns out it was a simple fix.

ksnider
  • 31
  • 4