1
$\begingroup$

I am from an applied background, where X2 and G-tests are the default ways to analyze count data (default as in, until today, I had no idea there were other ways, as I was only taught these methods). However, now that I see there are model-based approaches, I would like to analyze my data in this fashion (if possible).

The data is in a contingency table, and the first column is an individual. Each of cells in the next five columns has a count for something, such as a clothing type. Thus, I have something like

Person    Jeans    Collar.Shirt     Mini.Skirt     Maxi.Skirt     Tank.Top
1               5          10                4               2            7     
2               7           5                12              5            15  
3               15          7                10              10           8
4               6           7                3               11           17 

If I consider my first column a response variable, and the next five as predictors, I should, in theory, be able to do some type of regression. However, for this, it seems that since clothing types are all clothes, I end up with a single predictor, with counts as each level of a factor.

Because I have more outcomes than predictors, assuming I consider each its on IV, a multinomial logistic regression is going to end up with a lot of empty values, making this (in my mind, anyhow) inappropriate.

That leaves me with, as far as I know, Poisson and negative binomial regression.

When I attempted, in R, a NB model, using MASS on the wide-format table above, I get an error.

This is the code I used for the NB:

summary(NB <- glm.nb(Person ~ Jeans + Collar.Shirt + Mini.Skirt + Maxi.Skirt + Tank.Top, data = d))

This is the error:

 Warning messages:
    1: In theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace = control$trace >  :  iteration limit reached
    2: In theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace = control$trace >  :  iteration limit reached

When I do Poisson for this same dataframe, I do get results. Nothing significant, other than the Null...and each of the IV's have Z=0 and p=1. The Null Deviance is 10.3 and the Residual is 0.4. As I understand it, since the Residual is quite low, this model, as insignificant as it may be, does well at explaining the data. However, it seems inappropriate to use this model, given I technically have factors of a single predictor.

So, if I reshape the data into a long format, so that it looks like:

Person    Clothing         Count       
1               Jeans             5         
1               Mini.Skirt        4
1               Maxi.Skirt        2
1               Tank.Top          7
2               Jeans             7
...             ...               ...

where there are now five factors for the predictor "clothing" and counts of each item for "count",

and run the code for NB:

summary(NB2 <- glm.nb(Person ~ Clothing, data = d))

or run the code for Poisson:

summary(pois2 <- glm(Person ~ Clothing, family = poisson, data = d))

my Null and Residual Deviance values are the same (for both). This indicates a problem, I would think.

So, this all being said...Is there a way to do this, or am I stuck with my old standby??

Thank you!

$\endgroup$
  • $\begingroup$ Welcome. I don't think I am the guy who can answer, but for the others : How your dataset looks like is not really clear, could you edit your question by giving us some rows and tell us what the variables are. Maybe giving the exact formula you typed in R could help too. $\endgroup$ – brumar Jul 5 '15 at 7:46
  • $\begingroup$ Made edits. Let me know if it's still unclear. $\endgroup$ – BeyondApplied Jul 5 '15 at 8:40
0
$\begingroup$

[This was supposed to be a comment, but it got awfully long.]

Thanks for the edit ! This is much better ! Now I may see a part of the problem. I guessed $Person$ is the same as $Individual$. I think that in your mind, by analogy with the chi2 test, Person ~ Clothing represents the association between Individuals and Clothing. But as far as I know, it does not work like that. The response variable (at the left of the ~) is want you want to predict, what we call the response term. So in your case, you would prefer sthg along the line of Count~ Individual+Clothing. But you are looking for an interaction with Individual and Clothing, so Count~ Individual*Clothing, including all the interactions terms is more close from what you want.

But this won't work as you you will end up with too many free parameters. I think you should look at how mixed effects linear model works. This is certainly more complicated than a simple Chi squared test, but it's quite interesting. Very briefly, you may end up to study if individuals differ in their clothing by studying if there is a random effect or not at the scale at individual*clothing pick. Intuitively, one can think that it's less free parameters consuming than considering that each individual preferences must be estimated, on the contrary with a random effect model we only model a kind of random disturbance that create heterogeneity in individual preferences. If this disturbance is small enough to be rejected, there is independence, if it's a big one, there is no independance.

I don't know mixed effects models enough to get into more details (especially the specification of the random effects there), but may some more knowledgeable folks help you.

$\endgroup$
  • $\begingroup$ I actually am interested in discerning is there a difference between Person, given counts for the levels of Clothing. Thus, I am trying to predict Person, not count. In an ideal scenario, I would have more levels of IV than the number of classes of Person I am trying to predict, and a multinomial logistic regression would be my approach. $\endgroup$ – BeyondApplied Jul 5 '15 at 23:36
  • $\begingroup$ Oh. I see. I looked through multiple times your answer to get where I missed that until I check the title of your question...sorry. So let's talk about it and I ll edit my answer if I can later. 3 things I want to be sure : when you say more levels of IV, you mean more type of clothing ? Also you won't have any other IV ? Last thing : you won't have more rows by individual (like N_row will be always N_indiv*N_levels) ? If yes to three, you can't predict Person and I can more or less explain why. $\endgroup$ – brumar Jul 6 '15 at 6:32
  • $\begingroup$ I actually just found myself in another conundrum...after I adjust the counts for clothing based a separate variable (but one that is utterly non-independent from clothing counts, such as total number of articles of clothing), both at the level of individual and individual relative to total, I now end up with numerous cells having very small values...some <1. $\endgroup$ – BeyondApplied Jul 7 '15 at 8:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.