# Measuring effects of categorical factors on binomial outcome with many groups

I'd like to do some analysis of shooting efficiency in basketball when a team is leading (AHEAD) or trailing (BEHIND) by less than 8 points and whether they are HOME or AWAY. Here are a few examples of the data:

Ray Allen   HOME    BEHIND  59.4%   134
Ray Allen   HOME    AHEAD   57.13%  132
Ray Allen   AWAY    BEHIND  49.1%   166
Ray Allen   AWAY    AHEAD   48.03%  126
Jason Terry AWAY    BEHIND  56.6%   242
Jason Terry HOME    BEHIND  52.0%   193
Jason Terry AWAY    AHEAD   50.05%  198
Jason Terry HOME    AHEAD   48.73%  207
Jamal Crawford  AWAY    AHEAD   51.65%  82
Jamal Crawford  HOME    AHEAD   42.50%  178
Jamal Crawford  AWAY    BEHIND  35.5%   129
Jamal Crawford  HOME    BEHIND  33.4%   118
Kevin Durant    HOME    BEHIND  48.6%   222
Kevin Durant    HOME    AHEAD   44.05%  248
Kevin Durant    AWAY    BEHIND  41.4%   325
Kevin Durant    AWAY    AHEAD   40.07%  213


The 4th column is the FG% (i.e. proportion of made shots) and the 5th column is the number of shots (i.e. trials).

You can see even with these 4 players (and there are roughly 200 in the data set), that there is variation of the mean FG% between players, and for each player, there is not a consistent pattern in whether they are "better" at HOME or AWAY or AHEAD or BEHIND. So there's a lot of variance between groups and within groups as far as I can tell.

I thought about using lmer, but I wasn't sure how to do that for this problem, because if I just use the FG% as the outcome, I lose the information about how many shots were taken. Eventually, I'd like to put this into BUGS, but I thought there might be a more straightforward way for now, because I'm not quite ready for that yet.

I should just add that what I'm really after is a way to determine whether a player is "really" better under one of these conditions, or are the apparent differences just due to noise/variation from small sample sizes.

-
This question seems to call for a binomial model. E.g., putting the data in a data.frame with variables Name, Home, Ahead, Percent, and N, to get started (with a simple linear model, no interactions) you would account for the number of shot attempts by executing data$K <- floor(data$Percent * data$N / 100 + 0.5); data$L <- data$N - data$K; fit <- glm(cbind(K,L) ~ Name + Home + Ahead, data=data, family=binomial()); summary(fit). Is there some reason you haven't done this? –  whuber Aug 30 '12 at 15:35
@whuber, I didn't know you could put the response in that form. Let me see if this works. I would also like to have interaction terms. –  thecity2 Aug 30 '12 at 15:52
Put interactions in in the usual way. But start out without them to get a baseline. –  whuber Aug 30 '12 at 15:59
Well, I just ran this model w/o interactions, and it came back with only 3 players having a p-val<0.05. This doesn't really help me. –  thecity2 Aug 30 '12 at 16:05
How not, Evan? That sounds like a useful result to me. It's telling you there are few detectable differences among players after you factor in the other variables. However, such a result might not be credible in light of obvious differences in basketball performance. In fact, I found significant player differences even in the small subset you posted. It sounds like you should experiment on a smaller dataset and make sure you're applying and interpreting the procedures correctly by exploring the data extensively and producing diagnostics for the procedures. –  whuber Aug 30 '12 at 16:09