idx
int64 1
56k
| question
stringlengths 15
155
| answer
stringlengths 2
29.2k
⌀ | question_cut
stringlengths 15
100
| answer_cut
stringlengths 2
200
⌀ | conversation
stringlengths 47
29.3k
| conversation_cut
stringlengths 47
301
|
|---|---|---|---|---|---|---|
44,901
|
Intuition for the standard error of the difference of sample means
|
You seem to be thinking that $\sqrt{\text{Var}(\bar X-\bar Y)} = \sqrt{\text{Var}(\bar X)} + \sqrt{\text{Var}(\bar Y)}$.
This is not the case for independent variables.
For $X,Y$ independent, $\text{Var}(\bar X-\bar Y) = \text{Var}(\bar X) + \text{Var}(\bar Y)$
Further,
$\text{Var}(\bar X) = \text{Var}(\frac{1}{n}\sum_iX_i) = \frac{1}{n^2}\text{Var}(\sum_iX_i)= \frac{1}{n^2}\sum_i\text{Var}(X_i)= \frac{1}{n^2}\cdot n\cdot\sigma^2_1= \sigma^2_1/n$
(if the $X_i$ are independent of each other).
http://en.wikipedia.org/wiki/Variance#Basic_properties
In summary: the correct term:
$\color{red}{(1)}$ has $\sigma^2/n$ terms because we're looking at averages and that's the variance of an average of independent random variables;
$\color{red}{(2)}$ has a $+$ because the two samples are independent, so their variances (of the averages) add; and
$\color{red}{(3)}$ has a square root because we want the standard deviation of the distribution of the difference in sample means (the standard error of the difference in means). The part under the bar of the square root is the variance of the difference (the square of the standard error). Taking square roots of squared standard errors gives us standard errors.
The reason why we don't just add standard errors is standard errors don't add - the standard error of the difference in means is NOT the sum of the standard errors of the sample means for independent samples - the sum will always be too large. The variances do add, though, so we can use that to work out the standard errors.
Here's some intuition about why it's not standard deviations that add, rather than variances.
To make things a little simpler, just consider adding random variables.
If $Z = X+Y$, why is $\sigma_Z < \sigma_X+\sigma_Y$?
Imagine $Y = kX$ (for $k\neq 0$); that is, $X$ and $Y$ are perfectly linearly dependent. That is, they always 'move together' in the same direction and in proportion.
Then $Z = (k+1)X$ - which is simply a rescaling. Clearly $\sigma_Z = (k+1)\sigma_X = \sigma_X+\sigma_Y$.
That is, when $X$ and $Y$ are perfectly positively linearly dependent, always moving up or down together, standard deviations add.
When they don't always move up or down together, sometimes they move opposite directions. That means that their movements partly 'cancel out', yielding a smaller standard deviation than the direct sum.
|
Intuition for the standard error of the difference of sample means
|
You seem to be thinking that $\sqrt{\text{Var}(\bar X-\bar Y)} = \sqrt{\text{Var}(\bar X)} + \sqrt{\text{Var}(\bar Y)}$.
This is not the case for independent variables.
For $X,Y$ independent, $\text{
|
Intuition for the standard error of the difference of sample means
You seem to be thinking that $\sqrt{\text{Var}(\bar X-\bar Y)} = \sqrt{\text{Var}(\bar X)} + \sqrt{\text{Var}(\bar Y)}$.
This is not the case for independent variables.
For $X,Y$ independent, $\text{Var}(\bar X-\bar Y) = \text{Var}(\bar X) + \text{Var}(\bar Y)$
Further,
$\text{Var}(\bar X) = \text{Var}(\frac{1}{n}\sum_iX_i) = \frac{1}{n^2}\text{Var}(\sum_iX_i)= \frac{1}{n^2}\sum_i\text{Var}(X_i)= \frac{1}{n^2}\cdot n\cdot\sigma^2_1= \sigma^2_1/n$
(if the $X_i$ are independent of each other).
http://en.wikipedia.org/wiki/Variance#Basic_properties
In summary: the correct term:
$\color{red}{(1)}$ has $\sigma^2/n$ terms because we're looking at averages and that's the variance of an average of independent random variables;
$\color{red}{(2)}$ has a $+$ because the two samples are independent, so their variances (of the averages) add; and
$\color{red}{(3)}$ has a square root because we want the standard deviation of the distribution of the difference in sample means (the standard error of the difference in means). The part under the bar of the square root is the variance of the difference (the square of the standard error). Taking square roots of squared standard errors gives us standard errors.
The reason why we don't just add standard errors is standard errors don't add - the standard error of the difference in means is NOT the sum of the standard errors of the sample means for independent samples - the sum will always be too large. The variances do add, though, so we can use that to work out the standard errors.
Here's some intuition about why it's not standard deviations that add, rather than variances.
To make things a little simpler, just consider adding random variables.
If $Z = X+Y$, why is $\sigma_Z < \sigma_X+\sigma_Y$?
Imagine $Y = kX$ (for $k\neq 0$); that is, $X$ and $Y$ are perfectly linearly dependent. That is, they always 'move together' in the same direction and in proportion.
Then $Z = (k+1)X$ - which is simply a rescaling. Clearly $\sigma_Z = (k+1)\sigma_X = \sigma_X+\sigma_Y$.
That is, when $X$ and $Y$ are perfectly positively linearly dependent, always moving up or down together, standard deviations add.
When they don't always move up or down together, sometimes they move opposite directions. That means that their movements partly 'cancel out', yielding a smaller standard deviation than the direct sum.
|
Intuition for the standard error of the difference of sample means
You seem to be thinking that $\sqrt{\text{Var}(\bar X-\bar Y)} = \sqrt{\text{Var}(\bar X)} + \sqrt{\text{Var}(\bar Y)}$.
This is not the case for independent variables.
For $X,Y$ independent, $\text{
|
44,902
|
Intuition for the standard error of the difference of sample means
|
Algebraic intuition
The standard error of the mean for $n$ independent observations is $\frac{\sigma}{\sqrt{n}}$ where $\sigma$ is the standard deviation.
So if we have two independent samples we have the standard errors for the means of group 1 and group 2.
$$\sigma_{\mu_1}=\frac{\sigma_1}{\sqrt{n_1}}$$
$$\sigma_{\mu_2}=\frac{\sigma_2}{\sqrt{n_2}}$$
If we square these values we get the variance of the mean:
$$\sigma^2_{\mu_1}=\frac{\sigma^2_1}{n_1}$$
$$\sigma^2_{\mu_2}=\frac{\sigma^2_2}{n_2}$$
The variance of the sum or difference of two independent random variables
is the sum of the two variances. Thus,
$$\sigma^2_{\mu_1 - \mu_2} =\sigma^2_{\mu_1} + \sigma^2_{\mu_2} = \frac{\sigma^2_1}{n_1} + \frac{\sigma^2_2}{n_2} $$
So if we want the standard error of the difference we take the square root of the variance:
$$\sigma_{\mu_1 - \mu_2} =\sqrt{\sigma^2_{\mu_1} + \sigma^2_{\mu_2}} = \sqrt{\frac{\sigma^2_1}{n_1} + \frac{\sigma^2_2}{n_2}} $$
So I imagine this is intuitive if the component steps are intuitive. In particular it helps if you find intuitive the idea that the variance of the sum of independent variables is the sum of the variances of the component variables.
Fuzzy Intuition
In terms of more general intuition, if $n_1 = n_2$ and $\sigma=\sigma_1=\sigma_2$ then the standard error of the difference between means will be $\sqrt{2}\sigma_\mu\approx 1.4\times \sigma_\mu$. It makes sense that this value of approximately 1.4 is greater than 1 (i.e., the variance of a variable after adding a constant; i.e., equivalent to one sample t-test) and less than 2 (i.e., the standard deviation of the sum of two perfectly correlated variables (with equal variance) and the standard error implied by the formula you mention: $\frac{\sigma_1}{\sqrt{n_1}} + \frac{\sigma_2}{\sqrt{n_2}}$).
|
Intuition for the standard error of the difference of sample means
|
Algebraic intuition
The standard error of the mean for $n$ independent observations is $\frac{\sigma}{\sqrt{n}}$ where $\sigma$ is the standard deviation.
So if we have two independent samples we have
|
Intuition for the standard error of the difference of sample means
Algebraic intuition
The standard error of the mean for $n$ independent observations is $\frac{\sigma}{\sqrt{n}}$ where $\sigma$ is the standard deviation.
So if we have two independent samples we have the standard errors for the means of group 1 and group 2.
$$\sigma_{\mu_1}=\frac{\sigma_1}{\sqrt{n_1}}$$
$$\sigma_{\mu_2}=\frac{\sigma_2}{\sqrt{n_2}}$$
If we square these values we get the variance of the mean:
$$\sigma^2_{\mu_1}=\frac{\sigma^2_1}{n_1}$$
$$\sigma^2_{\mu_2}=\frac{\sigma^2_2}{n_2}$$
The variance of the sum or difference of two independent random variables
is the sum of the two variances. Thus,
$$\sigma^2_{\mu_1 - \mu_2} =\sigma^2_{\mu_1} + \sigma^2_{\mu_2} = \frac{\sigma^2_1}{n_1} + \frac{\sigma^2_2}{n_2} $$
So if we want the standard error of the difference we take the square root of the variance:
$$\sigma_{\mu_1 - \mu_2} =\sqrt{\sigma^2_{\mu_1} + \sigma^2_{\mu_2}} = \sqrt{\frac{\sigma^2_1}{n_1} + \frac{\sigma^2_2}{n_2}} $$
So I imagine this is intuitive if the component steps are intuitive. In particular it helps if you find intuitive the idea that the variance of the sum of independent variables is the sum of the variances of the component variables.
Fuzzy Intuition
In terms of more general intuition, if $n_1 = n_2$ and $\sigma=\sigma_1=\sigma_2$ then the standard error of the difference between means will be $\sqrt{2}\sigma_\mu\approx 1.4\times \sigma_\mu$. It makes sense that this value of approximately 1.4 is greater than 1 (i.e., the variance of a variable after adding a constant; i.e., equivalent to one sample t-test) and less than 2 (i.e., the standard deviation of the sum of two perfectly correlated variables (with equal variance) and the standard error implied by the formula you mention: $\frac{\sigma_1}{\sqrt{n_1}} + \frac{\sigma_2}{\sqrt{n_2}}$).
|
Intuition for the standard error of the difference of sample means
Algebraic intuition
The standard error of the mean for $n$ independent observations is $\frac{\sigma}{\sqrt{n}}$ where $\sigma$ is the standard deviation.
So if we have two independent samples we have
|
44,903
|
Intuition for the standard error of the difference of sample means
|
You don't square the sum of the variances, you take the square root of the sum of the variances. You do this for the same reason that the standard deviation is the square root of the variance: It make the units the same as the original ones, rather than squared units.
Although we often lose sight of it while doing statistics, the square of a measure involve squaring the measure as well as the number of units. For example, the square of 2 meters is not 4 meters, it is 4 meters squared, more commonly called 4 square meters. The same thing happens with other units that we aren't used to thinking of in this way: e.g. if you are measuring IQ, the square of an IQ is not an IQ of 10,000; it is a squared IQ of 10,000.
You divide by the sample size as a scaling technique. Variances (tend to) go up with sample size; you divide by $n$ to deal with that.
|
Intuition for the standard error of the difference of sample means
|
You don't square the sum of the variances, you take the square root of the sum of the variances. You do this for the same reason that the standard deviation is the square root of the variance: It make
|
Intuition for the standard error of the difference of sample means
You don't square the sum of the variances, you take the square root of the sum of the variances. You do this for the same reason that the standard deviation is the square root of the variance: It make the units the same as the original ones, rather than squared units.
Although we often lose sight of it while doing statistics, the square of a measure involve squaring the measure as well as the number of units. For example, the square of 2 meters is not 4 meters, it is 4 meters squared, more commonly called 4 square meters. The same thing happens with other units that we aren't used to thinking of in this way: e.g. if you are measuring IQ, the square of an IQ is not an IQ of 10,000; it is a squared IQ of 10,000.
You divide by the sample size as a scaling technique. Variances (tend to) go up with sample size; you divide by $n$ to deal with that.
|
Intuition for the standard error of the difference of sample means
You don't square the sum of the variances, you take the square root of the sum of the variances. You do this for the same reason that the standard deviation is the square root of the variance: It make
|
44,904
|
does rstandard standardize in z?
|
rstandard() produces standardised residuals via normalisation to unit variance using the overall error variance of the residuals/model.
rstudent() produces Studentized residuals in the same way, but it uses a leave-one-out estimate of the error variance.
The key line in rstandard() is
res <- infl$wt.res/(sd * sqrt(1 - infl$hat))
where sd is defined as
sqrt(deviance(model)/df.residual(model))
where model is the object returned by lm. But note this is not the same as sd(resid(model))
Note that the sd is also scaled by the hat values $1 - h_{ii}$ which together explain the discrepancy with your values.
The key line in rstudent() is
res <- res/(infl$sigma * sqrt(1 - infl$hat))
which is almost the same but sd is replaced via the leave-one-out estimate of the error variance (sd) infl$sigma
|
does rstandard standardize in z?
|
rstandard() produces standardised residuals via normalisation to unit variance using the overall error variance of the residuals/model.
rstudent() produces Studentized residuals in the same way, but i
|
does rstandard standardize in z?
rstandard() produces standardised residuals via normalisation to unit variance using the overall error variance of the residuals/model.
rstudent() produces Studentized residuals in the same way, but it uses a leave-one-out estimate of the error variance.
The key line in rstandard() is
res <- infl$wt.res/(sd * sqrt(1 - infl$hat))
where sd is defined as
sqrt(deviance(model)/df.residual(model))
where model is the object returned by lm. But note this is not the same as sd(resid(model))
Note that the sd is also scaled by the hat values $1 - h_{ii}$ which together explain the discrepancy with your values.
The key line in rstudent() is
res <- res/(infl$sigma * sqrt(1 - infl$hat))
which is almost the same but sd is replaced via the leave-one-out estimate of the error variance (sd) infl$sigma
|
does rstandard standardize in z?
rstandard() produces standardised residuals via normalisation to unit variance using the overall error variance of the residuals/model.
rstudent() produces Studentized residuals in the same way, but i
|
44,905
|
does rstandard standardize in z?
|
The two functions do different things, as I understand it.
residuals(model) gives the response minus the fitted values. (from help for lm)
rstandard(model) is part of leave one out influence diagnostics (from help for rstandard), which says:
This suite of functions can be used to compute some of the regression
(leave-one-out deletion) diagnostics for linear and generalized linear
models discussed in Belsley, Kuh and Welsch (1980), Cook and Weisberg
(1982), etc.
You can examine exactly what rstandard does by looking at the code. For lm, you can do this with
> methods(rstandard)
> getAnywhere(rstandard.lm)
.
|
does rstandard standardize in z?
|
The two functions do different things, as I understand it.
residuals(model) gives the response minus the fitted values. (from help for lm)
rstandard(model) is part of leave one out influence diagnosti
|
does rstandard standardize in z?
The two functions do different things, as I understand it.
residuals(model) gives the response minus the fitted values. (from help for lm)
rstandard(model) is part of leave one out influence diagnostics (from help for rstandard), which says:
This suite of functions can be used to compute some of the regression
(leave-one-out deletion) diagnostics for linear and generalized linear
models discussed in Belsley, Kuh and Welsch (1980), Cook and Weisberg
(1982), etc.
You can examine exactly what rstandard does by looking at the code. For lm, you can do this with
> methods(rstandard)
> getAnywhere(rstandard.lm)
.
|
does rstandard standardize in z?
The two functions do different things, as I understand it.
residuals(model) gives the response minus the fitted values. (from help for lm)
rstandard(model) is part of leave one out influence diagnosti
|
44,906
|
What is the current 'standard' for modern statistical computing hardware?
|
It's a little tough to provide specific recommendations, particularly without knowing too much about your budget and goals. However:
A lot of data analysis can now be done on...nearly anything. If you plan on doing a lot of $t$-tests, ANOVAs, or regression modeling, I think you would be hard-pressed to find a system that was too slow, even with relatively large data sets (tens of thousands of observations).
However, some techniques are considerably more power-hungry. Bootstrapping or other permutation/resampling tests require a fair bit of math, as do things like MCMC. Tuning and evaluating machine learning approaches can also eat as many cycles as you care to throw at it, particularly if you're being careful (e.g., nested cross-validations for finding hyperparameters).
In most cases, having a high-end computer won't make previously intractable problems tractable, but being able to adjust some code and see the results sooner, rather than later, will make a big difference to your productivity/quality of life.
Disk space has rarely been an issue for me, so I would suggest focusing your money on RAM and CPU.
More and faster RAM is always better, obviously, and it's a big win if all of your data and intermediate computations fit into memory (and even better if they fit into the processor's cache). You could try to calculate your RAM needs, but I've noticed that RAM prices tend to have an "elbow" where they go non-linear: 1 GB is twice the price of 2 GB, which is twice the price of 4 GB...but 64 GB is much more expensive than 2x32 GB. Plus, RAM is fairly cheap and easy to upgrade, particularly if you have some extra slots on the motherboard, so I'd buy just before the elbow.
CPUs vary in terms of speed, cache, and number of cores. More is better here too, obviously. Speed and cache size don't take any skill to exploit, but your ability to get a lot out of a large number of cores depends on your programming abilities and the type of analysis. Matlab and Revolution R make it easier to parallelize parallelizable computations, but that will largely be your responsibility if you are working in C.
In a similar vein, computing on GPUs has become increasingly popular, since (some) GPUs can be blazingly fast if you're doing some massively parallel computation. If you go this route, picking out a GPU has all the same hassles as selecting a CPU (# of cores, speed, amount of ram). However, there are several competing standards (OpenGL or CUDA, mainly). If you/your libraries use CUDA, then you need to get an NVIDIA card; there are more options for OpenCL. As a practical note, since high-end graphics cards are a little atypical for normal office use, you should give your IT or purchasing department a heads-up so they don't think you are trying to build a gaming rig on the company dime (seriously!). Also, be aware that 1) this will take some work on your part and 2) it's not a panecea--moving data on and off the GPU is dog-slow!
If your code or data lives on a network, a fast Ethernet card can be nice. I previously worked somewhere the home directories and data were all served off of a (local) fileserver, and switching from 100 Mb to gigabit Ethernet did massively reduce the amount of time I spent waiting for large data sets to load. If you go this route, you'll also need to ensure that everything between you and the fileserver is upgraded as well. If all your data is local, an SSD can provide similar speed-ups.
Finally, I'd suggest not driving yourself insane looking for the optimal machine. You can always rent time on EC2 or something if you find yourself in a bind.
|
What is the current 'standard' for modern statistical computing hardware?
|
It's a little tough to provide specific recommendations, particularly without knowing too much about your budget and goals. However:
A lot of data analysis can now be done on...nearly anything. If yo
|
What is the current 'standard' for modern statistical computing hardware?
It's a little tough to provide specific recommendations, particularly without knowing too much about your budget and goals. However:
A lot of data analysis can now be done on...nearly anything. If you plan on doing a lot of $t$-tests, ANOVAs, or regression modeling, I think you would be hard-pressed to find a system that was too slow, even with relatively large data sets (tens of thousands of observations).
However, some techniques are considerably more power-hungry. Bootstrapping or other permutation/resampling tests require a fair bit of math, as do things like MCMC. Tuning and evaluating machine learning approaches can also eat as many cycles as you care to throw at it, particularly if you're being careful (e.g., nested cross-validations for finding hyperparameters).
In most cases, having a high-end computer won't make previously intractable problems tractable, but being able to adjust some code and see the results sooner, rather than later, will make a big difference to your productivity/quality of life.
Disk space has rarely been an issue for me, so I would suggest focusing your money on RAM and CPU.
More and faster RAM is always better, obviously, and it's a big win if all of your data and intermediate computations fit into memory (and even better if they fit into the processor's cache). You could try to calculate your RAM needs, but I've noticed that RAM prices tend to have an "elbow" where they go non-linear: 1 GB is twice the price of 2 GB, which is twice the price of 4 GB...but 64 GB is much more expensive than 2x32 GB. Plus, RAM is fairly cheap and easy to upgrade, particularly if you have some extra slots on the motherboard, so I'd buy just before the elbow.
CPUs vary in terms of speed, cache, and number of cores. More is better here too, obviously. Speed and cache size don't take any skill to exploit, but your ability to get a lot out of a large number of cores depends on your programming abilities and the type of analysis. Matlab and Revolution R make it easier to parallelize parallelizable computations, but that will largely be your responsibility if you are working in C.
In a similar vein, computing on GPUs has become increasingly popular, since (some) GPUs can be blazingly fast if you're doing some massively parallel computation. If you go this route, picking out a GPU has all the same hassles as selecting a CPU (# of cores, speed, amount of ram). However, there are several competing standards (OpenGL or CUDA, mainly). If you/your libraries use CUDA, then you need to get an NVIDIA card; there are more options for OpenCL. As a practical note, since high-end graphics cards are a little atypical for normal office use, you should give your IT or purchasing department a heads-up so they don't think you are trying to build a gaming rig on the company dime (seriously!). Also, be aware that 1) this will take some work on your part and 2) it's not a panecea--moving data on and off the GPU is dog-slow!
If your code or data lives on a network, a fast Ethernet card can be nice. I previously worked somewhere the home directories and data were all served off of a (local) fileserver, and switching from 100 Mb to gigabit Ethernet did massively reduce the amount of time I spent waiting for large data sets to load. If you go this route, you'll also need to ensure that everything between you and the fileserver is upgraded as well. If all your data is local, an SSD can provide similar speed-ups.
Finally, I'd suggest not driving yourself insane looking for the optimal machine. You can always rent time on EC2 or something if you find yourself in a bind.
|
What is the current 'standard' for modern statistical computing hardware?
It's a little tough to provide specific recommendations, particularly without knowing too much about your budget and goals. However:
A lot of data analysis can now be done on...nearly anything. If yo
|
44,907
|
Multiple t-tests vs. one-way ANOVA
|
If your goal is to see which methods are better than the baseline, then method 1 is correct. If your goal is to see which methods are better than each other, then method 2 is correct. Method 2 with Dunnett's test could also be used, this makes corrections for the multiple comparisons involved. However, the question of whether you need to make these corrections is subject to debate and differing opinion. The tag "Multiple comparisons" here on Cross Validated will find lots of posts on that subject.
|
Multiple t-tests vs. one-way ANOVA
|
If your goal is to see which methods are better than the baseline, then method 1 is correct. If your goal is to see which methods are better than each other, then method 2 is correct. Method 2 with Du
|
Multiple t-tests vs. one-way ANOVA
If your goal is to see which methods are better than the baseline, then method 1 is correct. If your goal is to see which methods are better than each other, then method 2 is correct. Method 2 with Dunnett's test could also be used, this makes corrections for the multiple comparisons involved. However, the question of whether you need to make these corrections is subject to debate and differing opinion. The tag "Multiple comparisons" here on Cross Validated will find lots of posts on that subject.
|
Multiple t-tests vs. one-way ANOVA
If your goal is to see which methods are better than the baseline, then method 1 is correct. If your goal is to see which methods are better than each other, then method 2 is correct. Method 2 with Du
|
44,908
|
Multiple t-tests vs. one-way ANOVA
|
There are two problems with your first approach: Multiple testing and the interpretation of the difference between significant and non-significant.
First, when you perform several tests, you increase the overall error rate. If you set $\alpha = .05$, you will still reject the null hypothesis 5% of the time when it is actually true (i.e. when there is no difference whatsoever). However, the probability that you reject the null hypothesis at least once when performing several tests is higher because you are taking this 5% risk each time you run a test. The problem is not very acute with only three tests but it still does not make much sense to run a test if you don't care about controlling the error level.
A quick fix for this problem is to adjust the error level with the Bonferroni correction. Since it is based on a very general probability inequality, it doesn't matter what the tests are and you can always use it but you will loose power. For example, it's possible that, after applying the correction, none of your tests would be significant and you would be back to the results of your second approach. This would resolve the apparent inconsistency but would not be terribly useful. Generally speaking, the main problem with this technique is that yo are not using all the information you have and the correction is usually too conservative. That's one reason to choose an ANOVA approach when you have several groups.
The second problem is that the difference between significant and non-significant is not necessarily itself significant. If you rejected the null hypothesis that model 1 is equal to baseline but not the separate hypothesis that model 2 is different from baseline, you still haven't established that model 1 is different from model 2. Those are three different questions. Let's see how this could happen:
Now, let's imagine that the difference between baseline and model 1 is “barely” significant, say p = .04. The p-value from a test of the difference between baseline and model 2 would then be a little over the threshold, say p = .06, so not significant. Yet, at the same time, model 1 and model 2 appear very similar and the difference between the two is also obviously not significantly different from 0.
The thing is that the logic of statistical testing requires us to specify an error level but there is nothing exceptional about this threshold. We simply have a little less evidence than the score for model 2 is higher than baseline and maybe this evidence is not sufficient to rule out the null hypothesis at the specified error level. This is however not enough to conclude that it is different from model 1.
Ignoring the multiple testing issue, you could then conclude that you don't know if model 2 is in fact better or worse than baseline and you certainly don't know if it is better or worse than model 1. Intuitively, if your data indeed look like the data on the graph, I don't find this very satisfying because it means treating model 1 and model 2 differently based on evidence that is much thinner than the evidence that model 2 is in fact better than baseline. However, this type of thinking is quite different from the logic underlying statistical tests. Instead of blindly make binary decisions based on the tests, I would therefore rather look at some graphs and make a judgment call about the results.
Either way, the results you presented suggest that your models do in fact represent an improvement over the baseline but there is no way you can conclude that model 1 is better than model 2. This is also pretty much what you can conclude from the ANOVA. If you want to know more, you need to look carefully at the size of the difference and probably collect more data/test the models on a larger data set.
PS: All this ignores two potential additional problems that were not raised in the question, namely the nature of your response variable (is it a proportion?) and independence (are all the models tested on the same exemplars?) Depending on the answers to these questions, ANOVA/T-test might not be the best choice anyway (see also this previous question). Also, if you specifically want to compare each group to baseline, you can also achieve that in an ANOVA framework by using contrasts. You would have a theoretically sound approach with more power than post-hoc pairwise tests but still would not address the “which one is best” question.
|
Multiple t-tests vs. one-way ANOVA
|
There are two problems with your first approach: Multiple testing and the interpretation of the difference between significant and non-significant.
First, when you perform several tests, you increase
|
Multiple t-tests vs. one-way ANOVA
There are two problems with your first approach: Multiple testing and the interpretation of the difference between significant and non-significant.
First, when you perform several tests, you increase the overall error rate. If you set $\alpha = .05$, you will still reject the null hypothesis 5% of the time when it is actually true (i.e. when there is no difference whatsoever). However, the probability that you reject the null hypothesis at least once when performing several tests is higher because you are taking this 5% risk each time you run a test. The problem is not very acute with only three tests but it still does not make much sense to run a test if you don't care about controlling the error level.
A quick fix for this problem is to adjust the error level with the Bonferroni correction. Since it is based on a very general probability inequality, it doesn't matter what the tests are and you can always use it but you will loose power. For example, it's possible that, after applying the correction, none of your tests would be significant and you would be back to the results of your second approach. This would resolve the apparent inconsistency but would not be terribly useful. Generally speaking, the main problem with this technique is that yo are not using all the information you have and the correction is usually too conservative. That's one reason to choose an ANOVA approach when you have several groups.
The second problem is that the difference between significant and non-significant is not necessarily itself significant. If you rejected the null hypothesis that model 1 is equal to baseline but not the separate hypothesis that model 2 is different from baseline, you still haven't established that model 1 is different from model 2. Those are three different questions. Let's see how this could happen:
Now, let's imagine that the difference between baseline and model 1 is “barely” significant, say p = .04. The p-value from a test of the difference between baseline and model 2 would then be a little over the threshold, say p = .06, so not significant. Yet, at the same time, model 1 and model 2 appear very similar and the difference between the two is also obviously not significantly different from 0.
The thing is that the logic of statistical testing requires us to specify an error level but there is nothing exceptional about this threshold. We simply have a little less evidence than the score for model 2 is higher than baseline and maybe this evidence is not sufficient to rule out the null hypothesis at the specified error level. This is however not enough to conclude that it is different from model 1.
Ignoring the multiple testing issue, you could then conclude that you don't know if model 2 is in fact better or worse than baseline and you certainly don't know if it is better or worse than model 1. Intuitively, if your data indeed look like the data on the graph, I don't find this very satisfying because it means treating model 1 and model 2 differently based on evidence that is much thinner than the evidence that model 2 is in fact better than baseline. However, this type of thinking is quite different from the logic underlying statistical tests. Instead of blindly make binary decisions based on the tests, I would therefore rather look at some graphs and make a judgment call about the results.
Either way, the results you presented suggest that your models do in fact represent an improvement over the baseline but there is no way you can conclude that model 1 is better than model 2. This is also pretty much what you can conclude from the ANOVA. If you want to know more, you need to look carefully at the size of the difference and probably collect more data/test the models on a larger data set.
PS: All this ignores two potential additional problems that were not raised in the question, namely the nature of your response variable (is it a proportion?) and independence (are all the models tested on the same exemplars?) Depending on the answers to these questions, ANOVA/T-test might not be the best choice anyway (see also this previous question). Also, if you specifically want to compare each group to baseline, you can also achieve that in an ANOVA framework by using contrasts. You would have a theoretically sound approach with more power than post-hoc pairwise tests but still would not address the “which one is best” question.
|
Multiple t-tests vs. one-way ANOVA
There are two problems with your first approach: Multiple testing and the interpretation of the difference between significant and non-significant.
First, when you perform several tests, you increase
|
44,909
|
Another p-value fallacy
|
A test procedure goes like this:
(1) Define the sample space: 1024 outcomes of tossing a coin 10 times
(2) State the null hypothesis: A fair coin; i.e. $\mathsf{H}$ & $\mathsf{T}$ equiprobable, tosses independent
(3) Define a test statistic: You can use the sum of heads, or the number of runs, or whatever you like
(4) Perform the experiment & calculate the observed value test statistic: Toss the coin 10 times
(5) Calculate the probability (under the null hypothesis) of getting a value of the test statistic greater than or equal to the observed one.
The result from (5) is the p-value. It lets you calibrate the test statistic. Suppose the null hypothesis were indeed true: if you were to follow this test procedure many times & reject the null hypothesis (wrongly) every time you got a value of the test statistic this big or bigger, you'd reject it (wrongly) a fraction $p$ of the many times.
The tricky part is (3). What's right about your intuition is that every particular sequence can be seen as favouring some alternative or other against the null—there are so many different ways a coin can be unfair. But you have to choose a test statistic that gives you some discrimination. The count of heads is a good one if you want to test whether the probability of heads is different to one-half, & are not so doubtful of independence. The count of runs of the same side up is a good one if you're more concerned about independence. If someone tells you they're going to toss $\mathsf{HHTHTHHHTT}$ then to test their ability you can let your test statistic equal one when just that sequence arises, and zero otherwise. What you can't do is look at a particular sequence after the experiment, say it would have been extremely improbable according to some test statistic or other, & quote a p-value based on that.
[In response to your comment:
(a) The p-value of $\mathsf{HHTHTHHHTT}$ is not in general $\frac{1}{1024}$, but depends on the test statistic being used. If the count of heads is being used as the test statistic (as it is when the alternative of interest is that the probability of heads is greater than $\frac{1}{2}$), the more extreme cases are counts of 7, 8, 9, & 10, & the probabilities of these counts would be summed into the p-value. I gave an example of someone's saying they intended to toss $\mathsf{HHTHTHHHTT}$, & in this case, but certainly not in all cases, it would be sensible to define the test statistic such that $\mathsf{HHTHTHHHTT}$ was the most extreme value.
(b) You can calculate what probabilities you like before & after the experiment, but valid p-values are derived from a test statistic defined beforehand, or at any rate independently of the observed results. If you choose your test statistic depending on the observed results, you're following a different procedure from the one described above, & the interpretation in terms of error rates over hypothetical repetitions—which is the whole point of introducing p-values—will no longer be relevant.
(c) I can't follow your argument on sample size at all. An exact p-value will be valid regardless of sample size.]
|
Another p-value fallacy
|
A test procedure goes like this:
(1) Define the sample space: 1024 outcomes of tossing a coin 10 times
(2) State the null hypothesis: A fair coin; i.e. $\mathsf{H}$ & $\mathsf{T}$ equiprobable, tosse
|
Another p-value fallacy
A test procedure goes like this:
(1) Define the sample space: 1024 outcomes of tossing a coin 10 times
(2) State the null hypothesis: A fair coin; i.e. $\mathsf{H}$ & $\mathsf{T}$ equiprobable, tosses independent
(3) Define a test statistic: You can use the sum of heads, or the number of runs, or whatever you like
(4) Perform the experiment & calculate the observed value test statistic: Toss the coin 10 times
(5) Calculate the probability (under the null hypothesis) of getting a value of the test statistic greater than or equal to the observed one.
The result from (5) is the p-value. It lets you calibrate the test statistic. Suppose the null hypothesis were indeed true: if you were to follow this test procedure many times & reject the null hypothesis (wrongly) every time you got a value of the test statistic this big or bigger, you'd reject it (wrongly) a fraction $p$ of the many times.
The tricky part is (3). What's right about your intuition is that every particular sequence can be seen as favouring some alternative or other against the null—there are so many different ways a coin can be unfair. But you have to choose a test statistic that gives you some discrimination. The count of heads is a good one if you want to test whether the probability of heads is different to one-half, & are not so doubtful of independence. The count of runs of the same side up is a good one if you're more concerned about independence. If someone tells you they're going to toss $\mathsf{HHTHTHHHTT}$ then to test their ability you can let your test statistic equal one when just that sequence arises, and zero otherwise. What you can't do is look at a particular sequence after the experiment, say it would have been extremely improbable according to some test statistic or other, & quote a p-value based on that.
[In response to your comment:
(a) The p-value of $\mathsf{HHTHTHHHTT}$ is not in general $\frac{1}{1024}$, but depends on the test statistic being used. If the count of heads is being used as the test statistic (as it is when the alternative of interest is that the probability of heads is greater than $\frac{1}{2}$), the more extreme cases are counts of 7, 8, 9, & 10, & the probabilities of these counts would be summed into the p-value. I gave an example of someone's saying they intended to toss $\mathsf{HHTHTHHHTT}$, & in this case, but certainly not in all cases, it would be sensible to define the test statistic such that $\mathsf{HHTHTHHHTT}$ was the most extreme value.
(b) You can calculate what probabilities you like before & after the experiment, but valid p-values are derived from a test statistic defined beforehand, or at any rate independently of the observed results. If you choose your test statistic depending on the observed results, you're following a different procedure from the one described above, & the interpretation in terms of error rates over hypothetical repetitions—which is the whole point of introducing p-values—will no longer be relevant.
(c) I can't follow your argument on sample size at all. An exact p-value will be valid regardless of sample size.]
|
Another p-value fallacy
A test procedure goes like this:
(1) Define the sample space: 1024 outcomes of tossing a coin 10 times
(2) State the null hypothesis: A fair coin; i.e. $\mathsf{H}$ & $\mathsf{T}$ equiprobable, tosse
|
44,910
|
Another p-value fallacy
|
I don't think this is anything to do with P-values. In any case you nowhere specify what test you have in mind.
The usual definition of a fair coin I take to be that heads and tails are equally probable, but nothing rules out "fairness" being a vague concept that can be made precise in several ways. In practice one should also be wary of -- to take one example -- perfect alternation between heads and tails and suspect the coin -- or more to the point perhaps, the machine or person tossing it. Other kinds of regularity can also be imagined.
In that case, the thing to do is to set up a test specific to that kind of behaviour and calculate P-values (or preferably some kind of confidence interval for a key parameter). Alternatively, go as Bayesian as you want.
So, I don't see anything here except the idea that the wrong question can give you an irrelevant answer.
|
Another p-value fallacy
|
I don't think this is anything to do with P-values. In any case you nowhere specify what test you have in mind.
The usual definition of a fair coin I take to be that heads and tails are equally proba
|
Another p-value fallacy
I don't think this is anything to do with P-values. In any case you nowhere specify what test you have in mind.
The usual definition of a fair coin I take to be that heads and tails are equally probable, but nothing rules out "fairness" being a vague concept that can be made precise in several ways. In practice one should also be wary of -- to take one example -- perfect alternation between heads and tails and suspect the coin -- or more to the point perhaps, the machine or person tossing it. Other kinds of regularity can also be imagined.
In that case, the thing to do is to set up a test specific to that kind of behaviour and calculate P-values (or preferably some kind of confidence interval for a key parameter). Alternatively, go as Bayesian as you want.
So, I don't see anything here except the idea that the wrong question can give you an irrelevant answer.
|
Another p-value fallacy
I don't think this is anything to do with P-values. In any case you nowhere specify what test you have in mind.
The usual definition of a fair coin I take to be that heads and tails are equally proba
|
44,911
|
Another p-value fallacy
|
What's the implicit model?
The probability p = 1/1024 is derived from the fair coin model of $\Pr(H)=\Pr(T)=0.5$ with independent throws, i.e. $Cov(n_i,n_{i-1})=1$. Note that this model is invariant to the sequence of throws, i.e. $\Pr(HHT)=\Pr(HTH)=\Pr(THH)$.
Under this model, a sequence such as HTHTHTHT is suspect, because it violates the second condition - the sequence of throws doesn't display independence.
However, OP asks why we shouldn't consider any n-tuple to be suspect, as the probability of any n-tuple is $1 \over2^n$, which for $n>5$ is below the "traditional" cut-off of $p<0.05$. What OP fails to recognize in this question is that he is using a model of individual throws to model the p-value of n-tuples.
In my opinion, the appropriate model is $H_0:\Pr(T_{k,i})=\Pr(T_{k,j}) \forall i,j$ versus $H_A:\exists i,j: \Pr(T_{k,i}) \neq \Pr(T_{k,j})$, where $T_{k,i}$ is the i'th k-tuple. This follows a multinomial distribution with k outcomes, and the test statistic can be derived.
|
Another p-value fallacy
|
What's the implicit model?
The probability p = 1/1024 is derived from the fair coin model of $\Pr(H)=\Pr(T)=0.5$ with independent throws, i.e. $Cov(n_i,n_{i-1})=1$. Note that this model is invariant t
|
Another p-value fallacy
What's the implicit model?
The probability p = 1/1024 is derived from the fair coin model of $\Pr(H)=\Pr(T)=0.5$ with independent throws, i.e. $Cov(n_i,n_{i-1})=1$. Note that this model is invariant to the sequence of throws, i.e. $\Pr(HHT)=\Pr(HTH)=\Pr(THH)$.
Under this model, a sequence such as HTHTHTHT is suspect, because it violates the second condition - the sequence of throws doesn't display independence.
However, OP asks why we shouldn't consider any n-tuple to be suspect, as the probability of any n-tuple is $1 \over2^n$, which for $n>5$ is below the "traditional" cut-off of $p<0.05$. What OP fails to recognize in this question is that he is using a model of individual throws to model the p-value of n-tuples.
In my opinion, the appropriate model is $H_0:\Pr(T_{k,i})=\Pr(T_{k,j}) \forall i,j$ versus $H_A:\exists i,j: \Pr(T_{k,i}) \neq \Pr(T_{k,j})$, where $T_{k,i}$ is the i'th k-tuple. This follows a multinomial distribution with k outcomes, and the test statistic can be derived.
|
Another p-value fallacy
What's the implicit model?
The probability p = 1/1024 is derived from the fair coin model of $\Pr(H)=\Pr(T)=0.5$ with independent throws, i.e. $Cov(n_i,n_{i-1})=1$. Note that this model is invariant t
|
44,912
|
Another p-value fallacy
|
On the chance of misunderstanding you, I will guess about what you might mean.
I guess your hypothesis is that the coin is fair, right?
And your problem is how to test this if, in fact, all sequences by themselves have the same probability to occur. However when we are talking about p-values, this usually doesn't matter. At least not for the coins minted from the central bank of statistics books, if you will.
Well, if the coin if fair then we can (for example) assume that the throw is a random experiment which is Bernoulli distributed. If we assume that, then we can state that the result of "1111111..." is a result of a n-Binomial distribution of n throws of that coin.
And our hypothesis is then that the experiment, throwing the coin n-times with k successes stems from a binomial probability distribution. In this case, k=the amount of "1" we got, or our successes.
So we can test the hypothesis and we will see that it is highly unlikely to achieve the amount of successive "1" we got.
In fact the probability for this is NOT equal to all other sequences, since we are looking at the amount of successes with the binomial distribution. In fact the fact that the "1" are successsive doesn't matter for us. The order doesn't matter and therefore the probability of a sequence doesn't matter.
A binomial distribution with p=0.5 will have the most likely event that there are just as many heads as there are tails.
Like so, where in 15 throws the most "expected" outcome is 7.5:
This way, we could pretty accurately deny the hypothesis that the coin is fair and there would be no fallacy by using a simple binomial test.
http://en.wikipedia.org/wiki/Binomial_test
Your confusion seems to stem from the assumption we are testing not the amount of heads but rather the sequence. In this case you would be right: Every sequence is equally likely. But there are many more of these sequences that generate k throws with "1" if k is smaller than n, so with our fair coin we assume to have, our series of only "1" is unlikely precisely BECAUSE all throws have the same probability to go "1" or "0"
|
Another p-value fallacy
|
On the chance of misunderstanding you, I will guess about what you might mean.
I guess your hypothesis is that the coin is fair, right?
And your problem is how to test this if, in fact, all sequences
|
Another p-value fallacy
On the chance of misunderstanding you, I will guess about what you might mean.
I guess your hypothesis is that the coin is fair, right?
And your problem is how to test this if, in fact, all sequences by themselves have the same probability to occur. However when we are talking about p-values, this usually doesn't matter. At least not for the coins minted from the central bank of statistics books, if you will.
Well, if the coin if fair then we can (for example) assume that the throw is a random experiment which is Bernoulli distributed. If we assume that, then we can state that the result of "1111111..." is a result of a n-Binomial distribution of n throws of that coin.
And our hypothesis is then that the experiment, throwing the coin n-times with k successes stems from a binomial probability distribution. In this case, k=the amount of "1" we got, or our successes.
So we can test the hypothesis and we will see that it is highly unlikely to achieve the amount of successive "1" we got.
In fact the probability for this is NOT equal to all other sequences, since we are looking at the amount of successes with the binomial distribution. In fact the fact that the "1" are successsive doesn't matter for us. The order doesn't matter and therefore the probability of a sequence doesn't matter.
A binomial distribution with p=0.5 will have the most likely event that there are just as many heads as there are tails.
Like so, where in 15 throws the most "expected" outcome is 7.5:
This way, we could pretty accurately deny the hypothesis that the coin is fair and there would be no fallacy by using a simple binomial test.
http://en.wikipedia.org/wiki/Binomial_test
Your confusion seems to stem from the assumption we are testing not the amount of heads but rather the sequence. In this case you would be right: Every sequence is equally likely. But there are many more of these sequences that generate k throws with "1" if k is smaller than n, so with our fair coin we assume to have, our series of only "1" is unlikely precisely BECAUSE all throws have the same probability to go "1" or "0"
|
Another p-value fallacy
On the chance of misunderstanding you, I will guess about what you might mean.
I guess your hypothesis is that the coin is fair, right?
And your problem is how to test this if, in fact, all sequences
|
44,913
|
Estimating the covariance of the means from two samples?
|
\begin{eqnarray}
\text{cov}(\bar X_n, \bar Y_n)
&=& \text{cov}(1/n \sum X_i, 1/n \sum Y_j)\\
&=& 1/n^2 \cdot \text{cov}( \sum X_i, \sum Y_j)\\
&=& 1/n^2 \cdot \sum_i \sum_j \text{cov}( X_i, Y_j)
\end{eqnarray}
To go further, we need to specify something about the covariances. If the samples are iid random samples where $\text{cov}(X_i,Y_j)$ is constant over all $i,j$:
\begin{eqnarray}
\quad\quad &=& 1/n^2 \cdot n^2 \text{cov}( X, Y)\\
\quad\quad &=& \text{cov}( X, Y)\, .
\end{eqnarray}
If instead (and as seems to be the case here) we're talking about paired data, where $X_i$ and $Y_j$ are only correlated when $i=j$ then:
\begin{eqnarray}
\quad\quad &=& 1/n^2 \cdot \sum_i \sum_j \text{cov}( X_i, Y_j)\\
\quad\quad &=& 1/n^2 \cdot n \cdot \text{cov}( X_i, Y_i)\\
\quad\quad &=& 1/n \cdot \text{cov}( X_i, Y_i)\\
\quad\quad &=& 1/n \cdot \rho\, \sigma_x \sigma_y,
\end{eqnarray}
where $\rho$ is the correlation between $X$ and $Y$ pairs.
|
Estimating the covariance of the means from two samples?
|
\begin{eqnarray}
\text{cov}(\bar X_n, \bar Y_n)
&=& \text{cov}(1/n \sum X_i, 1/n \sum Y_j)\\
&=& 1/n^2 \cdot \text{cov}( \sum X_i, \sum Y_j)\\
&=& 1/n^2 \cdot \sum_i \sum_j \text{cov}( X_i, Y_j)
\en
|
Estimating the covariance of the means from two samples?
\begin{eqnarray}
\text{cov}(\bar X_n, \bar Y_n)
&=& \text{cov}(1/n \sum X_i, 1/n \sum Y_j)\\
&=& 1/n^2 \cdot \text{cov}( \sum X_i, \sum Y_j)\\
&=& 1/n^2 \cdot \sum_i \sum_j \text{cov}( X_i, Y_j)
\end{eqnarray}
To go further, we need to specify something about the covariances. If the samples are iid random samples where $\text{cov}(X_i,Y_j)$ is constant over all $i,j$:
\begin{eqnarray}
\quad\quad &=& 1/n^2 \cdot n^2 \text{cov}( X, Y)\\
\quad\quad &=& \text{cov}( X, Y)\, .
\end{eqnarray}
If instead (and as seems to be the case here) we're talking about paired data, where $X_i$ and $Y_j$ are only correlated when $i=j$ then:
\begin{eqnarray}
\quad\quad &=& 1/n^2 \cdot \sum_i \sum_j \text{cov}( X_i, Y_j)\\
\quad\quad &=& 1/n^2 \cdot n \cdot \text{cov}( X_i, Y_i)\\
\quad\quad &=& 1/n \cdot \text{cov}( X_i, Y_i)\\
\quad\quad &=& 1/n \cdot \rho\, \sigma_x \sigma_y,
\end{eqnarray}
where $\rho$ is the correlation between $X$ and $Y$ pairs.
|
Estimating the covariance of the means from two samples?
\begin{eqnarray}
\text{cov}(\bar X_n, \bar Y_n)
&=& \text{cov}(1/n \sum X_i, 1/n \sum Y_j)\\
&=& 1/n^2 \cdot \text{cov}( \sum X_i, \sum Y_j)\\
&=& 1/n^2 \cdot \sum_i \sum_j \text{cov}( X_i, Y_j)
\en
|
44,914
|
Estimating the covariance of the means from two samples?
|
Here is an answer derived using the theory of 'moments of moments', using power sum notation, and leaving the grunt work to mathStatica. In particular, in power sum notation, let:
$$s_{a,b}=\sum _{i=1}^n X_i^a Y_i^b$$
Then, $\operatorname{cov}(\bar X_n, \bar Y_n)$ = $\operatorname{cov}(\frac{s_{1,0}}{n}$, $\frac{s_{0,1}}{n}$) ... and since the covariance operator is just the {1,1} CentralMoment, the solution is:
where $\mu_{1,1}$ denotes the {1,1} central moment of the population ...
i.e. The solution is:
$$\operatorname{cov}(\bar X_n, \bar Y_n) = \frac{\operatorname{cov}(X, Y)}{n} $$
In the case of independence, $\operatorname{cov}(X,Y)$ is, of course, zero.
|
Estimating the covariance of the means from two samples?
|
Here is an answer derived using the theory of 'moments of moments', using power sum notation, and leaving the grunt work to mathStatica. In particular, in power sum notation, let:
$$s_{a,b}=\sum _{i=1
|
Estimating the covariance of the means from two samples?
Here is an answer derived using the theory of 'moments of moments', using power sum notation, and leaving the grunt work to mathStatica. In particular, in power sum notation, let:
$$s_{a,b}=\sum _{i=1}^n X_i^a Y_i^b$$
Then, $\operatorname{cov}(\bar X_n, \bar Y_n)$ = $\operatorname{cov}(\frac{s_{1,0}}{n}$, $\frac{s_{0,1}}{n}$) ... and since the covariance operator is just the {1,1} CentralMoment, the solution is:
where $\mu_{1,1}$ denotes the {1,1} central moment of the population ...
i.e. The solution is:
$$\operatorname{cov}(\bar X_n, \bar Y_n) = \frac{\operatorname{cov}(X, Y)}{n} $$
In the case of independence, $\operatorname{cov}(X,Y)$ is, of course, zero.
|
Estimating the covariance of the means from two samples?
Here is an answer derived using the theory of 'moments of moments', using power sum notation, and leaving the grunt work to mathStatica. In particular, in power sum notation, let:
$$s_{a,b}=\sum _{i=1
|
44,915
|
When is it appropriate to use a paired Wilcoxon test?
|
(Sorry, but I will have to use the word "paired")
There are two aspects to this question:
1) When to use paired tests
2) When to use Wilcoxon
Paired tests are appropriate when the data are not independent and when the dependency results in a 1 to 1 match. For example suppose I want to study heights of men and women. If I gather 100 random men and 100 random women, the data are independent: Bob's height has nothing to do with Mary's height. But if I gather data on 100 brother/sister pairs, the data are not independent: Siblings will share lots of factors that affect height. And, since they are brother sister pairs, a paired test works.
Wilcoxon tests (as opposed to t-tests, e.g.) are non-parametric. They do not assume things about the distributions. When the data are very non-normal, t-tests may not be appropriate and one alternative is Wilcoxon. In addition, Wilcoxon tests entire distributions whereas t-tests are tests of the means.
|
When is it appropriate to use a paired Wilcoxon test?
|
(Sorry, but I will have to use the word "paired")
There are two aspects to this question:
1) When to use paired tests
2) When to use Wilcoxon
Paired tests are appropriate when the data are not indepe
|
When is it appropriate to use a paired Wilcoxon test?
(Sorry, but I will have to use the word "paired")
There are two aspects to this question:
1) When to use paired tests
2) When to use Wilcoxon
Paired tests are appropriate when the data are not independent and when the dependency results in a 1 to 1 match. For example suppose I want to study heights of men and women. If I gather 100 random men and 100 random women, the data are independent: Bob's height has nothing to do with Mary's height. But if I gather data on 100 brother/sister pairs, the data are not independent: Siblings will share lots of factors that affect height. And, since they are brother sister pairs, a paired test works.
Wilcoxon tests (as opposed to t-tests, e.g.) are non-parametric. They do not assume things about the distributions. When the data are very non-normal, t-tests may not be appropriate and one alternative is Wilcoxon. In addition, Wilcoxon tests entire distributions whereas t-tests are tests of the means.
|
When is it appropriate to use a paired Wilcoxon test?
(Sorry, but I will have to use the word "paired")
There are two aspects to this question:
1) When to use paired tests
2) When to use Wilcoxon
Paired tests are appropriate when the data are not indepe
|
44,916
|
Machine learning book with code examples
|
Machine Learning, Stephen Marsland.
One of the best practical, Python based, texts I've come across.
|
Machine learning book with code examples
|
Machine Learning, Stephen Marsland.
One of the best practical, Python based, texts I've come across.
|
Machine learning book with code examples
Machine Learning, Stephen Marsland.
One of the best practical, Python based, texts I've come across.
|
Machine learning book with code examples
Machine Learning, Stephen Marsland.
One of the best practical, Python based, texts I've come across.
|
44,917
|
Machine learning book with code examples
|
Bayesian Reasoning and Machine Learning by Barber. It is freely available. In addition, there is Matlab toolbox of the book.
|
Machine learning book with code examples
|
Bayesian Reasoning and Machine Learning by Barber. It is freely available. In addition, there is Matlab toolbox of the book.
|
Machine learning book with code examples
Bayesian Reasoning and Machine Learning by Barber. It is freely available. In addition, there is Matlab toolbox of the book.
|
Machine learning book with code examples
Bayesian Reasoning and Machine Learning by Barber. It is freely available. In addition, there is Matlab toolbox of the book.
|
44,918
|
Machine learning book with code examples
|
The recently published
Machine learning: a probabilistic perspective, By Kevin Murphy
comes with an excellent and very extensive Matlab toolkit for Machine learning, which includes code for examples discussed in the book.
|
Machine learning book with code examples
|
The recently published
Machine learning: a probabilistic perspective, By Kevin Murphy
comes with an excellent and very extensive Matlab toolkit for Machine learning, which includes code for example
|
Machine learning book with code examples
The recently published
Machine learning: a probabilistic perspective, By Kevin Murphy
comes with an excellent and very extensive Matlab toolkit for Machine learning, which includes code for examples discussed in the book.
|
Machine learning book with code examples
The recently published
Machine learning: a probabilistic perspective, By Kevin Murphy
comes with an excellent and very extensive Matlab toolkit for Machine learning, which includes code for example
|
44,919
|
Machine learning book with code examples
|
WEKA is fully implemented in Java.
http://www.cs.waikato.ac.nz/ml/weka/
It has its own manual and book. You can find the manual in the WEKA directory if you install it or straight away in the zip file if you don't download the self-extracting.
|
Machine learning book with code examples
|
WEKA is fully implemented in Java.
http://www.cs.waikato.ac.nz/ml/weka/
It has its own manual and book. You can find the manual in the WEKA directory if you install it or straight away in the zip fil
|
Machine learning book with code examples
WEKA is fully implemented in Java.
http://www.cs.waikato.ac.nz/ml/weka/
It has its own manual and book. You can find the manual in the WEKA directory if you install it or straight away in the zip file if you don't download the self-extracting.
|
Machine learning book with code examples
WEKA is fully implemented in Java.
http://www.cs.waikato.ac.nz/ml/weka/
It has its own manual and book. You can find the manual in the WEKA directory if you install it or straight away in the zip fil
|
44,920
|
Problems with mixed model simulation
|
As ?lmeControl says, the default optimizer function is nlminb rather than optim. ?nlminb, however, says that optim is preferred and, indeed, the following works.
lme(y~1+x1, data=d1, random=~1+x1|j, control = lmeControl(opt = "optim"))
Linear mixed-effects model fit by REML
Data: d1
Log-restricted-likelihood: 320824.3
Fixed: y ~ 1 + x1
(Intercept) x1
8.302459 8.183053
Random effects:
Formula: ~1 + x1 | j
Structure: General positive-definite, Log-Cholesky parametrization
StdDev Corr
(Intercept) 1.699207e+00 (Intr)
x1 1.952189e+00 0.752
Residual 1.347943e-15
Number of Observations: 10000
Number of Groups: 100
It's hard to say why exactly that's the case. In general, one can see that false convergence (8) means
the gradient $\nabla f(x)$ may be computed incorrectly, the other
stopping tolerances may be too tight, or either $f$ or $\nabla f$
may be discontinuous near the current iterate $x$
|
Problems with mixed model simulation
|
As ?lmeControl says, the default optimizer function is nlminb rather than optim. ?nlminb, however, says that optim is preferred and, indeed, the following works.
lme(y~1+x1, data=d1, random=~1+x1|j, c
|
Problems with mixed model simulation
As ?lmeControl says, the default optimizer function is nlminb rather than optim. ?nlminb, however, says that optim is preferred and, indeed, the following works.
lme(y~1+x1, data=d1, random=~1+x1|j, control = lmeControl(opt = "optim"))
Linear mixed-effects model fit by REML
Data: d1
Log-restricted-likelihood: 320824.3
Fixed: y ~ 1 + x1
(Intercept) x1
8.302459 8.183053
Random effects:
Formula: ~1 + x1 | j
Structure: General positive-definite, Log-Cholesky parametrization
StdDev Corr
(Intercept) 1.699207e+00 (Intr)
x1 1.952189e+00 0.752
Residual 1.347943e-15
Number of Observations: 10000
Number of Groups: 100
It's hard to say why exactly that's the case. In general, one can see that false convergence (8) means
the gradient $\nabla f(x)$ may be computed incorrectly, the other
stopping tolerances may be too tight, or either $f$ or $\nabla f$
may be discontinuous near the current iterate $x$
|
Problems with mixed model simulation
As ?lmeControl says, the default optimizer function is nlminb rather than optim. ?nlminb, however, says that optim is preferred and, indeed, the following works.
lme(y~1+x1, data=d1, random=~1+x1|j, c
|
44,921
|
Problems with mixed model simulation
|
d1 <- data.frame(j, y=g00+u0j+(g10+u1j)*x1+e, x1) # You need to add error terms
My intuition is that when we simulatated a mixed model data set without error terms, sometimes it may be difficult to converge. This is likely to be a zero residual problem.
|
Problems with mixed model simulation
|
d1 <- data.frame(j, y=g00+u0j+(g10+u1j)*x1+e, x1) # You need to add error terms
My intuition is that when we simulatated a mixed model data set without error terms, sometimes it may be difficult to co
|
Problems with mixed model simulation
d1 <- data.frame(j, y=g00+u0j+(g10+u1j)*x1+e, x1) # You need to add error terms
My intuition is that when we simulatated a mixed model data set without error terms, sometimes it may be difficult to converge. This is likely to be a zero residual problem.
|
Problems with mixed model simulation
d1 <- data.frame(j, y=g00+u0j+(g10+u1j)*x1+e, x1) # You need to add error terms
My intuition is that when we simulatated a mixed model data set without error terms, sometimes it may be difficult to co
|
44,922
|
Problems with mixed model simulation
|
I might be missing a simpler answer (i.e., mis-specification in your model), but /if/ I was sure that the mixed model should converge, I would move on to using openbugs, which will let you drag out a much longer mcmc sample.
|
Problems with mixed model simulation
|
I might be missing a simpler answer (i.e., mis-specification in your model), but /if/ I was sure that the mixed model should converge, I would move on to using openbugs, which will let you drag out a
|
Problems with mixed model simulation
I might be missing a simpler answer (i.e., mis-specification in your model), but /if/ I was sure that the mixed model should converge, I would move on to using openbugs, which will let you drag out a much longer mcmc sample.
|
Problems with mixed model simulation
I might be missing a simpler answer (i.e., mis-specification in your model), but /if/ I was sure that the mixed model should converge, I would move on to using openbugs, which will let you drag out a
|
44,923
|
Problems with mixed model simulation
|
This works for me. Instead of using nlme or lmer, I use mgcv::gamm and specify a gaussian link as follows:
GAMM(y~1+x1, data=d1, random=~1+x1|j,family = gaussian)
The estimation results are close to nlme/lmer mixed models and is applicable for most of the cases. In fact, the HLM/mixed model is a specific case of GAMM.
|
Problems with mixed model simulation
|
This works for me. Instead of using nlme or lmer, I use mgcv::gamm and specify a gaussian link as follows:
GAMM(y~1+x1, data=d1, random=~1+x1|j,family = gaussian)
The estimation results are close to
|
Problems with mixed model simulation
This works for me. Instead of using nlme or lmer, I use mgcv::gamm and specify a gaussian link as follows:
GAMM(y~1+x1, data=d1, random=~1+x1|j,family = gaussian)
The estimation results are close to nlme/lmer mixed models and is applicable for most of the cases. In fact, the HLM/mixed model is a specific case of GAMM.
|
Problems with mixed model simulation
This works for me. Instead of using nlme or lmer, I use mgcv::gamm and specify a gaussian link as follows:
GAMM(y~1+x1, data=d1, random=~1+x1|j,family = gaussian)
The estimation results are close to
|
44,924
|
Could logistic regression be used to detect large errors in least squares regression?
|
I think this would only work if the logistic regression model had access to relevant covariates that are missing from the OLS model. In such a situation (i.e., model misspecification), there could be regions in which the observed response values diverge strongly from the predicted values and the logistic regression model would have the requisite information to detect them.
|
Could logistic regression be used to detect large errors in least squares regression?
|
I think this would only work if the logistic regression model had access to relevant covariates that are missing from the OLS model. In such a situation (i.e., model misspecification), there could be
|
Could logistic regression be used to detect large errors in least squares regression?
I think this would only work if the logistic regression model had access to relevant covariates that are missing from the OLS model. In such a situation (i.e., model misspecification), there could be regions in which the observed response values diverge strongly from the predicted values and the logistic regression model would have the requisite information to detect them.
|
Could logistic regression be used to detect large errors in least squares regression?
I think this would only work if the logistic regression model had access to relevant covariates that are missing from the OLS model. In such a situation (i.e., model misspecification), there could be
|
44,925
|
Could logistic regression be used to detect large errors in least squares regression?
|
You are trying to use logistic regression to find a possible structure to your residuals. Residuals should be unstructured. If logistic regression picks up something the model is misspecified. Great.
Important: logistic regression looks for a very specific structure. Your method works only if residuals are broken in a very specific way.
For this sort of detection use non-linear regressions. Kernel or Additive regression on the squared/log residuals are far more useful.
Even better: they will allow you to model the whole variance. This answers your question of where the large errors really are.
|
Could logistic regression be used to detect large errors in least squares regression?
|
You are trying to use logistic regression to find a possible structure to your residuals. Residuals should be unstructured. If logistic regression picks up something the model is misspecified. Great.
|
Could logistic regression be used to detect large errors in least squares regression?
You are trying to use logistic regression to find a possible structure to your residuals. Residuals should be unstructured. If logistic regression picks up something the model is misspecified. Great.
Important: logistic regression looks for a very specific structure. Your method works only if residuals are broken in a very specific way.
For this sort of detection use non-linear regressions. Kernel or Additive regression on the squared/log residuals are far more useful.
Even better: they will allow you to model the whole variance. This answers your question of where the large errors really are.
|
Could logistic regression be used to detect large errors in least squares regression?
You are trying to use logistic regression to find a possible structure to your residuals. Residuals should be unstructured. If logistic regression picks up something the model is misspecified. Great.
|
44,926
|
Could logistic regression be used to detect large errors in least squares regression?
|
It would be possible in the case where the original model was heteroskedastic and the heteroskedasticity was related to the covariates. For example,
$y_i \sim \text{N}(x_i^T\beta, \sigma^2x_{i,1}^2)$
where the variance of the $i^{th}$ observation is proportional to the square of the first covariate.
One can imagine, in non-Normal regression situations, similar structures that don't require heteroskedasticity per se. However, the default assumptions of regression models in general involve the errors being independent of the regressors, and the variance of the errors being constant.
On the other hand, if doing, for example, Poisson regression, you're out of the linear model world, but since the variance of the "error" is proportional to the mean, it follows that it is related to the covariates, and such a logistic regression would work - although it would convey no information not already conveyed by the results of the Poisson regression, which fully specify the conditional distributions of the $y_i | x_i$. In the generalized linear / additive model framework, where the likelihood is fully specified, the only way you'll be able to add information to the initial regression by using the logistic regression you suggest is if the initial regression has misspecified (usually by ignoring) the structure of the residuals, e.g., ignored the heteroskedasticity in the linear model presented above.
Nonetheless, your suggestion might reveal something about the structure of the residuals in an exploratory analysis. I suspect, though, that effectively discretizing the residuals by $< T$ or $\ge T$ would usually decrease the information content of them more than it would help clarify the analysis - unless it was an outlier analysis, perhaps.
|
Could logistic regression be used to detect large errors in least squares regression?
|
It would be possible in the case where the original model was heteroskedastic and the heteroskedasticity was related to the covariates. For example,
$y_i \sim \text{N}(x_i^T\beta, \sigma^2x_{i,1}^2)
|
Could logistic regression be used to detect large errors in least squares regression?
It would be possible in the case where the original model was heteroskedastic and the heteroskedasticity was related to the covariates. For example,
$y_i \sim \text{N}(x_i^T\beta, \sigma^2x_{i,1}^2)$
where the variance of the $i^{th}$ observation is proportional to the square of the first covariate.
One can imagine, in non-Normal regression situations, similar structures that don't require heteroskedasticity per se. However, the default assumptions of regression models in general involve the errors being independent of the regressors, and the variance of the errors being constant.
On the other hand, if doing, for example, Poisson regression, you're out of the linear model world, but since the variance of the "error" is proportional to the mean, it follows that it is related to the covariates, and such a logistic regression would work - although it would convey no information not already conveyed by the results of the Poisson regression, which fully specify the conditional distributions of the $y_i | x_i$. In the generalized linear / additive model framework, where the likelihood is fully specified, the only way you'll be able to add information to the initial regression by using the logistic regression you suggest is if the initial regression has misspecified (usually by ignoring) the structure of the residuals, e.g., ignored the heteroskedasticity in the linear model presented above.
Nonetheless, your suggestion might reveal something about the structure of the residuals in an exploratory analysis. I suspect, though, that effectively discretizing the residuals by $< T$ or $\ge T$ would usually decrease the information content of them more than it would help clarify the analysis - unless it was an outlier analysis, perhaps.
|
Could logistic regression be used to detect large errors in least squares regression?
It would be possible in the case where the original model was heteroskedastic and the heteroskedasticity was related to the covariates. For example,
$y_i \sim \text{N}(x_i^T\beta, \sigma^2x_{i,1}^2)
|
44,927
|
Could logistic regression be used to detect large errors in least squares regression?
|
There are circumstances where such a thing might be made to work - assuming you can supply suitable predictors to your logistic regression, but
(i) dichotomizing the spread may be less useful than leaving it continuous
(ii) I think formal hypothesis testing is a bad idea for assessing model assumptions, since it doesn't answer a useful question (imagine, in large samples, a very small trend in spread - it might be highly significant, but really quite unimportant in terms of its impact on the inference in the original model). More important to think about the effect-size (how much impact on our inference?) rather than the significance (is our sample size large enough to detect it?). We almost never satisfy the assumptions exactly, and we don't gain anything from testing what we already know - either we reject, which tells us nothing more than what we knew before, or we don't, which only tells us our sample size was to small to detect what we already know to be the case. Neither tells us how bad the failure of the assumptions might be for us.
|
Could logistic regression be used to detect large errors in least squares regression?
|
There are circumstances where such a thing might be made to work - assuming you can supply suitable predictors to your logistic regression, but
(i) dichotomizing the spread may be less useful than lea
|
Could logistic regression be used to detect large errors in least squares regression?
There are circumstances where such a thing might be made to work - assuming you can supply suitable predictors to your logistic regression, but
(i) dichotomizing the spread may be less useful than leaving it continuous
(ii) I think formal hypothesis testing is a bad idea for assessing model assumptions, since it doesn't answer a useful question (imagine, in large samples, a very small trend in spread - it might be highly significant, but really quite unimportant in terms of its impact on the inference in the original model). More important to think about the effect-size (how much impact on our inference?) rather than the significance (is our sample size large enough to detect it?). We almost never satisfy the assumptions exactly, and we don't gain anything from testing what we already know - either we reject, which tells us nothing more than what we knew before, or we don't, which only tells us our sample size was to small to detect what we already know to be the case. Neither tells us how bad the failure of the assumptions might be for us.
|
Could logistic regression be used to detect large errors in least squares regression?
There are circumstances where such a thing might be made to work - assuming you can supply suitable predictors to your logistic regression, but
(i) dichotomizing the spread may be less useful than lea
|
44,928
|
Two studies, opposite results: Am I allowed to compute an overall mean using random-effect model?
|
I am not an expert, but I think it is common sense to not merge two studies if they have strongly opposite outcomes. For the sake of the example, say they measure a variable $X$ (glucose in the blood etc.) in identical conditions.
Since the outcome is different, you can imagine that there is "something" unknown, so that one of the team measures actually $X + a$. Now does that make sense to merge the records? You end up with a mixture model which is much more difficult to analyze. To give you an example, the mean is meaningless because it will depend mostly on the ratio between the sample sizes.
Addition: Thank you @Michael Chernick for this fantastic quote in the comments below:
Man puts one foot in a bucket on fire and the other in a ice bucket. On average the temperature is normal. You wouldn't want to describe this with the sample mean
|
Two studies, opposite results: Am I allowed to compute an overall mean using random-effect model?
|
I am not an expert, but I think it is common sense to not merge two studies if they have strongly opposite outcomes. For the sake of the example, say they measure a variable $X$ (glucose in the blood
|
Two studies, opposite results: Am I allowed to compute an overall mean using random-effect model?
I am not an expert, but I think it is common sense to not merge two studies if they have strongly opposite outcomes. For the sake of the example, say they measure a variable $X$ (glucose in the blood etc.) in identical conditions.
Since the outcome is different, you can imagine that there is "something" unknown, so that one of the team measures actually $X + a$. Now does that make sense to merge the records? You end up with a mixture model which is much more difficult to analyze. To give you an example, the mean is meaningless because it will depend mostly on the ratio between the sample sizes.
Addition: Thank you @Michael Chernick for this fantastic quote in the comments below:
Man puts one foot in a bucket on fire and the other in a ice bucket. On average the temperature is normal. You wouldn't want to describe this with the sample mean
|
Two studies, opposite results: Am I allowed to compute an overall mean using random-effect model?
I am not an expert, but I think it is common sense to not merge two studies if they have strongly opposite outcomes. For the sake of the example, say they measure a variable $X$ (glucose in the blood
|
44,929
|
Two studies, opposite results: Am I allowed to compute an overall mean using random-effect model?
|
try to find the confounding variable.. see if you get any interactions or mabe run another test with different methodology (and more variables that may give you a clearer picture.
|
Two studies, opposite results: Am I allowed to compute an overall mean using random-effect model?
|
try to find the confounding variable.. see if you get any interactions or mabe run another test with different methodology (and more variables that may give you a clearer picture.
|
Two studies, opposite results: Am I allowed to compute an overall mean using random-effect model?
try to find the confounding variable.. see if you get any interactions or mabe run another test with different methodology (and more variables that may give you a clearer picture.
|
Two studies, opposite results: Am I allowed to compute an overall mean using random-effect model?
try to find the confounding variable.. see if you get any interactions or mabe run another test with different methodology (and more variables that may give you a clearer picture.
|
44,930
|
Two studies, opposite results: Am I allowed to compute an overall mean using random-effect model?
|
Generally, there can not be bimodal findings. The theoretical underpinnings must be considered. Moreover, two sets of outcomes can not be combined in this way. If you are keen to apply meta-analysis, the outcomes showing excellent results and outcomes showing bad results may be meta-anlysed separately. Be sure that number of outcomes (effect-sizes for a group of excellent (or bad) results is more than say, 15. If the effect-sizes are in d-form, you may follow one of the several available random-effects formulas (Hedges and Olkin 1985) for checking the variablity in effect-sizes of r (see Davar 2006).
|
Two studies, opposite results: Am I allowed to compute an overall mean using random-effect model?
|
Generally, there can not be bimodal findings. The theoretical underpinnings must be considered. Moreover, two sets of outcomes can not be combined in this way. If you are keen to apply meta-analysis,
|
Two studies, opposite results: Am I allowed to compute an overall mean using random-effect model?
Generally, there can not be bimodal findings. The theoretical underpinnings must be considered. Moreover, two sets of outcomes can not be combined in this way. If you are keen to apply meta-analysis, the outcomes showing excellent results and outcomes showing bad results may be meta-anlysed separately. Be sure that number of outcomes (effect-sizes for a group of excellent (or bad) results is more than say, 15. If the effect-sizes are in d-form, you may follow one of the several available random-effects formulas (Hedges and Olkin 1985) for checking the variablity in effect-sizes of r (see Davar 2006).
|
Two studies, opposite results: Am I allowed to compute an overall mean using random-effect model?
Generally, there can not be bimodal findings. The theoretical underpinnings must be considered. Moreover, two sets of outcomes can not be combined in this way. If you are keen to apply meta-analysis,
|
44,931
|
How to judge if a datapoint deviates substantially from the norm
|
Outlier detection in time series encompasses a large body of literature. First you would want to have a time series model that fit well to the data when there were no suspect observations. If for example an ARMA model works you might assume that the noise distribution is Gaussian. There are at least two types of outliers. Fox defined them in a 1972 paper. The best source to start with on this subject is the latest edition of Barnett and Lewis' "Outliers in Statistical Data" published by Wiley. They have a chapter on time series. My 1982 paper with Downing took the approach of looking at influence functions for autocorrwlation. Our idea is that if an observation had a big effect on one of more of the lagged correlations it would also affect the model parameters adversely. Martin, Yohai and others defined influence functionals for time series in a different way that seems to have better theoretical justification but addresses the same issue . Ruel Tsay, George Tiao and others have also published work on outliers in time series. I am less familiar with that. But our colleague IrishStat can probably comment on that and more. In the process of improving his autobox software over the years IrishStat and his son Tom have invested time into keeping up on the literature about outliers and level shifts (sometimes called interventions) in order to make their product state-of-the-art.
Just like with outliers in data that are not time dependent any outliers that are detected using time series methods should be studied to see why they occurred. Were they measurement errors? Maybe a change in the behavior of the process? Maybe a temporary intervention (like the Federal Reserve changing interest rates as an example)? The reason if it can be found will dictate how the outlier should be treated.
|
How to judge if a datapoint deviates substantially from the norm
|
Outlier detection in time series encompasses a large body of literature. First you would want to have a time series model that fit well to the data when there were no suspect observations. If for ex
|
How to judge if a datapoint deviates substantially from the norm
Outlier detection in time series encompasses a large body of literature. First you would want to have a time series model that fit well to the data when there were no suspect observations. If for example an ARMA model works you might assume that the noise distribution is Gaussian. There are at least two types of outliers. Fox defined them in a 1972 paper. The best source to start with on this subject is the latest edition of Barnett and Lewis' "Outliers in Statistical Data" published by Wiley. They have a chapter on time series. My 1982 paper with Downing took the approach of looking at influence functions for autocorrwlation. Our idea is that if an observation had a big effect on one of more of the lagged correlations it would also affect the model parameters adversely. Martin, Yohai and others defined influence functionals for time series in a different way that seems to have better theoretical justification but addresses the same issue . Ruel Tsay, George Tiao and others have also published work on outliers in time series. I am less familiar with that. But our colleague IrishStat can probably comment on that and more. In the process of improving his autobox software over the years IrishStat and his son Tom have invested time into keeping up on the literature about outliers and level shifts (sometimes called interventions) in order to make their product state-of-the-art.
Just like with outliers in data that are not time dependent any outliers that are detected using time series methods should be studied to see why they occurred. Were they measurement errors? Maybe a change in the behavior of the process? Maybe a temporary intervention (like the Federal Reserve changing interest rates as an example)? The reason if it can be found will dictate how the outlier should be treated.
|
How to judge if a datapoint deviates substantially from the norm
Outlier detection in time series encompasses a large body of literature. First you would want to have a time series model that fit well to the data when there were no suspect observations. If for ex
|
44,932
|
How to judge if a datapoint deviates substantially from the norm
|
I'm going to say something that's a bit down at the simpler end, in case you end up drowning in ARMA models (although that of course it the correct way to go).
A graph with a fitted line and some measure of variability on could improve your eyeballing. I drew this graph yesterday:
Using this code with ggplot2 in R:
ggplot(mydata, aes(x=Time2, y=Reception, group=1)) + geom_smooth() +
facet_wrap(~Prison) + opts(axis.text.x=theme_text(angle=90, hjust=1)) + geom_point()
There's loads of default options for the smoothing etc., so you don't have to use it out of the box like I have, you can set it up much more nicely than this. But you can see a couple of "outliers" (I use that word loosely) in Prison B straight away.
Or the forecast package in R is very useful too.
As I say, this is more the quick and dirty approach so caveat emptor and all that.
|
How to judge if a datapoint deviates substantially from the norm
|
I'm going to say something that's a bit down at the simpler end, in case you end up drowning in ARMA models (although that of course it the correct way to go).
A graph with a fitted line and some meas
|
How to judge if a datapoint deviates substantially from the norm
I'm going to say something that's a bit down at the simpler end, in case you end up drowning in ARMA models (although that of course it the correct way to go).
A graph with a fitted line and some measure of variability on could improve your eyeballing. I drew this graph yesterday:
Using this code with ggplot2 in R:
ggplot(mydata, aes(x=Time2, y=Reception, group=1)) + geom_smooth() +
facet_wrap(~Prison) + opts(axis.text.x=theme_text(angle=90, hjust=1)) + geom_point()
There's loads of default options for the smoothing etc., so you don't have to use it out of the box like I have, you can set it up much more nicely than this. But you can see a couple of "outliers" (I use that word loosely) in Prison B straight away.
Or the forecast package in R is very useful too.
As I say, this is more the quick and dirty approach so caveat emptor and all that.
|
How to judge if a datapoint deviates substantially from the norm
I'm going to say something that's a bit down at the simpler end, in case you end up drowning in ARMA models (although that of course it the correct way to go).
A graph with a fitted line and some meas
|
44,933
|
Calculating % unsampled in sampling with replacement
|
Let $Z_{ij}$ be the binary indicator that subject $i = 1, ..., N$ was selected as the $j=1,...,k$'th sampled unit. Since the sampling (assumed to be simple random sampling) is with replacement, each of the $Z_{ij}$ are independent bernoulli trials with success probability $1/N$. Therefore the number of times subject $i$ was sampled,
$$ Y_{i} = \sum_{j=1}^{k} Z_{ij}, $$
has a ${\rm Binomial}(k,1/N)$ distribution. So, the probability that a particular unit is not sampled, $P(Y_{i} = 0)$, is calculated from the binomial mass function as
$$ P(Y_{i} = 0) = (1 - 1/N)^{k} $$
So, the indicator of subject $i$ not being sampled, $X_{i} = \mathcal{I}(Y_{i} = 0)$, is a bernoulli trial with success probability $(1 - 1/N)^{k}$. Note that the $Y_{i}$'s are not independent of each other since, for example if $Y_{1} = N$, then you know $Y_{2}, ..., Y_{N}$, are all 0. It follows that the $X_{i}$'s are also probably not independent of each other. Regardless of whether or not they are, linearity of expectation still holds so the expected proportion of the population that is not sampled is
$$ \mu_{k} = E \left( \frac{1}{N} \sum_{i=1}^{N} X_{i}\right) = \frac{1}{N} \sum_{i=1}^{N} E(X_{i}) = \frac{1}{N} \cdot N \cdot (1 - 1/N)^{k} = (1 - 1/N)^{k} $$
Edit: As Mike Anderson points out in his answer, this quantity is well approximated by $e^{-k/N}$. This is an example of the poisson approximation to the binomial, http://en.wikipedia.org/wiki/Binomial_distribution#Poisson_approximation
|
Calculating % unsampled in sampling with replacement
|
Let $Z_{ij}$ be the binary indicator that subject $i = 1, ..., N$ was selected as the $j=1,...,k$'th sampled unit. Since the sampling (assumed to be simple random sampling) is with replacement, each o
|
Calculating % unsampled in sampling with replacement
Let $Z_{ij}$ be the binary indicator that subject $i = 1, ..., N$ was selected as the $j=1,...,k$'th sampled unit. Since the sampling (assumed to be simple random sampling) is with replacement, each of the $Z_{ij}$ are independent bernoulli trials with success probability $1/N$. Therefore the number of times subject $i$ was sampled,
$$ Y_{i} = \sum_{j=1}^{k} Z_{ij}, $$
has a ${\rm Binomial}(k,1/N)$ distribution. So, the probability that a particular unit is not sampled, $P(Y_{i} = 0)$, is calculated from the binomial mass function as
$$ P(Y_{i} = 0) = (1 - 1/N)^{k} $$
So, the indicator of subject $i$ not being sampled, $X_{i} = \mathcal{I}(Y_{i} = 0)$, is a bernoulli trial with success probability $(1 - 1/N)^{k}$. Note that the $Y_{i}$'s are not independent of each other since, for example if $Y_{1} = N$, then you know $Y_{2}, ..., Y_{N}$, are all 0. It follows that the $X_{i}$'s are also probably not independent of each other. Regardless of whether or not they are, linearity of expectation still holds so the expected proportion of the population that is not sampled is
$$ \mu_{k} = E \left( \frac{1}{N} \sum_{i=1}^{N} X_{i}\right) = \frac{1}{N} \sum_{i=1}^{N} E(X_{i}) = \frac{1}{N} \cdot N \cdot (1 - 1/N)^{k} = (1 - 1/N)^{k} $$
Edit: As Mike Anderson points out in his answer, this quantity is well approximated by $e^{-k/N}$. This is an example of the poisson approximation to the binomial, http://en.wikipedia.org/wiki/Binomial_distribution#Poisson_approximation
|
Calculating % unsampled in sampling with replacement
Let $Z_{ij}$ be the binary indicator that subject $i = 1, ..., N$ was selected as the $j=1,...,k$'th sampled unit. Since the sampling (assumed to be simple random sampling) is with replacement, each o
|
44,934
|
Calculating % unsampled in sampling with replacement
|
If $N$ is large, the distribution of per item sampling frequencies is approximately Poisson distributed, with mean $k/N$. So you can estimate the unsampled proportion as $e^{-k/N}$. An exact solution for small $N$ is a bit of a chore to derive.
|
Calculating % unsampled in sampling with replacement
|
If $N$ is large, the distribution of per item sampling frequencies is approximately Poisson distributed, with mean $k/N$. So you can estimate the unsampled proportion as $e^{-k/N}$. An exact solutio
|
Calculating % unsampled in sampling with replacement
If $N$ is large, the distribution of per item sampling frequencies is approximately Poisson distributed, with mean $k/N$. So you can estimate the unsampled proportion as $e^{-k/N}$. An exact solution for small $N$ is a bit of a chore to derive.
|
Calculating % unsampled in sampling with replacement
If $N$ is large, the distribution of per item sampling frequencies is approximately Poisson distributed, with mean $k/N$. So you can estimate the unsampled proportion as $e^{-k/N}$. An exact solutio
|
44,935
|
How to plot a learning curve based on a sequence of date stamped successes and failures?
|
If your dates are in string or factor form, convert them to Dates with as.Date(DateVariable, format="%Y-%m-%d") (potentially with an as.character around DateVariable if it is a factor.
Sort the data.frame with the date and outcome by surgery date. To get the y variable you describe, the easiest way is to take the cumulative number of outcomes and divide by the number of cases to date (which is just a running sequence from 1 to the number of cases when sorted). In code:
#Make some random data to play with
DF <- data.frame(DateVariable = as.Date(runif(100, 0, 800), origin="2005-01-01"),
outcome = rbinom(100, 1, 0.1))
#Sort by date
DF <- DF[order(DF$DateVariable),]
DF <- rbind.fill(data.frame(outcome=1),DF)
#Add case numbers (in order, since sorted)
DF$x <- seq(length=nrow(DF))
#Create your definition for y (average to date, which is sum to date divided by number to date)
DF$y <- cumsum(DF$outcome) / DF$x
#Plot it
library(ggplot2)
ggplot(DF, aes(x,y)) +
geom_point(shape=4) +
geom_point(aes(x,outcome),shape=3) +
stat_smooth(method="loess", se=FALSE, color="darkgreen", size=1) +
scale_y_continuous(name= "Failure rate", limits=c(0, 1)) +
scale_x_continuous(name= "Operations performed")
Result:
(plus marks success and error cases. X - cumulative sum, line - loess curve)
I don't think, however, this is a good metric. Check out some work on CUSUM curves and risk adjusted CUSUM curves. CUSUM is just plotting number of (negative) outcomes versus case number; risk adjusted CUSUM assumes you can determine a probability of negative outcome (based on pre-operative variables) and use that to determine if performance is exceeding or lagging expectations.
|
How to plot a learning curve based on a sequence of date stamped successes and failures?
|
If your dates are in string or factor form, convert them to Dates with as.Date(DateVariable, format="%Y-%m-%d") (potentially with an as.character around DateVariable if it is a factor.
Sort the data.f
|
How to plot a learning curve based on a sequence of date stamped successes and failures?
If your dates are in string or factor form, convert them to Dates with as.Date(DateVariable, format="%Y-%m-%d") (potentially with an as.character around DateVariable if it is a factor.
Sort the data.frame with the date and outcome by surgery date. To get the y variable you describe, the easiest way is to take the cumulative number of outcomes and divide by the number of cases to date (which is just a running sequence from 1 to the number of cases when sorted). In code:
#Make some random data to play with
DF <- data.frame(DateVariable = as.Date(runif(100, 0, 800), origin="2005-01-01"),
outcome = rbinom(100, 1, 0.1))
#Sort by date
DF <- DF[order(DF$DateVariable),]
DF <- rbind.fill(data.frame(outcome=1),DF)
#Add case numbers (in order, since sorted)
DF$x <- seq(length=nrow(DF))
#Create your definition for y (average to date, which is sum to date divided by number to date)
DF$y <- cumsum(DF$outcome) / DF$x
#Plot it
library(ggplot2)
ggplot(DF, aes(x,y)) +
geom_point(shape=4) +
geom_point(aes(x,outcome),shape=3) +
stat_smooth(method="loess", se=FALSE, color="darkgreen", size=1) +
scale_y_continuous(name= "Failure rate", limits=c(0, 1)) +
scale_x_continuous(name= "Operations performed")
Result:
(plus marks success and error cases. X - cumulative sum, line - loess curve)
I don't think, however, this is a good metric. Check out some work on CUSUM curves and risk adjusted CUSUM curves. CUSUM is just plotting number of (negative) outcomes versus case number; risk adjusted CUSUM assumes you can determine a probability of negative outcome (based on pre-operative variables) and use that to determine if performance is exceeding or lagging expectations.
|
How to plot a learning curve based on a sequence of date stamped successes and failures?
If your dates are in string or factor form, convert them to Dates with as.Date(DateVariable, format="%Y-%m-%d") (potentially with an as.character around DateVariable if it is a factor.
Sort the data.f
|
44,936
|
How to plot a learning curve based on a sequence of date stamped successes and failures?
|
An informative "learning curve" will indicate the current performance of success. A cumulative average, however, doesn't do that, because it includes old results along with the new. When learning truly improves, the cumulative average will be biased low.
A good solution is to use a Lowess smooth of the response plotted over time. This robust nonparametric smoother is implemented in many R packages: search for the current choices on the RSeek page.
As an example, here is a scatterplot of simulated data, their cumulative average, and a Lowess smooth of the data:
The green (upper) curve is the Lowess smooth. (This coding uses 1 for success, 0 for failure, so that an improving curve slopes upward.) The two curves differ substantially: the cumulative average barely has a positive slope (about 0.0015) and ends up around 0.5 at the most recent time, whereas the Lowess smooth has a slope around .005 (over three times as great) and ends up around 0.85. To get a sense of which is correct, consider the most recent responses, say those after time=80: there are 26 of them averaging 0.77. The Lowess curve is consistent with that level during this period but the cumulative average curve is clearly too low.
(This is a standard exploratory technique to prepare for logistic regression. If, on a logit scale, the Lowess smooth is approximately linear, then logistic regression of the response versus time should work well to model the learning curve. If the smooth is not linear, you could consider logistic regression with cubic splines, allowing for changes in slope over time.)
|
How to plot a learning curve based on a sequence of date stamped successes and failures?
|
An informative "learning curve" will indicate the current performance of success. A cumulative average, however, doesn't do that, because it includes old results along with the new. When learning tr
|
How to plot a learning curve based on a sequence of date stamped successes and failures?
An informative "learning curve" will indicate the current performance of success. A cumulative average, however, doesn't do that, because it includes old results along with the new. When learning truly improves, the cumulative average will be biased low.
A good solution is to use a Lowess smooth of the response plotted over time. This robust nonparametric smoother is implemented in many R packages: search for the current choices on the RSeek page.
As an example, here is a scatterplot of simulated data, their cumulative average, and a Lowess smooth of the data:
The green (upper) curve is the Lowess smooth. (This coding uses 1 for success, 0 for failure, so that an improving curve slopes upward.) The two curves differ substantially: the cumulative average barely has a positive slope (about 0.0015) and ends up around 0.5 at the most recent time, whereas the Lowess smooth has a slope around .005 (over three times as great) and ends up around 0.85. To get a sense of which is correct, consider the most recent responses, say those after time=80: there are 26 of them averaging 0.77. The Lowess curve is consistent with that level during this period but the cumulative average curve is clearly too low.
(This is a standard exploratory technique to prepare for logistic regression. If, on a logit scale, the Lowess smooth is approximately linear, then logistic regression of the response versus time should work well to model the learning curve. If the smooth is not linear, you could consider logistic regression with cubic splines, allowing for changes in slope over time.)
|
How to plot a learning curve based on a sequence of date stamped successes and failures?
An informative "learning curve" will indicate the current performance of success. A cumulative average, however, doesn't do that, because it includes old results along with the new. When learning tr
|
44,937
|
How to plot a learning curve based on a sequence of date stamped successes and failures?
|
Use as.POSIXct to convert to dates, which are stored as seconds from the epoch (and are thus easily plotted) but can be easily displayed in human-readable formats. The help file documents how to import from arbitrary character representations.
Use geom_line for plotting. You can use aggregate or by to bin the observations into days or weeks or whatever. I think ggplot2 has some native functionality for this as well.
I don't know much about learning curves, but I suspect that describing your overall goal more, rather than just the math, would help other people suggest whether the $\frac{successful}{total}$ statistic would tell you what you want to know.
|
How to plot a learning curve based on a sequence of date stamped successes and failures?
|
Use as.POSIXct to convert to dates, which are stored as seconds from the epoch (and are thus easily plotted) but can be easily displayed in human-readable formats. The help file documents how to impor
|
How to plot a learning curve based on a sequence of date stamped successes and failures?
Use as.POSIXct to convert to dates, which are stored as seconds from the epoch (and are thus easily plotted) but can be easily displayed in human-readable formats. The help file documents how to import from arbitrary character representations.
Use geom_line for plotting. You can use aggregate or by to bin the observations into days or weeks or whatever. I think ggplot2 has some native functionality for this as well.
I don't know much about learning curves, but I suspect that describing your overall goal more, rather than just the math, would help other people suggest whether the $\frac{successful}{total}$ statistic would tell you what you want to know.
|
How to plot a learning curve based on a sequence of date stamped successes and failures?
Use as.POSIXct to convert to dates, which are stored as seconds from the epoch (and are thus easily plotted) but can be easily displayed in human-readable formats. The help file documents how to impor
|
44,938
|
Intra- and inter-rater reliability on the same data
|
I assume that A through D are different symptoms, say, and 1 and 2 are the two raters. As you tagged this in Stata, I will build a Stata example. Let us first simulate some data: we have a bunch of subjects with two uncorrelated traits, and a battery of questions, tapping upon these traits. The two raters have different sensitivities to each of the traits: the first rater is a tad more likely than the second rater to give a positive answer on question A, but slightly less likely to give a positive answer on question B, etc.
clear
set seed 10101
set obs 200
* generate orthogonal individual traits
generate trait1 = rnormal()
generate trait2 = rnormal()
* raters' interecepts for individual questions
local q1list 0.3 0.7 -0.2 -0.4
local q2list 0.5 0.5 0 -0.5
* prefixes
local letters a b c d
forvalues k = 1/4 {
local thisletter : word `k' of `letters'
local rater1 : word `k' of `q1list'
local rater2 : word `k' of `q2list'
generate byte `thisletter'1 = ( `k'/3*trait1 + (3-`k')/5*trait2 + 0.3*rnormal() > `rater1' )
generate byte `thisletter'2 = ( `k'/3*trait1 + (3-`k')/5*trait2 + 0.3*rnormal() > `rater2' )
}
This should produce something like
. list a1-d2 in 1/5, noobs
+---------------------------------------+
| a1 a2 b1 b2 c1 c2 d1 d2 |
|---------------------------------------|
| 1 1 0 0 1 0 1 1 |
| 0 0 0 0 0 1 1 1 |
| 0 0 0 0 0 0 0 0 |
| 1 0 0 1 1 1 1 1 |
| 0 0 0 1 1 1 1 1 |
+---------------------------------------+
which I hope resembles your data, at least in terms of the existing variables.
A fully non-parametric summary of the inter-rater agreement can be constructed by converting the binary representation into a decimal representation. The outcome a1=0, b1=0, c1=0, c4=0 is 0000b=0; the outcome in the first observation is 1011b = 11, etc. Let us produce this encoding:
generate int pattern1 = 0
generate int pattern2 = 0
forvalues k = 1/4 {
local thisletter : word `k' of `letters'
replace pattern1 = pattern1 + `thisletter'1 * 2^(4-`k')
replace pattern2 = pattern2 + `thisletter'2 * 2^(4-`k')
tab pattern*
}
This should produce something like
. list a1- d2 pat* in 1/5, noobs
+-------------------------------------------------------------+
| a1 a2 b1 b2 c1 c2 d1 d2 pattern1 pattern2 |
|-------------------------------------------------------------|
| 1 1 0 0 1 0 1 1 11 9 |
| 0 0 0 0 0 1 1 1 1 3 |
| 0 0 0 0 0 0 0 0 0 0 |
| 1 0 0 1 1 1 1 1 11 7 |
| 0 0 0 1 1 1 1 1 3 7 |
+-------------------------------------------------------------+
Now, these patterns are perfectly comparable using kap:
. kap pattern1 pattern2
Agreement Exp.Agrmt Kappa Std. Err. Z Prob>Z
-----------------------------------------------------------------
54.00% 17.91% 0.4396 0.0308 14.25 0.0000
You can play with the sample size or with the differences between raters to produce a non-significant answer :). This kappa suffers from a serious drawback: it does not reflect the fact of having some common items: the patterns 0001 and 0000, even though they match by 75%, would be considered non-matches within this approach. So it is an extremely conservative measure of the inter-rater agreement.
To get fair estimates of all the ICCs, you would need to run a cross-classified mixed model. Let us first reshape the data to make it possible:
generate long id = _n
* reshape the raters
reshape long a b c d , i(id) j(rater 1 2)
* reshape the items
forvalues k = 1/4 {
local thisletter : word `k' of `letters'
rename `thisletter' q`k'
}
reshape long q , i(id rater) j(item 1 2 3 4)
Now, we can run xtmelogit (or gllamm if you like it better) on this data:
. xtmelogit q || _all : R.rater || _all: R.item || _all: R.id, nolog
Note: factor variables specified; option laplace assumed
Mixed-effects logistic regression Number of obs = 1600
Group variable: _all Number of groups = 1
Obs per group:
min = 1600
avg = 1600.0
max = 1600
Integration points = 1 Wald chi2(0) = .
Log likelihood = -697.55526 Prob > chi2 = .
------------------------------------------------------------------------------
q | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_cons | -.7795316 .9384147 -0.83 0.406 -2.618791 1.059727
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
_all: Identity |
sd(R.rater) | .1407056 .1627763 .0145745 1.358408
-----------------------------+------------------------------------------------
_all: Identity |
sd(R.item) | 1.797133 .6461083 .8882897 3.635847
-----------------------------+------------------------------------------------
_all: Identity |
sd(R.id) | 3.18933 .2673165 2.706171 3.758751
------------------------------------------------------------------------------
LR test vs. logistic regression: chi2(3) = 793.71 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
Note: log-likelihood calculations are based on the Laplacian approximation.
This is a cross-classified model with three random effects: subjects, raters and items, assuming that they are uncorrelated (which is wrong for this data; see below). Let us now estimate the ICCs:
. local Vrater ( exp(2*_b[lns1_1_1:_cons]) )
. local Vitem ( exp(2*_b[lns1_2_1:_cons]) )
. local Vid ( exp(2*_b[lns1_3_1:_cons]) )
. nlcom `Vrater' / (`Vrater' + `Vitem' + `Vid' + _pi*_pi/3 )
-----------------------------------------------------------------------
q | Coef. Std. Err. z P>|z| [95% Conf. Interval]
------+----------------------------------------------------------------
_nl_1 | .0011847 .0027384 0.43 0.665 -.0041824 .0065519
-----------------------------------------------------------------------
. nlcom `Vid' / (`Vrater' + `Vitem' + `Vid' + _pi*_pi/3 )
------------------------------------------------------------------------
q | Coef. Std. Err. z P>|z| [95% Conf. Interval]
------+----------------------------------------------------------------
_nl_1 | .6086839 .0903816 6.73 0.000 .4315393 .7858285
------------------------------------------------------------------------
. nlcom `Vitem' / (`Vrater' + `Vitem' + `Vid' + _pi*_pi/3 )
-----------------------------------------------------------------------
q | Coef. Std. Err. z P>|z| [95% Conf. Interval]
------+----------------------------------------------------------------
_nl_1 | .193265 .1121376 1.72 0.085 -.0265206 .4130506
-----------------------------------------------------------------------
(Hint: I figured out the names of the parameters by matrix list e(b).)
These are ICCs corresponding to raters, subjects and items, respectively. The zero ICC of the raters actually makes sense in the context of how the data were generated: there is no systematic effect in the sense that one rater consistently rates the condition better or worse than the other rater. There is an interaction between rater and item, but the model does not reflect it. True to life would be something like
xtmelogit q ibn.item##ibn.rater, nocons || id:
With this specification, you would have to get ICCs by an even more complicated mix of the variance components and the point estimates from the fixed effects part of the model.
If you have the patience (or a powerful computer), you can specify intp(7) or something like that to get an approximation more accurate than the Laplace approximation (a single point at the mode of the distribution of the random effects).
|
Intra- and inter-rater reliability on the same data
|
I assume that A through D are different symptoms, say, and 1 and 2 are the two raters. As you tagged this in Stata, I will build a Stata example. Let us first simulate some data: we have a bunch of su
|
Intra- and inter-rater reliability on the same data
I assume that A through D are different symptoms, say, and 1 and 2 are the two raters. As you tagged this in Stata, I will build a Stata example. Let us first simulate some data: we have a bunch of subjects with two uncorrelated traits, and a battery of questions, tapping upon these traits. The two raters have different sensitivities to each of the traits: the first rater is a tad more likely than the second rater to give a positive answer on question A, but slightly less likely to give a positive answer on question B, etc.
clear
set seed 10101
set obs 200
* generate orthogonal individual traits
generate trait1 = rnormal()
generate trait2 = rnormal()
* raters' interecepts for individual questions
local q1list 0.3 0.7 -0.2 -0.4
local q2list 0.5 0.5 0 -0.5
* prefixes
local letters a b c d
forvalues k = 1/4 {
local thisletter : word `k' of `letters'
local rater1 : word `k' of `q1list'
local rater2 : word `k' of `q2list'
generate byte `thisletter'1 = ( `k'/3*trait1 + (3-`k')/5*trait2 + 0.3*rnormal() > `rater1' )
generate byte `thisletter'2 = ( `k'/3*trait1 + (3-`k')/5*trait2 + 0.3*rnormal() > `rater2' )
}
This should produce something like
. list a1-d2 in 1/5, noobs
+---------------------------------------+
| a1 a2 b1 b2 c1 c2 d1 d2 |
|---------------------------------------|
| 1 1 0 0 1 0 1 1 |
| 0 0 0 0 0 1 1 1 |
| 0 0 0 0 0 0 0 0 |
| 1 0 0 1 1 1 1 1 |
| 0 0 0 1 1 1 1 1 |
+---------------------------------------+
which I hope resembles your data, at least in terms of the existing variables.
A fully non-parametric summary of the inter-rater agreement can be constructed by converting the binary representation into a decimal representation. The outcome a1=0, b1=0, c1=0, c4=0 is 0000b=0; the outcome in the first observation is 1011b = 11, etc. Let us produce this encoding:
generate int pattern1 = 0
generate int pattern2 = 0
forvalues k = 1/4 {
local thisletter : word `k' of `letters'
replace pattern1 = pattern1 + `thisletter'1 * 2^(4-`k')
replace pattern2 = pattern2 + `thisletter'2 * 2^(4-`k')
tab pattern*
}
This should produce something like
. list a1- d2 pat* in 1/5, noobs
+-------------------------------------------------------------+
| a1 a2 b1 b2 c1 c2 d1 d2 pattern1 pattern2 |
|-------------------------------------------------------------|
| 1 1 0 0 1 0 1 1 11 9 |
| 0 0 0 0 0 1 1 1 1 3 |
| 0 0 0 0 0 0 0 0 0 0 |
| 1 0 0 1 1 1 1 1 11 7 |
| 0 0 0 1 1 1 1 1 3 7 |
+-------------------------------------------------------------+
Now, these patterns are perfectly comparable using kap:
. kap pattern1 pattern2
Agreement Exp.Agrmt Kappa Std. Err. Z Prob>Z
-----------------------------------------------------------------
54.00% 17.91% 0.4396 0.0308 14.25 0.0000
You can play with the sample size or with the differences between raters to produce a non-significant answer :). This kappa suffers from a serious drawback: it does not reflect the fact of having some common items: the patterns 0001 and 0000, even though they match by 75%, would be considered non-matches within this approach. So it is an extremely conservative measure of the inter-rater agreement.
To get fair estimates of all the ICCs, you would need to run a cross-classified mixed model. Let us first reshape the data to make it possible:
generate long id = _n
* reshape the raters
reshape long a b c d , i(id) j(rater 1 2)
* reshape the items
forvalues k = 1/4 {
local thisletter : word `k' of `letters'
rename `thisletter' q`k'
}
reshape long q , i(id rater) j(item 1 2 3 4)
Now, we can run xtmelogit (or gllamm if you like it better) on this data:
. xtmelogit q || _all : R.rater || _all: R.item || _all: R.id, nolog
Note: factor variables specified; option laplace assumed
Mixed-effects logistic regression Number of obs = 1600
Group variable: _all Number of groups = 1
Obs per group:
min = 1600
avg = 1600.0
max = 1600
Integration points = 1 Wald chi2(0) = .
Log likelihood = -697.55526 Prob > chi2 = .
------------------------------------------------------------------------------
q | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_cons | -.7795316 .9384147 -0.83 0.406 -2.618791 1.059727
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
_all: Identity |
sd(R.rater) | .1407056 .1627763 .0145745 1.358408
-----------------------------+------------------------------------------------
_all: Identity |
sd(R.item) | 1.797133 .6461083 .8882897 3.635847
-----------------------------+------------------------------------------------
_all: Identity |
sd(R.id) | 3.18933 .2673165 2.706171 3.758751
------------------------------------------------------------------------------
LR test vs. logistic regression: chi2(3) = 793.71 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
Note: log-likelihood calculations are based on the Laplacian approximation.
This is a cross-classified model with three random effects: subjects, raters and items, assuming that they are uncorrelated (which is wrong for this data; see below). Let us now estimate the ICCs:
. local Vrater ( exp(2*_b[lns1_1_1:_cons]) )
. local Vitem ( exp(2*_b[lns1_2_1:_cons]) )
. local Vid ( exp(2*_b[lns1_3_1:_cons]) )
. nlcom `Vrater' / (`Vrater' + `Vitem' + `Vid' + _pi*_pi/3 )
-----------------------------------------------------------------------
q | Coef. Std. Err. z P>|z| [95% Conf. Interval]
------+----------------------------------------------------------------
_nl_1 | .0011847 .0027384 0.43 0.665 -.0041824 .0065519
-----------------------------------------------------------------------
. nlcom `Vid' / (`Vrater' + `Vitem' + `Vid' + _pi*_pi/3 )
------------------------------------------------------------------------
q | Coef. Std. Err. z P>|z| [95% Conf. Interval]
------+----------------------------------------------------------------
_nl_1 | .6086839 .0903816 6.73 0.000 .4315393 .7858285
------------------------------------------------------------------------
. nlcom `Vitem' / (`Vrater' + `Vitem' + `Vid' + _pi*_pi/3 )
-----------------------------------------------------------------------
q | Coef. Std. Err. z P>|z| [95% Conf. Interval]
------+----------------------------------------------------------------
_nl_1 | .193265 .1121376 1.72 0.085 -.0265206 .4130506
-----------------------------------------------------------------------
(Hint: I figured out the names of the parameters by matrix list e(b).)
These are ICCs corresponding to raters, subjects and items, respectively. The zero ICC of the raters actually makes sense in the context of how the data were generated: there is no systematic effect in the sense that one rater consistently rates the condition better or worse than the other rater. There is an interaction between rater and item, but the model does not reflect it. True to life would be something like
xtmelogit q ibn.item##ibn.rater, nocons || id:
With this specification, you would have to get ICCs by an even more complicated mix of the variance components and the point estimates from the fixed effects part of the model.
If you have the patience (or a powerful computer), you can specify intp(7) or something like that to get an approximation more accurate than the Laplace approximation (a single point at the mode of the distribution of the random effects).
|
Intra- and inter-rater reliability on the same data
I assume that A through D are different symptoms, say, and 1 and 2 are the two raters. As you tagged this in Stata, I will build a Stata example. Let us first simulate some data: we have a bunch of su
|
44,939
|
Combining 2 sets of coefficients, weighting one of the sets
|
You are retaining $p$ (=3 in this case) values for each regression: the estimated coefficients. If you are willing to retain $p(p+1)$ (=12) values per regression, you can weight your results in a way that is equivalent to having all the data and performing a weighted least squares regression with them en masse.
The analysis is simple: let $X_1$ be the design matrix (i.e., an $n_1$ by $p$ matrix of independent variable values) for the first year and $y_1$ be the $n_1$-vector of dependent values for that year. The estimated coefficients are
$$\hat{\beta}_1 = \left( X_1' X_1 \right)^{-1} X_1' y_1.$$
Let the subscript $2$ designate the same quantities for the second year. Suppose you would like to uniformly weight all observations with (positive) values $w_1^2$ and $w_2^2$ in those two years. The design matrix $X$ is the vertical concatenation of $X_1$ and $X_2$, an $n_1+n_2$ by $p$ matrix, and similarly the vector of dependent values $y$ is the vertical concatenation of $y_1$ and $y_2$. Let $W$ be the diagonal matrix with values $w_1$ along the first $n_1$ places and $w_2$ along the last $n_2$ places. The weighted least squares solution is
$$\hat{\beta} = \left( (W X)' (W X) \right)^{-1} (W X)' W y.$$
However, $(W X)' (W X)$ = $X' W'W X$ is the vertical concatenation of $X_1 W_1 W_1' X_1$ and $X_2 W_2 W_2' X_1$. Because both $W_1 W_1'$ and $W_2 W_2'$ are multiples of identity matrices, they factor through, giving
$$\hat{\beta} = \left( w_1^2 X_1' X_1 + w_2^2 X_2' X_2 \right)^{-1} \left(w_1 X_1 y_1 + w_2 X_2 y_2\right).$$
Notice that $X_1' X_1$ and $X_2' X_2$ are just $p$ by $p$ matrices and that $X_1 y_1$ and $X_2 y_2$ are just $p$-vectors. Therefore you can obtain $\hat{\beta}$ just from the two $p$ by $p$ matrices, the two $p$-vectors, and the two numbers $w_1$ and $w_2$.
This approach generalizes in an obvious way when more than two regressions are involved. It shows, incidentally, that the weighted combination $w_1^2 \hat{\beta_1} + w_2^2 \hat{\beta_2}$ as suggested in the question will not in general equal the weighted least-squares solution. Therefore, if you are using least squares for any of its optimality properties, you should not want to use this seductively simple solution, because it will be suboptimal.
In conclusion, if you would store the 12 numbers $X_i' X_i$ and $X_i' y_i$ each year, then retrospectively (without needing the original data) you can fit any regression on all the data for any set of positive weights without any loss of information.
I would recommend saving some additional values such as the estimated error variances: these will help you detect changes in variability over time (heteroscedasticity).
|
Combining 2 sets of coefficients, weighting one of the sets
|
You are retaining $p$ (=3 in this case) values for each regression: the estimated coefficients. If you are willing to retain $p(p+1)$ (=12) values per regression, you can weight your results in a way
|
Combining 2 sets of coefficients, weighting one of the sets
You are retaining $p$ (=3 in this case) values for each regression: the estimated coefficients. If you are willing to retain $p(p+1)$ (=12) values per regression, you can weight your results in a way that is equivalent to having all the data and performing a weighted least squares regression with them en masse.
The analysis is simple: let $X_1$ be the design matrix (i.e., an $n_1$ by $p$ matrix of independent variable values) for the first year and $y_1$ be the $n_1$-vector of dependent values for that year. The estimated coefficients are
$$\hat{\beta}_1 = \left( X_1' X_1 \right)^{-1} X_1' y_1.$$
Let the subscript $2$ designate the same quantities for the second year. Suppose you would like to uniformly weight all observations with (positive) values $w_1^2$ and $w_2^2$ in those two years. The design matrix $X$ is the vertical concatenation of $X_1$ and $X_2$, an $n_1+n_2$ by $p$ matrix, and similarly the vector of dependent values $y$ is the vertical concatenation of $y_1$ and $y_2$. Let $W$ be the diagonal matrix with values $w_1$ along the first $n_1$ places and $w_2$ along the last $n_2$ places. The weighted least squares solution is
$$\hat{\beta} = \left( (W X)' (W X) \right)^{-1} (W X)' W y.$$
However, $(W X)' (W X)$ = $X' W'W X$ is the vertical concatenation of $X_1 W_1 W_1' X_1$ and $X_2 W_2 W_2' X_1$. Because both $W_1 W_1'$ and $W_2 W_2'$ are multiples of identity matrices, they factor through, giving
$$\hat{\beta} = \left( w_1^2 X_1' X_1 + w_2^2 X_2' X_2 \right)^{-1} \left(w_1 X_1 y_1 + w_2 X_2 y_2\right).$$
Notice that $X_1' X_1$ and $X_2' X_2$ are just $p$ by $p$ matrices and that $X_1 y_1$ and $X_2 y_2$ are just $p$-vectors. Therefore you can obtain $\hat{\beta}$ just from the two $p$ by $p$ matrices, the two $p$-vectors, and the two numbers $w_1$ and $w_2$.
This approach generalizes in an obvious way when more than two regressions are involved. It shows, incidentally, that the weighted combination $w_1^2 \hat{\beta_1} + w_2^2 \hat{\beta_2}$ as suggested in the question will not in general equal the weighted least-squares solution. Therefore, if you are using least squares for any of its optimality properties, you should not want to use this seductively simple solution, because it will be suboptimal.
In conclusion, if you would store the 12 numbers $X_i' X_i$ and $X_i' y_i$ each year, then retrospectively (without needing the original data) you can fit any regression on all the data for any set of positive weights without any loss of information.
I would recommend saving some additional values such as the estimated error variances: these will help you detect changes in variability over time (heteroscedasticity).
|
Combining 2 sets of coefficients, weighting one of the sets
You are retaining $p$ (=3 in this case) values for each regression: the estimated coefficients. If you are willing to retain $p(p+1)$ (=12) values per regression, you can weight your results in a way
|
44,940
|
Combining 2 sets of coefficients, weighting one of the sets
|
This is "taylor made" almost for a Bayesian regression. First of all, there is nothing "fundamentally wrong" with what you suggest. You result may not be optimal by some mathematical standard, but it will almost certainly be optimal time wise. Most other methods will involve much more time than a straight multiplication and division.
I would use a normal likelihood $(y_i|\beta,\sigma,x_i,I)\sim N(x_i^T\beta,\sigma^2)$ and the "jeffreys prior" $p(\beta,\sigma|x_i,I) \propto \frac{1}{\sigma}$. This gives a posterior for $\beta$ as a multivariate t-distribution, with scale matrix $s^2(X^TX)^{-1}$ and mean vector $\beta_{ols}$ with the standard $n-p$ degrees of freedom. Now you simply use this posterior based on the "A" data set as the prior for the "B" data set. Now because you have a "t" prior and a "normal" likelihood, the posterior for beta will favour the normal likelihood, because the t has fatter tails - hence less "pulling power". This regression will balance the A and B regression between how accurately A was estimated, and how well the B estimate fits the data.
An "add-hoc" way that you could add more weight to "B" is by setting the degrees of freedom to 1 in the "A" posterior. But then you may as well save some time and do the multiply the B estimate by two.
I don't think there is a simple analytic expression for this posterior, so will likely need to simulate. But you only require the estimate from the "A" data set, and the covariance matrix from the "A" data set, and the number of observations in the "A" data set. Once you have these quantities, you don't require the original data set.
|
Combining 2 sets of coefficients, weighting one of the sets
|
This is "taylor made" almost for a Bayesian regression. First of all, there is nothing "fundamentally wrong" with what you suggest. You result may not be optimal by some mathematical standard, but i
|
Combining 2 sets of coefficients, weighting one of the sets
This is "taylor made" almost for a Bayesian regression. First of all, there is nothing "fundamentally wrong" with what you suggest. You result may not be optimal by some mathematical standard, but it will almost certainly be optimal time wise. Most other methods will involve much more time than a straight multiplication and division.
I would use a normal likelihood $(y_i|\beta,\sigma,x_i,I)\sim N(x_i^T\beta,\sigma^2)$ and the "jeffreys prior" $p(\beta,\sigma|x_i,I) \propto \frac{1}{\sigma}$. This gives a posterior for $\beta$ as a multivariate t-distribution, with scale matrix $s^2(X^TX)^{-1}$ and mean vector $\beta_{ols}$ with the standard $n-p$ degrees of freedom. Now you simply use this posterior based on the "A" data set as the prior for the "B" data set. Now because you have a "t" prior and a "normal" likelihood, the posterior for beta will favour the normal likelihood, because the t has fatter tails - hence less "pulling power". This regression will balance the A and B regression between how accurately A was estimated, and how well the B estimate fits the data.
An "add-hoc" way that you could add more weight to "B" is by setting the degrees of freedom to 1 in the "A" posterior. But then you may as well save some time and do the multiply the B estimate by two.
I don't think there is a simple analytic expression for this posterior, so will likely need to simulate. But you only require the estimate from the "A" data set, and the covariance matrix from the "A" data set, and the number of observations in the "A" data set. Once you have these quantities, you don't require the original data set.
|
Combining 2 sets of coefficients, weighting one of the sets
This is "taylor made" almost for a Bayesian regression. First of all, there is nothing "fundamentally wrong" with what you suggest. You result may not be optimal by some mathematical standard, but i
|
44,941
|
Combining 2 sets of coefficients, weighting one of the sets
|
There is no reason accounting for the use of convex linear combinations of coefficients in order to "average" two models.
At best, you could consider the three coefficients for each dataset are realizations of the same three random variables, and you would be interested in the distribution of each random variable.
What I would do would be to fit the model again with a new dataset (of size $n$) consisting of a random sample of size $\lambda\times n$ taken from the B dataset, and $\left(1-\lambda\right)\times n$ of the A dataset. You could use $\lambda=\frac{2}{3}$ for instance.
|
Combining 2 sets of coefficients, weighting one of the sets
|
There is no reason accounting for the use of convex linear combinations of coefficients in order to "average" two models.
At best, you could consider the three coefficients for each dataset are realiz
|
Combining 2 sets of coefficients, weighting one of the sets
There is no reason accounting for the use of convex linear combinations of coefficients in order to "average" two models.
At best, you could consider the three coefficients for each dataset are realizations of the same three random variables, and you would be interested in the distribution of each random variable.
What I would do would be to fit the model again with a new dataset (of size $n$) consisting of a random sample of size $\lambda\times n$ taken from the B dataset, and $\left(1-\lambda\right)\times n$ of the A dataset. You could use $\lambda=\frac{2}{3}$ for instance.
|
Combining 2 sets of coefficients, weighting one of the sets
There is no reason accounting for the use of convex linear combinations of coefficients in order to "average" two models.
At best, you could consider the three coefficients for each dataset are realiz
|
44,942
|
Combining 2 sets of coefficients, weighting one of the sets
|
Maybe you should look into "stacking". Or even "feature-weighed stacking".
The former is using a cross validation method to determine the weights you should use to linearly stack them. The latter is using "meta-parameters" to give even more insight on how to weight the parameters depending on what is being predicted. This is a method that the #2 Netflix competition team developed. http://arxiv.org/abs/0911.0460
|
Combining 2 sets of coefficients, weighting one of the sets
|
Maybe you should look into "stacking". Or even "feature-weighed stacking".
The former is using a cross validation method to determine the weights you should use to linearly stack them. The latter is u
|
Combining 2 sets of coefficients, weighting one of the sets
Maybe you should look into "stacking". Or even "feature-weighed stacking".
The former is using a cross validation method to determine the weights you should use to linearly stack them. The latter is using "meta-parameters" to give even more insight on how to weight the parameters depending on what is being predicted. This is a method that the #2 Netflix competition team developed. http://arxiv.org/abs/0911.0460
|
Combining 2 sets of coefficients, weighting one of the sets
Maybe you should look into "stacking". Or even "feature-weighed stacking".
The former is using a cross validation method to determine the weights you should use to linearly stack them. The latter is u
|
44,943
|
Random effect slopes in linear mixed models
|
First, you should compare models from lmer after fitting with ML (maximum likelihood) since the default is REML. So something like:
fit.nc <- update(NoCor, REML=FALSE)
fit.wc <- udpate(WithCor, REML=FALSE)
anova(fit.nc, fit.wc)
It would help to see the output of the random effects variation from your fits. For example, to answer: is there a strong correlation between the intercept and slope and what are the variation sizes?
If you find that the random slope only model (NoCor) provides the best fit, then this means that the Size variable has a different effect between groups (depending on the variation). But the no intercept implies that the mean response at some zero level (baseline for your factor Size) is the same across all groups.
A random slope only model is not as common unless informed by theory -- usually we assume baseline variation between groups (random intercept) and then let effects (slope) vary as well. If you don't think there's a good reason to accept the slope-only model, then you may want to keep the random intercept & slope model since it may conform better to theory.
|
Random effect slopes in linear mixed models
|
First, you should compare models from lmer after fitting with ML (maximum likelihood) since the default is REML. So something like:
fit.nc <- update(NoCor, REML=FALSE)
fit.wc <- udpate(WithCor, REML=
|
Random effect slopes in linear mixed models
First, you should compare models from lmer after fitting with ML (maximum likelihood) since the default is REML. So something like:
fit.nc <- update(NoCor, REML=FALSE)
fit.wc <- udpate(WithCor, REML=FALSE)
anova(fit.nc, fit.wc)
It would help to see the output of the random effects variation from your fits. For example, to answer: is there a strong correlation between the intercept and slope and what are the variation sizes?
If you find that the random slope only model (NoCor) provides the best fit, then this means that the Size variable has a different effect between groups (depending on the variation). But the no intercept implies that the mean response at some zero level (baseline for your factor Size) is the same across all groups.
A random slope only model is not as common unless informed by theory -- usually we assume baseline variation between groups (random intercept) and then let effects (slope) vary as well. If you don't think there's a good reason to accept the slope-only model, then you may want to keep the random intercept & slope model since it may conform better to theory.
|
Random effect slopes in linear mixed models
First, you should compare models from lmer after fitting with ML (maximum likelihood) since the default is REML. So something like:
fit.nc <- update(NoCor, REML=FALSE)
fit.wc <- udpate(WithCor, REML=
|
44,944
|
Random effect slopes in linear mixed models
|
In this case it would not be expected to find substantive differences between the 'NoCor' model and the 'WithCor' model that you have specified. This is because 'Size' is a factor, not a numeric covariate, and what changes between the two models is that instead of the random effects being referenced to the intercept (base level) the random effects are set as stand alone. You can see when you contrast them with ANOVA that there is no difference in AIC, BIC and logLik and no differences in the degrees of freedom (both models have the same number of parameters).
I've found that it might be better to create dummy variables if you want to estimate a variance component for each level of a factor, without including correlations. Something like:
rt$Size1<- ifelse(rt$Size == "small", 1, 0)
rt$Size2<- ifelse(rt$Size == "med", 1, 0)
rt$Size3<- ifelse(rt$Size == "large", 1, 0)
NoCor2 <- lmer(RT ~ Size + (0+Size1|ID) + (0+Size2|ID) + (0+Size3|ID), data=rt)
You might also want to try the slightly simpler model:
NoCorHom <- lmer(RT ~ Size + (1|ID) + (1|ID:Size), data=rt)
You can see from the model summary that this fits a single variance for the size factor, equivalent to assuming sphericity and homogeneity (just like a regular repeated measures ANOVA).
If Size was numeric then you would be looking at something like the below to compare the correlation parameter:
NoCor3 <- lmer(RT ~ Size + (1|ID) + (0+Size|ID), data=rt)
#vs
Cor <- lmer(RT ~ Size + (1+Size|ID), data=rt)
|
Random effect slopes in linear mixed models
|
In this case it would not be expected to find substantive differences between the 'NoCor' model and the 'WithCor' model that you have specified. This is because 'Size' is a factor, not a numeric covar
|
Random effect slopes in linear mixed models
In this case it would not be expected to find substantive differences between the 'NoCor' model and the 'WithCor' model that you have specified. This is because 'Size' is a factor, not a numeric covariate, and what changes between the two models is that instead of the random effects being referenced to the intercept (base level) the random effects are set as stand alone. You can see when you contrast them with ANOVA that there is no difference in AIC, BIC and logLik and no differences in the degrees of freedom (both models have the same number of parameters).
I've found that it might be better to create dummy variables if you want to estimate a variance component for each level of a factor, without including correlations. Something like:
rt$Size1<- ifelse(rt$Size == "small", 1, 0)
rt$Size2<- ifelse(rt$Size == "med", 1, 0)
rt$Size3<- ifelse(rt$Size == "large", 1, 0)
NoCor2 <- lmer(RT ~ Size + (0+Size1|ID) + (0+Size2|ID) + (0+Size3|ID), data=rt)
You might also want to try the slightly simpler model:
NoCorHom <- lmer(RT ~ Size + (1|ID) + (1|ID:Size), data=rt)
You can see from the model summary that this fits a single variance for the size factor, equivalent to assuming sphericity and homogeneity (just like a regular repeated measures ANOVA).
If Size was numeric then you would be looking at something like the below to compare the correlation parameter:
NoCor3 <- lmer(RT ~ Size + (1|ID) + (0+Size|ID), data=rt)
#vs
Cor <- lmer(RT ~ Size + (1+Size|ID), data=rt)
|
Random effect slopes in linear mixed models
In this case it would not be expected to find substantive differences between the 'NoCor' model and the 'WithCor' model that you have specified. This is because 'Size' is a factor, not a numeric covar
|
44,945
|
What is the normality test for binary data?
|
There is no such thing as normality of categorical variable. Normal distribution is a continuous distribution so in assumption don't cover categorical output.
|
What is the normality test for binary data?
|
There is no such thing as normality of categorical variable. Normal distribution is a continuous distribution so in assumption don't cover categorical output.
|
What is the normality test for binary data?
There is no such thing as normality of categorical variable. Normal distribution is a continuous distribution so in assumption don't cover categorical output.
|
What is the normality test for binary data?
There is no such thing as normality of categorical variable. Normal distribution is a continuous distribution so in assumption don't cover categorical output.
|
44,946
|
The "Risk" game dice problem
|
You should not do a calculation of probability for an event deemed surprising post hoc as if it were an event specified before it was rolled (observed).
It's very difficult to to do a proper calculation of post hoc probability, because what other events would have been deemed at least as surprising depends on what the context is, and also on the person doing the deeming.
Would three ones twice in a row at an earlier or later stage of the game have been as surprising? Would you rolling three ones have been as surprising as him rolling them? Would three sixes be as surprising as three ones? and so on... What is the totality of all the events would have been surprising enough to generate a post like this one?
To take an extreme example, imagine a wheelbarrow-full-of-dice (ten thousand, say), each with a tiny individualized serial number. We tip the barrow out and exclaim "Whoah, what are the chances of getting this?" -- and if we work it out, $P(d_1=3)\cdot P(d_2=6)\cdot
\ldots P(d_{10000}=2)$ is $6^{-10000}$. Astronomically small. If we repeat the experiment, we get an equally unusual event. In fact, every single time we do it, we get an event so astronomically unbelievably small that we could almost power a starship with it. The problem is that the calculation is meaningless, because we specified the event post-hoc.
(Even if it were legitimate to do the calculation as if it were a pre-specified event, it looks like you have that calculation incorrect. Specifically, the probability (for an event specified before the roll) of taking three dice and rolling $(1,1,1)$ is $(1/6)^3 = 1/216$, because the three rolls are independent, not $1/56$, and the probability of doing it twice out of a total of two rolls is the square of that - but neither the condition of being pre-specified nor the "out of two rolls" actually hold)
|
The "Risk" game dice problem
|
You should not do a calculation of probability for an event deemed surprising post hoc as if it were an event specified before it was rolled (observed).
It's very difficult to to do a proper calculati
|
The "Risk" game dice problem
You should not do a calculation of probability for an event deemed surprising post hoc as if it were an event specified before it was rolled (observed).
It's very difficult to to do a proper calculation of post hoc probability, because what other events would have been deemed at least as surprising depends on what the context is, and also on the person doing the deeming.
Would three ones twice in a row at an earlier or later stage of the game have been as surprising? Would you rolling three ones have been as surprising as him rolling them? Would three sixes be as surprising as three ones? and so on... What is the totality of all the events would have been surprising enough to generate a post like this one?
To take an extreme example, imagine a wheelbarrow-full-of-dice (ten thousand, say), each with a tiny individualized serial number. We tip the barrow out and exclaim "Whoah, what are the chances of getting this?" -- and if we work it out, $P(d_1=3)\cdot P(d_2=6)\cdot
\ldots P(d_{10000}=2)$ is $6^{-10000}$. Astronomically small. If we repeat the experiment, we get an equally unusual event. In fact, every single time we do it, we get an event so astronomically unbelievably small that we could almost power a starship with it. The problem is that the calculation is meaningless, because we specified the event post-hoc.
(Even if it were legitimate to do the calculation as if it were a pre-specified event, it looks like you have that calculation incorrect. Specifically, the probability (for an event specified before the roll) of taking three dice and rolling $(1,1,1)$ is $(1/6)^3 = 1/216$, because the three rolls are independent, not $1/56$, and the probability of doing it twice out of a total of two rolls is the square of that - but neither the condition of being pre-specified nor the "out of two rolls" actually hold)
|
The "Risk" game dice problem
You should not do a calculation of probability for an event deemed surprising post hoc as if it were an event specified before it was rolled (observed).
It's very difficult to to do a proper calculati
|
44,947
|
Bayesian Analysis in the Absence of Prior Information?
|
If you have no information, you can use “uninformative” priors. Those priors aim to bring as little information as possible, but as you already learned from the What is an "uninformative prior"? Can we ever have one with truly no information? thread, the name is a little bit misleading because even such priors bring some information to the model. That is why more modern recommendation would be to pick a weakly informative prior (centered on something, but very uncertain).
On another hand, using a frequentist model does not mean making no assumptions: you may still assume things like Gaussian likelihood, a linear relationship between the variables, or using regularized regression you are using implicit priors on the parameters, etc. Even if you wanted to make as few assumptions as possible and used a nonparametric model, you would be making some assumptions. For example, say that you would pick $k$NN regression that just averages among "similar" observations. Still, you need to decide on a similarity metric to define what "similar" means and you need to somehow pick the hyperparameter $k$. With Bayesian models, you make additional assumptions by choosing priors, but other approaches also make assumptions.
But, can you have truly no information about something? Say a meteor hits the planet Earth and brings us a new virus from space. A Bayesian statistician needs to build a model on it. They know nothing about space viruses. Hopefully, they know a lot about viruses from Earth, many scientists also did a lot of educated guesses on what extraterrestrial life forms could be and how they could be similar or different to the life on Earth, etc. The scientist in fact has a lot of prior knowledge and assumptions that they could use to come up with priors.
|
Bayesian Analysis in the Absence of Prior Information?
|
If you have no information, you can use “uninformative” priors. Those priors aim to bring as little information as possible, but as you already learned from the What is an "uninformative prior"? Can
|
Bayesian Analysis in the Absence of Prior Information?
If you have no information, you can use “uninformative” priors. Those priors aim to bring as little information as possible, but as you already learned from the What is an "uninformative prior"? Can we ever have one with truly no information? thread, the name is a little bit misleading because even such priors bring some information to the model. That is why more modern recommendation would be to pick a weakly informative prior (centered on something, but very uncertain).
On another hand, using a frequentist model does not mean making no assumptions: you may still assume things like Gaussian likelihood, a linear relationship between the variables, or using regularized regression you are using implicit priors on the parameters, etc. Even if you wanted to make as few assumptions as possible and used a nonparametric model, you would be making some assumptions. For example, say that you would pick $k$NN regression that just averages among "similar" observations. Still, you need to decide on a similarity metric to define what "similar" means and you need to somehow pick the hyperparameter $k$. With Bayesian models, you make additional assumptions by choosing priors, but other approaches also make assumptions.
But, can you have truly no information about something? Say a meteor hits the planet Earth and brings us a new virus from space. A Bayesian statistician needs to build a model on it. They know nothing about space viruses. Hopefully, they know a lot about viruses from Earth, many scientists also did a lot of educated guesses on what extraterrestrial life forms could be and how they could be similar or different to the life on Earth, etc. The scientist in fact has a lot of prior knowledge and assumptions that they could use to come up with priors.
|
Bayesian Analysis in the Absence of Prior Information?
If you have no information, you can use “uninformative” priors. Those priors aim to bring as little information as possible, but as you already learned from the What is an "uninformative prior"? Can
|
44,948
|
Bayesian Analysis in the Absence of Prior Information?
|
I think that the posterior inherits meaning from the prior, which implies that if the prior is meaningless, so is the posterior.
Now there are different varieties of Bayesians when it comes to interpreting probabilities, i.e., assigning meaning to priors (and posteriors). Most (but not all) Bayesian interpretation of probabilities is epistemic, meaning that probabilities formalise a state of belief or knowledge rather than a data generating mechanism that exists in reality (as frequentists do).
Subjectivist Bayesians traditionally state that the prior should formalise your personal prior belief. This particularly means that probabilities do not model data, and data cannot contradict the prior (as observing data later cannot change your belief before data). Note that this applies to both the parameter prior and the likelihood in standard Bayesian setups in which there is a parametric likelihood and a prior on the parameters. The original literature (de Finetti and Ramsey) postulates that you basically have prior beliefs about everything that can be formalised as prior distribution. One way to operationlise that is to ask you to bet on how the data will turn out before you see it, implying that your are forced to offer bets on all kinds of possible outcomes. Existing prior information will make you expect certain outcomes more than others, so that you should put higher prior probability on these. If you don't have much information, you need to spread out probability so that everything that is possible has enough share in the overall distribution that data ultimately can push the posterior there if there is a clear message from the data.
The thing is that in real data analysis hardly anyone is forced to bet in advance, and for sure not on enough events to determine the prior completely. In fact there is some literature about imprecise probabilities in which you are not forced to bet but where the few bets (or specifications, if proper bets are not involved) you are willing to make determine "upper" and "lower" (prior, but later also posterior) probabilities. A similar thing happens in Bayesian sensitivity analysis - you may not be willing to specify a precise prior, but rather a range of different priors may look appropriate to you, and you can run Bayesian analyses with all of these and see how much results differ.
In reality, you may have some information, but this information may not translate readily into prior probabilities such as "the probability for $\theta$ to be between -2 and 2 is 85%"; you may think it's likely, but whether that translates into 70, 85, or 92% may not be so clear to you, and is certainly not enforced by the information itself. The subjectivist approach is that you should basically then decide how to place your bets (i.e., if you are ready to pay 85 for a possible win of 100 in case this happens, or rather not). What I think is misleading about this idea is that subjectivists seem to think that there exists some "true" personal prior that can be "found out" in this way, whereas I think that you are rather forced to make it up out of more or less thin air if you want to do a Bayesian analysis. Obviously sensitivity analysis can show you, when things run well (which often means that you need to have a lot of data), that your final conclusions may not be all that different given different choices that look equally plausible to you, and although you make some choices that don't seem that well founded, this doesn't affect the conclusions much. Unfortunately, in much published real Bayesian analysis, disappointingly little care is invested into motivating the prior and into exploring sensitivity in case of alternative choices, as these are hard tasks and everyone (not only the frequentists!) wants statistics to be easy. If indeed the posterior inherits meaning from the prior, there isn't much to expect from the resulting posteriors.
Objectivist Bayesians would not like to think of probabilities as made up by individuals forced to bet, but the objectivist idea rather is that the prior should only formalise "objective" external information that can be verified and agreed upon. Otherwise non-informative priors should be used. Unfortunately this is of little help in the situation that there is prior information that doesn't come in form of objectively verifiable probabilities. Almost all prior information is of this kind. In practice objectivist analysis therefore either becomes subjective at least to some extent (J. Berger says in some papers that so-called objective Bayes is not really objective but rather points to the attitude that we should try as hard as we can to reach an ultimately unattainable ideal), or people use non-informative priors despite in fact having some information, which deprives the Bayesian approach of one of its major benefits. (On top of that, even what is called non-informative priors will often carry some subtle information that may harm analyses if not consciously acknowledged and used.)
There is also the possibility to actually interpret probabilities in an aleatory way (i.e., non-epistemic, referring to data generating processes in the world; some say "frequentist). A. Gelman occasionally advertises Bayesian statistics in this way. The data is then in fact informative about the prior, and if the data contradict it, it may be changed, although this violates the Bayesian concept of coherence. For setting up a convincing informative model this may make sense, but posterior probabilities should not be interpreted in a naive fashion such as "after data the probability that the true $\theta$ is between -2 and -1.5 is 98.5%", because the model within which that "true $\theta$" is defined is an idealisation and may be changed with more information coming in (which by the way should also be kept in mind for frequentist analyses); also the potential of changing the prior with the data may lead to overprecision, i.e., credible intervals may be too small because the prior that in Bayesian analysis is meant to be fixed before data has been adapted to the data (the same issue occurs in many frequentist analyses).
Personally I think there are big issues with any kind of statistical approach; Bayesians often tell frequentists off for many issues that in some way or another they actually face themselves (for example there is the accusation of "adhockery", frequentists are accused of adapting their approach in non-principled and irregular ways to the situation at hand, but if Bayesians want to learn and adapt the prior rather than being constrained by whatever their first prior choice implies, they violate one of their own major principles).
Setting up a prior basically means to put weights on the parameter (and observation) space, which will then influence analyses. There are situations in which there are good reasons to do this, particularly if there is some information that is meant to influence the analysis (but then of course this needs to be translated into prior probabilities and this is hard). I'm not keen though on doing Bayesian analysis for the sake of it, so from my personal view, if there is no prior information that you want to use to do this kind of reweighting, I'd be happy to do a frequentist analysis. (Note that there are still various ways how prior information can influence your analysis; the idea that relevant information should always and only be used to determine prior probabilities for outcomes and parameters is nonsense.)
I will also acknowledge that there may be reasons to want epistemic probabilities rather than frequentist ones (particularly if the frequentist ideal of unlimited identical repetition of experiments doesn't seem convincing), in which case a Bayesian approach even with supposedly non-informative priors can be preferred. However, the postulate that there are unique true epistemic probabilities looks just as questionable to me as the postulate of infinitely repeatable experiments, resulting in the existence of true frequentist probabilities. Also, be careful to prevent your prior from bringing in some implicit informations/implications that you don't want.
|
Bayesian Analysis in the Absence of Prior Information?
|
I think that the posterior inherits meaning from the prior, which implies that if the prior is meaningless, so is the posterior.
Now there are different varieties of Bayesians when it comes to interpr
|
Bayesian Analysis in the Absence of Prior Information?
I think that the posterior inherits meaning from the prior, which implies that if the prior is meaningless, so is the posterior.
Now there are different varieties of Bayesians when it comes to interpreting probabilities, i.e., assigning meaning to priors (and posteriors). Most (but not all) Bayesian interpretation of probabilities is epistemic, meaning that probabilities formalise a state of belief or knowledge rather than a data generating mechanism that exists in reality (as frequentists do).
Subjectivist Bayesians traditionally state that the prior should formalise your personal prior belief. This particularly means that probabilities do not model data, and data cannot contradict the prior (as observing data later cannot change your belief before data). Note that this applies to both the parameter prior and the likelihood in standard Bayesian setups in which there is a parametric likelihood and a prior on the parameters. The original literature (de Finetti and Ramsey) postulates that you basically have prior beliefs about everything that can be formalised as prior distribution. One way to operationlise that is to ask you to bet on how the data will turn out before you see it, implying that your are forced to offer bets on all kinds of possible outcomes. Existing prior information will make you expect certain outcomes more than others, so that you should put higher prior probability on these. If you don't have much information, you need to spread out probability so that everything that is possible has enough share in the overall distribution that data ultimately can push the posterior there if there is a clear message from the data.
The thing is that in real data analysis hardly anyone is forced to bet in advance, and for sure not on enough events to determine the prior completely. In fact there is some literature about imprecise probabilities in which you are not forced to bet but where the few bets (or specifications, if proper bets are not involved) you are willing to make determine "upper" and "lower" (prior, but later also posterior) probabilities. A similar thing happens in Bayesian sensitivity analysis - you may not be willing to specify a precise prior, but rather a range of different priors may look appropriate to you, and you can run Bayesian analyses with all of these and see how much results differ.
In reality, you may have some information, but this information may not translate readily into prior probabilities such as "the probability for $\theta$ to be between -2 and 2 is 85%"; you may think it's likely, but whether that translates into 70, 85, or 92% may not be so clear to you, and is certainly not enforced by the information itself. The subjectivist approach is that you should basically then decide how to place your bets (i.e., if you are ready to pay 85 for a possible win of 100 in case this happens, or rather not). What I think is misleading about this idea is that subjectivists seem to think that there exists some "true" personal prior that can be "found out" in this way, whereas I think that you are rather forced to make it up out of more or less thin air if you want to do a Bayesian analysis. Obviously sensitivity analysis can show you, when things run well (which often means that you need to have a lot of data), that your final conclusions may not be all that different given different choices that look equally plausible to you, and although you make some choices that don't seem that well founded, this doesn't affect the conclusions much. Unfortunately, in much published real Bayesian analysis, disappointingly little care is invested into motivating the prior and into exploring sensitivity in case of alternative choices, as these are hard tasks and everyone (not only the frequentists!) wants statistics to be easy. If indeed the posterior inherits meaning from the prior, there isn't much to expect from the resulting posteriors.
Objectivist Bayesians would not like to think of probabilities as made up by individuals forced to bet, but the objectivist idea rather is that the prior should only formalise "objective" external information that can be verified and agreed upon. Otherwise non-informative priors should be used. Unfortunately this is of little help in the situation that there is prior information that doesn't come in form of objectively verifiable probabilities. Almost all prior information is of this kind. In practice objectivist analysis therefore either becomes subjective at least to some extent (J. Berger says in some papers that so-called objective Bayes is not really objective but rather points to the attitude that we should try as hard as we can to reach an ultimately unattainable ideal), or people use non-informative priors despite in fact having some information, which deprives the Bayesian approach of one of its major benefits. (On top of that, even what is called non-informative priors will often carry some subtle information that may harm analyses if not consciously acknowledged and used.)
There is also the possibility to actually interpret probabilities in an aleatory way (i.e., non-epistemic, referring to data generating processes in the world; some say "frequentist). A. Gelman occasionally advertises Bayesian statistics in this way. The data is then in fact informative about the prior, and if the data contradict it, it may be changed, although this violates the Bayesian concept of coherence. For setting up a convincing informative model this may make sense, but posterior probabilities should not be interpreted in a naive fashion such as "after data the probability that the true $\theta$ is between -2 and -1.5 is 98.5%", because the model within which that "true $\theta$" is defined is an idealisation and may be changed with more information coming in (which by the way should also be kept in mind for frequentist analyses); also the potential of changing the prior with the data may lead to overprecision, i.e., credible intervals may be too small because the prior that in Bayesian analysis is meant to be fixed before data has been adapted to the data (the same issue occurs in many frequentist analyses).
Personally I think there are big issues with any kind of statistical approach; Bayesians often tell frequentists off for many issues that in some way or another they actually face themselves (for example there is the accusation of "adhockery", frequentists are accused of adapting their approach in non-principled and irregular ways to the situation at hand, but if Bayesians want to learn and adapt the prior rather than being constrained by whatever their first prior choice implies, they violate one of their own major principles).
Setting up a prior basically means to put weights on the parameter (and observation) space, which will then influence analyses. There are situations in which there are good reasons to do this, particularly if there is some information that is meant to influence the analysis (but then of course this needs to be translated into prior probabilities and this is hard). I'm not keen though on doing Bayesian analysis for the sake of it, so from my personal view, if there is no prior information that you want to use to do this kind of reweighting, I'd be happy to do a frequentist analysis. (Note that there are still various ways how prior information can influence your analysis; the idea that relevant information should always and only be used to determine prior probabilities for outcomes and parameters is nonsense.)
I will also acknowledge that there may be reasons to want epistemic probabilities rather than frequentist ones (particularly if the frequentist ideal of unlimited identical repetition of experiments doesn't seem convincing), in which case a Bayesian approach even with supposedly non-informative priors can be preferred. However, the postulate that there are unique true epistemic probabilities looks just as questionable to me as the postulate of infinitely repeatable experiments, resulting in the existence of true frequentist probabilities. Also, be careful to prevent your prior from bringing in some implicit informations/implications that you don't want.
|
Bayesian Analysis in the Absence of Prior Information?
I think that the posterior inherits meaning from the prior, which implies that if the prior is meaningless, so is the posterior.
Now there are different varieties of Bayesians when it comes to interpr
|
44,949
|
Bayesian Analysis in the Absence of Prior Information?
|
When we don't have a lot of confidence on information that can be used
to construct Bayesian Priors - is it generally better to stick to
Frequentist Approaches instead of "guessing" which Priors will better
fit the data and the choice of model?
In my opinion, the full power of a Bayesian analysis is unleashed when a priori information is available, although how to translate this prior information into a distribution is far from trivial and there may be several different ways to do it.
Indeed, building a prior from extra experimental (or expert opinions) data is, to some extent, akin to choosing the statistical model. Thus the inferential task for a subjective Bayesian is heavier than that of a frequentist statistician. The power, however, is that we can, at least in principle, include expert opinion or extra experimental information in our inferential conclusions, information that in a frequentist approach would have been otherwise discarded.
In absence of information, however, we also can find several compelling reasons why a Bayesian approach is still useful. In the linked post you find many of them, and I summarise them as
lead to inferential procedures with good frequentist properties (probability coverage, unbiasedness of the MAP)
default priors tailored to the parameter of the model at hand that are guaranteed to impact the posterior as less as possible.
Notice the bold default, which seems to be the most suitable adjective. Indeed, we cannot call them non-informative since "informativeness" is relative to the measure of information used and may depend on the scale of the parameter.
Among these compelling reasons, I find two of them that are particularly relevant. Firstly, some of these default priors have been discovered and used by frequentists in order to adjust their inference that otherwise would have been inaccurate or useless.
For instance, Firth(1993) showed that the Jeffreys prior in exponential families expressed in the canonical form leads to a maximum a posteriori (MAP) with reduced bias. Furthermore, and more importantly for frequentists, he proposed a weight function for frequentists which solves the problem of perfect separation in logistic regression.
However, the most compelling argument in the defence of default priors, such as the Jeffreys, is invariance under one-to-one reparametrizations. (personal communication by J. Berger in an O'Bayes meeting some years ago). And I totally agree with this. Indeed, if we think invariance to parametrization is a good thing, as most frequentists do, then that's the ultimate defence for the use of non-informative or default prior.
|
Bayesian Analysis in the Absence of Prior Information?
|
When we don't have a lot of confidence on information that can be used
to construct Bayesian Priors - is it generally better to stick to
Frequentist Approaches instead of "guessing" which Priors will
|
Bayesian Analysis in the Absence of Prior Information?
When we don't have a lot of confidence on information that can be used
to construct Bayesian Priors - is it generally better to stick to
Frequentist Approaches instead of "guessing" which Priors will better
fit the data and the choice of model?
In my opinion, the full power of a Bayesian analysis is unleashed when a priori information is available, although how to translate this prior information into a distribution is far from trivial and there may be several different ways to do it.
Indeed, building a prior from extra experimental (or expert opinions) data is, to some extent, akin to choosing the statistical model. Thus the inferential task for a subjective Bayesian is heavier than that of a frequentist statistician. The power, however, is that we can, at least in principle, include expert opinion or extra experimental information in our inferential conclusions, information that in a frequentist approach would have been otherwise discarded.
In absence of information, however, we also can find several compelling reasons why a Bayesian approach is still useful. In the linked post you find many of them, and I summarise them as
lead to inferential procedures with good frequentist properties (probability coverage, unbiasedness of the MAP)
default priors tailored to the parameter of the model at hand that are guaranteed to impact the posterior as less as possible.
Notice the bold default, which seems to be the most suitable adjective. Indeed, we cannot call them non-informative since "informativeness" is relative to the measure of information used and may depend on the scale of the parameter.
Among these compelling reasons, I find two of them that are particularly relevant. Firstly, some of these default priors have been discovered and used by frequentists in order to adjust their inference that otherwise would have been inaccurate or useless.
For instance, Firth(1993) showed that the Jeffreys prior in exponential families expressed in the canonical form leads to a maximum a posteriori (MAP) with reduced bias. Furthermore, and more importantly for frequentists, he proposed a weight function for frequentists which solves the problem of perfect separation in logistic regression.
However, the most compelling argument in the defence of default priors, such as the Jeffreys, is invariance under one-to-one reparametrizations. (personal communication by J. Berger in an O'Bayes meeting some years ago). And I totally agree with this. Indeed, if we think invariance to parametrization is a good thing, as most frequentists do, then that's the ultimate defence for the use of non-informative or default prior.
|
Bayesian Analysis in the Absence of Prior Information?
When we don't have a lot of confidence on information that can be used
to construct Bayesian Priors - is it generally better to stick to
Frequentist Approaches instead of "guessing" which Priors will
|
44,950
|
Is there an equivalent to an ECDF with a "<" sign?
|
Remember how the CDF is a right-continuous function? That comes from using the $\le$.
If you use $<$, then you change the function to be left-continuous.
Regarding your exact question about if such a function exists, the answer is that it does, and you wrote out exactly what it is. That function isn’t the classical CDF, but if it has meaning for your application, use it!
Apparently Kolmogorov used the $<$ convention and left-continuity in his first probability book, so you might consider yourself to be in good company by thinking this is reasonable!
|
Is there an equivalent to an ECDF with a "<" sign?
|
Remember how the CDF is a right-continuous function? That comes from using the $\le$.
If you use $<$, then you change the function to be left-continuous.
Regarding your exact question about if such a
|
Is there an equivalent to an ECDF with a "<" sign?
Remember how the CDF is a right-continuous function? That comes from using the $\le$.
If you use $<$, then you change the function to be left-continuous.
Regarding your exact question about if such a function exists, the answer is that it does, and you wrote out exactly what it is. That function isn’t the classical CDF, but if it has meaning for your application, use it!
Apparently Kolmogorov used the $<$ convention and left-continuity in his first probability book, so you might consider yourself to be in good company by thinking this is reasonable!
|
Is there an equivalent to an ECDF with a "<" sign?
Remember how the CDF is a right-continuous function? That comes from using the $\le$.
If you use $<$, then you change the function to be left-continuous.
Regarding your exact question about if such a
|
44,951
|
Do Statistical Binning Algorithms Exist?
|
The most rational and elegant solution, and best performing in terms of mean squared error of estimates, is to use a method that borrows information across groups: either penalized maximum likelihood estimation, mixed effects model, or a Bayesian model that connects the groups through the use of random effects. But a quick and not-too-dirty solution is to estimate how many parameters the sample size will allow you to estimate and to pool categories with the lowest marginal frequencies until you only estimate that many parameters.
A drastically different approach is to reduce dimensionality by scoring the 55 groups. For example, Fisher's optimum scoring algorithm replaces groups with the mean value of a surrogate variable computed on just that group. Or use subject matter knowledge. For example if you had 55 zip codes you could replace the categories with the median family income that exists within its zip zode, or code as distance from some center point.
|
Do Statistical Binning Algorithms Exist?
|
The most rational and elegant solution, and best performing in terms of mean squared error of estimates, is to use a method that borrows information across groups: either penalized maximum likelihood
|
Do Statistical Binning Algorithms Exist?
The most rational and elegant solution, and best performing in terms of mean squared error of estimates, is to use a method that borrows information across groups: either penalized maximum likelihood estimation, mixed effects model, or a Bayesian model that connects the groups through the use of random effects. But a quick and not-too-dirty solution is to estimate how many parameters the sample size will allow you to estimate and to pool categories with the lowest marginal frequencies until you only estimate that many parameters.
A drastically different approach is to reduce dimensionality by scoring the 55 groups. For example, Fisher's optimum scoring algorithm replaces groups with the mean value of a surrogate variable computed on just that group. Or use subject matter knowledge. For example if you had 55 zip codes you could replace the categories with the median family income that exists within its zip zode, or code as distance from some center point.
|
Do Statistical Binning Algorithms Exist?
The most rational and elegant solution, and best performing in terms of mean squared error of estimates, is to use a method that borrows information across groups: either penalized maximum likelihood
|
44,952
|
What is the derivation for "Partial Expectation"?
|
One way is to think about the conditional density. The density of $X|X>k$ is zero when $X\leq k$, so it's proportional to $f_X(x)I(X>k)$. The constant of proportionality is given by the fact that a density has to integrate to 1, so the conditional density is
$$g_X(x)=\frac{f_X(x)I(X>k)}{P(X>k)}$$
So,
$$E[X|X>k]=\int_{-\infty}^\infty x\frac{f_X(x)I(X>k)}{P(X>k)}\,dx=\int_k^\infty x\frac{f_X(x)}{P(X>k)}\,dx$$
where the last step is based on noticing that the integral up to $k$ has to be zero.
This then rearranges to give what you want.
|
What is the derivation for "Partial Expectation"?
|
One way is to think about the conditional density. The density of $X|X>k$ is zero when $X\leq k$, so it's proportional to $f_X(x)I(X>k)$. The constant of proportionality is given by the fact that a
|
What is the derivation for "Partial Expectation"?
One way is to think about the conditional density. The density of $X|X>k$ is zero when $X\leq k$, so it's proportional to $f_X(x)I(X>k)$. The constant of proportionality is given by the fact that a density has to integrate to 1, so the conditional density is
$$g_X(x)=\frac{f_X(x)I(X>k)}{P(X>k)}$$
So,
$$E[X|X>k]=\int_{-\infty}^\infty x\frac{f_X(x)I(X>k)}{P(X>k)}\,dx=\int_k^\infty x\frac{f_X(x)}{P(X>k)}\,dx$$
where the last step is based on noticing that the integral up to $k$ has to be zero.
This then rearranges to give what you want.
|
What is the derivation for "Partial Expectation"?
One way is to think about the conditional density. The density of $X|X>k$ is zero when $X\leq k$, so it's proportional to $f_X(x)I(X>k)$. The constant of proportionality is given by the fact that a
|
44,953
|
What is the derivation for "Partial Expectation"?
|
The first equation can be derived using two fundamental formulas:
The formula for the expectation of a random variable $X$ given event $A$:
$$E(X\mid A)=\frac{E(XI(A))}{P(A)}\tag1$$
The formula for the expectation of a function $h$ of a random variable $X$ (often described as the law of the unconscious statistician): If $X$ has density $f_X$, then
$$ E [h(X)] = \int h(x) f_X(x)\, dx.\tag2$$
In your situation, apply formula (1) with $A:=\{X>k\}$, obtaining
$$E(X\mid X>k)=\frac{E [XI(X>k)]}{P(X>k)}.$$ Now apply (2), noting that $XI(X>k)$ can be written $h(X)$, where $h$ has the form
$$
h(x):=\begin{cases}
x&\text{if $x>k$}\\
0&\text{if $x\le k$}
\end{cases}.
$$ This gives
$$ E [XI(X>k)]=\int_k^\infty xf_X(x)\,dx.$$
|
What is the derivation for "Partial Expectation"?
|
The first equation can be derived using two fundamental formulas:
The formula for the expectation of a random variable $X$ given event $A$:
$$E(X\mid A)=\frac{E(XI(A))}{P(A)}\tag1$$
The formula for
|
What is the derivation for "Partial Expectation"?
The first equation can be derived using two fundamental formulas:
The formula for the expectation of a random variable $X$ given event $A$:
$$E(X\mid A)=\frac{E(XI(A))}{P(A)}\tag1$$
The formula for the expectation of a function $h$ of a random variable $X$ (often described as the law of the unconscious statistician): If $X$ has density $f_X$, then
$$ E [h(X)] = \int h(x) f_X(x)\, dx.\tag2$$
In your situation, apply formula (1) with $A:=\{X>k\}$, obtaining
$$E(X\mid X>k)=\frac{E [XI(X>k)]}{P(X>k)}.$$ Now apply (2), noting that $XI(X>k)$ can be written $h(X)$, where $h$ has the form
$$
h(x):=\begin{cases}
x&\text{if $x>k$}\\
0&\text{if $x\le k$}
\end{cases}.
$$ This gives
$$ E [XI(X>k)]=\int_k^\infty xf_X(x)\,dx.$$
|
What is the derivation for "Partial Expectation"?
The first equation can be derived using two fundamental formulas:
The formula for the expectation of a random variable $X$ given event $A$:
$$E(X\mid A)=\frac{E(XI(A))}{P(A)}\tag1$$
The formula for
|
44,954
|
Paired, discrete hypothesis testing
|
Lazy version: permutation testing.
The null hypothesis is that their interests would be unchanged. Operationally, that means that for each student, you might as well flip a coin to pick their "before" rating and "after" rating. So do that, a large number of times. If the result is more extreme than the one you have often, then you might as well believe the null hypothesis.
So something like this:
import random
# First of pair is before, second is after.
observed = [
(3, 4), (2, 2), (3, 1), (4, 5), (5, 5),
(2, 3), (4, 4), (3, 4), (3, 3), (2, 4)
]
def improvement(observed):
"How many students' interest scores improve?"
return sum(a > b for b, a in observed)
print(f'Observed improvement: {improvement(observed)}')
def assume_null(observed):
"For each pair, toss coin to pick before and after."
for b, a in observed:
yield (a, b) if random.choice([True, False]) else (b, a)
# Number of simulations from the null hypothesis.
B = 1000
# Generate many potential improvements under the null hypothesis.
null_distr = [improvement(assume_null(observed)) for _ in range(0, B)]
# Fraction of simulations from the null hypothesis that are at least as extreme as
# the one observed in real life.
more_extreme = sum(impr >= improvement(observed) for impr in null_distr)
p = more_extreme/B
print(f'The null hypothesis gets at least as extreme a result in {p*100:.2f} % of the simulations.')
If you want to compute how much the scores improved, you just chuck that computation into the improvement function:
def improvement(observed):
"By how many points did each student's interest improve?"
return sum(a - b for b, a in observed)
If you have unpaired data, the approach is the same, but it will be much harder to show significance (because of the less powerful experiment design).
Instead of tossing a coin to pick a number from each pair, you just pool together both data sets (since under the null hypothesis, they are practically the same data set, right?) and then draw two random new data sets from that pool.
import random
before = [3, 2, 3, 4, 5, 2, 4, 3, 3, 2]
after = [4, 2, 1, 5, 5, 3, 4, 4, 3, 4]
def improvement(before, after):
"By how much did interest change in aggregate?"
return sum(after) - sum(before)
print(f'Observed improvement: {improvement(before, after)}')
def assume_null(before, after):
"Draw two new before and after sets from both."
n_b = len(before)
n_a = len(after)
combined_data = before + after
shuffled = random.sample(combined_data, n_b + n_a)
# Take the first half of the shuffled data to be "before"
# and the second half to be "after".
return (shuffled[1:n_b], shuffled[n_b:n_b+n_a])
# Number of simulations from the null hypothesis.
B = 1000
# Generate many potential improvements under the null hypothesis.
null_distr = [improvement(*assume_null(before, after)) for _ in range(0, B)]
# Fraction of simulations from the null hypothesis that are at least as extreme as
# the one observed in real life.
more_extreme = sum(impr >= improvement(before, after) for impr in null_distr)
p = more_extreme/B
print(f'The null hypothesis gets at least as extreme a result in {p*100:.2f} % of the simulations.')
```
|
Paired, discrete hypothesis testing
|
Lazy version: permutation testing.
The null hypothesis is that their interests would be unchanged. Operationally, that means that for each student, you might as well flip a coin to pick their "before"
|
Paired, discrete hypothesis testing
Lazy version: permutation testing.
The null hypothesis is that their interests would be unchanged. Operationally, that means that for each student, you might as well flip a coin to pick their "before" rating and "after" rating. So do that, a large number of times. If the result is more extreme than the one you have often, then you might as well believe the null hypothesis.
So something like this:
import random
# First of pair is before, second is after.
observed = [
(3, 4), (2, 2), (3, 1), (4, 5), (5, 5),
(2, 3), (4, 4), (3, 4), (3, 3), (2, 4)
]
def improvement(observed):
"How many students' interest scores improve?"
return sum(a > b for b, a in observed)
print(f'Observed improvement: {improvement(observed)}')
def assume_null(observed):
"For each pair, toss coin to pick before and after."
for b, a in observed:
yield (a, b) if random.choice([True, False]) else (b, a)
# Number of simulations from the null hypothesis.
B = 1000
# Generate many potential improvements under the null hypothesis.
null_distr = [improvement(assume_null(observed)) for _ in range(0, B)]
# Fraction of simulations from the null hypothesis that are at least as extreme as
# the one observed in real life.
more_extreme = sum(impr >= improvement(observed) for impr in null_distr)
p = more_extreme/B
print(f'The null hypothesis gets at least as extreme a result in {p*100:.2f} % of the simulations.')
If you want to compute how much the scores improved, you just chuck that computation into the improvement function:
def improvement(observed):
"By how many points did each student's interest improve?"
return sum(a - b for b, a in observed)
If you have unpaired data, the approach is the same, but it will be much harder to show significance (because of the less powerful experiment design).
Instead of tossing a coin to pick a number from each pair, you just pool together both data sets (since under the null hypothesis, they are practically the same data set, right?) and then draw two random new data sets from that pool.
import random
before = [3, 2, 3, 4, 5, 2, 4, 3, 3, 2]
after = [4, 2, 1, 5, 5, 3, 4, 4, 3, 4]
def improvement(before, after):
"By how much did interest change in aggregate?"
return sum(after) - sum(before)
print(f'Observed improvement: {improvement(before, after)}')
def assume_null(before, after):
"Draw two new before and after sets from both."
n_b = len(before)
n_a = len(after)
combined_data = before + after
shuffled = random.sample(combined_data, n_b + n_a)
# Take the first half of the shuffled data to be "before"
# and the second half to be "after".
return (shuffled[1:n_b], shuffled[n_b:n_b+n_a])
# Number of simulations from the null hypothesis.
B = 1000
# Generate many potential improvements under the null hypothesis.
null_distr = [improvement(*assume_null(before, after)) for _ in range(0, B)]
# Fraction of simulations from the null hypothesis that are at least as extreme as
# the one observed in real life.
more_extreme = sum(impr >= improvement(before, after) for impr in null_distr)
p = more_extreme/B
print(f'The null hypothesis gets at least as extreme a result in {p*100:.2f} % of the simulations.')
```
|
Paired, discrete hypothesis testing
Lazy version: permutation testing.
The null hypothesis is that their interests would be unchanged. Operationally, that means that for each student, you might as well flip a coin to pick their "before"
|
44,955
|
Paired, discrete hypothesis testing
|
The sign test or the Wilcoxon sign-rank test present alternatives to a permutation test.
The former has really low power, but a reasonably comprehensible null and alternative hypothesis:
$\text{H}_{0}\text{: }P(X_{\text{before}} > X_{\text{after}}) = 0.5$ , with
$\text{H}_{\text{A}}\text{: }P(X_{\text{before}} > X_{\text{after}}) \ne 0.5$
In plain words, the null hypothesis of the sign test is that a randomly selected student is equally likely to have a before measurement that is larger than their after measurement.
The sign-rank test has much more power, but the null and alternate are less intuitive:
$\text{H}_{0}\text{: The distribution of } X \text{ is symmetrical and centered on 0,}$ with
$\text{H}_{\text{A}}\text{: The distribution of } X \text{ is either asymmetrical, or not centered on 0, or both.}$
|
Paired, discrete hypothesis testing
|
The sign test or the Wilcoxon sign-rank test present alternatives to a permutation test.
The former has really low power, but a reasonably comprehensible null and alternative hypothesis:
$\text{H}_{0}
|
Paired, discrete hypothesis testing
The sign test or the Wilcoxon sign-rank test present alternatives to a permutation test.
The former has really low power, but a reasonably comprehensible null and alternative hypothesis:
$\text{H}_{0}\text{: }P(X_{\text{before}} > X_{\text{after}}) = 0.5$ , with
$\text{H}_{\text{A}}\text{: }P(X_{\text{before}} > X_{\text{after}}) \ne 0.5$
In plain words, the null hypothesis of the sign test is that a randomly selected student is equally likely to have a before measurement that is larger than their after measurement.
The sign-rank test has much more power, but the null and alternate are less intuitive:
$\text{H}_{0}\text{: The distribution of } X \text{ is symmetrical and centered on 0,}$ with
$\text{H}_{\text{A}}\text{: The distribution of } X \text{ is either asymmetrical, or not centered on 0, or both.}$
|
Paired, discrete hypothesis testing
The sign test or the Wilcoxon sign-rank test present alternatives to a permutation test.
The former has really low power, but a reasonably comprehensible null and alternative hypothesis:
$\text{H}_{0}
|
44,956
|
Can any Models be "Bagged"?
|
You ask "Or is 'bagging' only used for very specific models and instances (e.g. Random Forest)?"
If you truly want to, you can bag any model. The reason that bagging is almost synonymous with random forest is that bagging is more effective for high-variance models like decision trees. Again, Elements of Statistical Learning (p. 589) writes
Not all estimators can be improved by shaking up the data like this [via bagging].
It seems that highly nonlinear estimators, such as trees, benefit the most.
For bootstrapped trees, $\rho$ [the correlation of estimators] is typically small (0.05 or lower is typical; see
Figure 15.9), while $\sigma^2$ [their variance]
is not much larger than the variance for the original
tree. On the other hand, bagging does not change linear estimates, such
as the sample mean (hence its variance either); the pairwise correlation
between bootstrapped means is about 50% (Exercise 15.4).
This is made more precise in the surrounding text, but this paragraph is a good summary.
Whether a model is "interpretable" is up to you to decide. Elements of Statistical Learning (p. 286) provides some commentary:
Note that when we bag a model, any simple structure in the model is
lost. As an example, a bagged tree is no longer a tree. For interpretation
of the model this is clearly a drawback. More stable procedures like nearest neighbors are typically not affected much by bagging. Unfortunately,
the unstable models most helped by bagging are unstable because of the
emphasis on interpretability, and this is lost in the bagging process.
Regarding memory-constrained computation of Markov Models, I have 2 comments.
The bootstrap sample has a similar memory cost as the original sample. In the naive implementation, you're drawing a random sample equal to the original data size. If you use weighting instead of naively gathering duplicates of the data, this might economize the memory consumption a little, since on average the bootstrap sample includes $1 - \exp(-1) \approx 63\%$ of the original data, but this seems marginal on the whole.
You can just fit the model out-of-memory. In the past when I've faced this problem, I've used a neural network library, and hand-coded the model. In the NN forward pass, I implemented Baum-Welch in the NN library. Then the backward pass is automatically done via backprop. In this way, we can update the model incrementally using whatever mini-batch size fits in memory.
|
Can any Models be "Bagged"?
|
You ask "Or is 'bagging' only used for very specific models and instances (e.g. Random Forest)?"
If you truly want to, you can bag any model. The reason that bagging is almost synonymous with random f
|
Can any Models be "Bagged"?
You ask "Or is 'bagging' only used for very specific models and instances (e.g. Random Forest)?"
If you truly want to, you can bag any model. The reason that bagging is almost synonymous with random forest is that bagging is more effective for high-variance models like decision trees. Again, Elements of Statistical Learning (p. 589) writes
Not all estimators can be improved by shaking up the data like this [via bagging].
It seems that highly nonlinear estimators, such as trees, benefit the most.
For bootstrapped trees, $\rho$ [the correlation of estimators] is typically small (0.05 or lower is typical; see
Figure 15.9), while $\sigma^2$ [their variance]
is not much larger than the variance for the original
tree. On the other hand, bagging does not change linear estimates, such
as the sample mean (hence its variance either); the pairwise correlation
between bootstrapped means is about 50% (Exercise 15.4).
This is made more precise in the surrounding text, but this paragraph is a good summary.
Whether a model is "interpretable" is up to you to decide. Elements of Statistical Learning (p. 286) provides some commentary:
Note that when we bag a model, any simple structure in the model is
lost. As an example, a bagged tree is no longer a tree. For interpretation
of the model this is clearly a drawback. More stable procedures like nearest neighbors are typically not affected much by bagging. Unfortunately,
the unstable models most helped by bagging are unstable because of the
emphasis on interpretability, and this is lost in the bagging process.
Regarding memory-constrained computation of Markov Models, I have 2 comments.
The bootstrap sample has a similar memory cost as the original sample. In the naive implementation, you're drawing a random sample equal to the original data size. If you use weighting instead of naively gathering duplicates of the data, this might economize the memory consumption a little, since on average the bootstrap sample includes $1 - \exp(-1) \approx 63\%$ of the original data, but this seems marginal on the whole.
You can just fit the model out-of-memory. In the past when I've faced this problem, I've used a neural network library, and hand-coded the model. In the NN forward pass, I implemented Baum-Welch in the NN library. Then the backward pass is automatically done via backprop. In this way, we can update the model incrementally using whatever mini-batch size fits in memory.
|
Can any Models be "Bagged"?
You ask "Or is 'bagging' only used for very specific models and instances (e.g. Random Forest)?"
If you truly want to, you can bag any model. The reason that bagging is almost synonymous with random f
|
44,957
|
Can any Models be "Bagged"?
|
Bagging is usually used for model so called the "weak learner" like Decision Tree. The reason behind is those weak learner usually overfit and lack of generalization power (High Variance).
With the application of Bagging , researcher found that it can reduce the variance of model (prevent overfitting). Althought some suggest that bagging would sometime reduce bias, mostly people use bagging to reduce overfitting. For underfitting, boosting may be a better idea.
For your case, your MSM model seems is underfitting the data instead of overfitting. Bagging might not be a good idea.
|
Can any Models be "Bagged"?
|
Bagging is usually used for model so called the "weak learner" like Decision Tree. The reason behind is those weak learner usually overfit and lack of generalization power (High Variance).
With the ap
|
Can any Models be "Bagged"?
Bagging is usually used for model so called the "weak learner" like Decision Tree. The reason behind is those weak learner usually overfit and lack of generalization power (High Variance).
With the application of Bagging , researcher found that it can reduce the variance of model (prevent overfitting). Althought some suggest that bagging would sometime reduce bias, mostly people use bagging to reduce overfitting. For underfitting, boosting may be a better idea.
For your case, your MSM model seems is underfitting the data instead of overfitting. Bagging might not be a good idea.
|
Can any Models be "Bagged"?
Bagging is usually used for model so called the "weak learner" like Decision Tree. The reason behind is those weak learner usually overfit and lack of generalization power (High Variance).
With the ap
|
44,958
|
Non-linearity of neural network classification
|
A neural network with a single sigmoid neuron is also a linear classifier when the output is thresholded for classification. But, more than one layer produces a non-linear one because the decision rule can't be written in the following form:
$$\sum w_i x_i+b>\tau$$
where $\tau$ is threshold, $w_i$ are learnable weights and $x_i$ are features. This is why logistic regression is referred as a linear classifier.
|
Non-linearity of neural network classification
|
A neural network with a single sigmoid neuron is also a linear classifier when the output is thresholded for classification. But, more than one layer produces a non-linear one because the decision rul
|
Non-linearity of neural network classification
A neural network with a single sigmoid neuron is also a linear classifier when the output is thresholded for classification. But, more than one layer produces a non-linear one because the decision rule can't be written in the following form:
$$\sum w_i x_i+b>\tau$$
where $\tau$ is threshold, $w_i$ are learnable weights and $x_i$ are features. This is why logistic regression is referred as a linear classifier.
|
Non-linearity of neural network classification
A neural network with a single sigmoid neuron is also a linear classifier when the output is thresholded for classification. But, more than one layer produces a non-linear one because the decision rul
|
44,959
|
How is time series analysis a different problem than forecasting?
|
Forecasting tries to answer questions like "can we predict the distribution of values of a time series variable at some point in the future?" Consider Sugihara's simplex projection (a kind of state space reconstruction method), which can make reasonable short term forecasts on a time series variable, even when that variable is itself causally linked with other unmeasured variables.
Time series analysis may instead ask questions like "what explains the behavior of variables across time?" Consider Abadie's synthetic control methods as ways of explaining the causal effect of policies on macro-level variables.
Your question gets at the distinctions between explanation and prediction. Really good explanations may not give much predictive power. Really good predictive systems, may even behave as a black box, and provide little to no explanation. In a time series context explanation and prediction are also both domains of concern about uncertainty and inference.
Finally, I would say that, my pointing at distinctions between prediction and explanation aside, "time series analysis" is a broad term, and covers explanatory methods, some people would probably see forecasting as a subset of time series methods, and of course, some people will simply be interested in the behavior of a time series (for example in an AR(1) setting, drawing distinctions between strong and weak stationarity and unit root, moving average errors, behavior of expected values, etc.).
Summarizing, I would say that "time series analysis" broadly encompasses:
Description and categorization of time-series behaviors
Prediction of time-series behavior
Explanation of time-series behavior
I read Hyndman as lauding the attention to #2 that the forecasting competitions were producing, including the critical insight that explanatory (but perhaps also descriptive) time-series models do not necessarily produce wonderful predictions.
References
Abadie, A. (2021). Using Synthetic Controls: Feasibility, Data Requirements, and Methodological Aspects. Journal of Economic Literature, 59(2), 391–425.
Rescher, N. (1958). On Prediction and Explanation. The British Journal for the Philosophy of Science, 8(32), 281–290.
Scheffler, I. (1957). Explanation, Prediction, and Abstraction. The British Journal for the Philosophy of Science, 7(28), 293–309.
Shmueli, G. (2010). To Explain or to Predict? Statistical Science, 25(3), 289–310.
Sugihara, G., & May, R. M. (1990). Nonlinear forecasting as a way of distinguishing chaos from measurement error in time series. Nature, 344(6268), 734–741.
|
How is time series analysis a different problem than forecasting?
|
Forecasting tries to answer questions like "can we predict the distribution of values of a time series variable at some point in the future?" Consider Sugihara's simplex projection (a kind of state sp
|
How is time series analysis a different problem than forecasting?
Forecasting tries to answer questions like "can we predict the distribution of values of a time series variable at some point in the future?" Consider Sugihara's simplex projection (a kind of state space reconstruction method), which can make reasonable short term forecasts on a time series variable, even when that variable is itself causally linked with other unmeasured variables.
Time series analysis may instead ask questions like "what explains the behavior of variables across time?" Consider Abadie's synthetic control methods as ways of explaining the causal effect of policies on macro-level variables.
Your question gets at the distinctions between explanation and prediction. Really good explanations may not give much predictive power. Really good predictive systems, may even behave as a black box, and provide little to no explanation. In a time series context explanation and prediction are also both domains of concern about uncertainty and inference.
Finally, I would say that, my pointing at distinctions between prediction and explanation aside, "time series analysis" is a broad term, and covers explanatory methods, some people would probably see forecasting as a subset of time series methods, and of course, some people will simply be interested in the behavior of a time series (for example in an AR(1) setting, drawing distinctions between strong and weak stationarity and unit root, moving average errors, behavior of expected values, etc.).
Summarizing, I would say that "time series analysis" broadly encompasses:
Description and categorization of time-series behaviors
Prediction of time-series behavior
Explanation of time-series behavior
I read Hyndman as lauding the attention to #2 that the forecasting competitions were producing, including the critical insight that explanatory (but perhaps also descriptive) time-series models do not necessarily produce wonderful predictions.
References
Abadie, A. (2021). Using Synthetic Controls: Feasibility, Data Requirements, and Methodological Aspects. Journal of Economic Literature, 59(2), 391–425.
Rescher, N. (1958). On Prediction and Explanation. The British Journal for the Philosophy of Science, 8(32), 281–290.
Scheffler, I. (1957). Explanation, Prediction, and Abstraction. The British Journal for the Philosophy of Science, 7(28), 293–309.
Shmueli, G. (2010). To Explain or to Predict? Statistical Science, 25(3), 289–310.
Sugihara, G., & May, R. M. (1990). Nonlinear forecasting as a way of distinguishing chaos from measurement error in time series. Nature, 344(6268), 734–741.
|
How is time series analysis a different problem than forecasting?
Forecasting tries to answer questions like "can we predict the distribution of values of a time series variable at some point in the future?" Consider Sugihara's simplex projection (a kind of state sp
|
44,960
|
Is "Permutation Test" sufficient for a/b testing?
|
Ultimately permutation tests are a type of statistical significance test; we could have use bootstrapping if we want another frequentist non-parametric approach (e.g. see "How do bootstrap and permutation tests work?" (2003) by Janssen & Pauls for a relevant comparison). Whether or not they should be used instead of standard parametric tests is an question that is really old (e.g. see The large-sample power of tests based on permutations of observations (1952) by Hoeffding as an early attempt to use permutation tests instead of standard parametric tests of hypothesis testing) and doesn't really have a definitive answer. It might be even argued that permutation tests construct a null when there is not a well-defined one while parametric test never shy away from the explicit definition of a null - see Chapt. 17 Large-Scale Hypothesis Testing and FDRs in Computer Age Statistical Inference (2016) by Efron & Hastie for a more careful discussion on that.
Permutation tests therefore are not a statistical panacea. As such, think the question should not be if "permutation testing" is sufficient for A/B testing but if "hypothesis testing" is sufficient for A/B testing. In that case, the answer is no. We need regression analysis, we need to be able to be certain that there are not confounding variables that we accidentally ignored or unexpectedly included, and so forth. Yes, permutation testing is enough in the majority of cases where everything has gone as planned, we observe no seasonality, no primacy or novelty effects, we have limited selection bias, and what not. In order cases, I would strongly urge you to educate yourself in regression analysis and general experimental design principles too. Recently, causal inference has also come to the foreground as a mean to get even greater insights by our observational data but that is a step following standard regression analysis techniques.
Finally, it is notable that while permutation tests are indeed a type of hypothesis testing, A/B testing is a type of an experimentation approach to maximise business goals and using statistical hypothesis testing is only part of the methodology required (parametric or non-parametric, frequentist or Bayesian, etc). For example, multi-armed bandits is another experimentation approach to solve the same problem. Ultimately what we want to maximise our utility functions (e.g. time on client, user expenditure, etc.) That is not what hypothesis testing is aiming to do as it is much more interested in the truthfulness of a hypothesis.
|
Is "Permutation Test" sufficient for a/b testing?
|
Ultimately permutation tests are a type of statistical significance test; we could have use bootstrapping if we want another frequentist non-parametric approach (e.g. see "How do bootstrap and permuta
|
Is "Permutation Test" sufficient for a/b testing?
Ultimately permutation tests are a type of statistical significance test; we could have use bootstrapping if we want another frequentist non-parametric approach (e.g. see "How do bootstrap and permutation tests work?" (2003) by Janssen & Pauls for a relevant comparison). Whether or not they should be used instead of standard parametric tests is an question that is really old (e.g. see The large-sample power of tests based on permutations of observations (1952) by Hoeffding as an early attempt to use permutation tests instead of standard parametric tests of hypothesis testing) and doesn't really have a definitive answer. It might be even argued that permutation tests construct a null when there is not a well-defined one while parametric test never shy away from the explicit definition of a null - see Chapt. 17 Large-Scale Hypothesis Testing and FDRs in Computer Age Statistical Inference (2016) by Efron & Hastie for a more careful discussion on that.
Permutation tests therefore are not a statistical panacea. As such, think the question should not be if "permutation testing" is sufficient for A/B testing but if "hypothesis testing" is sufficient for A/B testing. In that case, the answer is no. We need regression analysis, we need to be able to be certain that there are not confounding variables that we accidentally ignored or unexpectedly included, and so forth. Yes, permutation testing is enough in the majority of cases where everything has gone as planned, we observe no seasonality, no primacy or novelty effects, we have limited selection bias, and what not. In order cases, I would strongly urge you to educate yourself in regression analysis and general experimental design principles too. Recently, causal inference has also come to the foreground as a mean to get even greater insights by our observational data but that is a step following standard regression analysis techniques.
Finally, it is notable that while permutation tests are indeed a type of hypothesis testing, A/B testing is a type of an experimentation approach to maximise business goals and using statistical hypothesis testing is only part of the methodology required (parametric or non-parametric, frequentist or Bayesian, etc). For example, multi-armed bandits is another experimentation approach to solve the same problem. Ultimately what we want to maximise our utility functions (e.g. time on client, user expenditure, etc.) That is not what hypothesis testing is aiming to do as it is much more interested in the truthfulness of a hypothesis.
|
Is "Permutation Test" sufficient for a/b testing?
Ultimately permutation tests are a type of statistical significance test; we could have use bootstrapping if we want another frequentist non-parametric approach (e.g. see "How do bootstrap and permuta
|
44,961
|
Is "Permutation Test" sufficient for a/b testing?
|
Consider the two fictitious normal samples below, in which
sample sizes, sample means, and sample variances all differ.
set.seed(2021)
x1 = rnorm( 70, 50, 5)
x2 = rnorm(100, 53.2, 9)
Someone who did not notice the different variances, might
do a pooled 2-sample t test, find no difference in means
at the 5% level, and conclude nothing interesting is going on.
t.test(x1, x2, var.eq=T)$p.val
[1] 0.07286454
summary(x1); length(x1); sd(x1)
Min. 1st Qu. Median Mean 3rd Qu. Max.
38.72 45.22 49.70 49.55 52.70 60.60
[1] 70 # sample size
[1] 5.366852 # sample standard deviation
summary(x2); length(x2); sd(x2)
Min. 1st Qu. Median Mean 3rd Qu. Max.
28.89 45.37 51.90 51.87 57.64 77.20
[1] 100
[1] 9.805152
stripchart(list(x1,x2), ylim=c(.5,2.5), pch="|")
However, a more appropriate Welch 2-sample t test (that does not
assume equal variances) does find a difference in means at the 5% level.
t.test(x1, x2)$p.val
[1] 0.04866419
And (assuming normality) an F-test finds a highly significant difference
between sample variances.
var.test(x1,x2)$p.val
[1] 3.605368e-07
Even the notoriously underpowered Kolmogorov-Smirnov test
finds that the two population distributions are not quite the same.
ks.test(x1,x2)$p.val
[1] 0.04495466
A nonparametric Wilcoxon Rank Sum test finds a significant difference.
However, owing to the different shapes of the samples, this cannot be
considered as a test for difference in medians.
wilcox.test(x1, x2)
Wilcoxon rank sum test with continuity correction
data: x1 and x2
W = 2878, p-value = 0.04909
alternative hypothesis: true location shift is not equal to 0
Nor is it clear that the (barely significant) 'location shift' really amounts to stochastic
domination by the second (larger) sample [brown in the empirical
CDF plots below.]
hdr = "ECDFs of Samples 1 [blue] and 2 [brown]"
plot(ecdf(x1), col="blue", main=hdr)
lines(ecdf(x2), col="brown")
Furthermore, permutation tests using various metrics could be
proposed, which might show a difference in population means---or not.
Depending on what you mean by "better," you might find a standard
or permutation test to support that either A or B is "better"--or that there is not enough "difference" between them to be of practical
importance.
|
Is "Permutation Test" sufficient for a/b testing?
|
Consider the two fictitious normal samples below, in which
sample sizes, sample means, and sample variances all differ.
set.seed(2021)
x1 = rnorm( 70, 50, 5)
x2 = rnorm(100, 53.2, 9)
Someone who di
|
Is "Permutation Test" sufficient for a/b testing?
Consider the two fictitious normal samples below, in which
sample sizes, sample means, and sample variances all differ.
set.seed(2021)
x1 = rnorm( 70, 50, 5)
x2 = rnorm(100, 53.2, 9)
Someone who did not notice the different variances, might
do a pooled 2-sample t test, find no difference in means
at the 5% level, and conclude nothing interesting is going on.
t.test(x1, x2, var.eq=T)$p.val
[1] 0.07286454
summary(x1); length(x1); sd(x1)
Min. 1st Qu. Median Mean 3rd Qu. Max.
38.72 45.22 49.70 49.55 52.70 60.60
[1] 70 # sample size
[1] 5.366852 # sample standard deviation
summary(x2); length(x2); sd(x2)
Min. 1st Qu. Median Mean 3rd Qu. Max.
28.89 45.37 51.90 51.87 57.64 77.20
[1] 100
[1] 9.805152
stripchart(list(x1,x2), ylim=c(.5,2.5), pch="|")
However, a more appropriate Welch 2-sample t test (that does not
assume equal variances) does find a difference in means at the 5% level.
t.test(x1, x2)$p.val
[1] 0.04866419
And (assuming normality) an F-test finds a highly significant difference
between sample variances.
var.test(x1,x2)$p.val
[1] 3.605368e-07
Even the notoriously underpowered Kolmogorov-Smirnov test
finds that the two population distributions are not quite the same.
ks.test(x1,x2)$p.val
[1] 0.04495466
A nonparametric Wilcoxon Rank Sum test finds a significant difference.
However, owing to the different shapes of the samples, this cannot be
considered as a test for difference in medians.
wilcox.test(x1, x2)
Wilcoxon rank sum test with continuity correction
data: x1 and x2
W = 2878, p-value = 0.04909
alternative hypothesis: true location shift is not equal to 0
Nor is it clear that the (barely significant) 'location shift' really amounts to stochastic
domination by the second (larger) sample [brown in the empirical
CDF plots below.]
hdr = "ECDFs of Samples 1 [blue] and 2 [brown]"
plot(ecdf(x1), col="blue", main=hdr)
lines(ecdf(x2), col="brown")
Furthermore, permutation tests using various metrics could be
proposed, which might show a difference in population means---or not.
Depending on what you mean by "better," you might find a standard
or permutation test to support that either A or B is "better"--or that there is not enough "difference" between them to be of practical
importance.
|
Is "Permutation Test" sufficient for a/b testing?
Consider the two fictitious normal samples below, in which
sample sizes, sample means, and sample variances all differ.
set.seed(2021)
x1 = rnorm( 70, 50, 5)
x2 = rnorm(100, 53.2, 9)
Someone who di
|
44,962
|
Is "Permutation Test" sufficient for a/b testing?
|
It depends. That’s a very broad question.
Permutation testing is one way, of many, for hypothesis testing. In contrast to the more common tests based on sampling distribution, permutation tests tend to be more conservative to accept new evidence (lower power) and less sensitive to assumptions about the population. A downside of these tests is they’re very computationally intensive and impractical for medium or large datasets.
So permutation tests are appropriate for A/B testing if you’re willing to make these trade offs.
|
Is "Permutation Test" sufficient for a/b testing?
|
It depends. That’s a very broad question.
Permutation testing is one way, of many, for hypothesis testing. In contrast to the more common tests based on sampling distribution, permutation tests tend t
|
Is "Permutation Test" sufficient for a/b testing?
It depends. That’s a very broad question.
Permutation testing is one way, of many, for hypothesis testing. In contrast to the more common tests based on sampling distribution, permutation tests tend to be more conservative to accept new evidence (lower power) and less sensitive to assumptions about the population. A downside of these tests is they’re very computationally intensive and impractical for medium or large datasets.
So permutation tests are appropriate for A/B testing if you’re willing to make these trade offs.
|
Is "Permutation Test" sufficient for a/b testing?
It depends. That’s a very broad question.
Permutation testing is one way, of many, for hypothesis testing. In contrast to the more common tests based on sampling distribution, permutation tests tend t
|
44,963
|
Is the Cross Validation Error more "Informative" compared to AIC, BIC and the Likelihood Test?
|
Another thing to bring up in addition to the answers that already exist: AIC, BIC etc. can be really good (i.e. cheap to evaluate, use all the data, let you do things like AIC-model averaging etc.) in the specific circumstances when you can define them and they are valid. What do I mean by this limitation? E.g. for some model class especially with a lot of regularization it can be very hard to even define these (e.g. what is AIC or BIC - especially in terms of the number of parameters - for a XGBoost, a random forest or a convolutional neural network), even if there are various extensions like DIC. Additionally, your model may be rather mis-specified in important ways (e.g. you are using some kind of time series model like ARIMA, but you kind of know that you are mis-specifying the true underlying correlation of records over time). In those situations, I worry whether my likelihood in AIC or BIC is right and whether it may inappropriately overstate (usually more the worry) the evidence for one model vs. another.
Cross-validation is also quite good for optimizing metrics, which are not easy to optimize directly as likelihood function. One example would be optimizing AuROC: while there are some tricks and attempts to define loss functions that directly optimize it, it's not straightforward, but you can fit some model using some standard likelihood function and then make choices based on what optimizes AuROC in cross-validation.
These factors above mean that e.g. in prediction competitions like on Kaggle forms of cross-validation are usually the go-to-method for model evaluation/making modeling choices.
I may be overly negative about the likelihood ratio test, and, yes, I realize that you could re-phrase AIC model selection in terms of model selection with a particular alpha level (but I'd not recommend model selection, anyway, but rather model averaging), but for the purposes where one would consider AIC, BIC or cross-validation, I don't find them all that useful. Sure, a null hypothesis test is useful when you have a pre-specified model for an experiment (e.g. randomized controlled trial of drug A vs. placebo for disease X), but it's a lot less useful for building a good model that performs well by some metric.
I don't really see the distinction for inference models beyond this point. You could clearly define a meaningful cross-validation metric for the example you describe.
I suspect many examples where one technique is used and another might be just as good (or even better), come down to historical precedent in certain research communities. E.g. in some areas AIC is super-popular, in others train-test splits and/or cross-validation, others are really keen on hypothesis tests, and to name another option that has not, yet, been mentioned, there's also various forms of bootstrapping.
|
Is the Cross Validation Error more "Informative" compared to AIC, BIC and the Likelihood Test?
|
Another thing to bring up in addition to the answers that already exist: AIC, BIC etc. can be really good (i.e. cheap to evaluate, use all the data, let you do things like AIC-model averaging etc.) in
|
Is the Cross Validation Error more "Informative" compared to AIC, BIC and the Likelihood Test?
Another thing to bring up in addition to the answers that already exist: AIC, BIC etc. can be really good (i.e. cheap to evaluate, use all the data, let you do things like AIC-model averaging etc.) in the specific circumstances when you can define them and they are valid. What do I mean by this limitation? E.g. for some model class especially with a lot of regularization it can be very hard to even define these (e.g. what is AIC or BIC - especially in terms of the number of parameters - for a XGBoost, a random forest or a convolutional neural network), even if there are various extensions like DIC. Additionally, your model may be rather mis-specified in important ways (e.g. you are using some kind of time series model like ARIMA, but you kind of know that you are mis-specifying the true underlying correlation of records over time). In those situations, I worry whether my likelihood in AIC or BIC is right and whether it may inappropriately overstate (usually more the worry) the evidence for one model vs. another.
Cross-validation is also quite good for optimizing metrics, which are not easy to optimize directly as likelihood function. One example would be optimizing AuROC: while there are some tricks and attempts to define loss functions that directly optimize it, it's not straightforward, but you can fit some model using some standard likelihood function and then make choices based on what optimizes AuROC in cross-validation.
These factors above mean that e.g. in prediction competitions like on Kaggle forms of cross-validation are usually the go-to-method for model evaluation/making modeling choices.
I may be overly negative about the likelihood ratio test, and, yes, I realize that you could re-phrase AIC model selection in terms of model selection with a particular alpha level (but I'd not recommend model selection, anyway, but rather model averaging), but for the purposes where one would consider AIC, BIC or cross-validation, I don't find them all that useful. Sure, a null hypothesis test is useful when you have a pre-specified model for an experiment (e.g. randomized controlled trial of drug A vs. placebo for disease X), but it's a lot less useful for building a good model that performs well by some metric.
I don't really see the distinction for inference models beyond this point. You could clearly define a meaningful cross-validation metric for the example you describe.
I suspect many examples where one technique is used and another might be just as good (or even better), come down to historical precedent in certain research communities. E.g. in some areas AIC is super-popular, in others train-test splits and/or cross-validation, others are really keen on hypothesis tests, and to name another option that has not, yet, been mentioned, there's also various forms of bootstrapping.
|
Is the Cross Validation Error more "Informative" compared to AIC, BIC and the Likelihood Test?
Another thing to bring up in addition to the answers that already exist: AIC, BIC etc. can be really good (i.e. cheap to evaluate, use all the data, let you do things like AIC-model averaging etc.) in
|
44,964
|
Is the Cross Validation Error more "Informative" compared to AIC, BIC and the Likelihood Test?
|
@RichardHardy already gave a partial answer
1) AIC does have an interpretation as twice the negative expected log-likelihood (as mentioned e.g. here). Hence, it is not only a relative measure. Moreover, it is in a sense a measure of error. 2) Cross validation used to be computationally infeasible for some complex models, but AIC/BIC are algebraically infeasible since the models' likelihood and degrees of freedom can be very hard to obtain.
Extending it, notice that things like LR tests or AIC are measured on your training data as compared to out-of-sample approaches like having held out test set for validation, $k$-fold cross-validation, LOOCV, etc. When using the former metrics you are making the assumption that what they measure tells you something that is relevant for judging the potential out-of-sample performance of the model. When using some form of cross-validation you are directly measuring the out-of-sample performance. Of course, your test set is a subsample of the data you gathered, so if your data is not representative for the population, the cross validation metrics would be biased as well.
Moreover, as noted by Richard, using cross validation may be simpler to do (it works for whatever model you want, no math is needed), but more computationally expensive, so there would be cases where you would prefer one of the approaches as compared to the another.
You are not always concerned with out-of-sample performance. Machine learning is concerned about making predictions and it favors cross-validation, statistics is concerned about inference and it often uses the in-sample metrics. See The Two Cultures: statistics vs. machine learning? for details.
Finally, the metrics do not necessarily have sense in machine learning scenario, for example, AIC penalizes the number of parameters, you wouldn't do that for a deep learning model where the number of parameters is always huge and it's not your biggest concern.
|
Is the Cross Validation Error more "Informative" compared to AIC, BIC and the Likelihood Test?
|
@RichardHardy already gave a partial answer
1) AIC does have an interpretation as twice the negative expected log-likelihood (as mentioned e.g. here). Hence, it is not only a relative measure. Moreov
|
Is the Cross Validation Error more "Informative" compared to AIC, BIC and the Likelihood Test?
@RichardHardy already gave a partial answer
1) AIC does have an interpretation as twice the negative expected log-likelihood (as mentioned e.g. here). Hence, it is not only a relative measure. Moreover, it is in a sense a measure of error. 2) Cross validation used to be computationally infeasible for some complex models, but AIC/BIC are algebraically infeasible since the models' likelihood and degrees of freedom can be very hard to obtain.
Extending it, notice that things like LR tests or AIC are measured on your training data as compared to out-of-sample approaches like having held out test set for validation, $k$-fold cross-validation, LOOCV, etc. When using the former metrics you are making the assumption that what they measure tells you something that is relevant for judging the potential out-of-sample performance of the model. When using some form of cross-validation you are directly measuring the out-of-sample performance. Of course, your test set is a subsample of the data you gathered, so if your data is not representative for the population, the cross validation metrics would be biased as well.
Moreover, as noted by Richard, using cross validation may be simpler to do (it works for whatever model you want, no math is needed), but more computationally expensive, so there would be cases where you would prefer one of the approaches as compared to the another.
You are not always concerned with out-of-sample performance. Machine learning is concerned about making predictions and it favors cross-validation, statistics is concerned about inference and it often uses the in-sample metrics. See The Two Cultures: statistics vs. machine learning? for details.
Finally, the metrics do not necessarily have sense in machine learning scenario, for example, AIC penalizes the number of parameters, you wouldn't do that for a deep learning model where the number of parameters is always huge and it's not your biggest concern.
|
Is the Cross Validation Error more "Informative" compared to AIC, BIC and the Likelihood Test?
@RichardHardy already gave a partial answer
1) AIC does have an interpretation as twice the negative expected log-likelihood (as mentioned e.g. here). Hence, it is not only a relative measure. Moreov
|
44,965
|
T-tests provide info about the margin of mean difference?
|
if I can use the t-test to claim that one dataset provides significantly better results than the other
I wanted to point out that the expression "statistically significant" has been discouraged by the American Statistical Association. (But personally, I don't feel too strongly against it)
use confidence intervals (or some other method) to show that one performs better than the other one
Confidence intervals can be interpreted as the range of values compatible with the observed data given the assumptions. In fact, it's been suggested that they should be renamed compatibility intervals (see Is the interpretation of a "Compatibility Interval" (Greenland, 2019) valid in general? and links therein).
So it seems to me that reporting confidence intervals is appropriate in your case from that little bit I can tell.
I would also note that there is a duality between p-values and confidence intervals since the 95% confidence interval is the range where the p-value becomes greater than 0.05 (or whatever alpha you chose to determine the interval). So the confidence interval is often considered a more informative alternative to the p-value for reporting results.
|
T-tests provide info about the margin of mean difference?
|
if I can use the t-test to claim that one dataset provides significantly better results than the other
I wanted to point out that the expression "statistically significant" has been discouraged by th
|
T-tests provide info about the margin of mean difference?
if I can use the t-test to claim that one dataset provides significantly better results than the other
I wanted to point out that the expression "statistically significant" has been discouraged by the American Statistical Association. (But personally, I don't feel too strongly against it)
use confidence intervals (or some other method) to show that one performs better than the other one
Confidence intervals can be interpreted as the range of values compatible with the observed data given the assumptions. In fact, it's been suggested that they should be renamed compatibility intervals (see Is the interpretation of a "Compatibility Interval" (Greenland, 2019) valid in general? and links therein).
So it seems to me that reporting confidence intervals is appropriate in your case from that little bit I can tell.
I would also note that there is a duality between p-values and confidence intervals since the 95% confidence interval is the range where the p-value becomes greater than 0.05 (or whatever alpha you chose to determine the interval). So the confidence interval is often considered a more informative alternative to the p-value for reporting results.
|
T-tests provide info about the margin of mean difference?
if I can use the t-test to claim that one dataset provides significantly better results than the other
I wanted to point out that the expression "statistically significant" has been discouraged by th
|
44,966
|
T-tests provide info about the margin of mean difference?
|
Consider the two independent fictitious normal datasets below.
set.seed(910)
x1 = rnorm(100, 50, 7)
x2 = rnorm(90, 60, 8)
mean(x1)
[1] 49.86995
mean(x2)
[1] 60.04863
The sample means show $\bar X_1 < \bar X_2$ suggesting that $\mu_1$ may be 'significantly' smaller than $\mu_2.$ Welch two-sample t test in R shows that the null hypothesis $H_0: \mu_1 = \mu_2$ is rejected in
favor of $H_a: \mu_1 < \mu_2.$ with P-value near $0.$
More specifically, the one sided CI: shows 95% confidence that
$\mu_1 - \mu_2 \le -8.412.$
t.test(x1, x2, alt="less")
Welch Two Sample t-test
data: x1 and x2
t = -9.5241, df = 187.95, p-value < 2.2e-16
alternative hypothesis:
true difference in means is less than 0
95 percent confidence interval:
-Inf -8.412074
sample estimates:
mean of x mean of y
49.86995 60.04863
Nothing here is a 'proof' that $\mu_1 < \mu_2.$ Of course, because
I simulated these data, we know $\mu_1 - \mu_2 = -10.$ However,
in a real statistical application we would not have such exact information.
The best we can do is to
report that sample means show $\bar X_1 =49.87 < \bar X_2 = 60.05$
and to say we are
'reasonably sure' that $\mu_1 - \mu_2 \le -8.412.$
|
T-tests provide info about the margin of mean difference?
|
Consider the two independent fictitious normal datasets below.
set.seed(910)
x1 = rnorm(100, 50, 7)
x2 = rnorm(90, 60, 8)
mean(x1)
[1] 49.86995
mean(x2)
[1] 60.04863
The sample means show $\bar X_1
|
T-tests provide info about the margin of mean difference?
Consider the two independent fictitious normal datasets below.
set.seed(910)
x1 = rnorm(100, 50, 7)
x2 = rnorm(90, 60, 8)
mean(x1)
[1] 49.86995
mean(x2)
[1] 60.04863
The sample means show $\bar X_1 < \bar X_2$ suggesting that $\mu_1$ may be 'significantly' smaller than $\mu_2.$ Welch two-sample t test in R shows that the null hypothesis $H_0: \mu_1 = \mu_2$ is rejected in
favor of $H_a: \mu_1 < \mu_2.$ with P-value near $0.$
More specifically, the one sided CI: shows 95% confidence that
$\mu_1 - \mu_2 \le -8.412.$
t.test(x1, x2, alt="less")
Welch Two Sample t-test
data: x1 and x2
t = -9.5241, df = 187.95, p-value < 2.2e-16
alternative hypothesis:
true difference in means is less than 0
95 percent confidence interval:
-Inf -8.412074
sample estimates:
mean of x mean of y
49.86995 60.04863
Nothing here is a 'proof' that $\mu_1 < \mu_2.$ Of course, because
I simulated these data, we know $\mu_1 - \mu_2 = -10.$ However,
in a real statistical application we would not have such exact information.
The best we can do is to
report that sample means show $\bar X_1 =49.87 < \bar X_2 = 60.05$
and to say we are
'reasonably sure' that $\mu_1 - \mu_2 \le -8.412.$
|
T-tests provide info about the margin of mean difference?
Consider the two independent fictitious normal datasets below.
set.seed(910)
x1 = rnorm(100, 50, 7)
x2 = rnorm(90, 60, 8)
mean(x1)
[1] 49.86995
mean(x2)
[1] 60.04863
The sample means show $\bar X_1
|
44,967
|
T-tests provide info about the margin of mean difference?
|
If the null hypothesis is $t=0$, then this is testing if the two means are the same or not. But you can also test $t > a$, then this tests if the margin is larger than some number.
|
T-tests provide info about the margin of mean difference?
|
If the null hypothesis is $t=0$, then this is testing if the two means are the same or not. But you can also test $t > a$, then this tests if the margin is larger than some number.
|
T-tests provide info about the margin of mean difference?
If the null hypothesis is $t=0$, then this is testing if the two means are the same or not. But you can also test $t > a$, then this tests if the margin is larger than some number.
|
T-tests provide info about the margin of mean difference?
If the null hypothesis is $t=0$, then this is testing if the two means are the same or not. But you can also test $t > a$, then this tests if the margin is larger than some number.
|
44,968
|
Paired t-test with multiple observations per pair
|
Averaging the data will result in a loss information and statistical power, so it is best avoided.
Since you have repeated measures for websites, you can account the differences between websites (or equivalently, the non-independence of observations within each website, since observations on one website are more likely to be similar to each other than to observations on other websites), by fitting random intercepts for website ID in a regression model (a mixed effects regression model). This would look something like:
apply_technique ~ treatment + (1 | website_ID)
and you could fit such a model using lmer from the lme4 package. This way you will make maximal use of the data.
|
Paired t-test with multiple observations per pair
|
Averaging the data will result in a loss information and statistical power, so it is best avoided.
Since you have repeated measures for websites, you can account the differences between websites (or e
|
Paired t-test with multiple observations per pair
Averaging the data will result in a loss information and statistical power, so it is best avoided.
Since you have repeated measures for websites, you can account the differences between websites (or equivalently, the non-independence of observations within each website, since observations on one website are more likely to be similar to each other than to observations on other websites), by fitting random intercepts for website ID in a regression model (a mixed effects regression model). This would look something like:
apply_technique ~ treatment + (1 | website_ID)
and you could fit such a model using lmer from the lme4 package. This way you will make maximal use of the data.
|
Paired t-test with multiple observations per pair
Averaging the data will result in a loss information and statistical power, so it is best avoided.
Since you have repeated measures for websites, you can account the differences between websites (or e
|
44,969
|
Paired t-test with multiple observations per pair
|
If each group has the same number of members, then the mean of the group means is the same as the mean over all the observations. The sd can be more complicated, depending on what you're taking as your null hypothesis. One of the simplest null hypotheses is that each observation is equal to $\mu(W)+\epsilon$, where $\mu$ is some function of the website (that is, $\mu: \text {set of websites} \rightarrow \mathbb R$), and $\epsilon$ is normally distributed with zero mean and sd that is independent of the website. A more complicated null hypothesis would have the sd of $\epsilon$ depend on the website (there is no need to consider the possibility that the mean is nonzero or depends on the website, as that is absorbed into $\mu(W)$).
If your null hypothesis has constant $\sigma$, then $s$ should be calculated on the set of observations as a whole. However, if your null doesn't have a single $\sigma$, then you won't be able to calculate a single $s$. You'll have to calculate a different $s$ and thus $p$ for each website, then use some method of combining them. For this to be rigorous, you should decide on the combination method before collecting any data.
Now, if you reject this null, then you are rejecting the hypothesis that the statistic is normally distributed and the mean for the two conditions is the same. So the null being false means that the means are different or the statistic isn't normally distributed. If you think, looking at the data, that the statistic isn't normally distributed, then testing whether the means are the same requires an adjustment, but that runs into the issue of HARKing.
|
Paired t-test with multiple observations per pair
|
If each group has the same number of members, then the mean of the group means is the same as the mean over all the observations. The sd can be more complicated, depending on what you're taking as you
|
Paired t-test with multiple observations per pair
If each group has the same number of members, then the mean of the group means is the same as the mean over all the observations. The sd can be more complicated, depending on what you're taking as your null hypothesis. One of the simplest null hypotheses is that each observation is equal to $\mu(W)+\epsilon$, where $\mu$ is some function of the website (that is, $\mu: \text {set of websites} \rightarrow \mathbb R$), and $\epsilon$ is normally distributed with zero mean and sd that is independent of the website. A more complicated null hypothesis would have the sd of $\epsilon$ depend on the website (there is no need to consider the possibility that the mean is nonzero or depends on the website, as that is absorbed into $\mu(W)$).
If your null hypothesis has constant $\sigma$, then $s$ should be calculated on the set of observations as a whole. However, if your null doesn't have a single $\sigma$, then you won't be able to calculate a single $s$. You'll have to calculate a different $s$ and thus $p$ for each website, then use some method of combining them. For this to be rigorous, you should decide on the combination method before collecting any data.
Now, if you reject this null, then you are rejecting the hypothesis that the statistic is normally distributed and the mean for the two conditions is the same. So the null being false means that the means are different or the statistic isn't normally distributed. If you think, looking at the data, that the statistic isn't normally distributed, then testing whether the means are the same requires an adjustment, but that runs into the issue of HARKing.
|
Paired t-test with multiple observations per pair
If each group has the same number of members, then the mean of the group means is the same as the mean over all the observations. The sd can be more complicated, depending on what you're taking as you
|
44,970
|
Lowercase $x$ vs Uppercase $X$ in statistics
|
In this context, capitalisation is usually used to distinguish random variables from fixed values, so you are correct to interpret $X: \Omega \rightarrow \mathbb{R}$ as a random variable. The post specifies that it is considering a sequence of random variables $X_n : \Omega \rightarrow \mathbb{R}$, so there are an infinite number of these random variables, of the form:
$$\begin{align}
X_1(\omega) &= (1+\tfrac{1}{1}) X(\omega), \\[6pt]
X_2(\omega) &= (1+\tfrac{1}{2}) X(\omega), \\[6pt]
X_3(\omega) &= (1+\tfrac{1}{3}) X(\omega), \\[6pt]
&\ \ \vdots \\[6pt]
X_n(\omega) &= (1+\tfrac{1}{n}) X(\omega), \\[6pt]
&\ \ \vdots \\[6pt]
\end{align}$$
Finally, the value $n$ here has nothing to do with the size of $\Omega$ or any other substantive property of the sample space. It is merely an index used to specify the form of the random variables in the sequence --- the post could just as easily have used the index $i$, or any other variable notation here.
|
Lowercase $x$ vs Uppercase $X$ in statistics
|
In this context, capitalisation is usually used to distinguish random variables from fixed values, so you are correct to interpret $X: \Omega \rightarrow \mathbb{R}$ as a random variable. The post sp
|
Lowercase $x$ vs Uppercase $X$ in statistics
In this context, capitalisation is usually used to distinguish random variables from fixed values, so you are correct to interpret $X: \Omega \rightarrow \mathbb{R}$ as a random variable. The post specifies that it is considering a sequence of random variables $X_n : \Omega \rightarrow \mathbb{R}$, so there are an infinite number of these random variables, of the form:
$$\begin{align}
X_1(\omega) &= (1+\tfrac{1}{1}) X(\omega), \\[6pt]
X_2(\omega) &= (1+\tfrac{1}{2}) X(\omega), \\[6pt]
X_3(\omega) &= (1+\tfrac{1}{3}) X(\omega), \\[6pt]
&\ \ \vdots \\[6pt]
X_n(\omega) &= (1+\tfrac{1}{n}) X(\omega), \\[6pt]
&\ \ \vdots \\[6pt]
\end{align}$$
Finally, the value $n$ here has nothing to do with the size of $\Omega$ or any other substantive property of the sample space. It is merely an index used to specify the form of the random variables in the sequence --- the post could just as easily have used the index $i$, or any other variable notation here.
|
Lowercase $x$ vs Uppercase $X$ in statistics
In this context, capitalisation is usually used to distinguish random variables from fixed values, so you are correct to interpret $X: \Omega \rightarrow \mathbb{R}$ as a random variable. The post sp
|
44,971
|
Lowercase $x$ vs Uppercase $X$ in statistics
|
You are correct that $X$ is a Borel function $X : \Omega\to\mathbb R$. A realization of $X$ is a particular real number $X(\omega)$, and such a number may be referred to as $x$. This means, for example, the event $\{X = x\}$ is more formally written as $\{\omega\in\Omega : X(\omega) = x\}$.
We can define as many functions as we want from $\Omega$ to $\mathbb R$, so e.g. we can imagine having $X_1, X_2, \dots : \Omega\to\mathbb R$. If $X_i = a_i X$ for constants $a_i\in\mathbb R$ then each function $X_i$ is also Borel so these are all random variables too. $n$ is often used to index a sequence of random variables so I could refer to $X_n$ as an arbitrary element of the sequence of functions $X_1, X_2, \dots$ instead of using $X_i$ or some other indexing variable. This use of $n$ is totally different from that of a sample size, although often the sequence of RVs in question comes from imagining taking bigger and bigger samples so $X_n$ may correspond to a sample of $n$ things, but it doesn't have to.
We can then ask about how the sequence of RVs evolves by letting $n \to \infty$. For example, in your case since $a_n \to 1$ as $n\to\infty$ we'll have $X_n$ converging on $X$ in some sense.
|
Lowercase $x$ vs Uppercase $X$ in statistics
|
You are correct that $X$ is a Borel function $X : \Omega\to\mathbb R$. A realization of $X$ is a particular real number $X(\omega)$, and such a number may be referred to as $x$. This means, for exampl
|
Lowercase $x$ vs Uppercase $X$ in statistics
You are correct that $X$ is a Borel function $X : \Omega\to\mathbb R$. A realization of $X$ is a particular real number $X(\omega)$, and such a number may be referred to as $x$. This means, for example, the event $\{X = x\}$ is more formally written as $\{\omega\in\Omega : X(\omega) = x\}$.
We can define as many functions as we want from $\Omega$ to $\mathbb R$, so e.g. we can imagine having $X_1, X_2, \dots : \Omega\to\mathbb R$. If $X_i = a_i X$ for constants $a_i\in\mathbb R$ then each function $X_i$ is also Borel so these are all random variables too. $n$ is often used to index a sequence of random variables so I could refer to $X_n$ as an arbitrary element of the sequence of functions $X_1, X_2, \dots$ instead of using $X_i$ or some other indexing variable. This use of $n$ is totally different from that of a sample size, although often the sequence of RVs in question comes from imagining taking bigger and bigger samples so $X_n$ may correspond to a sample of $n$ things, but it doesn't have to.
We can then ask about how the sequence of RVs evolves by letting $n \to \infty$. For example, in your case since $a_n \to 1$ as $n\to\infty$ we'll have $X_n$ converging on $X$ in some sense.
|
Lowercase $x$ vs Uppercase $X$ in statistics
You are correct that $X$ is a Borel function $X : \Omega\to\mathbb R$. A realization of $X$ is a particular real number $X(\omega)$, and such a number may be referred to as $x$. This means, for exampl
|
44,972
|
Comparing two, or more, independent paired t-tests
|
Using the difference between t2 and t1 as feature should work; one can use ANOVA to test the equality of the means.
Note that there are post-hoc tests that allow you to get more insight into the differences, if any, found. This allows you to identify which means deviate. These post-hoc tests take into account that multiple test are being made; i.e. 'Bonferroni test' included.
You can also use a two way ANOVA if you want to add gender as second variable.
Would you want to add more variables, you could try to setup the tests as a hierarchical linear regression problem with dummy variables. Starting out with a model with a single mean, and comparing this model to one that has two dummy variables for the experimental conditions would give you the answer you want. The smaller and the larger model can be compared because the models are considered hierarchical; i.e. the larger model extends the smaller model.
Using an extra dummy for gender, and potentially dummies for interaction effects for gender x treatment, one can squeeze a lot of information out of the data. Note that one has to apply some Bonferroni type correction in this case. One would like to do some kind of power analysis upfront to see if the sample size sustains multiple testing without loosing to much power.
Happy testing!
|
Comparing two, or more, independent paired t-tests
|
Using the difference between t2 and t1 as feature should work; one can use ANOVA to test the equality of the means.
Note that there are post-hoc tests that allow you to get more insight into the diffe
|
Comparing two, or more, independent paired t-tests
Using the difference between t2 and t1 as feature should work; one can use ANOVA to test the equality of the means.
Note that there are post-hoc tests that allow you to get more insight into the differences, if any, found. This allows you to identify which means deviate. These post-hoc tests take into account that multiple test are being made; i.e. 'Bonferroni test' included.
You can also use a two way ANOVA if you want to add gender as second variable.
Would you want to add more variables, you could try to setup the tests as a hierarchical linear regression problem with dummy variables. Starting out with a model with a single mean, and comparing this model to one that has two dummy variables for the experimental conditions would give you the answer you want. The smaller and the larger model can be compared because the models are considered hierarchical; i.e. the larger model extends the smaller model.
Using an extra dummy for gender, and potentially dummies for interaction effects for gender x treatment, one can squeeze a lot of information out of the data. Note that one has to apply some Bonferroni type correction in this case. One would like to do some kind of power analysis upfront to see if the sample size sustains multiple testing without loosing to much power.
Happy testing!
|
Comparing two, or more, independent paired t-tests
Using the difference between t2 and t1 as feature should work; one can use ANOVA to test the equality of the means.
Note that there are post-hoc tests that allow you to get more insight into the diffe
|
44,973
|
Comparing two, or more, independent paired t-tests
|
Dunnett's test is the canonical test for a one-way ANOVA of various treatments versus control. It has slightly more statistical power compared to multiple independent t-tests with Bonferoni corrections under the baseline assumptions.
See the Wikipedia entry on Dunnett's test: https://en.wikipedia.org/wiki/Dunnett%27s_test
Any good design of experiments text book will have a discussion of a one-way ANOVA and Dunnett's test. See this STATS 503 class: https://online.stat.psu.edu/stat503/lesson/3/3.1
Here is an example analysis in R code:
require(DescTools)
#> Loading required package: DescTools
require(ggplot2)
#> Loading required package: ggplot2
# Simulate Data
set.seed(184873)
NperTreat <- 20
dat <- data.frame(group = factor(rep(c("Control", "Treat1", "Treat2"), each = NperTreat)),
t1 = rnorm(3*NperTreat, 74.7, 15.46),
t2 = c(rnorm(NperTreat, 74.7, 15.46),
rnorm(NperTreat, 74.7 - 2, 15.46),
rnorm(NperTreat, 74.7 - 15, 15.46)))
dat$weight_difference <- dat$t2 - dat$t1
ggplot(dat, aes(x = group, y = weight_difference)) + geom_boxplot()
mod1 <- aov(weight_difference ~ group, data = dat)
summary(mod1)
#> Df Sum Sq Mean Sq F value Pr(>F)
#> group 2 6043 3022 4.827 0.0116 *
#> Residuals 57 35684 626
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# There is at least one difference between the group means p = 0.00116
DescTools::DunnettTest(dat$weight_difference, g = dat$group, control = "Control")
#>
#> Dunnett's test for comparing several treatments with a control :
#> 95% family-wise confidence level
#>
#> $Control
#> diff lwr.ci upr.ci pval
#> Treat1-Control -0.9113978 -18.85869 17.035898 0.9903
#> Treat2-Control -21.7305135 -39.67781 -3.783218 0.0153 *
#>
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# there is insufficient evidence to conclude treatment1 is differnt from control p = 0.9903
# treatment 2 is different from control by an estimated 21 kg p = 0.0153
################################################################################
# Two independent t-tests have less power than Dunnett's to detect a difference
# a test at alpha = 0.05 / 2 is equivalent to a confidence level of 1 - 0.05 / 2
with(dat, t.test(weight_difference[group == "Treat1"],
weight_difference[group == "Control"],
conf.level = 0.975))
#>
#> Welch Two Sample t-test
#>
#> data: weight_difference[group == "Treat1"] and weight_difference[group == "Control"]
#> t = -0.10537, df = 37.985, p-value = 0.9166
#> alternative hypothesis: true difference in means is not equal to 0
#> 97.5 percent confidence interval:
#> -21.09656 19.27376
#> sample estimates:
#> mean of x mean of y
#> -1.8206320 -0.9092341
with(dat, t.test(weight_difference[group == "Treat2"],
weight_difference[group == "Control"],
conf.level = 0.975))
#>
#> Welch Two Sample t-test
#>
#> data: weight_difference[group == "Treat2"] and weight_difference[group == "Control"]
#> t = -2.9104, df = 34.572, p-value = 0.006276
#> alternative hypothesis: true difference in means is not equal to 0
#> 97.5 percent confidence interval:
#> -39.226556 -4.234471
#> sample estimates:
#> mean of x mean of y
#> -22.6397477 -0.9092341
################################################################################
# with additional co-variates, you can switch to a regression
dat$age <- runif(NperTreat*3, 18, 65)
lm1 <- lm(weight_difference ~ group + age, data = dat)
summary(lm1)
#>
#> Call:
#> lm(formula = weight_difference ~ group + age, data = dat)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -50.505 -19.415 2.283 16.157 60.701
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 1.96136 11.56566 0.170 0.86595
#> groupTreat1 -1.17136 8.02909 -0.146 0.88453
#> groupTreat2 -21.55551 8.00057 -2.694 0.00929 **
#> age -0.06888 0.24229 -0.284 0.77723
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> Residual standard error: 25.23 on 56 degrees of freedom
#> Multiple R-squared: 0.1461, Adjusted R-squared: 0.1003
#> F-statistic: 3.193 on 3 and 56 DF, p-value: 0.03038
# There is at least one significant explanatory variable p = 0.03038
# After accounting for age, there is insufficient evidence to conclude there is a difference due to treatment 1 p = 0.88453
# After accounting for age, there is a significant effect due to Treatment 2 p = 0.00929
|
Comparing two, or more, independent paired t-tests
|
Dunnett's test is the canonical test for a one-way ANOVA of various treatments versus control. It has slightly more statistical power compared to multiple independent t-tests with Bonferoni correctio
|
Comparing two, or more, independent paired t-tests
Dunnett's test is the canonical test for a one-way ANOVA of various treatments versus control. It has slightly more statistical power compared to multiple independent t-tests with Bonferoni corrections under the baseline assumptions.
See the Wikipedia entry on Dunnett's test: https://en.wikipedia.org/wiki/Dunnett%27s_test
Any good design of experiments text book will have a discussion of a one-way ANOVA and Dunnett's test. See this STATS 503 class: https://online.stat.psu.edu/stat503/lesson/3/3.1
Here is an example analysis in R code:
require(DescTools)
#> Loading required package: DescTools
require(ggplot2)
#> Loading required package: ggplot2
# Simulate Data
set.seed(184873)
NperTreat <- 20
dat <- data.frame(group = factor(rep(c("Control", "Treat1", "Treat2"), each = NperTreat)),
t1 = rnorm(3*NperTreat, 74.7, 15.46),
t2 = c(rnorm(NperTreat, 74.7, 15.46),
rnorm(NperTreat, 74.7 - 2, 15.46),
rnorm(NperTreat, 74.7 - 15, 15.46)))
dat$weight_difference <- dat$t2 - dat$t1
ggplot(dat, aes(x = group, y = weight_difference)) + geom_boxplot()
mod1 <- aov(weight_difference ~ group, data = dat)
summary(mod1)
#> Df Sum Sq Mean Sq F value Pr(>F)
#> group 2 6043 3022 4.827 0.0116 *
#> Residuals 57 35684 626
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# There is at least one difference between the group means p = 0.00116
DescTools::DunnettTest(dat$weight_difference, g = dat$group, control = "Control")
#>
#> Dunnett's test for comparing several treatments with a control :
#> 95% family-wise confidence level
#>
#> $Control
#> diff lwr.ci upr.ci pval
#> Treat1-Control -0.9113978 -18.85869 17.035898 0.9903
#> Treat2-Control -21.7305135 -39.67781 -3.783218 0.0153 *
#>
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# there is insufficient evidence to conclude treatment1 is differnt from control p = 0.9903
# treatment 2 is different from control by an estimated 21 kg p = 0.0153
################################################################################
# Two independent t-tests have less power than Dunnett's to detect a difference
# a test at alpha = 0.05 / 2 is equivalent to a confidence level of 1 - 0.05 / 2
with(dat, t.test(weight_difference[group == "Treat1"],
weight_difference[group == "Control"],
conf.level = 0.975))
#>
#> Welch Two Sample t-test
#>
#> data: weight_difference[group == "Treat1"] and weight_difference[group == "Control"]
#> t = -0.10537, df = 37.985, p-value = 0.9166
#> alternative hypothesis: true difference in means is not equal to 0
#> 97.5 percent confidence interval:
#> -21.09656 19.27376
#> sample estimates:
#> mean of x mean of y
#> -1.8206320 -0.9092341
with(dat, t.test(weight_difference[group == "Treat2"],
weight_difference[group == "Control"],
conf.level = 0.975))
#>
#> Welch Two Sample t-test
#>
#> data: weight_difference[group == "Treat2"] and weight_difference[group == "Control"]
#> t = -2.9104, df = 34.572, p-value = 0.006276
#> alternative hypothesis: true difference in means is not equal to 0
#> 97.5 percent confidence interval:
#> -39.226556 -4.234471
#> sample estimates:
#> mean of x mean of y
#> -22.6397477 -0.9092341
################################################################################
# with additional co-variates, you can switch to a regression
dat$age <- runif(NperTreat*3, 18, 65)
lm1 <- lm(weight_difference ~ group + age, data = dat)
summary(lm1)
#>
#> Call:
#> lm(formula = weight_difference ~ group + age, data = dat)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -50.505 -19.415 2.283 16.157 60.701
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 1.96136 11.56566 0.170 0.86595
#> groupTreat1 -1.17136 8.02909 -0.146 0.88453
#> groupTreat2 -21.55551 8.00057 -2.694 0.00929 **
#> age -0.06888 0.24229 -0.284 0.77723
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> Residual standard error: 25.23 on 56 degrees of freedom
#> Multiple R-squared: 0.1461, Adjusted R-squared: 0.1003
#> F-statistic: 3.193 on 3 and 56 DF, p-value: 0.03038
# There is at least one significant explanatory variable p = 0.03038
# After accounting for age, there is insufficient evidence to conclude there is a difference due to treatment 1 p = 0.88453
# After accounting for age, there is a significant effect due to Treatment 2 p = 0.00929
|
Comparing two, or more, independent paired t-tests
Dunnett's test is the canonical test for a one-way ANOVA of various treatments versus control. It has slightly more statistical power compared to multiple independent t-tests with Bonferoni correctio
|
44,974
|
Comparing two, or more, independent paired t-tests
|
There is no reason you cannot just apply ANOVA with a standard regression model in this case. Taking three seperate T-tests and combining them into a single inference is inferior to conducting a single ANOVA with a model that includes data from all the groups.
In regard to your concerns about ANOVA, it is important to note that ANOVA is a method of analysis, not a model (see e.g., here). It can be applied to a linear regression model irrespective of the particular terms and interactions you include or exclude from your model.
The simplest way to undertake this kind of analysis with your data would be to form a new variable for the weight difference (i.e., weight at the later time minus weight at the earlier time). You can easily form a linear regression model with the drug as your sole explanatory variable and the weight difference as your response variable. The model formula (in R notation) would be:
weight.diff ~ factor(drug)
If you form a model like this then you can easily apply ANOVA to test whether or not there is a statistical relationship between the drug variable and the weight.diff variable. It is best to do a holistic ANOVA for all groups first, and then proceed down to individual tests afterward, with proper consideration of multiple comparisons. Note also that one thing that is important in this kind of work is for your drug allocations to be randomised so that you are doing an Randomised Controlled Trial (RCT). Randomisation of your drug allocations, and use of placebos for the control group, should ensure that your drug variable is not statistically dependent with any possible confounding factors, which allows you to make causal inferences from your statistical inferences.
|
Comparing two, or more, independent paired t-tests
|
There is no reason you cannot just apply ANOVA with a standard regression model in this case. Taking three seperate T-tests and combining them into a single inference is inferior to conducting a sing
|
Comparing two, or more, independent paired t-tests
There is no reason you cannot just apply ANOVA with a standard regression model in this case. Taking three seperate T-tests and combining them into a single inference is inferior to conducting a single ANOVA with a model that includes data from all the groups.
In regard to your concerns about ANOVA, it is important to note that ANOVA is a method of analysis, not a model (see e.g., here). It can be applied to a linear regression model irrespective of the particular terms and interactions you include or exclude from your model.
The simplest way to undertake this kind of analysis with your data would be to form a new variable for the weight difference (i.e., weight at the later time minus weight at the earlier time). You can easily form a linear regression model with the drug as your sole explanatory variable and the weight difference as your response variable. The model formula (in R notation) would be:
weight.diff ~ factor(drug)
If you form a model like this then you can easily apply ANOVA to test whether or not there is a statistical relationship between the drug variable and the weight.diff variable. It is best to do a holistic ANOVA for all groups first, and then proceed down to individual tests afterward, with proper consideration of multiple comparisons. Note also that one thing that is important in this kind of work is for your drug allocations to be randomised so that you are doing an Randomised Controlled Trial (RCT). Randomisation of your drug allocations, and use of placebos for the control group, should ensure that your drug variable is not statistically dependent with any possible confounding factors, which allows you to make causal inferences from your statistical inferences.
|
Comparing two, or more, independent paired t-tests
There is no reason you cannot just apply ANOVA with a standard regression model in this case. Taking three seperate T-tests and combining them into a single inference is inferior to conducting a sing
|
44,975
|
Comparing two, or more, independent paired t-tests
|
Yes, you can compare multiple independent t-tests, but note that by doing so you increase the probability of making a Type-I error. Assuming an $\alpha$ of .05, the probability of a Type-I error is 14.3% if comparing between three groups.
Instead of comparing the start and end weights as a pair, compare the difference between the two. I.e, for every participant, subtract the end from the start, and run an ANOVA on that value.
|
Comparing two, or more, independent paired t-tests
|
Yes, you can compare multiple independent t-tests, but note that by doing so you increase the probability of making a Type-I error. Assuming an $\alpha$ of .05, the probability of a Type-I error is 14
|
Comparing two, or more, independent paired t-tests
Yes, you can compare multiple independent t-tests, but note that by doing so you increase the probability of making a Type-I error. Assuming an $\alpha$ of .05, the probability of a Type-I error is 14.3% if comparing between three groups.
Instead of comparing the start and end weights as a pair, compare the difference between the two. I.e, for every participant, subtract the end from the start, and run an ANOVA on that value.
|
Comparing two, or more, independent paired t-tests
Yes, you can compare multiple independent t-tests, but note that by doing so you increase the probability of making a Type-I error. Assuming an $\alpha$ of .05, the probability of a Type-I error is 14
|
44,976
|
Comparing two, or more, independent paired t-tests
|
If you compare multiple independent t-test(s) you should counteract the multiple comparison problem.
If you want to go down this path, one way to tackle the multi comparison problem is to use theBonferroni correction but others are available. you can find a bunch of them here.
|
Comparing two, or more, independent paired t-tests
|
If you compare multiple independent t-test(s) you should counteract the multiple comparison problem.
If you want to go down this path, one way to tackle the multi comparison problem is to use theBonfe
|
Comparing two, or more, independent paired t-tests
If you compare multiple independent t-test(s) you should counteract the multiple comparison problem.
If you want to go down this path, one way to tackle the multi comparison problem is to use theBonferroni correction but others are available. you can find a bunch of them here.
|
Comparing two, or more, independent paired t-tests
If you compare multiple independent t-test(s) you should counteract the multiple comparison problem.
If you want to go down this path, one way to tackle the multi comparison problem is to use theBonfe
|
44,977
|
Comparing two, or more, independent paired t-tests
|
Instead of doing ANOVA, I want to make three independent paired t-tests, i.e, one paired t-test for each one of the groups (measuring weight before and weight after).
...
Can I compare the outputs from the three paired t-tests?
You can do this with Tukey's range method
It is actually relatively similar and there are similar rejection regions (similar for rejecting the null hypothesis $\mu_1=\mu_2=\mu_3$ Tukey's method versus anova).
The F-statistic in anova can be computed from the t-statistics (when these are computed with the pooled standard deviation).
$$F = \frac{t_1^2+t_2^2+t_3^2}{3}$$
With Tukey's method you are regarding the maximum of the absolute value of the t-statistics.
$$q = max(|t_1|,|t_2|,|t_3|)$$
The method is more complex with ordering of the means and finding groups with significant differences, but the control of the FWER is done based on this maximum range. (While this test is often performed as a post-hoc test for ANOVA, you do not need to do ANOVA before Tukey's method. The FWER is controlled by using the studentized range distribution for the cutoff for $q$.)
Demonstration/visualisation/simulation
Below is a simulation assuming the populations are normal distributed with equal variances and equal means.
We plot two out of the three t-statistics (from $10^4$ different simulations). The third t-statistic is fully dependent on these two.
The t-statistics are correlated and not independent (see the clouds of points being an elongated shape). This is because the different t-statistics are computed with similar groups. If $t_1$ relates to the difference 'treatment1 - placebo' and $t_2$ relates to the difference 'treatment2 - placebo', then the placebo sample will have a similar effect on both $t_1$ and $t_2$ which is how they become correlated.
This is the reason why the 'multiple comparison problem' should not be tackled with something like the Šidák correction as suggested by some. Instead you should use the studentized range distribution to determine the FWER.
For a given maximum range the F-statistic can have different values.
Say the lowest mean is 0 and the highest mean is 1. The total variance will depend on the third mean and is highest when it is close to 0 or 1 and lowest when it is close to 0.5.
So, you might have a situation that the treatment 1 is significantly different according to Tukey's test, but depending on treatment 2 the ANOVA result can be more not significant (and vice-versa: R Tukey HSD Anova: Anova significant, Tukey not?).
Strangely the anova test can fail when the treatment 2 has values further away from the placebo. (E.g. the values 'placebo = 0, treatment1 = 1 and treatment2 = 0' have higher variance than 'placebo = 0, treatment1 = 0.5 and treatment2 = 0'.)
The rejection regions are both rejecting in 5% of the cases the null hypothesis $\mu_1=\mu_2=\mu_3$ if the null hypothesis is correct (type I error). The rejection regions are very similar.
sim <- function(n=20,mu1=0,mu2=0) {
### sampling
x0 <- rnorm(n)
x1 <- rnorm(n, mu1)
x2 <- rnorm(n, mu2)
### compute intermediate statistics
mean_total <- mean(c(x0,x1,x2))
SSR <- sum((x0-mean(x0))^2+
(x1-mean(x1))^2+
(x2-mean(x2))^2) ### residuals
SSE <- n*((mean(x0)-mean_total)^2+
(mean(x1)-mean_total)^2+
(mean(x2)-mean_total)^2) ### explained
SST <- sum((x0-mean_total)^2+
(x1-mean_total)^2+
(x2-mean_total)^2) ### total
sig_pooled <- sqrt(SSR/(3*n-3))
### compute test statistics
t1 <- (mean(x1)-mean(x0))/sig_pooled/sqrt(2/n)
t2 <- (mean(x2)-mean(x0))/sig_pooled/sqrt(2/n)
t3 <- (mean(x2)-mean(x1))/sig_pooled/sqrt(2/n)
Fscore <- (SSE/2) / (SSR/(3*n-3))
### output
return(list(t1=t1, t2=t2, t3=t3, Fscore=Fscore))
}
### simulate
set.seed(1)
n = 20
alpha = 0.95
x <- replicate(10^4,sim(n))
t1 <- as.numeric(x[1,])
t2 <- as.numeric(x[2,])
t3 <- as.numeric(x[3,])
Fscore <- as.numeric(x[4,])
### boundaries for colouring
### F-score
f_boundary <- qf(alpha,2,n*3-3)
colf = (Fscore >= f_boundary)
### range
t_boundary <- qtukey(alpha, nmeans = 3, df = n*3-3)/sqrt(2)
#t_boundary <- qt(1-0.5*(1-alpha), df = n*3-3)
colt = 1-(abs(t1) < t_boundary)*(abs(t2) < t_boundary)*(abs(t3) < t_boundary)
### plot results
col = hsv(0.33+colt*0.33-colf*0.33, 1, ((colf+colt)>=1)*0.7,0.5)
plot(t1,t2, col = col, bg = col, pch = 21 , cex = 0.3,
xlab = "t1", ylab = "t2",
ylim = c(-4,4), xlim = c(-4,4))
sum(colf)/length(t1) ### 5.03% outside the F boundary
sum(colt)/length(t1) ### 5.08% outside the Tukey boundary
### F-distribution boundary
### F * 3 = (t1^2+t2^2+t3^2) = (t1^2+t2^2+(t2-t1)^2) =
### = (2t1^2 + 2t2^2 - 2t1t2 = 1/2 (t1+t2)^2+ 3/2 (t2-t1)^2
phi <- seq(0,2*pi,0.01)
u <- cos(phi)*sqrt(f_boundary*2)
v <- sin(phi)*sqrt(f_boundary*6)
x1 <- (v-u)/2
x2 <- (u+v)/2
lines(x1,x2,col=2)
### Tukey range boundary
lines(t_boundary*c(1,1,0,-1,-1,0,1),t_boundary*c(0,1,1,0,-1,-1,0), col = 4)
title("comparing anova with Tukey's Method")
legend(-4,4, c("non significant",
"both significant",
"only anova",
"only Tukey's method"), col = c(1,3,2,4), pt.bg = c(1,3,2,4), pch=21, cex = 0.7)
This problem would also be more complex if I needed to add another variable, for example a variable for gender (male and female) to check if gender also affects the treatment.
The most easy would be to formulate this as a linear model and use variance (F-test/anova) or parameter estimates (t-test) to describe the significance. (Effectively these will be the same, anova and t-tests give the same results)
I want to test if drug 1 and drug 2 are effective to reduce weight
If you are more interested in only a few out of all possible comparisons of means, and/or if you are interested in one sided alternative hypotheses ($H_0: \text{not effective}$ versus $H_a: \text{effective and more specifically weight reducing}$), then you can change the rejection boundaries of the t-test (e.g. use 1 sided t-tests and ignore the 3rd t-statistic for difference between treatments). The result is Dunnett's test, which R Carnell speaks about in their answer, which will be a more powerful test.
|
Comparing two, or more, independent paired t-tests
|
Instead of doing ANOVA, I want to make three independent paired t-tests, i.e, one paired t-test for each one of the groups (measuring weight before and weight after).
...
Can I compare the outputs fro
|
Comparing two, or more, independent paired t-tests
Instead of doing ANOVA, I want to make three independent paired t-tests, i.e, one paired t-test for each one of the groups (measuring weight before and weight after).
...
Can I compare the outputs from the three paired t-tests?
You can do this with Tukey's range method
It is actually relatively similar and there are similar rejection regions (similar for rejecting the null hypothesis $\mu_1=\mu_2=\mu_3$ Tukey's method versus anova).
The F-statistic in anova can be computed from the t-statistics (when these are computed with the pooled standard deviation).
$$F = \frac{t_1^2+t_2^2+t_3^2}{3}$$
With Tukey's method you are regarding the maximum of the absolute value of the t-statistics.
$$q = max(|t_1|,|t_2|,|t_3|)$$
The method is more complex with ordering of the means and finding groups with significant differences, but the control of the FWER is done based on this maximum range. (While this test is often performed as a post-hoc test for ANOVA, you do not need to do ANOVA before Tukey's method. The FWER is controlled by using the studentized range distribution for the cutoff for $q$.)
Demonstration/visualisation/simulation
Below is a simulation assuming the populations are normal distributed with equal variances and equal means.
We plot two out of the three t-statistics (from $10^4$ different simulations). The third t-statistic is fully dependent on these two.
The t-statistics are correlated and not independent (see the clouds of points being an elongated shape). This is because the different t-statistics are computed with similar groups. If $t_1$ relates to the difference 'treatment1 - placebo' and $t_2$ relates to the difference 'treatment2 - placebo', then the placebo sample will have a similar effect on both $t_1$ and $t_2$ which is how they become correlated.
This is the reason why the 'multiple comparison problem' should not be tackled with something like the Šidák correction as suggested by some. Instead you should use the studentized range distribution to determine the FWER.
For a given maximum range the F-statistic can have different values.
Say the lowest mean is 0 and the highest mean is 1. The total variance will depend on the third mean and is highest when it is close to 0 or 1 and lowest when it is close to 0.5.
So, you might have a situation that the treatment 1 is significantly different according to Tukey's test, but depending on treatment 2 the ANOVA result can be more not significant (and vice-versa: R Tukey HSD Anova: Anova significant, Tukey not?).
Strangely the anova test can fail when the treatment 2 has values further away from the placebo. (E.g. the values 'placebo = 0, treatment1 = 1 and treatment2 = 0' have higher variance than 'placebo = 0, treatment1 = 0.5 and treatment2 = 0'.)
The rejection regions are both rejecting in 5% of the cases the null hypothesis $\mu_1=\mu_2=\mu_3$ if the null hypothesis is correct (type I error). The rejection regions are very similar.
sim <- function(n=20,mu1=0,mu2=0) {
### sampling
x0 <- rnorm(n)
x1 <- rnorm(n, mu1)
x2 <- rnorm(n, mu2)
### compute intermediate statistics
mean_total <- mean(c(x0,x1,x2))
SSR <- sum((x0-mean(x0))^2+
(x1-mean(x1))^2+
(x2-mean(x2))^2) ### residuals
SSE <- n*((mean(x0)-mean_total)^2+
(mean(x1)-mean_total)^2+
(mean(x2)-mean_total)^2) ### explained
SST <- sum((x0-mean_total)^2+
(x1-mean_total)^2+
(x2-mean_total)^2) ### total
sig_pooled <- sqrt(SSR/(3*n-3))
### compute test statistics
t1 <- (mean(x1)-mean(x0))/sig_pooled/sqrt(2/n)
t2 <- (mean(x2)-mean(x0))/sig_pooled/sqrt(2/n)
t3 <- (mean(x2)-mean(x1))/sig_pooled/sqrt(2/n)
Fscore <- (SSE/2) / (SSR/(3*n-3))
### output
return(list(t1=t1, t2=t2, t3=t3, Fscore=Fscore))
}
### simulate
set.seed(1)
n = 20
alpha = 0.95
x <- replicate(10^4,sim(n))
t1 <- as.numeric(x[1,])
t2 <- as.numeric(x[2,])
t3 <- as.numeric(x[3,])
Fscore <- as.numeric(x[4,])
### boundaries for colouring
### F-score
f_boundary <- qf(alpha,2,n*3-3)
colf = (Fscore >= f_boundary)
### range
t_boundary <- qtukey(alpha, nmeans = 3, df = n*3-3)/sqrt(2)
#t_boundary <- qt(1-0.5*(1-alpha), df = n*3-3)
colt = 1-(abs(t1) < t_boundary)*(abs(t2) < t_boundary)*(abs(t3) < t_boundary)
### plot results
col = hsv(0.33+colt*0.33-colf*0.33, 1, ((colf+colt)>=1)*0.7,0.5)
plot(t1,t2, col = col, bg = col, pch = 21 , cex = 0.3,
xlab = "t1", ylab = "t2",
ylim = c(-4,4), xlim = c(-4,4))
sum(colf)/length(t1) ### 5.03% outside the F boundary
sum(colt)/length(t1) ### 5.08% outside the Tukey boundary
### F-distribution boundary
### F * 3 = (t1^2+t2^2+t3^2) = (t1^2+t2^2+(t2-t1)^2) =
### = (2t1^2 + 2t2^2 - 2t1t2 = 1/2 (t1+t2)^2+ 3/2 (t2-t1)^2
phi <- seq(0,2*pi,0.01)
u <- cos(phi)*sqrt(f_boundary*2)
v <- sin(phi)*sqrt(f_boundary*6)
x1 <- (v-u)/2
x2 <- (u+v)/2
lines(x1,x2,col=2)
### Tukey range boundary
lines(t_boundary*c(1,1,0,-1,-1,0,1),t_boundary*c(0,1,1,0,-1,-1,0), col = 4)
title("comparing anova with Tukey's Method")
legend(-4,4, c("non significant",
"both significant",
"only anova",
"only Tukey's method"), col = c(1,3,2,4), pt.bg = c(1,3,2,4), pch=21, cex = 0.7)
This problem would also be more complex if I needed to add another variable, for example a variable for gender (male and female) to check if gender also affects the treatment.
The most easy would be to formulate this as a linear model and use variance (F-test/anova) or parameter estimates (t-test) to describe the significance. (Effectively these will be the same, anova and t-tests give the same results)
I want to test if drug 1 and drug 2 are effective to reduce weight
If you are more interested in only a few out of all possible comparisons of means, and/or if you are interested in one sided alternative hypotheses ($H_0: \text{not effective}$ versus $H_a: \text{effective and more specifically weight reducing}$), then you can change the rejection boundaries of the t-test (e.g. use 1 sided t-tests and ignore the 3rd t-statistic for difference between treatments). The result is Dunnett's test, which R Carnell speaks about in their answer, which will be a more powerful test.
|
Comparing two, or more, independent paired t-tests
Instead of doing ANOVA, I want to make three independent paired t-tests, i.e, one paired t-test for each one of the groups (measuring weight before and weight after).
...
Can I compare the outputs fro
|
44,978
|
How many must you sample with no negatives to conclude there is no negatives in the population?
|
Suppose we want to expect that there are no defective widgets at the 95% confidence level. What this means is that we must test enough widgets that if there were a defective widget, then we would have a 95% chance of finding the defective one in our tests.
Of course, if we want to have a 95% chance of finding the defective widget, that means we must test 95% of all widgets. So the answer, unfortunately, is that you have to test 950 of the 1,000 widgets.
And that's it, that's the entire answer to your question. But let me talk about practical considerations, because in practice, there isn't really any situation in which you'd want to test 95% of all widgets.
Scenario 1: You're building a chain out of 1,000 links. For some reason, you've decided to buy each link from a different person, so you have 1,000 different people supplying chain links to you. All of the links have to be strong in order for the chain to be strong; having even one weak link is unacceptable.
In this scenario, the problem is that testing some of the links doesn't tell you anything about the remaining links. Even if you test 999 of them, you still haven't learned anything whatsoever about the remaining link. So, testing (say) only 750 of the links is definitely not enough.
As I mentioned, in order to conclude at the 95% confidence level that none of the links are weak, you need to test 950 of them. At this point, you might be wondering, "Why should I stop at 950? Why not just test all 1,000 of them?" And the answer is that you're absolutely right. You should probably just test all 1,000 links, so that you know that all of them are strong.
Scenario 2: You have a machine that makes chain links, and you've just made a batch of 1,000 chain links using that machine. As above, all of the links have to be strong in order for the chain to be strong. How many chain links should you test in order to be sure that you'll have a strong chain?
If you're faced with this scenario in the real world, then you should try to find out more information about the machine. The best case is that there are two types of machines: ones which produce only strong links, and ones which produce only weak links. In this case, you only need to test one link in order to know that all of the links are strong!
A more realistic case, perhaps, is where some machines produce only strong links, and other machines produce 50% strong links and 50% weak links. In this case, in order to achieve your 95% confidence level, you only need to test 5 links and see that they're all strong.
Another interesting case is the case where these machines are known to be very reliable, and 99.9% of them produce only strong links. In this case, if this machine was chosen randomly out of all machines, then you don't need to test any links in order to reach the 95% confidence level that all of the links are strong.
I can't describe all possible practical situations, of course, but hopefully this gives you an idea of why 950 is the correct answer to the original question, as well as why that answer isn't likely to be very useful in practice.
|
How many must you sample with no negatives to conclude there is no negatives in the population?
|
Suppose we want to expect that there are no defective widgets at the 95% confidence level. What this means is that we must test enough widgets that if there were a defective widget, then we would have
|
How many must you sample with no negatives to conclude there is no negatives in the population?
Suppose we want to expect that there are no defective widgets at the 95% confidence level. What this means is that we must test enough widgets that if there were a defective widget, then we would have a 95% chance of finding the defective one in our tests.
Of course, if we want to have a 95% chance of finding the defective widget, that means we must test 95% of all widgets. So the answer, unfortunately, is that you have to test 950 of the 1,000 widgets.
And that's it, that's the entire answer to your question. But let me talk about practical considerations, because in practice, there isn't really any situation in which you'd want to test 95% of all widgets.
Scenario 1: You're building a chain out of 1,000 links. For some reason, you've decided to buy each link from a different person, so you have 1,000 different people supplying chain links to you. All of the links have to be strong in order for the chain to be strong; having even one weak link is unacceptable.
In this scenario, the problem is that testing some of the links doesn't tell you anything about the remaining links. Even if you test 999 of them, you still haven't learned anything whatsoever about the remaining link. So, testing (say) only 750 of the links is definitely not enough.
As I mentioned, in order to conclude at the 95% confidence level that none of the links are weak, you need to test 950 of them. At this point, you might be wondering, "Why should I stop at 950? Why not just test all 1,000 of them?" And the answer is that you're absolutely right. You should probably just test all 1,000 links, so that you know that all of them are strong.
Scenario 2: You have a machine that makes chain links, and you've just made a batch of 1,000 chain links using that machine. As above, all of the links have to be strong in order for the chain to be strong. How many chain links should you test in order to be sure that you'll have a strong chain?
If you're faced with this scenario in the real world, then you should try to find out more information about the machine. The best case is that there are two types of machines: ones which produce only strong links, and ones which produce only weak links. In this case, you only need to test one link in order to know that all of the links are strong!
A more realistic case, perhaps, is where some machines produce only strong links, and other machines produce 50% strong links and 50% weak links. In this case, in order to achieve your 95% confidence level, you only need to test 5 links and see that they're all strong.
Another interesting case is the case where these machines are known to be very reliable, and 99.9% of them produce only strong links. In this case, if this machine was chosen randomly out of all machines, then you don't need to test any links in order to reach the 95% confidence level that all of the links are strong.
I can't describe all possible practical situations, of course, but hopefully this gives you an idea of why 950 is the correct answer to the original question, as well as why that answer isn't likely to be very useful in practice.
|
How many must you sample with no negatives to conclude there is no negatives in the population?
Suppose we want to expect that there are no defective widgets at the 95% confidence level. What this means is that we must test enough widgets that if there were a defective widget, then we would have
|
44,979
|
How many must you sample with no negatives to conclude there is no negatives in the population?
|
As explained in the Wikipedia link, the "Rule of Three" is for (binomial)
sampling with replacement or sampling from a theoetical infinite distribution. I am skeptical that this rule applies to your question.
Of course, to be 100% sure not even one of your 1000 widgets is defective, you will
have to look at all of them.
If there is one defective widget among 1000, then your chances of finding
it by looking at 750 randomly chosen widgets is only
$\frac{{1\choose 1}{999\choose 749}}{{1000\choose 750}} = 0.75,$ a hypergeometric probability. In R,
dhyper(1, 1, 999, 750)
[1] 0.75
If you want to be 95% sure to find the one defective among 1000, you will need to sample 950 widgets (without replacement).
dhyper(1, 1, 999, 950)
[1] 0.95
If there are two or more defectives among the 1000, then it would be (almost) good enough to look at 750.
sum(dhyper(1:2, 2, 998, 750))
[1] 0.9376877
sum(dhyper(1:2, 2, 998, 775))
[1] 0.9495495
sum(dhyper(1:2, 2, 998, 777))
[1] 0.9504444
|
How many must you sample with no negatives to conclude there is no negatives in the population?
|
As explained in the Wikipedia link, the "Rule of Three" is for (binomial)
sampling with replacement or sampling from a theoetical infinite distribution. I am skeptical that this rule applies to your q
|
How many must you sample with no negatives to conclude there is no negatives in the population?
As explained in the Wikipedia link, the "Rule of Three" is for (binomial)
sampling with replacement or sampling from a theoetical infinite distribution. I am skeptical that this rule applies to your question.
Of course, to be 100% sure not even one of your 1000 widgets is defective, you will
have to look at all of them.
If there is one defective widget among 1000, then your chances of finding
it by looking at 750 randomly chosen widgets is only
$\frac{{1\choose 1}{999\choose 749}}{{1000\choose 750}} = 0.75,$ a hypergeometric probability. In R,
dhyper(1, 1, 999, 750)
[1] 0.75
If you want to be 95% sure to find the one defective among 1000, you will need to sample 950 widgets (without replacement).
dhyper(1, 1, 999, 950)
[1] 0.95
If there are two or more defectives among the 1000, then it would be (almost) good enough to look at 750.
sum(dhyper(1:2, 2, 998, 750))
[1] 0.9376877
sum(dhyper(1:2, 2, 998, 775))
[1] 0.9495495
sum(dhyper(1:2, 2, 998, 777))
[1] 0.9504444
|
How many must you sample with no negatives to conclude there is no negatives in the population?
As explained in the Wikipedia link, the "Rule of Three" is for (binomial)
sampling with replacement or sampling from a theoetical infinite distribution. I am skeptical that this rule applies to your q
|
44,980
|
How many must you sample with no negatives to conclude there is no negatives in the population?
|
I looked at a version of this problem back in April, to see what we could say about Covid elimination based on reasonable numbers of tests (spoiler: not a lot).
As @keith's answer shows, if you want to be sure there isn't even one failure in the population, you need sample a large fraction of the population. That's obviously not sensible in most cases.
As @BruceET says in his comment, a Bayesian solution makes sense. However, because there's very little information in the data about very small numbers of failures in the population
it will matter what prior you put on very small numbers of failures
if you think small numbers are plausible a priori, and don't sample a big fraction of the population, you will inevitably still think that a posteriori, so you won't end up with high posterior probability on zero
Suppose you take a $Beta(a,b)$ prior for the probability of failure. The posterior after no failures out of $n$ is $Beta(a+0,b+n)$. So you can look up the quantiles of that distribution and see when it's concentrated close enough to zero for what you want to use it for.
|
How many must you sample with no negatives to conclude there is no negatives in the population?
|
I looked at a version of this problem back in April, to see what we could say about Covid elimination based on reasonable numbers of tests (spoiler: not a lot).
As @keith's answer shows, if you want t
|
How many must you sample with no negatives to conclude there is no negatives in the population?
I looked at a version of this problem back in April, to see what we could say about Covid elimination based on reasonable numbers of tests (spoiler: not a lot).
As @keith's answer shows, if you want to be sure there isn't even one failure in the population, you need sample a large fraction of the population. That's obviously not sensible in most cases.
As @BruceET says in his comment, a Bayesian solution makes sense. However, because there's very little information in the data about very small numbers of failures in the population
it will matter what prior you put on very small numbers of failures
if you think small numbers are plausible a priori, and don't sample a big fraction of the population, you will inevitably still think that a posteriori, so you won't end up with high posterior probability on zero
Suppose you take a $Beta(a,b)$ prior for the probability of failure. The posterior after no failures out of $n$ is $Beta(a+0,b+n)$. So you can look up the quantiles of that distribution and see when it's concentrated close enough to zero for what you want to use it for.
|
How many must you sample with no negatives to conclude there is no negatives in the population?
I looked at a version of this problem back in April, to see what we could say about Covid elimination based on reasonable numbers of tests (spoiler: not a lot).
As @keith's answer shows, if you want t
|
44,981
|
How many must you sample with no negatives to conclude there is no negatives in the population?
|
The Rule of three states that if I sample N then I know I have a rate less than 3/N at 95% CL
My expectation, E, is my rate times the number of total events, T.
E = T*3/N
The total events remaining is just the number unsampled T=1000-N
E = (1000-N)*3/N
I want to expect at most 1 so E=1
Solving for N gives
N = 10003/(1+3) = 10003/4 = 750
Sampling 3/4 seems like a lot so I have some doubts but this is a pretty strict requirement.
The general case for any confidence can also be given where the multiplayer is -ln(α) with α being 1 minus the confidence level.
With a population size P the general case is
N = P*ln(α)/(ln(α)-E)
|
How many must you sample with no negatives to conclude there is no negatives in the population?
|
The Rule of three states that if I sample N then I know I have a rate less than 3/N at 95% CL
My expectation, E, is my rate times the number of total events, T.
E = T*3/N
The total events remaining i
|
How many must you sample with no negatives to conclude there is no negatives in the population?
The Rule of three states that if I sample N then I know I have a rate less than 3/N at 95% CL
My expectation, E, is my rate times the number of total events, T.
E = T*3/N
The total events remaining is just the number unsampled T=1000-N
E = (1000-N)*3/N
I want to expect at most 1 so E=1
Solving for N gives
N = 10003/(1+3) = 10003/4 = 750
Sampling 3/4 seems like a lot so I have some doubts but this is a pretty strict requirement.
The general case for any confidence can also be given where the multiplayer is -ln(α) with α being 1 minus the confidence level.
With a population size P the general case is
N = P*ln(α)/(ln(α)-E)
|
How many must you sample with no negatives to conclude there is no negatives in the population?
The Rule of three states that if I sample N then I know I have a rate less than 3/N at 95% CL
My expectation, E, is my rate times the number of total events, T.
E = T*3/N
The total events remaining i
|
44,982
|
Distribution of $\frac{1}{1+X}$ if $X$ is Lognormal
|
I will answer a simplified version, so leave the generalization as an exercise. Let $Z$ be a standard normal random variable so $X=e^Z$ is standard lognormal. Since $X>0 $ we have $Y=\frac1{1+X}$ is in the unit interval. Let $\phi, \Phi$ be the density and cdf (cumulative distribution ) functions of the standard normal, then we find
$$ \DeclareMathOperator{\P}{\mathbb{P}}
F_Y(y)=\P(Y \le y)= 1-\Phi\left( \ln(\frac{1-y}{y})\right)
$$
and by differentiation the density is
$$f_Y(y)=\frac{\phi\left( \ln(\frac{1-y}{y}) \right)}{y(1-y)} $$
The factor in the denominator leads the thoughts to something logistic, and,in fact, this is a Logit-normal distribution.
That relationship seems important and need a simpler derivation, just from the definitions. Since $Z$ is standard normal, so symmetric about zero, $-Z$ have the same distribution, so to represent (the distribution of ) $X$ we can as well use $X=e^{-Z}$. Then
$$ Y=\frac1{1+X}=\frac1{1+e^{-Z}}=\frac{e^Z}{1+e^Z} $$
and it follows directly that $\operatorname{logit}(Y)$ is a standard normal distribution, without any need of deriving the density function.
|
Distribution of $\frac{1}{1+X}$ if $X$ is Lognormal
|
I will answer a simplified version, so leave the generalization as an exercise. Let $Z$ be a standard normal random variable so $X=e^Z$ is standard lognormal. Since $X>0 $ we have $Y=\frac1{1+X}$ is
|
Distribution of $\frac{1}{1+X}$ if $X$ is Lognormal
I will answer a simplified version, so leave the generalization as an exercise. Let $Z$ be a standard normal random variable so $X=e^Z$ is standard lognormal. Since $X>0 $ we have $Y=\frac1{1+X}$ is in the unit interval. Let $\phi, \Phi$ be the density and cdf (cumulative distribution ) functions of the standard normal, then we find
$$ \DeclareMathOperator{\P}{\mathbb{P}}
F_Y(y)=\P(Y \le y)= 1-\Phi\left( \ln(\frac{1-y}{y})\right)
$$
and by differentiation the density is
$$f_Y(y)=\frac{\phi\left( \ln(\frac{1-y}{y}) \right)}{y(1-y)} $$
The factor in the denominator leads the thoughts to something logistic, and,in fact, this is a Logit-normal distribution.
That relationship seems important and need a simpler derivation, just from the definitions. Since $Z$ is standard normal, so symmetric about zero, $-Z$ have the same distribution, so to represent (the distribution of ) $X$ we can as well use $X=e^{-Z}$. Then
$$ Y=\frac1{1+X}=\frac1{1+e^{-Z}}=\frac{e^Z}{1+e^Z} $$
and it follows directly that $\operatorname{logit}(Y)$ is a standard normal distribution, without any need of deriving the density function.
|
Distribution of $\frac{1}{1+X}$ if $X$ is Lognormal
I will answer a simplified version, so leave the generalization as an exercise. Let $Z$ be a standard normal random variable so $X=e^Z$ is standard lognormal. Since $X>0 $ we have $Y=\frac1{1+X}$ is
|
44,983
|
Can't understand the proof of the first backpropagation equation in Nielsen's neural network book
|
That's because the author is considering in that part that the activation function of a neuron $j$ only depends on the value of $z_j^L$. This happens for example with the sigmoid or ReLU activation functions.
However, when using activation functions like Softmax (described in Chapter 3.1.4), we have that:
$$a_j^L = \frac{e^{z_j^L}}{\sum_k e^{z_k^L}}$$
Here we can see that $\partial a_j^L/\partial z_k^L \neq0$ (or equivalently: $\partial a_k^L/\partial z_j^L \neq0$) for $k\neq j$, so the correct computation of $\delta_j^L$ is the equation given by the author:
$$ \delta_j^L=\sum_k\frac{\partial C}{\partial a_k^L}\frac{\partial a_k^L}{\partial z_j^L} $$
So, to sum up, the above equation is the general expresion of $\delta_j^L$, however if we use certain activation functions, it can be simplified to the equation $(38)$ of the question.
|
Can't understand the proof of the first backpropagation equation in Nielsen's neural network book
|
That's because the author is considering in that part that the activation function of a neuron $j$ only depends on the value of $z_j^L$. This happens for example with the sigmoid or ReLU activation fu
|
Can't understand the proof of the first backpropagation equation in Nielsen's neural network book
That's because the author is considering in that part that the activation function of a neuron $j$ only depends on the value of $z_j^L$. This happens for example with the sigmoid or ReLU activation functions.
However, when using activation functions like Softmax (described in Chapter 3.1.4), we have that:
$$a_j^L = \frac{e^{z_j^L}}{\sum_k e^{z_k^L}}$$
Here we can see that $\partial a_j^L/\partial z_k^L \neq0$ (or equivalently: $\partial a_k^L/\partial z_j^L \neq0$) for $k\neq j$, so the correct computation of $\delta_j^L$ is the equation given by the author:
$$ \delta_j^L=\sum_k\frac{\partial C}{\partial a_k^L}\frac{\partial a_k^L}{\partial z_j^L} $$
So, to sum up, the above equation is the general expresion of $\delta_j^L$, however if we use certain activation functions, it can be simplified to the equation $(38)$ of the question.
|
Can't understand the proof of the first backpropagation equation in Nielsen's neural network book
That's because the author is considering in that part that the activation function of a neuron $j$ only depends on the value of $z_j^L$. This happens for example with the sigmoid or ReLU activation fu
|
44,984
|
Can't understand the proof of the first backpropagation equation in Nielsen's neural network book
|
Yes, in this case, it's obvious. The author is simply writing a general equation for taking derivatives in a multivariate setting. If $f(x,y)$ is a function of $x,y$ and we look for the derivative of $f$ wrt $t$, it's customary to write the following:
$$\frac{\partial f}{\partial t}=\frac{\partial f}{\partial x}\frac{\partial x}{\partial t}+\frac{\partial f}{\partial y}\frac{\partial y}{\partial t}$$
|
Can't understand the proof of the first backpropagation equation in Nielsen's neural network book
|
Yes, in this case, it's obvious. The author is simply writing a general equation for taking derivatives in a multivariate setting. If $f(x,y)$ is a function of $x,y$ and we look for the derivative of
|
Can't understand the proof of the first backpropagation equation in Nielsen's neural network book
Yes, in this case, it's obvious. The author is simply writing a general equation for taking derivatives in a multivariate setting. If $f(x,y)$ is a function of $x,y$ and we look for the derivative of $f$ wrt $t$, it's customary to write the following:
$$\frac{\partial f}{\partial t}=\frac{\partial f}{\partial x}\frac{\partial x}{\partial t}+\frac{\partial f}{\partial y}\frac{\partial y}{\partial t}$$
|
Can't understand the proof of the first backpropagation equation in Nielsen's neural network book
Yes, in this case, it's obvious. The author is simply writing a general equation for taking derivatives in a multivariate setting. If $f(x,y)$ is a function of $x,y$ and we look for the derivative of
|
44,985
|
Given $n$ random variables of variance 1 with pairwise correlation $-1/(n-1)$ and the value of $n-1$ of the variables, can we recover the $n$th value?
|
Since $$\text{Var}(X_1 + \cdots + X_n) = n + n(n-1) \left(-\frac{1}{n-1}\right) = 0$$
the sum of the $n$ random variables is a constant. If you know this constant, then yes knowing the realizations of $n-1$ of the random variables will give you the last one.
However, if we don't know this constant, without further information beyond the variances and correlations given in your question, I'm not sure we can do much. For instance, I believe the mean of each distribution can be freely set to be anything. Seeing a single realization of $n-1$ of the random variables would not tell you much about the last one at all, since variance and correlation are invariant under additive shifts.
|
Given $n$ random variables of variance 1 with pairwise correlation $-1/(n-1)$ and the value of $n-1$
|
Since $$\text{Var}(X_1 + \cdots + X_n) = n + n(n-1) \left(-\frac{1}{n-1}\right) = 0$$
the sum of the $n$ random variables is a constant. If you know this constant, then yes knowing the realizations of
|
Given $n$ random variables of variance 1 with pairwise correlation $-1/(n-1)$ and the value of $n-1$ of the variables, can we recover the $n$th value?
Since $$\text{Var}(X_1 + \cdots + X_n) = n + n(n-1) \left(-\frac{1}{n-1}\right) = 0$$
the sum of the $n$ random variables is a constant. If you know this constant, then yes knowing the realizations of $n-1$ of the random variables will give you the last one.
However, if we don't know this constant, without further information beyond the variances and correlations given in your question, I'm not sure we can do much. For instance, I believe the mean of each distribution can be freely set to be anything. Seeing a single realization of $n-1$ of the random variables would not tell you much about the last one at all, since variance and correlation are invariant under additive shifts.
|
Given $n$ random variables of variance 1 with pairwise correlation $-1/(n-1)$ and the value of $n-1$
Since $$\text{Var}(X_1 + \cdots + X_n) = n + n(n-1) \left(-\frac{1}{n-1}\right) = 0$$
the sum of the $n$ random variables is a constant. If you know this constant, then yes knowing the realizations of
|
44,986
|
Given $n$ random variables of variance 1 with pairwise correlation $-1/(n-1)$ and the value of $n-1$ of the variables, can we recover the $n$th value?
|
As a concrete example of @angryavian's point, with $n=2$
If you take $X_1\sim N(0,1)$, you could have $X_2=42-X_1$ or $X_2=69-X_1$ or $X_2=17-X_1$ and these would all have unit variance and correlation $-1$. In general, $X_n = A-\sum_{i=1}^{n-1} X_i$, and $A$ can be chosen freely.
If you also required $E[X_i]=0$ there would be a unique answer
|
Given $n$ random variables of variance 1 with pairwise correlation $-1/(n-1)$ and the value of $n-1$
|
As a concrete example of @angryavian's point, with $n=2$
If you take $X_1\sim N(0,1)$, you could have $X_2=42-X_1$ or $X_2=69-X_1$ or $X_2=17-X_1$ and these would all have unit variance and correlati
|
Given $n$ random variables of variance 1 with pairwise correlation $-1/(n-1)$ and the value of $n-1$ of the variables, can we recover the $n$th value?
As a concrete example of @angryavian's point, with $n=2$
If you take $X_1\sim N(0,1)$, you could have $X_2=42-X_1$ or $X_2=69-X_1$ or $X_2=17-X_1$ and these would all have unit variance and correlation $-1$. In general, $X_n = A-\sum_{i=1}^{n-1} X_i$, and $A$ can be chosen freely.
If you also required $E[X_i]=0$ there would be a unique answer
|
Given $n$ random variables of variance 1 with pairwise correlation $-1/(n-1)$ and the value of $n-1$
As a concrete example of @angryavian's point, with $n=2$
If you take $X_1\sim N(0,1)$, you could have $X_2=42-X_1$ or $X_2=69-X_1$ or $X_2=17-X_1$ and these would all have unit variance and correlati
|
44,987
|
least square estimator of regression x onto y [duplicate]
|
To prove that the reverse regression is not a good estimator for $1/\beta$, recall that OLS is generally consistent (when regressing $y$ on $x$) for $cov(x,y)/var(x)$. Correspondingly, it is consistent for $cov(x,y)/var(y)$ when regressing $x$ on $y$.
When the relationship between error and regressor is (essentially, predeterminedness) is such that $\beta=cov(x,y)/var(x)$, to have that $cov(x,y)/var(y)=1/\beta$ would require that
$$
cov(x,y)/var(y)=var(x)/cov(x,y),
$$
and there is no reason to expect this to hold in general.
In fact, the condition could be reexpressed as
$$
\frac{cov(x,y)^2}{var(y)var(x)}=1,
$$
which is the limiting case of the Cauchy-Schwarz inequality, which is known to only obtain if the random variables in question are multiples of each other.
In that case, we have, say, $y=\beta x$, so that
$$
\frac{cov(x,y)}{var(x)}=\beta \cdot var(x)/var(x)=\beta
$$
and
$$
\frac{cov(x,y)}{var(y)}=\frac{\beta \cdot var(x)}{\beta ^2var(x)}=\frac{1}{\beta }
$$
Here is a little graphical illustration (where you'd want to read the cases of regressing $x$ on $y$ rotating the plot counterclockwise by 90 degrees):
library(mvtnorm)
n <- 10000
cov.xy <- 0.5
var.y <- 1
var.x <- 4
beta <- cov.xy/var.x
dat <- rmvnorm(n, mean = rep(0,2), sigma = matrix(c(var.y, cov.xy, cov.xy, var.x), ncol=2))
y <- dat[,1]
x <- dat[,2]
par(mfrow=c(1,2))
plot(x, y, pch=19, cex=0.2, col="lightgreen")
abline(lm(y~x),lwd=2, col="lightgreen") # a regression of y on x
abline(a=0, b=beta, lwd=2, col="green") # what OLS of y on x is consistent for
plot(y, x, pch=19, cex=0.2, col="lightblue")
abline(lm(x~y), lwd=2, col="lightblue") # a regression of x on y
abline(a=0, cov.xy/var.y, lwd=2, col="darkblue") # what OLS of x on y is consistent for
abline(a=0, b=1/beta, lwd=2, col="red") # what OLS of x on y is NOT consistent for
|
least square estimator of regression x onto y [duplicate]
|
To prove that the reverse regression is not a good estimator for $1/\beta$, recall that OLS is generally consistent (when regressing $y$ on $x$) for $cov(x,y)/var(x)$. Correspondingly, it is consisten
|
least square estimator of regression x onto y [duplicate]
To prove that the reverse regression is not a good estimator for $1/\beta$, recall that OLS is generally consistent (when regressing $y$ on $x$) for $cov(x,y)/var(x)$. Correspondingly, it is consistent for $cov(x,y)/var(y)$ when regressing $x$ on $y$.
When the relationship between error and regressor is (essentially, predeterminedness) is such that $\beta=cov(x,y)/var(x)$, to have that $cov(x,y)/var(y)=1/\beta$ would require that
$$
cov(x,y)/var(y)=var(x)/cov(x,y),
$$
and there is no reason to expect this to hold in general.
In fact, the condition could be reexpressed as
$$
\frac{cov(x,y)^2}{var(y)var(x)}=1,
$$
which is the limiting case of the Cauchy-Schwarz inequality, which is known to only obtain if the random variables in question are multiples of each other.
In that case, we have, say, $y=\beta x$, so that
$$
\frac{cov(x,y)}{var(x)}=\beta \cdot var(x)/var(x)=\beta
$$
and
$$
\frac{cov(x,y)}{var(y)}=\frac{\beta \cdot var(x)}{\beta ^2var(x)}=\frac{1}{\beta }
$$
Here is a little graphical illustration (where you'd want to read the cases of regressing $x$ on $y$ rotating the plot counterclockwise by 90 degrees):
library(mvtnorm)
n <- 10000
cov.xy <- 0.5
var.y <- 1
var.x <- 4
beta <- cov.xy/var.x
dat <- rmvnorm(n, mean = rep(0,2), sigma = matrix(c(var.y, cov.xy, cov.xy, var.x), ncol=2))
y <- dat[,1]
x <- dat[,2]
par(mfrow=c(1,2))
plot(x, y, pch=19, cex=0.2, col="lightgreen")
abline(lm(y~x),lwd=2, col="lightgreen") # a regression of y on x
abline(a=0, b=beta, lwd=2, col="green") # what OLS of y on x is consistent for
plot(y, x, pch=19, cex=0.2, col="lightblue")
abline(lm(x~y), lwd=2, col="lightblue") # a regression of x on y
abline(a=0, cov.xy/var.y, lwd=2, col="darkblue") # what OLS of x on y is consistent for
abline(a=0, b=1/beta, lwd=2, col="red") # what OLS of x on y is NOT consistent for
|
least square estimator of regression x onto y [duplicate]
To prove that the reverse regression is not a good estimator for $1/\beta$, recall that OLS is generally consistent (when regressing $y$ on $x$) for $cov(x,y)/var(x)$. Correspondingly, it is consisten
|
44,988
|
least square estimator of regression x onto y [duplicate]
|
No, in general you will obtain a different line wih ordinary least squares if you interchange x and y. You can easily check this with your formula by interchanging x and y and comparing it to $1/\beta$. The reaaon for this descrepancy is that ordinary least squares is not about fitting a line through points, but about prediction and thus assumes a specific role of the variables: x is "predictor", y is "response".
If your problem is actually about fitting a line through points, you should consider "orthogonal least squares", which is a symmetric approach and has (for straight lines) two equivalent solutions:
the right singular vector $\vec{v}_1$ corresponding to the largest singular
value $s_1\geq\ldots\geq s_n$ in the singular value decomposition (SVD)
$Q=USV^T$ of the matrix built from the centered data points
$$Q^T = (\vec{q}_1,\ldots,\vec{q}_n) \quad\mbox{ with }\quad
\vec{q}_i = \vec{x}_i - \vec{a}$$
the eigenvector corresponding to the largest eigenvalue of $Q^TQ$. $Q^TQ$
is identical to the scatter matrix, or $(n-1)$ times the covariance matrix
of the data points $\vec{x}_1,\ldots,\vec{x}_n$. Thus, this vector is
simply the principal component obtained from a principal component
analysis (PCA)
Note that orthogonal least squares also yields a reasonable result when the points happen to fall on (or around) a vertical line.
Reference:
H. Späth: "Orthogonal least squares fitting with linear manifolds."
Numerische Mathematik 48 (1986), pp. 441–445.
|
least square estimator of regression x onto y [duplicate]
|
No, in general you will obtain a different line wih ordinary least squares if you interchange x and y. You can easily check this with your formula by interchanging x and y and comparing it to $1/\beta
|
least square estimator of regression x onto y [duplicate]
No, in general you will obtain a different line wih ordinary least squares if you interchange x and y. You can easily check this with your formula by interchanging x and y and comparing it to $1/\beta$. The reaaon for this descrepancy is that ordinary least squares is not about fitting a line through points, but about prediction and thus assumes a specific role of the variables: x is "predictor", y is "response".
If your problem is actually about fitting a line through points, you should consider "orthogonal least squares", which is a symmetric approach and has (for straight lines) two equivalent solutions:
the right singular vector $\vec{v}_1$ corresponding to the largest singular
value $s_1\geq\ldots\geq s_n$ in the singular value decomposition (SVD)
$Q=USV^T$ of the matrix built from the centered data points
$$Q^T = (\vec{q}_1,\ldots,\vec{q}_n) \quad\mbox{ with }\quad
\vec{q}_i = \vec{x}_i - \vec{a}$$
the eigenvector corresponding to the largest eigenvalue of $Q^TQ$. $Q^TQ$
is identical to the scatter matrix, or $(n-1)$ times the covariance matrix
of the data points $\vec{x}_1,\ldots,\vec{x}_n$. Thus, this vector is
simply the principal component obtained from a principal component
analysis (PCA)
Note that orthogonal least squares also yields a reasonable result when the points happen to fall on (or around) a vertical line.
Reference:
H. Späth: "Orthogonal least squares fitting with linear manifolds."
Numerische Mathematik 48 (1986), pp. 441–445.
|
least square estimator of regression x onto y [duplicate]
No, in general you will obtain a different line wih ordinary least squares if you interchange x and y. You can easily check this with your formula by interchanging x and y and comparing it to $1/\beta
|
44,989
|
Relationship between KL divergence and entropy
|
I will reformulate using my answer at Intuition on the Kullback-Leibler (KL) Divergence. Since I am a statistician, I am more comfortable with likelihoods than with entropies, but I also think that gives more intuition here. Now entropy $ \DeclareMathOperator{\E}{\mathbb{E}} H(X) =-\sum_x p(x) \log p(x) =-\E_p \log p$. So entropy is simply the negative expected loglikelihood. Similarly, cross-entropy is the (negative) expected loglikelihood, but now not calculated under itself "its own truth", but under some other distribution, some other truth. We can use this to express the divergences as
$$
\text{D}_\text{KL}(p || q) = \E_p \log p - \E_p \log q
\label{*} \tag{*}
$$ and
$$
\text{D}_\text{KL}(q || p) = \E_q \log q - \E_q \log p \label{**} \tag{**}
$$ Using the interpretation from the above linked post, $\text{D}_\text{KL}(p || q)$ is the expectation under the alternative of the log likelihood ratio for testing $H_0\colon q$ against the alternative $p$. In your setting, $p$ is a known distribution, and we suppose it is multimodal. In case $\eqref{*}$, $q$ is the null distribution and the divergence is small for such $q$ which is difficult to reject against alternative $p$, when the expectation is calculated under $p$. But that means all the modes of $p$ will contribute to the expectation,so better that $q$ have some mass in all those modes. So this minimization must indeed give distributions that have some probability everywhere $p$ has it.
Then turn to $\eqref{**}$. Now $p$ is the null hypothesis and the divergence is small when it is difficult to reject $p$ against the alternative $q$, and the expectation is calculated under $q$. So in this case, if $q$ omits some of the modes of $p$, that does not matter, because the large likelihood ratio there does not contribute to the expectation! So the conclusion in the book is indeed correct.
Another comment: In $\eqref{*}$, if the known distribution $p$ is the empirical data distribution, we find a model $q$ best approximating it, we get effectively maximum likelihood.
|
Relationship between KL divergence and entropy
|
I will reformulate using my answer at Intuition on the Kullback-Leibler (KL) Divergence. Since I am a statistician, I am more comfortable with likelihoods than with entropies, but I also think that gi
|
Relationship between KL divergence and entropy
I will reformulate using my answer at Intuition on the Kullback-Leibler (KL) Divergence. Since I am a statistician, I am more comfortable with likelihoods than with entropies, but I also think that gives more intuition here. Now entropy $ \DeclareMathOperator{\E}{\mathbb{E}} H(X) =-\sum_x p(x) \log p(x) =-\E_p \log p$. So entropy is simply the negative expected loglikelihood. Similarly, cross-entropy is the (negative) expected loglikelihood, but now not calculated under itself "its own truth", but under some other distribution, some other truth. We can use this to express the divergences as
$$
\text{D}_\text{KL}(p || q) = \E_p \log p - \E_p \log q
\label{*} \tag{*}
$$ and
$$
\text{D}_\text{KL}(q || p) = \E_q \log q - \E_q \log p \label{**} \tag{**}
$$ Using the interpretation from the above linked post, $\text{D}_\text{KL}(p || q)$ is the expectation under the alternative of the log likelihood ratio for testing $H_0\colon q$ against the alternative $p$. In your setting, $p$ is a known distribution, and we suppose it is multimodal. In case $\eqref{*}$, $q$ is the null distribution and the divergence is small for such $q$ which is difficult to reject against alternative $p$, when the expectation is calculated under $p$. But that means all the modes of $p$ will contribute to the expectation,so better that $q$ have some mass in all those modes. So this minimization must indeed give distributions that have some probability everywhere $p$ has it.
Then turn to $\eqref{**}$. Now $p$ is the null hypothesis and the divergence is small when it is difficult to reject $p$ against the alternative $q$, and the expectation is calculated under $q$. So in this case, if $q$ omits some of the modes of $p$, that does not matter, because the large likelihood ratio there does not contribute to the expectation! So the conclusion in the book is indeed correct.
Another comment: In $\eqref{*}$, if the known distribution $p$ is the empirical data distribution, we find a model $q$ best approximating it, we get effectively maximum likelihood.
|
Relationship between KL divergence and entropy
I will reformulate using my answer at Intuition on the Kullback-Leibler (KL) Divergence. Since I am a statistician, I am more comfortable with likelihoods than with entropies, but I also think that gi
|
44,990
|
Relationship between KL divergence and entropy
|
Firstly, the KL divergence $D_{KL}(p||q)$ is synonymous with the relative entropy, relative entropy of $p$ with respect to $q$.
Entropy then becomes the self‐information of a random variable. Mutual information is a special case of a more general quantity called relative entropy, which is a measure of the distance between two probability distributions.
Source: Entropy, Relative Entropy and Mutual Information
Secondly, the entropy is related to the relative entropy, relative entropy of $p$ with respect to a uniform distribution.
Intuitively, the entropy of a random variable X with a probability distribution $p(x)$ is related to how much $p(x)$ diverges from the uniform distribution on the support of $X$. The more $p(x)$ diverges the lesser its entropy and vice versa.
\begin{align}
H(X) &= \sum_{x\in X}p(x)\log \frac{1}{p(x)} \\
&=log|X| - \sum_{x\in X}p(x)\log\frac{p(x)}{\frac{1}{|X|}} \\
&=\log|X|-D(p||uniform)
\end{align}
Source: section 1.2 of COS597D: Information Theory in Computer Science
Then your question(the title) can be rephrased into "the relationship between relative entropy of $p$ relative to $q$ and relative entropy of $q$ relative to uniform distribution". It's impossible that how $p$ diverges from $q$ relates to how $q$ diverges from a uniform distribution given that $p$ and $q$ can be any distribution pairs.
Shouldn't the entropy of $q$ be greater when minimizing $D_{KL}(q \:||\: p)$ than when minimizing $D_{KL}(p \:||\: q)$ (each w.r.t. parameters of $q$)?
NO.
The two relative entropy just don't correlate two each other. The relative entropy of $q$ relative to a uniform distribution doesn't depend on which relative entropy you are minimizing(because $p$ can be varying).
|
Relationship between KL divergence and entropy
|
Firstly, the KL divergence $D_{KL}(p||q)$ is synonymous with the relative entropy, relative entropy of $p$ with respect to $q$.
Entropy then becomes the self‐information of a random variable. Mutual
|
Relationship between KL divergence and entropy
Firstly, the KL divergence $D_{KL}(p||q)$ is synonymous with the relative entropy, relative entropy of $p$ with respect to $q$.
Entropy then becomes the self‐information of a random variable. Mutual information is a special case of a more general quantity called relative entropy, which is a measure of the distance between two probability distributions.
Source: Entropy, Relative Entropy and Mutual Information
Secondly, the entropy is related to the relative entropy, relative entropy of $p$ with respect to a uniform distribution.
Intuitively, the entropy of a random variable X with a probability distribution $p(x)$ is related to how much $p(x)$ diverges from the uniform distribution on the support of $X$. The more $p(x)$ diverges the lesser its entropy and vice versa.
\begin{align}
H(X) &= \sum_{x\in X}p(x)\log \frac{1}{p(x)} \\
&=log|X| - \sum_{x\in X}p(x)\log\frac{p(x)}{\frac{1}{|X|}} \\
&=\log|X|-D(p||uniform)
\end{align}
Source: section 1.2 of COS597D: Information Theory in Computer Science
Then your question(the title) can be rephrased into "the relationship between relative entropy of $p$ relative to $q$ and relative entropy of $q$ relative to uniform distribution". It's impossible that how $p$ diverges from $q$ relates to how $q$ diverges from a uniform distribution given that $p$ and $q$ can be any distribution pairs.
Shouldn't the entropy of $q$ be greater when minimizing $D_{KL}(q \:||\: p)$ than when minimizing $D_{KL}(p \:||\: q)$ (each w.r.t. parameters of $q$)?
NO.
The two relative entropy just don't correlate two each other. The relative entropy of $q$ relative to a uniform distribution doesn't depend on which relative entropy you are minimizing(because $p$ can be varying).
|
Relationship between KL divergence and entropy
Firstly, the KL divergence $D_{KL}(p||q)$ is synonymous with the relative entropy, relative entropy of $p$ with respect to $q$.
Entropy then becomes the self‐information of a random variable. Mutual
|
44,991
|
Why glm() can't recover the true parameters?
|
Poisson regression model is
$$
\log (\operatorname{E}(Y\mid\mathbf{x}))=\alpha + \mathbf{\beta}' \mathbf{x}
$$
So you are fitting different function to your data, then the one that generated it, so it would have different parameters. Poisson regression uses by default the log as a link function. For your simulation to be in-line with the Poisson regression model, you would need to draw samples from
$$
Y \sim \mathcal{P}(\,\exp[\alpha + \mathbf{\beta}'\mathbf{x} ]\,)
$$
Translating this into R code, that gives:
set.seed(123)
n <- 100
x <- seq_len(n)
y <- rpois(n, x/10)
beta <- glm(y ~ x, family='poisson')$coef
plot(x, y)
curve(x/10, min(x), max(x), col='blue', lty=2, lwd=2, add=TRUE)
curve(exp(beta[1] + beta[2] * x), min(x), max(x), col='red', lwd=2, add=TRUE)
title(expression(lambda == x/10))
x <- seq_len(n)
y <- rpois(n, exp(x/10))
beta <- glm(y ~ x, family='poisson')$coef
plot(x, y)
curve(exp(x/10), min(x), max(x), col='blue', lty=2, lwd=2, add=TRUE)
curve(exp(beta[1] + beta[2] * x), min(x), max(x), col='red', lwd=2, add=TRUE)
title(expression(lambda == exp(x/10)))
As you can see on the plots, the true regression line (blue dashed line) in first case differs from the regression line (red line) predicted by the model, while in second case they match so closely, that they are indistinguishable on the plot.
|
Why glm() can't recover the true parameters?
|
Poisson regression model is
$$
\log (\operatorname{E}(Y\mid\mathbf{x}))=\alpha + \mathbf{\beta}' \mathbf{x}
$$
So you are fitting different function to your data, then the one that generated it, so it
|
Why glm() can't recover the true parameters?
Poisson regression model is
$$
\log (\operatorname{E}(Y\mid\mathbf{x}))=\alpha + \mathbf{\beta}' \mathbf{x}
$$
So you are fitting different function to your data, then the one that generated it, so it would have different parameters. Poisson regression uses by default the log as a link function. For your simulation to be in-line with the Poisson regression model, you would need to draw samples from
$$
Y \sim \mathcal{P}(\,\exp[\alpha + \mathbf{\beta}'\mathbf{x} ]\,)
$$
Translating this into R code, that gives:
set.seed(123)
n <- 100
x <- seq_len(n)
y <- rpois(n, x/10)
beta <- glm(y ~ x, family='poisson')$coef
plot(x, y)
curve(x/10, min(x), max(x), col='blue', lty=2, lwd=2, add=TRUE)
curve(exp(beta[1] + beta[2] * x), min(x), max(x), col='red', lwd=2, add=TRUE)
title(expression(lambda == x/10))
x <- seq_len(n)
y <- rpois(n, exp(x/10))
beta <- glm(y ~ x, family='poisson')$coef
plot(x, y)
curve(exp(x/10), min(x), max(x), col='blue', lty=2, lwd=2, add=TRUE)
curve(exp(beta[1] + beta[2] * x), min(x), max(x), col='red', lwd=2, add=TRUE)
title(expression(lambda == exp(x/10)))
As you can see on the plots, the true regression line (blue dashed line) in first case differs from the regression line (red line) predicted by the model, while in second case they match so closely, that they are indistinguishable on the plot.
|
Why glm() can't recover the true parameters?
Poisson regression model is
$$
\log (\operatorname{E}(Y\mid\mathbf{x}))=\alpha + \mathbf{\beta}' \mathbf{x}
$$
So you are fitting different function to your data, then the one that generated it, so it
|
44,992
|
When is a data set a time series?
|
This raises an under-appreciated point about the scope of "time-series analysis"
I think you have hit on an under-appreciated point in time-series analysis here, which is that mathematically these models can also legitimately model data indexed by some other variable that does not represent "time" in the real world. If we step back from the terminology used in the field and just look at the bare bones of the mathematics of the models, we see that the field of "time-series analysis" uses statistical models with the following general features:
There are data values $x_t$ indexed by an index $t$, and this latter index can be either an integer (for "discrete-time" models) or a real number (for "continuous-time" models).
Models in this field may incorporate deterministic effects on the index $t$ (e.g., a linear trend, a polynomial trend, a sinusoidal wave, etc.).
Models in this field may incorporate "auto-regressive" statistical relationships, whereby we can write an equation for $x_t$ that depends on one or more values $x_r$ for $r<t$ and random error (and possibly also some exogenous variables).
Although models can often be manipulated into other forms, the defining form of the model never involves effects that reference larger values of the index $t$. So, for example, in the defining equation for the data value $x_t$ we would not include any effect referencing $x_r$ for any $r>t$. In this sense, the definition of the model treats the index $t$ as an ordering where effects can only reference "previous" values (or "current" values of other variables).
In more complicated models, we may have multiple series of data values $x_t$, $y_t$, $z_t$, etc., and we incorporate cross-referencing effects between them. Again, these models obey the general rule that their defining forms only reference "current" or "previous" values.
Now, it is entirely possible that models obeying the above properties might be useful in describing phenomena where we have data $x_t$ referenced by an index $t$ that does not represent time. In this case, we would model the data using a "time series model" even though the dataset is not actually a time-series --- i.e., the index referencing the data does not refer to time. In theory, it is possible that $t$ might represent a spatial variable, or a temperature variable, or something else that is not time. Obviously the models in time-series analysis are only really applicable when indices that are "directional" in the sense that they the requirements above, so some kinds of spatial models (which have effects that operate in both directions in space) would not meet these requirements.
In any case, as you can see, the scope of "time-series analysis" is technically larger than just models for data indexed by time. This is one of the points that I try to get across to students when teaching time-series analysis, but it is often forgotten through the force of repetition of the time-based terminology used to describe the models. It is a nice thing to bear in mind, in case you encounter statistical problems where you have data indexed by another directional variable, where you want to use a model with the above properties. In this case you can use "time-series analysis" even though your data does not vary with time.
To be sure that I answer your title question, please note that any dataset containing a series of observations indexed by time is ---by definition--- a time-series. This is a contextual question regarding the meaning of the variable $t$, not a mathematical question. This means that you will need to look at context and the meaning of your variables to determine whether or not your dataset is a time-series. However, the relevant issue for whether or not the field of "time-series analysis" is applicable is whether or not the model forms developed in that field are appropriate to the data. The vast majority of actual time-series datasets can be dealt with fruitfully by the models in "time-series analysis" or regression, but other datasets not involving time can sometimes be dealt with using these models.
|
When is a data set a time series?
|
This raises an under-appreciated point about the scope of "time-series analysis"
I think you have hit on an under-appreciated point in time-series analysis here, which is that mathematically these mod
|
When is a data set a time series?
This raises an under-appreciated point about the scope of "time-series analysis"
I think you have hit on an under-appreciated point in time-series analysis here, which is that mathematically these models can also legitimately model data indexed by some other variable that does not represent "time" in the real world. If we step back from the terminology used in the field and just look at the bare bones of the mathematics of the models, we see that the field of "time-series analysis" uses statistical models with the following general features:
There are data values $x_t$ indexed by an index $t$, and this latter index can be either an integer (for "discrete-time" models) or a real number (for "continuous-time" models).
Models in this field may incorporate deterministic effects on the index $t$ (e.g., a linear trend, a polynomial trend, a sinusoidal wave, etc.).
Models in this field may incorporate "auto-regressive" statistical relationships, whereby we can write an equation for $x_t$ that depends on one or more values $x_r$ for $r<t$ and random error (and possibly also some exogenous variables).
Although models can often be manipulated into other forms, the defining form of the model never involves effects that reference larger values of the index $t$. So, for example, in the defining equation for the data value $x_t$ we would not include any effect referencing $x_r$ for any $r>t$. In this sense, the definition of the model treats the index $t$ as an ordering where effects can only reference "previous" values (or "current" values of other variables).
In more complicated models, we may have multiple series of data values $x_t$, $y_t$, $z_t$, etc., and we incorporate cross-referencing effects between them. Again, these models obey the general rule that their defining forms only reference "current" or "previous" values.
Now, it is entirely possible that models obeying the above properties might be useful in describing phenomena where we have data $x_t$ referenced by an index $t$ that does not represent time. In this case, we would model the data using a "time series model" even though the dataset is not actually a time-series --- i.e., the index referencing the data does not refer to time. In theory, it is possible that $t$ might represent a spatial variable, or a temperature variable, or something else that is not time. Obviously the models in time-series analysis are only really applicable when indices that are "directional" in the sense that they the requirements above, so some kinds of spatial models (which have effects that operate in both directions in space) would not meet these requirements.
In any case, as you can see, the scope of "time-series analysis" is technically larger than just models for data indexed by time. This is one of the points that I try to get across to students when teaching time-series analysis, but it is often forgotten through the force of repetition of the time-based terminology used to describe the models. It is a nice thing to bear in mind, in case you encounter statistical problems where you have data indexed by another directional variable, where you want to use a model with the above properties. In this case you can use "time-series analysis" even though your data does not vary with time.
To be sure that I answer your title question, please note that any dataset containing a series of observations indexed by time is ---by definition--- a time-series. This is a contextual question regarding the meaning of the variable $t$, not a mathematical question. This means that you will need to look at context and the meaning of your variables to determine whether or not your dataset is a time-series. However, the relevant issue for whether or not the field of "time-series analysis" is applicable is whether or not the model forms developed in that field are appropriate to the data. The vast majority of actual time-series datasets can be dealt with fruitfully by the models in "time-series analysis" or regression, but other datasets not involving time can sometimes be dealt with using these models.
|
When is a data set a time series?
This raises an under-appreciated point about the scope of "time-series analysis"
I think you have hit on an under-appreciated point in time-series analysis here, which is that mathematically these mod
|
44,993
|
When is a data set a time series?
|
I would say the simplest answer is that a time-series is any dataset where event time is a feature. It doesn't need to be correlated with anything in any way,
but you also can't assume it's not.
Event time here is defined as a unique numeric index $T$ corresponding to a partial ordering of the set of events such that for any pair of events $A$ and $B$, if $T_A = T_B$ then $A$ and $B$ were concurrent up to the 'resolution' of the index.
This means only reporting a Unix timestamp up to the hour value is fine, but reporting the year and the UTC hour on a wall clock as an integer alone is not - 1 PM can refer to the same hour in any number of days.
Event time as an index has a bunch of properties that makes it distinct from any random numerical feature, even an orderable one. Even with no causality in the common sense of the word the values of $Y_2$ become more and more correlated with the values of $Y_1$ as $T_2 - T_1$ goes to zero. With causality on top, the data-generating process is effectively a Markov chain of some (arbitrarily high or low) dimensionality.
|
When is a data set a time series?
|
I would say the simplest answer is that a time-series is any dataset where event time is a feature. It doesn't need to be correlated with anything in any way,
but you also can't assume it's not.
Even
|
When is a data set a time series?
I would say the simplest answer is that a time-series is any dataset where event time is a feature. It doesn't need to be correlated with anything in any way,
but you also can't assume it's not.
Event time here is defined as a unique numeric index $T$ corresponding to a partial ordering of the set of events such that for any pair of events $A$ and $B$, if $T_A = T_B$ then $A$ and $B$ were concurrent up to the 'resolution' of the index.
This means only reporting a Unix timestamp up to the hour value is fine, but reporting the year and the UTC hour on a wall clock as an integer alone is not - 1 PM can refer to the same hour in any number of days.
Event time as an index has a bunch of properties that makes it distinct from any random numerical feature, even an orderable one. Even with no causality in the common sense of the word the values of $Y_2$ become more and more correlated with the values of $Y_1$ as $T_2 - T_1$ goes to zero. With causality on top, the data-generating process is effectively a Markov chain of some (arbitrarily high or low) dimensionality.
|
When is a data set a time series?
I would say the simplest answer is that a time-series is any dataset where event time is a feature. It doesn't need to be correlated with anything in any way,
but you also can't assume it's not.
Even
|
44,994
|
When is a data set a time series?
|
A time-series data set is just data collected through time. For calling it a time series, it doesn't matter if futures values are a function of past values or not.
So in your moon brightness example, if you measure the brightness and record the time of measurement, it's time-series data. Even the number of road accident deaths for each year is time-series data.
Suppose, I roll a die 100 times and note down the outcome of each roll, this data set is also time series.
Now, given time-series data, one useful thing to do is to forecast the future values of the series. For doing this, one way is to model the time series as a sequence of random variables and look for correlation among these variables, referred to as autocorrelation in time series terminology. If this correlation exists, it can be used to forecast values ahead even if there may not be a causal relationship between future and past values.
Remember, correlation is not causation, but the correlation is still very useful in forecasting.
This is a good place to get more information on time series data and what you can do with it.
|
When is a data set a time series?
|
A time-series data set is just data collected through time. For calling it a time series, it doesn't matter if futures values are a function of past values or not.
So in your moon brightness example,
|
When is a data set a time series?
A time-series data set is just data collected through time. For calling it a time series, it doesn't matter if futures values are a function of past values or not.
So in your moon brightness example, if you measure the brightness and record the time of measurement, it's time-series data. Even the number of road accident deaths for each year is time-series data.
Suppose, I roll a die 100 times and note down the outcome of each roll, this data set is also time series.
Now, given time-series data, one useful thing to do is to forecast the future values of the series. For doing this, one way is to model the time series as a sequence of random variables and look for correlation among these variables, referred to as autocorrelation in time series terminology. If this correlation exists, it can be used to forecast values ahead even if there may not be a causal relationship between future and past values.
Remember, correlation is not causation, but the correlation is still very useful in forecasting.
This is a good place to get more information on time series data and what you can do with it.
|
When is a data set a time series?
A time-series data set is just data collected through time. For calling it a time series, it doesn't matter if futures values are a function of past values or not.
So in your moon brightness example,
|
44,995
|
When is a data set a time series?
|
I think that, in practice, a time-series is a method, not a data type, one of those developed such as ARIMA to address problems when data is causally ordered and thus X can predict Y differently at different points in time, and autocorrelation is an issue. But that is another way of saying I guess that if autocorrelation is tied to time and a change in the impact of a predictor on the response variable over time (at different lags) occurs you have time-series data.
|
When is a data set a time series?
|
I think that, in practice, a time-series is a method, not a data type, one of those developed such as ARIMA to address problems when data is causally ordered and thus X can predict Y differently at di
|
When is a data set a time series?
I think that, in practice, a time-series is a method, not a data type, one of those developed such as ARIMA to address problems when data is causally ordered and thus X can predict Y differently at different points in time, and autocorrelation is an issue. But that is another way of saying I guess that if autocorrelation is tied to time and a change in the impact of a predictor on the response variable over time (at different lags) occurs you have time-series data.
|
When is a data set a time series?
I think that, in practice, a time-series is a method, not a data type, one of those developed such as ARIMA to address problems when data is causally ordered and thus X can predict Y differently at di
|
44,996
|
Linear regression with aggregated data or not?
|
I would suggest taking advantage of all the data by fitting a linear mixed effects model. This is a model that includes fixed effects and random effects. If you aggregate the data then you lose information, while if you fail to account for the probability that costs in one lane are more similar to costs in that lane than other lanes then you will obtain biased results.
To do this, you simply fit random intercepts for lane. Using the lme4 in R package as an example the would look like:
lmer(cost ~ distance + (1 | lane), data = mydata)
The lane variable is treated as random in the sense that it can be thought of as a variable for which you have more than just a few (5-10 is often mentioned as being the minimum, although there is no consensus on the matter: you have 2000 so this is not an issue at all), and each lane then has it's own intercept which varies randomly around the global intercept (which is equivalent to just "the intercept" in a model without random effects). We do this in order to control for the non-independence of observations/measures within each lane, otherwise biased results are very likely.
You can also allow the effect of distance to be different for each lane by adding random slopes:
lmer(cost ~ distance + (distance | lane), data = mydata)
And finally you can also allow distance to have a non-linear effect on cost by including nonlinear terms in the model equation, or using splines.
The above models will help you to understand the association between distance and cost for existing lanes, and it will also help you to understand the variation in costs by lane, and in the case of the random slopes model, to also see if the association between cost and distance differs between lanes. However, you say that you are interested in prediction for new lanes that have not been seen before. To get to grips with this problem, more information is needed about what the lanes actually are.
|
Linear regression with aggregated data or not?
|
I would suggest taking advantage of all the data by fitting a linear mixed effects model. This is a model that includes fixed effects and random effects. If you aggregate the data then you lose inform
|
Linear regression with aggregated data or not?
I would suggest taking advantage of all the data by fitting a linear mixed effects model. This is a model that includes fixed effects and random effects. If you aggregate the data then you lose information, while if you fail to account for the probability that costs in one lane are more similar to costs in that lane than other lanes then you will obtain biased results.
To do this, you simply fit random intercepts for lane. Using the lme4 in R package as an example the would look like:
lmer(cost ~ distance + (1 | lane), data = mydata)
The lane variable is treated as random in the sense that it can be thought of as a variable for which you have more than just a few (5-10 is often mentioned as being the minimum, although there is no consensus on the matter: you have 2000 so this is not an issue at all), and each lane then has it's own intercept which varies randomly around the global intercept (which is equivalent to just "the intercept" in a model without random effects). We do this in order to control for the non-independence of observations/measures within each lane, otherwise biased results are very likely.
You can also allow the effect of distance to be different for each lane by adding random slopes:
lmer(cost ~ distance + (distance | lane), data = mydata)
And finally you can also allow distance to have a non-linear effect on cost by including nonlinear terms in the model equation, or using splines.
The above models will help you to understand the association between distance and cost for existing lanes, and it will also help you to understand the variation in costs by lane, and in the case of the random slopes model, to also see if the association between cost and distance differs between lanes. However, you say that you are interested in prediction for new lanes that have not been seen before. To get to grips with this problem, more information is needed about what the lanes actually are.
|
Linear regression with aggregated data or not?
I would suggest taking advantage of all the data by fitting a linear mixed effects model. This is a model that includes fixed effects and random effects. If you aggregate the data then you lose inform
|
44,997
|
Linear regression with aggregated data or not?
|
First, I'd try to answer the questions. Are the cost/distance relationships between each lane statistically different? If yes, are the differences large enough to matter for our application / problem? If no, use the aggregated data. Otherwise, we need to do some simple thought experiments to see what using aggregated / non-aggregated data means.
Suppose 50% of lanes cost \$10/km and 50% \$2/km. The average would be \$6/km. But does this mean anything for making predictions? I'd say a \$6/km prediction for a previously unseen lane is wrong. If all lanes are similar, than it's either going to cost \$10/km or \$2/km. But the average of hundreds of new lanes will be close to \$6/km.
Using aggregated or non-aggregated data answers different questions.
Hope this helps a little.
|
Linear regression with aggregated data or not?
|
First, I'd try to answer the questions. Are the cost/distance relationships between each lane statistically different? If yes, are the differences large enough to matter for our application / problem?
|
Linear regression with aggregated data or not?
First, I'd try to answer the questions. Are the cost/distance relationships between each lane statistically different? If yes, are the differences large enough to matter for our application / problem? If no, use the aggregated data. Otherwise, we need to do some simple thought experiments to see what using aggregated / non-aggregated data means.
Suppose 50% of lanes cost \$10/km and 50% \$2/km. The average would be \$6/km. But does this mean anything for making predictions? I'd say a \$6/km prediction for a previously unseen lane is wrong. If all lanes are similar, than it's either going to cost \$10/km or \$2/km. But the average of hundreds of new lanes will be close to \$6/km.
Using aggregated or non-aggregated data answers different questions.
Hope this helps a little.
|
Linear regression with aggregated data or not?
First, I'd try to answer the questions. Are the cost/distance relationships between each lane statistically different? If yes, are the differences large enough to matter for our application / problem?
|
44,998
|
Suppose $X$ follows a normal mixture. In which cases is $X$ itself normally distributed?
|
When a finite mixture of Normal variables is Normal, then all the variables are identically distributed. Thus, if $\mu_1\ne\mu_2$ or $\sigma_1^2\ne\sigma_2^2,$ $F$ cannot be Normal.
A simple way to see why this assertion is true uses the characteristic function. Let the Normal components have variances $\sigma_1^2 \le \sigma_2^2 \le \cdots \le \sigma_n^2,$ corresponding means $\mu_1, \ldots, \mu_n,$ and nonzero proportions $\pi_1, \ldots, \pi_n.$ With no loss of generality, shift all means by a common amount to make the mixture mean zero. Suppose this mixture is Normal with the same zero mean and variance $\sigma.$ Its characteristic function must equal that of the mixture. Thus, for all real values $t,$
$$\exp(-\sigma^2 t^2/2) = \sum_{j=1}^n \pi_j \exp(i\mu_j t - \sigma_j^2 t^2/2).\tag{1}$$
Taking derivatives with respect to $t$ shows the left hand side is always real. The imaginary part of the derivative of the right side therefore must be constantly zero, especially in any neighborhood of $0$ where we may approximate the sine function by the linear term in its Taylor series:
$$0 = \frac{1}{2}\sum_{j=1}^n \pi_j \mu_j \sigma_j^2 \exp(- \sigma_j^2 t^2/2) \sin(\mu_j t) = \left(\frac{1}{2}\sum_{j=1}^n \pi_j \mu_j^2 \exp(-\sigma_j^2 t^2/2)\right) t + O(t^2).$$
This is impossible unless the coefficient of $t$ is identically zero, implying every $\mu_j=0.$ That is, all the component means must be equal if the mixture is Normal.
In light of this, $(1)$ asserts
$$\exp(-\sigma^2 t^2/2) = \sum_{j=1}^n \pi_j \exp(-\sigma_j^2 t^2/2) = \exp(-\sigma_1^2t^2/2 )\sum_{j=1}^n \pi_j \exp((\sigma_1^2-\sigma_j^2) t^2/2).$$
As $t^2$ grows large, the terms in the right hand sum either equal $\pi_j$ when $\sigma_j=\sigma_1$ or decrease rapidly to zero when $\sigma_j \gt \sigma_1.$ Taking logarithms, we find
$$\sigma^2t^2/2 = -\sigma_1^2 t^2/2 + \log\left(\sum_{j=1}^k \pi_j\right) + \epsilon,$$
where $\epsilon$ can be made arbitrarily small and $\sigma_1^2=\sigma_2^2=\cdots=\sigma_k^2 \ne \sigma_{k+1}^2.$ This is impossible unless the constant term on the right is zero, which means
$$1 = \sum_{j=1}^k \pi_j,$$
showing that $k=n.$ That is, all the $\sigma_j$ are equal, QED.
|
Suppose $X$ follows a normal mixture. In which cases is $X$ itself normally distributed?
|
When a finite mixture of Normal variables is Normal, then all the variables are identically distributed. Thus, if $\mu_1\ne\mu_2$ or $\sigma_1^2\ne\sigma_2^2,$ $F$ cannot be Normal.
A simple way to
|
Suppose $X$ follows a normal mixture. In which cases is $X$ itself normally distributed?
When a finite mixture of Normal variables is Normal, then all the variables are identically distributed. Thus, if $\mu_1\ne\mu_2$ or $\sigma_1^2\ne\sigma_2^2,$ $F$ cannot be Normal.
A simple way to see why this assertion is true uses the characteristic function. Let the Normal components have variances $\sigma_1^2 \le \sigma_2^2 \le \cdots \le \sigma_n^2,$ corresponding means $\mu_1, \ldots, \mu_n,$ and nonzero proportions $\pi_1, \ldots, \pi_n.$ With no loss of generality, shift all means by a common amount to make the mixture mean zero. Suppose this mixture is Normal with the same zero mean and variance $\sigma.$ Its characteristic function must equal that of the mixture. Thus, for all real values $t,$
$$\exp(-\sigma^2 t^2/2) = \sum_{j=1}^n \pi_j \exp(i\mu_j t - \sigma_j^2 t^2/2).\tag{1}$$
Taking derivatives with respect to $t$ shows the left hand side is always real. The imaginary part of the derivative of the right side therefore must be constantly zero, especially in any neighborhood of $0$ where we may approximate the sine function by the linear term in its Taylor series:
$$0 = \frac{1}{2}\sum_{j=1}^n \pi_j \mu_j \sigma_j^2 \exp(- \sigma_j^2 t^2/2) \sin(\mu_j t) = \left(\frac{1}{2}\sum_{j=1}^n \pi_j \mu_j^2 \exp(-\sigma_j^2 t^2/2)\right) t + O(t^2).$$
This is impossible unless the coefficient of $t$ is identically zero, implying every $\mu_j=0.$ That is, all the component means must be equal if the mixture is Normal.
In light of this, $(1)$ asserts
$$\exp(-\sigma^2 t^2/2) = \sum_{j=1}^n \pi_j \exp(-\sigma_j^2 t^2/2) = \exp(-\sigma_1^2t^2/2 )\sum_{j=1}^n \pi_j \exp((\sigma_1^2-\sigma_j^2) t^2/2).$$
As $t^2$ grows large, the terms in the right hand sum either equal $\pi_j$ when $\sigma_j=\sigma_1$ or decrease rapidly to zero when $\sigma_j \gt \sigma_1.$ Taking logarithms, we find
$$\sigma^2t^2/2 = -\sigma_1^2 t^2/2 + \log\left(\sum_{j=1}^k \pi_j\right) + \epsilon,$$
where $\epsilon$ can be made arbitrarily small and $\sigma_1^2=\sigma_2^2=\cdots=\sigma_k^2 \ne \sigma_{k+1}^2.$ This is impossible unless the constant term on the right is zero, which means
$$1 = \sum_{j=1}^k \pi_j,$$
showing that $k=n.$ That is, all the $\sigma_j$ are equal, QED.
|
Suppose $X$ follows a normal mixture. In which cases is $X$ itself normally distributed?
When a finite mixture of Normal variables is Normal, then all the variables are identically distributed. Thus, if $\mu_1\ne\mu_2$ or $\sigma_1^2\ne\sigma_2^2,$ $F$ cannot be Normal.
A simple way to
|
44,999
|
Does order of events matter in Bayesian update?
|
AFAIK, you cannot say that $p > \frac{1}{2}$ or even $\mathbb E[p]>\frac{1}{2}$ is an "observation" or "event", but rather a constraint on your model parameter(s). The term "observation" is usually reserved for specific realizations of a random variable (i.e. draws from a distribution). In your model, one could plausibly observe $p$ (numbers between 0 and 1) or the outcomes of $Bernoulli(p)$ (either 0 or 1). There is no way to observe $\mathbb E[p]>\frac{1}{2}$, this information lies outside your probabilistic model.
As a rough rule (some caveats apply) you should be able to simulate observations from your probabilistic model, given model parameters. How would you simulate a model where $\mathbb E[p]>\frac{1}{2}$ is a possible observation?
If you start with the $p\sim Beta(a_0,b_0); a_0, b_0 \in \mathbb{R}^+$ model and then learn that $\mathbb E[p]>\frac{1}{2}$, it means your initial model was incorrect and you should change your model to reflect the constraint ($\mathbb E[p]>\frac{1}{2}$ implies $\frac{a_0}{a_0 + b_0} > \frac{1}{2}$, so some combinations of $a_0$ and $b_0$ are ruled out). Adding a constraint cannot be AFAIK directly handled in the language of Bayesian updating.
Hope that helps.
|
Does order of events matter in Bayesian update?
|
AFAIK, you cannot say that $p > \frac{1}{2}$ or even $\mathbb E[p]>\frac{1}{2}$ is an "observation" or "event", but rather a constraint on your model parameter(s). The term "observation" is usually re
|
Does order of events matter in Bayesian update?
AFAIK, you cannot say that $p > \frac{1}{2}$ or even $\mathbb E[p]>\frac{1}{2}$ is an "observation" or "event", but rather a constraint on your model parameter(s). The term "observation" is usually reserved for specific realizations of a random variable (i.e. draws from a distribution). In your model, one could plausibly observe $p$ (numbers between 0 and 1) or the outcomes of $Bernoulli(p)$ (either 0 or 1). There is no way to observe $\mathbb E[p]>\frac{1}{2}$, this information lies outside your probabilistic model.
As a rough rule (some caveats apply) you should be able to simulate observations from your probabilistic model, given model parameters. How would you simulate a model where $\mathbb E[p]>\frac{1}{2}$ is a possible observation?
If you start with the $p\sim Beta(a_0,b_0); a_0, b_0 \in \mathbb{R}^+$ model and then learn that $\mathbb E[p]>\frac{1}{2}$, it means your initial model was incorrect and you should change your model to reflect the constraint ($\mathbb E[p]>\frac{1}{2}$ implies $\frac{a_0}{a_0 + b_0} > \frac{1}{2}$, so some combinations of $a_0$ and $b_0$ are ruled out). Adding a constraint cannot be AFAIK directly handled in the language of Bayesian updating.
Hope that helps.
|
Does order of events matter in Bayesian update?
AFAIK, you cannot say that $p > \frac{1}{2}$ or even $\mathbb E[p]>\frac{1}{2}$ is an "observation" or "event", but rather a constraint on your model parameter(s). The term "observation" is usually re
|
45,000
|
Does order of events matter in Bayesian update?
|
In Bayesian inference, terms like "observation" and "event" are just conveniences; there is no fundamental importance to them, so don't get hung up on them.
In particular, there is no physical causality or time's arrow -- no "events". Whether you can carry out some calculations in more than one order depends solely on the form of the model. If, algebraically, the results are the same assuming different orders of assignments to some variables (i.e., "observations"), then, terrific, you can do whatever is convenient. If not, well, so what?
About the representation of p > 1/2, you could represent that as a likelihood function which is just a step at 1/2. That is, it is zero to the left of 1/2, and any positive constant to the right. Note that ordinary "observations" yield likelihood functions which vary smoothly, but the smoothness is not a requirement.
|
Does order of events matter in Bayesian update?
|
In Bayesian inference, terms like "observation" and "event" are just conveniences; there is no fundamental importance to them, so don't get hung up on them.
In particular, there is no physical causal
|
Does order of events matter in Bayesian update?
In Bayesian inference, terms like "observation" and "event" are just conveniences; there is no fundamental importance to them, so don't get hung up on them.
In particular, there is no physical causality or time's arrow -- no "events". Whether you can carry out some calculations in more than one order depends solely on the form of the model. If, algebraically, the results are the same assuming different orders of assignments to some variables (i.e., "observations"), then, terrific, you can do whatever is convenient. If not, well, so what?
About the representation of p > 1/2, you could represent that as a likelihood function which is just a step at 1/2. That is, it is zero to the left of 1/2, and any positive constant to the right. Note that ordinary "observations" yield likelihood functions which vary smoothly, but the smoothness is not a requirement.
|
Does order of events matter in Bayesian update?
In Bayesian inference, terms like "observation" and "event" are just conveniences; there is no fundamental importance to them, so don't get hung up on them.
In particular, there is no physical causal
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.