3
$\begingroup$

I am attempting to conduct a logistic regression for a tennis analytics project, endeavoring to predict the probability of a player winning a point in which he is the server. My response variable (service points) is binary in the sense that it can have only two outcomes for each observation - a success (service point win) or a failure (service point loss).

I have an issue with my data: For a given player, I have the point by point data for hundreds of matches. So take my data for R. Nadal as an example:

250 matches, each with about 70 dependent variable observations (service points). So for each match I currently have the two variables: Total_Service_Points_Played and Total_Service_Points_Won.

Eg - Match 1: Total_Service_Points_Played: 70 ; Total_Service_Points_Won: 47

So my data isn't in 1's and 0's. Is there a way I can implement a logistic regression with my dependent variable observations in their current form? Is there any simple transformation that comes to mind?

What springs to mind for me is to flesh out my match data into 1's and 0's. So following on from Match 1 above I would have: 47 1's followed by 26 0's . My data doesn't provide information as to what sequence these 1's and 0's arrived in, but since the depdendent variable observations are i.i.d this won't cause an issue? Correct me if I'm wrong please. Another issue posed by this technique would be the massive increase in my data - from 250 observations as a ratio (service point wins/service points played) to 250*70=17500 observations or more.

As a side note, the last thing I'm wondering is about the dispersion of my dependent variable data. Specifically, in the ratio of serve wins to total serve points as above, there exists no values < 0.2 or 20% .... In addition, there exists no value > 0.9 ..... Does this fit the bill for the (link=logit) argument? I know this relates to an S shape curve which is undefined at 0 and 1, but approaches both values.... I might be going off track here but is this something to be concerned about?

$\endgroup$
  • 1
    $\begingroup$ What are your explanatory variables ? $\endgroup$ – user83346 Jul 31 '15 at 11:00
  • 3
    $\begingroup$ Look about r glm function. It tells that response can be two column matrix with columns having counts of successes and failures. $\endgroup$ – Analyst Jul 31 '15 at 11:03
  • $\begingroup$ @fcoppens my explanatory variables are : court surface (categorical with 3 types) and the log of opposition world ranking points. Any ideas? $\endgroup$ – Stevie Kvothe Jul 31 '15 at 11:09
9
$\begingroup$

If you're fitting with glm, you can use the win rate as your DV and use the weights option to specify the number of "trials" each rate observation is based on. From ?glm:

For a binomial GLM prior weights are used to give the number of trials when the response is the proportion of successes

So your call to glm would look something like this:

glm(Total_Service_Points_Won/Total_Service_Points_Played ~ ... ,
    family = binomial(link=logit), weights = Total_Service_Points_Played)
$\endgroup$
  • 1
    $\begingroup$ Thanks. That works out nicely and the code supplied saved me a lot of time. As a side note, the last thing I'm wondering is about the dispersion of my dependent variable data. Specifically, in the ratio of serve wins to total serve points as above, there exists no values < 0.2 or 20% .... In addition, there exists no value > 0.9 ..... Does this fit the bill for the (link=logit) argument? I know this relates to an S shape curve which is undefined at 0 and 1, but approaches both values.... I might be going off track here but is this something to be concerned about? $\endgroup$ – Stevie Kvothe Jul 31 '15 at 13:36
  • $\begingroup$ Stevie: no, there's no problem. If you had a wider range of variation of mean of response you could get more accuracy in estimates, but it's not a problem at all $\endgroup$ – Glen_b Jul 31 '15 at 17:33
4
$\begingroup$

Provided your predictors are constant during a match, it shouldn't matter. Suppose you are applying a generalized linear model of the form $\exp(\eta y - \psi(\eta))$ to some grouped responses, $y_{11},\ldots,y_{1n_1},\ldots,y_{N1},\ldots,y_{Nn_N}$. Here there are $N$ groups (250 matches in your case) with $n_i$ observations (about 70 in your case) in the $ith$ group, and $\eta()$ is (in your case) the logistic function. The likelihood is then

$\Pi_{i=1}^N\Pi_{j=1}^{n_i} \exp(\eta_i y_{ij} - \psi(\eta_i))= \Pi_{i=1}^N \exp(\Sigma_{j=1}^{n_i}\eta_i y_{ij}-n_i\psi(\eta_i)) = \Pi_{i=1}^N \exp(n_i(\eta_i y_{i.}-\psi(\eta_i))).$

The last equation is just the likelihood of an exponential family with sufficient statistic $y_{i.}=\Sigma y_{ij}/n_i$ (the group match averages in your case). You can optimize the likelihood using this grouped statistic as well. So the likelihood equation is the same whether you use the group averages or any sequence of 0s, 1s that give the same group averages. In particular, the same coefficient vector $\beta$ under a regression model $\eta_i=x_i^T\beta$ maximizes the likelihood, if your predictors $x_i$ are fixed at the block (match) level.

$\endgroup$
4
$\begingroup$

There exists a logistic regression for binary data, but also one for grouped data. In the former case the likelihood function is a product of Bernouilli probabilities and in the latter case a product of Binomial probabilities (see, e.g., in this pdf). As @Analist has indicated in a comment, both types are implemented in R, in the glm function.

You should create a data frame with columns nbr.success, nbr.failure and the explanatory variables surface and ranking and then use the formula, cbind(nbr.success, nbr.failure) ~ surface + ranking + 1, in the glm function.

$\endgroup$
  • $\begingroup$ You describe using GLM with a two column matrix or data.frame containing nbr.successes and nbr.failures. Analyst describes using the ratio of successes to total number of trials and a weights argument in the GLM call. Is there a difference between the result of these methods? Or an advantage of one over the other? Also, is the +1 in the model formula representing an intercept? If so, I was under the impression R added an intercept by default? Thanks for your response f copppens, really appreciate it $\endgroup$ – Stevie Kvothe Jul 31 '15 at 13:41
  • 1
    $\begingroup$ @Stevie Kvothe: if you ask for help on glm in R, it says in the details section: "For binomial and quasibinomial families the response can also be specified as a factor (when the first level denotes failure and all others success) or as a two-column matrix with the columns giving the numbers of successes and failures", I did not try it but there is is said that it should be numbers of successes and numbers of failures. It could be that R adds the constant by default, I personally find like to write is explicitly. $\endgroup$ – user83346 Jul 31 '15 at 15:06
  • $\begingroup$ @f coppens thanks a lot i'm on the right track now! $\endgroup$ – Stevie Kvothe Aug 1 '15 at 20:03
  • $\begingroup$ @Stevie Kvothe: don't thank me, just vote for the answers that you like and if there is an answer that you prefer you can always vote it as your 'best answer' $\endgroup$ – user83346 Aug 14 '15 at 18:28

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.