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
|
|---|---|---|---|---|---|---|
8,701
|
How to design and implement an asymmetric loss function for regression?
|
As mentioned in the comments above, quantile regression uses an asymmetric loss function ( linear but with different slopes for positive and negative errors). The quadratic (squared loss) analog of quantile regression is expectile regression.
You can google quantile regression for the references. For expectile regression see the R package expectreg and the references in the reference manual.
|
How to design and implement an asymmetric loss function for regression?
|
As mentioned in the comments above, quantile regression uses an asymmetric loss function ( linear but with different slopes for positive and negative errors). The quadratic (squared loss) analog of qu
|
How to design and implement an asymmetric loss function for regression?
As mentioned in the comments above, quantile regression uses an asymmetric loss function ( linear but with different slopes for positive and negative errors). The quadratic (squared loss) analog of quantile regression is expectile regression.
You can google quantile regression for the references. For expectile regression see the R package expectreg and the references in the reference manual.
|
How to design and implement an asymmetric loss function for regression?
As mentioned in the comments above, quantile regression uses an asymmetric loss function ( linear but with different slopes for positive and negative errors). The quadratic (squared loss) analog of qu
|
8,702
|
How to design and implement an asymmetric loss function for regression?
|
This sort of unequal weighting is often done in classification problems with two classes. The Bayes rule can be modifed using a loss function that that weights the loss higher for one error than the other. This will lead to a rule that produces unequal error rates.
In regression it would certainly be possible to construct a weight function such as a weighted sum of squares that will give some weight to the negative errors and a higher weight to the positive ones. This would be similar to weighted least square but a little different because weighted least squares is intended for problems where the error variance is not constant over the space of possible values for the predictor variables. In that case the weights are higher for the points where the error variance is known to be small and higher where the error variance is known to be large. This of course will lead to values for the regression parameters that are different from what OLS would give you.
|
How to design and implement an asymmetric loss function for regression?
|
This sort of unequal weighting is often done in classification problems with two classes. The Bayes rule can be modifed using a loss function that that weights the loss higher for one error than the
|
How to design and implement an asymmetric loss function for regression?
This sort of unequal weighting is often done in classification problems with two classes. The Bayes rule can be modifed using a loss function that that weights the loss higher for one error than the other. This will lead to a rule that produces unequal error rates.
In regression it would certainly be possible to construct a weight function such as a weighted sum of squares that will give some weight to the negative errors and a higher weight to the positive ones. This would be similar to weighted least square but a little different because weighted least squares is intended for problems where the error variance is not constant over the space of possible values for the predictor variables. In that case the weights are higher for the points where the error variance is known to be small and higher where the error variance is known to be large. This of course will lead to values for the regression parameters that are different from what OLS would give you.
|
How to design and implement an asymmetric loss function for regression?
This sort of unequal weighting is often done in classification problems with two classes. The Bayes rule can be modifed using a loss function that that weights the loss higher for one error than the
|
8,703
|
AIC versus cross validation in time series: the small sample case
|
Taking theoretical considerations aside, Akaike Information Criterion is just likelihood penalized by the degrees of freedom. What follows, AIC accounts for uncertainty in the data (-2LL) and makes the assumption that more parameters leads to higher risk of overfitting (2k). Cross-validation just looks at the test set performance of the model, with no further assumptions.
If you care mostly about making the predictions and you can assume that the test set(s) would be reasonably similar to the real-world data, you should go for cross-validation. The possible problem is that when your data is small, then by splitting it, you end up with small training and test sets. Less data for training is bad, and less data for test set makes the cross-validation results more uncertain (see Varoquaux, 2018). If your test sample is insufficient, you may be forced to use AIC, but keep in mind what it measures, and what assumptions it can make.
On another hand, as already mentioned in comments, AIC gives you asymptotic guarantees, and it's not the case with small samples. Small samples may be misleading about the uncertainty in the data as well.
|
AIC versus cross validation in time series: the small sample case
|
Taking theoretical considerations aside, Akaike Information Criterion is just likelihood penalized by the degrees of freedom. What follows, AIC accounts for uncertainty in the data (-2LL) and makes th
|
AIC versus cross validation in time series: the small sample case
Taking theoretical considerations aside, Akaike Information Criterion is just likelihood penalized by the degrees of freedom. What follows, AIC accounts for uncertainty in the data (-2LL) and makes the assumption that more parameters leads to higher risk of overfitting (2k). Cross-validation just looks at the test set performance of the model, with no further assumptions.
If you care mostly about making the predictions and you can assume that the test set(s) would be reasonably similar to the real-world data, you should go for cross-validation. The possible problem is that when your data is small, then by splitting it, you end up with small training and test sets. Less data for training is bad, and less data for test set makes the cross-validation results more uncertain (see Varoquaux, 2018). If your test sample is insufficient, you may be forced to use AIC, but keep in mind what it measures, and what assumptions it can make.
On another hand, as already mentioned in comments, AIC gives you asymptotic guarantees, and it's not the case with small samples. Small samples may be misleading about the uncertainty in the data as well.
|
AIC versus cross validation in time series: the small sample case
Taking theoretical considerations aside, Akaike Information Criterion is just likelihood penalized by the degrees of freedom. What follows, AIC accounts for uncertainty in the data (-2LL) and makes th
|
8,704
|
AIC versus cross validation in time series: the small sample case
|
Hm - if your ultimate goal is to predict, why do you intend to do model selection at all? As far as I know, it is well established both in the "traditional" statistical literature and the machine learning literature that model averaging is superior when it comes to prediction. Put simply, model averaging means that you estimate all plausible models, let them all predict and average their predictions weighted by their relative model evidence.
A useful reference to start is
https://journals.sagepub.com/doi/10.1177/0049124104268644
They explain this quite simply and refer to the relevant literature.
Hope this helps.
|
AIC versus cross validation in time series: the small sample case
|
Hm - if your ultimate goal is to predict, why do you intend to do model selection at all? As far as I know, it is well established both in the "traditional" statistical literature and the machine lear
|
AIC versus cross validation in time series: the small sample case
Hm - if your ultimate goal is to predict, why do you intend to do model selection at all? As far as I know, it is well established both in the "traditional" statistical literature and the machine learning literature that model averaging is superior when it comes to prediction. Put simply, model averaging means that you estimate all plausible models, let them all predict and average their predictions weighted by their relative model evidence.
A useful reference to start is
https://journals.sagepub.com/doi/10.1177/0049124104268644
They explain this quite simply and refer to the relevant literature.
Hope this helps.
|
AIC versus cross validation in time series: the small sample case
Hm - if your ultimate goal is to predict, why do you intend to do model selection at all? As far as I know, it is well established both in the "traditional" statistical literature and the machine lear
|
8,705
|
AIC versus cross validation in time series: the small sample case
|
My idea is, do both and see. It's direct to use AIC. Smaller the AIC, better the model. But one cannot depend on AIC and say such model is the best. So, if you have a pool of ARIMA models, take each and check on forecasting for the existing values and see which model predicts the closest to the existing time series data. Secondly check for the
AIC as well and considering both, come to a good choice. There are no hard and fast rules. Just go for the model which predicts the best.
|
AIC versus cross validation in time series: the small sample case
|
My idea is, do both and see. It's direct to use AIC. Smaller the AIC, better the model. But one cannot depend on AIC and say such model is the best. So, if you have a pool of ARIMA models, take each a
|
AIC versus cross validation in time series: the small sample case
My idea is, do both and see. It's direct to use AIC. Smaller the AIC, better the model. But one cannot depend on AIC and say such model is the best. So, if you have a pool of ARIMA models, take each and check on forecasting for the existing values and see which model predicts the closest to the existing time series data. Secondly check for the
AIC as well and considering both, come to a good choice. There are no hard and fast rules. Just go for the model which predicts the best.
|
AIC versus cross validation in time series: the small sample case
My idea is, do both and see. It's direct to use AIC. Smaller the AIC, better the model. But one cannot depend on AIC and say such model is the best. So, if you have a pool of ARIMA models, take each a
|
8,706
|
Two dice rolls - same number in sequence
|
The probability of rolling a specific number twice in a row is indeed 1/36, because you have a 1/6 chance of getting that number on each of two rolls (1/6 x 1/6).
The probability of rolling any number twice in a row is 1/6, because there are six ways to roll a specific number twice in a row (6 x 1/36). Another way to think about it is that you don't care what the first number is, you just need the second number to match it (with probability 1/6 ).
|
Two dice rolls - same number in sequence
|
The probability of rolling a specific number twice in a row is indeed 1/36, because you have a 1/6 chance of getting that number on each of two rolls (1/6 x 1/6).
The probability of rolling any number
|
Two dice rolls - same number in sequence
The probability of rolling a specific number twice in a row is indeed 1/36, because you have a 1/6 chance of getting that number on each of two rolls (1/6 x 1/6).
The probability of rolling any number twice in a row is 1/6, because there are six ways to roll a specific number twice in a row (6 x 1/36). Another way to think about it is that you don't care what the first number is, you just need the second number to match it (with probability 1/6 ).
|
Two dice rolls - same number in sequence
The probability of rolling a specific number twice in a row is indeed 1/36, because you have a 1/6 chance of getting that number on each of two rolls (1/6 x 1/6).
The probability of rolling any number
|
8,707
|
Two dice rolls - same number in sequence
|
To make it perfectly clear, consider the sample space for rolling a die twice.
(1, 1) (1, 2) (1, 3) (1, 4) (1, 5) (1, 6)
(2, 1) (2, 2) (2, 3) (2, 4) (2, 5) (2, 6)
(3, 1) (3, 2) (3, 3) (3, 4) (3, 5) (3, 6)
(4, 1) (4, 2) (4, 3) (4, 4) (4, 5) (4, 6)
(5, 1) (5, 2) (5, 3) (5, 4) (5, 5) (5, 6)
(6, 1) (6, 2) (6, 3) (6, 4) (6, 5) (6, 6)
There are 36 equally likely possible outcomes, 6 of which define the event "rolling the same number two times in a row". Then, the probability of this event occurring is $\frac{6}{36}$, which is equal to $\frac{1}{6}$.
|
Two dice rolls - same number in sequence
|
To make it perfectly clear, consider the sample space for rolling a die twice.
(1, 1) (1, 2) (1, 3) (1, 4) (1, 5) (1, 6)
(2, 1) (2, 2) (2, 3) (2, 4) (2, 5) (2, 6)
(3, 1) (3, 2) (3, 3) (3, 4) (3, 5) (3
|
Two dice rolls - same number in sequence
To make it perfectly clear, consider the sample space for rolling a die twice.
(1, 1) (1, 2) (1, 3) (1, 4) (1, 5) (1, 6)
(2, 1) (2, 2) (2, 3) (2, 4) (2, 5) (2, 6)
(3, 1) (3, 2) (3, 3) (3, 4) (3, 5) (3, 6)
(4, 1) (4, 2) (4, 3) (4, 4) (4, 5) (4, 6)
(5, 1) (5, 2) (5, 3) (5, 4) (5, 5) (5, 6)
(6, 1) (6, 2) (6, 3) (6, 4) (6, 5) (6, 6)
There are 36 equally likely possible outcomes, 6 of which define the event "rolling the same number two times in a row". Then, the probability of this event occurring is $\frac{6}{36}$, which is equal to $\frac{1}{6}$.
|
Two dice rolls - same number in sequence
To make it perfectly clear, consider the sample space for rolling a die twice.
(1, 1) (1, 2) (1, 3) (1, 4) (1, 5) (1, 6)
(2, 1) (2, 2) (2, 3) (2, 4) (2, 5) (2, 6)
(3, 1) (3, 2) (3, 3) (3, 4) (3, 5) (3
|
8,708
|
Two dice rolls - same number in sequence
|
Conceptually, this is just asking "what are the chances a second die matches the result of the first". Suppose I rolled a die, secretly, and asked you to match the outcome with your own roll.
No matter which number I rolled, there is a 1/6 chance that your die matches my roll, as there is a 1/6 chance any die roll comes up any specific number.
|
Two dice rolls - same number in sequence
|
Conceptually, this is just asking "what are the chances a second die matches the result of the first". Suppose I rolled a die, secretly, and asked you to match the outcome with your own roll.
No matt
|
Two dice rolls - same number in sequence
Conceptually, this is just asking "what are the chances a second die matches the result of the first". Suppose I rolled a die, secretly, and asked you to match the outcome with your own roll.
No matter which number I rolled, there is a 1/6 chance that your die matches my roll, as there is a 1/6 chance any die roll comes up any specific number.
|
Two dice rolls - same number in sequence
Conceptually, this is just asking "what are the chances a second die matches the result of the first". Suppose I rolled a die, secretly, and asked you to match the outcome with your own roll.
No matt
|
8,709
|
Two dice rolls - same number in sequence
|
If you roll a 1 then on the second roll (for a fair 6 sided die) the probability that the second roll is a 1 is 1/6 (assuming independence. This would be true for any other possible first roll.
|
Two dice rolls - same number in sequence
|
If you roll a 1 then on the second roll (for a fair 6 sided die) the probability that the second roll is a 1 is 1/6 (assuming independence. This would be true for any other possible first roll.
|
Two dice rolls - same number in sequence
If you roll a 1 then on the second roll (for a fair 6 sided die) the probability that the second roll is a 1 is 1/6 (assuming independence. This would be true for any other possible first roll.
|
Two dice rolls - same number in sequence
If you roll a 1 then on the second roll (for a fair 6 sided die) the probability that the second roll is a 1 is 1/6 (assuming independence. This would be true for any other possible first roll.
|
8,710
|
Two dice rolls - same number in sequence
|
i would look at it as a combination problem . where you are asked what possible combinations are thre that have same numbers on first and second roll. combinations are 6 (11,22,33,44,55,66)
from a total possibilities 6*6=36
so probability is 6/36
|
Two dice rolls - same number in sequence
|
i would look at it as a combination problem . where you are asked what possible combinations are thre that have same numbers on first and second roll. combinations are 6 (11,22,33,44,55,66)
from a to
|
Two dice rolls - same number in sequence
i would look at it as a combination problem . where you are asked what possible combinations are thre that have same numbers on first and second roll. combinations are 6 (11,22,33,44,55,66)
from a total possibilities 6*6=36
so probability is 6/36
|
Two dice rolls - same number in sequence
i would look at it as a combination problem . where you are asked what possible combinations are thre that have same numbers on first and second roll. combinations are 6 (11,22,33,44,55,66)
from a to
|
8,711
|
Two dice rolls - same number in sequence
|
Hope this helps :
Probability for the first roll to turn up as 1 : 1/6
Probability for the second roll also to turn up as 1 : 1/6
Therefore , probability that the first two rolls turn up as 1 is (1/6*1/6) = 1/36
Now the probability that the first two rolls turn up as 2 is (1/6*1/6) = 1/36
.
.
.
.
Same applies for 3,4,5,6
So the probability for any number to turn up consecutively twice is (1/36+1/36+1/36+1/36+1/36+1/36) = (6/36)
= 1/6
|
Two dice rolls - same number in sequence
|
Hope this helps :
Probability for the first roll to turn up as 1 : 1/6
Probability for the second roll also to turn up as 1 : 1/6
Therefore , probability that the first two rolls turn up as 1 is (1/6*
|
Two dice rolls - same number in sequence
Hope this helps :
Probability for the first roll to turn up as 1 : 1/6
Probability for the second roll also to turn up as 1 : 1/6
Therefore , probability that the first two rolls turn up as 1 is (1/6*1/6) = 1/36
Now the probability that the first two rolls turn up as 2 is (1/6*1/6) = 1/36
.
.
.
.
Same applies for 3,4,5,6
So the probability for any number to turn up consecutively twice is (1/36+1/36+1/36+1/36+1/36+1/36) = (6/36)
= 1/6
|
Two dice rolls - same number in sequence
Hope this helps :
Probability for the first roll to turn up as 1 : 1/6
Probability for the second roll also to turn up as 1 : 1/6
Therefore , probability that the first two rolls turn up as 1 is (1/6*
|
8,712
|
Two dice rolls - same number in sequence
|
Since I didn't see this exact way of framing it above:
For your first roll there are 6 possible answers, and 6 acceptable answers (as any number 1-6 is acceptable).
6/6
For the second roll there are 6 possible answers, but now only 1 will match the first roll.
1/6
6/6 * 1/6 = 1/6
|
Two dice rolls - same number in sequence
|
Since I didn't see this exact way of framing it above:
For your first roll there are 6 possible answers, and 6 acceptable answers (as any number 1-6 is acceptable).
6/6
For the second roll there are 6
|
Two dice rolls - same number in sequence
Since I didn't see this exact way of framing it above:
For your first roll there are 6 possible answers, and 6 acceptable answers (as any number 1-6 is acceptable).
6/6
For the second roll there are 6 possible answers, but now only 1 will match the first roll.
1/6
6/6 * 1/6 = 1/6
|
Two dice rolls - same number in sequence
Since I didn't see this exact way of framing it above:
For your first roll there are 6 possible answers, and 6 acceptable answers (as any number 1-6 is acceptable).
6/6
For the second roll there are 6
|
8,713
|
Two dice rolls - same number in sequence
|
I guess you are confused because it did not mention an exact number. If the question said something like rolling a die twice and getting a 1 twice then you are correct but since it did not say so, the same is true for getting a 1,2 3 or any other number. Thus since there are 6 numbers that can turn up that way, it will be 6/36 which will give you 1/6.
|
Two dice rolls - same number in sequence
|
I guess you are confused because it did not mention an exact number. If the question said something like rolling a die twice and getting a 1 twice then you are correct but since it did not say so, the
|
Two dice rolls - same number in sequence
I guess you are confused because it did not mention an exact number. If the question said something like rolling a die twice and getting a 1 twice then you are correct but since it did not say so, the same is true for getting a 1,2 3 or any other number. Thus since there are 6 numbers that can turn up that way, it will be 6/36 which will give you 1/6.
|
Two dice rolls - same number in sequence
I guess you are confused because it did not mention an exact number. If the question said something like rolling a die twice and getting a 1 twice then you are correct but since it did not say so, the
|
8,714
|
How can I prove mathematically that the mean of a distribution is the measure that minimizes the variance?
|
Budding statisticians in Statistics 101 with no mathematical skills beyond high-school algebra should consider
\begin{align}
E\left[(X-a)^2\right] &= E\bigr[\big(X-\mu + \mu -a\big)^2\bigr] & {\scriptstyle{\text{Here,}~\mu ~ \text{denotes the mean of} ~ X}}\\
&= E\bigr[\big((X-\mu) + (\mu -a)\big)^2\bigr]\\
&= E\bigr[(X-\mu)^2 + (\mu -a)^2 &{\scriptstyle{(\alpha+\beta)^2 = \alpha^2+\beta^2 + 2\beta\alpha}}\\
& ~~~~~~~~~~~~~~+ 2(\mu-a)(X-\mu)\bigr]\\
&= E\big[(X-\mu)^2\big] + E\big[(\mu -a)^2\big]
&{\scriptstyle{\text{Expectation of sum is the sum of}}}\\
& ~~~~~~~~~+ 2(\mu-a)E\big[X-\mu\big] &{\scriptstyle{\text{the expectations, and constants}}}\\
& &{\scriptstyle{\text{can be pulled out ofexpectations}}}\\
&= \operatorname{var}(X) + (\mu -a)^2 + 2(\mu-a)\times 0
&{\scriptstyle{\text{definition of variance; expectation}}}\\
& &{\scriptstyle{\text{of a constant equals the constant;}}}\\
& &{\scriptstyle{E[X-\mu] = E[X] -E[\mu] = \mu -\mu = 0}}\\
&= \operatorname{var}(X) + (\mu -a)^2\\
&\geq \operatorname{var}(X) &{\scriptstyle{\text{with equality holding when}~ a=\mu.}}
\end{align}
Thus, we have shown that $E\left[(X-a)^2\right] \geq \operatorname{var}(X)$ with equality holding when $a = \mu$.
Look, Ma! No calculus! No derivatives or second derivative tests! Not even geometry and invocations of Pythogoras; just high-school algebra (even pre-algebra might have sufficed), together with a just a smidgen of Stats 101.
|
How can I prove mathematically that the mean of a distribution is the measure that minimizes the var
|
Budding statisticians in Statistics 101 with no mathematical skills beyond high-school algebra should consider
\begin{align}
E\left[(X-a)^2\right] &= E\bigr[\big(X-\mu + \mu -a\big)^2\bigr] & {\script
|
How can I prove mathematically that the mean of a distribution is the measure that minimizes the variance?
Budding statisticians in Statistics 101 with no mathematical skills beyond high-school algebra should consider
\begin{align}
E\left[(X-a)^2\right] &= E\bigr[\big(X-\mu + \mu -a\big)^2\bigr] & {\scriptstyle{\text{Here,}~\mu ~ \text{denotes the mean of} ~ X}}\\
&= E\bigr[\big((X-\mu) + (\mu -a)\big)^2\bigr]\\
&= E\bigr[(X-\mu)^2 + (\mu -a)^2 &{\scriptstyle{(\alpha+\beta)^2 = \alpha^2+\beta^2 + 2\beta\alpha}}\\
& ~~~~~~~~~~~~~~+ 2(\mu-a)(X-\mu)\bigr]\\
&= E\big[(X-\mu)^2\big] + E\big[(\mu -a)^2\big]
&{\scriptstyle{\text{Expectation of sum is the sum of}}}\\
& ~~~~~~~~~+ 2(\mu-a)E\big[X-\mu\big] &{\scriptstyle{\text{the expectations, and constants}}}\\
& &{\scriptstyle{\text{can be pulled out ofexpectations}}}\\
&= \operatorname{var}(X) + (\mu -a)^2 + 2(\mu-a)\times 0
&{\scriptstyle{\text{definition of variance; expectation}}}\\
& &{\scriptstyle{\text{of a constant equals the constant;}}}\\
& &{\scriptstyle{E[X-\mu] = E[X] -E[\mu] = \mu -\mu = 0}}\\
&= \operatorname{var}(X) + (\mu -a)^2\\
&\geq \operatorname{var}(X) &{\scriptstyle{\text{with equality holding when}~ a=\mu.}}
\end{align}
Thus, we have shown that $E\left[(X-a)^2\right] \geq \operatorname{var}(X)$ with equality holding when $a = \mu$.
Look, Ma! No calculus! No derivatives or second derivative tests! Not even geometry and invocations of Pythogoras; just high-school algebra (even pre-algebra might have sufficed), together with a just a smidgen of Stats 101.
|
How can I prove mathematically that the mean of a distribution is the measure that minimizes the var
Budding statisticians in Statistics 101 with no mathematical skills beyond high-school algebra should consider
\begin{align}
E\left[(X-a)^2\right] &= E\bigr[\big(X-\mu + \mu -a\big)^2\bigr] & {\script
|
8,715
|
How can I prove mathematically that the mean of a distribution is the measure that minimizes the variance?
|
The expression is $\mathbb E[(X-a)^2]$. We'll differentiate and equate the expression to $0$:
$$\begin{align}\frac{d}{da}\mathbb E[(X-a)^2]&=\mathbb E\left[\frac{d}{da}(X-a)^2\right]\\&=\mathbb E[-2(X-a)]\\&=0\end{align}$$
Then, $\mathbb E[-2X +2a]=0\rightarrow \mathbb E[2X]=\mathbb E[2a]=2a\rightarrow a=\mathbb E[X]$. The second derivative is positive, so it's the minimizer.
|
How can I prove mathematically that the mean of a distribution is the measure that minimizes the var
|
The expression is $\mathbb E[(X-a)^2]$. We'll differentiate and equate the expression to $0$:
$$\begin{align}\frac{d}{da}\mathbb E[(X-a)^2]&=\mathbb E\left[\frac{d}{da}(X-a)^2\right]\\&=\mathbb E[-2(X
|
How can I prove mathematically that the mean of a distribution is the measure that minimizes the variance?
The expression is $\mathbb E[(X-a)^2]$. We'll differentiate and equate the expression to $0$:
$$\begin{align}\frac{d}{da}\mathbb E[(X-a)^2]&=\mathbb E\left[\frac{d}{da}(X-a)^2\right]\\&=\mathbb E[-2(X-a)]\\&=0\end{align}$$
Then, $\mathbb E[-2X +2a]=0\rightarrow \mathbb E[2X]=\mathbb E[2a]=2a\rightarrow a=\mathbb E[X]$. The second derivative is positive, so it's the minimizer.
|
How can I prove mathematically that the mean of a distribution is the measure that minimizes the var
The expression is $\mathbb E[(X-a)^2]$. We'll differentiate and equate the expression to $0$:
$$\begin{align}\frac{d}{da}\mathbb E[(X-a)^2]&=\mathbb E\left[\frac{d}{da}(X-a)^2\right]\\&=\mathbb E[-2(X
|
8,716
|
How can I prove mathematically that the mean of a distribution is the measure that minimizes the variance?
|
Assuming that you have $n$ values $\{x_1, x_2, \ldots, x_n\}$, the mean squared difference from each value $x_i$ to some number $a$ is:
$$
m(a)=\frac{1}{n}\sum_{i=1}^{n}(x_i-a)^2
$$
We could ignore the term $\frac{1}{n}$ but I'm leaving it in. Expand the square and manipulate:
$$
m(a)=\frac{1}{n}\left(\sum_{i=1}^{n}x_{i}^{2}-2ax_i+a^2\right)=\frac{1}{n}\left(\sum_{i=1}^{n}x_{i}^{2}-\sum_{i=1}^{n}2ax_i+\sum_{i=1}^{n}a^2\right)=\frac{1}{n}\left(\sum_{i=1}^{n}x_{i}^{2}-2a\sum_{i=1}^{n}x_i+na^2\right)
$$
To find the value of $a$ that minimizes the expression, differentiate with respect to $a$ to get:
$$
m'(a)=\frac{1}{n}\left(2na - 2\sum_{i=1}^{n}x_i\right)
$$
Now set this to zero an solve for $a$ to get:
$$
a=\frac{\sum_{i=1}^{n}x_i}{n}
$$
which is the mean of the values $x_i$. To show that this is indeed the minimum, calculate the second dervative wrt to $a$, which is $m''(a)=2>0$ so it's a minimum.
|
How can I prove mathematically that the mean of a distribution is the measure that minimizes the var
|
Assuming that you have $n$ values $\{x_1, x_2, \ldots, x_n\}$, the mean squared difference from each value $x_i$ to some number $a$ is:
$$
m(a)=\frac{1}{n}\sum_{i=1}^{n}(x_i-a)^2
$$
We could ignore th
|
How can I prove mathematically that the mean of a distribution is the measure that minimizes the variance?
Assuming that you have $n$ values $\{x_1, x_2, \ldots, x_n\}$, the mean squared difference from each value $x_i$ to some number $a$ is:
$$
m(a)=\frac{1}{n}\sum_{i=1}^{n}(x_i-a)^2
$$
We could ignore the term $\frac{1}{n}$ but I'm leaving it in. Expand the square and manipulate:
$$
m(a)=\frac{1}{n}\left(\sum_{i=1}^{n}x_{i}^{2}-2ax_i+a^2\right)=\frac{1}{n}\left(\sum_{i=1}^{n}x_{i}^{2}-\sum_{i=1}^{n}2ax_i+\sum_{i=1}^{n}a^2\right)=\frac{1}{n}\left(\sum_{i=1}^{n}x_{i}^{2}-2a\sum_{i=1}^{n}x_i+na^2\right)
$$
To find the value of $a$ that minimizes the expression, differentiate with respect to $a$ to get:
$$
m'(a)=\frac{1}{n}\left(2na - 2\sum_{i=1}^{n}x_i\right)
$$
Now set this to zero an solve for $a$ to get:
$$
a=\frac{\sum_{i=1}^{n}x_i}{n}
$$
which is the mean of the values $x_i$. To show that this is indeed the minimum, calculate the second dervative wrt to $a$, which is $m''(a)=2>0$ so it's a minimum.
|
How can I prove mathematically that the mean of a distribution is the measure that minimizes the var
Assuming that you have $n$ values $\{x_1, x_2, \ldots, x_n\}$, the mean squared difference from each value $x_i$ to some number $a$ is:
$$
m(a)=\frac{1}{n}\sum_{i=1}^{n}(x_i-a)^2
$$
We could ignore th
|
8,717
|
How can I prove mathematically that the mean of a distribution is the measure that minimizes the variance?
|
A quick one:
This follows from a property of moments (a rule to transform the center)
$$E\left[(x-\hat{x})^n\right] = \sum_{i=0}^n {n \choose i} E\left[(x-a)^i\right] (a-\hat{x})^{n-i}$$
which becomes for $n=2$ and $a=\mu=E[X]$
$$E \left[(x-\hat{x})^2\right] = \underbrace{E \left[(x-\mu)^2\right] }_{=\text{Var}(x)} + 2 \underbrace{E \left[(x-\mu)\right] }_{=0} (\mu-\hat{x}) + (\mu-\hat{x})^2 = \text{Var}(x) + (\mu-\hat{x})^2 $$
and this is minimised when $\hat{x}=\mu$.
A longer one:
It goes similar using the expression $∫dx p(x)(x−M)^2$
$$\begin{array}{}
∫dx p(x)(x−M)^2 &=& ∫dx p(x)\underbrace{((x-\mu)+(\mu-M))^2}_{=(x-\mu)^2 + 2(x-\mu)(\mu-M) + (\mu-M)^2} \\
& =& ∫dx p(x)(x-\mu)^2 + ∫dx p(x)2(x-\mu)(\mu-M) +∫dx p(x) (\mu-M)^2 \\
& =& ∫dx p(x)(x-\mu)^2 + ∫dx p(x)2 x(\mu-M) - ∫dx p(x)2\mu(\mu-M)+∫dx p(x) (\mu-M)^2 \\
& =& \underbrace{∫dx p(x)(x-\mu)^2}_{=\text{var}(x)} + 2 (\mu-M)\underbrace{∫dx p(x)x}_{=\mu} - 2 (\mu-M)\mu \underbrace{∫dx p(x)}_{=1}+(\mu-M)^2 \underbrace{∫dx p(x)}_{=1} \\
&=& \text{var}(x) +(\mu-M)^2
\end{array}$$
Intuitively:
In other words, the variance is the 2nd moment about the mean and a 2nd moment about some other point will be larger.
In order to find the optimum you could differentiate the integral and set equal to zero then you get
$$\frac{\partial}{\partial M} ∫dx p(x)(x−M)^2 =2 ∫dx p(x)(x−M) = 2(\mu-M) =0 $$
Which results in $M=\mu$.
In words: if you shift the point $M$ then the contributions of the $(x-M)^2$ term change and become less or more, and this is more when the distance $x-M$ is larger. When $M$ is equal to the mean $\mu$ the increase and decrease (the sum/mean of $x-M$) balance each other and you reach the minimum.
Something similar can be done to minimize the integral $∫dx p(x)|x−M|$ and you will find that this is minimised when $M$ is equal to the median.
|
How can I prove mathematically that the mean of a distribution is the measure that minimizes the var
|
A quick one:
This follows from a property of moments (a rule to transform the center)
$$E\left[(x-\hat{x})^n\right] = \sum_{i=0}^n {n \choose i} E\left[(x-a)^i\right] (a-\hat{x})^{n-i}$$
which become
|
How can I prove mathematically that the mean of a distribution is the measure that minimizes the variance?
A quick one:
This follows from a property of moments (a rule to transform the center)
$$E\left[(x-\hat{x})^n\right] = \sum_{i=0}^n {n \choose i} E\left[(x-a)^i\right] (a-\hat{x})^{n-i}$$
which becomes for $n=2$ and $a=\mu=E[X]$
$$E \left[(x-\hat{x})^2\right] = \underbrace{E \left[(x-\mu)^2\right] }_{=\text{Var}(x)} + 2 \underbrace{E \left[(x-\mu)\right] }_{=0} (\mu-\hat{x}) + (\mu-\hat{x})^2 = \text{Var}(x) + (\mu-\hat{x})^2 $$
and this is minimised when $\hat{x}=\mu$.
A longer one:
It goes similar using the expression $∫dx p(x)(x−M)^2$
$$\begin{array}{}
∫dx p(x)(x−M)^2 &=& ∫dx p(x)\underbrace{((x-\mu)+(\mu-M))^2}_{=(x-\mu)^2 + 2(x-\mu)(\mu-M) + (\mu-M)^2} \\
& =& ∫dx p(x)(x-\mu)^2 + ∫dx p(x)2(x-\mu)(\mu-M) +∫dx p(x) (\mu-M)^2 \\
& =& ∫dx p(x)(x-\mu)^2 + ∫dx p(x)2 x(\mu-M) - ∫dx p(x)2\mu(\mu-M)+∫dx p(x) (\mu-M)^2 \\
& =& \underbrace{∫dx p(x)(x-\mu)^2}_{=\text{var}(x)} + 2 (\mu-M)\underbrace{∫dx p(x)x}_{=\mu} - 2 (\mu-M)\mu \underbrace{∫dx p(x)}_{=1}+(\mu-M)^2 \underbrace{∫dx p(x)}_{=1} \\
&=& \text{var}(x) +(\mu-M)^2
\end{array}$$
Intuitively:
In other words, the variance is the 2nd moment about the mean and a 2nd moment about some other point will be larger.
In order to find the optimum you could differentiate the integral and set equal to zero then you get
$$\frac{\partial}{\partial M} ∫dx p(x)(x−M)^2 =2 ∫dx p(x)(x−M) = 2(\mu-M) =0 $$
Which results in $M=\mu$.
In words: if you shift the point $M$ then the contributions of the $(x-M)^2$ term change and become less or more, and this is more when the distance $x-M$ is larger. When $M$ is equal to the mean $\mu$ the increase and decrease (the sum/mean of $x-M$) balance each other and you reach the minimum.
Something similar can be done to minimize the integral $∫dx p(x)|x−M|$ and you will find that this is minimised when $M$ is equal to the median.
|
How can I prove mathematically that the mean of a distribution is the measure that minimizes the var
A quick one:
This follows from a property of moments (a rule to transform the center)
$$E\left[(x-\hat{x})^n\right] = \sum_{i=0}^n {n \choose i} E\left[(x-a)^i\right] (a-\hat{x})^{n-i}$$
which become
|
8,718
|
How can I prove mathematically that the mean of a distribution is the measure that minimizes the variance?
|
Just work it out.
$$\frac{\partial}{\partial c}E[(X-c)^2]=E\left[ \frac{\partial}{\partial c}(X-c)^2 \right]=2E\left[ X-c \right]$$
Setting this to zero, $E[X]=c$ is the only stationary point and it's obviously not a maximum.
.
(there's an invocation of the dominated convergence theorem or near offer in there to justify putting the derivative through the integral, which might fail if the variance doesn't exist or something pathological like that)
|
How can I prove mathematically that the mean of a distribution is the measure that minimizes the var
|
Just work it out.
$$\frac{\partial}{\partial c}E[(X-c)^2]=E\left[ \frac{\partial}{\partial c}(X-c)^2 \right]=2E\left[ X-c \right]$$
Setting this to zero, $E[X]=c$ is the only stationary point and it's
|
How can I prove mathematically that the mean of a distribution is the measure that minimizes the variance?
Just work it out.
$$\frac{\partial}{\partial c}E[(X-c)^2]=E\left[ \frac{\partial}{\partial c}(X-c)^2 \right]=2E\left[ X-c \right]$$
Setting this to zero, $E[X]=c$ is the only stationary point and it's obviously not a maximum.
.
(there's an invocation of the dominated convergence theorem or near offer in there to justify putting the derivative through the integral, which might fail if the variance doesn't exist or something pathological like that)
|
How can I prove mathematically that the mean of a distribution is the measure that minimizes the var
Just work it out.
$$\frac{\partial}{\partial c}E[(X-c)^2]=E\left[ \frac{\partial}{\partial c}(X-c)^2 \right]=2E\left[ X-c \right]$$
Setting this to zero, $E[X]=c$ is the only stationary point and it's
|
8,719
|
How can I prove mathematically that the mean of a distribution is the measure that minimizes the variance?
|
I have another geometric perspective which my college suggested me. In essence "the value $M$" that you are looking for is a factor such that $M\cdot\mathbb{1}$ is a projection of $X$ onto subspace generated by $\mathbb{1}$ in $L^2(\Omega, A, P)$ space where $\mathbb{1}$ is a constant random variable equal 1 almost everywhere.
Recall that if we have an $\mathbb{R}^n$ space with an inner product $\langle\cdot,\cdot\rangle$ and we want to project vector $p$ on subspace generated by vector $x$ then the projected vector is given by formula
$$v=\frac{\langle p,x\rangle}{||x||^2}x$$
and $v$ it is a unique vector of form $Mx$ which minimizes $||p-Mx||^2.$
Instead of regular $\mathbb{R}^n$ consider space $L^2(\Omega, A, P)$ (space of random variables $X:\Omega\to\mathbb{R}$ such that $\operatorname{E}[X^2]<\infty$) with an inner product given by formula
$$\langle X_1,X_2\rangle = \operatorname{E}[X_1\cdot X_2]=\int_\Omega X_1(x)X_2(x)dP(x).$$
If we fix an arbitrary random variable $X$ from $L^2(\Omega, A, P)$ and we want to project it onto subspace generated by random variable $\mathbb{1}$, then it is the same of finding $M$ such that it minimizes
$$ \operatorname{E}[(X-M\cdot\mathbb{1})^2].$$
Using the same argument as in the $\mathbb{R}^n$, we get that $M=\frac{\langle X,\mathbb{1}\rangle}{||\mathbb{1}||^2}=\operatorname{E}[X]$.
|
How can I prove mathematically that the mean of a distribution is the measure that minimizes the var
|
I have another geometric perspective which my college suggested me. In essence "the value $M$" that you are looking for is a factor such that $M\cdot\mathbb{1}$ is a projection of $X$ onto subspace ge
|
How can I prove mathematically that the mean of a distribution is the measure that minimizes the variance?
I have another geometric perspective which my college suggested me. In essence "the value $M$" that you are looking for is a factor such that $M\cdot\mathbb{1}$ is a projection of $X$ onto subspace generated by $\mathbb{1}$ in $L^2(\Omega, A, P)$ space where $\mathbb{1}$ is a constant random variable equal 1 almost everywhere.
Recall that if we have an $\mathbb{R}^n$ space with an inner product $\langle\cdot,\cdot\rangle$ and we want to project vector $p$ on subspace generated by vector $x$ then the projected vector is given by formula
$$v=\frac{\langle p,x\rangle}{||x||^2}x$$
and $v$ it is a unique vector of form $Mx$ which minimizes $||p-Mx||^2.$
Instead of regular $\mathbb{R}^n$ consider space $L^2(\Omega, A, P)$ (space of random variables $X:\Omega\to\mathbb{R}$ such that $\operatorname{E}[X^2]<\infty$) with an inner product given by formula
$$\langle X_1,X_2\rangle = \operatorname{E}[X_1\cdot X_2]=\int_\Omega X_1(x)X_2(x)dP(x).$$
If we fix an arbitrary random variable $X$ from $L^2(\Omega, A, P)$ and we want to project it onto subspace generated by random variable $\mathbb{1}$, then it is the same of finding $M$ such that it minimizes
$$ \operatorname{E}[(X-M\cdot\mathbb{1})^2].$$
Using the same argument as in the $\mathbb{R}^n$, we get that $M=\frac{\langle X,\mathbb{1}\rangle}{||\mathbb{1}||^2}=\operatorname{E}[X]$.
|
How can I prove mathematically that the mean of a distribution is the measure that minimizes the var
I have another geometric perspective which my college suggested me. In essence "the value $M$" that you are looking for is a factor such that $M\cdot\mathbb{1}$ is a projection of $X$ onto subspace ge
|
8,720
|
Does mean=mode imply a symmetric distribution?
|
Mean = mode doesn't imply symmetry.
Even if mean = median = mode you still don't necessarily have symmetry.
And in anticipation of the potential followup -- even if mean=median=mode and the third central moment is zero (so moment-skewness is 0), you still don't necessarily have symmetry.
... but there was a followup to that one. NickT asked in comments if having all odd moments zero was enough to require symmetry. The answer to that is also no. [See the discussion at the end.$^\dagger$]
Those various things are all implied by symmetry (assuming the relevant moments are finite) but the implication doesn't go the other way - in spite of many an elementary text clearly saying otherwise about one or more of them.
Counterexamples are pretty trivial to construct.
Consider the following discrete distribution:
x -4 0 1 5
P(X=x) 0.2 0.4 0.3 0.1
It has mean, median, mode and third central moment (and hence moment-skewness) all 0 but it is asymmetric.
This sort of example can be done with a purely continuous distribution as well. For example, here's a density with the same properties:
This is a mixture of symmetric triangular densities (each with range 2) with means at
-6, -4, -3, -1, 0, 1, 2, 5 and mixture weights 0.08, 0.08, 0.12, 0.08, 0.28, 0.08, 0.08, 0.20 respectively. The fact that I just made this now -- having never seen it before -- suggests how simple these cases are to construct.
[I chose triangular mixture components in order that the mode would be visually unambiguous -- a smoother distribution could have been used.]
Here's an additional discrete example to address Hong Ooi's questions about how far from symmetry these conditions allow you to get. This is by no means a limiting case, it's just illustrating that it's simple to make a less symmetric looking example:
x -2 0 1 6
P(X=x) 0.175 0.5 0.32 0.005
The spike at 0 can be made relatively higher or lower without changing the conditions; similarly the point out to the right can be placed further away (with a reduction in probability) without changing the relative heights at 1 and -2 by much (i.e. their relative probability will stay close to the 2:1 ratio as you move the rightmost element about).
More detail on the response to NickT's question
$\dagger$ The all-odd-moments zero case is addressed in a number of questions on site. There's an example here (see the plot) based on the details here (see toward the end of the answer). That is a continuous unimodal asymmetric density with all odd moments 0 and mean=median=mode. The median is 0 by the 50-50 mixture construction, the mode is 0 by inspection -- all members of the family on the real half-line from which the example is constructed have a density that's monotonic decreasing from a finite value at the origin, and the mean is zero because all odd moments are 0.
|
Does mean=mode imply a symmetric distribution?
|
Mean = mode doesn't imply symmetry.
Even if mean = median = mode you still don't necessarily have symmetry.
And in anticipation of the potential followup -- even if mean=median=mode and the third cen
|
Does mean=mode imply a symmetric distribution?
Mean = mode doesn't imply symmetry.
Even if mean = median = mode you still don't necessarily have symmetry.
And in anticipation of the potential followup -- even if mean=median=mode and the third central moment is zero (so moment-skewness is 0), you still don't necessarily have symmetry.
... but there was a followup to that one. NickT asked in comments if having all odd moments zero was enough to require symmetry. The answer to that is also no. [See the discussion at the end.$^\dagger$]
Those various things are all implied by symmetry (assuming the relevant moments are finite) but the implication doesn't go the other way - in spite of many an elementary text clearly saying otherwise about one or more of them.
Counterexamples are pretty trivial to construct.
Consider the following discrete distribution:
x -4 0 1 5
P(X=x) 0.2 0.4 0.3 0.1
It has mean, median, mode and third central moment (and hence moment-skewness) all 0 but it is asymmetric.
This sort of example can be done with a purely continuous distribution as well. For example, here's a density with the same properties:
This is a mixture of symmetric triangular densities (each with range 2) with means at
-6, -4, -3, -1, 0, 1, 2, 5 and mixture weights 0.08, 0.08, 0.12, 0.08, 0.28, 0.08, 0.08, 0.20 respectively. The fact that I just made this now -- having never seen it before -- suggests how simple these cases are to construct.
[I chose triangular mixture components in order that the mode would be visually unambiguous -- a smoother distribution could have been used.]
Here's an additional discrete example to address Hong Ooi's questions about how far from symmetry these conditions allow you to get. This is by no means a limiting case, it's just illustrating that it's simple to make a less symmetric looking example:
x -2 0 1 6
P(X=x) 0.175 0.5 0.32 0.005
The spike at 0 can be made relatively higher or lower without changing the conditions; similarly the point out to the right can be placed further away (with a reduction in probability) without changing the relative heights at 1 and -2 by much (i.e. their relative probability will stay close to the 2:1 ratio as you move the rightmost element about).
More detail on the response to NickT's question
$\dagger$ The all-odd-moments zero case is addressed in a number of questions on site. There's an example here (see the plot) based on the details here (see toward the end of the answer). That is a continuous unimodal asymmetric density with all odd moments 0 and mean=median=mode. The median is 0 by the 50-50 mixture construction, the mode is 0 by inspection -- all members of the family on the real half-line from which the example is constructed have a density that's monotonic decreasing from a finite value at the origin, and the mean is zero because all odd moments are 0.
|
Does mean=mode imply a symmetric distribution?
Mean = mode doesn't imply symmetry.
Even if mean = median = mode you still don't necessarily have symmetry.
And in anticipation of the potential followup -- even if mean=median=mode and the third cen
|
8,721
|
Does mean=mode imply a symmetric distribution?
|
Try this set of numbers:
\begin{align}
X &= \{2,3,5,5,10\} \\[10pt]
{\rm mean}(X) &= 5 \\
{\rm median}(X) &= 5 \\
{\rm mode}(X) &= 5
\end{align}
I wouldn't call that distribution symmetrical.
|
Does mean=mode imply a symmetric distribution?
|
Try this set of numbers:
\begin{align}
X &= \{2,3,5,5,10\} \\[10pt]
{\rm mean}(X) &= 5 \\
{\rm median}(X) &= 5 \\
{\rm mode}(X) &= 5
\end{align}
I wouldn't call that distribution symmetrical.
|
Does mean=mode imply a symmetric distribution?
Try this set of numbers:
\begin{align}
X &= \{2,3,5,5,10\} \\[10pt]
{\rm mean}(X) &= 5 \\
{\rm median}(X) &= 5 \\
{\rm mode}(X) &= 5
\end{align}
I wouldn't call that distribution symmetrical.
|
Does mean=mode imply a symmetric distribution?
Try this set of numbers:
\begin{align}
X &= \{2,3,5,5,10\} \\[10pt]
{\rm mean}(X) &= 5 \\
{\rm median}(X) &= 5 \\
{\rm mode}(X) &= 5
\end{align}
I wouldn't call that distribution symmetrical.
|
8,722
|
Does mean=mode imply a symmetric distribution?
|
No.
Let $X$ be a discrete random variable with $p(X = -2) = \tfrac{1}{6}$, $p(X = 0) = \tfrac{1}{2}$, and $p(X = 1) = \tfrac{1}{3}$. Obviously, $X$ is not symmetric, but its mean and mode are both 0.
|
Does mean=mode imply a symmetric distribution?
|
No.
Let $X$ be a discrete random variable with $p(X = -2) = \tfrac{1}{6}$, $p(X = 0) = \tfrac{1}{2}$, and $p(X = 1) = \tfrac{1}{3}$. Obviously, $X$ is not symmetric, but its mean and mode are both 0.
|
Does mean=mode imply a symmetric distribution?
No.
Let $X$ be a discrete random variable with $p(X = -2) = \tfrac{1}{6}$, $p(X = 0) = \tfrac{1}{2}$, and $p(X = 1) = \tfrac{1}{3}$. Obviously, $X$ is not symmetric, but its mean and mode are both 0.
|
Does mean=mode imply a symmetric distribution?
No.
Let $X$ be a discrete random variable with $p(X = -2) = \tfrac{1}{6}$, $p(X = 0) = \tfrac{1}{2}$, and $p(X = 1) = \tfrac{1}{3}$. Obviously, $X$ is not symmetric, but its mean and mode are both 0.
|
8,723
|
Does mean=mode imply a symmetric distribution?
|
To repeat an answer I gave elsewhere, but fits here too:
$$\mathbb{P}(X=n) = \left\{
\begin{array}{ll}
0.03 & n=-3 \\
0.04 & n=-2 \\
0.25 & n=-1 \\
0.40 & n=0 \\
0.15 & n=1 \\
0.12 & n=2 \\
0.01 & n=3
\end{array}
\right.$$
which not only has mean, median and mode all equal, but also has zero skewness. Many other versions are possible.
|
Does mean=mode imply a symmetric distribution?
|
To repeat an answer I gave elsewhere, but fits here too:
$$\mathbb{P}(X=n) = \left\{
\begin{array}{ll}
0.03 & n=-3 \\
0.04 & n=-2 \\
0.25 & n=-1 \\
0.40 & n=0 \\
|
Does mean=mode imply a symmetric distribution?
To repeat an answer I gave elsewhere, but fits here too:
$$\mathbb{P}(X=n) = \left\{
\begin{array}{ll}
0.03 & n=-3 \\
0.04 & n=-2 \\
0.25 & n=-1 \\
0.40 & n=0 \\
0.15 & n=1 \\
0.12 & n=2 \\
0.01 & n=3
\end{array}
\right.$$
which not only has mean, median and mode all equal, but also has zero skewness. Many other versions are possible.
|
Does mean=mode imply a symmetric distribution?
To repeat an answer I gave elsewhere, but fits here too:
$$\mathbb{P}(X=n) = \left\{
\begin{array}{ll}
0.03 & n=-3 \\
0.04 & n=-2 \\
0.25 & n=-1 \\
0.40 & n=0 \\
|
8,724
|
Visualising many variables in one plot
|
Fortuitously or otherwise, your example is of optimal size (up to 7 values for each of 15
groups) first, to show that there is a problem graphically; and second, to allow other and
fairly simple solutions. The graph is of a kind often called spaghetti by people in
different fields, although it's not always clear whether that term is meant as affectionate
or abusive. (The term spaghetti was used by Gene Zelazny in 1985, but may well be much older
yet.) The graph does show the collective or family behaviour of all the groups, but it is
fairly hopeless at showing the detail to be explored.
One standard alternative is just to show the separate groups in separate panels, but that in
turn can make precise group-to-group comparisons difficult; each group is separated from its
context of the other groups.
So why not combine both ideas: a separate panel for each group, but also show the other
groups as backdrop? This hinges crucially on highlighting the group which is in focus and on
downplaying the others, which is easy enough in this example given some use of line colour,
thickness etc. In other examples, marker or point symbol choices might be natural instead.
In this case, details of possible practical or scientific importance or interest are
highlighted:
We only have one value for A and M.
We don't have all values for all given years in all other cases.
Some groups plot high, some low, and so forth.
I won't attempt an interpretation here: the data are anonymous, but that is the researcher's
concern in any case.
Depending on what is easy or possible in your software, there is scope for changing small
details here, such as whether axis labels and titles are repeated (there are simple
arguments both for and against).
The larger issue is how far this strategy will work more generally. The number of groups is
the major driver, more so than the number of points in each group. Roughly speaking, the
approach might work up to about 25 groups (a 5 x 5 display, say): with more groups, not only
do the graphs become smaller and more difficult to read, but even the researcher loses the
inclination to scan all the panels. If there were hundreds (thousands, ...) of groups, it
would usually be essential to select a small number of groups to show. Some mix of criteria
such as selecting some "typical" and some "extreme" panels would be needed; that should be
driven by project goals and some idea of what makes sense for each dataset. Another approach
that can be efficient is to emphasize a small number of series in each panel. So, if there
were 25 broad groups, each broad group could be shown with all others as backdrop.
Alternatively, there could be some averaging or other summarization. Using (e.g.) principal
or independent components might also be a good idea.
Although the example calls for line plots, the principle is naturally much general. Examples
could be multiplied, scatter plots, model diagnostic plots, etc.
Similar but not identical ideas
Cleveland (1985, pp.74, 203, 205, 268) shows graphs in which summary curves
for groups are repeated with data shown separately for each group.
(Note: these graphs do not appear in Cleveland 1994.)
Wallgren et al. (1996, pp.47, 69) use the same idea.
Cleveland, W.S. 1985. Elements of Graphing Data. Monterey, CA: Wadsworth.
Cleveland, W.S. 1994. Elements of Graphing Data. Summit, NJ: Hobart Press.
Wallgren, A., B. Wallgren, R. Persson, U. Jorner, and J.-A. Haaland.
1996. Graphing Statistics and Data: Creating Better Charts. Newbury
Park, CA: SAGE.
Zelazny (1985 and later editions) has a different twist:
Zelazny, G. 1985. Say It With Charts: The Executive's Guide to Successful Presentations.
Homewood, IL: Dow Jones-Irwin. See p.39 for a graph with four panels: series A compared in
turn with series B, C, D, E. See also p.111.
Same pages in 4th edition: Zelazny, G. 2001. Say It With Charts: The Executive's Guide to
Visual Communication. New York: McGraw-Hill. See p.39 for a graph with four panels: series
A compared in turn with series B, C, D, E. See also p.111.
Direct examples [others are most welcome]
Koenker, R. 2005. Quantile Regression. Cambridge: Cambridge University
Press. See pp.12-13.
Carr, D.B. and Pickle, L.W. 2010. Visualizing Data Patterns with Micromaps. Boca Raton,
FL: CRC Press. See p.85.
Cox, N.J. 2010. Graphing subsets. Stata Journal 10: 670-681.
Yau, N. 2013. Data Points: Visualization That Means Something.
Indianapolis, IN: John Wiley. See p.224.
Rougier, N.P., Droettboom, M. and Bourne, P.E. 2014.
Ten simple rules for better figures.
PLOS Computational Biology 10(9): e1003833.
doi:10.1371/journal.pcbi.1003833
link here
Schwabish, J.A. 2014. An economist's guide to visualizing data. Journal
of Economic Perspectives 28: 209-234.
Knaflic, C.N. 2015. Storytelling with Data: A Data Visualization Guide
for Business Professionals. Hoboken, NJ: Wiley. See p.233.
Unwin, A. 2015. Graphical Data Analysis with R. Boca Raton, FL: CRC
Press. See pp.121, 217.
Berinato, S. 2016.
Good Charts: The HBR Guide to Making Smarter, More Persuasive Data Visualizations.
Boston, MA: Harvard Business Review Press. See p.74.
Cairo, A. 2016.
The Truthful Art: Data, Charts, and Maps for Communication.
San Francisco, CA: New Riders. See p.211
Camões, J. 2016. Data at Work: Best Practices for Creating Effective Charts
and Information Graphics in Microsoft Excel. San Francisco, CA: New
Riders. See p.354.
Standage, T. 2016. Go Figure: The Economist Explains: Things You Didn't Know You Didn't Know. London: Profile Books. See p.177.
Wickham, H. 2016. ggplot2: Elegant Graphics for Data Analysis. Cham: Springer.
See p.157.
Schwabish, J. 2017. Better Presentations: A Guide for Scholars, Researchers, and Wonks. New York: Columbia University Press. See p.98.
Kriebel, A. and Murray, E. 2018. #MakeoverMonday: Improving How We Visualize and Analyze
Data, One Chart at a Time. Hoboken, NJ: John Wiley. See p.303.
Grant, R. 2019. Data Visualization: Charts, Maps, and Interactive Graphics.
Boca Raton, FL: CRC Press. See p.52.
Koponen, J. and Hildén, J. 2019.
The Data Visualization Handbook.
Espoo: Aalto ARTS Books. See p.101.
Tufte, E.R. 2020. Seeing with Fresh Eyes: Meaning, Space, Data, Truth.
Cheshire, CT: Graphics Press. See p.26 [original work by John Burn-Murdoch, but showing 0 on logarithmic scale (!) and alphabetical order by countries, which could be tuned]
Note: The graph was created in Stata. subsetplot must be installed first with ssc inst subsetplot. Data were copied and pasted from R and value labels were defined to show years as 90 95 00 05 10 15. The main command is
subsetplot connected Val Year, by(Var) c(L) lcolor(gs12) backdrop(line) xtitle("") combine(imargin(small)) subset(lcolor(blue) mcolor(blue))
|
Visualising many variables in one plot
|
Fortuitously or otherwise, your example is of optimal size (up to 7 values for each of 15
groups) first, to show that there is a problem graphically; and second, to allow other and
fairly simple solut
|
Visualising many variables in one plot
Fortuitously or otherwise, your example is of optimal size (up to 7 values for each of 15
groups) first, to show that there is a problem graphically; and second, to allow other and
fairly simple solutions. The graph is of a kind often called spaghetti by people in
different fields, although it's not always clear whether that term is meant as affectionate
or abusive. (The term spaghetti was used by Gene Zelazny in 1985, but may well be much older
yet.) The graph does show the collective or family behaviour of all the groups, but it is
fairly hopeless at showing the detail to be explored.
One standard alternative is just to show the separate groups in separate panels, but that in
turn can make precise group-to-group comparisons difficult; each group is separated from its
context of the other groups.
So why not combine both ideas: a separate panel for each group, but also show the other
groups as backdrop? This hinges crucially on highlighting the group which is in focus and on
downplaying the others, which is easy enough in this example given some use of line colour,
thickness etc. In other examples, marker or point symbol choices might be natural instead.
In this case, details of possible practical or scientific importance or interest are
highlighted:
We only have one value for A and M.
We don't have all values for all given years in all other cases.
Some groups plot high, some low, and so forth.
I won't attempt an interpretation here: the data are anonymous, but that is the researcher's
concern in any case.
Depending on what is easy or possible in your software, there is scope for changing small
details here, such as whether axis labels and titles are repeated (there are simple
arguments both for and against).
The larger issue is how far this strategy will work more generally. The number of groups is
the major driver, more so than the number of points in each group. Roughly speaking, the
approach might work up to about 25 groups (a 5 x 5 display, say): with more groups, not only
do the graphs become smaller and more difficult to read, but even the researcher loses the
inclination to scan all the panels. If there were hundreds (thousands, ...) of groups, it
would usually be essential to select a small number of groups to show. Some mix of criteria
such as selecting some "typical" and some "extreme" panels would be needed; that should be
driven by project goals and some idea of what makes sense for each dataset. Another approach
that can be efficient is to emphasize a small number of series in each panel. So, if there
were 25 broad groups, each broad group could be shown with all others as backdrop.
Alternatively, there could be some averaging or other summarization. Using (e.g.) principal
or independent components might also be a good idea.
Although the example calls for line plots, the principle is naturally much general. Examples
could be multiplied, scatter plots, model diagnostic plots, etc.
Similar but not identical ideas
Cleveland (1985, pp.74, 203, 205, 268) shows graphs in which summary curves
for groups are repeated with data shown separately for each group.
(Note: these graphs do not appear in Cleveland 1994.)
Wallgren et al. (1996, pp.47, 69) use the same idea.
Cleveland, W.S. 1985. Elements of Graphing Data. Monterey, CA: Wadsworth.
Cleveland, W.S. 1994. Elements of Graphing Data. Summit, NJ: Hobart Press.
Wallgren, A., B. Wallgren, R. Persson, U. Jorner, and J.-A. Haaland.
1996. Graphing Statistics and Data: Creating Better Charts. Newbury
Park, CA: SAGE.
Zelazny (1985 and later editions) has a different twist:
Zelazny, G. 1985. Say It With Charts: The Executive's Guide to Successful Presentations.
Homewood, IL: Dow Jones-Irwin. See p.39 for a graph with four panels: series A compared in
turn with series B, C, D, E. See also p.111.
Same pages in 4th edition: Zelazny, G. 2001. Say It With Charts: The Executive's Guide to
Visual Communication. New York: McGraw-Hill. See p.39 for a graph with four panels: series
A compared in turn with series B, C, D, E. See also p.111.
Direct examples [others are most welcome]
Koenker, R. 2005. Quantile Regression. Cambridge: Cambridge University
Press. See pp.12-13.
Carr, D.B. and Pickle, L.W. 2010. Visualizing Data Patterns with Micromaps. Boca Raton,
FL: CRC Press. See p.85.
Cox, N.J. 2010. Graphing subsets. Stata Journal 10: 670-681.
Yau, N. 2013. Data Points: Visualization That Means Something.
Indianapolis, IN: John Wiley. See p.224.
Rougier, N.P., Droettboom, M. and Bourne, P.E. 2014.
Ten simple rules for better figures.
PLOS Computational Biology 10(9): e1003833.
doi:10.1371/journal.pcbi.1003833
link here
Schwabish, J.A. 2014. An economist's guide to visualizing data. Journal
of Economic Perspectives 28: 209-234.
Knaflic, C.N. 2015. Storytelling with Data: A Data Visualization Guide
for Business Professionals. Hoboken, NJ: Wiley. See p.233.
Unwin, A. 2015. Graphical Data Analysis with R. Boca Raton, FL: CRC
Press. See pp.121, 217.
Berinato, S. 2016.
Good Charts: The HBR Guide to Making Smarter, More Persuasive Data Visualizations.
Boston, MA: Harvard Business Review Press. See p.74.
Cairo, A. 2016.
The Truthful Art: Data, Charts, and Maps for Communication.
San Francisco, CA: New Riders. See p.211
Camões, J. 2016. Data at Work: Best Practices for Creating Effective Charts
and Information Graphics in Microsoft Excel. San Francisco, CA: New
Riders. See p.354.
Standage, T. 2016. Go Figure: The Economist Explains: Things You Didn't Know You Didn't Know. London: Profile Books. See p.177.
Wickham, H. 2016. ggplot2: Elegant Graphics for Data Analysis. Cham: Springer.
See p.157.
Schwabish, J. 2017. Better Presentations: A Guide for Scholars, Researchers, and Wonks. New York: Columbia University Press. See p.98.
Kriebel, A. and Murray, E. 2018. #MakeoverMonday: Improving How We Visualize and Analyze
Data, One Chart at a Time. Hoboken, NJ: John Wiley. See p.303.
Grant, R. 2019. Data Visualization: Charts, Maps, and Interactive Graphics.
Boca Raton, FL: CRC Press. See p.52.
Koponen, J. and Hildén, J. 2019.
The Data Visualization Handbook.
Espoo: Aalto ARTS Books. See p.101.
Tufte, E.R. 2020. Seeing with Fresh Eyes: Meaning, Space, Data, Truth.
Cheshire, CT: Graphics Press. See p.26 [original work by John Burn-Murdoch, but showing 0 on logarithmic scale (!) and alphabetical order by countries, which could be tuned]
Note: The graph was created in Stata. subsetplot must be installed first with ssc inst subsetplot. Data were copied and pasted from R and value labels were defined to show years as 90 95 00 05 10 15. The main command is
subsetplot connected Val Year, by(Var) c(L) lcolor(gs12) backdrop(line) xtitle("") combine(imargin(small)) subset(lcolor(blue) mcolor(blue))
|
Visualising many variables in one plot
Fortuitously or otherwise, your example is of optimal size (up to 7 values for each of 15
groups) first, to show that there is a problem graphically; and second, to allow other and
fairly simple solut
|
8,725
|
Visualising many variables in one plot
|
As a complement to Nick's answer, here's some R code for making a similar plot using simulated data:
library(ggplot2)
get_df <- function(label="group A", n_obs=10, drift=runif(1)) {
df <- data.frame(time=seq(1, n_obs), label=label)
df$y <- df$time * drift + cumsum(rnorm(n_obs))
return(df)
}
df_list <- lapply(sprintf("group %s", toupper(letters[1:9])),
function(label) { get_df(label) })
df <- do.call(rbind, df_list)
df$label2 <- df$label
p <- (ggplot(df, aes(x=time, y=y, group=label2)) +
geom_line(size=0.9, alpha=0.8,
data=df[, c("time", "y", "label2")], color="grey") +
geom_line(size=1.1, color="black") +
ylab("") +
theme_bw() +
theme(panel.border=element_blank()) +
theme(strip.background=element_blank()) +
facet_wrap(~ label))
p
ggsave("example_facet.png", p, width=10, height=8)
|
Visualising many variables in one plot
|
As a complement to Nick's answer, here's some R code for making a similar plot using simulated data:
library(ggplot2)
get_df <- function(label="group A", n_obs=10, drift=runif(1)) {
df <- data.fr
|
Visualising many variables in one plot
As a complement to Nick's answer, here's some R code for making a similar plot using simulated data:
library(ggplot2)
get_df <- function(label="group A", n_obs=10, drift=runif(1)) {
df <- data.frame(time=seq(1, n_obs), label=label)
df$y <- df$time * drift + cumsum(rnorm(n_obs))
return(df)
}
df_list <- lapply(sprintf("group %s", toupper(letters[1:9])),
function(label) { get_df(label) })
df <- do.call(rbind, df_list)
df$label2 <- df$label
p <- (ggplot(df, aes(x=time, y=y, group=label2)) +
geom_line(size=0.9, alpha=0.8,
data=df[, c("time", "y", "label2")], color="grey") +
geom_line(size=1.1, color="black") +
ylab("") +
theme_bw() +
theme(panel.border=element_blank()) +
theme(strip.background=element_blank()) +
facet_wrap(~ label))
p
ggsave("example_facet.png", p, width=10, height=8)
|
Visualising many variables in one plot
As a complement to Nick's answer, here's some R code for making a similar plot using simulated data:
library(ggplot2)
get_df <- function(label="group A", n_obs=10, drift=runif(1)) {
df <- data.fr
|
8,726
|
Visualising many variables in one plot
|
For those wanting to use a ggplot2 approach in R consider the facetshade function in the package extracat. This offers a general approach, not just for line plots. Here is an example with scatterplots (from the foot of this page):
data(olives, package="extracat")
library(scales)
fs1 <- facetshade(data = olives,
aes(x = palmitic, y = palmitoleic), f =
. ~ Area)
fs1 + geom_point(colour = alpha("black", 0.05)) +
geom_point(data = olives, colour = "red") +
facet_wrap(f=~Area, nrow=3) +
theme(legend.position="none")
EDIT: Using Adrian's simulated dataset from his earlier answer:
library(extracat)
facetshade(df, aes(x=time, y=y), f = .~label, bg.all = FALSE,
keep.orig = TRUE) +
geom_line(aes(x=time, y=y,
group=orig.label),colour = alpha(1,0.3)) +
geom_line(data=df, aes(colour=label), size = 1.2)
+ xlab("") + ylab("")
Another approach is to draw two separate layers, one for the background and one for the highlighted cases. The trick is to draw the background layer using the dataset without the faceting variable. For the olive oil dataset the code is:
data(olives, package="extracat")
ggplot(olives, aes(palmitic, palmitoleic)) +
facet_wrap(~Area, nrow=3) +
geom_point(data=olives %>% select(-Area),
colour=alpha("black", 0.05)) +
geom_point(data=olives, colour="red") +
theme(legend.position="none")
|
Visualising many variables in one plot
|
For those wanting to use a ggplot2 approach in R consider the facetshade function in the package extracat. This offers a general approach, not just for line plots. Here is an example with scatterplo
|
Visualising many variables in one plot
For those wanting to use a ggplot2 approach in R consider the facetshade function in the package extracat. This offers a general approach, not just for line plots. Here is an example with scatterplots (from the foot of this page):
data(olives, package="extracat")
library(scales)
fs1 <- facetshade(data = olives,
aes(x = palmitic, y = palmitoleic), f =
. ~ Area)
fs1 + geom_point(colour = alpha("black", 0.05)) +
geom_point(data = olives, colour = "red") +
facet_wrap(f=~Area, nrow=3) +
theme(legend.position="none")
EDIT: Using Adrian's simulated dataset from his earlier answer:
library(extracat)
facetshade(df, aes(x=time, y=y), f = .~label, bg.all = FALSE,
keep.orig = TRUE) +
geom_line(aes(x=time, y=y,
group=orig.label),colour = alpha(1,0.3)) +
geom_line(data=df, aes(colour=label), size = 1.2)
+ xlab("") + ylab("")
Another approach is to draw two separate layers, one for the background and one for the highlighted cases. The trick is to draw the background layer using the dataset without the faceting variable. For the olive oil dataset the code is:
data(olives, package="extracat")
ggplot(olives, aes(palmitic, palmitoleic)) +
facet_wrap(~Area, nrow=3) +
geom_point(data=olives %>% select(-Area),
colour=alpha("black", 0.05)) +
geom_point(data=olives, colour="red") +
theme(legend.position="none")
|
Visualising many variables in one plot
For those wanting to use a ggplot2 approach in R consider the facetshade function in the package extracat. This offers a general approach, not just for line plots. Here is an example with scatterplo
|
8,727
|
Visualising many variables in one plot
|
Here is a solution inspired by Ch. 11.3, the section on "Texas Housing Data", in Hadley Wickham's Book on ggplot2. Here I fit a linear model to each time series , take the residuals (which are centered around mean 0), and draw a summary line in a different color.
library(ggplot2)
library(dplyr)
#works with dplyr version 0.4.3.9000 from Github (hadley/dplyr@4f2d7f8), or higher
df1 <- as.data.frame(list(Var = structure(c(1L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L,
6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 16L, 16L, 16L, 16L, 16L, 16L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 18L, 18L, 18L, 18L, 18L, 18L, 18L), .Label = c("A",
"B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
"O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"), class = "factor"),
Year = c(2015L, 1991L, 1993L, 1996L, 2000L, 2004L, 2011L,
2015L, 1991L, 1993L, 1996L, 2000L, 2004L, 2011L, 2015L, 1991L,
1993L, 1996L, 2000L, 2004L, 2011L, 2015L, 1993L, 1996L, 2000L,
2004L, 2011L, 2015L, 1991L, 1993L, 1996L, 2000L, 2004L, 2011L,
2015L, 1991L, 1993L, 1996L, 2000L, 2004L, 2011L, 2015L, 1991L,
1993L, 1996L, 2000L, 2004L, 2011L, 2015L, 1991L, 1993L, 1996L,
2000L, 2004L, 2011L, 2015L, 1993L, 1996L, 2000L, 2004L, 2011L,
2015L, 2015L, 1991L, 1993L, 1996L, 2000L, 2004L, 2011L, 2015L,
1991L, 1993L, 1996L, 2000L, 2011L, 2015L, 1991L, 1993L, 1996L,
2000L, 2004L, 2011L, 2015L, 1991L, 1993L, 1996L, 2000L, 2004L,
2011L, 2015L),
Val = c(25.6, 22.93, 20.82, 24.1, 24.5, 29,
25.55, 24.5, 24.52, 20.73, 25.8, 25.5, 29.5, 27.7, 25.1,
25, 24.55, 26.75, 25, 30.5, 27.25, 25.1, 22.4, 27.07, 26,
29, 27.2, 24.2, 23, 24.27, 27.68, 27, 30.5, 28.1, 24.9, 23.75,
22.75, 27.25, 25, 29, 28.45, 24, 20.25, 17.07, 24.45, 25,
28.5, 26.75, 24.9, 21.25, 20.65, 25.1, 24.5, 26.5, 25.35,
23.5, 21.93, 26.5, 24.5, 29, 29.1, 26.4, 28.1, 23.75, 26.5,
28.05, 27, 30.5, 25.65, 23.3, 23.25, 24.57, 26.07, 27.5,
28.85, 27.7, 22, 23.43, 26.88, 27, 30.5, 29.25, 28.1, 23,
23.8, 28.32, 27, 29.5, 29.15, 27.6)),
row.names = c(1L, 4L,
5L, 6L, 7L, 8L, 9L, 10L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L,
21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 35L,
36L, 37L, 38L, 39L, 40L, 41L, 44L, 45L, 46L, 47L, 48L, 49L, 50L,
53L, 54L, 55L, 56L, 57L, 58L, 59L, 62L, 63L, 64L, 65L, 66L, 67L,
68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L, 78L, 79L, 80L, 81L, 82L,
83L, 84L, 87L, 88L, 89L, 90L, 91L, 92L, 95L, 96L, 97L, 98L, 99L,
100L, 101L, 104L, 105L, 106L, 107L, 108L, 109L, 110L),
na.action = structure(c(2L,
3L, 11L, 12L, 33L, 34L, 42L, 43L, 51L, 52L, 60L, 61L, 76L, 77L,
85L, 86L, 93L, 94L, 102L, 103L),
.Names = c("2", "3", "11", "12","33", "34", "42", "43", "51", "52", "60",
"61", "76", "77", "85", "86", "93", "94", "102", "103"), class = "omit"),
class = "data.frame", .Names = c("Var","Year", "Val"))
df1 %>%
group_by(Var) %>%
do(mutate(.,resid = resid(lm(Val ~ Year, data=., na.action = na.exclude)))) %>%
ggplot(aes(Year, resid)) +
labs(y=paste0("Val "), x="Year") +
geom_line(aes(group = Var), alpha = 1/5) +
geom_line(stat = "summary", fun.y = "mean", colour = "red")
|
Visualising many variables in one plot
|
Here is a solution inspired by Ch. 11.3, the section on "Texas Housing Data", in Hadley Wickham's Book on ggplot2. Here I fit a linear model to each time series , take the residuals (which are centere
|
Visualising many variables in one plot
Here is a solution inspired by Ch. 11.3, the section on "Texas Housing Data", in Hadley Wickham's Book on ggplot2. Here I fit a linear model to each time series , take the residuals (which are centered around mean 0), and draw a summary line in a different color.
library(ggplot2)
library(dplyr)
#works with dplyr version 0.4.3.9000 from Github (hadley/dplyr@4f2d7f8), or higher
df1 <- as.data.frame(list(Var = structure(c(1L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L,
6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 16L, 16L, 16L, 16L, 16L, 16L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 18L, 18L, 18L, 18L, 18L, 18L, 18L), .Label = c("A",
"B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
"O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"), class = "factor"),
Year = c(2015L, 1991L, 1993L, 1996L, 2000L, 2004L, 2011L,
2015L, 1991L, 1993L, 1996L, 2000L, 2004L, 2011L, 2015L, 1991L,
1993L, 1996L, 2000L, 2004L, 2011L, 2015L, 1993L, 1996L, 2000L,
2004L, 2011L, 2015L, 1991L, 1993L, 1996L, 2000L, 2004L, 2011L,
2015L, 1991L, 1993L, 1996L, 2000L, 2004L, 2011L, 2015L, 1991L,
1993L, 1996L, 2000L, 2004L, 2011L, 2015L, 1991L, 1993L, 1996L,
2000L, 2004L, 2011L, 2015L, 1993L, 1996L, 2000L, 2004L, 2011L,
2015L, 2015L, 1991L, 1993L, 1996L, 2000L, 2004L, 2011L, 2015L,
1991L, 1993L, 1996L, 2000L, 2011L, 2015L, 1991L, 1993L, 1996L,
2000L, 2004L, 2011L, 2015L, 1991L, 1993L, 1996L, 2000L, 2004L,
2011L, 2015L),
Val = c(25.6, 22.93, 20.82, 24.1, 24.5, 29,
25.55, 24.5, 24.52, 20.73, 25.8, 25.5, 29.5, 27.7, 25.1,
25, 24.55, 26.75, 25, 30.5, 27.25, 25.1, 22.4, 27.07, 26,
29, 27.2, 24.2, 23, 24.27, 27.68, 27, 30.5, 28.1, 24.9, 23.75,
22.75, 27.25, 25, 29, 28.45, 24, 20.25, 17.07, 24.45, 25,
28.5, 26.75, 24.9, 21.25, 20.65, 25.1, 24.5, 26.5, 25.35,
23.5, 21.93, 26.5, 24.5, 29, 29.1, 26.4, 28.1, 23.75, 26.5,
28.05, 27, 30.5, 25.65, 23.3, 23.25, 24.57, 26.07, 27.5,
28.85, 27.7, 22, 23.43, 26.88, 27, 30.5, 29.25, 28.1, 23,
23.8, 28.32, 27, 29.5, 29.15, 27.6)),
row.names = c(1L, 4L,
5L, 6L, 7L, 8L, 9L, 10L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L,
21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 35L,
36L, 37L, 38L, 39L, 40L, 41L, 44L, 45L, 46L, 47L, 48L, 49L, 50L,
53L, 54L, 55L, 56L, 57L, 58L, 59L, 62L, 63L, 64L, 65L, 66L, 67L,
68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L, 78L, 79L, 80L, 81L, 82L,
83L, 84L, 87L, 88L, 89L, 90L, 91L, 92L, 95L, 96L, 97L, 98L, 99L,
100L, 101L, 104L, 105L, 106L, 107L, 108L, 109L, 110L),
na.action = structure(c(2L,
3L, 11L, 12L, 33L, 34L, 42L, 43L, 51L, 52L, 60L, 61L, 76L, 77L,
85L, 86L, 93L, 94L, 102L, 103L),
.Names = c("2", "3", "11", "12","33", "34", "42", "43", "51", "52", "60",
"61", "76", "77", "85", "86", "93", "94", "102", "103"), class = "omit"),
class = "data.frame", .Names = c("Var","Year", "Val"))
df1 %>%
group_by(Var) %>%
do(mutate(.,resid = resid(lm(Val ~ Year, data=., na.action = na.exclude)))) %>%
ggplot(aes(Year, resid)) +
labs(y=paste0("Val "), x="Year") +
geom_line(aes(group = Var), alpha = 1/5) +
geom_line(stat = "summary", fun.y = "mean", colour = "red")
|
Visualising many variables in one plot
Here is a solution inspired by Ch. 11.3, the section on "Texas Housing Data", in Hadley Wickham's Book on ggplot2. Here I fit a linear model to each time series , take the residuals (which are centere
|
8,728
|
What is the difference between something being "true" and 'true with probability 1"?
|
If something is true, then it is true with probability of one. Or at least let us assume that without raising further complications. But something with probability of one is not necessarily true. This is the notion of something being almost surely true.
Example
Suppose we sample uniformly on the interval $x \in [0,1] \subset \mathbb{R}$. Since $P(x=\frac{1}{2}) = 0$, we can infer that $P(\lnot [x = \frac{1}{2}]) = 1 - P(x = \frac{1}{2}) = 1$. It is almost surely the case that you will not sample $x=\frac{1}{2}$, but it isn't impossible.
Example: Dart Throwing
This example is from Wikipedia.
Imagine throwing a dart at a unit square (a square with an area of 1) so that the dart always hits an exact point in the square, in such a way that each point in the square is equally likely to be hit. Since the square has area 1, the probability that the dart will hit any particular subregion of the square is equal to the area of that subregion. For example, the probability that the dart will hit the right half of the square is 0.5, since the right half has area 0.5.
Next, consider the event that the dart hits exactly a point in the diagonals of the unit square. Since the area of the diagonals of the square is 0, the probability that the dart will land exactly on a diagonal is 0. That is, the dart will almost never land on a diagonal (equivalently, it will almost surely not land on a diagonal), even though the set of points on the diagonals is not empty, and a point on a diagonal is no less possible than any other point.
|
What is the difference between something being "true" and 'true with probability 1"?
|
If something is true, then it is true with probability of one. Or at least let us assume that without raising further complications. But something with probability of one is not necessarily true. This
|
What is the difference between something being "true" and 'true with probability 1"?
If something is true, then it is true with probability of one. Or at least let us assume that without raising further complications. But something with probability of one is not necessarily true. This is the notion of something being almost surely true.
Example
Suppose we sample uniformly on the interval $x \in [0,1] \subset \mathbb{R}$. Since $P(x=\frac{1}{2}) = 0$, we can infer that $P(\lnot [x = \frac{1}{2}]) = 1 - P(x = \frac{1}{2}) = 1$. It is almost surely the case that you will not sample $x=\frac{1}{2}$, but it isn't impossible.
Example: Dart Throwing
This example is from Wikipedia.
Imagine throwing a dart at a unit square (a square with an area of 1) so that the dart always hits an exact point in the square, in such a way that each point in the square is equally likely to be hit. Since the square has area 1, the probability that the dart will hit any particular subregion of the square is equal to the area of that subregion. For example, the probability that the dart will hit the right half of the square is 0.5, since the right half has area 0.5.
Next, consider the event that the dart hits exactly a point in the diagonals of the unit square. Since the area of the diagonals of the square is 0, the probability that the dart will land exactly on a diagonal is 0. That is, the dart will almost never land on a diagonal (equivalently, it will almost surely not land on a diagonal), even though the set of points on the diagonals is not empty, and a point on a diagonal is no less possible than any other point.
|
What is the difference between something being "true" and 'true with probability 1"?
If something is true, then it is true with probability of one. Or at least let us assume that without raising further complications. But something with probability of one is not necessarily true. This
|
8,729
|
What is the difference between something being "true" and 'true with probability 1"?
|
This difference occurs because of the difference between probability and possibility
This answer is based on a longer paper O'Neill (2014) that looks at the interaction of a binary possibility operator and a probability measure. Have a look at this paper if you'd like a more detailed exposition of the subject covered in this answer. You can also find a related answer here.
The basic idea here is that we can have a space of outcomes $\Omega_*$ that are all possible, but some outcomes in the space may be so improbable that we can remove them from consideration while still having probability one for the set of remaining outcomes. For example, if we have a continuous random variable $X$ with support $\mathscr{X}$ then every value in the support is possible, but each specific value also has zero probability of occurring. Thus, if we take some value $x \in \mathscr{X}$ then we know that $x$ is a possible value, but we also have $\mathbb{P}(X \neq x) = 1$. In this case, it is not necessarily true that $X \neq x$ (since $x$ is a possible value) but it is true with probability one (we say that this occurs "almost surely"). You can easily construct examples of the divergence between possibility and probability by using zero-probability events for continuous random variables. The dart-throwing example cited in the other answer here is one instance of this.
This split occurs because of the difference between probability and possibility, and it is something you need to keep in mind when dealing with continuous random variables or in other similar cases. Below I will give you a basic outline of how possibility is represented in the analysis of events, and how it diverges from probability. There is a sizable literature analysing mathematical representations of possibility (this field is known as possibility theory), which is closely related to modal logic and fuzzy set theory. Overviews of this field can be found in Yager (ed) (1982), Kacprzyk and Orlovski (eds) (1987), Dubois and Prade (1993), Terano, Asai and Sugeno (eds) (1992), Zadeh and Kacprzyk (1992) and Dubois (2006).
A Brief Description of Possibility Theory
The field of possibility theory is formalised in a similar manner to the field of probability theory. In both cases we have an overall space of outcomes $\Omega$ and a class of events $\mathscr{E} \subseteq \Omega$ on that space. Possibilty theory works with a set operator that measures events on a scale from zero to one, just as in probability theory. The theory is characterised by a possibility function $\nabla$ that obeys a set of axioms that are close to those of probability theory, except that they display different behaviour when applied to unions of disjoint events. The general theory allows for a possibility measure that takes on values between zero and one, but here I will use an all-or-nothing possibility measure taking on values zero or one. (This is partly for illustrative purposes and partly because this special case conforms best to the intuitive idea of possibility.) The properties characterising a possibility measure $\nabla$ and a probability measure $\mathbb{P}$ are as follows (in the last line we refer to a countable set $\mathscr{E}_1,\mathscr{E}_2,\mathscr{E}_3,...$ of disjoint events):
$$\begin{matrix}
\text{Possibility measure} \quad \quad & & & & & \text{Probability measure} \quad \\[6pt]
\nabla(\varnothing) = 0 \quad \quad \quad & & & & & \mathbb{P}(\varnothing) = 0 \quad \quad \\[6pt]
\nabla(\Omega) = 1 \quad \quad \quad & & & & & \mathbb{P}(\Omega) = 1 \quad \quad \\[6pt]
\nabla ( \bigcup_i \mathscr{E}_i ) = \max_i \nabla(\mathscr{E}_i) & & & & & \mathbb{P} ( \bigcup_i \mathscr{E}_i ) = \sum_i \mathbb{P}(\mathscr{E}_i) \\[6pt]
\end{matrix}$$
As you can see, both functions give zero measure for the empty event $\varnothing$ and unit measure for the full space $\Omega$. However, when it comes to dealing with countable unions of disjoint sets, the two measures differ --- the probability of a countable union of disjoint events is equal to the sum of the probabilities of those events, whereas the possibility measure of a countable union of disjoint events is equal to the maximum of the possibility measures of those events.
The above measure for possibility might look a bit strange, since we are used to thinking of possibility as a binary. The possibility measure is formulated in a more generalised way (allowing any value between zero and one) in order to accommodate fields like fuzzy logic and modal logic. Nevertheless, for present purposes, we can simplify possibility theory to deal only with events classified using the binary categorisation (zero or one) with $\nabla(\mathscr{E}) = 0$ meaning that $\mathscr{E}$ is impossible and $\nabla(\mathscr{E}) = 1$ meaning that $\mathscr{E}$ is possible. (Similarly, we say that an event is certain if its negation is impossible.) The third property above then reduces to saying that the union of a countable set of disjoint events is possible if and only if at least one of the events is possible, which corresponds to our intuition.
(In fact, if all events have possibility measure zero or one then it is possible to extend the properties for the possibility measure to allow the above maximisation property over arbitrary unions, not just countable unions. This extension is not generally possible for the probability measure, as is well known.)
Relating Probability and Possibility
In order to relate probability and possibility measures on the same space (and thereby see how they interact) we can begin by taking some overarching space $\Omega$ and considering the set of all possible outcomes defined by $\Omega_* \equiv \{ \omega \in \Omega | \nabla(\{\omega\}) = 1 \}$. We would then usually begin our analysis with the axiom that the set of all possible outcomes has probability one (i.e., that $\mathbb{P}(\Omega_*)=1$). Starting with this axiom we can then establish that all certain events are almost sure and all events with positive probability are possible. However, the converses are not necessarily true --- an almost sure event is not necessarily certain and a possible event does not necessarily have positive probability.
I will leave it as an exercise to you to see if you can derive the above rules from the axiom above. It is relatively simple to formulate an example using a continuous random variable where you have events that are uncertain but have probability one.
|
What is the difference between something being "true" and 'true with probability 1"?
|
This difference occurs because of the difference between probability and possibility
This answer is based on a longer paper O'Neill (2014) that looks at the interaction of a binary possibility operato
|
What is the difference between something being "true" and 'true with probability 1"?
This difference occurs because of the difference between probability and possibility
This answer is based on a longer paper O'Neill (2014) that looks at the interaction of a binary possibility operator and a probability measure. Have a look at this paper if you'd like a more detailed exposition of the subject covered in this answer. You can also find a related answer here.
The basic idea here is that we can have a space of outcomes $\Omega_*$ that are all possible, but some outcomes in the space may be so improbable that we can remove them from consideration while still having probability one for the set of remaining outcomes. For example, if we have a continuous random variable $X$ with support $\mathscr{X}$ then every value in the support is possible, but each specific value also has zero probability of occurring. Thus, if we take some value $x \in \mathscr{X}$ then we know that $x$ is a possible value, but we also have $\mathbb{P}(X \neq x) = 1$. In this case, it is not necessarily true that $X \neq x$ (since $x$ is a possible value) but it is true with probability one (we say that this occurs "almost surely"). You can easily construct examples of the divergence between possibility and probability by using zero-probability events for continuous random variables. The dart-throwing example cited in the other answer here is one instance of this.
This split occurs because of the difference between probability and possibility, and it is something you need to keep in mind when dealing with continuous random variables or in other similar cases. Below I will give you a basic outline of how possibility is represented in the analysis of events, and how it diverges from probability. There is a sizable literature analysing mathematical representations of possibility (this field is known as possibility theory), which is closely related to modal logic and fuzzy set theory. Overviews of this field can be found in Yager (ed) (1982), Kacprzyk and Orlovski (eds) (1987), Dubois and Prade (1993), Terano, Asai and Sugeno (eds) (1992), Zadeh and Kacprzyk (1992) and Dubois (2006).
A Brief Description of Possibility Theory
The field of possibility theory is formalised in a similar manner to the field of probability theory. In both cases we have an overall space of outcomes $\Omega$ and a class of events $\mathscr{E} \subseteq \Omega$ on that space. Possibilty theory works with a set operator that measures events on a scale from zero to one, just as in probability theory. The theory is characterised by a possibility function $\nabla$ that obeys a set of axioms that are close to those of probability theory, except that they display different behaviour when applied to unions of disjoint events. The general theory allows for a possibility measure that takes on values between zero and one, but here I will use an all-or-nothing possibility measure taking on values zero or one. (This is partly for illustrative purposes and partly because this special case conforms best to the intuitive idea of possibility.) The properties characterising a possibility measure $\nabla$ and a probability measure $\mathbb{P}$ are as follows (in the last line we refer to a countable set $\mathscr{E}_1,\mathscr{E}_2,\mathscr{E}_3,...$ of disjoint events):
$$\begin{matrix}
\text{Possibility measure} \quad \quad & & & & & \text{Probability measure} \quad \\[6pt]
\nabla(\varnothing) = 0 \quad \quad \quad & & & & & \mathbb{P}(\varnothing) = 0 \quad \quad \\[6pt]
\nabla(\Omega) = 1 \quad \quad \quad & & & & & \mathbb{P}(\Omega) = 1 \quad \quad \\[6pt]
\nabla ( \bigcup_i \mathscr{E}_i ) = \max_i \nabla(\mathscr{E}_i) & & & & & \mathbb{P} ( \bigcup_i \mathscr{E}_i ) = \sum_i \mathbb{P}(\mathscr{E}_i) \\[6pt]
\end{matrix}$$
As you can see, both functions give zero measure for the empty event $\varnothing$ and unit measure for the full space $\Omega$. However, when it comes to dealing with countable unions of disjoint sets, the two measures differ --- the probability of a countable union of disjoint events is equal to the sum of the probabilities of those events, whereas the possibility measure of a countable union of disjoint events is equal to the maximum of the possibility measures of those events.
The above measure for possibility might look a bit strange, since we are used to thinking of possibility as a binary. The possibility measure is formulated in a more generalised way (allowing any value between zero and one) in order to accommodate fields like fuzzy logic and modal logic. Nevertheless, for present purposes, we can simplify possibility theory to deal only with events classified using the binary categorisation (zero or one) with $\nabla(\mathscr{E}) = 0$ meaning that $\mathscr{E}$ is impossible and $\nabla(\mathscr{E}) = 1$ meaning that $\mathscr{E}$ is possible. (Similarly, we say that an event is certain if its negation is impossible.) The third property above then reduces to saying that the union of a countable set of disjoint events is possible if and only if at least one of the events is possible, which corresponds to our intuition.
(In fact, if all events have possibility measure zero or one then it is possible to extend the properties for the possibility measure to allow the above maximisation property over arbitrary unions, not just countable unions. This extension is not generally possible for the probability measure, as is well known.)
Relating Probability and Possibility
In order to relate probability and possibility measures on the same space (and thereby see how they interact) we can begin by taking some overarching space $\Omega$ and considering the set of all possible outcomes defined by $\Omega_* \equiv \{ \omega \in \Omega | \nabla(\{\omega\}) = 1 \}$. We would then usually begin our analysis with the axiom that the set of all possible outcomes has probability one (i.e., that $\mathbb{P}(\Omega_*)=1$). Starting with this axiom we can then establish that all certain events are almost sure and all events with positive probability are possible. However, the converses are not necessarily true --- an almost sure event is not necessarily certain and a possible event does not necessarily have positive probability.
I will leave it as an exercise to you to see if you can derive the above rules from the axiom above. It is relatively simple to formulate an example using a continuous random variable where you have events that are uncertain but have probability one.
|
What is the difference between something being "true" and 'true with probability 1"?
This difference occurs because of the difference between probability and possibility
This answer is based on a longer paper O'Neill (2014) that looks at the interaction of a binary possibility operato
|
8,730
|
What is the difference between something being "true" and 'true with probability 1"?
|
As Galen indicated, this is the concept of almost surely or almost everywhere.
To provide a more general framework, consider a measure space $(X, \mathfrak A, \mu). $ For a measurable set $A\in \mathfrak A, $ a property $\mathsf Q$ holds almost everywhere on $A$, provided there exists a null set $A_0\subset A$ that is $\mu(A_0) = 0,$ and
$$\mathsf Q(x)~~~ \forall x\in A\setminus A_0.\tag 1$$
Reference:
$[\rm I]$ Real Analysis, H. L. Royden, P. M. Fitzpatrick, Pearson Education, $2010, $ section $2.5, $ p. $45.$
|
What is the difference between something being "true" and 'true with probability 1"?
|
As Galen indicated, this is the concept of almost surely or almost everywhere.
To provide a more general framework, consider a measure space $(X, \mathfrak A, \mu). $ For a measurable set $A\in \mathf
|
What is the difference between something being "true" and 'true with probability 1"?
As Galen indicated, this is the concept of almost surely or almost everywhere.
To provide a more general framework, consider a measure space $(X, \mathfrak A, \mu). $ For a measurable set $A\in \mathfrak A, $ a property $\mathsf Q$ holds almost everywhere on $A$, provided there exists a null set $A_0\subset A$ that is $\mu(A_0) = 0,$ and
$$\mathsf Q(x)~~~ \forall x\in A\setminus A_0.\tag 1$$
Reference:
$[\rm I]$ Real Analysis, H. L. Royden, P. M. Fitzpatrick, Pearson Education, $2010, $ section $2.5, $ p. $45.$
|
What is the difference between something being "true" and 'true with probability 1"?
As Galen indicated, this is the concept of almost surely or almost everywhere.
To provide a more general framework, consider a measure space $(X, \mathfrak A, \mu). $ For a measurable set $A\in \mathf
|
8,731
|
What is the difference between something being "true" and 'true with probability 1"?
|
A probability is just a function that satisfies a set of axioms, and maps subsets of the sample space to real numbers between $0$ and $1$. A widely used one is Kolmogorov axioms. Therefore, if you construct your own function that satisfies that set of axioms, no matter what it is, and you have a set which is mapped to $1$, then (the outcome represented by) that set is said to be true with probability $1$.
But when we say something is true, it is logically true. For example, if you flip a coin, it is true that you get either a head or a tail. It can be considered in the realm of “probability”, but it also has logical meaning.
|
What is the difference between something being "true" and 'true with probability 1"?
|
A probability is just a function that satisfies a set of axioms, and maps subsets of the sample space to real numbers between $0$ and $1$. A widely used one is Kolmogorov axioms. Therefore, if you con
|
What is the difference between something being "true" and 'true with probability 1"?
A probability is just a function that satisfies a set of axioms, and maps subsets of the sample space to real numbers between $0$ and $1$. A widely used one is Kolmogorov axioms. Therefore, if you construct your own function that satisfies that set of axioms, no matter what it is, and you have a set which is mapped to $1$, then (the outcome represented by) that set is said to be true with probability $1$.
But when we say something is true, it is logically true. For example, if you flip a coin, it is true that you get either a head or a tail. It can be considered in the realm of “probability”, but it also has logical meaning.
|
What is the difference between something being "true" and 'true with probability 1"?
A probability is just a function that satisfies a set of axioms, and maps subsets of the sample space to real numbers between $0$ and $1$. A widely used one is Kolmogorov axioms. Therefore, if you con
|
8,732
|
What is the difference between something being "true" and 'true with probability 1"?
|
Consider the (-1,-1)-(+1,+1) sheet with a point sized hole in the origin.
It is true with probability 1 that a random point within (-1,-1)-(+1,+1) in the sheet. But there is a point that meets that definition that isn't on the sheet. So it is not true that a point within (-1,-1)-(+1,+1) is on the sheet.
There is no difference in the finite realm.
|
What is the difference between something being "true" and 'true with probability 1"?
|
Consider the (-1,-1)-(+1,+1) sheet with a point sized hole in the origin.
It is true with probability 1 that a random point within (-1,-1)-(+1,+1) in the sheet. But there is a point that meets that de
|
What is the difference between something being "true" and 'true with probability 1"?
Consider the (-1,-1)-(+1,+1) sheet with a point sized hole in the origin.
It is true with probability 1 that a random point within (-1,-1)-(+1,+1) in the sheet. But there is a point that meets that definition that isn't on the sheet. So it is not true that a point within (-1,-1)-(+1,+1) is on the sheet.
There is no difference in the finite realm.
|
What is the difference between something being "true" and 'true with probability 1"?
Consider the (-1,-1)-(+1,+1) sheet with a point sized hole in the origin.
It is true with probability 1 that a random point within (-1,-1)-(+1,+1) in the sheet. But there is a point that meets that de
|
8,733
|
Why is a mixture of two normally distributed variables only bimodal if their means differ by at least two times the common standard deviation?
|
This figure from the the paper linked in that wiki article provides a nice illustration:
The proof they provide is based on the fact that normal distributions are concave within one SD of their mean (the SD being the inflection point of the normal pdf, where it goes from concave to convex). Thus, if you add two normal pdfs together (in equal proportions), then as long as their means differ by less than two SDs, the sum-pdf (i.e. the mixture) will be concave in the region between the two means, and therefore the global maximum must be at the point exactly between the two means.
Reference: Schilling, M. F., Watkins, A. E., & Watkins, W. (2002). Is Human Height Bimodal? The American Statistician, 56(3), 223–229. doi:10.1198/00031300265
|
Why is a mixture of two normally distributed variables only bimodal if their means differ by at leas
|
This figure from the the paper linked in that wiki article provides a nice illustration:
The proof they provide is based on the fact that normal distributions are concave within one SD of their mean
|
Why is a mixture of two normally distributed variables only bimodal if their means differ by at least two times the common standard deviation?
This figure from the the paper linked in that wiki article provides a nice illustration:
The proof they provide is based on the fact that normal distributions are concave within one SD of their mean (the SD being the inflection point of the normal pdf, where it goes from concave to convex). Thus, if you add two normal pdfs together (in equal proportions), then as long as their means differ by less than two SDs, the sum-pdf (i.e. the mixture) will be concave in the region between the two means, and therefore the global maximum must be at the point exactly between the two means.
Reference: Schilling, M. F., Watkins, A. E., & Watkins, W. (2002). Is Human Height Bimodal? The American Statistician, 56(3), 223–229. doi:10.1198/00031300265
|
Why is a mixture of two normally distributed variables only bimodal if their means differ by at leas
This figure from the the paper linked in that wiki article provides a nice illustration:
The proof they provide is based on the fact that normal distributions are concave within one SD of their mean
|
8,734
|
Why is a mixture of two normally distributed variables only bimodal if their means differ by at least two times the common standard deviation?
|
This is a case where pictures can be deceiving, because this result is a special characteristic of normal mixtures: an analog does not necessarily hold for other mixtures, even when the components are symmetric unimodal distributions! For instance, an equal mixture of two Student t distributions separated by a little less than twice their common standard deviation will be bimodal. For real insight then, we have to do some math or appeal to special properties of Normal distributions.
Choose units of measurement (by recentering and rescaling as needed) to place the means of the component distributions at $\pm\mu,$ $\mu\ge 0,$ and to make their common variance unity. Let $p,$ $0 \lt p \lt 1,$ be the amount of the larger-mean component in the mixture. This enables us to express the mixture density in full generality as
$$\sqrt{2\pi}f(x;\mu,p) = p \exp\left(-\frac{(x-\mu)^2}{2}\right) + (1-p) \exp\left(-\frac{(x+\mu)^2}{2}\right).$$
Because both component densities increase where $x\lt -\mu$ and decrease where $x\gt \mu,$ the only possible modes occur where $-\mu\le x \le \mu.$ Find them by differentiating $f$ with respect to $x$ and setting it to zero. Clearing out any positive coefficients we obtain
$$0 = -e^{2x\mu} p(x-\mu) + (1-p)(x+\mu).$$
Performing similar operations with the second derivative of $f$ and replacing $e^{2x\mu}$ by the value determined by the preceding equation tells us the sign of the second derivative at any critical point is the sign of
$$f^{\prime\prime}(x;\mu,p) \propto \frac{(1+x^2-\mu^2)}{x-\mu}.$$
Since the denominator is negative when $-\mu\lt x \lt \mu,$ the sign of $f^{\prime\prime}$ is that of $-(1-\mu^2 + x^2).$ It is clear that when $\mu\le 1,$ the sign must be negative. In a multimodal distribution, however (because the density is continuous), there must be an antimode between any two modes, where the sign is non-negative. Thus, when $\mu$ is less than $1$ (the SD), the distribution must be unimodal.
Since the separation of the means is $2\mu,$ the conclusion of this analysis is
A mixture of Normal distributions is unimodal whenever the means are separated by no more than twice the common standard deviation.
That's logically equivalent to the statement in the question.
|
Why is a mixture of two normally distributed variables only bimodal if their means differ by at leas
|
This is a case where pictures can be deceiving, because this result is a special characteristic of normal mixtures: an analog does not necessarily hold for other mixtures, even when the components are
|
Why is a mixture of two normally distributed variables only bimodal if their means differ by at least two times the common standard deviation?
This is a case where pictures can be deceiving, because this result is a special characteristic of normal mixtures: an analog does not necessarily hold for other mixtures, even when the components are symmetric unimodal distributions! For instance, an equal mixture of two Student t distributions separated by a little less than twice their common standard deviation will be bimodal. For real insight then, we have to do some math or appeal to special properties of Normal distributions.
Choose units of measurement (by recentering and rescaling as needed) to place the means of the component distributions at $\pm\mu,$ $\mu\ge 0,$ and to make their common variance unity. Let $p,$ $0 \lt p \lt 1,$ be the amount of the larger-mean component in the mixture. This enables us to express the mixture density in full generality as
$$\sqrt{2\pi}f(x;\mu,p) = p \exp\left(-\frac{(x-\mu)^2}{2}\right) + (1-p) \exp\left(-\frac{(x+\mu)^2}{2}\right).$$
Because both component densities increase where $x\lt -\mu$ and decrease where $x\gt \mu,$ the only possible modes occur where $-\mu\le x \le \mu.$ Find them by differentiating $f$ with respect to $x$ and setting it to zero. Clearing out any positive coefficients we obtain
$$0 = -e^{2x\mu} p(x-\mu) + (1-p)(x+\mu).$$
Performing similar operations with the second derivative of $f$ and replacing $e^{2x\mu}$ by the value determined by the preceding equation tells us the sign of the second derivative at any critical point is the sign of
$$f^{\prime\prime}(x;\mu,p) \propto \frac{(1+x^2-\mu^2)}{x-\mu}.$$
Since the denominator is negative when $-\mu\lt x \lt \mu,$ the sign of $f^{\prime\prime}$ is that of $-(1-\mu^2 + x^2).$ It is clear that when $\mu\le 1,$ the sign must be negative. In a multimodal distribution, however (because the density is continuous), there must be an antimode between any two modes, where the sign is non-negative. Thus, when $\mu$ is less than $1$ (the SD), the distribution must be unimodal.
Since the separation of the means is $2\mu,$ the conclusion of this analysis is
A mixture of Normal distributions is unimodal whenever the means are separated by no more than twice the common standard deviation.
That's logically equivalent to the statement in the question.
|
Why is a mixture of two normally distributed variables only bimodal if their means differ by at leas
This is a case where pictures can be deceiving, because this result is a special characteristic of normal mixtures: an analog does not necessarily hold for other mixtures, even when the components are
|
8,735
|
Why is a mixture of two normally distributed variables only bimodal if their means differ by at least two times the common standard deviation?
|
Comment from above pasted here for continuity:
"[F]ormally, for a 50:50 mixture of two normal distributions with the same SD σ, if you write the density $$f(x)=0.5g_1(x)+0.5g_2(x)$$ in full form showing the parameters, you will see that its second derivative changes sign at the midpoint between the two means when the distance between means increases from below 2σ to above."
Comment continued:
In each case the two normal curves that are 'mixed'
have $\sigma=1.$ From left to right the distances between means are $3\sigma, 2\sigma,$ and $\sigma,$ respectively.
The concavity of the mixture density at the midpoint (1.5) between means changes from negative, to zero, to positive.
R code for the figure:
par(mfrow=c(1,3))
curve(dnorm(x, 0, 1)+dnorm(x,3,1), -3, 7, col="green3",
lwd=2,n=1001, ylab="PDF", main="3 SD: Dip")
curve(dnorm(x, .5, 1)+dnorm(x,2.5,1), -4, 7, col="orange",
lwd=2, n=1001,ylab="PDF", main="2 SD: Flat")
curve(dnorm(x, 1, 1)+dnorm(x,2,1), -4, 7, col="violet",
lwd=2, n=1001, ylab="PDF", main="1 SD: Peak")
par(mfrow=c(1,3))
|
Why is a mixture of two normally distributed variables only bimodal if their means differ by at leas
|
Comment from above pasted here for continuity:
"[F]ormally, for a 50:50 mixture of two normal distributions with the same SD σ, if you write the density $$f(x)=0.5g_1(x)+0.5g_2(x)$$ in full form showi
|
Why is a mixture of two normally distributed variables only bimodal if their means differ by at least two times the common standard deviation?
Comment from above pasted here for continuity:
"[F]ormally, for a 50:50 mixture of two normal distributions with the same SD σ, if you write the density $$f(x)=0.5g_1(x)+0.5g_2(x)$$ in full form showing the parameters, you will see that its second derivative changes sign at the midpoint between the two means when the distance between means increases from below 2σ to above."
Comment continued:
In each case the two normal curves that are 'mixed'
have $\sigma=1.$ From left to right the distances between means are $3\sigma, 2\sigma,$ and $\sigma,$ respectively.
The concavity of the mixture density at the midpoint (1.5) between means changes from negative, to zero, to positive.
R code for the figure:
par(mfrow=c(1,3))
curve(dnorm(x, 0, 1)+dnorm(x,3,1), -3, 7, col="green3",
lwd=2,n=1001, ylab="PDF", main="3 SD: Dip")
curve(dnorm(x, .5, 1)+dnorm(x,2.5,1), -4, 7, col="orange",
lwd=2, n=1001,ylab="PDF", main="2 SD: Flat")
curve(dnorm(x, 1, 1)+dnorm(x,2,1), -4, 7, col="violet",
lwd=2, n=1001, ylab="PDF", main="1 SD: Peak")
par(mfrow=c(1,3))
|
Why is a mixture of two normally distributed variables only bimodal if their means differ by at leas
Comment from above pasted here for continuity:
"[F]ormally, for a 50:50 mixture of two normal distributions with the same SD σ, if you write the density $$f(x)=0.5g_1(x)+0.5g_2(x)$$ in full form showi
|
8,736
|
Why Not Prune Your Neural Network?
|
Pruning is indeed remarkably effective and I think it is pretty commonly used on networks which are "deployed" for use after training.
The catch about pruning is that you can only increase efficiency, speed, etc. after training is done. You still have to train with the full size network. Most computation time throughout the lifetime of a model's development and deployment is spent during development: training networks, playing with model architectures, tweaking parameters, etc. You might train a network several hundred times before you settle on the final model. Reducing computation of the deployed network is a drop in the bucket compared to this.
Among ML researchers, we're mainly trying to improve training techniques for DNN's. We usually aren't concerned with deployment, so pruning isn't used there.
There is some research on utilizing pruning techniques to speed up network training, but not much progress has been made. See, for example, my own paper from 2018 which experimented with training on pruned and other structurally sparse NN architectures: https://arxiv.org/abs/1810.00299
|
Why Not Prune Your Neural Network?
|
Pruning is indeed remarkably effective and I think it is pretty commonly used on networks which are "deployed" for use after training.
The catch about pruning is that you can only increase efficiency,
|
Why Not Prune Your Neural Network?
Pruning is indeed remarkably effective and I think it is pretty commonly used on networks which are "deployed" for use after training.
The catch about pruning is that you can only increase efficiency, speed, etc. after training is done. You still have to train with the full size network. Most computation time throughout the lifetime of a model's development and deployment is spent during development: training networks, playing with model architectures, tweaking parameters, etc. You might train a network several hundred times before you settle on the final model. Reducing computation of the deployed network is a drop in the bucket compared to this.
Among ML researchers, we're mainly trying to improve training techniques for DNN's. We usually aren't concerned with deployment, so pruning isn't used there.
There is some research on utilizing pruning techniques to speed up network training, but not much progress has been made. See, for example, my own paper from 2018 which experimented with training on pruned and other structurally sparse NN architectures: https://arxiv.org/abs/1810.00299
|
Why Not Prune Your Neural Network?
Pruning is indeed remarkably effective and I think it is pretty commonly used on networks which are "deployed" for use after training.
The catch about pruning is that you can only increase efficiency,
|
8,737
|
Why Not Prune Your Neural Network?
|
In addition to the points raised in the other answers, a pruned network may not be faster. Common machine learning frameworks have very efficient optimizations for computing dense matrix multiplications (i.e. normal, unpruned layers), but those algorithms can't take any additional advantage of the fact that some weights are set to 0 (because they are pruned).
So the result of pruning is often a neural network that is smaller, but no faster and has worse performance. In many cases, better performance is more important than a smaller model size, so pruning is not useful in those cases.
Note that pruned networks could be faster if 1. an overwhelmingly large fraction of weights were pruned away, in which case sparse matrix multiplication algorithms might start being faster; or 2. (in CNNs; I'm not sure off the top of my head if this is applicable to other architectures) if pruning was not weight-level but rather channel-level (so either an entire channel is pruned all at once or the whole channel is left as is), which does work with the optimizations; or 3. given specialized hardware or ML frameworks.
|
Why Not Prune Your Neural Network?
|
In addition to the points raised in the other answers, a pruned network may not be faster. Common machine learning frameworks have very efficient optimizations for computing dense matrix multiplicatio
|
Why Not Prune Your Neural Network?
In addition to the points raised in the other answers, a pruned network may not be faster. Common machine learning frameworks have very efficient optimizations for computing dense matrix multiplications (i.e. normal, unpruned layers), but those algorithms can't take any additional advantage of the fact that some weights are set to 0 (because they are pruned).
So the result of pruning is often a neural network that is smaller, but no faster and has worse performance. In many cases, better performance is more important than a smaller model size, so pruning is not useful in those cases.
Note that pruned networks could be faster if 1. an overwhelmingly large fraction of weights were pruned away, in which case sparse matrix multiplication algorithms might start being faster; or 2. (in CNNs; I'm not sure off the top of my head if this is applicable to other architectures) if pruning was not weight-level but rather channel-level (so either an entire channel is pruned all at once or the whole channel is left as is), which does work with the optimizations; or 3. given specialized hardware or ML frameworks.
|
Why Not Prune Your Neural Network?
In addition to the points raised in the other answers, a pruned network may not be faster. Common machine learning frameworks have very efficient optimizations for computing dense matrix multiplicatio
|
8,738
|
Why Not Prune Your Neural Network?
|
As mentioned previously, you need to train on large networks in order to prune them. There are some theories as to why, but the one I'm most familiar with is the "golden ticket" theory. Presented in "The Lottery Ticket Hypothesis: Finding Sparse, Trainable Neural Networks" by Jonathan Frankle, Michael Carbin the golden ticket theory of neural networks asserts that there is a subset of the network which is already very close and what training does is to find and slightly improve this subset of the network, while downplaying the wrong parts of the network. A real-life analogy of this is that only a few of your lottery tickets will be worth anything but you need to buy a lot in order to find them.
There is a connection to the original rationale behind dropout: Train many networks 'in parallel' and some of the time you will be training the only the golden ticket network.
|
Why Not Prune Your Neural Network?
|
As mentioned previously, you need to train on large networks in order to prune them. There are some theories as to why, but the one I'm most familiar with is the "golden ticket" theory. Presented in "
|
Why Not Prune Your Neural Network?
As mentioned previously, you need to train on large networks in order to prune them. There are some theories as to why, but the one I'm most familiar with is the "golden ticket" theory. Presented in "The Lottery Ticket Hypothesis: Finding Sparse, Trainable Neural Networks" by Jonathan Frankle, Michael Carbin the golden ticket theory of neural networks asserts that there is a subset of the network which is already very close and what training does is to find and slightly improve this subset of the network, while downplaying the wrong parts of the network. A real-life analogy of this is that only a few of your lottery tickets will be worth anything but you need to buy a lot in order to find them.
There is a connection to the original rationale behind dropout: Train many networks 'in parallel' and some of the time you will be training the only the golden ticket network.
|
Why Not Prune Your Neural Network?
As mentioned previously, you need to train on large networks in order to prune them. There are some theories as to why, but the one I'm most familiar with is the "golden ticket" theory. Presented in "
|
8,739
|
How to understand "nonlinear" as in "nonlinear dimensionality reduction"?
|
Dimensionality reduction means that you map each many-dimensional vector into a low-dimensional vector. In other words, you represent (replace) each many-dimensional vector by a low-dimensional vector.
Linear dimensionality reduction means that components of the low-dimensional vector are given by linear functions of the components of the corresponding high-dimensional vector. For example in case of reduction to two dimensions we have:
[x1, x2, ..., xn] -> [f1(x1, x2, ..., xn), f2(x1, x2, ..., xn)]
If f1 and f2 are (non)linear functions, we have a (non)linear dimensionality reduction.
|
How to understand "nonlinear" as in "nonlinear dimensionality reduction"?
|
Dimensionality reduction means that you map each many-dimensional vector into a low-dimensional vector. In other words, you represent (replace) each many-dimensional vector by a low-dimensional vector
|
How to understand "nonlinear" as in "nonlinear dimensionality reduction"?
Dimensionality reduction means that you map each many-dimensional vector into a low-dimensional vector. In other words, you represent (replace) each many-dimensional vector by a low-dimensional vector.
Linear dimensionality reduction means that components of the low-dimensional vector are given by linear functions of the components of the corresponding high-dimensional vector. For example in case of reduction to two dimensions we have:
[x1, x2, ..., xn] -> [f1(x1, x2, ..., xn), f2(x1, x2, ..., xn)]
If f1 and f2 are (non)linear functions, we have a (non)linear dimensionality reduction.
|
How to understand "nonlinear" as in "nonlinear dimensionality reduction"?
Dimensionality reduction means that you map each many-dimensional vector into a low-dimensional vector. In other words, you represent (replace) each many-dimensional vector by a low-dimensional vector
|
8,740
|
How to understand "nonlinear" as in "nonlinear dimensionality reduction"?
|
A picture is worth a thousand words:
Here we are looking for 1-dimensional structure in 2D. The points lie along an S-shaped curve. PCA tries to describe the data with a linear 1-dimensional manifold, which is simply a line; of course a line fits these data quite bad. Isomap is looking for a nonlinear (i.e. curved!) 1-dimensional manifold, and should be able to discover the underlying S-shaped curve.
|
How to understand "nonlinear" as in "nonlinear dimensionality reduction"?
|
A picture is worth a thousand words:
Here we are looking for 1-dimensional structure in 2D. The points lie along an S-shaped curve. PCA tries to describe the data with a linear 1-dimensional manifold
|
How to understand "nonlinear" as in "nonlinear dimensionality reduction"?
A picture is worth a thousand words:
Here we are looking for 1-dimensional structure in 2D. The points lie along an S-shaped curve. PCA tries to describe the data with a linear 1-dimensional manifold, which is simply a line; of course a line fits these data quite bad. Isomap is looking for a nonlinear (i.e. curved!) 1-dimensional manifold, and should be able to discover the underlying S-shaped curve.
|
How to understand "nonlinear" as in "nonlinear dimensionality reduction"?
A picture is worth a thousand words:
Here we are looking for 1-dimensional structure in 2D. The points lie along an S-shaped curve. PCA tries to describe the data with a linear 1-dimensional manifold
|
8,741
|
Binomial confidence interval estimation - why is it not symmetric?
|
They're believed to be symmetric because quite often a normal approximation is used. This one works well enough in case p lies around 0.5. binom.test on the other hand reports "exact" Clopper-Pearson intervals, which are based on the F distribution (see here for the exact formulas of both approaches). If we would implement the Clopper-Pearson interval in R it would be something like (see note):
Clopper.Pearson <- function(x, n, conf.level){
alpha <- (1 - conf.level) / 2
QF.l <- qf(1 - alpha, 2*n - 2*x + 2, 2*x)
QF.u <- qf(1 - alpha, 2*x + 2, 2*n - 2*x)
ll <- if (x == 0){
0
} else { x / ( x + (n-x+1)*QF.l ) }
uu <- if (x == 0){
0
} else { (x+1)*QF.u / ( n - x + (x+1)*QF.u ) }
return(c(ll, uu))
}
You see both in the link and in the implementation that the formula for the upper and the lower limit are completely different. The only case of a symmetric confidence interval is when p=0.5. Using the formulas from the link and taking into account that in this case $n = 2\times x$ it's easy to derive yourself how it comes.
I personally understood it better looking at the confidence intervals based on a logistic approach. Binomial data is generally modeled using a logit link function, defined as:
$${\rm logit}(x) = \log\! \bigg( \frac{x}{1-x} \bigg)$$
This link function "maps" the error term in a logistic regression to a normal distribution. As a consequence, confidence intervals in the logistic framework are symmetric around the logit values, much like in the classic linear regression framework. The logit transformation is used exactly to allow for using the whole normality-based theory around the linear regression.
After doing the inverse transformation:
$${\rm logit}^{-1}(x) = \frac{e^x}{1+e^{x}}$$
You get an asymmetric interval again. Now these confidence intervals are actually biased. Their coverage is not what you would expect, especially at the boundaries of the binomial distribution. Yet, as an illustration they show you why it is logic that a binomial distribution has asymmetric confidence intervals.
An example in R:
logit <- function(x){ log(x/(1-x)) }
inv.logit <- function(x){ exp(x)/(1+exp(x)) }
x <- c(0.2, 0.5, 0.8)
lx <- logit(x)
upper <- lx + 2
lower <- lx - 2
logxtab <- cbind(lx, upper, lower)
logxtab # the confidence intervals are symmetric by construction
xtab <- inv.logit(logxtab)
xtab # back transformation gives asymmetric confidence intervals
note : In fact, R uses the beta distribution, but this is completely equivalent and computationally a bit more efficient. The implementation in R is thus different from what I show here, but it gives exactly the same result.
|
Binomial confidence interval estimation - why is it not symmetric?
|
They're believed to be symmetric because quite often a normal approximation is used. This one works well enough in case p lies around 0.5. binom.test on the other hand reports "exact" Clopper-Pearson
|
Binomial confidence interval estimation - why is it not symmetric?
They're believed to be symmetric because quite often a normal approximation is used. This one works well enough in case p lies around 0.5. binom.test on the other hand reports "exact" Clopper-Pearson intervals, which are based on the F distribution (see here for the exact formulas of both approaches). If we would implement the Clopper-Pearson interval in R it would be something like (see note):
Clopper.Pearson <- function(x, n, conf.level){
alpha <- (1 - conf.level) / 2
QF.l <- qf(1 - alpha, 2*n - 2*x + 2, 2*x)
QF.u <- qf(1 - alpha, 2*x + 2, 2*n - 2*x)
ll <- if (x == 0){
0
} else { x / ( x + (n-x+1)*QF.l ) }
uu <- if (x == 0){
0
} else { (x+1)*QF.u / ( n - x + (x+1)*QF.u ) }
return(c(ll, uu))
}
You see both in the link and in the implementation that the formula for the upper and the lower limit are completely different. The only case of a symmetric confidence interval is when p=0.5. Using the formulas from the link and taking into account that in this case $n = 2\times x$ it's easy to derive yourself how it comes.
I personally understood it better looking at the confidence intervals based on a logistic approach. Binomial data is generally modeled using a logit link function, defined as:
$${\rm logit}(x) = \log\! \bigg( \frac{x}{1-x} \bigg)$$
This link function "maps" the error term in a logistic regression to a normal distribution. As a consequence, confidence intervals in the logistic framework are symmetric around the logit values, much like in the classic linear regression framework. The logit transformation is used exactly to allow for using the whole normality-based theory around the linear regression.
After doing the inverse transformation:
$${\rm logit}^{-1}(x) = \frac{e^x}{1+e^{x}}$$
You get an asymmetric interval again. Now these confidence intervals are actually biased. Their coverage is not what you would expect, especially at the boundaries of the binomial distribution. Yet, as an illustration they show you why it is logic that a binomial distribution has asymmetric confidence intervals.
An example in R:
logit <- function(x){ log(x/(1-x)) }
inv.logit <- function(x){ exp(x)/(1+exp(x)) }
x <- c(0.2, 0.5, 0.8)
lx <- logit(x)
upper <- lx + 2
lower <- lx - 2
logxtab <- cbind(lx, upper, lower)
logxtab # the confidence intervals are symmetric by construction
xtab <- inv.logit(logxtab)
xtab # back transformation gives asymmetric confidence intervals
note : In fact, R uses the beta distribution, but this is completely equivalent and computationally a bit more efficient. The implementation in R is thus different from what I show here, but it gives exactly the same result.
|
Binomial confidence interval estimation - why is it not symmetric?
They're believed to be symmetric because quite often a normal approximation is used. This one works well enough in case p lies around 0.5. binom.test on the other hand reports "exact" Clopper-Pearson
|
8,742
|
Binomial confidence interval estimation - why is it not symmetric?
|
To see why it should not be symmetric, think of the situation where $p=0.9$ and you get 9 successes in 10 trials. Then $\hat{p}=0.9$ and the 95% CI for $p$ is [0.554, 0.997]. The upper limit cannot be greater than 1 obviously, so most of the uncertainty must fall to the left of $\hat{p}$.
|
Binomial confidence interval estimation - why is it not symmetric?
|
To see why it should not be symmetric, think of the situation where $p=0.9$ and you get 9 successes in 10 trials. Then $\hat{p}=0.9$ and the 95% CI for $p$ is [0.554, 0.997]. The upper limit cannot be
|
Binomial confidence interval estimation - why is it not symmetric?
To see why it should not be symmetric, think of the situation where $p=0.9$ and you get 9 successes in 10 trials. Then $\hat{p}=0.9$ and the 95% CI for $p$ is [0.554, 0.997]. The upper limit cannot be greater than 1 obviously, so most of the uncertainty must fall to the left of $\hat{p}$.
|
Binomial confidence interval estimation - why is it not symmetric?
To see why it should not be symmetric, think of the situation where $p=0.9$ and you get 9 successes in 10 trials. Then $\hat{p}=0.9$ and the 95% CI for $p$ is [0.554, 0.997]. The upper limit cannot be
|
8,743
|
Binomial confidence interval estimation - why is it not symmetric?
|
There are symmetric confidence intervals for the Binomial distribution: asymmetry is not forced on us, despite all the reasons already mentioned. The symmetric intervals are usually considered inferior in that
Although they are numerically symmetric, they are not symmetric in probability: that is, their one-tailed coverages differ from each other. This--a necessary consequence of the possible asymmetry of the Binomial distribution--is the crux of the matter.
Often one endpoint has to be unrealistic (less than 0 or greater than 1), as @Rob Hyndman points out.
Having said that, I suspect that numerically symmetric CIs might have some good properties, such as tending to be shorter than the probabilistically symmetric ones in some circumstances.
|
Binomial confidence interval estimation - why is it not symmetric?
|
There are symmetric confidence intervals for the Binomial distribution: asymmetry is not forced on us, despite all the reasons already mentioned. The symmetric intervals are usually considered inferi
|
Binomial confidence interval estimation - why is it not symmetric?
There are symmetric confidence intervals for the Binomial distribution: asymmetry is not forced on us, despite all the reasons already mentioned. The symmetric intervals are usually considered inferior in that
Although they are numerically symmetric, they are not symmetric in probability: that is, their one-tailed coverages differ from each other. This--a necessary consequence of the possible asymmetry of the Binomial distribution--is the crux of the matter.
Often one endpoint has to be unrealistic (less than 0 or greater than 1), as @Rob Hyndman points out.
Having said that, I suspect that numerically symmetric CIs might have some good properties, such as tending to be shorter than the probabilistically symmetric ones in some circumstances.
|
Binomial confidence interval estimation - why is it not symmetric?
There are symmetric confidence intervals for the Binomial distribution: asymmetry is not forced on us, despite all the reasons already mentioned. The symmetric intervals are usually considered inferi
|
8,744
|
Binomial confidence interval estimation - why is it not symmetric?
|
@Joris mentioned the symmetric or "asymptotic" interval, that is most likely the one you are expecting. @Joris also mentioned the "exact" Clopper-Pearson intervals and gave you a reference which looks very nice. There is another confidence interval for proportions which you will likely encounter (note it is also not symmetric), the "Wilson" interval which is a type of asymptotic interval based on inverting the score test. The endpoints of the interval solve (in $p$) the equation
$$
(\hat{p} - p)/\sqrt{p(1-p)}=\pm z_{\alpha/2}
$$
Anyway, you can get all three in R with the following:
library(Hmisc)
binconf(29, 38, method = "asymptotic")
binconf(29, 38, method = "exact")
binconf(29, 38, method = "wilson")
Note that method "wilson" is the same confidence interval used by prop.test without Yates' continuity correction:
prop.test(29, 38, correct = FALSE)
See here for Laura Thompson's free SPLUS + R manual which accompanies Agresti's Categorical Data Analysis in which these issues are discussed in great detail.
|
Binomial confidence interval estimation - why is it not symmetric?
|
@Joris mentioned the symmetric or "asymptotic" interval, that is most likely the one you are expecting. @Joris also mentioned the "exact" Clopper-Pearson intervals and gave you a reference which look
|
Binomial confidence interval estimation - why is it not symmetric?
@Joris mentioned the symmetric or "asymptotic" interval, that is most likely the one you are expecting. @Joris also mentioned the "exact" Clopper-Pearson intervals and gave you a reference which looks very nice. There is another confidence interval for proportions which you will likely encounter (note it is also not symmetric), the "Wilson" interval which is a type of asymptotic interval based on inverting the score test. The endpoints of the interval solve (in $p$) the equation
$$
(\hat{p} - p)/\sqrt{p(1-p)}=\pm z_{\alpha/2}
$$
Anyway, you can get all three in R with the following:
library(Hmisc)
binconf(29, 38, method = "asymptotic")
binconf(29, 38, method = "exact")
binconf(29, 38, method = "wilson")
Note that method "wilson" is the same confidence interval used by prop.test without Yates' continuity correction:
prop.test(29, 38, correct = FALSE)
See here for Laura Thompson's free SPLUS + R manual which accompanies Agresti's Categorical Data Analysis in which these issues are discussed in great detail.
|
Binomial confidence interval estimation - why is it not symmetric?
@Joris mentioned the symmetric or "asymptotic" interval, that is most likely the one you are expecting. @Joris also mentioned the "exact" Clopper-Pearson intervals and gave you a reference which look
|
8,745
|
Binomial confidence interval estimation - why is it not symmetric?
|
Binomial distribution is just not symmetric, yet this fact emerges especially for $p$ near $0$ or $1$ and for small $n$; most people use it for $p\approx 0.5$ and so the confusion.
|
Binomial confidence interval estimation - why is it not symmetric?
|
Binomial distribution is just not symmetric, yet this fact emerges especially for $p$ near $0$ or $1$ and for small $n$; most people use it for $p\approx 0.5$ and so the confusion.
|
Binomial confidence interval estimation - why is it not symmetric?
Binomial distribution is just not symmetric, yet this fact emerges especially for $p$ near $0$ or $1$ and for small $n$; most people use it for $p\approx 0.5$ and so the confusion.
|
Binomial confidence interval estimation - why is it not symmetric?
Binomial distribution is just not symmetric, yet this fact emerges especially for $p$ near $0$ or $1$ and for small $n$; most people use it for $p\approx 0.5$ and so the confusion.
|
8,746
|
Binomial confidence interval estimation - why is it not symmetric?
|
I know that it has been a while, but I thought that I would chime in here. Given n and p, it is simple to compute the probability of a particular number of successes directly using the binomial distribution. One can then examine the distribution to see that it is not symmetric. It will approach symmetry for large np and large n(1-p).
One can accumulate the probabilities in the tails to compute a particular CI. Given the discrete nature of the distribution, finding a particular probability in a tail (e.g., 2.5% for a 95% CI) will require interpolation between the number of successes. With this method, one can compute CIs directly without approximation (other than the required interpolation).
|
Binomial confidence interval estimation - why is it not symmetric?
|
I know that it has been a while, but I thought that I would chime in here. Given n and p, it is simple to compute the probability of a particular number of successes directly using the binomial distr
|
Binomial confidence interval estimation - why is it not symmetric?
I know that it has been a while, but I thought that I would chime in here. Given n and p, it is simple to compute the probability of a particular number of successes directly using the binomial distribution. One can then examine the distribution to see that it is not symmetric. It will approach symmetry for large np and large n(1-p).
One can accumulate the probabilities in the tails to compute a particular CI. Given the discrete nature of the distribution, finding a particular probability in a tail (e.g., 2.5% for a 95% CI) will require interpolation between the number of successes. With this method, one can compute CIs directly without approximation (other than the required interpolation).
|
Binomial confidence interval estimation - why is it not symmetric?
I know that it has been a while, but I thought that I would chime in here. Given n and p, it is simple to compute the probability of a particular number of successes directly using the binomial distr
|
8,747
|
What is the expected correlation between residual and the dependent variable?
|
In the regression model:
$$y_i=\mathbf{x}_i'\beta+u_i$$
the usual assumption is that $(y_i,\mathbf{x}_i,u_i)$, $i=1,...,n$ is an iid sample. Under assumptions that $E\mathbf{x}_iu_i=0$ and $E(\mathbf{x}_i\mathbf{x}_i')$ has full rank, the ordinary least squares estimator:
$$\widehat{\beta}=\left(\sum_{i=1}^n\mathbf{x}_i\mathbf{x}_i'\right)^{-1}\sum_{i=1}\mathbf{x}_iy_i$$
is consistent and asymptotically normal. The expected covariance between a residual and the response variable then is:
$$Ey_iu_i=E(\mathbf{x}_i'\beta+u_i)u_i=Eu_i^2$$
If we furthermore assume that $E(u_i|\mathbf{x}_1,...,\mathbf{x}_n)=0$ and $E(u_i^2|\mathbf{x}_1,...,\mathbf{x}_n)=\sigma^2$, we can calculate the expected covariance between $y_i$ and its regression residual:
$$\begin{align*}
Ey_i\widehat{u}_i&=Ey_i(y_i-\mathbf{x}_i'\widehat{\beta})\\\\
&=E(\mathbf{x}_i'\beta+u_i)(u_i-\mathbf{x}_i(\widehat{\beta}-\beta))\\\\
&=E(u_i^2)\left(1-E\mathbf{x}_i' \left(\sum_{j=1}^n\mathbf{x}_j\mathbf{x}_j'\right)^{-1}\mathbf{x}_i\right)
\end{align*}$$
Now to get the correlation we need to calculate $\text{Var}(y_i)$ and $\text{Var}(\hat{u}_i)$. It turns out that
$$\text{Var}(\hat u_i)=E(y_i\hat{u}_i),$$
hence
$$\text{Corr}(y_i,\hat u_i)=\sqrt{1-E\mathbf{x}_i' \left(\sum_{j=1}^n\mathbf{x}_j\mathbf{x}_j'\right)^{-1}\mathbf{x}_i}$$
Now the term $\mathbf{x}_i' \left(\sum_{j=1}^n\mathbf{x}_j\mathbf{x}_j'\right)^{-1}\mathbf{x}_i$ comes from diagonal of the hat matrix $H=X(X'X)^{-1}X'$, where $X=[\mathbf{x}_i,...,\mathbf{x}_N]'$. The matrix $H$ is idempotent, hence it satisfies a following property
$$\text{trace}(H)=\sum_{i}h_{ii}=\text{rank}(H),$$
where $h_{ii}$ is the diagonal term of $H$. The $\text{rank}(H)$ is the number of linearly independent variables in $\mathbf{x}_i$, which is usually the number of variables. Let us call it $p$. The number of $h_{ii}$ is the sample size $N$. So we have $N$ nonnegative terms which should sum up to $p$. Usually $N$ is much bigger than $p$, hence a lot of $h_{ii}$ would be close to the zero, meaning that the correlation between the residual and the response variable would be close to 1 for the bigger part of observations.
The term $h_{ii}$ is also used in various regression diagnostics for determining influential observations.
|
What is the expected correlation between residual and the dependent variable?
|
In the regression model:
$$y_i=\mathbf{x}_i'\beta+u_i$$
the usual assumption is that $(y_i,\mathbf{x}_i,u_i)$, $i=1,...,n$ is an iid sample. Under assumptions that $E\mathbf{x}_iu_i=0$ and $E(\mathbf{
|
What is the expected correlation between residual and the dependent variable?
In the regression model:
$$y_i=\mathbf{x}_i'\beta+u_i$$
the usual assumption is that $(y_i,\mathbf{x}_i,u_i)$, $i=1,...,n$ is an iid sample. Under assumptions that $E\mathbf{x}_iu_i=0$ and $E(\mathbf{x}_i\mathbf{x}_i')$ has full rank, the ordinary least squares estimator:
$$\widehat{\beta}=\left(\sum_{i=1}^n\mathbf{x}_i\mathbf{x}_i'\right)^{-1}\sum_{i=1}\mathbf{x}_iy_i$$
is consistent and asymptotically normal. The expected covariance between a residual and the response variable then is:
$$Ey_iu_i=E(\mathbf{x}_i'\beta+u_i)u_i=Eu_i^2$$
If we furthermore assume that $E(u_i|\mathbf{x}_1,...,\mathbf{x}_n)=0$ and $E(u_i^2|\mathbf{x}_1,...,\mathbf{x}_n)=\sigma^2$, we can calculate the expected covariance between $y_i$ and its regression residual:
$$\begin{align*}
Ey_i\widehat{u}_i&=Ey_i(y_i-\mathbf{x}_i'\widehat{\beta})\\\\
&=E(\mathbf{x}_i'\beta+u_i)(u_i-\mathbf{x}_i(\widehat{\beta}-\beta))\\\\
&=E(u_i^2)\left(1-E\mathbf{x}_i' \left(\sum_{j=1}^n\mathbf{x}_j\mathbf{x}_j'\right)^{-1}\mathbf{x}_i\right)
\end{align*}$$
Now to get the correlation we need to calculate $\text{Var}(y_i)$ and $\text{Var}(\hat{u}_i)$. It turns out that
$$\text{Var}(\hat u_i)=E(y_i\hat{u}_i),$$
hence
$$\text{Corr}(y_i,\hat u_i)=\sqrt{1-E\mathbf{x}_i' \left(\sum_{j=1}^n\mathbf{x}_j\mathbf{x}_j'\right)^{-1}\mathbf{x}_i}$$
Now the term $\mathbf{x}_i' \left(\sum_{j=1}^n\mathbf{x}_j\mathbf{x}_j'\right)^{-1}\mathbf{x}_i$ comes from diagonal of the hat matrix $H=X(X'X)^{-1}X'$, where $X=[\mathbf{x}_i,...,\mathbf{x}_N]'$. The matrix $H$ is idempotent, hence it satisfies a following property
$$\text{trace}(H)=\sum_{i}h_{ii}=\text{rank}(H),$$
where $h_{ii}$ is the diagonal term of $H$. The $\text{rank}(H)$ is the number of linearly independent variables in $\mathbf{x}_i$, which is usually the number of variables. Let us call it $p$. The number of $h_{ii}$ is the sample size $N$. So we have $N$ nonnegative terms which should sum up to $p$. Usually $N$ is much bigger than $p$, hence a lot of $h_{ii}$ would be close to the zero, meaning that the correlation between the residual and the response variable would be close to 1 for the bigger part of observations.
The term $h_{ii}$ is also used in various regression diagnostics for determining influential observations.
|
What is the expected correlation between residual and the dependent variable?
In the regression model:
$$y_i=\mathbf{x}_i'\beta+u_i$$
the usual assumption is that $(y_i,\mathbf{x}_i,u_i)$, $i=1,...,n$ is an iid sample. Under assumptions that $E\mathbf{x}_iu_i=0$ and $E(\mathbf{
|
8,748
|
What is the expected correlation between residual and the dependent variable?
|
The correlation depends on the $R^2$. If $R^2$ is high, it means that much of variation in your dependent variable can be attributed to variation in your independent variables, and NOT your error term.
However, if $R^2$ is low, then it means that much of the variation in your dependent variable is unrelated to variation in your independent variables, and thus must be related to the error term.
Consider the following model:
$Y=X\beta+\varepsilon$, where $Y$ and $X$ are uncorrelated.
Assuming sufficient regularity conditions for the CLT to hold.
$\hat{\beta}$ will converge to $0$, since $X$ and $Y$ are uncorrelated. Therefore $\hat{Y}=X\hat{\beta}$ will always be zero. Thus, the $\varepsilon:=Y-\hat{Y}=Y-0=Y$. $\varepsilon$ and $Y$ are perfectly correlated!!!
Holding all else fixed, increasing the $R^2$ will decrease the correlation between the error an the dependent. A strong correlation is not necessarily cause for alarm. This may simply means the underlying process is noisy. However, a low $R^2$ (and hence high correlation between error and dependent) may be due to model misspecification.
|
What is the expected correlation between residual and the dependent variable?
|
The correlation depends on the $R^2$. If $R^2$ is high, it means that much of variation in your dependent variable can be attributed to variation in your independent variables, and NOT your error ter
|
What is the expected correlation between residual and the dependent variable?
The correlation depends on the $R^2$. If $R^2$ is high, it means that much of variation in your dependent variable can be attributed to variation in your independent variables, and NOT your error term.
However, if $R^2$ is low, then it means that much of the variation in your dependent variable is unrelated to variation in your independent variables, and thus must be related to the error term.
Consider the following model:
$Y=X\beta+\varepsilon$, where $Y$ and $X$ are uncorrelated.
Assuming sufficient regularity conditions for the CLT to hold.
$\hat{\beta}$ will converge to $0$, since $X$ and $Y$ are uncorrelated. Therefore $\hat{Y}=X\hat{\beta}$ will always be zero. Thus, the $\varepsilon:=Y-\hat{Y}=Y-0=Y$. $\varepsilon$ and $Y$ are perfectly correlated!!!
Holding all else fixed, increasing the $R^2$ will decrease the correlation between the error an the dependent. A strong correlation is not necessarily cause for alarm. This may simply means the underlying process is noisy. However, a low $R^2$ (and hence high correlation between error and dependent) may be due to model misspecification.
|
What is the expected correlation between residual and the dependent variable?
The correlation depends on the $R^2$. If $R^2$ is high, it means that much of variation in your dependent variable can be attributed to variation in your independent variables, and NOT your error ter
|
8,749
|
What is the expected correlation between residual and the dependent variable?
|
I find this topic quite interesting and current answers are unfortunately incomplete or partly misleading - despite the relevance and high popularity of this question.
By definition of classical OLS framework there should be no relationship between $y ̂$ and $\hat u$, since the residuals obtained are per construction uncorrelated with $y ̂$ when deriving the OLS estimator. The variance minimizing property under homoskedasticity ensures that the residual error are randomly spread around the fitted values. This can be formally shown by:
$$\text{Cov}(y ̂,u ̂|X)=\text{Cov}(Py,My|X)=\text{Cov}(Py,(I-P)y|X)=P\text{Cov}(y,y)(I-P)'$$
$$=Pσ^2-Pσ^2=0$$
Where $M$ and $P$ are idempotent matrices defined as: $P=X(X' X)X'$ and $M=I-P$.
This result is based on strict exogeneity and homoskedasticity, and practically holds in large samples. The intuition for their uncorrelatedness is the following: The fitted values $y ̂$ conditional on $X$ are centered around $u ̂$, which are thought as independently and identically distributed. However, any deviation from the strict exogeneity and homoskedasticity assumption could cause the explanatory variables to be endogenous and spur a latent correlation between $u ̂$ and $y ̂$.
Now the correlation between the residuals $u ̂$ and the "original" $y$ is a completely different story:
$$\text{Cov}(y,u ̂|X)=\text{Cov}(yMy|X)=\text{Cov}(y,(1-P)y)=\text{Cov}(y,y)(1-P)=σ^2 M$$
Some checking in the theory and we know that this covariance matrix is identical to the covariance matrix of the residual $\hat{u}$ itself (proof omitted). We have:
$$\text{Var}(u ̂ )=σ^2 M=\text{Cov}(y,u ̂|X)$$
If we would like to calculate the (scalar) covariance between $y$ and $\hat{u}$ as requested by the OP, we obtain:
$$\implies \text{Cov}_{scalar}(y,u ̂|X)=\text{Var}(u ̂|X)=\left(∑u_i^2 \right)/N$$
(= by summing up of the diagonal entries of the covariance matrix and divide by N)
The above formula indicates an interesting point. If we test the relationship by regressing $y$ on the residuals $\hat{u}$ (+constant), the slope coefficient $\beta_{\hat{u},y}=1$, which can be easily derived when we divide the above expression by the $\text{Var}(u ̂|X)$.
On the other hand, the correlation is the standardized covariance by the respective standard deviations. Now, the variance matrix of the residuals is $σ^2 M$, while the variance of $y$ is $σ^2 I$. The correlation $\text{Corr}(y,u ̂ )$ becomes therefore:
$$\text{Corr}(y,u ̂ )=\frac{\text{Var}(u ̂ )}{\sqrt{\text{Var}(\hat{u})\text{Var}(y)}}=\sqrt{\frac{\text{Var}(u ̂ )}{\text{Var}(y)} }=\sqrt{\frac{\text{Var}(u ̂ )}{σ^2 }}$$
This is the core result which ought to hold in a linear regression. The intuition is that the $\text{Corr}(y,u ̂ )$ expresses the error between the true variance of the error term and a proxy for the variance based on residuals. Notice that the variance of $y$ is equal to the variance of $\hat{y}$ plus the variance of the residuals $\hat{u}$. So it can be more intuitively rewritten as:
$$\text{Corr}(y,u ̂ )=\frac{1}{\sqrt{1+\frac{\text{Var}(\hat{y)}}{\text{Var}(u ̂ )}}}$$
The are two forces here at work. If we have a great fit of the regression line, the correlation is expected to be low due to $\text{Var}(u ̂ )\approx 0$. On the other hand, $\text{Var}(\hat{y})$ is a bit of a fudge to esteem as it is unconditional and a line in parameter space. Comparing an unconditional and conditional variances within a ratio may not be an appropriate indicator after all. Perhaps, that's why it rarely done in practice.
An attempt conclude the question: The correlation between $y$ and $u ̂$ is positive and relates to the ratio of the variance of the residuals and the variance of the true error term, proxied by the unconditional variance in $y$. Hence, it is a bit of a misleading indicator.
Notwithstanding this exercise may give us some intuition on the workings and inherent theoretical assumptions of an OLS regression, we rarely evaluate the correlation between $y$ and $u ̂$. There are certainly more established tests for checking properties of the true error term. Secondly, keep in mind that the residuals are not the error term, and tests on residuals $u ̂$ that make predictions of the characteristics on the true error term $u$ are limited and their validity need to be handled with utmost care.
For example, I would like to point out a statement made by a previous poster here. It is said that,
"If your residuals are correlated with your independent variables, then your model is heteroskedastic..."
I think that may not be entirely valid in this context. Believe it or not, but the OLS residuals $u ̂$ are by construction made to be uncorrelated with the independent variable $x_k$. To see this, consider:
$$X'u_i=X'My=X'(I-P)y=X'y-X'Py$$
$$=X'y-X'X(X'X)X'y=X'y-X'y=0$$
$$\implies X'u_i=0 \implies \text{Cov}(X',u_i|X)=0 \implies \text{Cov}(x_{ki},u_i|x_ki)=0$$
However, you may have heard claims that an explanatory variable is correlated with the error term. Notice that such claims are based on assumptions about the whole population with a true underlying regression model, that we do not observe first hand. Consequently, checking the correlation between $y$ and $u ̂$ seems pointless in a linear OLS framework. However, when testing for heteroskedasticity, we take here into account the second conditional moment, for example, we regress the squared residuals on $X$ or a function of $X$, as it is often the case with FGSL estimators. This is different from evaluating the plain correlation. I hope this helps to make matters more clear.
|
What is the expected correlation between residual and the dependent variable?
|
I find this topic quite interesting and current answers are unfortunately incomplete or partly misleading - despite the relevance and high popularity of this question.
By definition of classical OLS f
|
What is the expected correlation between residual and the dependent variable?
I find this topic quite interesting and current answers are unfortunately incomplete or partly misleading - despite the relevance and high popularity of this question.
By definition of classical OLS framework there should be no relationship between $y ̂$ and $\hat u$, since the residuals obtained are per construction uncorrelated with $y ̂$ when deriving the OLS estimator. The variance minimizing property under homoskedasticity ensures that the residual error are randomly spread around the fitted values. This can be formally shown by:
$$\text{Cov}(y ̂,u ̂|X)=\text{Cov}(Py,My|X)=\text{Cov}(Py,(I-P)y|X)=P\text{Cov}(y,y)(I-P)'$$
$$=Pσ^2-Pσ^2=0$$
Where $M$ and $P$ are idempotent matrices defined as: $P=X(X' X)X'$ and $M=I-P$.
This result is based on strict exogeneity and homoskedasticity, and practically holds in large samples. The intuition for their uncorrelatedness is the following: The fitted values $y ̂$ conditional on $X$ are centered around $u ̂$, which are thought as independently and identically distributed. However, any deviation from the strict exogeneity and homoskedasticity assumption could cause the explanatory variables to be endogenous and spur a latent correlation between $u ̂$ and $y ̂$.
Now the correlation between the residuals $u ̂$ and the "original" $y$ is a completely different story:
$$\text{Cov}(y,u ̂|X)=\text{Cov}(yMy|X)=\text{Cov}(y,(1-P)y)=\text{Cov}(y,y)(1-P)=σ^2 M$$
Some checking in the theory and we know that this covariance matrix is identical to the covariance matrix of the residual $\hat{u}$ itself (proof omitted). We have:
$$\text{Var}(u ̂ )=σ^2 M=\text{Cov}(y,u ̂|X)$$
If we would like to calculate the (scalar) covariance between $y$ and $\hat{u}$ as requested by the OP, we obtain:
$$\implies \text{Cov}_{scalar}(y,u ̂|X)=\text{Var}(u ̂|X)=\left(∑u_i^2 \right)/N$$
(= by summing up of the diagonal entries of the covariance matrix and divide by N)
The above formula indicates an interesting point. If we test the relationship by regressing $y$ on the residuals $\hat{u}$ (+constant), the slope coefficient $\beta_{\hat{u},y}=1$, which can be easily derived when we divide the above expression by the $\text{Var}(u ̂|X)$.
On the other hand, the correlation is the standardized covariance by the respective standard deviations. Now, the variance matrix of the residuals is $σ^2 M$, while the variance of $y$ is $σ^2 I$. The correlation $\text{Corr}(y,u ̂ )$ becomes therefore:
$$\text{Corr}(y,u ̂ )=\frac{\text{Var}(u ̂ )}{\sqrt{\text{Var}(\hat{u})\text{Var}(y)}}=\sqrt{\frac{\text{Var}(u ̂ )}{\text{Var}(y)} }=\sqrt{\frac{\text{Var}(u ̂ )}{σ^2 }}$$
This is the core result which ought to hold in a linear regression. The intuition is that the $\text{Corr}(y,u ̂ )$ expresses the error between the true variance of the error term and a proxy for the variance based on residuals. Notice that the variance of $y$ is equal to the variance of $\hat{y}$ plus the variance of the residuals $\hat{u}$. So it can be more intuitively rewritten as:
$$\text{Corr}(y,u ̂ )=\frac{1}{\sqrt{1+\frac{\text{Var}(\hat{y)}}{\text{Var}(u ̂ )}}}$$
The are two forces here at work. If we have a great fit of the regression line, the correlation is expected to be low due to $\text{Var}(u ̂ )\approx 0$. On the other hand, $\text{Var}(\hat{y})$ is a bit of a fudge to esteem as it is unconditional and a line in parameter space. Comparing an unconditional and conditional variances within a ratio may not be an appropriate indicator after all. Perhaps, that's why it rarely done in practice.
An attempt conclude the question: The correlation between $y$ and $u ̂$ is positive and relates to the ratio of the variance of the residuals and the variance of the true error term, proxied by the unconditional variance in $y$. Hence, it is a bit of a misleading indicator.
Notwithstanding this exercise may give us some intuition on the workings and inherent theoretical assumptions of an OLS regression, we rarely evaluate the correlation between $y$ and $u ̂$. There are certainly more established tests for checking properties of the true error term. Secondly, keep in mind that the residuals are not the error term, and tests on residuals $u ̂$ that make predictions of the characteristics on the true error term $u$ are limited and their validity need to be handled with utmost care.
For example, I would like to point out a statement made by a previous poster here. It is said that,
"If your residuals are correlated with your independent variables, then your model is heteroskedastic..."
I think that may not be entirely valid in this context. Believe it or not, but the OLS residuals $u ̂$ are by construction made to be uncorrelated with the independent variable $x_k$. To see this, consider:
$$X'u_i=X'My=X'(I-P)y=X'y-X'Py$$
$$=X'y-X'X(X'X)X'y=X'y-X'y=0$$
$$\implies X'u_i=0 \implies \text{Cov}(X',u_i|X)=0 \implies \text{Cov}(x_{ki},u_i|x_ki)=0$$
However, you may have heard claims that an explanatory variable is correlated with the error term. Notice that such claims are based on assumptions about the whole population with a true underlying regression model, that we do not observe first hand. Consequently, checking the correlation between $y$ and $u ̂$ seems pointless in a linear OLS framework. However, when testing for heteroskedasticity, we take here into account the second conditional moment, for example, we regress the squared residuals on $X$ or a function of $X$, as it is often the case with FGSL estimators. This is different from evaluating the plain correlation. I hope this helps to make matters more clear.
|
What is the expected correlation between residual and the dependent variable?
I find this topic quite interesting and current answers are unfortunately incomplete or partly misleading - despite the relevance and high popularity of this question.
By definition of classical OLS f
|
8,750
|
What is the expected correlation between residual and the dependent variable?
|
The Adam's answer is wrong. Even with a model that fits data perfectly, you can still get high correlation between residuals and dependent variable. That's the reason no regression book asks you to check this correlation. You can find the answer on Dr. Draper's "Applied Regression Analysis" book.
|
What is the expected correlation between residual and the dependent variable?
|
The Adam's answer is wrong. Even with a model that fits data perfectly, you can still get high correlation between residuals and dependent variable. That's the reason no regression book asks you to ch
|
What is the expected correlation between residual and the dependent variable?
The Adam's answer is wrong. Even with a model that fits data perfectly, you can still get high correlation between residuals and dependent variable. That's the reason no regression book asks you to check this correlation. You can find the answer on Dr. Draper's "Applied Regression Analysis" book.
|
What is the expected correlation between residual and the dependent variable?
The Adam's answer is wrong. Even with a model that fits data perfectly, you can still get high correlation between residuals and dependent variable. That's the reason no regression book asks you to ch
|
8,751
|
What is the expected correlation between residual and the dependent variable?
|
So, the residuals are your unexplained variance, the difference between your model's predictions and the actual outcome you're modeling. In practice, few models produced through linear regression will have all residuals close to zero unless linear regression is being used to analyze a mechanical or fixed process.
Ideally, the residuals from your model should be random, meaning they should not be correlated with either your independent or dependent variables (what you term the criterion variable). In linear regression, your error term is normally distributed, so your residuals should also be normally distributed as well. If you have significant outliers, or If your residuals are correlated with either your dependent variable or your independent variables, then you have a problem with your model.
If you have significant outliers and non-normal distribution of your residuals, then the outliers may be skewing your weights (Betas), and I would suggest calculating DFBETAS to check the influence of your observations on your weights. If your residuals are correlated with your dependent variable, then there is a significantly large amount of unexplained variance that you are not accounting for. You may also see this if you're analyzing repeated observations of the same thing, due to autocorrelation. This can be checked for by seeing if your residuals are correlated with your time or index variable. If your residuals are correlated with your independent variables, then your model is heteroskedastic (see: http://en.wikipedia.org/wiki/Heteroscedasticity). You should check (if you haven't already) if your input variables are normally distributed, and if not, then you should consider scaling or transforming your data (the most common kinds are log and square-root) in order to make it more normalized.
In the case of both, your residuals, and your independent variables, you should take a QQ-Plot, as well as perform a Kolmogorov-Smirnov test (this particular implementation is sometimes referred to as the Lilliefors test) to make sure that your values fit a normal distribution.
Three things that are quick and may be helpful in dealing with this problem, are examining the median of your residuals, it should be as close to zero as possible (the mean will almost always be zero as a result of how the error term is fitted in linear regression), a Durbin-Watson test for autocorrelation in your residuals (especially as I mentioned before, if you are looking at multiple observations of the same things), and performing a partial residual plot will help you look for heteroscedasticity and outliers.
|
What is the expected correlation between residual and the dependent variable?
|
So, the residuals are your unexplained variance, the difference between your model's predictions and the actual outcome you're modeling. In practice, few models produced through linear regression will
|
What is the expected correlation between residual and the dependent variable?
So, the residuals are your unexplained variance, the difference between your model's predictions and the actual outcome you're modeling. In practice, few models produced through linear regression will have all residuals close to zero unless linear regression is being used to analyze a mechanical or fixed process.
Ideally, the residuals from your model should be random, meaning they should not be correlated with either your independent or dependent variables (what you term the criterion variable). In linear regression, your error term is normally distributed, so your residuals should also be normally distributed as well. If you have significant outliers, or If your residuals are correlated with either your dependent variable or your independent variables, then you have a problem with your model.
If you have significant outliers and non-normal distribution of your residuals, then the outliers may be skewing your weights (Betas), and I would suggest calculating DFBETAS to check the influence of your observations on your weights. If your residuals are correlated with your dependent variable, then there is a significantly large amount of unexplained variance that you are not accounting for. You may also see this if you're analyzing repeated observations of the same thing, due to autocorrelation. This can be checked for by seeing if your residuals are correlated with your time or index variable. If your residuals are correlated with your independent variables, then your model is heteroskedastic (see: http://en.wikipedia.org/wiki/Heteroscedasticity). You should check (if you haven't already) if your input variables are normally distributed, and if not, then you should consider scaling or transforming your data (the most common kinds are log and square-root) in order to make it more normalized.
In the case of both, your residuals, and your independent variables, you should take a QQ-Plot, as well as perform a Kolmogorov-Smirnov test (this particular implementation is sometimes referred to as the Lilliefors test) to make sure that your values fit a normal distribution.
Three things that are quick and may be helpful in dealing with this problem, are examining the median of your residuals, it should be as close to zero as possible (the mean will almost always be zero as a result of how the error term is fitted in linear regression), a Durbin-Watson test for autocorrelation in your residuals (especially as I mentioned before, if you are looking at multiple observations of the same things), and performing a partial residual plot will help you look for heteroscedasticity and outliers.
|
What is the expected correlation between residual and the dependent variable?
So, the residuals are your unexplained variance, the difference between your model's predictions and the actual outcome you're modeling. In practice, few models produced through linear regression will
|
8,752
|
Testing for linear dependence among the columns of a matrix
|
You seem to ask a really provoking question: how to detect, given a singular correlation (or covariance, or sum-of-squares-and-cross-product) matrix, which column is linearly dependent on which. I tentatively suppose that sweep operation could help. Here is my probe in SPSS (not R) to illustrate.
Let's generate some data:
v1 v2 v3 v4 v5
-1.64454 .35119 -.06384 -1.05188 .25192
-1.78520 -.21598 1.20315 .40267 1.14790
1.36357 -.96107 -.46651 .92889 -1.38072
-.31455 -.74937 1.17505 1.27623 -1.04640
-.31795 .85860 .10061 .00145 .39644
-.97010 .19129 2.43890 -.83642 -.13250
-.66439 .29267 1.20405 .90068 -1.78066
.87025 -.89018 -.99386 -1.80001 .42768
-1.96219 -.27535 .58754 .34556 .12587
-1.03638 -.24645 -.11083 .07013 -.84446
Let's create some linear dependancy between V2, V4 and V5:
compute V4 = .4*V2+1.2*V5.
execute.
So, we modified our column V4.
matrix.
get X. /*take the data*/
compute M = sscp(X). /*SSCP matrix, X'X; it is singular*/
print rank(M). /*with rank 5-1=4, because there's 1 group of interdependent columns*/
loop i= 1 to 5. /*Start iterative sweep operation on M from column 1 to column 5*/
-compute M = sweep(M,i).
-print M. /*That's printout we want to trace*/
end loop.
end matrix.
The printouts of M in 5 iterations:
M
.06660028 -.12645565 -.54275426 -.19692972 -.12195621
.12645565 3.20350385 -.08946808 2.84946215 1.30671718
.54275426 -.08946808 7.38023317 -3.51467361 -2.89907198
.19692972 2.84946215 -3.51467361 13.88671851 10.62244471
.12195621 1.30671718 -2.89907198 10.62244471 8.41646486
M
.07159201 .03947417 -.54628594 -.08444957 -.07037464
.03947417 .31215820 -.02792819 .88948298 .40790248
.54628594 .02792819 7.37773449 -3.43509328 -2.86257773
.08444957 -.88948298 -3.43509328 11.35217042 9.46014202
.07037464 -.40790248 -2.86257773 9.46014202 7.88345168
M
.112041875 .041542117 .074045215 -.338801789 -.282334825
.041542117 .312263922 .003785470 .876479537 .397066281
.074045215 .003785470 .135542964 -.465602725 -.388002270
.338801789 -.876479537 .465602725 9.752781632 8.127318027
.282334825 -.397066281 .388002270 8.127318027 6.772765022
M
.1238115070 .0110941027 .0902197842 .0347389906 .0000000000
.0110941027 .3910328733 -.0380581058 -.0898696977 -.3333333333
.0902197842 -.0380581058 .1577710733 .0477405054 .0000000000
.0347389906 -.0898696977 .0477405054 .1025348498 .8333333333
.0000000000 .3333333333 .0000000000 -.8333333333 .0000000000
M
.1238115070 .0110941027 .0902197842 .0347389906 .0000000000
.0110941027 .3910328733 -.0380581058 -.0898696977 .0000000000
.0902197842 -.0380581058 .1577710733 .0477405054 .0000000000
.0347389906 -.0898696977 .0477405054 .1025348498 .0000000000
.0000000000 .0000000000 .0000000000 .0000000000 .0000000000
Notice that eventually column 5 got full of zeros. This means (as I understand it) that V5 is linearly tied with some of preceeding columns. Which columns? Look at iteration where column 5 is last not full of zeroes - iteration 4. We see there that V5 is tied with V2 and V4 with coefficients -.3333 and .8333: V5 = -.3333*V2+.8333*V4, which corresponds to what we've done with the data: V4 = .4*V2+1.2*V5.
That's how we knew which column is linearly tied with which other. I didn't check how helpful is the above approach in more general case with many groups of interdependancies in the data. In the above example it appeared helpful, though.
|
Testing for linear dependence among the columns of a matrix
|
You seem to ask a really provoking question: how to detect, given a singular correlation (or covariance, or sum-of-squares-and-cross-product) matrix, which column is linearly dependent on which. I ten
|
Testing for linear dependence among the columns of a matrix
You seem to ask a really provoking question: how to detect, given a singular correlation (or covariance, or sum-of-squares-and-cross-product) matrix, which column is linearly dependent on which. I tentatively suppose that sweep operation could help. Here is my probe in SPSS (not R) to illustrate.
Let's generate some data:
v1 v2 v3 v4 v5
-1.64454 .35119 -.06384 -1.05188 .25192
-1.78520 -.21598 1.20315 .40267 1.14790
1.36357 -.96107 -.46651 .92889 -1.38072
-.31455 -.74937 1.17505 1.27623 -1.04640
-.31795 .85860 .10061 .00145 .39644
-.97010 .19129 2.43890 -.83642 -.13250
-.66439 .29267 1.20405 .90068 -1.78066
.87025 -.89018 -.99386 -1.80001 .42768
-1.96219 -.27535 .58754 .34556 .12587
-1.03638 -.24645 -.11083 .07013 -.84446
Let's create some linear dependancy between V2, V4 and V5:
compute V4 = .4*V2+1.2*V5.
execute.
So, we modified our column V4.
matrix.
get X. /*take the data*/
compute M = sscp(X). /*SSCP matrix, X'X; it is singular*/
print rank(M). /*with rank 5-1=4, because there's 1 group of interdependent columns*/
loop i= 1 to 5. /*Start iterative sweep operation on M from column 1 to column 5*/
-compute M = sweep(M,i).
-print M. /*That's printout we want to trace*/
end loop.
end matrix.
The printouts of M in 5 iterations:
M
.06660028 -.12645565 -.54275426 -.19692972 -.12195621
.12645565 3.20350385 -.08946808 2.84946215 1.30671718
.54275426 -.08946808 7.38023317 -3.51467361 -2.89907198
.19692972 2.84946215 -3.51467361 13.88671851 10.62244471
.12195621 1.30671718 -2.89907198 10.62244471 8.41646486
M
.07159201 .03947417 -.54628594 -.08444957 -.07037464
.03947417 .31215820 -.02792819 .88948298 .40790248
.54628594 .02792819 7.37773449 -3.43509328 -2.86257773
.08444957 -.88948298 -3.43509328 11.35217042 9.46014202
.07037464 -.40790248 -2.86257773 9.46014202 7.88345168
M
.112041875 .041542117 .074045215 -.338801789 -.282334825
.041542117 .312263922 .003785470 .876479537 .397066281
.074045215 .003785470 .135542964 -.465602725 -.388002270
.338801789 -.876479537 .465602725 9.752781632 8.127318027
.282334825 -.397066281 .388002270 8.127318027 6.772765022
M
.1238115070 .0110941027 .0902197842 .0347389906 .0000000000
.0110941027 .3910328733 -.0380581058 -.0898696977 -.3333333333
.0902197842 -.0380581058 .1577710733 .0477405054 .0000000000
.0347389906 -.0898696977 .0477405054 .1025348498 .8333333333
.0000000000 .3333333333 .0000000000 -.8333333333 .0000000000
M
.1238115070 .0110941027 .0902197842 .0347389906 .0000000000
.0110941027 .3910328733 -.0380581058 -.0898696977 .0000000000
.0902197842 -.0380581058 .1577710733 .0477405054 .0000000000
.0347389906 -.0898696977 .0477405054 .1025348498 .0000000000
.0000000000 .0000000000 .0000000000 .0000000000 .0000000000
Notice that eventually column 5 got full of zeros. This means (as I understand it) that V5 is linearly tied with some of preceeding columns. Which columns? Look at iteration where column 5 is last not full of zeroes - iteration 4. We see there that V5 is tied with V2 and V4 with coefficients -.3333 and .8333: V5 = -.3333*V2+.8333*V4, which corresponds to what we've done with the data: V4 = .4*V2+1.2*V5.
That's how we knew which column is linearly tied with which other. I didn't check how helpful is the above approach in more general case with many groups of interdependancies in the data. In the above example it appeared helpful, though.
|
Testing for linear dependence among the columns of a matrix
You seem to ask a really provoking question: how to detect, given a singular correlation (or covariance, or sum-of-squares-and-cross-product) matrix, which column is linearly dependent on which. I ten
|
8,753
|
Testing for linear dependence among the columns of a matrix
|
Here's a straightforward approach: compute the rank of the matrix that results from removing each of the columns. The columns which, when removed, result in the highest rank are the linearly dependent ones (since removing those does not decrease rank, while removing a linearly independent column does).
In R:
rankifremoved <- sapply(1:ncol(your.matrix), function (x) qr(your.matrix[,-x])$rank)
which(rankifremoved == max(rankifremoved))
|
Testing for linear dependence among the columns of a matrix
|
Here's a straightforward approach: compute the rank of the matrix that results from removing each of the columns. The columns which, when removed, result in the highest rank are the linearly dependen
|
Testing for linear dependence among the columns of a matrix
Here's a straightforward approach: compute the rank of the matrix that results from removing each of the columns. The columns which, when removed, result in the highest rank are the linearly dependent ones (since removing those does not decrease rank, while removing a linearly independent column does).
In R:
rankifremoved <- sapply(1:ncol(your.matrix), function (x) qr(your.matrix[,-x])$rank)
which(rankifremoved == max(rankifremoved))
|
Testing for linear dependence among the columns of a matrix
Here's a straightforward approach: compute the rank of the matrix that results from removing each of the columns. The columns which, when removed, result in the highest rank are the linearly dependen
|
8,754
|
Testing for linear dependence among the columns of a matrix
|
The question asks about "identifying underlying [linear] relationships" among variables.
The quick and easy way to detect relationships is to regress any other variable (use a constant, even) against those variables using your favorite software: any good regression procedure will detect and diagnose collinearity. (You will not even bother to look at the regression results: we're just relying on a useful side-effect of setting up and analyzing the regression matrix.)
Assuming collinearity is detected, though, what next? Principal Components Analysis (PCA) is exactly what is needed: its smallest components correspond to near-linear relations. These relations can be read directly off the "loadings," which are linear combinations of the original variables. Small loadings (that is, those associated with small eigenvalues) correspond to near-collinearities. An eigenvalue of $0$ would correspond to a perfect linear relation. Slightly larger eigenvalues that are still much smaller than the largest would correspond to approximate linear relations.
(There is an art and quite a lot of literature associated with identifying what a "small" loading is. For modeling a dependent variable, I would suggest including it within the independent variables in the PCA in order to identify the components--regardless of their sizes--in which the dependent variable plays an important role. From this point of view, "small" means much smaller than any such component.)
Let's look at some examples. (These use R for the calculations and plotting.) Begin with a function to perform PCA, look for small components, plot them, and return the linear relations among them.
pca <- function(x, threshold, ...) {
fit <- princomp(x)
#
# Compute the relations among "small" components.
#
if(missing(threshold)) threshold <- max(fit$sdev) / ncol(x)
i <- which(fit$sdev < threshold)
relations <- fit$loadings[, i, drop=FALSE]
relations <- round(t(t(relations) / apply(relations, 2, max)), digits=2)
#
# Plot the loadings, highlighting those for the small components.
#
matplot(x, pch=1, cex=.8, col="Gray", xlab="Observation", ylab="Value", ...)
suppressWarnings(matplot(x %*% relations, pch=19, col="#e0404080", add=TRUE))
return(t(relations))
}
Let's apply this to some random data. These are built on four variables (the $B,C,D,$ and $E$ of the question). Here is a little function to compute $A$ as a given linear combination of the others. It then adds i.i.d. Normally-distributed values to all five variables (to see how well the procedure performs when multicollinearity is only approximate and not exact).
process <- function(z, beta, sd, ...) {
x <- z %*% beta; colnames(x) <- "A"
pca(cbind(x, z + rnorm(length(x), sd=sd)), ...)
}
We're all set to go: it remains only to generate $B, \ldots, E$ and apply these procedures. I use the two scenarios described in the question: $A=B+C+D+E$ (plus some error in each) and $A=B+(C+D)/2+E$ (plus some error in each). First, however, note that PCA is almost always applied to centered data, so these simulated data are centered (but not otherwise rescaled) using sweep.
n.obs <- 80 # Number of cases
n.vars <- 4 # Number of independent variables
set.seed(17)
z <- matrix(rnorm(n.obs*(n.vars)), ncol=n.vars)
z.mean <- apply(z, 2, mean)
z <- sweep(z, 2, z.mean)
colnames(z) <- c("B","C","D","E") # Optional; modify to match `n.vars` in length
Here we go with two scenarios and three levels of error applied to each. The original variables $B, \ldots, E$ are retained throughout without change: only $A$ and the error terms vary.
The output associated with the upper left panel was
A B C D E
Comp.5 1 -1 -1 -1 -1
This says that the row of red dots--which is constantly at $0$, demonstrating a perfect multicollinearity--consists of the combination $0 \approx A -B-C-D-E$: exactly what was specified.
The output for the upper middle panel was
A B C D E
Comp.5 1 -0.95 -1.03 -0.98 -1.02
The coefficients are still close to what we expected, but they are not quite the same due to the error introduced. It thickened the four-dimensional hyperplane within the five-dimensional space implied by $(A,B,C,D,E)$ and that tilted the estimated direction just a little. With more error, the thickening becomes comparable to the original spread of the points, making the hyperplane almost impossible to estimate. Now (in the upper right panel) the coefficients are
A B C D E
Comp.5 1 -1.33 -0.77 -0.74 -1.07
They have changed quite a bit but still reflect the basic underlying relationship $A' = B' + C' + D' + E'$ where the primes denote the values with the (unknown) error removed.
The bottom row is interpreted the same way and its output similarly reflects the coefficients $1, 1/2, 1/2, 1$.
In practice, it is often not the case that one variable is singled out as an obvious combination of the others: all coefficients may be of comparable sizes and of varying signs. Moreover, when there is more than one dimension of relations, there is no unique way to specify them: further analysis (such as row reduction) is needed to identify a useful basis for those relations. That's how the world works: all you can say is that these particular combinations that are output by PCA correspond to almost no variation in the data. To cope with this, some people use the largest ("principal") components directly as the independent variables in the regression or the subsequent analysis, whatever form it might take. If you do this, do not forget first to remove the dependent variable from the set of variables and redo the PCA!
Here is the code to reproduce this figure:
par(mfrow=c(2,3))
beta <- c(1,1,1,1) # Also can be a matrix with `n.obs` rows: try it!
process(z, beta, sd=0, main="A=B+C+D+E; No error")
process(z, beta, sd=1/10, main="A=B+C+D+E; Small error")
process(z, beta, sd=1/3, threshold=2/3, main="A=B+C+D+E; Large error")
beta <- c(1,1/2,1/2,1)
process(z, beta, sd=0, main="A=B+(C+D)/2+E; No error")
process(z, beta, sd=1/10, main="A=B+(C+D)/2+E; Small error")
process(z, beta, sd=1/3, threshold=2/3, main="A=B+(C+D)/2+E; Large error")
(I had to fiddle with the threshold in the large-error cases in order to display just a single component: that's the reason for supplying this value as a parameter to process.)
User ttnphns has kindly directed our attention to a closely related thread. One of its answers (by J.M.) suggests the approach described here.
|
Testing for linear dependence among the columns of a matrix
|
The question asks about "identifying underlying [linear] relationships" among variables.
The quick and easy way to detect relationships is to regress any other variable (use a constant, even) against
|
Testing for linear dependence among the columns of a matrix
The question asks about "identifying underlying [linear] relationships" among variables.
The quick and easy way to detect relationships is to regress any other variable (use a constant, even) against those variables using your favorite software: any good regression procedure will detect and diagnose collinearity. (You will not even bother to look at the regression results: we're just relying on a useful side-effect of setting up and analyzing the regression matrix.)
Assuming collinearity is detected, though, what next? Principal Components Analysis (PCA) is exactly what is needed: its smallest components correspond to near-linear relations. These relations can be read directly off the "loadings," which are linear combinations of the original variables. Small loadings (that is, those associated with small eigenvalues) correspond to near-collinearities. An eigenvalue of $0$ would correspond to a perfect linear relation. Slightly larger eigenvalues that are still much smaller than the largest would correspond to approximate linear relations.
(There is an art and quite a lot of literature associated with identifying what a "small" loading is. For modeling a dependent variable, I would suggest including it within the independent variables in the PCA in order to identify the components--regardless of their sizes--in which the dependent variable plays an important role. From this point of view, "small" means much smaller than any such component.)
Let's look at some examples. (These use R for the calculations and plotting.) Begin with a function to perform PCA, look for small components, plot them, and return the linear relations among them.
pca <- function(x, threshold, ...) {
fit <- princomp(x)
#
# Compute the relations among "small" components.
#
if(missing(threshold)) threshold <- max(fit$sdev) / ncol(x)
i <- which(fit$sdev < threshold)
relations <- fit$loadings[, i, drop=FALSE]
relations <- round(t(t(relations) / apply(relations, 2, max)), digits=2)
#
# Plot the loadings, highlighting those for the small components.
#
matplot(x, pch=1, cex=.8, col="Gray", xlab="Observation", ylab="Value", ...)
suppressWarnings(matplot(x %*% relations, pch=19, col="#e0404080", add=TRUE))
return(t(relations))
}
Let's apply this to some random data. These are built on four variables (the $B,C,D,$ and $E$ of the question). Here is a little function to compute $A$ as a given linear combination of the others. It then adds i.i.d. Normally-distributed values to all five variables (to see how well the procedure performs when multicollinearity is only approximate and not exact).
process <- function(z, beta, sd, ...) {
x <- z %*% beta; colnames(x) <- "A"
pca(cbind(x, z + rnorm(length(x), sd=sd)), ...)
}
We're all set to go: it remains only to generate $B, \ldots, E$ and apply these procedures. I use the two scenarios described in the question: $A=B+C+D+E$ (plus some error in each) and $A=B+(C+D)/2+E$ (plus some error in each). First, however, note that PCA is almost always applied to centered data, so these simulated data are centered (but not otherwise rescaled) using sweep.
n.obs <- 80 # Number of cases
n.vars <- 4 # Number of independent variables
set.seed(17)
z <- matrix(rnorm(n.obs*(n.vars)), ncol=n.vars)
z.mean <- apply(z, 2, mean)
z <- sweep(z, 2, z.mean)
colnames(z) <- c("B","C","D","E") # Optional; modify to match `n.vars` in length
Here we go with two scenarios and three levels of error applied to each. The original variables $B, \ldots, E$ are retained throughout without change: only $A$ and the error terms vary.
The output associated with the upper left panel was
A B C D E
Comp.5 1 -1 -1 -1 -1
This says that the row of red dots--which is constantly at $0$, demonstrating a perfect multicollinearity--consists of the combination $0 \approx A -B-C-D-E$: exactly what was specified.
The output for the upper middle panel was
A B C D E
Comp.5 1 -0.95 -1.03 -0.98 -1.02
The coefficients are still close to what we expected, but they are not quite the same due to the error introduced. It thickened the four-dimensional hyperplane within the five-dimensional space implied by $(A,B,C,D,E)$ and that tilted the estimated direction just a little. With more error, the thickening becomes comparable to the original spread of the points, making the hyperplane almost impossible to estimate. Now (in the upper right panel) the coefficients are
A B C D E
Comp.5 1 -1.33 -0.77 -0.74 -1.07
They have changed quite a bit but still reflect the basic underlying relationship $A' = B' + C' + D' + E'$ where the primes denote the values with the (unknown) error removed.
The bottom row is interpreted the same way and its output similarly reflects the coefficients $1, 1/2, 1/2, 1$.
In practice, it is often not the case that one variable is singled out as an obvious combination of the others: all coefficients may be of comparable sizes and of varying signs. Moreover, when there is more than one dimension of relations, there is no unique way to specify them: further analysis (such as row reduction) is needed to identify a useful basis for those relations. That's how the world works: all you can say is that these particular combinations that are output by PCA correspond to almost no variation in the data. To cope with this, some people use the largest ("principal") components directly as the independent variables in the regression or the subsequent analysis, whatever form it might take. If you do this, do not forget first to remove the dependent variable from the set of variables and redo the PCA!
Here is the code to reproduce this figure:
par(mfrow=c(2,3))
beta <- c(1,1,1,1) # Also can be a matrix with `n.obs` rows: try it!
process(z, beta, sd=0, main="A=B+C+D+E; No error")
process(z, beta, sd=1/10, main="A=B+C+D+E; Small error")
process(z, beta, sd=1/3, threshold=2/3, main="A=B+C+D+E; Large error")
beta <- c(1,1/2,1/2,1)
process(z, beta, sd=0, main="A=B+(C+D)/2+E; No error")
process(z, beta, sd=1/10, main="A=B+(C+D)/2+E; Small error")
process(z, beta, sd=1/3, threshold=2/3, main="A=B+(C+D)/2+E; Large error")
(I had to fiddle with the threshold in the large-error cases in order to display just a single component: that's the reason for supplying this value as a parameter to process.)
User ttnphns has kindly directed our attention to a closely related thread. One of its answers (by J.M.) suggests the approach described here.
|
Testing for linear dependence among the columns of a matrix
The question asks about "identifying underlying [linear] relationships" among variables.
The quick and easy way to detect relationships is to regress any other variable (use a constant, even) against
|
8,755
|
Testing for linear dependence among the columns of a matrix
|
What I'd try to do here for diagnostic purposes is to take the $502\times 480$ matrix (that is, the transpose) and determine the singular values of the matrix (for diagnostic purposes, you don't need the full singular value decomposition... yet). Once you have the 480 singular values, check how many of those are "small" (a usual criterion is that a singular value is "small" if it is less than the largest singular value times the machine precision). If there are any "small" singular values, then yes, you have linear dependence.
|
Testing for linear dependence among the columns of a matrix
|
What I'd try to do here for diagnostic purposes is to take the $502\times 480$ matrix (that is, the transpose) and determine the singular values of the matrix (for diagnostic purposes, you don't need
|
Testing for linear dependence among the columns of a matrix
What I'd try to do here for diagnostic purposes is to take the $502\times 480$ matrix (that is, the transpose) and determine the singular values of the matrix (for diagnostic purposes, you don't need the full singular value decomposition... yet). Once you have the 480 singular values, check how many of those are "small" (a usual criterion is that a singular value is "small" if it is less than the largest singular value times the machine precision). If there are any "small" singular values, then yes, you have linear dependence.
|
Testing for linear dependence among the columns of a matrix
What I'd try to do here for diagnostic purposes is to take the $502\times 480$ matrix (that is, the transpose) and determine the singular values of the matrix (for diagnostic purposes, you don't need
|
8,756
|
Testing for linear dependence among the columns of a matrix
|
Not that the answer @Whuber gave really needs to be expanded on but I thought I'd provide a brief description of the math.
If the linear combination $\mathbf{X'Xv}=\mathbf{0}$ for $\mathbf{v}\neq\mathbf{0}$ then $\mathbf{v}$ is an eigenvector of $\mathbf{X'X}$ associated with eigenvalue $\lambda=0$. The eigenvectors and eigenvalues of $\mathbf{X'X}$ are also the eigenvectors and eigenvalues of $\mathbf{X}$, so the eigenvectors of $\mathbf{X'X}$ associated with eigenvalues near $\lambda=0$ represent the coefficients for approximate linear relationships among the regressors. Principal Component Analysis outputs the eigenvectors and eigenvalues of $\mathbf{X'X}$, so you can use the eigenvectors $\mathbf{v}$ associated with small $\lambda$ to determine if linear relationships exist among some of your regressors.
One method of determining if an eigenvalue is appropriately small to constitute collinearity is to use the Condition Indices:
$$
\mathbf{\kappa_j}=\frac{\lambda_{max}}{\lambda_j}
$$
which measures the size of the smallest eigenvalues relative to the largest. A general rule of thumb is that modest multicollinearity is associated with a condition index between 100 and 1,000 while severe multicollinearity is associated with a condition index above 1,000 (Montgomery, 2009).
It's important to use an appropriate method for determining if an eigenvalue is small because it's not the absolute size of the eigenvalues, it's the relative size of the condition index that's important, as can be seen in an example. Consider the matrix
$$
\mathbf{X'X}=\left[\begin{array}{rr}
0.001 & 0 & 0 \\
0 & 0.001 & 0 \\
0 & 0 & 0.001 \\
\end{array}
\right].
$$
The eigenvalues for this matrix are $\lambda_1=\lambda_2=\lambda_3=0.001$. Although these eigenvalues appear small the condition index is
$$
\mathbf{\kappa}=\frac{\lambda_{max}}{\lambda_{min}}=1
$$
indicating absence of multicolinearity and , in fact, the columns of this matrix are linearly independent.
Citations
Montgomery, D. (2012). Introduction to Linear Regression Analysis, 5th Edition. John Wiley & Sons Inc.
|
Testing for linear dependence among the columns of a matrix
|
Not that the answer @Whuber gave really needs to be expanded on but I thought I'd provide a brief description of the math.
If the linear combination $\mathbf{X'Xv}=\mathbf{0}$ for $\mathbf{v}\neq\math
|
Testing for linear dependence among the columns of a matrix
Not that the answer @Whuber gave really needs to be expanded on but I thought I'd provide a brief description of the math.
If the linear combination $\mathbf{X'Xv}=\mathbf{0}$ for $\mathbf{v}\neq\mathbf{0}$ then $\mathbf{v}$ is an eigenvector of $\mathbf{X'X}$ associated with eigenvalue $\lambda=0$. The eigenvectors and eigenvalues of $\mathbf{X'X}$ are also the eigenvectors and eigenvalues of $\mathbf{X}$, so the eigenvectors of $\mathbf{X'X}$ associated with eigenvalues near $\lambda=0$ represent the coefficients for approximate linear relationships among the regressors. Principal Component Analysis outputs the eigenvectors and eigenvalues of $\mathbf{X'X}$, so you can use the eigenvectors $\mathbf{v}$ associated with small $\lambda$ to determine if linear relationships exist among some of your regressors.
One method of determining if an eigenvalue is appropriately small to constitute collinearity is to use the Condition Indices:
$$
\mathbf{\kappa_j}=\frac{\lambda_{max}}{\lambda_j}
$$
which measures the size of the smallest eigenvalues relative to the largest. A general rule of thumb is that modest multicollinearity is associated with a condition index between 100 and 1,000 while severe multicollinearity is associated with a condition index above 1,000 (Montgomery, 2009).
It's important to use an appropriate method for determining if an eigenvalue is small because it's not the absolute size of the eigenvalues, it's the relative size of the condition index that's important, as can be seen in an example. Consider the matrix
$$
\mathbf{X'X}=\left[\begin{array}{rr}
0.001 & 0 & 0 \\
0 & 0.001 & 0 \\
0 & 0 & 0.001 \\
\end{array}
\right].
$$
The eigenvalues for this matrix are $\lambda_1=\lambda_2=\lambda_3=0.001$. Although these eigenvalues appear small the condition index is
$$
\mathbf{\kappa}=\frac{\lambda_{max}}{\lambda_{min}}=1
$$
indicating absence of multicolinearity and , in fact, the columns of this matrix are linearly independent.
Citations
Montgomery, D. (2012). Introduction to Linear Regression Analysis, 5th Edition. John Wiley & Sons Inc.
|
Testing for linear dependence among the columns of a matrix
Not that the answer @Whuber gave really needs to be expanded on but I thought I'd provide a brief description of the math.
If the linear combination $\mathbf{X'Xv}=\mathbf{0}$ for $\mathbf{v}\neq\math
|
8,757
|
Testing for linear dependence among the columns of a matrix
|
I ran into this issue roughly two weeks ago and decided that I needed to revisit it because when dealing with massive data sets, it is impossible to do these things manually.
I created a for() loop that calculates the rank of the matrix one column at a time. So for the first iteration, the rank will be 1. The second, 2. This occurs until the rank becomes LESS than the column number you are using.
Very straightforward:
for (i in 1:47) {
print(qr(data.frame[1:i])$rank)
print(i)
print(colnames(data.frame)[i])
print("###")
}
for() loop breakdown
calculates the rank for the ith column
prints the iteration number
prints the column name for reference
divides the console with "###" so that you can easily scroll through
I am sure that you can add an if statement, I don't need it yet because I am only dealing with 50ish columns.
Hope this helps!
|
Testing for linear dependence among the columns of a matrix
|
I ran into this issue roughly two weeks ago and decided that I needed to revisit it because when dealing with massive data sets, it is impossible to do these things manually.
I created a for() loop t
|
Testing for linear dependence among the columns of a matrix
I ran into this issue roughly two weeks ago and decided that I needed to revisit it because when dealing with massive data sets, it is impossible to do these things manually.
I created a for() loop that calculates the rank of the matrix one column at a time. So for the first iteration, the rank will be 1. The second, 2. This occurs until the rank becomes LESS than the column number you are using.
Very straightforward:
for (i in 1:47) {
print(qr(data.frame[1:i])$rank)
print(i)
print(colnames(data.frame)[i])
print("###")
}
for() loop breakdown
calculates the rank for the ith column
prints the iteration number
prints the column name for reference
divides the console with "###" so that you can easily scroll through
I am sure that you can add an if statement, I don't need it yet because I am only dealing with 50ish columns.
Hope this helps!
|
Testing for linear dependence among the columns of a matrix
I ran into this issue roughly two weeks ago and decided that I needed to revisit it because when dealing with massive data sets, it is impossible to do these things manually.
I created a for() loop t
|
8,758
|
Testing for linear dependence among the columns of a matrix
|
Rank, r of a matrix = number of linearly independent columns (or rows) of a matrix. For a n by n matrix A, rank(A) = n => all columns (or rows) are linearly independent.
|
Testing for linear dependence among the columns of a matrix
|
Rank, r of a matrix = number of linearly independent columns (or rows) of a matrix. For a n by n matrix A, rank(A) = n => all columns (or rows) are linearly independent.
|
Testing for linear dependence among the columns of a matrix
Rank, r of a matrix = number of linearly independent columns (or rows) of a matrix. For a n by n matrix A, rank(A) = n => all columns (or rows) are linearly independent.
|
Testing for linear dependence among the columns of a matrix
Rank, r of a matrix = number of linearly independent columns (or rows) of a matrix. For a n by n matrix A, rank(A) = n => all columns (or rows) are linearly independent.
|
8,759
|
Can a meta-analysis of studies which are all "not statistically signficant" lead to a "significant" conclusion?
|
In theory, yes...
The results of individual studies may be insignificant but viewed together, the results may be significant.
In theory you can proceed by treating the results $y_i$ of study $i$ like any other random variable.
Let $y_i$ be some random variable (eg. the estimate from study $i$). Then if $y_i$ are independent and $E[y_i]=\mu$, you can consistently estimate the mean with:
$$ \hat{\mu} = \frac{1}{n} \sum_i y_i $$
Adding more assumptions, let $\sigma^2_i$ be the variance of estimate $y_i$. Then you can efficiently estimate $\mu$ with inverse variance weighting:
$$\hat{\mu} = \sum_i w_i y_i \quad \quad w_i = \frac{1 / \sigma^2_i}{\sum_j 1 / \sigma^2_j}$$
In either of these cases, $\hat{\mu}$ may be statistically significant at some confidence level even if the individual estimates are not.
BUT there may be big problems, issues to be cognizant of...
If $E[y_i] \neq \mu$ then the meta-analysis may not converge to $\mu$ (i.e. the mean of the meta-analysis is an inconsistent estimator).
For example, if there's a bias against publishing negative results, this simple meta-analysis may be horribly inconsistent and biased! It would be like estimating the probability that a coin flip lands heads by only observing the flips where it didn't land tails!
$y_i$ and $y_j$ may not be independent. For example, if two studies $i$ and $j$ were based upon the same data, then treating $y_i$ and $y_j$ as independent in the meta-analysis may vastly underestimate the standard errors and overstate statistical significance. Your estimates would still be consistent, but the standard-errors need to reasonably account for cross-correlation in the studies.
Combining (1) and (2) can be especially bad.
For example, the meta-analysis of averaging polls together tends to be more accurate than any individual poll. But averaging polls together is still vulnerable to correlated error. Something that has come up in past elections is that young exit poll workers may tend to interview other young people rather than old people. If all the exit polls make the same error, then you have a bad estimate which you may think is a good estimate (the exit polls are correlated because they use the same approach to conduct exit polls and this approach generates the same error).
Undoubtedly people more familiar with meta-analysis may come up with better examples, more nuanced issues, more sophisticated estimation techniques, etc..., but this gets at some of the most basic theory and some of the bigger problems. If the different studies make independent, random error, then meta-analysis may be incredibly powerful. If the error is systematic across studies (eg. everyone undercounts older voters etc...), then the average of the studies will also be off. If you underestimate how correlated studies are or how correlated errors are, you effectively over estimate your aggregate sample size and underestimate your standard errors.
There are also all kinds of practical issues of consistent definitions etc...
|
Can a meta-analysis of studies which are all "not statistically signficant" lead to a "significant"
|
In theory, yes...
The results of individual studies may be insignificant but viewed together, the results may be significant.
In theory you can proceed by treating the results $y_i$ of study $i$ like
|
Can a meta-analysis of studies which are all "not statistically signficant" lead to a "significant" conclusion?
In theory, yes...
The results of individual studies may be insignificant but viewed together, the results may be significant.
In theory you can proceed by treating the results $y_i$ of study $i$ like any other random variable.
Let $y_i$ be some random variable (eg. the estimate from study $i$). Then if $y_i$ are independent and $E[y_i]=\mu$, you can consistently estimate the mean with:
$$ \hat{\mu} = \frac{1}{n} \sum_i y_i $$
Adding more assumptions, let $\sigma^2_i$ be the variance of estimate $y_i$. Then you can efficiently estimate $\mu$ with inverse variance weighting:
$$\hat{\mu} = \sum_i w_i y_i \quad \quad w_i = \frac{1 / \sigma^2_i}{\sum_j 1 / \sigma^2_j}$$
In either of these cases, $\hat{\mu}$ may be statistically significant at some confidence level even if the individual estimates are not.
BUT there may be big problems, issues to be cognizant of...
If $E[y_i] \neq \mu$ then the meta-analysis may not converge to $\mu$ (i.e. the mean of the meta-analysis is an inconsistent estimator).
For example, if there's a bias against publishing negative results, this simple meta-analysis may be horribly inconsistent and biased! It would be like estimating the probability that a coin flip lands heads by only observing the flips where it didn't land tails!
$y_i$ and $y_j$ may not be independent. For example, if two studies $i$ and $j$ were based upon the same data, then treating $y_i$ and $y_j$ as independent in the meta-analysis may vastly underestimate the standard errors and overstate statistical significance. Your estimates would still be consistent, but the standard-errors need to reasonably account for cross-correlation in the studies.
Combining (1) and (2) can be especially bad.
For example, the meta-analysis of averaging polls together tends to be more accurate than any individual poll. But averaging polls together is still vulnerable to correlated error. Something that has come up in past elections is that young exit poll workers may tend to interview other young people rather than old people. If all the exit polls make the same error, then you have a bad estimate which you may think is a good estimate (the exit polls are correlated because they use the same approach to conduct exit polls and this approach generates the same error).
Undoubtedly people more familiar with meta-analysis may come up with better examples, more nuanced issues, more sophisticated estimation techniques, etc..., but this gets at some of the most basic theory and some of the bigger problems. If the different studies make independent, random error, then meta-analysis may be incredibly powerful. If the error is systematic across studies (eg. everyone undercounts older voters etc...), then the average of the studies will also be off. If you underestimate how correlated studies are or how correlated errors are, you effectively over estimate your aggregate sample size and underestimate your standard errors.
There are also all kinds of practical issues of consistent definitions etc...
|
Can a meta-analysis of studies which are all "not statistically signficant" lead to a "significant"
In theory, yes...
The results of individual studies may be insignificant but viewed together, the results may be significant.
In theory you can proceed by treating the results $y_i$ of study $i$ like
|
8,760
|
Can a meta-analysis of studies which are all "not statistically signficant" lead to a "significant" conclusion?
|
Yes. Suppose you have $N$ p-values from $N$ independent studies.
Fisher's test
(EDIT - in response to @mdewey's useful comment below, it is relevant to distinguish between different meta tests. I spell out the case of another meta test mentioned by mdewey below)
The classical Fisher meta test (see Fisher (1932), "Statistical Methods for Research Workers" ) statistic
$$
F=-2\sum_{i=1}^N\ln(p_i)
$$
has a $\chi^2_{2N}$ null distribution, as $-2\ln(U)\sim\chi^2_2$ for a uniform r.v. $U$.
Let $\chi^2_{2N}(1-\alpha)$ denote the $(1-\alpha)$-quantile of the null distribution.
Suppose all p-values are equal to $c$, where, possibly, $c>\alpha$. Then, $F=-2N\ln(c)$ and $F>\chi^2_{2N}(1-\alpha)$ when
$$c < \exp\left(-\frac{\chi^2_{2N}(1-\alpha)}{2N}\right)$$
For example, for $\alpha=0.05$ and $N=20$, the individual $p$-values only need to be less than
> exp(-qchisq(0.95, df = 40)/40)
[1] 0.2480904
Of course, what the meta statistic tests is "only" the "aggregate" null that all individual nulls are true, which is to be rejected as soon as only one of the $N$ nulls is false.
EDIT:
Here is a plot of the "admissible" p-values against $N$, which confirms that $c$ grows in $N$, although it seems to level off at $c\approx0.36$.
I found an upper bound for the quantiles of the $\chi^2$ distribution
$$
\chi^2_{2N}(1-\alpha)\leq 2N+2\log(1/\alpha)+2\sqrt{2N\log(1/\alpha)},
$$
here, suggesting that $\chi^2_{2N}(1-\alpha)=O(N)$ so that
$\exp\left(-\frac{\chi^2_{2N}(1-\alpha)}{2N}\right)$ is bounded from above by $\exp(-1)$ as $N\to\infty$. As $\exp(-1)\approx0.3679$, this bound seems reasonably sharp.
Inverse Normal test (Stouffer et al., 1949)
The test statistic is given by
$$
Z=\frac{1}{\sqrt{N}}\sum_{i=1}^N\Phi^{-1}(p_i)
$$
with $\Phi^{-1}$ the standard normal quantile function. The test rejects for large negative values, viz., if $Z < -1.645$ at $\alpha=0.05$. Hence, for $p_i=c$, $Z=\sqrt{N}\Phi^{-1}(c)$. When $c<0.5$, $\Phi^{-1}(c)<0$ and hence $Z\to_p-\infty$ as $N\to\infty$. If $c\geq0.5$, $Z$ will take values in the acceptance region for any $N$. Hence, a common p-value less than 0.5 is sufficient to produce a rejection of the meta test as $N\to\infty$.
More specifically, $Z < -1.645$ if $c<\Phi(-1.645/\sqrt{N})$, which tends to $\Phi(0)=0.5$ from below as $N\to\infty$.
|
Can a meta-analysis of studies which are all "not statistically signficant" lead to a "significant"
|
Yes. Suppose you have $N$ p-values from $N$ independent studies.
Fisher's test
(EDIT - in response to @mdewey's useful comment below, it is relevant to distinguish between different meta tests. I spe
|
Can a meta-analysis of studies which are all "not statistically signficant" lead to a "significant" conclusion?
Yes. Suppose you have $N$ p-values from $N$ independent studies.
Fisher's test
(EDIT - in response to @mdewey's useful comment below, it is relevant to distinguish between different meta tests. I spell out the case of another meta test mentioned by mdewey below)
The classical Fisher meta test (see Fisher (1932), "Statistical Methods for Research Workers" ) statistic
$$
F=-2\sum_{i=1}^N\ln(p_i)
$$
has a $\chi^2_{2N}$ null distribution, as $-2\ln(U)\sim\chi^2_2$ for a uniform r.v. $U$.
Let $\chi^2_{2N}(1-\alpha)$ denote the $(1-\alpha)$-quantile of the null distribution.
Suppose all p-values are equal to $c$, where, possibly, $c>\alpha$. Then, $F=-2N\ln(c)$ and $F>\chi^2_{2N}(1-\alpha)$ when
$$c < \exp\left(-\frac{\chi^2_{2N}(1-\alpha)}{2N}\right)$$
For example, for $\alpha=0.05$ and $N=20$, the individual $p$-values only need to be less than
> exp(-qchisq(0.95, df = 40)/40)
[1] 0.2480904
Of course, what the meta statistic tests is "only" the "aggregate" null that all individual nulls are true, which is to be rejected as soon as only one of the $N$ nulls is false.
EDIT:
Here is a plot of the "admissible" p-values against $N$, which confirms that $c$ grows in $N$, although it seems to level off at $c\approx0.36$.
I found an upper bound for the quantiles of the $\chi^2$ distribution
$$
\chi^2_{2N}(1-\alpha)\leq 2N+2\log(1/\alpha)+2\sqrt{2N\log(1/\alpha)},
$$
here, suggesting that $\chi^2_{2N}(1-\alpha)=O(N)$ so that
$\exp\left(-\frac{\chi^2_{2N}(1-\alpha)}{2N}\right)$ is bounded from above by $\exp(-1)$ as $N\to\infty$. As $\exp(-1)\approx0.3679$, this bound seems reasonably sharp.
Inverse Normal test (Stouffer et al., 1949)
The test statistic is given by
$$
Z=\frac{1}{\sqrt{N}}\sum_{i=1}^N\Phi^{-1}(p_i)
$$
with $\Phi^{-1}$ the standard normal quantile function. The test rejects for large negative values, viz., if $Z < -1.645$ at $\alpha=0.05$. Hence, for $p_i=c$, $Z=\sqrt{N}\Phi^{-1}(c)$. When $c<0.5$, $\Phi^{-1}(c)<0$ and hence $Z\to_p-\infty$ as $N\to\infty$. If $c\geq0.5$, $Z$ will take values in the acceptance region for any $N$. Hence, a common p-value less than 0.5 is sufficient to produce a rejection of the meta test as $N\to\infty$.
More specifically, $Z < -1.645$ if $c<\Phi(-1.645/\sqrt{N})$, which tends to $\Phi(0)=0.5$ from below as $N\to\infty$.
|
Can a meta-analysis of studies which are all "not statistically signficant" lead to a "significant"
Yes. Suppose you have $N$ p-values from $N$ independent studies.
Fisher's test
(EDIT - in response to @mdewey's useful comment below, it is relevant to distinguish between different meta tests. I spe
|
8,761
|
Can a meta-analysis of studies which are all "not statistically signficant" lead to a "significant" conclusion?
|
The answer to this depends on what method you use for combining $p$-values. Other answers have considered some of these but here I focus on one method for which the answer to the original question is no.
The minimum $p$ method, also known as Tippett's method,
is usually described in terms
of a rejection at the $\alpha_*$ level of the
null hypothesis.
Define
$$
p_{[1]} \le p_{[2]} \dots p_{[k]}
$$
for the $k$ studies.
Tippett's method then evaluates whether
\begin{equation}
p_{[1]} < 1 - (1 - \alpha_*)^{\frac{1}{k}}
\end{equation}
It is easy to see the since the $k$th root of a number less than unity is closer to unity the last term is greater than $\alpha_*$ and hence the overall result will be non-significant unless $p_{[1]}$ is already less than $\alpha_*$.
It is possible to work out the critical value and for example if we have ten primary studies each with a $p$-values of 00.05 so as close to significant as can be then the overall critical value is 0.40. The method can be seen as a special case of Wilkinson's method which uses $p_{[r]}$ for $1\le r\le k$ and in fact for the particular set of primary studies even $r=2$ is not significant ($p=0.09$)
L H C Tippett's method is described in a book The methods of statistics. 1931 (1st ed) and Wilkinson's method is here in an article "A statistical consideration in psychological research"
|
Can a meta-analysis of studies which are all "not statistically signficant" lead to a "significant"
|
The answer to this depends on what method you use for combining $p$-values. Other answers have considered some of these but here I focus on one method for which the answer to the original question is
|
Can a meta-analysis of studies which are all "not statistically signficant" lead to a "significant" conclusion?
The answer to this depends on what method you use for combining $p$-values. Other answers have considered some of these but here I focus on one method for which the answer to the original question is no.
The minimum $p$ method, also known as Tippett's method,
is usually described in terms
of a rejection at the $\alpha_*$ level of the
null hypothesis.
Define
$$
p_{[1]} \le p_{[2]} \dots p_{[k]}
$$
for the $k$ studies.
Tippett's method then evaluates whether
\begin{equation}
p_{[1]} < 1 - (1 - \alpha_*)^{\frac{1}{k}}
\end{equation}
It is easy to see the since the $k$th root of a number less than unity is closer to unity the last term is greater than $\alpha_*$ and hence the overall result will be non-significant unless $p_{[1]}$ is already less than $\alpha_*$.
It is possible to work out the critical value and for example if we have ten primary studies each with a $p$-values of 00.05 so as close to significant as can be then the overall critical value is 0.40. The method can be seen as a special case of Wilkinson's method which uses $p_{[r]}$ for $1\le r\le k$ and in fact for the particular set of primary studies even $r=2$ is not significant ($p=0.09$)
L H C Tippett's method is described in a book The methods of statistics. 1931 (1st ed) and Wilkinson's method is here in an article "A statistical consideration in psychological research"
|
Can a meta-analysis of studies which are all "not statistically signficant" lead to a "significant"
The answer to this depends on what method you use for combining $p$-values. Other answers have considered some of these but here I focus on one method for which the answer to the original question is
|
8,762
|
What are good data visualization techniques to compare distributions?
|
I am going to elaborate my comment, as suggested by @gung. I will also include the violin plot suggested by @Alexander, for completeness. Some of these tools can be used for comparing more than two samples.
# Required packages
library(sn)
library(aplpack)
library(vioplot)
library(moments)
library(beanplot)
# Simulate from a normal and skew-normal distributions
x = rnorm(250,0,1)
y = rsn(250,0,1,5)
# Separated histograms
hist(x)
hist(y)
# Combined histograms
hist(x, xlim=c(-4,4),ylim=c(0,1), col="red",probability=T)
hist(y, add=T, col="blue",probability=T)
# Boxplots
boxplot(x,y)
# Separated smoothed densities
plot(density(x))
plot(density(y))
# Combined smoothed densities
plot(density(x),type="l",col="red",ylim=c(0,1),xlim=c(-4,4))
points(density(y),type="l",col="blue")
# Stem-and-leaf plots
stem(x)
stem(y)
# Back-to-back stem-and-leaf plots
stem.leaf.backback(x,y)
# Violin plot (suggested by Alexander)
vioplot(x,y)
# QQ-plot
qqplot(x,y,xlim=c(-4,4),ylim=c(-4,4))
qqline(x,y,col="red")
# Kolmogorov-Smirnov test
ks.test(x,y)
# six-numbers summary
summary(x)
summary(y)
# moment-based summary
c(mean(x),var(x),skewness(x),kurtosis(x))
c(mean(y),var(y),skewness(y),kurtosis(y))
# Empirical ROC curve
xx = c(-Inf, sort(unique(c(x,y))), Inf)
sens = sapply(xx, function(t){mean(x >= t)})
spec = sapply(xx, function(t){mean(y < t)})
plot(0, 0, xlim = c(0, 1), ylim = c(0, 1), type = 'l')
segments(0, 0, 1, 1, col = 1)
lines(1 - spec, sens, type = 'l', col = 2, lwd = 1)
# Beanplots
beanplot(x,y)
# Empirical CDF
plot(ecdf(x))
lines(ecdf(y))
I hope this helps.
|
What are good data visualization techniques to compare distributions?
|
I am going to elaborate my comment, as suggested by @gung. I will also include the violin plot suggested by @Alexander, for completeness. Some of these tools can be used for comparing more than two sa
|
What are good data visualization techniques to compare distributions?
I am going to elaborate my comment, as suggested by @gung. I will also include the violin plot suggested by @Alexander, for completeness. Some of these tools can be used for comparing more than two samples.
# Required packages
library(sn)
library(aplpack)
library(vioplot)
library(moments)
library(beanplot)
# Simulate from a normal and skew-normal distributions
x = rnorm(250,0,1)
y = rsn(250,0,1,5)
# Separated histograms
hist(x)
hist(y)
# Combined histograms
hist(x, xlim=c(-4,4),ylim=c(0,1), col="red",probability=T)
hist(y, add=T, col="blue",probability=T)
# Boxplots
boxplot(x,y)
# Separated smoothed densities
plot(density(x))
plot(density(y))
# Combined smoothed densities
plot(density(x),type="l",col="red",ylim=c(0,1),xlim=c(-4,4))
points(density(y),type="l",col="blue")
# Stem-and-leaf plots
stem(x)
stem(y)
# Back-to-back stem-and-leaf plots
stem.leaf.backback(x,y)
# Violin plot (suggested by Alexander)
vioplot(x,y)
# QQ-plot
qqplot(x,y,xlim=c(-4,4),ylim=c(-4,4))
qqline(x,y,col="red")
# Kolmogorov-Smirnov test
ks.test(x,y)
# six-numbers summary
summary(x)
summary(y)
# moment-based summary
c(mean(x),var(x),skewness(x),kurtosis(x))
c(mean(y),var(y),skewness(y),kurtosis(y))
# Empirical ROC curve
xx = c(-Inf, sort(unique(c(x,y))), Inf)
sens = sapply(xx, function(t){mean(x >= t)})
spec = sapply(xx, function(t){mean(y < t)})
plot(0, 0, xlim = c(0, 1), ylim = c(0, 1), type = 'l')
segments(0, 0, 1, 1, col = 1)
lines(1 - spec, sens, type = 'l', col = 2, lwd = 1)
# Beanplots
beanplot(x,y)
# Empirical CDF
plot(ecdf(x))
lines(ecdf(y))
I hope this helps.
|
What are good data visualization techniques to compare distributions?
I am going to elaborate my comment, as suggested by @gung. I will also include the violin plot suggested by @Alexander, for completeness. Some of these tools can be used for comparing more than two sa
|
8,763
|
What are good data visualization techniques to compare distributions?
|
After exploring a bit more on your suggestions I found this kind of plot to complement @Procastinator 's answer. It is called 'bee swarm' and is a mixture of box plot with violin plot with the same detail level as scatter plot.
beeswarm R package
|
What are good data visualization techniques to compare distributions?
|
After exploring a bit more on your suggestions I found this kind of plot to complement @Procastinator 's answer. It is called 'bee swarm' and is a mixture of box plot with violin plot with the same de
|
What are good data visualization techniques to compare distributions?
After exploring a bit more on your suggestions I found this kind of plot to complement @Procastinator 's answer. It is called 'bee swarm' and is a mixture of box plot with violin plot with the same detail level as scatter plot.
beeswarm R package
|
What are good data visualization techniques to compare distributions?
After exploring a bit more on your suggestions I found this kind of plot to complement @Procastinator 's answer. It is called 'bee swarm' and is a mixture of box plot with violin plot with the same de
|
8,764
|
What are good data visualization techniques to compare distributions?
|
Here's a nice tutorial from Nathan Yau's Flowing Data blog using R and US state-level crime data. It shows:
Box-and-Whisker Plots (which you already use)
Histograms
Kernel Density Plots
Rug Plots
Violin Plots
Bean Plots (a weird combo of a box plot, density plot, with a rug in the middle).
Lately, I find myself plotting CDFs much more than histograms.
|
What are good data visualization techniques to compare distributions?
|
Here's a nice tutorial from Nathan Yau's Flowing Data blog using R and US state-level crime data. It shows:
Box-and-Whisker Plots (which you already use)
Histograms
Kernel Density Plots
Rug Plots
Vio
|
What are good data visualization techniques to compare distributions?
Here's a nice tutorial from Nathan Yau's Flowing Data blog using R and US state-level crime data. It shows:
Box-and-Whisker Plots (which you already use)
Histograms
Kernel Density Plots
Rug Plots
Violin Plots
Bean Plots (a weird combo of a box plot, density plot, with a rug in the middle).
Lately, I find myself plotting CDFs much more than histograms.
|
What are good data visualization techniques to compare distributions?
Here's a nice tutorial from Nathan Yau's Flowing Data blog using R and US state-level crime data. It shows:
Box-and-Whisker Plots (which you already use)
Histograms
Kernel Density Plots
Rug Plots
Vio
|
8,765
|
What are good data visualization techniques to compare distributions?
|
A note:
You want to answer questions about your data, and not create questions about the visualization method itself. Often, boring is better. It does make comparisons of comparisons easier to comprehend too.
An Answer:
The need for simple formatting beyond R's base package probably explains the popularity of Hadley's ggplot package in R.
library(sn)
library(ggplot2)
# Simulate from a normal and skew-normal distributions
x = rnorm(250,0,1)
y = rsn(250,0,1,5)
##============================================================================
## I put the data into a data frame for ease of use
##============================================================================
dat = data.frame(x,y=y[1:250]) ## y[1:250] is used to remove attributes of y
str(dat)
dat = stack(dat)
str(dat)
##============================================================================
## Density plots with ggplot2
##============================================================================
ggplot(dat,
aes(x=values, fill=ind, y=..scaled..)) +
geom_density() +
opts(title = "Some Example Densities") +
opts(plot.title = theme_text(size = 20, colour = "Black"))
ggplot(dat,
aes(x=values, fill=ind, y=..scaled..)) +
geom_density() +
facet_grid(ind ~ .) +
opts(title = "Some Example Densities \n Faceted") +
opts(plot.title = theme_text(size = 20, colour = "Black"))
ggplot(dat,
aes(x=values, fill=ind)) +
geom_density() +
facet_grid(ind ~ .) +
opts(title = "Some Densities \n This time without \"scaled\" ") +
opts(plot.title = theme_text(size = 20, colour = "Black"))
##----------------------------------------------------------------------------
## You can do histograms in ggplot2 as well...
## but I don't think that you can get all the good stats
## in a table, as with hist
## e.g. stats = hist(x)
##----------------------------------------------------------------------------
ggplot(dat,
aes(x=values, fill=ind)) +
geom_histogram(binwidth=.1) +
facet_grid(ind ~ .) +
opts(title = "Some Example Histograms \n Faceted") +
opts(plot.title = theme_text(size = 20, colour = "Black"))
## Note, I put in code to mimic the default "30 bins" setting
ggplot(dat,
aes(x=values, fill=ind)) +
geom_histogram(binwidth=diff(range(dat$values))/30) +
opts(title = "Some Example Histograms") +
opts(plot.title = theme_text(size = 20, colour = "Black"))
Finally, I've found that adding a simple background helps.
Which is why I wrote "bgfun" which can be called by panel.first
bgfun = function (color="honeydew2", linecolor="grey45", addgridlines=TRUE) {
tmp = par("usr")
rect(tmp[1], tmp[3], tmp[2], tmp[4], col = color)
if (addgridlines) {
ylimits = par()$usr[c(3, 4)]
abline(h = pretty(ylimits, 10), lty = 2, col = linecolor)
}
}
plot(rnorm(100), panel.first=bgfun())
## Plot with original example data
op = par(mfcol=c(2,1))
hist(x, panel.first=bgfun(), col='antiquewhite1', main='Bases belonging to us')
hist(y, panel.first=bgfun(color='darkolivegreen2'),
col='antiquewhite2', main='Bases not belonging to us')
mtext( 'all your base are belong to us', 1, 4)
par(op)
|
What are good data visualization techniques to compare distributions?
|
A note:
You want to answer questions about your data, and not create questions about the visualization method itself. Often, boring is better. It does make comparisons of comparisons easier to compr
|
What are good data visualization techniques to compare distributions?
A note:
You want to answer questions about your data, and not create questions about the visualization method itself. Often, boring is better. It does make comparisons of comparisons easier to comprehend too.
An Answer:
The need for simple formatting beyond R's base package probably explains the popularity of Hadley's ggplot package in R.
library(sn)
library(ggplot2)
# Simulate from a normal and skew-normal distributions
x = rnorm(250,0,1)
y = rsn(250,0,1,5)
##============================================================================
## I put the data into a data frame for ease of use
##============================================================================
dat = data.frame(x,y=y[1:250]) ## y[1:250] is used to remove attributes of y
str(dat)
dat = stack(dat)
str(dat)
##============================================================================
## Density plots with ggplot2
##============================================================================
ggplot(dat,
aes(x=values, fill=ind, y=..scaled..)) +
geom_density() +
opts(title = "Some Example Densities") +
opts(plot.title = theme_text(size = 20, colour = "Black"))
ggplot(dat,
aes(x=values, fill=ind, y=..scaled..)) +
geom_density() +
facet_grid(ind ~ .) +
opts(title = "Some Example Densities \n Faceted") +
opts(plot.title = theme_text(size = 20, colour = "Black"))
ggplot(dat,
aes(x=values, fill=ind)) +
geom_density() +
facet_grid(ind ~ .) +
opts(title = "Some Densities \n This time without \"scaled\" ") +
opts(plot.title = theme_text(size = 20, colour = "Black"))
##----------------------------------------------------------------------------
## You can do histograms in ggplot2 as well...
## but I don't think that you can get all the good stats
## in a table, as with hist
## e.g. stats = hist(x)
##----------------------------------------------------------------------------
ggplot(dat,
aes(x=values, fill=ind)) +
geom_histogram(binwidth=.1) +
facet_grid(ind ~ .) +
opts(title = "Some Example Histograms \n Faceted") +
opts(plot.title = theme_text(size = 20, colour = "Black"))
## Note, I put in code to mimic the default "30 bins" setting
ggplot(dat,
aes(x=values, fill=ind)) +
geom_histogram(binwidth=diff(range(dat$values))/30) +
opts(title = "Some Example Histograms") +
opts(plot.title = theme_text(size = 20, colour = "Black"))
Finally, I've found that adding a simple background helps.
Which is why I wrote "bgfun" which can be called by panel.first
bgfun = function (color="honeydew2", linecolor="grey45", addgridlines=TRUE) {
tmp = par("usr")
rect(tmp[1], tmp[3], tmp[2], tmp[4], col = color)
if (addgridlines) {
ylimits = par()$usr[c(3, 4)]
abline(h = pretty(ylimits, 10), lty = 2, col = linecolor)
}
}
plot(rnorm(100), panel.first=bgfun())
## Plot with original example data
op = par(mfcol=c(2,1))
hist(x, panel.first=bgfun(), col='antiquewhite1', main='Bases belonging to us')
hist(y, panel.first=bgfun(color='darkolivegreen2'),
col='antiquewhite2', main='Bases not belonging to us')
mtext( 'all your base are belong to us', 1, 4)
par(op)
|
What are good data visualization techniques to compare distributions?
A note:
You want to answer questions about your data, and not create questions about the visualization method itself. Often, boring is better. It does make comparisons of comparisons easier to compr
|
8,766
|
What are good data visualization techniques to compare distributions?
|
There is a concept specifically for comparing distributions, which ought to be better known: the relative distribution.
Let's say we have random variables $Y_0, Y$ with cumulative distribution functions $F_0, F$ and we want to compare them, using $F_0$ as a reference.
Define
$$
R = F_0(Y)
$$
The distribution of the random variable $R$ is the relative distribution of $Y$, with $Y_0$ as reference. Note that we have that $F_0(Y_0)$ has always the uniform distribution (with continuous random variables, if the random variables are discrete this will be approximate).
Let us look at an example. The website http://www.math.hope.edu/swanson/data/cellphone.txt gives data on the length of male and female students' last phone call. Let us express the distribution of phone call length for male students, with women students as reference.
We can see immediately that men (in this college class ...) tend to have shorter phone calls than women ... and this is expressed directly, in a very direct way. On the $x$ axis is shown the proportions in the women's distribution, and we can read that, for example, for the time $T$ (whatever it is, its value is not shown) such that 20% of women's calls were shorter (or equal) to that, the relative density for men in that interval varies between about 1.3 and 1.4. If we approximate (mentally from the graph) the mean relative density in that interval as 1.35, we see that the proportion of men in that interval is about 35% higher than the proportion of women. That corresponds to 27% of the men in that interval.
We can also make the same plot with pointwise confidence intervals around the relative density curve:
The wide confidence bands in this case reflects the small sample size.
There is a book about this method: Handcock
The R code for the plot is here:
phone <- read.table(file="phone.txt", header=TRUE)
library(reldist)
men <- phone[, 1]
women <- phone[, 3]
reldist(men, women)
title("length of men's last phonecall with women as reference")
For the last plot change to:
reldist(men, women, ci=TRUE)
title("length of men's last phonecall with women as
reference\nwith pointwise confidence interval (95%)")
Note that the plots are produced with use of kernel density estimation, with degree of smoothness chosen via gcv (generalized cross validation).
Some more details about the relative density. Let $Q_0$ be the quantile function corresponding to $F_0$. Let $r$ be a quantile of $R$ with $y_r$ the corresponding value on the original measurement scale. Then the relative density can be written as
$$
g(r) = \frac{f(Q_0(r))}{f_0(Q_0(r))}
$$
or on the original measurement scale as $g(r)=\frac{f(y_r)}{f_0(y_r)}$.
This shows that the relative density can be interpreted as a ratio of densities. But, in the first form, with argument $r$, it is also a density in own right, integrating to one over the interval $(0,1)$.
That makes it a good starting point for inference.
|
What are good data visualization techniques to compare distributions?
|
There is a concept specifically for comparing distributions, which ought to be better known: the relative distribution.
Let's say we have random variables $Y_0, Y$ with cumulative distribution functio
|
What are good data visualization techniques to compare distributions?
There is a concept specifically for comparing distributions, which ought to be better known: the relative distribution.
Let's say we have random variables $Y_0, Y$ with cumulative distribution functions $F_0, F$ and we want to compare them, using $F_0$ as a reference.
Define
$$
R = F_0(Y)
$$
The distribution of the random variable $R$ is the relative distribution of $Y$, with $Y_0$ as reference. Note that we have that $F_0(Y_0)$ has always the uniform distribution (with continuous random variables, if the random variables are discrete this will be approximate).
Let us look at an example. The website http://www.math.hope.edu/swanson/data/cellphone.txt gives data on the length of male and female students' last phone call. Let us express the distribution of phone call length for male students, with women students as reference.
We can see immediately that men (in this college class ...) tend to have shorter phone calls than women ... and this is expressed directly, in a very direct way. On the $x$ axis is shown the proportions in the women's distribution, and we can read that, for example, for the time $T$ (whatever it is, its value is not shown) such that 20% of women's calls were shorter (or equal) to that, the relative density for men in that interval varies between about 1.3 and 1.4. If we approximate (mentally from the graph) the mean relative density in that interval as 1.35, we see that the proportion of men in that interval is about 35% higher than the proportion of women. That corresponds to 27% of the men in that interval.
We can also make the same plot with pointwise confidence intervals around the relative density curve:
The wide confidence bands in this case reflects the small sample size.
There is a book about this method: Handcock
The R code for the plot is here:
phone <- read.table(file="phone.txt", header=TRUE)
library(reldist)
men <- phone[, 1]
women <- phone[, 3]
reldist(men, women)
title("length of men's last phonecall with women as reference")
For the last plot change to:
reldist(men, women, ci=TRUE)
title("length of men's last phonecall with women as
reference\nwith pointwise confidence interval (95%)")
Note that the plots are produced with use of kernel density estimation, with degree of smoothness chosen via gcv (generalized cross validation).
Some more details about the relative density. Let $Q_0$ be the quantile function corresponding to $F_0$. Let $r$ be a quantile of $R$ with $y_r$ the corresponding value on the original measurement scale. Then the relative density can be written as
$$
g(r) = \frac{f(Q_0(r))}{f_0(Q_0(r))}
$$
or on the original measurement scale as $g(r)=\frac{f(y_r)}{f_0(y_r)}$.
This shows that the relative density can be interpreted as a ratio of densities. But, in the first form, with argument $r$, it is also a density in own right, integrating to one over the interval $(0,1)$.
That makes it a good starting point for inference.
|
What are good data visualization techniques to compare distributions?
There is a concept specifically for comparing distributions, which ought to be better known: the relative distribution.
Let's say we have random variables $Y_0, Y$ with cumulative distribution functio
|
8,767
|
What are good data visualization techniques to compare distributions?
|
I strongly recommend quantile plots, here in the first instance plots of the data in rank order (observed quantiles) against cumulative probability. Many quantile plots are explicitly plots against some other quantiles, and may be called quantile-quantile plots or QQ-plots. A plot against cumulative probability is not an exception as values on the horizontal axis are quantiles of a uniform (rectangular, flat) distribution on the unit interval. Although quantiles in statistics are often (usually!) particular summary points, such as quartiles, deciles, or percentiles, in this graphical context quantiles are simply all the ordered data, or equivalently the order statistics of several values on some variable.
Quantile plots entail no arbitrary decisions about binning or smoothing and represent the data as they arrive, showing level, spread, and shape (including outliers, gaps, spikes and other detail as it occurs). A convention to show data points as points is just that; for a large sample the pattern of points often blurs into a line, which is genuine whenever it is observed and not a limitation. Line representations are also possible.
Here I echo a previous answer and use the Iris data from E.S. Anderson, as made famous by R.A. Fisher.
The choice between superimposed and juxtaposed should always be one of which works best. In this example superimposition works well, although with other datasets it can lead to tangled spaghetti. The picture for these data is mostly that the subsets differ in level, with loosely similar spread and shape, although extra detail can be spotted (e.g. conventional rounding in reporting results and a mild outlier on virginica).
Quantile plots can be smoothed, although this seems rarely done. Conversely, it can be argued that reducing data to a smaller set of say letter values preserves most of the information on each distribution. This paper is a gateway to older literature. Although named by John W. Tukey, letter values go back at least to Francis Galton.
Quantile plots can even be used for categorical data so long as they have numerical codes. The stepped nature of the resulting plots is realistic and if the point is to compare the same variable for different subsets, or for similar variables, the essential is just that values are coded consistently, which is hardly demanding.
A default quantile plot just plots observed values against an associated cumulative probability, in this context often called a plotting position.
In many cases it will be a good idea to plot against some theoretical quantile, essentially the result of pushing a plotting position through a quantile function. This is natural if a particular distribution is in mind, or at least a particular distribution may serve as a reference distribution. As many authors have noted, taking a normal (Gaussian) distribution as reference may be quite widely convenient. It is exactly the right thing to do if comparisons with normal distributions are of direct concern, and not absurd even if they aren't. The use of normal distribution as reference no more implies that data are, or should be, normally distributed, than does comparing shapes with circles or spheres, comparing altitudes with sea level, or comparing temperatures with the freezing point of water. If some other family of distributions is a better reference, say gamma or exponential, then use it. Similarly, monotonic transformations of the observed quantiles (e.g. a logarithmic scale) may often help, the essential being that such transformations preserve order.
The same information in principle is encoded in (empirical (cumulative)) distribution function plots (ECDF plots) or in survival function plots. In practice, quantile plots can make it easier to look at tail behaviour closely, while ECDF plots perhaps make comparisons of middles of distributions slightly easier. The choice often comes down to tribal habits as much as personal taste or comparisons of which work best in some sense.
This is, or should be, very easy in R, and indeed in your favourite statistical or mathematical software if different. If not, you need a new favourite.
|
What are good data visualization techniques to compare distributions?
|
I strongly recommend quantile plots, here in the first instance plots of the data in rank order (observed quantiles) against cumulative probability. Many quantile plots are explicitly plots against so
|
What are good data visualization techniques to compare distributions?
I strongly recommend quantile plots, here in the first instance plots of the data in rank order (observed quantiles) against cumulative probability. Many quantile plots are explicitly plots against some other quantiles, and may be called quantile-quantile plots or QQ-plots. A plot against cumulative probability is not an exception as values on the horizontal axis are quantiles of a uniform (rectangular, flat) distribution on the unit interval. Although quantiles in statistics are often (usually!) particular summary points, such as quartiles, deciles, or percentiles, in this graphical context quantiles are simply all the ordered data, or equivalently the order statistics of several values on some variable.
Quantile plots entail no arbitrary decisions about binning or smoothing and represent the data as they arrive, showing level, spread, and shape (including outliers, gaps, spikes and other detail as it occurs). A convention to show data points as points is just that; for a large sample the pattern of points often blurs into a line, which is genuine whenever it is observed and not a limitation. Line representations are also possible.
Here I echo a previous answer and use the Iris data from E.S. Anderson, as made famous by R.A. Fisher.
The choice between superimposed and juxtaposed should always be one of which works best. In this example superimposition works well, although with other datasets it can lead to tangled spaghetti. The picture for these data is mostly that the subsets differ in level, with loosely similar spread and shape, although extra detail can be spotted (e.g. conventional rounding in reporting results and a mild outlier on virginica).
Quantile plots can be smoothed, although this seems rarely done. Conversely, it can be argued that reducing data to a smaller set of say letter values preserves most of the information on each distribution. This paper is a gateway to older literature. Although named by John W. Tukey, letter values go back at least to Francis Galton.
Quantile plots can even be used for categorical data so long as they have numerical codes. The stepped nature of the resulting plots is realistic and if the point is to compare the same variable for different subsets, or for similar variables, the essential is just that values are coded consistently, which is hardly demanding.
A default quantile plot just plots observed values against an associated cumulative probability, in this context often called a plotting position.
In many cases it will be a good idea to plot against some theoretical quantile, essentially the result of pushing a plotting position through a quantile function. This is natural if a particular distribution is in mind, or at least a particular distribution may serve as a reference distribution. As many authors have noted, taking a normal (Gaussian) distribution as reference may be quite widely convenient. It is exactly the right thing to do if comparisons with normal distributions are of direct concern, and not absurd even if they aren't. The use of normal distribution as reference no more implies that data are, or should be, normally distributed, than does comparing shapes with circles or spheres, comparing altitudes with sea level, or comparing temperatures with the freezing point of water. If some other family of distributions is a better reference, say gamma or exponential, then use it. Similarly, monotonic transformations of the observed quantiles (e.g. a logarithmic scale) may often help, the essential being that such transformations preserve order.
The same information in principle is encoded in (empirical (cumulative)) distribution function plots (ECDF plots) or in survival function plots. In practice, quantile plots can make it easier to look at tail behaviour closely, while ECDF plots perhaps make comparisons of middles of distributions slightly easier. The choice often comes down to tribal habits as much as personal taste or comparisons of which work best in some sense.
This is, or should be, very easy in R, and indeed in your favourite statistical or mathematical software if different. If not, you need a new favourite.
|
What are good data visualization techniques to compare distributions?
I strongly recommend quantile plots, here in the first instance plots of the data in rank order (observed quantiles) against cumulative probability. Many quantile plots are explicitly plots against so
|
8,768
|
What are good data visualization techniques to compare distributions?
|
I like to just estimate the densities and plot them,
head(iris)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 5.1 3.5 1.4 0.2 setosa
2 4.9 3.0 1.4 0.2 setosa
3 4.7 3.2 1.3 0.2 setosa
4 4.6 3.1 1.5 0.2 setosa
5 5.0 3.6 1.4 0.2 setosa
6 5.4 3.9 1.7 0.4 setosa
library(ggplot2)
ggplot(data = iris) + geom_density(aes(x = Sepal.Length, color = Species, fill = Species), alpha = .2)
|
What are good data visualization techniques to compare distributions?
|
I like to just estimate the densities and plot them,
head(iris)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 5.1 3.5 1.4 0.2 setosa
2 4.9
|
What are good data visualization techniques to compare distributions?
I like to just estimate the densities and plot them,
head(iris)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 5.1 3.5 1.4 0.2 setosa
2 4.9 3.0 1.4 0.2 setosa
3 4.7 3.2 1.3 0.2 setosa
4 4.6 3.1 1.5 0.2 setosa
5 5.0 3.6 1.4 0.2 setosa
6 5.4 3.9 1.7 0.4 setosa
library(ggplot2)
ggplot(data = iris) + geom_density(aes(x = Sepal.Length, color = Species, fill = Species), alpha = .2)
|
What are good data visualization techniques to compare distributions?
I like to just estimate the densities and plot them,
head(iris)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 5.1 3.5 1.4 0.2 setosa
2 4.9
|
8,769
|
Multiple Imputation by Chained Equations (MICE) Explained
|
MICE is a multiple imputation method used to replace missing data values in a data set under certain assumptions about the data missingness mechanism (e.g., the data are missing at random, the data are missing completely at random).
If you start out with a data set which includes missing values in one or more of its variables, you can create multiple copies of this data set - for example, you can create 5 copies of the original data set - and replace the missing data values in each copy using the MICE procedure. You can then:
Analyze the 5 complete data set copies using your intended statistical analysis;
Combine (or pool) the results of these complete data analyses;
Report the combined result.
The rules for combining (or pooling) results are specific to the results being combined and were initially developed by Rubin.
Figure 1 in the article Multiple Imputation by Chained Equations in Praxis: Guidelines and Review by Jesper N. Wulff and Linda Ejlskov is visually summarizes the process described above: https://vbn.aau.dk/en/publications/multiple-imputation-by-chained-equations-in-praxis-guidelines-and.
How does MICE replace the missing data values in each copy of the original data set?
The article Multiple Imputation by Chained Equations: What is it and how does it work? by Azur et al. explains what happens underneath the MICE hood with a nice example: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3074241/
In the example, the author articles start out with a simple data set which includes only 3 variables: age, income, and gender. All 3 have at least some missing values.
To apply MICE, create 5 copies (say) of this simple data set and cycle multiple times through the steps below for each copy:
Step 1: Replace (or impute) the missing values in each variable with temporary "place holder" values derived solely from the non-missing values available for that variable. For example, replace the missing age value with the mean age value observed in the data, replace the missing income values with the mean income value observed in the data, etc.
Step 2 Set back to missing the “place holder” imputations for the age variable only. This way, the current data copy contains missing values for age, but not for income and gender.
Step 3: Regress age on income and gender via a linear regression model (though it is possible to also regress age on only one of these variables); to be able to fit the model to the current data copy, drop all the records where age is missing during the model fitting process. In this model, age is the dependent variable and income and gender are the independent variables.
Step 4 Use the fitted regression model in the previous step to predict the missing age values. (When age will be subsequently used as an independent variable in the regression models for other variables, both the observed values of age and these predicted values will be used.) The article doesn't make it clear that a random component should be added to these predictions.
Step 5: Repeat Steps 2–4 separately for each variable that has missing data, namely income and gender.
Cycling through Steps 1–5 once for each of the variables age, income and gender constitutes one cycle. At the end of this cycle, all of the missing values in age, income an gender will have been replaced with predictions from regression models that reflect the relationships observed in the data between these variables.
As stated earlier, MICE requires that we cycle through Steps 1–5 for a number of cycles, with the imputations of the missing values of age, income and gender being updated at each subsequent cycle.
We can specify in advance the number of cycles to be performed (e.g., 10 cycles) – once we reach the final cycle, we retain the imputed values corresponding to that final cycle, obtaining an imputed data set (i.e., a data set where all missing values in age, gender and income were replaced with imputed data values obtained via an iterative procedure).
To sum up, MICE imputes missing values in the variables of a data set by using a divide and conquer approach – in other words, by focusing on one variable at a time. Once the focus is placed on one variable, MICE uses all the other variables in the data set (or a sensibly chosen subset of these variables) to predict missingness in that variable. The prediction is based on a regression model, with the form of the model depending on the nature of the focus variable (e.g., age and income will require linear regression models for prediction of their missing values, but gender will require a logistic regression model).
|
Multiple Imputation by Chained Equations (MICE) Explained
|
MICE is a multiple imputation method used to replace missing data values in a data set under certain assumptions about the data missingness mechanism (e.g., the data are missing at random, the data ar
|
Multiple Imputation by Chained Equations (MICE) Explained
MICE is a multiple imputation method used to replace missing data values in a data set under certain assumptions about the data missingness mechanism (e.g., the data are missing at random, the data are missing completely at random).
If you start out with a data set which includes missing values in one or more of its variables, you can create multiple copies of this data set - for example, you can create 5 copies of the original data set - and replace the missing data values in each copy using the MICE procedure. You can then:
Analyze the 5 complete data set copies using your intended statistical analysis;
Combine (or pool) the results of these complete data analyses;
Report the combined result.
The rules for combining (or pooling) results are specific to the results being combined and were initially developed by Rubin.
Figure 1 in the article Multiple Imputation by Chained Equations in Praxis: Guidelines and Review by Jesper N. Wulff and Linda Ejlskov is visually summarizes the process described above: https://vbn.aau.dk/en/publications/multiple-imputation-by-chained-equations-in-praxis-guidelines-and.
How does MICE replace the missing data values in each copy of the original data set?
The article Multiple Imputation by Chained Equations: What is it and how does it work? by Azur et al. explains what happens underneath the MICE hood with a nice example: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3074241/
In the example, the author articles start out with a simple data set which includes only 3 variables: age, income, and gender. All 3 have at least some missing values.
To apply MICE, create 5 copies (say) of this simple data set and cycle multiple times through the steps below for each copy:
Step 1: Replace (or impute) the missing values in each variable with temporary "place holder" values derived solely from the non-missing values available for that variable. For example, replace the missing age value with the mean age value observed in the data, replace the missing income values with the mean income value observed in the data, etc.
Step 2 Set back to missing the “place holder” imputations for the age variable only. This way, the current data copy contains missing values for age, but not for income and gender.
Step 3: Regress age on income and gender via a linear regression model (though it is possible to also regress age on only one of these variables); to be able to fit the model to the current data copy, drop all the records where age is missing during the model fitting process. In this model, age is the dependent variable and income and gender are the independent variables.
Step 4 Use the fitted regression model in the previous step to predict the missing age values. (When age will be subsequently used as an independent variable in the regression models for other variables, both the observed values of age and these predicted values will be used.) The article doesn't make it clear that a random component should be added to these predictions.
Step 5: Repeat Steps 2–4 separately for each variable that has missing data, namely income and gender.
Cycling through Steps 1–5 once for each of the variables age, income and gender constitutes one cycle. At the end of this cycle, all of the missing values in age, income an gender will have been replaced with predictions from regression models that reflect the relationships observed in the data between these variables.
As stated earlier, MICE requires that we cycle through Steps 1–5 for a number of cycles, with the imputations of the missing values of age, income and gender being updated at each subsequent cycle.
We can specify in advance the number of cycles to be performed (e.g., 10 cycles) – once we reach the final cycle, we retain the imputed values corresponding to that final cycle, obtaining an imputed data set (i.e., a data set where all missing values in age, gender and income were replaced with imputed data values obtained via an iterative procedure).
To sum up, MICE imputes missing values in the variables of a data set by using a divide and conquer approach – in other words, by focusing on one variable at a time. Once the focus is placed on one variable, MICE uses all the other variables in the data set (or a sensibly chosen subset of these variables) to predict missingness in that variable. The prediction is based on a regression model, with the form of the model depending on the nature of the focus variable (e.g., age and income will require linear regression models for prediction of their missing values, but gender will require a logistic regression model).
|
Multiple Imputation by Chained Equations (MICE) Explained
MICE is a multiple imputation method used to replace missing data values in a data set under certain assumptions about the data missingness mechanism (e.g., the data are missing at random, the data ar
|
8,770
|
How can top principal components retain the predictive power on a dependent variable (or even lead to better predictions)?
|
Indeed, there is no guarantee that top principal components (PCs) have more predictive power than the low-variance ones.
Real-world examples can be found where this is not the case, and it is easy to construct an artificial example where e.g. only the smallest PC has any relation to $y$ at all.
This topic was discussed a lot on our forum, and in the (unfortunate) absence of one clearly canonical thread, I can only give several links that together provide various real life as well as artificial examples:
Low variance components in PCA, are they really just noise? Is there any way to test for it?
Examples of PCA where PCs with low variance are "useful"
How can a later principal component be significant predictor in a regression, when an earlier PC is not?
How to use principal components analysis to select variables for regression?
And the same topic, but in the context of classification:
What can cause PCA to worsen results of a classifier?
The first principal component does not separate classes, but other PCs do; how is that possible?
However, in practice, top PCs often do often have more predictive power than the low-variance ones, and moreover, using only top PCs can yield better predictive power than using all PCs.
In situations with a lot of predictors $p$ and relatively few data points $n$ (e.g. when $p \approx n$ or even $p>n$), ordinary regression will overfit and needs to be regularized. Principal component regression (PCR) can be seen as one way to regularize the regression and will tend to give superior results. Moreover, it is closely related to ridge regression, which is a standard way of shrinkage regularization. Whereas using ridge regression is usually a better idea, PCR will often behave reasonably well. See Why does shrinkage work? for the general discussion about bias-variance tradeoff and about how shrinkage can be beneficial.
In a way, one can say that both ridge regression and PCR assume that most information about $y$ is contained in the large PCs of $X$, and this assumption is often warranted.
See the later answer by @cbeleites (+1) for some discussion about why this assumption is often warranted (and also this newer thread: Is dimensionality reduction almost always useful for classification? for some further comments).
Hastie et al. in The Elements of Statistical Learning (section 3.4.1) comment on this in the context of ridge regression:
[T]he small singular values [...] correspond to directions in the column space of $\mathbf X$ having small variance, and ridge regression shrinks these directions the most. [...] Ridge regression protects against the potentially high variance
of gradients estimated in the short directions. The implicit assumption is
that the response will tend to vary most in the directions of high variance
of the inputs. This is often a reasonable assumption, since predictors are
often chosen for study because they vary with the response variable, but
need not hold in general.
See my answers in the following threads for details:
What is the advantage of reducing dimensionality of predictors for the purposes of regression?
Relationship between ridge regression and PCA regression
Does it make sense to combine PCA and LDA?
Bottom line
For high-dimensional problems, pre-processing with PCA (meaning reducing dimensionality and keeping only top PCs) can be seen as one way of regularization and will often improve the results of any subsequent analysis, be it a regression or a classification method. But there is no guarantee that this will work, and there are often better regularization approaches.
|
How can top principal components retain the predictive power on a dependent variable (or even lead t
|
Indeed, there is no guarantee that top principal components (PCs) have more predictive power than the low-variance ones.
Real-world examples can be found where this is not the case, and it is easy to
|
How can top principal components retain the predictive power on a dependent variable (or even lead to better predictions)?
Indeed, there is no guarantee that top principal components (PCs) have more predictive power than the low-variance ones.
Real-world examples can be found where this is not the case, and it is easy to construct an artificial example where e.g. only the smallest PC has any relation to $y$ at all.
This topic was discussed a lot on our forum, and in the (unfortunate) absence of one clearly canonical thread, I can only give several links that together provide various real life as well as artificial examples:
Low variance components in PCA, are they really just noise? Is there any way to test for it?
Examples of PCA where PCs with low variance are "useful"
How can a later principal component be significant predictor in a regression, when an earlier PC is not?
How to use principal components analysis to select variables for regression?
And the same topic, but in the context of classification:
What can cause PCA to worsen results of a classifier?
The first principal component does not separate classes, but other PCs do; how is that possible?
However, in practice, top PCs often do often have more predictive power than the low-variance ones, and moreover, using only top PCs can yield better predictive power than using all PCs.
In situations with a lot of predictors $p$ and relatively few data points $n$ (e.g. when $p \approx n$ or even $p>n$), ordinary regression will overfit and needs to be regularized. Principal component regression (PCR) can be seen as one way to regularize the regression and will tend to give superior results. Moreover, it is closely related to ridge regression, which is a standard way of shrinkage regularization. Whereas using ridge regression is usually a better idea, PCR will often behave reasonably well. See Why does shrinkage work? for the general discussion about bias-variance tradeoff and about how shrinkage can be beneficial.
In a way, one can say that both ridge regression and PCR assume that most information about $y$ is contained in the large PCs of $X$, and this assumption is often warranted.
See the later answer by @cbeleites (+1) for some discussion about why this assumption is often warranted (and also this newer thread: Is dimensionality reduction almost always useful for classification? for some further comments).
Hastie et al. in The Elements of Statistical Learning (section 3.4.1) comment on this in the context of ridge regression:
[T]he small singular values [...] correspond to directions in the column space of $\mathbf X$ having small variance, and ridge regression shrinks these directions the most. [...] Ridge regression protects against the potentially high variance
of gradients estimated in the short directions. The implicit assumption is
that the response will tend to vary most in the directions of high variance
of the inputs. This is often a reasonable assumption, since predictors are
often chosen for study because they vary with the response variable, but
need not hold in general.
See my answers in the following threads for details:
What is the advantage of reducing dimensionality of predictors for the purposes of regression?
Relationship between ridge regression and PCA regression
Does it make sense to combine PCA and LDA?
Bottom line
For high-dimensional problems, pre-processing with PCA (meaning reducing dimensionality and keeping only top PCs) can be seen as one way of regularization and will often improve the results of any subsequent analysis, be it a regression or a classification method. But there is no guarantee that this will work, and there are often better regularization approaches.
|
How can top principal components retain the predictive power on a dependent variable (or even lead t
Indeed, there is no guarantee that top principal components (PCs) have more predictive power than the low-variance ones.
Real-world examples can be found where this is not the case, and it is easy to
|
8,771
|
How can top principal components retain the predictive power on a dependent variable (or even lead to better predictions)?
|
In addition to the answers that already focus on the mathematical properties, I'd like to comment from an experimental point of view.
Summary: data generation processes are often optimized in a way that makes the data suitable for principal component (PCR) or partial least squares (PLS) regression.
I'm analytical chemist. When I designing an experiment/method to measure (regression or classification) something, I use my knowledge about application and available instruments to get data that carries a good signal to noise ratio with respect to the task at hand. That means, the data I generate is designed to have large covariance with the property of interest.
This leads to a variance structure where the interesting variance is large, and the later PCs will carry the (small) noise only.
I'd also prefer methods that yield redundant information about the task at hand, in order to have more robust or more precise results. PCA concentrates redundant measurement channels into one PC, which then carries much variance and is therefore one of the first PCs.
If there are known confounders that will lead to large variance that is not correlated with the property of interest, I'll usually try to correct for these as much as possible during the preprocessing of the data: in many cases these confounders are of a known physical or chemical nature, and this knowledge suggests appropriate ways to correct for the confounders. E.g. I measure Raman spectra under the microscope. Their intensity depends on the intensity of the laser light as well as on how well I can focus the microscope. Both lead to changes that can be corrected by normalizing e.g. to a signal that is known to be constant.
Thus, large contributors of variance that does not contribute to the solution may have been eliminated before the data enters PCA, leaving mostly meaningful variance in the first PCs.
Last but not least, there's a bit of a self-fulfilling prophecy here: Obviously PCR is done with data where the assumption that the information carrying variance is large does make sense. If e.g. I think that there could be important confounders that I don't know how to correct for, I'd immediately go for PLS which is better at ignoring large contributions that do not help with the prediction task.
|
How can top principal components retain the predictive power on a dependent variable (or even lead t
|
In addition to the answers that already focus on the mathematical properties, I'd like to comment from an experimental point of view.
Summary: data generation processes are often optimized in a way t
|
How can top principal components retain the predictive power on a dependent variable (or even lead to better predictions)?
In addition to the answers that already focus on the mathematical properties, I'd like to comment from an experimental point of view.
Summary: data generation processes are often optimized in a way that makes the data suitable for principal component (PCR) or partial least squares (PLS) regression.
I'm analytical chemist. When I designing an experiment/method to measure (regression or classification) something, I use my knowledge about application and available instruments to get data that carries a good signal to noise ratio with respect to the task at hand. That means, the data I generate is designed to have large covariance with the property of interest.
This leads to a variance structure where the interesting variance is large, and the later PCs will carry the (small) noise only.
I'd also prefer methods that yield redundant information about the task at hand, in order to have more robust or more precise results. PCA concentrates redundant measurement channels into one PC, which then carries much variance and is therefore one of the first PCs.
If there are known confounders that will lead to large variance that is not correlated with the property of interest, I'll usually try to correct for these as much as possible during the preprocessing of the data: in many cases these confounders are of a known physical or chemical nature, and this knowledge suggests appropriate ways to correct for the confounders. E.g. I measure Raman spectra under the microscope. Their intensity depends on the intensity of the laser light as well as on how well I can focus the microscope. Both lead to changes that can be corrected by normalizing e.g. to a signal that is known to be constant.
Thus, large contributors of variance that does not contribute to the solution may have been eliminated before the data enters PCA, leaving mostly meaningful variance in the first PCs.
Last but not least, there's a bit of a self-fulfilling prophecy here: Obviously PCR is done with data where the assumption that the information carrying variance is large does make sense. If e.g. I think that there could be important confounders that I don't know how to correct for, I'd immediately go for PLS which is better at ignoring large contributions that do not help with the prediction task.
|
How can top principal components retain the predictive power on a dependent variable (or even lead t
In addition to the answers that already focus on the mathematical properties, I'd like to comment from an experimental point of view.
Summary: data generation processes are often optimized in a way t
|
8,772
|
How can top principal components retain the predictive power on a dependent variable (or even lead to better predictions)?
|
PCA is sometimes used to correct problems caused by collinear variables so that most of the variation in the X space is captured by the K principal components.
But this mathematical problem is of course not the same as capturing most of variation both in X, Y space in such way that unexplained variation is as small as possible.
Partial least squares tries to do this in the latter sense:
http://en.wikipedia.org/wiki/Partial_least_squares_regression
|
How can top principal components retain the predictive power on a dependent variable (or even lead t
|
PCA is sometimes used to correct problems caused by collinear variables so that most of the variation in the X space is captured by the K principal components.
But this mathematical problem is of co
|
How can top principal components retain the predictive power on a dependent variable (or even lead to better predictions)?
PCA is sometimes used to correct problems caused by collinear variables so that most of the variation in the X space is captured by the K principal components.
But this mathematical problem is of course not the same as capturing most of variation both in X, Y space in such way that unexplained variation is as small as possible.
Partial least squares tries to do this in the latter sense:
http://en.wikipedia.org/wiki/Partial_least_squares_regression
|
How can top principal components retain the predictive power on a dependent variable (or even lead t
PCA is sometimes used to correct problems caused by collinear variables so that most of the variation in the X space is captured by the K principal components.
But this mathematical problem is of co
|
8,773
|
How can top principal components retain the predictive power on a dependent variable (or even lead to better predictions)?
|
As other has pointed out, there is no direct link between top k eigenvectors and the predictive power. By picking the top and using them as basis, you are retaining some top energy (or variance along those axis).
It can be that the axis explaining the most variance are actually useful for prediction but in general this is not the case.
|
How can top principal components retain the predictive power on a dependent variable (or even lead t
|
As other has pointed out, there is no direct link between top k eigenvectors and the predictive power. By picking the top and using them as basis, you are retaining some top energy (or variance along
|
How can top principal components retain the predictive power on a dependent variable (or even lead to better predictions)?
As other has pointed out, there is no direct link between top k eigenvectors and the predictive power. By picking the top and using them as basis, you are retaining some top energy (or variance along those axis).
It can be that the axis explaining the most variance are actually useful for prediction but in general this is not the case.
|
How can top principal components retain the predictive power on a dependent variable (or even lead t
As other has pointed out, there is no direct link between top k eigenvectors and the predictive power. By picking the top and using them as basis, you are retaining some top energy (or variance along
|
8,774
|
How can top principal components retain the predictive power on a dependent variable (or even lead to better predictions)?
|
Let me offer one simple explanation.
PCA amounts to removing certain features intuitively. This decreases chances of over-fitting.
|
How can top principal components retain the predictive power on a dependent variable (or even lead t
|
Let me offer one simple explanation.
PCA amounts to removing certain features intuitively. This decreases chances of over-fitting.
|
How can top principal components retain the predictive power on a dependent variable (or even lead to better predictions)?
Let me offer one simple explanation.
PCA amounts to removing certain features intuitively. This decreases chances of over-fitting.
|
How can top principal components retain the predictive power on a dependent variable (or even lead t
Let me offer one simple explanation.
PCA amounts to removing certain features intuitively. This decreases chances of over-fitting.
|
8,775
|
When to avoid Random Forest?
|
Thinking about the specific language of the quotation, a leatherman is a multi-tool: a single piece of hardware with lots of little gizmos tucked into it. It's a pair of pliers, and a knife, and a screwdriver and more! Rather than having to carry each of these tools individually, the leatherman is a single item that you can clip to your trousers so it's always at hand. This is convenient, but the trade-off is that each of the component tools is not the best at its job. The can opener is hard to use, the screwdriver bits are usually the wrong size, and the knife can accomplish little more than whittling. If doing any of these tasks is critical, you'd be better served with a specialized tool: an actual knife, an actual screwdriver, or an actual pair of pliers.
A random forest can be thought of in the same terms. Random forest yields strong results on a variety of data sets, and is not incredibly sensitive to tuning parameters. But it's not perfect. The more you know about the problem, the easier it is to build specialized models to accommodate your particular problem.
There are a couple of obvious cases where random forests will struggle:
Sparsity - When the data are very sparse, it's very plausible that for some node, the bootstrapped sample and the random subset of features will collaborate to produce an invariant feature space. There's no productive split to be had, so it's unlikely that the children of this node will be at all helpful. XGBoost can do better in this context.
Data are not axis-aligned - Suppose that there is a diagonal decision boundary in the space of two features, $x_1$ and $x_2$. Even if this is the only relevant dimension to your data, it will take an ordinary random forest model many splits to describe that diagonal boundary. This is because each split is oriented perpendicular to the axis of either $x_1$ or $x_2$. (This should be intuitive because an ordinary random forest model is making splits of the form $x_1>4$.) Rotation forest, which performs a PCA projection on the subset of features selected for each split, can be used to overcome this: the projections into an orthogonal basis will, in principle, reduce the influence of the axis-aligned property because the splits will no longer be axis-aligned in the original basis.
This image provides another example of how axis-aligned splits influence random forest decisions. The decision boundary is a circle at the origin, but note that this particular random forest model draws a box to approximate the circle. There are a number of things one could do to improve this boundary; the simplest include gathering more data and building more trees.
Random forests basically only work on tabular data, i.e. there is not a strong, qualitatively important relationship among the features in the sense of the data being an image, or the observations being networked together on a graph. These structures are typically not well-approximated by many rectangular partitions. If your data live in a time series, or are a series of images, or live on a graph, or have some other obvious structure, the random forest will have a very hard time recognizing that. I have no doubt that researchers have developed variations on the method to attempt to accommodate these situations, but a vanilla random forest won't necessarily pick up on these structures in a helpful way. The good news is that you typically know when this is the case, i.e. you know you have images, a time-series or a graph to work with, so you can immediately apply a method more appropriate to that type of data.
|
When to avoid Random Forest?
|
Thinking about the specific language of the quotation, a leatherman is a multi-tool: a single piece of hardware with lots of little gizmos tucked into it. It's a pair of pliers, and a knife, and a scr
|
When to avoid Random Forest?
Thinking about the specific language of the quotation, a leatherman is a multi-tool: a single piece of hardware with lots of little gizmos tucked into it. It's a pair of pliers, and a knife, and a screwdriver and more! Rather than having to carry each of these tools individually, the leatherman is a single item that you can clip to your trousers so it's always at hand. This is convenient, but the trade-off is that each of the component tools is not the best at its job. The can opener is hard to use, the screwdriver bits are usually the wrong size, and the knife can accomplish little more than whittling. If doing any of these tasks is critical, you'd be better served with a specialized tool: an actual knife, an actual screwdriver, or an actual pair of pliers.
A random forest can be thought of in the same terms. Random forest yields strong results on a variety of data sets, and is not incredibly sensitive to tuning parameters. But it's not perfect. The more you know about the problem, the easier it is to build specialized models to accommodate your particular problem.
There are a couple of obvious cases where random forests will struggle:
Sparsity - When the data are very sparse, it's very plausible that for some node, the bootstrapped sample and the random subset of features will collaborate to produce an invariant feature space. There's no productive split to be had, so it's unlikely that the children of this node will be at all helpful. XGBoost can do better in this context.
Data are not axis-aligned - Suppose that there is a diagonal decision boundary in the space of two features, $x_1$ and $x_2$. Even if this is the only relevant dimension to your data, it will take an ordinary random forest model many splits to describe that diagonal boundary. This is because each split is oriented perpendicular to the axis of either $x_1$ or $x_2$. (This should be intuitive because an ordinary random forest model is making splits of the form $x_1>4$.) Rotation forest, which performs a PCA projection on the subset of features selected for each split, can be used to overcome this: the projections into an orthogonal basis will, in principle, reduce the influence of the axis-aligned property because the splits will no longer be axis-aligned in the original basis.
This image provides another example of how axis-aligned splits influence random forest decisions. The decision boundary is a circle at the origin, but note that this particular random forest model draws a box to approximate the circle. There are a number of things one could do to improve this boundary; the simplest include gathering more data and building more trees.
Random forests basically only work on tabular data, i.e. there is not a strong, qualitatively important relationship among the features in the sense of the data being an image, or the observations being networked together on a graph. These structures are typically not well-approximated by many rectangular partitions. If your data live in a time series, or are a series of images, or live on a graph, or have some other obvious structure, the random forest will have a very hard time recognizing that. I have no doubt that researchers have developed variations on the method to attempt to accommodate these situations, but a vanilla random forest won't necessarily pick up on these structures in a helpful way. The good news is that you typically know when this is the case, i.e. you know you have images, a time-series or a graph to work with, so you can immediately apply a method more appropriate to that type of data.
|
When to avoid Random Forest?
Thinking about the specific language of the quotation, a leatherman is a multi-tool: a single piece of hardware with lots of little gizmos tucked into it. It's a pair of pliers, and a knife, and a scr
|
8,776
|
When to avoid Random Forest?
|
Sharp corners. Exactness.
They use diffusion methods. They fit lumpy things well. They do not fit elaborate and highly detailed things well when the sample size is low. I would imagine that they do not do well on multivariate time-series data - when something over here depends on that one thing over there a distance.
Gradient boosted forests might fit or over-fit, but can get substantially lower error for the same data.
"Leathermen" do not exist. There are no "silver bullets". There are toolboxes. Know your tools, and take good care of them so they can take care of you. Be wary of "when you are a hammer, then every problem looks like a nail" especially when you do not have a dense library in your toolbox.
Until you know the problem well, it is easy to imagine anything might solve it, or your favorite tool might solve it. Wisdom suggests getting deep in understanding the problem, and being very familiar with your tools.
Added:
If you have enough compute resources or time margin to use something else. The RF is not only fast to train, but fast to execute. A very deep boosted structure is less of that. You have to have the overhead to support that.
|
When to avoid Random Forest?
|
Sharp corners. Exactness.
They use diffusion methods. They fit lumpy things well. They do not fit elaborate and highly detailed things well when the sample size is low. I would imagine that they d
|
When to avoid Random Forest?
Sharp corners. Exactness.
They use diffusion methods. They fit lumpy things well. They do not fit elaborate and highly detailed things well when the sample size is low. I would imagine that they do not do well on multivariate time-series data - when something over here depends on that one thing over there a distance.
Gradient boosted forests might fit or over-fit, but can get substantially lower error for the same data.
"Leathermen" do not exist. There are no "silver bullets". There are toolboxes. Know your tools, and take good care of them so they can take care of you. Be wary of "when you are a hammer, then every problem looks like a nail" especially when you do not have a dense library in your toolbox.
Until you know the problem well, it is easy to imagine anything might solve it, or your favorite tool might solve it. Wisdom suggests getting deep in understanding the problem, and being very familiar with your tools.
Added:
If you have enough compute resources or time margin to use something else. The RF is not only fast to train, but fast to execute. A very deep boosted structure is less of that. You have to have the overhead to support that.
|
When to avoid Random Forest?
Sharp corners. Exactness.
They use diffusion methods. They fit lumpy things well. They do not fit elaborate and highly detailed things well when the sample size is low. I would imagine that they d
|
8,777
|
When to avoid Random Forest?
|
This is the first time I actually answer a question, so do not pin me down on it .. but I do think I can answer your question:
If you are indeed only interested in model performance and not in thing like interpretability, random forest is indeed often a very good learning algorithm, but does perform slightly worse in the following cases:
1.) When the dimensionality (number of features) is very high with respect to the number of training samples, in those cases a regularized linear regression or SVM would be better.
2.) In the case there are higher order representations/convolutional structures in the data, like e.g. in computer vision problems. In those computer vision cases a convolutional neural network will outperform a random forest (In general if there is knowledge one can incorporate into the learning that is a better thing).
That being said random forest are a very good starting point. One of the person I admire for his Machine Learning skills always starts with learning a random forest and a regularized linear regressor.
However, if you want the best possible performance I believe nowadays neural networks aka. Deep Learning is looking like a very attractive approach. More and more winners on data-challenge websites like Kaggle use Deep Learning models for the competition. Another pro of neural networks is that they can handle very large numbers of samples (>10^6 one can train them using stochastic gradient descend, feeding bits of data at a time).
Personally I find this a very attractive pro for Deep Learning.
|
When to avoid Random Forest?
|
This is the first time I actually answer a question, so do not pin me down on it .. but I do think I can answer your question:
If you are indeed only interested in model performance and not in thing l
|
When to avoid Random Forest?
This is the first time I actually answer a question, so do not pin me down on it .. but I do think I can answer your question:
If you are indeed only interested in model performance and not in thing like interpretability, random forest is indeed often a very good learning algorithm, but does perform slightly worse in the following cases:
1.) When the dimensionality (number of features) is very high with respect to the number of training samples, in those cases a regularized linear regression or SVM would be better.
2.) In the case there are higher order representations/convolutional structures in the data, like e.g. in computer vision problems. In those computer vision cases a convolutional neural network will outperform a random forest (In general if there is knowledge one can incorporate into the learning that is a better thing).
That being said random forest are a very good starting point. One of the person I admire for his Machine Learning skills always starts with learning a random forest and a regularized linear regressor.
However, if you want the best possible performance I believe nowadays neural networks aka. Deep Learning is looking like a very attractive approach. More and more winners on data-challenge websites like Kaggle use Deep Learning models for the competition. Another pro of neural networks is that they can handle very large numbers of samples (>10^6 one can train them using stochastic gradient descend, feeding bits of data at a time).
Personally I find this a very attractive pro for Deep Learning.
|
When to avoid Random Forest?
This is the first time I actually answer a question, so do not pin me down on it .. but I do think I can answer your question:
If you are indeed only interested in model performance and not in thing l
|
8,778
|
When to avoid Random Forest?
|
Random forest fits multi-dimensional staircase to your data. It produces sharp edges in predictions. If your data are of continuous nature, then probably there are better methods to fit them. That doesn't mean however that "you should avoid random forest to fit them" :-) I don't think there is any kind of data where you "should be worried" about using RF.
And, I wouldn't say RF is "leatherman", it's definitely not, in the sense that "it will do everything for you". It's just a basic universal method you can use on wide variety of data. I would say it's more like "first simple thing to try", or a "baseline" for benchmarking better methods. I also use it when I want to see which predictor variables are important; there is an excellent R package Boruta for this purpose.
|
When to avoid Random Forest?
|
Random forest fits multi-dimensional staircase to your data. It produces sharp edges in predictions. If your data are of continuous nature, then probably there are better methods to fit them. That doe
|
When to avoid Random Forest?
Random forest fits multi-dimensional staircase to your data. It produces sharp edges in predictions. If your data are of continuous nature, then probably there are better methods to fit them. That doesn't mean however that "you should avoid random forest to fit them" :-) I don't think there is any kind of data where you "should be worried" about using RF.
And, I wouldn't say RF is "leatherman", it's definitely not, in the sense that "it will do everything for you". It's just a basic universal method you can use on wide variety of data. I would say it's more like "first simple thing to try", or a "baseline" for benchmarking better methods. I also use it when I want to see which predictor variables are important; there is an excellent R package Boruta for this purpose.
|
When to avoid Random Forest?
Random forest fits multi-dimensional staircase to your data. It produces sharp edges in predictions. If your data are of continuous nature, then probably there are better methods to fit them. That doe
|
8,779
|
When to avoid Random Forest?
|
There's already many good points by others e.g. about sparse feature spaces, when we know a step-function will not work well/when you don't have a good representation of the data (some of these may of course be a matter of creating better features first), as well as non-tabular data types where other approaches are known to work better especially for how to represent the input data (as mentioned by others: images, text, audio).
However, here are some additional situations that are non-ideal for RF (in approximately descending order of my strength of concern about using RF). Several of these are not specifically an issue with RF, but rather apply more broadly to many prediction modelling approaches.
When we know mechanistically what underlies the system we model. E.g. you can often define a set of biologically sensible differential equations that govern the blood levels of a drug in the human body. You are much better off to set-up a non-linear model based on these, while any modelling approach that ignores this understanding of the biology is going to be a lot less efficient - especially for small datasets -, and likely terrible at extrapolation (see below). I would not ever seriously consider basic RF (or other "default" prediction models like gradient boosted decision trees) here.
When you need to extrapolate beyond your training data. The fitted step-functions will remain constant outside the training feature value range, which will often be an implausible thing to assume. Extrapolation is generally a big challenge, but e.g. mechanistic models from the previous bullet point would be a much, much better bet for extrapolation than RF.
RF is also not so great for multivariate outputs. Even something as simple as many correlated multi-label binary classification tasks can be more efficient with neural networks. It becomes even clearer, when the desired outputs is e.g. an image, a series of values such as a sentence of words, or a variable number of bounding boxes with class assignments.
When you want to causally interpret the effect of a feature. This may be a really silly and obvious thing to point out, but I've seen too many people saying things like:"My RF predicts that being in a hospital is a predictor of a higher risk of death! Don't go to the hospital, if you get sick!" or similar other misinterpretations. Obviously, you need a different approach than the standard prediction set-up in order to try to approach a causal question (for which there are approaches that try to use RF).
When there are high cardinality categorical features. E.g. user ID when there's hundreds or thousands of users (in a sense see sparse inputs), products that are being sold etc. and so on. This is not necessarily a case where RF should not be used, but rather where other approaches (such as neural networks with embeddings) might outperform them (of course, you could use neural network embeddings as inputs).
When you need to win a data science competition on tabular data, RF is also not necessarily the first thing you'd try. Gradient boosting (xgboost, LightGBM, catboost etc.) tends to outperform RF once properly tuned. It's not necessarily by much and may not be of relevance for many applications unless every little improvement in prediction performance matters.
|
When to avoid Random Forest?
|
There's already many good points by others e.g. about sparse feature spaces, when we know a step-function will not work well/when you don't have a good representation of the data (some of these may of
|
When to avoid Random Forest?
There's already many good points by others e.g. about sparse feature spaces, when we know a step-function will not work well/when you don't have a good representation of the data (some of these may of course be a matter of creating better features first), as well as non-tabular data types where other approaches are known to work better especially for how to represent the input data (as mentioned by others: images, text, audio).
However, here are some additional situations that are non-ideal for RF (in approximately descending order of my strength of concern about using RF). Several of these are not specifically an issue with RF, but rather apply more broadly to many prediction modelling approaches.
When we know mechanistically what underlies the system we model. E.g. you can often define a set of biologically sensible differential equations that govern the blood levels of a drug in the human body. You are much better off to set-up a non-linear model based on these, while any modelling approach that ignores this understanding of the biology is going to be a lot less efficient - especially for small datasets -, and likely terrible at extrapolation (see below). I would not ever seriously consider basic RF (or other "default" prediction models like gradient boosted decision trees) here.
When you need to extrapolate beyond your training data. The fitted step-functions will remain constant outside the training feature value range, which will often be an implausible thing to assume. Extrapolation is generally a big challenge, but e.g. mechanistic models from the previous bullet point would be a much, much better bet for extrapolation than RF.
RF is also not so great for multivariate outputs. Even something as simple as many correlated multi-label binary classification tasks can be more efficient with neural networks. It becomes even clearer, when the desired outputs is e.g. an image, a series of values such as a sentence of words, or a variable number of bounding boxes with class assignments.
When you want to causally interpret the effect of a feature. This may be a really silly and obvious thing to point out, but I've seen too many people saying things like:"My RF predicts that being in a hospital is a predictor of a higher risk of death! Don't go to the hospital, if you get sick!" or similar other misinterpretations. Obviously, you need a different approach than the standard prediction set-up in order to try to approach a causal question (for which there are approaches that try to use RF).
When there are high cardinality categorical features. E.g. user ID when there's hundreds or thousands of users (in a sense see sparse inputs), products that are being sold etc. and so on. This is not necessarily a case where RF should not be used, but rather where other approaches (such as neural networks with embeddings) might outperform them (of course, you could use neural network embeddings as inputs).
When you need to win a data science competition on tabular data, RF is also not necessarily the first thing you'd try. Gradient boosting (xgboost, LightGBM, catboost etc.) tends to outperform RF once properly tuned. It's not necessarily by much and may not be of relevance for many applications unless every little improvement in prediction performance matters.
|
When to avoid Random Forest?
There's already many good points by others e.g. about sparse feature spaces, when we know a step-function will not work well/when you don't have a good representation of the data (some of these may of
|
8,780
|
When to avoid Random Forest?
|
RF is a static model and when it comes to dealing with dynamical systems and online learning, the cost of adapting to the data drift is the same as reconstructing the entire structure again.
|
When to avoid Random Forest?
|
RF is a static model and when it comes to dealing with dynamical systems and online learning, the cost of adapting to the data drift is the same as reconstructing the entire structure again.
|
When to avoid Random Forest?
RF is a static model and when it comes to dealing with dynamical systems and online learning, the cost of adapting to the data drift is the same as reconstructing the entire structure again.
|
When to avoid Random Forest?
RF is a static model and when it comes to dealing with dynamical systems and online learning, the cost of adapting to the data drift is the same as reconstructing the entire structure again.
|
8,781
|
When to avoid Random Forest?
|
First of all, the Random Forest cannot be applied to the following data types:
images
audio
text (after preprocessing data will be sparse and RF doesn't work well with sparse data)
For tabular data type, it is always good to check Random Forest because:
it requires less data preparation and preprocessing than Neural Networks or SVMs. For example, you don't need to do feature scaling.
For Random Forest training you can just use default parameters and set the number of trees (the more trees in RF the better). When you compare Random Forest to Neural Networks, the training is very easy (don't need to define architecture, or tune training algorithm). Random Forest is easier to train than Neural Networks.
|
When to avoid Random Forest?
|
First of all, the Random Forest cannot be applied to the following data types:
images
audio
text (after preprocessing data will be sparse and RF doesn't work well with sparse data)
For tabular data
|
When to avoid Random Forest?
First of all, the Random Forest cannot be applied to the following data types:
images
audio
text (after preprocessing data will be sparse and RF doesn't work well with sparse data)
For tabular data type, it is always good to check Random Forest because:
it requires less data preparation and preprocessing than Neural Networks or SVMs. For example, you don't need to do feature scaling.
For Random Forest training you can just use default parameters and set the number of trees (the more trees in RF the better). When you compare Random Forest to Neural Networks, the training is very easy (don't need to define architecture, or tune training algorithm). Random Forest is easier to train than Neural Networks.
|
When to avoid Random Forest?
First of all, the Random Forest cannot be applied to the following data types:
images
audio
text (after preprocessing data will be sparse and RF doesn't work well with sparse data)
For tabular data
|
8,782
|
When to avoid Random Forest?
|
Random Forests are prone to exhausing memory and causing out-of-memory errors (as compared to an incremental / batch learning method that fixes memory usage.
|
When to avoid Random Forest?
|
Random Forests are prone to exhausing memory and causing out-of-memory errors (as compared to an incremental / batch learning method that fixes memory usage.
|
When to avoid Random Forest?
Random Forests are prone to exhausing memory and causing out-of-memory errors (as compared to an incremental / batch learning method that fixes memory usage.
|
When to avoid Random Forest?
Random Forests are prone to exhausing memory and causing out-of-memory errors (as compared to an incremental / batch learning method that fixes memory usage.
|
8,783
|
How to know if a time series is stationary or non-stationary?
|
Testing if a series is stationary versus non-stationary requires that you consider a sequence of alternative hypotheses . One for each listable Gaussian Assumption. One has to understand that the Gaussian Assumptions are all about the error process and have nothing to do with the observed series under evaluation. As correctly summarized by StasK this could include violations of stationarity, like mean change, variance change, changes in the parameters of the model over time. For example an upward trending set of values would be a prima facie example of a series that in Y was not constant while the residuals from a suitable model might be described as having a constant mean. Thus the original series is non-stationary in the mean but the residual series is stationary in its mean. If there are unmitigated mean violations in the residual series like Pulses, Level Shifts, Seasonal Pulses and/or Local Time Trends then the residual series (untreated) can be characterized as being non-stationary in the mean while a series of indicator variables could be easily detected and incorporated into the model to render the model residuals stationary in the mean. Now if the variance of the original series exhibits non-stationary variance it is quite reasonable to constrict a filter/model to render an error process that has constant variance. Similarly the residuals from a model might have non-constant variance requiring one of three possible remedies -
Weighted Least Squares (broadly overlooked by some analysts)
A power transformation to decouple the expected value from the variance of the errors identifiable via a Box-Cox test and/or
A need for a GARCH model to account for an ARIMA structure evident in the squared residuals. Continuing if parameters change over time OR the form of the model changes over time then one is faced with the need for detecting this characteristic and remedying it with either data segmentation or the utilization of a TAR approach à la Tong.
|
How to know if a time series is stationary or non-stationary?
|
Testing if a series is stationary versus non-stationary requires that you consider a sequence of alternative hypotheses . One for each listable Gaussian Assumption. One has to understand that the Gaus
|
How to know if a time series is stationary or non-stationary?
Testing if a series is stationary versus non-stationary requires that you consider a sequence of alternative hypotheses . One for each listable Gaussian Assumption. One has to understand that the Gaussian Assumptions are all about the error process and have nothing to do with the observed series under evaluation. As correctly summarized by StasK this could include violations of stationarity, like mean change, variance change, changes in the parameters of the model over time. For example an upward trending set of values would be a prima facie example of a series that in Y was not constant while the residuals from a suitable model might be described as having a constant mean. Thus the original series is non-stationary in the mean but the residual series is stationary in its mean. If there are unmitigated mean violations in the residual series like Pulses, Level Shifts, Seasonal Pulses and/or Local Time Trends then the residual series (untreated) can be characterized as being non-stationary in the mean while a series of indicator variables could be easily detected and incorporated into the model to render the model residuals stationary in the mean. Now if the variance of the original series exhibits non-stationary variance it is quite reasonable to constrict a filter/model to render an error process that has constant variance. Similarly the residuals from a model might have non-constant variance requiring one of three possible remedies -
Weighted Least Squares (broadly overlooked by some analysts)
A power transformation to decouple the expected value from the variance of the errors identifiable via a Box-Cox test and/or
A need for a GARCH model to account for an ARIMA structure evident in the squared residuals. Continuing if parameters change over time OR the form of the model changes over time then one is faced with the need for detecting this characteristic and remedying it with either data segmentation or the utilization of a TAR approach à la Tong.
|
How to know if a time series is stationary or non-stationary?
Testing if a series is stationary versus non-stationary requires that you consider a sequence of alternative hypotheses . One for each listable Gaussian Assumption. One has to understand that the Gaus
|
8,784
|
How to know if a time series is stationary or non-stationary?
|
Stationarity means that the marginal distribution of the process does not change with time. A weaker forms states that the mean and the variance stay the same over time. So anything that violates it will be deemed non-stationary, for whatever silly reasons. For instance, a deterministic $y_t = \sin t$ is non-stationary, as its mean keeps changing, although at the face of it, this is a pretty simple and predictable process.
All the tests you are considering have a specific alternative in mind: a random walk process
$$
y_t = y_{t-1} + \epsilon_t
$$
or some easy modification of it (e.g., include additional lags $y_{t-2}$, $y_{t-3}$ with small coefficients). This is a simple model of an efficient financial market, where no information whatsoever can be used to predict the future changes in prices. Most economists think about their time series as coming from ARIMA models; these time series have well defined periods when stuff happens (month, quarter, or year), so it rarely gets worse than an integrated time series for them. So these tests are not designed for more complex violations of stationarity, like mean change, variance change, change in the autoregressive coefficients, etc., although tests for these effects have obviously been developed, too.
In engineering or natural sciences, you are more likely to encounter time series with more complicated issues, like long range dependence, fractional integration, pink noise, etc. With the lack of clear guidance from the description of the process regarding the typical time scales (how often does the climate change?), it usually makes more sense to analyze the data in the frequency domain (while for economists, the frequency domain is quite clear: there are annual seasonal cycles, plus longer 3-4-5 year business cycles; few surprises can occur otherwise).
So basically I told you why you don't want to do what you set out to do. If you don't understand time series, you would be better off finding somebody who does and paying consultancy fee, rather than having your project screwed up because you've done something silly. Having said that, the formal solution to your problem would be to reject the null hypothesis of a stationary series when, for a given series, at least one test has a $p$-value below $0.05/(3M)$ where $M$ is the total number of series, $3$ is the number of tests you perform on them, $0.05$ is the favorite 5% significance level, and the whole expression is known as Bonferroni correction for multiple testing. The output does not show the $p$-values with sufficient accuracy, so you would need to pull them as the returned class members, such as pp.test(x)$p.value. You'll be doing this in cycle, anyway, so it would probably suffice if you suppress all of the output, and only produce the name(s) of the variable(s) that fail stationarity.
|
How to know if a time series is stationary or non-stationary?
|
Stationarity means that the marginal distribution of the process does not change with time. A weaker forms states that the mean and the variance stay the same over time. So anything that violates it w
|
How to know if a time series is stationary or non-stationary?
Stationarity means that the marginal distribution of the process does not change with time. A weaker forms states that the mean and the variance stay the same over time. So anything that violates it will be deemed non-stationary, for whatever silly reasons. For instance, a deterministic $y_t = \sin t$ is non-stationary, as its mean keeps changing, although at the face of it, this is a pretty simple and predictable process.
All the tests you are considering have a specific alternative in mind: a random walk process
$$
y_t = y_{t-1} + \epsilon_t
$$
or some easy modification of it (e.g., include additional lags $y_{t-2}$, $y_{t-3}$ with small coefficients). This is a simple model of an efficient financial market, where no information whatsoever can be used to predict the future changes in prices. Most economists think about their time series as coming from ARIMA models; these time series have well defined periods when stuff happens (month, quarter, or year), so it rarely gets worse than an integrated time series for them. So these tests are not designed for more complex violations of stationarity, like mean change, variance change, change in the autoregressive coefficients, etc., although tests for these effects have obviously been developed, too.
In engineering or natural sciences, you are more likely to encounter time series with more complicated issues, like long range dependence, fractional integration, pink noise, etc. With the lack of clear guidance from the description of the process regarding the typical time scales (how often does the climate change?), it usually makes more sense to analyze the data in the frequency domain (while for economists, the frequency domain is quite clear: there are annual seasonal cycles, plus longer 3-4-5 year business cycles; few surprises can occur otherwise).
So basically I told you why you don't want to do what you set out to do. If you don't understand time series, you would be better off finding somebody who does and paying consultancy fee, rather than having your project screwed up because you've done something silly. Having said that, the formal solution to your problem would be to reject the null hypothesis of a stationary series when, for a given series, at least one test has a $p$-value below $0.05/(3M)$ where $M$ is the total number of series, $3$ is the number of tests you perform on them, $0.05$ is the favorite 5% significance level, and the whole expression is known as Bonferroni correction for multiple testing. The output does not show the $p$-values with sufficient accuracy, so you would need to pull them as the returned class members, such as pp.test(x)$p.value. You'll be doing this in cycle, anyway, so it would probably suffice if you suppress all of the output, and only produce the name(s) of the variable(s) that fail stationarity.
|
How to know if a time series is stationary or non-stationary?
Stationarity means that the marginal distribution of the process does not change with time. A weaker forms states that the mean and the variance stay the same over time. So anything that violates it w
|
8,785
|
How to know if a time series is stationary or non-stationary?
|
Time series is stationary if its mean level and variance stay steady over time. You can read more on this topic (with specification of relevant tests in R), in our post..
http://www.statosphere.com.au/check-time-series-stationary-r/
|
How to know if a time series is stationary or non-stationary?
|
Time series is stationary if its mean level and variance stay steady over time. You can read more on this topic (with specification of relevant tests in R), in our post..
http://www.statosphere.com.au
|
How to know if a time series is stationary or non-stationary?
Time series is stationary if its mean level and variance stay steady over time. You can read more on this topic (with specification of relevant tests in R), in our post..
http://www.statosphere.com.au/check-time-series-stationary-r/
|
How to know if a time series is stationary or non-stationary?
Time series is stationary if its mean level and variance stay steady over time. You can read more on this topic (with specification of relevant tests in R), in our post..
http://www.statosphere.com.au
|
8,786
|
Cost function in OLS linear regression
|
As you seem to realize, we certainly don't need the $1/m$ factor to get linear regression. The minimizers will of course be exactly the same, with or without it. One typical reason to normalize by $m$ is so that we can view the cost function as an approximation to the "generalization error", which is the expected square loss on a randomly chosen new example (not in the training set):
Suppose $(X,Y),(X^{(1)},Y^{(1)}),\ldots,(X^{(m)},Y^{(m)})$ are sampled i.i.d. from some distribution. Then for large $m$ we expect that
$$
\frac{1}{m} \sum _{i=1}^m \left(h_\theta(X^{(i)})-Y^{(i)}\right)^2 \approx \mathbb{E}\left(h_\theta(X)-Y\right)^2.
$$
More precisely, by the Strong Law of Large Numbers, we have
$$
\lim_{m\to\infty} \frac{1}{m} \sum _{i=1}^m \left(h_\theta(X^{(i)})-Y^{(i)}\right)^2 = \mathbb{E}\left(h_\theta(X)-Y\right)^2
$$
with probability 1.
Note: Each of the statements above are for any particular $\theta$, chosen without looking at the training set. For machine learning, we want these statements to hold for some $\hat{\theta}$ chosen based on its good performance on the training set. These claims can still hold in this case, though we need to make some assumptions on the set of functions $\{h_\theta \,|\, \theta \in \Theta\}$, and we'll need something stronger than the Law of Large Numbers.
|
Cost function in OLS linear regression
|
As you seem to realize, we certainly don't need the $1/m$ factor to get linear regression. The minimizers will of course be exactly the same, with or without it. One typical reason to normalize by $
|
Cost function in OLS linear regression
As you seem to realize, we certainly don't need the $1/m$ factor to get linear regression. The minimizers will of course be exactly the same, with or without it. One typical reason to normalize by $m$ is so that we can view the cost function as an approximation to the "generalization error", which is the expected square loss on a randomly chosen new example (not in the training set):
Suppose $(X,Y),(X^{(1)},Y^{(1)}),\ldots,(X^{(m)},Y^{(m)})$ are sampled i.i.d. from some distribution. Then for large $m$ we expect that
$$
\frac{1}{m} \sum _{i=1}^m \left(h_\theta(X^{(i)})-Y^{(i)}\right)^2 \approx \mathbb{E}\left(h_\theta(X)-Y\right)^2.
$$
More precisely, by the Strong Law of Large Numbers, we have
$$
\lim_{m\to\infty} \frac{1}{m} \sum _{i=1}^m \left(h_\theta(X^{(i)})-Y^{(i)}\right)^2 = \mathbb{E}\left(h_\theta(X)-Y\right)^2
$$
with probability 1.
Note: Each of the statements above are for any particular $\theta$, chosen without looking at the training set. For machine learning, we want these statements to hold for some $\hat{\theta}$ chosen based on its good performance on the training set. These claims can still hold in this case, though we need to make some assumptions on the set of functions $\{h_\theta \,|\, \theta \in \Theta\}$, and we'll need something stronger than the Law of Large Numbers.
|
Cost function in OLS linear regression
As you seem to realize, we certainly don't need the $1/m$ factor to get linear regression. The minimizers will of course be exactly the same, with or without it. One typical reason to normalize by $
|
8,787
|
Cost function in OLS linear regression
|
You don't have to. The loss function has the same minimum whether you include the $\frac{1}{m}$ or suppress it. If you include it though, you get the nice interpretation of minimizing (one half) the average error per datapoint. Put another way, you are minimizing the error rate instead of the total error.
Consider comparing the performance on two data sets of differing sizes. The raw sum of squared errors are not directly comparable, as larger datasets tend to have more total error just due to their size. On the other hand, the average error per datapoint is.
Can you elaborate a bit?
Sure. Your data set is a collection of data points $\{ x_i, y_i \}$. Once you have a model $h$, the least squares error of $h$ on a single data point is
$$ (h(x_i) - y_i)^2 $$
this is, of course, different for each datapoint. Now, if we simply sum up the errors (and multiply by one half for the reason you describe) we get the total error
$$ \frac{1}{2} \sum_i (h(x_i) - y_i)^2 $$
but if we divide by the number of summands we get the average error per data point
$$ \frac{1}{2m} \sum_i (h(x_i) - y_i)^2 $$
The benefit of the average error is that if we have two datasets $\{ x_i, y_i \}$ and $\{ x'_i, y'_i \}$ of differeing sizes, then we can compare the average errors but not the total errors. For if the second data set is, say, ten times the size of the first, then we would expect the total error to be about ten times larger for the same model. On the other hand, the average error divides out the effect of the size of the data set, and so we would expect models of similar performance to have the similar average errors on different data sets.
|
Cost function in OLS linear regression
|
You don't have to. The loss function has the same minimum whether you include the $\frac{1}{m}$ or suppress it. If you include it though, you get the nice interpretation of minimizing (one half) the
|
Cost function in OLS linear regression
You don't have to. The loss function has the same minimum whether you include the $\frac{1}{m}$ or suppress it. If you include it though, you get the nice interpretation of minimizing (one half) the average error per datapoint. Put another way, you are minimizing the error rate instead of the total error.
Consider comparing the performance on two data sets of differing sizes. The raw sum of squared errors are not directly comparable, as larger datasets tend to have more total error just due to their size. On the other hand, the average error per datapoint is.
Can you elaborate a bit?
Sure. Your data set is a collection of data points $\{ x_i, y_i \}$. Once you have a model $h$, the least squares error of $h$ on a single data point is
$$ (h(x_i) - y_i)^2 $$
this is, of course, different for each datapoint. Now, if we simply sum up the errors (and multiply by one half for the reason you describe) we get the total error
$$ \frac{1}{2} \sum_i (h(x_i) - y_i)^2 $$
but if we divide by the number of summands we get the average error per data point
$$ \frac{1}{2m} \sum_i (h(x_i) - y_i)^2 $$
The benefit of the average error is that if we have two datasets $\{ x_i, y_i \}$ and $\{ x'_i, y'_i \}$ of differeing sizes, then we can compare the average errors but not the total errors. For if the second data set is, say, ten times the size of the first, then we would expect the total error to be about ten times larger for the same model. On the other hand, the average error divides out the effect of the size of the data set, and so we would expect models of similar performance to have the similar average errors on different data sets.
|
Cost function in OLS linear regression
You don't have to. The loss function has the same minimum whether you include the $\frac{1}{m}$ or suppress it. If you include it though, you get the nice interpretation of minimizing (one half) the
|
8,788
|
Cross-validation or bootstrapping to evaluate classification performance?
|
One important difference in the usual way cross validation and out-of-bootstrap methods are applied is that most people apply cross validation only once (i.e. each case is tested exactly once), while out-of-bootstrap validation is performed with a large number of repetitions/iterations.
In that situation, cross validation is subject to higher variance due to model instability. However, that can be avoided by using e.g. iterated/repeated $k$-fold cross validation. If that is done, at least for the spectroscopic data sets I've been working with, the total error of both resampling schemes seems to be the same in practice.
Leave-one-out cross validation is discouraged, as there is no possibility to reduce the model instability-type variance and there are some classifiers and problems where it exhibits a huge pessimistic bias.
.632 bootstrap does a reasonable job as long as the resampling error which is mixed in is not too optimistically biased. (E.g. for the data I work with, very wide matrices with lots of variates, it doesn't work very well as the models are prone to serious overfitting). This means also that I'd avoid using .632 bootstrap for comparing models of varying complexity. With .632+ bootstrap I don't have experience: if overfitting happens and is properly detected, it will equal the original out-of-bootstrap estimate, so I stick with plain oob or iterated/repeated cross validation for my data.
Literature:
Kohavi, R.: A Study of Cross-Validation and Bootstrap for Accuracy Estimation and Model Selection Artificial Intelligence Proceedings 14th International Joint Conference, 20 -- 25. August 1995, Montréal, Québec, Canada, 1995, 1137 - 1145.
(a classic)
Dougherty and Braga-Neto have a number of publications on the topic, e.g.
Dougherty, E. R. et al.: Performance of Error Estimators for Classification Current Bioinformatics, 2010, 5, 53-67
Beleites, C. et al.: Variance reduction in estimating classification error using sparse datasets Chemom Intell Lab Syst, 2005, 79, 91 - 100.
We have a comparison of doing cross validation only once or iterating/repeating, and compare that with out-of-bootstrap and .632 bootstrap as well for particularly wide data with multi-collinearities.
Kim, J.-H.: Estimating classification error rate: Repeated cross-validation, repeated hold-out and bootstrap, Computational Statistics & Data Analysis , 2009, 53, 3735 - 374
Also finds that repeated/iterated $k$-fold cross validation and out-of-bootstrap have similar performance (as opposed to doing the cross validation only once).
Choice of metric:
accuray (of which @FrankHarrell will tell you that it is a bad choice as it is not a proper scoring rule) is subject to high variance because it counts each case either as completely correct or completely incorrect, even if the classifier predicted e.g. only 60 % posterior probability for the test case to belong to the class in question. A proper scoring rule is e.g. Brier's score, which is closely related to mean squared error in regression.
Mean square error analoga are available for proportions like accuracy, sensitivity, specificity, predictive values: Beleites, C. et al.: Validation of soft classification models using partial class memberships: An extended concept of sensitivity & Co. applied to grading of astrocytoma tissues, Chemom Intell Lab Syst, 2013, 122, 12 - 22; DOI: 10.1016/j.chemolab.2012.12.003 (summary page giving link to preprint as well)
My ultimate goal is to be able to say with some confidence that one machine learning method is superior to another for a particular dataset.
Use a paired test to evaluate that. For comparing proportions, have a look at McNemar's test.
The answer to this will be affected by the choice of metric. As regression-type error measures do not have the "hardening" step of cutting decisions with a threshold, they often have less variance than their classification counterparts. Metrics like accuracy that are basically proportions will need huge numbers of test cases to establish the superiority of one classifier over another.
Fleiss: "Statistical methods for rates and proportions" gives examples (and tables) for unpaired comparison of proportions. To give you an impression of what I mean with "huge sample sizes", have a look at the image in my answer to this other question.
Paired tests like McNemar's need less test cases, but IIRC still in the best case half (?) of the sample size needed for the unpaired test.
To characterize a classifier's performance (hardened), you usually need a working curve of least two values such as the ROC (sensitivity vs. specificity) or the like.
I seldom use overall accuracy or AUC, as my applications usually have restrictions e.g. that sensitivity is more important than specificity, or certain bounds on these measures should be met. If you go for "single number" sum characteristics, make sure that the working point of the models you're looking at is actually in a sensible range.
For accuracy and other performance measures that summarize the performance for several classes according to the reference labels, make sure that you take into account the relative frequency of the classes that you'll encounter in the application - which is not necessarily the same as in your training or test data.
Provost, F. et al.: The Case Against Accuracy Estimation for Comparing Induction Algorithms In Proceedings of the Fifteenth International Conference on Machine Learning, 1998
edit: comparing multiple classifiers
I've been thinking about this problem for a while, but did not yet arrive at a solution (nor did I meet anyone who had a solution).
Here's what I've got so far:
The problem is that you run very swiftly into into massive multiple comparison situation.
However, you may say that for the applications I have at hand, multiple comparisons is not really making things any worse, because I rarely have enought test cases to allow even a single comparison...
I think tuning of model hyperparameters is a specialized version of the general model comparison problem, which may be easier to tackle for a beginning. However, there are rumours that the quality of models depends much on the expertise of the one who builds them, possibly even more so than on the choice of model type
For the moment, I decided that "optimization is the root of all evil", and take a very different approach instead:
I decide as much as possible by expert knowledge about the problem at hand. That actually allows to narrow down things quite a bit, so that I can often avoid model comparison. When I have to compare models, I try to be very open and clear reminding people about the uncertainty of the performance estimate and that particularly multiple model comparison is AFAIK still an unsolved problem.
Edit 2: paired tests
Among $n$ models, you can make $\frac{1}{2} (n^2 - n)$ comparisons between two different models (which is a massive multiple comparison situation), I don't know how to properly do this. However, the paired of the test just refers to the fact that as all models are tested with exactly the same test cases, you can split the cases into "easy" and "difficult" cases on the one hand, for which all models arrive at a correct (or wrong) prediction. They do not help distinguishing among the models. On the other hand, there are the "interesting" cases which are predicted correctly by some, but not by other models. Only these "interesting" cases need to be considered for judging superiority, neither the "easy" nor the "difficult" cases help with that. (This is how I understand the idea behind McNemar's test).
For the massively multiple comparison between $n$ models, I guess one problem is that unless you're very lucky, the more models you compare the fewer cases you will be able to exclude from the further considerations: even if all models are truly equal in their overall performance, it becomes less and less likely that a case ends up being always predicted correctly (or always wrongly) by $n$ models.
|
Cross-validation or bootstrapping to evaluate classification performance?
|
One important difference in the usual way cross validation and out-of-bootstrap methods are applied is that most people apply cross validation only once (i.e. each case is tested exactly once), while
|
Cross-validation or bootstrapping to evaluate classification performance?
One important difference in the usual way cross validation and out-of-bootstrap methods are applied is that most people apply cross validation only once (i.e. each case is tested exactly once), while out-of-bootstrap validation is performed with a large number of repetitions/iterations.
In that situation, cross validation is subject to higher variance due to model instability. However, that can be avoided by using e.g. iterated/repeated $k$-fold cross validation. If that is done, at least for the spectroscopic data sets I've been working with, the total error of both resampling schemes seems to be the same in practice.
Leave-one-out cross validation is discouraged, as there is no possibility to reduce the model instability-type variance and there are some classifiers and problems where it exhibits a huge pessimistic bias.
.632 bootstrap does a reasonable job as long as the resampling error which is mixed in is not too optimistically biased. (E.g. for the data I work with, very wide matrices with lots of variates, it doesn't work very well as the models are prone to serious overfitting). This means also that I'd avoid using .632 bootstrap for comparing models of varying complexity. With .632+ bootstrap I don't have experience: if overfitting happens and is properly detected, it will equal the original out-of-bootstrap estimate, so I stick with plain oob or iterated/repeated cross validation for my data.
Literature:
Kohavi, R.: A Study of Cross-Validation and Bootstrap for Accuracy Estimation and Model Selection Artificial Intelligence Proceedings 14th International Joint Conference, 20 -- 25. August 1995, Montréal, Québec, Canada, 1995, 1137 - 1145.
(a classic)
Dougherty and Braga-Neto have a number of publications on the topic, e.g.
Dougherty, E. R. et al.: Performance of Error Estimators for Classification Current Bioinformatics, 2010, 5, 53-67
Beleites, C. et al.: Variance reduction in estimating classification error using sparse datasets Chemom Intell Lab Syst, 2005, 79, 91 - 100.
We have a comparison of doing cross validation only once or iterating/repeating, and compare that with out-of-bootstrap and .632 bootstrap as well for particularly wide data with multi-collinearities.
Kim, J.-H.: Estimating classification error rate: Repeated cross-validation, repeated hold-out and bootstrap, Computational Statistics & Data Analysis , 2009, 53, 3735 - 374
Also finds that repeated/iterated $k$-fold cross validation and out-of-bootstrap have similar performance (as opposed to doing the cross validation only once).
Choice of metric:
accuray (of which @FrankHarrell will tell you that it is a bad choice as it is not a proper scoring rule) is subject to high variance because it counts each case either as completely correct or completely incorrect, even if the classifier predicted e.g. only 60 % posterior probability for the test case to belong to the class in question. A proper scoring rule is e.g. Brier's score, which is closely related to mean squared error in regression.
Mean square error analoga are available for proportions like accuracy, sensitivity, specificity, predictive values: Beleites, C. et al.: Validation of soft classification models using partial class memberships: An extended concept of sensitivity & Co. applied to grading of astrocytoma tissues, Chemom Intell Lab Syst, 2013, 122, 12 - 22; DOI: 10.1016/j.chemolab.2012.12.003 (summary page giving link to preprint as well)
My ultimate goal is to be able to say with some confidence that one machine learning method is superior to another for a particular dataset.
Use a paired test to evaluate that. For comparing proportions, have a look at McNemar's test.
The answer to this will be affected by the choice of metric. As regression-type error measures do not have the "hardening" step of cutting decisions with a threshold, they often have less variance than their classification counterparts. Metrics like accuracy that are basically proportions will need huge numbers of test cases to establish the superiority of one classifier over another.
Fleiss: "Statistical methods for rates and proportions" gives examples (and tables) for unpaired comparison of proportions. To give you an impression of what I mean with "huge sample sizes", have a look at the image in my answer to this other question.
Paired tests like McNemar's need less test cases, but IIRC still in the best case half (?) of the sample size needed for the unpaired test.
To characterize a classifier's performance (hardened), you usually need a working curve of least two values such as the ROC (sensitivity vs. specificity) or the like.
I seldom use overall accuracy or AUC, as my applications usually have restrictions e.g. that sensitivity is more important than specificity, or certain bounds on these measures should be met. If you go for "single number" sum characteristics, make sure that the working point of the models you're looking at is actually in a sensible range.
For accuracy and other performance measures that summarize the performance for several classes according to the reference labels, make sure that you take into account the relative frequency of the classes that you'll encounter in the application - which is not necessarily the same as in your training or test data.
Provost, F. et al.: The Case Against Accuracy Estimation for Comparing Induction Algorithms In Proceedings of the Fifteenth International Conference on Machine Learning, 1998
edit: comparing multiple classifiers
I've been thinking about this problem for a while, but did not yet arrive at a solution (nor did I meet anyone who had a solution).
Here's what I've got so far:
The problem is that you run very swiftly into into massive multiple comparison situation.
However, you may say that for the applications I have at hand, multiple comparisons is not really making things any worse, because I rarely have enought test cases to allow even a single comparison...
I think tuning of model hyperparameters is a specialized version of the general model comparison problem, which may be easier to tackle for a beginning. However, there are rumours that the quality of models depends much on the expertise of the one who builds them, possibly even more so than on the choice of model type
For the moment, I decided that "optimization is the root of all evil", and take a very different approach instead:
I decide as much as possible by expert knowledge about the problem at hand. That actually allows to narrow down things quite a bit, so that I can often avoid model comparison. When I have to compare models, I try to be very open and clear reminding people about the uncertainty of the performance estimate and that particularly multiple model comparison is AFAIK still an unsolved problem.
Edit 2: paired tests
Among $n$ models, you can make $\frac{1}{2} (n^2 - n)$ comparisons between two different models (which is a massive multiple comparison situation), I don't know how to properly do this. However, the paired of the test just refers to the fact that as all models are tested with exactly the same test cases, you can split the cases into "easy" and "difficult" cases on the one hand, for which all models arrive at a correct (or wrong) prediction. They do not help distinguishing among the models. On the other hand, there are the "interesting" cases which are predicted correctly by some, but not by other models. Only these "interesting" cases need to be considered for judging superiority, neither the "easy" nor the "difficult" cases help with that. (This is how I understand the idea behind McNemar's test).
For the massively multiple comparison between $n$ models, I guess one problem is that unless you're very lucky, the more models you compare the fewer cases you will be able to exclude from the further considerations: even if all models are truly equal in their overall performance, it becomes less and less likely that a case ends up being always predicted correctly (or always wrongly) by $n$ models.
|
Cross-validation or bootstrapping to evaluate classification performance?
One important difference in the usual way cross validation and out-of-bootstrap methods are applied is that most people apply cross validation only once (i.e. each case is tested exactly once), while
|
8,789
|
Cross-validation or bootstrapping to evaluate classification performance?
|
You need modifications to the bootstrap (.632, .632+) only because the original research used a discontinuous improper scoring rule (proportion classified correctly). For other accuracy scores the ordinary optimism bootstrap tends to work fine. For more information see this.
Improper scoring rules mislead you on the choice of features and their weights. In other words, everything that can go wrong will go wrong. For more see this.
|
Cross-validation or bootstrapping to evaluate classification performance?
|
You need modifications to the bootstrap (.632, .632+) only because the original research used a discontinuous improper scoring rule (proportion classified correctly). For other accuracy scores the or
|
Cross-validation or bootstrapping to evaluate classification performance?
You need modifications to the bootstrap (.632, .632+) only because the original research used a discontinuous improper scoring rule (proportion classified correctly). For other accuracy scores the ordinary optimism bootstrap tends to work fine. For more information see this.
Improper scoring rules mislead you on the choice of features and their weights. In other words, everything that can go wrong will go wrong. For more see this.
|
Cross-validation or bootstrapping to evaluate classification performance?
You need modifications to the bootstrap (.632, .632+) only because the original research used a discontinuous improper scoring rule (proportion classified correctly). For other accuracy scores the or
|
8,790
|
Cross-validation or bootstrapping to evaluate classification performance?
|
From 'Applied Predictive Modeling., Khun. Johnson. p.78
"No resampling method is uniformly better than another; the choice should be made while considering several factors. If the sample size is small, we recommend using repeated 10-fold cross validation for several reasons; the bias and variance properties are good, and given the sample size, the computational costs are not large. If the goal is to choose between models, as opposed to getting the best indicator of performance, a strong case can be made for using one of the bootstrap procedures since these have very low variance. For large sample sizes, the differences between resampling methods become less pronounced, and computational efficiency increases in performance." p. 78
In addition, given the choice of two similar results, the more interpretable model is generally preferred. As an example (from the same text), using 10 fold CV, a SVM classifier had a 75% accuracy estimate with resample results between 66 and 82%. The same parameters were used on a logistic regression classifier with 74.9% accuracy, and same resample range. The simpler logistic regression model might be preferred as it is easier to interpret results.
|
Cross-validation or bootstrapping to evaluate classification performance?
|
From 'Applied Predictive Modeling., Khun. Johnson. p.78
"No resampling method is uniformly better than another; the choice should be made while considering several factors. If the sample size is smal
|
Cross-validation or bootstrapping to evaluate classification performance?
From 'Applied Predictive Modeling., Khun. Johnson. p.78
"No resampling method is uniformly better than another; the choice should be made while considering several factors. If the sample size is small, we recommend using repeated 10-fold cross validation for several reasons; the bias and variance properties are good, and given the sample size, the computational costs are not large. If the goal is to choose between models, as opposed to getting the best indicator of performance, a strong case can be made for using one of the bootstrap procedures since these have very low variance. For large sample sizes, the differences between resampling methods become less pronounced, and computational efficiency increases in performance." p. 78
In addition, given the choice of two similar results, the more interpretable model is generally preferred. As an example (from the same text), using 10 fold CV, a SVM classifier had a 75% accuracy estimate with resample results between 66 and 82%. The same parameters were used on a logistic regression classifier with 74.9% accuracy, and same resample range. The simpler logistic regression model might be preferred as it is easier to interpret results.
|
Cross-validation or bootstrapping to evaluate classification performance?
From 'Applied Predictive Modeling., Khun. Johnson. p.78
"No resampling method is uniformly better than another; the choice should be made while considering several factors. If the sample size is smal
|
8,791
|
What is the difference between "limiting" and "stationary" distributions?
|
From An Introduction to Stochastic Modeling by Pinsky and Karlin (2011):
A limiting distribution, when it exists, is always a stationary distribution, but the converse is not true. There may exist a stationary distribution but no limiting distribution. For example, there is no limiting distribution for the periodic Markov chain whose transition probability matrix is
$$
\mathbf{P}=\left\|\begin{matrix}0 & 1\\1 & 0\end{matrix}\right\|
$$
but $\pi=\left(\frac{1}{2},\frac{1}{2}\right)$ is a stationary distribution, since
$$
\left(\frac{1}{2},\frac{1}{2}\right)\left\|\begin{matrix}0 & 1\\1 & 0\end{matrix}\right\|=\left(\frac{1}{2},\frac{1}{2}\right)
$$ (p. 205).
In a prior section, they had already defined a "limiting probability distribution" $\pi$ by
$$\lim_{n\rightarrow\infty}P_{ij}^{(n)}=\pi_j~\mathrm{for}~j=0,1,\dots,N$$
and equivalently
$$\lim_{n\rightarrow\infty}\operatorname{Pr}\{X_n=j|X_0=i\}=\pi_j>0~\mathrm{for}~j=0,1,\dots,N$$ (p. 165).
The example above oscillates deterministically, and so fails to have a limit in the same way that the sequence $\{1,0,1,0,1,\dots\}$ fails to have a limit.
They state that a regular Markov chain (in which all the n-step transition probabilities are positive) always has a limiting distribution, and prove that it must be the unique nonnegative solution to
$$\pi_j=\sum_{k=0}^N\pi_kP_{kj},~~j=0,1,\dots,N,\\
\sum_{k=0}^N\pi_k=1$$ (p. 168)
Then on the same page as the example, they write
Any set $(\pi_i)_{i=0}^{\infty}$ satisfying (4.27) is called a stationary probability distribution of the Markov chain. The term "stationary" derives from the property that a Markov chain started according to a stationary distribution will follow this distribution at all points of time. Formally, if $\operatorname{Pr}\{X_0=i\}=\pi_i$, then $\operatorname{Pr}\{X_n=i\}=\pi_i$ for all $n=1,2,\dots$.
where (4.27) is the set of equations
$$\pi_i \geq 0, \sum_{i=0}^{\infty} \pi_i=1,~\mathrm{and}~\pi_j = \sum_{i=0}^{\infty} \pi_iP_{ij}.$$
which is precisely the same stationarity condition as above, except now with an infinite number of states.
With this definition of stationarity, the statement on page 168 can be retroactively restated as:
The limiting distribution of a regular Markov chain is a stationary distribution.
If the limiting distribution of a Markov chain is a stationary distribution, then the stationary distribution is unique.
|
What is the difference between "limiting" and "stationary" distributions?
|
From An Introduction to Stochastic Modeling by Pinsky and Karlin (2011):
A limiting distribution, when it exists, is always a stationary distribution, but the converse is not true. There may exist a
|
What is the difference between "limiting" and "stationary" distributions?
From An Introduction to Stochastic Modeling by Pinsky and Karlin (2011):
A limiting distribution, when it exists, is always a stationary distribution, but the converse is not true. There may exist a stationary distribution but no limiting distribution. For example, there is no limiting distribution for the periodic Markov chain whose transition probability matrix is
$$
\mathbf{P}=\left\|\begin{matrix}0 & 1\\1 & 0\end{matrix}\right\|
$$
but $\pi=\left(\frac{1}{2},\frac{1}{2}\right)$ is a stationary distribution, since
$$
\left(\frac{1}{2},\frac{1}{2}\right)\left\|\begin{matrix}0 & 1\\1 & 0\end{matrix}\right\|=\left(\frac{1}{2},\frac{1}{2}\right)
$$ (p. 205).
In a prior section, they had already defined a "limiting probability distribution" $\pi$ by
$$\lim_{n\rightarrow\infty}P_{ij}^{(n)}=\pi_j~\mathrm{for}~j=0,1,\dots,N$$
and equivalently
$$\lim_{n\rightarrow\infty}\operatorname{Pr}\{X_n=j|X_0=i\}=\pi_j>0~\mathrm{for}~j=0,1,\dots,N$$ (p. 165).
The example above oscillates deterministically, and so fails to have a limit in the same way that the sequence $\{1,0,1,0,1,\dots\}$ fails to have a limit.
They state that a regular Markov chain (in which all the n-step transition probabilities are positive) always has a limiting distribution, and prove that it must be the unique nonnegative solution to
$$\pi_j=\sum_{k=0}^N\pi_kP_{kj},~~j=0,1,\dots,N,\\
\sum_{k=0}^N\pi_k=1$$ (p. 168)
Then on the same page as the example, they write
Any set $(\pi_i)_{i=0}^{\infty}$ satisfying (4.27) is called a stationary probability distribution of the Markov chain. The term "stationary" derives from the property that a Markov chain started according to a stationary distribution will follow this distribution at all points of time. Formally, if $\operatorname{Pr}\{X_0=i\}=\pi_i$, then $\operatorname{Pr}\{X_n=i\}=\pi_i$ for all $n=1,2,\dots$.
where (4.27) is the set of equations
$$\pi_i \geq 0, \sum_{i=0}^{\infty} \pi_i=1,~\mathrm{and}~\pi_j = \sum_{i=0}^{\infty} \pi_iP_{ij}.$$
which is precisely the same stationarity condition as above, except now with an infinite number of states.
With this definition of stationarity, the statement on page 168 can be retroactively restated as:
The limiting distribution of a regular Markov chain is a stationary distribution.
If the limiting distribution of a Markov chain is a stationary distribution, then the stationary distribution is unique.
|
What is the difference between "limiting" and "stationary" distributions?
From An Introduction to Stochastic Modeling by Pinsky and Karlin (2011):
A limiting distribution, when it exists, is always a stationary distribution, but the converse is not true. There may exist a
|
8,792
|
What is the difference between "limiting" and "stationary" distributions?
|
A stationary distribution is such a distribution $\pi$ that if the distribution over states at step $k$ is $\pi$, then also the distribution over states at step $k+1$ is $\pi$. That is,
\begin{equation}
\pi = \pi P.
\end{equation}
A limiting distribution is such a distribution $\pi$ that no matter what the initial distribution is, the distribution over states converges to $\pi$ as the number of steps goes to infinity:
\begin{equation}
\lim_{k\rightarrow \infty} \pi^{(0)} P^k = \pi,
\end{equation}
independent of $\pi^{(0)}$.
For example, let us consider a Markov chain whose two states are the sides of a coin, $\{heads, tails\}$. Each step consists of turning the coin upside down (with probability 1). Note that when we compute the state distributions, they are not conditional on previous steps, i.e., the guy who computes the probabilities does not see the coin. So, the transition matrix is
\begin{equation}
P = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}.
\end{equation}
If we first initialize the coin by flipping it randomly ($\pi^{(0)} = \begin{pmatrix}0.5 & 0.5\end{pmatrix}$), then also all subsequent time steps follow this distribution. (If you flip a fair coin, and then turn it upside down, the probability of heads is still $0.5$). Thus, $\begin{pmatrix} 0.5 & 0.5 \end{pmatrix}$ is a stationary distribution for this Markov chain.
However, this chain does not have a limiting distribution: suppose we initialize the coin so that it is heads with probability $2/3$. Then, as all subsequent states are determined by the initial state, after an even number of steps, the state is heads with probability $2/3$ and after an odd number of steps the state is heads with probability $1/3$. This holds no matter how many steps are taken, thus the distribution over states has no limit.
Now, let us modify the process so that at each step, one does not necessarily turn the coin. Instead, one throws a die, and if the result is $6$, the coin is left as is. This Markov chain has transition matrix
\begin{equation}
P = \begin{pmatrix} 1/6 & 5/6 \\ 5/6 & 1/6 \end{pmatrix}.
\end{equation}
Without going over the math, I will point out that this process will 'forget' the initial state due to randomly omitting the turn. After a huge amount of steps, the probability of heads will be close to $0.5$, even if we know how the coin was initialized. Thus, this chain has the limiting distribution $\begin{pmatrix} 0.5 & 0.5 \end{pmatrix}$.
|
What is the difference between "limiting" and "stationary" distributions?
|
A stationary distribution is such a distribution $\pi$ that if the distribution over states at step $k$ is $\pi$, then also the distribution over states at step $k+1$ is $\pi$. That is,
\begin{equati
|
What is the difference between "limiting" and "stationary" distributions?
A stationary distribution is such a distribution $\pi$ that if the distribution over states at step $k$ is $\pi$, then also the distribution over states at step $k+1$ is $\pi$. That is,
\begin{equation}
\pi = \pi P.
\end{equation}
A limiting distribution is such a distribution $\pi$ that no matter what the initial distribution is, the distribution over states converges to $\pi$ as the number of steps goes to infinity:
\begin{equation}
\lim_{k\rightarrow \infty} \pi^{(0)} P^k = \pi,
\end{equation}
independent of $\pi^{(0)}$.
For example, let us consider a Markov chain whose two states are the sides of a coin, $\{heads, tails\}$. Each step consists of turning the coin upside down (with probability 1). Note that when we compute the state distributions, they are not conditional on previous steps, i.e., the guy who computes the probabilities does not see the coin. So, the transition matrix is
\begin{equation}
P = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}.
\end{equation}
If we first initialize the coin by flipping it randomly ($\pi^{(0)} = \begin{pmatrix}0.5 & 0.5\end{pmatrix}$), then also all subsequent time steps follow this distribution. (If you flip a fair coin, and then turn it upside down, the probability of heads is still $0.5$). Thus, $\begin{pmatrix} 0.5 & 0.5 \end{pmatrix}$ is a stationary distribution for this Markov chain.
However, this chain does not have a limiting distribution: suppose we initialize the coin so that it is heads with probability $2/3$. Then, as all subsequent states are determined by the initial state, after an even number of steps, the state is heads with probability $2/3$ and after an odd number of steps the state is heads with probability $1/3$. This holds no matter how many steps are taken, thus the distribution over states has no limit.
Now, let us modify the process so that at each step, one does not necessarily turn the coin. Instead, one throws a die, and if the result is $6$, the coin is left as is. This Markov chain has transition matrix
\begin{equation}
P = \begin{pmatrix} 1/6 & 5/6 \\ 5/6 & 1/6 \end{pmatrix}.
\end{equation}
Without going over the math, I will point out that this process will 'forget' the initial state due to randomly omitting the turn. After a huge amount of steps, the probability of heads will be close to $0.5$, even if we know how the coin was initialized. Thus, this chain has the limiting distribution $\begin{pmatrix} 0.5 & 0.5 \end{pmatrix}$.
|
What is the difference between "limiting" and "stationary" distributions?
A stationary distribution is such a distribution $\pi$ that if the distribution over states at step $k$ is $\pi$, then also the distribution over states at step $k+1$ is $\pi$. That is,
\begin{equati
|
8,793
|
What is the difference between "limiting" and "stationary" distributions?
|
Putting notation aside, the word "stationary" means "once you get there, you will stay there"; while the word "limiting" implies "you will eventually get there if you go far enough". Just thought this might be helpful.
|
What is the difference between "limiting" and "stationary" distributions?
|
Putting notation aside, the word "stationary" means "once you get there, you will stay there"; while the word "limiting" implies "you will eventually get there if you go far enough". Just thought this
|
What is the difference between "limiting" and "stationary" distributions?
Putting notation aside, the word "stationary" means "once you get there, you will stay there"; while the word "limiting" implies "you will eventually get there if you go far enough". Just thought this might be helpful.
|
What is the difference between "limiting" and "stationary" distributions?
Putting notation aside, the word "stationary" means "once you get there, you will stay there"; while the word "limiting" implies "you will eventually get there if you go far enough". Just thought this
|
8,794
|
What's the difference between a probability and a proportion?
|
I have hesitated to wade into this discussion, but because it seems to have gotten sidetracked over a trivial issue concerning how to express numbers, maybe it's worthwhile refocusing it. A point of departure for your consideration is this:
A probability is a hypothetical property. Proportions summarize observations.
A frequentist might rely on laws of large numbers to justify statements like "the long-run proportion of an event [is] its probability." This supplies meaning to statements like "a probability is an expected proportion," which otherwise might appear merely tautological. Other interpretations of probability also lead to connections between probabilities and proportions but they are less direct than this one.
In our models we usually take probabilities to be definite but unknown. Due to the sharp contrasts among the meanings of "probable," "definite," and "unknown" I am reluctant to apply the term "uncertain" to describe that situation. However, before we conduct a sequence of observations, the [eventual] proportion, like any future event, is indeed "uncertain". After we make those observations, the proportion is both definite and known. (Perhaps this is what is meant by "guaranteed" in the OP.) Much of our knowledge about the [hypothetical] probability is mediated through these uncertain observations and informed by the idea that they might have turned out otherwise. In this sense--that uncertainty about the observations is transmitted back to uncertain knowledge of the underlying probability--it seems justifiable to refer to the probability as "uncertain."
In any event it is apparent that probabilities and proportions function differently in statistics, despite their similarities and intimate relationships. It would be a mistake to take them to be the same thing.
Reference
Huber, WA Ignorance is Not Probability. Risk Analysis Volume 30, Issue 3, pages 371–376, March 2010.
|
What's the difference between a probability and a proportion?
|
I have hesitated to wade into this discussion, but because it seems to have gotten sidetracked over a trivial issue concerning how to express numbers, maybe it's worthwhile refocusing it. A point of
|
What's the difference between a probability and a proportion?
I have hesitated to wade into this discussion, but because it seems to have gotten sidetracked over a trivial issue concerning how to express numbers, maybe it's worthwhile refocusing it. A point of departure for your consideration is this:
A probability is a hypothetical property. Proportions summarize observations.
A frequentist might rely on laws of large numbers to justify statements like "the long-run proportion of an event [is] its probability." This supplies meaning to statements like "a probability is an expected proportion," which otherwise might appear merely tautological. Other interpretations of probability also lead to connections between probabilities and proportions but they are less direct than this one.
In our models we usually take probabilities to be definite but unknown. Due to the sharp contrasts among the meanings of "probable," "definite," and "unknown" I am reluctant to apply the term "uncertain" to describe that situation. However, before we conduct a sequence of observations, the [eventual] proportion, like any future event, is indeed "uncertain". After we make those observations, the proportion is both definite and known. (Perhaps this is what is meant by "guaranteed" in the OP.) Much of our knowledge about the [hypothetical] probability is mediated through these uncertain observations and informed by the idea that they might have turned out otherwise. In this sense--that uncertainty about the observations is transmitted back to uncertain knowledge of the underlying probability--it seems justifiable to refer to the probability as "uncertain."
In any event it is apparent that probabilities and proportions function differently in statistics, despite their similarities and intimate relationships. It would be a mistake to take them to be the same thing.
Reference
Huber, WA Ignorance is Not Probability. Risk Analysis Volume 30, Issue 3, pages 371–376, March 2010.
|
What's the difference between a probability and a proportion?
I have hesitated to wade into this discussion, but because it seems to have gotten sidetracked over a trivial issue concerning how to express numbers, maybe it's worthwhile refocusing it. A point of
|
8,795
|
What's the difference between a probability and a proportion?
|
If you flip a fair coin 10 times and it comes up heads 3 times, the proportion of heads is .30 but the probability of a head on any one flip is .50.
|
What's the difference between a probability and a proportion?
|
If you flip a fair coin 10 times and it comes up heads 3 times, the proportion of heads is .30 but the probability of a head on any one flip is .50.
|
What's the difference between a probability and a proportion?
If you flip a fair coin 10 times and it comes up heads 3 times, the proportion of heads is .30 but the probability of a head on any one flip is .50.
|
What's the difference between a probability and a proportion?
If you flip a fair coin 10 times and it comes up heads 3 times, the proportion of heads is .30 but the probability of a head on any one flip is .50.
|
8,796
|
What's the difference between a probability and a proportion?
|
A proportion implies it is a guaranteed event, whereas a probability is not.
If you eat hamburgers 14% of the time, in a given (4-week) month (or over whatever interval you based your proportion on), you must have eaten 4 hamburgers; whereas with probability there is a possibility of having eaten no hamburgers at all or perhaps eaten a hamburger everyday.
Probability is a measure of uncertainty, whereas proportion is a measure of certainty.
|
What's the difference between a probability and a proportion?
|
A proportion implies it is a guaranteed event, whereas a probability is not.
If you eat hamburgers 14% of the time, in a given (4-week) month (or over whatever interval you based your proportion on),
|
What's the difference between a probability and a proportion?
A proportion implies it is a guaranteed event, whereas a probability is not.
If you eat hamburgers 14% of the time, in a given (4-week) month (or over whatever interval you based your proportion on), you must have eaten 4 hamburgers; whereas with probability there is a possibility of having eaten no hamburgers at all or perhaps eaten a hamburger everyday.
Probability is a measure of uncertainty, whereas proportion is a measure of certainty.
|
What's the difference between a probability and a proportion?
A proportion implies it is a guaranteed event, whereas a probability is not.
If you eat hamburgers 14% of the time, in a given (4-week) month (or over whatever interval you based your proportion on),
|
8,797
|
What's the difference between a probability and a proportion?
|
The difference is not in the calculation, but in the purpose to which the metric is put: Probability is a concept of time; proportionality is a concept of space.
If we want to know the probability of a future event, we can use the probability at which the event took place in the past to derive our best estimate for the probability of the event in the future. If we want to know how much space is left in the theater then we use proportionality: the number of unoccupied seats/the number of seats.
This ratio is not the probability of securing a seat; the probability of securing a seat (a future event) is a function of the occupied and unoccupied seats, as well as the reserved seats, the no-show probability, and a myriad of other conditions.
|
What's the difference between a probability and a proportion?
|
The difference is not in the calculation, but in the purpose to which the metric is put: Probability is a concept of time; proportionality is a concept of space.
If we want to know the probability o
|
What's the difference between a probability and a proportion?
The difference is not in the calculation, but in the purpose to which the metric is put: Probability is a concept of time; proportionality is a concept of space.
If we want to know the probability of a future event, we can use the probability at which the event took place in the past to derive our best estimate for the probability of the event in the future. If we want to know how much space is left in the theater then we use proportionality: the number of unoccupied seats/the number of seats.
This ratio is not the probability of securing a seat; the probability of securing a seat (a future event) is a function of the occupied and unoccupied seats, as well as the reserved seats, the no-show probability, and a myriad of other conditions.
|
What's the difference between a probability and a proportion?
The difference is not in the calculation, but in the purpose to which the metric is put: Probability is a concept of time; proportionality is a concept of space.
If we want to know the probability o
|
8,798
|
What's the difference between a probability and a proportion?
|
Proportion and probability, both are calculated from the total but the value of proportion is certain while that of probability is no0t certain..
|
What's the difference between a probability and a proportion?
|
Proportion and probability, both are calculated from the total but the value of proportion is certain while that of probability is no0t certain..
|
What's the difference between a probability and a proportion?
Proportion and probability, both are calculated from the total but the value of proportion is certain while that of probability is no0t certain..
|
What's the difference between a probability and a proportion?
Proportion and probability, both are calculated from the total but the value of proportion is certain while that of probability is no0t certain..
|
8,799
|
What's the difference between a probability and a proportion?
|
From my point of view the main difference between proportion and probability is the three axioms of probability which proportions don't have. i.e.
(i) Probability always lies between 0 and 1.
(ii) Probability sure event is one.
(iii) P(A or B) = P(A) +P(B), A and B are mutually exclusive events
|
What's the difference between a probability and a proportion?
|
From my point of view the main difference between proportion and probability is the three axioms of probability which proportions don't have. i.e.
(i) Probability always lies between 0 and 1.
(ii) Pro
|
What's the difference between a probability and a proportion?
From my point of view the main difference between proportion and probability is the three axioms of probability which proportions don't have. i.e.
(i) Probability always lies between 0 and 1.
(ii) Probability sure event is one.
(iii) P(A or B) = P(A) +P(B), A and B are mutually exclusive events
|
What's the difference between a probability and a proportion?
From my point of view the main difference between proportion and probability is the three axioms of probability which proportions don't have. i.e.
(i) Probability always lies between 0 and 1.
(ii) Pro
|
8,800
|
What's the difference between a probability and a proportion?
|
In the Frequentist Interpretation of Probability, the probability is long-run relative frequency. That means, the proportion in a large number of observations.
If you toss a coin 10 times and you get 4 tails, the proportion of tails is 0.4. However, 10 is not a very large number. This is only a proportion, not a probability.
Well, what is "a large number"? Bernoulli's estimation is 25,000 minimum. If you toss a coin around 50,000 times (for example) you are bound to get something close to 0.5 tails/heads. This means that the probability of getting heads/tails is 0.5.
(and if you increase the number of trials, say, to 1 million, the proportion would become closer to 0.5)
The only problem here is: what is probability? Long-run relative frequency is how we MEASURE probability, but what is it? What does it really mean when I say "The probability of getting heads is 0.5"? This is one of the great problems with the Frequentist Interpretation. But this is my opinion only. I am sure many people differ.
|
What's the difference between a probability and a proportion?
|
In the Frequentist Interpretation of Probability, the probability is long-run relative frequency. That means, the proportion in a large number of observations.
If you toss a coin 10 times and you get
|
What's the difference between a probability and a proportion?
In the Frequentist Interpretation of Probability, the probability is long-run relative frequency. That means, the proportion in a large number of observations.
If you toss a coin 10 times and you get 4 tails, the proportion of tails is 0.4. However, 10 is not a very large number. This is only a proportion, not a probability.
Well, what is "a large number"? Bernoulli's estimation is 25,000 minimum. If you toss a coin around 50,000 times (for example) you are bound to get something close to 0.5 tails/heads. This means that the probability of getting heads/tails is 0.5.
(and if you increase the number of trials, say, to 1 million, the proportion would become closer to 0.5)
The only problem here is: what is probability? Long-run relative frequency is how we MEASURE probability, but what is it? What does it really mean when I say "The probability of getting heads is 0.5"? This is one of the great problems with the Frequentist Interpretation. But this is my opinion only. I am sure many people differ.
|
What's the difference between a probability and a proportion?
In the Frequentist Interpretation of Probability, the probability is long-run relative frequency. That means, the proportion in a large number of observations.
If you toss a coin 10 times and you get
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.