#1 · Dvd Avins
25 Jan 2012
This is somewhat off topic but the community here seems an excellent place to ask, for both interest and ability.
I am modeling a real-world situation. I'll say what it is later, but in case anyone wants consider the problem in the abstract, I won't put that at the top of the post. Peek and come back to the beginning, if you want. It's just after the first separating line.
In most general terms, I am attempting to find the least-squares solution for a set of data and model. The model does *not* have the common form where, aside from the residual, the result is expected to be the sum of the conditions and there unknown coefficients..I do not know if there are publicly available utilities that will find least-square solutions for models that do not follow the common linear form.
I have a multinomial and a theoretical model in which the ratios of probabilities P(1): P(2),...,P(n) in the multinomial is the product of the ratios of functions of several other, unknown ratios. In speaking of the products of ratios, I do not mean the dot product or cross product of the vectors, merely the simpler product of the 1st member of each vector compared to the product of the second on each, etc. When any vector's ratios are normalized to represent probabilities, there are only n - 1 independent members because all the members together sum to 1. In the application I'm working on, n is 5 in one class of situations and 4 in the other.
Let's start with a simplified version, where for each possible experimental condition, I have an identical sample size and where the relationship between what I'll call Factor 4 on the one hand and Factors 2 and 3 on the other never varies from its usual simplicity.
Factor 1 is a known constant vector. (It is known because the reported data is taken to be taken to be a full reporting of a population, rather than a sampling. (When I imprecisely refer to a sample, that's only because I'm in the habit of doing so where a larger data-set would yield better estimates of unknowns.) It is at least in part because the data represents a full population that some functions mentioned below are more complicated when we take the real-word case where different rows of data have different sample sizes.
Factors 2, 3, and 4 each have some number m possible values where m may be assumed to be between 8 and 30.each possible value of each factor has an associated vector.
For each sampling condition, value only one of Factors 2 and 3 are known. Except that if the known factor has value K, the unknown factor does not have value K and is assumed to be equally likely to have any other value. That means that for Factor 2 = K and therefore Factor 3!= K, there is an implicit vector that is a function of the vector where Factor 3 does equal K and of sample data that may be applied tot he expected results.
Let P(u) represent the uth element of a vector and recall that there are m possible values for Factors 2, 3, and 4. In this simple (for some value of "simple") example where all conditions have the same sample size, the uth element of the un-normalized vector where value(Factor 3) != K = (m - P(u)) / (n - 1) where Factor 3 = K. That computation is done for each outcome and then each outcome is divided by the sum of those results to get the implicit probability vector where Factor 3 != K.
Where is it Factor 3 whose value is known, the procedure described above is applied to Factor 2.
Factor 4 is either of the same value as the known value in Factors 2 and 3, or it is of the same unknown value as in the other of Factors 2 and 3. In the latter case, the same procedure as described for the unknown of Factors 2 and 3 is applied to Factor 4.
Factor 5 has only two possible conditions and the vector of the second condition is a function of the vector of the first. If the condition of Factor 4 is the condition of Factor 2, we have the first condition of Factor 5. When the condition of Factor 4 is the condition of Factor 3, the other condition of Factor 5 is in effect. In this simple case where all conditions are equally likely, the values in an un-normalized vector for the second condition are the reciprocals of the values for the first condition.
I don't believe this matters except to give an appearance of greater confidence in the results, but each real-world trail is represented twice in the data-set: once where Factor 2 is known and once where Factor 3 is.
Each row in the data-set will generate n rows in a least-squares calculation, one for each possible outcome of the multinomial. For each of the m fundamental possible values of Factors 2, 3, and 4, I will have four rows in my data-set: a 2 x 2 matrix where the dimensions represent whether it is Factor 2 or Factor 3 that is known and whether or not Factor 4 is known. Thus I have 4 * m * n residuals, the sum of whose squares I need to minimize.
Each unknown vector has n - 1 independent variables. Each value of factors 2, 3, and 4 have m possible conditions and therefore m vectors containing m * (n - 1) variables. Factor 5 has one independent vector, so the total number of variables is (m + 1) * (n - 1).
I don't think it matters, but Factors 2 and 3 are nuisance factors. Having obtained them, they may be of small interest, but the purpose of this exercise is to determine the effects of factor 5 and especially Factor 4. If there are computational shortcuts that would mask Factors 2 and 3, that would be OK, but I don't think such shortcuts exist.
\_\_\_______________________________________________________
This model attempts to determine the effects of ballparks on hitting statistics for a given year, league, and batter-handedness. It does so without recourse to individual player data, but has aggregate team data (both for the team and the batting statistics of it's opponents in the same games) broken out by hand (which creates a distinct population) and by whether the game is played at home or on the road.
The model will be applied at least twice for each population. The first (and less necessary) time is to separate all Plate Appearances that do not result in in Sacrifice Hits, Intentional Bases on Balls, or the batter reaching base doe to Interference or Obstruction into probabilities of Hit By Pitch, unintentional Bases on Balls, Strikeouts, and those Plate Appearances ended by the batter making contact. The last case (contact) is then taken as the entirety smaller population, which is distributed among Singles, Doubles, Triples, Home Runs, and those Plate Appearances in which the fielders are expected to retire the batter or a forced runner, regardless of whether the actual play resulted in an out or the batter reaching base as the result of an error.
Factor 1 represents the league average distribution. Factor 2 represents the team at bat. Factor 3 represents the team in the field. Factor 4 represents the park in which the game is played. factor 5 accounts for home-field advantage.
\_\_\_______________________________________________
To apply this model to real statistics, I will need to account for differing 'sample sizes' for different conditions. For some years, I will also need to account for teams having more than one home park and for teams sharing a home park. In the last case, a team's 'away' games in its own park are not distinguished in the given data from its other way games.
There is one more complexity that I hesitate to mention and I'm willing to overlook. I believe the model above would give better results than those currently in use and is computationally soluble. There is a similar model that I think is fundamentally more sound and would give yet better results, but I fear it is not practically soluble. In the latter model, each factor has an exponent that is unknown and constant across all conditions of the factor and across all outcomes of the multinomial. The exponent of Factor 1 is 1. Any difference in the exponent of Factor 2 and factor 3 would be of great interest (both to my business and to the baseball analytic community) apart from any value in determining park factors.
I need this primarily as background to a game I'm developing, but I am also likely to report results to The Society For Baseball Research's (SABR's) analytic community and would be happy to share credit. I say share rather than give all, because the thought that went into determining and explaining the model has already been extensive.