1
$\begingroup$

First off, here is my calculation for the confidence intervals:

BPLpredictions["upr"] = BPLpredictions$fit + (z * BPLpredictions$se.fit)
BPLpredictions["lwr"] = BPLpredictions$fit - (z * BPLpredictions$se.fit)

After calculating the running total for all of my predictions, I end up with the following data frame:

> BPLSeason
        upr       lwr       fit Running fit Running lwr Running upr
1  1.046068 0.6191719 0.8326201   0.8326201   0.6191719    1.046068
2  1.066816 0.6655935 0.8662049   1.6988250   1.2847654    2.112885
3  1.088620 0.7136692 0.9011444   2.5999694   1.9984346    3.201504
4  1.167051 0.8622466 1.0146486   3.6146180   2.8606811    4.368555
5  1.112002 0.7629848 0.9374932   4.5521112   3.6236659    5.480557
6  1.112002 0.7629848 0.9374932   5.4896044   4.3866506    6.592558
7  1.088620 0.7136692 0.9011444   6.3907488   5.1003198    7.681178
8  1.242889 0.9534183 1.0981538   7.4889026   6.0537381    8.924067
9  1.201472 0.9096795 1.0555757   8.5444783   6.9634176   10.125539
10 1.201472 0.9096795 1.0555757   9.6000541   7.8730970   11.327011
11 1.292990 0.9919085 1.1424492  10.7425033   8.8650055   12.620001
12 1.201472 0.9096795 1.0555757  11.7980790   9.7746850   13.821473
13 1.242889 0.9534183 1.0981538  12.8962328  10.7281032   15.064362
14 1.242889 0.9534183 1.0981538  13.9943865  11.6815215   16.307252
15 1.292990 0.9919085 1.1424492  15.1368357  12.6734300   17.600241
16 1.292990 0.9919085 1.1424492  16.2792849  13.6653384   18.893231
17 1.352706 1.0243564 1.1885314  17.4678163  14.6896948   20.245938
18 1.292990 0.9919085 1.1424492  18.6102655  15.6816033   21.538928
19 1.352706 1.0243564 1.1885314  19.7987969  16.7059597   22.891634
20 1.422037 1.0509079 1.2364723  21.0352693  17.7568676   24.313671

So you understand the context of this data frame, fit is the predicted number of goals in a specific game and upr and lwr and the upper and lower bounds of the 95% CI.

The three additional columns are essentially the running total for each. This may be a dumb question but is it ok for me to calculate the running total for the upr and lwr bounds or should I, for example, use upr[20] - fit[20] and add that to running fit[20]

Sorry if this is trivial. I'm brand new to R and Stats.

[Additional Information]

The following negative binomial regression model was used:

mod 1 = glm.nb(Goals ~ Defense, data = Messi.Liga)

Here is the summary of the model:

Coefficients:
 Estimate Std. Error z value Pr(>|z|) 
(Intercept) 3.05943 1.11817 2.736 0.00622 **
Defense -0.03954 0.01498 -2.639 0.00831 **

This command was used to predict BPL values:

BPLpredictions = data.frame(predict(mod1, bpl.df, type = "response", se.fit = TRUE))

And finally, this is how I calculated the CI (z = 1.96):

BPLpredictions["upr"] = BPLpredictions$fit + (z * BPLpredictions$se.fit)
BPLpredictions["lwr"] = BPLpredictions$fit - (z * BPLpredictions$se.fit)
$\endgroup$
  • $\begingroup$ can an you give the context of your point estimates? PS: in the R there exist a command cumsum (stat.ethz.ch/R-manual/R-devel/library/base/html/cumsum.html) so, I assume that in the R-community "cumulative sum" is a bit more intuitive than "running total". $\endgroup$ – Qaswed Aug 16 '16 at 8:22
  • $\begingroup$ Software-specific questions are off-topic here. Please see advice in the Help Center. stats.stackexchange.com/help/on-topic $\endgroup$ – Nick Cox Aug 16 '16 at 10:16
  • $\begingroup$ @NickCox, I don't see it as a software-specific question (if I think about, I even would suggest to remove the r-tag). I see the main question to be if it makes sense to get confidence intervalls by summing up other confidence intervalls. $\endgroup$ – Qaswed Aug 16 '16 at 11:24
  • $\begingroup$ @Qaswed If you are right, and there is a statistical question here, then it should in my view be rewritten removing the dependency on R code. I don't think it's at all clear in any case, so there are multiple grounds for closing and requesting a rewrite. If there is an underlying issue of whether successive games are independent, that should all be spelled out. $\endgroup$ – Nick Cox Aug 16 '16 at 11:55
  • $\begingroup$ For a start, nothing is said about where the predictions come from and what were the assumptions in fitting. $\endgroup$ – Nick Cox Aug 16 '16 at 12:04
1
$\begingroup$

If you assume your point estimates as normally distributed (what I think you do, as you say $z = 1.96$) and INDEPENDENT (!), you can calculate a running total.

For two indipendent random normally distributed variables $fit_i \sim N(\mu_i,~ \sigma_i^2)$ and $fit_j \sim N(\mu_j,~ \sigma_j^2)$, then $fit_i + fit_j \sim N(\mu_i+ \mu_j,~ \sigma_i^2 + \sigma_j^2)$ and thus its confidence interval is $[\mu_i+ \mu_j - z \cdot (\sigma_i + \sigma_j), ~ \mu_i+ \mu_j + z \cdot (\sigma_i + \sigma_j)]$. And this is exactly the same result to calculate the confidence intervals by a running total: $[\mu_i - z \cdot \sigma_i + \mu_j - z \cdot \sigma_j, ~\mu_i + z \cdot \sigma_i + \mu_j + z \cdot \sigma_j]$.

$\endgroup$

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