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
|
|---|---|---|---|---|---|---|
5,701
|
Test for bimodal distribution
|
As mentioned in comments, the Wikipedia page on 'Bimodal distribution' lists eight tests for multimodality against unimodality and supplies references for seven of them.
There are at least some in R. For example:
The package diptest implements Hartigan's dip test.
The stamp data in the bootstrap package was used in Efron and Tibshirani's Introduction to the Bootstrap (the book on which the package is based) to do an example relating to bootstrapping on the number of modes; if you have access to the book you might be able to use that approach.
Efron, B. and Tibshirani, R. (1993) An Introduction to the Bootstrap.
Chapman and Hall, New York, London.
--
There's a question on CV that talks about identifying (i.e., estimating rather than testing) the number of modes which @whuber's search turns up. It's worth reading the answers there. One of the responses there (mine, as it happens) has a link to a Google search which turns up this paper[1] by David Donoho on constructing one-sided CIs for the number of modes, which can of course be used as a test (e.g., if the one-sided interval doesn't include the unimodal case, you can reject unimodality). To the best of my knowledge that isn't one of the tests that Wikipedia mentions. I don't think there's an R implementation of that interval, but (in spite of the fact that Donoho tends to use fairly sophisticated tools in his discussion of it) it's actually a pretty simple idea to implement. That idea is directly related to the notion of using kernel density estimation.
[1]: David L. Donoho, (1988)
"One-Sided Inference about Functionals of a Density,"
Ann. Statist. 16(4): 1390-1420 (December)
|
Test for bimodal distribution
|
As mentioned in comments, the Wikipedia page on 'Bimodal distribution' lists eight tests for multimodality against unimodality and supplies references for seven of them.
There are at least some in R.
|
Test for bimodal distribution
As mentioned in comments, the Wikipedia page on 'Bimodal distribution' lists eight tests for multimodality against unimodality and supplies references for seven of them.
There are at least some in R. For example:
The package diptest implements Hartigan's dip test.
The stamp data in the bootstrap package was used in Efron and Tibshirani's Introduction to the Bootstrap (the book on which the package is based) to do an example relating to bootstrapping on the number of modes; if you have access to the book you might be able to use that approach.
Efron, B. and Tibshirani, R. (1993) An Introduction to the Bootstrap.
Chapman and Hall, New York, London.
--
There's a question on CV that talks about identifying (i.e., estimating rather than testing) the number of modes which @whuber's search turns up. It's worth reading the answers there. One of the responses there (mine, as it happens) has a link to a Google search which turns up this paper[1] by David Donoho on constructing one-sided CIs for the number of modes, which can of course be used as a test (e.g., if the one-sided interval doesn't include the unimodal case, you can reject unimodality). To the best of my knowledge that isn't one of the tests that Wikipedia mentions. I don't think there's an R implementation of that interval, but (in spite of the fact that Donoho tends to use fairly sophisticated tools in his discussion of it) it's actually a pretty simple idea to implement. That idea is directly related to the notion of using kernel density estimation.
[1]: David L. Donoho, (1988)
"One-Sided Inference about Functionals of a Density,"
Ann. Statist. 16(4): 1390-1420 (December)
|
Test for bimodal distribution
As mentioned in comments, the Wikipedia page on 'Bimodal distribution' lists eight tests for multimodality against unimodality and supplies references for seven of them.
There are at least some in R.
|
5,702
|
Test for bimodal distribution
|
You should look at the multimode package, which has also a Journal of Statistical Software companion paper: multimode: An R Package for Mode Assessment
The function modetest provides many tests with the argument method=...
Bandwidth test: original test from Silverman (1981) method=SI and improved p-values by Hall and York (2001), HY
Dip test: test by Hartigan and Hartigan (1985), HH
Excess Mass test: improved p-values of Cheng and Hall (1998) CH, and improved test by the authors of the package, Ameijeiras-Alonso et al. (2019) ACR
Cramer-von Mises test: Fisher and Marron (2001), FM
References:
Silverman BW (1981). “Using Kernel Density Estimates to Investigate Multimodality.” Journal of the Royal Statistical Society B, 43(1), 97–99. doi:10.1111/j.2517-6161.1981.tb01155.x.
Hartigan JA, Hartigan PM (1985). “The Dip Test of Unimodality.” The Annals of Statistics, 13(1), 70–84. doi:10.1214/aos/1176346577.
Hall P, York M (2001). “On the Calibration of Silverman’s Test for Multimodality.” Statistica Sinica, 11(1), 515–536.
Fisher NI, Marron JS (2001). “Mode Testing via the Excess Mass Estimate.” Biometrika, 88(2), 419–517. doi:10.1093/biomet/88.2.499.
Cheng MY, Hall P (1998). “Calibrating the Excess Mass and Dip Tests of Modality.” Journal of the Royal Statistical Society B, 60(3), 579–589. doi:10.1111/1467-9868.00141.
Ameijeiras-Alonso J, Crujeiras RM, Rodríguez-Casal A (2019). “Mode Testing, Critical Bandwidth and Excess Mass.” Test, 28(3), 900–919. doi:10.1007/s11749-018-0611-5.
|
Test for bimodal distribution
|
You should look at the multimode package, which has also a Journal of Statistical Software companion paper: multimode: An R Package for Mode Assessment
The function modetest provides many tests with t
|
Test for bimodal distribution
You should look at the multimode package, which has also a Journal of Statistical Software companion paper: multimode: An R Package for Mode Assessment
The function modetest provides many tests with the argument method=...
Bandwidth test: original test from Silverman (1981) method=SI and improved p-values by Hall and York (2001), HY
Dip test: test by Hartigan and Hartigan (1985), HH
Excess Mass test: improved p-values of Cheng and Hall (1998) CH, and improved test by the authors of the package, Ameijeiras-Alonso et al. (2019) ACR
Cramer-von Mises test: Fisher and Marron (2001), FM
References:
Silverman BW (1981). “Using Kernel Density Estimates to Investigate Multimodality.” Journal of the Royal Statistical Society B, 43(1), 97–99. doi:10.1111/j.2517-6161.1981.tb01155.x.
Hartigan JA, Hartigan PM (1985). “The Dip Test of Unimodality.” The Annals of Statistics, 13(1), 70–84. doi:10.1214/aos/1176346577.
Hall P, York M (2001). “On the Calibration of Silverman’s Test for Multimodality.” Statistica Sinica, 11(1), 515–536.
Fisher NI, Marron JS (2001). “Mode Testing via the Excess Mass Estimate.” Biometrika, 88(2), 419–517. doi:10.1093/biomet/88.2.499.
Cheng MY, Hall P (1998). “Calibrating the Excess Mass and Dip Tests of Modality.” Journal of the Royal Statistical Society B, 60(3), 579–589. doi:10.1111/1467-9868.00141.
Ameijeiras-Alonso J, Crujeiras RM, Rodríguez-Casal A (2019). “Mode Testing, Critical Bandwidth and Excess Mass.” Test, 28(3), 900–919. doi:10.1007/s11749-018-0611-5.
|
Test for bimodal distribution
You should look at the multimode package, which has also a Journal of Statistical Software companion paper: multimode: An R Package for Mode Assessment
The function modetest provides many tests with t
|
5,703
|
Differences between Bhattacharyya distance and KL divergence
|
The Bhattacharyya coefficient is defined as $$D_B(p,q) = \int \sqrt{p(x)q(x)}\,\text{d}x$$ and can be turned into a distance $d_H(p,q)$ as $$d_H(p,q)=\{1-D_B(p,q)\}^{1/2}$$ which is called the Hellinger distance. A connection between this Hellinger distance and the Kullback-Leibler divergence is
$$d_{KL}(p\|q) \geq 2 d_H^2(p,q) = 2 \{1-D_B(p,q)\}\,,$$
since
\begin{align*}
d_{KL}(p\|q) &= \int \log \frac{p(x)}{q(x)}\,p(x)\text{d}x\\
&= 2\int \log \frac{\sqrt{p(x)}}{\sqrt{q(x)}}\,p(x)\text{d}x\\
&= 2\int -\log \frac{\sqrt{q(x)}}{\sqrt{p(x)}}\,p(x)\text{d}x\\
&\ge 2\int \left\{1-\frac{\sqrt{q(x)}}{\sqrt{p(x)}}\right\}\,p(x)\text{d}x\\
&= \int \left\{1+1-2\sqrt{p(x)}\sqrt{q(x)}\right\}\,\text{d}x\\
&= \int \left\{\sqrt{p(x)}-\sqrt{q(x)}\right\}^2\,\text{d}x\\
&= 2d_H(p,q)^2
\end{align*}
However, this is not the question: if the Bhattacharyya distance is defined as$$d_B(p,q)\stackrel{\text{def}}{=}-\log D_B(p,q)\,,$$then
\begin{align*}d_B(p,q)=-\log D_B(p,q)&=-\log \int \sqrt{p(x)q(x)}\,\text{d}x\\
&\stackrel{\text{def}}{=}-\log \int h(x)\,\text{d}x\\
&= -\log \int \frac{h(x)}{p(x)}\,p(x)\,\text{d}x\\
&\le \int -\log \left\{\frac{h(x)}{p(x)}\right\}\,p(x)\,\text{d}x\\
&= \int \frac{-1}{2}\log \left\{\frac{h^2(x)}{p^2(x)}\right\}\,p(x)\,\text{d}x\\
\end{align*}
Hence, the inequality between the two distances is
$${d_{KL}(p\|q)\ge 2d_B(p,q)\,.}$$
One could then wonder whether this inequality follows from the first one. It happens to be the opposite: since $$-\log(x)\ge 1-x\qquad\qquad 0\le x\le 1\,,$$
we have the complete ordering$${d_{KL}(p\|q)\ge 2d_B(p,q)\ge 2d_H(p,q)^2\,.}$$
|
Differences between Bhattacharyya distance and KL divergence
|
The Bhattacharyya coefficient is defined as $$D_B(p,q) = \int \sqrt{p(x)q(x)}\,\text{d}x$$ and can be turned into a distance $d_H(p,q)$ as $$d_H(p,q)=\{1-D_B(p,q)\}^{1/2}$$ which is called the Helling
|
Differences between Bhattacharyya distance and KL divergence
The Bhattacharyya coefficient is defined as $$D_B(p,q) = \int \sqrt{p(x)q(x)}\,\text{d}x$$ and can be turned into a distance $d_H(p,q)$ as $$d_H(p,q)=\{1-D_B(p,q)\}^{1/2}$$ which is called the Hellinger distance. A connection between this Hellinger distance and the Kullback-Leibler divergence is
$$d_{KL}(p\|q) \geq 2 d_H^2(p,q) = 2 \{1-D_B(p,q)\}\,,$$
since
\begin{align*}
d_{KL}(p\|q) &= \int \log \frac{p(x)}{q(x)}\,p(x)\text{d}x\\
&= 2\int \log \frac{\sqrt{p(x)}}{\sqrt{q(x)}}\,p(x)\text{d}x\\
&= 2\int -\log \frac{\sqrt{q(x)}}{\sqrt{p(x)}}\,p(x)\text{d}x\\
&\ge 2\int \left\{1-\frac{\sqrt{q(x)}}{\sqrt{p(x)}}\right\}\,p(x)\text{d}x\\
&= \int \left\{1+1-2\sqrt{p(x)}\sqrt{q(x)}\right\}\,\text{d}x\\
&= \int \left\{\sqrt{p(x)}-\sqrt{q(x)}\right\}^2\,\text{d}x\\
&= 2d_H(p,q)^2
\end{align*}
However, this is not the question: if the Bhattacharyya distance is defined as$$d_B(p,q)\stackrel{\text{def}}{=}-\log D_B(p,q)\,,$$then
\begin{align*}d_B(p,q)=-\log D_B(p,q)&=-\log \int \sqrt{p(x)q(x)}\,\text{d}x\\
&\stackrel{\text{def}}{=}-\log \int h(x)\,\text{d}x\\
&= -\log \int \frac{h(x)}{p(x)}\,p(x)\,\text{d}x\\
&\le \int -\log \left\{\frac{h(x)}{p(x)}\right\}\,p(x)\,\text{d}x\\
&= \int \frac{-1}{2}\log \left\{\frac{h^2(x)}{p^2(x)}\right\}\,p(x)\,\text{d}x\\
\end{align*}
Hence, the inequality between the two distances is
$${d_{KL}(p\|q)\ge 2d_B(p,q)\,.}$$
One could then wonder whether this inequality follows from the first one. It happens to be the opposite: since $$-\log(x)\ge 1-x\qquad\qquad 0\le x\le 1\,,$$
we have the complete ordering$${d_{KL}(p\|q)\ge 2d_B(p,q)\ge 2d_H(p,q)^2\,.}$$
|
Differences between Bhattacharyya distance and KL divergence
The Bhattacharyya coefficient is defined as $$D_B(p,q) = \int \sqrt{p(x)q(x)}\,\text{d}x$$ and can be turned into a distance $d_H(p,q)$ as $$d_H(p,q)=\{1-D_B(p,q)\}^{1/2}$$ which is called the Helling
|
5,704
|
Differences between Bhattacharyya distance and KL divergence
|
I don't know of any explicit relation between the two, but decided to have a quick poke at them to see what I could find. So this isn't much of an answer, but more of a point of interest.
For simplicity, let's work over discrete distributions. We can write the BC distance as
$$d_\text{BC}(p,q) = - \ln \sum_x (p(x)q(x))^\frac{1}{2}$$
and the KL divergence as
$$d_\text{KL}(p,q) = \sum_x p(x)\ln \frac{p(x)}{q(x)}$$
Now we can't push the log inside the sum on the $\text{BC}$ distance, so let's try pulling the log to the outside of the $\text{KL}$ divergence:
$$d_\text{KL}(p,q) = -\ln \prod_x \left( \frac{q(x)}{p(x)} \right)^{p(x)}$$
Let's consider their behaviour when $p$ is fixed to be the uniform distribution over $n$ possibilities:
$$d_\text{KL}(p,q) = -\ln n - \ln \left(\prod_x q(x)\right)^\frac{1}{n} \qquad d_\text{BC}(p,q) = - \ln \frac{1}{\sqrt{n}} - \ln\sum_x \sqrt{q(x)}$$
On the left, we have the log of something that's similar in form to the geometric mean. On the right, we have something similar to the log of the arithmetic mean. Like I said, this isn't much of an answer, but I think it gives a neat intuition of how the BC distance and the KL divergence react to deviations between $p$ and $q$.
|
Differences between Bhattacharyya distance and KL divergence
|
I don't know of any explicit relation between the two, but decided to have a quick poke at them to see what I could find. So this isn't much of an answer, but more of a point of interest.
For simplici
|
Differences between Bhattacharyya distance and KL divergence
I don't know of any explicit relation between the two, but decided to have a quick poke at them to see what I could find. So this isn't much of an answer, but more of a point of interest.
For simplicity, let's work over discrete distributions. We can write the BC distance as
$$d_\text{BC}(p,q) = - \ln \sum_x (p(x)q(x))^\frac{1}{2}$$
and the KL divergence as
$$d_\text{KL}(p,q) = \sum_x p(x)\ln \frac{p(x)}{q(x)}$$
Now we can't push the log inside the sum on the $\text{BC}$ distance, so let's try pulling the log to the outside of the $\text{KL}$ divergence:
$$d_\text{KL}(p,q) = -\ln \prod_x \left( \frac{q(x)}{p(x)} \right)^{p(x)}$$
Let's consider their behaviour when $p$ is fixed to be the uniform distribution over $n$ possibilities:
$$d_\text{KL}(p,q) = -\ln n - \ln \left(\prod_x q(x)\right)^\frac{1}{n} \qquad d_\text{BC}(p,q) = - \ln \frac{1}{\sqrt{n}} - \ln\sum_x \sqrt{q(x)}$$
On the left, we have the log of something that's similar in form to the geometric mean. On the right, we have something similar to the log of the arithmetic mean. Like I said, this isn't much of an answer, but I think it gives a neat intuition of how the BC distance and the KL divergence react to deviations between $p$ and $q$.
|
Differences between Bhattacharyya distance and KL divergence
I don't know of any explicit relation between the two, but decided to have a quick poke at them to see what I could find. So this isn't much of an answer, but more of a point of interest.
For simplici
|
5,705
|
How is softmax_cross_entropy_with_logits different from softmax_cross_entropy_with_logits_v2?
|
You have every reason to be confused, because in supervised learning one doesn't need to backpropagate to labels. They are considered fixed ground truth and only the weights need to be adjusted to match them.
But in some cases, the labels themselves may come from a differentiable source, another network. One example might be adversarial learning. In this case, both networks might benefit from the error signal. That's the reason why tf.nn.softmax_cross_entropy_with_logits_v2 was introduced. Note that when the labels are the placeholders (which is also typical), there is no difference if the gradient through flows or not, because there are no variables to apply gradient to.
|
How is softmax_cross_entropy_with_logits different from softmax_cross_entropy_with_logits_v2?
|
You have every reason to be confused, because in supervised learning one doesn't need to backpropagate to labels. They are considered fixed ground truth and only the weights need to be adjusted to mat
|
How is softmax_cross_entropy_with_logits different from softmax_cross_entropy_with_logits_v2?
You have every reason to be confused, because in supervised learning one doesn't need to backpropagate to labels. They are considered fixed ground truth and only the weights need to be adjusted to match them.
But in some cases, the labels themselves may come from a differentiable source, another network. One example might be adversarial learning. In this case, both networks might benefit from the error signal. That's the reason why tf.nn.softmax_cross_entropy_with_logits_v2 was introduced. Note that when the labels are the placeholders (which is also typical), there is no difference if the gradient through flows or not, because there are no variables to apply gradient to.
|
How is softmax_cross_entropy_with_logits different from softmax_cross_entropy_with_logits_v2?
You have every reason to be confused, because in supervised learning one doesn't need to backpropagate to labels. They are considered fixed ground truth and only the weights need to be adjusted to mat
|
5,706
|
Mixed Effects Model with Nesting
|
I think this is correct.
(1|Tree/Organ/Sample) expands to/is equivalent to (1|Tree)+(1|Tree:Organ)+(1|Tree:Organ:Sample) (where : denotes an interaction).
The fixed factors Treatment, Organ and Tissue automatically get handled at the correct level.
You should probably include Site as a fixed effect (conceptually it's a random effect, but it's not practical to try to estimate among-site variance with only two sites); this will reduce the among-tree variance slightly.
You should probably include all the data within a data frame, and pass this explicitly to lmer via a data=my.data.frame argument.
You may find the glmm FAQ helpful (it's focused on GLMMs but does have stuff relevant to linear mixed models as well).
|
Mixed Effects Model with Nesting
|
I think this is correct.
(1|Tree/Organ/Sample) expands to/is equivalent to (1|Tree)+(1|Tree:Organ)+(1|Tree:Organ:Sample) (where : denotes an interaction).
The fixed factors Treatment, Organ and Ti
|
Mixed Effects Model with Nesting
I think this is correct.
(1|Tree/Organ/Sample) expands to/is equivalent to (1|Tree)+(1|Tree:Organ)+(1|Tree:Organ:Sample) (where : denotes an interaction).
The fixed factors Treatment, Organ and Tissue automatically get handled at the correct level.
You should probably include Site as a fixed effect (conceptually it's a random effect, but it's not practical to try to estimate among-site variance with only two sites); this will reduce the among-tree variance slightly.
You should probably include all the data within a data frame, and pass this explicitly to lmer via a data=my.data.frame argument.
You may find the glmm FAQ helpful (it's focused on GLMMs but does have stuff relevant to linear mixed models as well).
|
Mixed Effects Model with Nesting
I think this is correct.
(1|Tree/Organ/Sample) expands to/is equivalent to (1|Tree)+(1|Tree:Organ)+(1|Tree:Organ:Sample) (where : denotes an interaction).
The fixed factors Treatment, Organ and Ti
|
5,707
|
Mixed Effects Model with Nesting
|
I read this question and Dr. Bolker's answer, and tried to replicate the data (not caring much, frankly, about what "length" represents in biological terms or units, and then fit the model as above. I'm posting the results here to share and seek feedback as to the probable presence of misunderstandings.
The code I used to generate this fictional data can be found here, and the data set has the inner structure of the OP:
site tree treatment organ sample tissue length
1 L LT01 T root 1 phloem 108.21230
2 L LT01 T root 1 xylem 138.54267
3 L LT01 T root 2 phloem 68.88804
4 L LT01 T root 2 xylem 107.91239
5 L LT01 T root 3 phloem 96.78523
6 L LT01 T root 3 xylem 88.93194
7 L LT01 T stem 1 phloem 101.84103
8 L LT01 T stem 1 xylem 118.30319
The structure is as follows:
'data.frame': 360 obs. of 7 variables:
$ site : Factor w/ 2 levels "L","R": 1 1 1 1 1 1 1 1 1 1 ...
$ tree : Factor w/ 30 levels "LT01","LT02",..: 1 1 1 1 1 1 1 1 1 1 ...
$ treatment: Factor w/ 2 levels "C","T": 2 2 2 2 2 2 2 2 2 2 ...
$ organ : Factor w/ 2 levels "root","stem": 1 1 1 1 1 1 2 2 2 2 ...
$ sample : num 1 1 2 2 3 3 1 1 2 2 ...
$ tissue : Factor w/ 2 levels "phloem","xylem": 1 2 1 2 1 2 1 2 1 2 ...
$ length : num 108.2 138.5 68.9 107.9 96.8 ...
The data set was "rigged" (feedback here would be welcome) as follows:
For treatment, there is a fixed effect with two distinct intercepts for treatment versus controls (100 versus 70), and no random effects.
I set the values for tissue with prominent fixed effects with very different intercepts for phloem versus xylem (3 versus 6), and random effects with a sd = 3.
For organ there are two random intercept "contributions" from a $N(0,3)$ (i.e. sd = 3) with a fixed effect contribution to the intercept of 6 for both root and stem.
For tree we just have random effects with a sd = 7.
For sample I tried to set up only random effects with sd = 5.
For for site also just random eff's with sd = 3.
There were no slopes set up, due to the categorical nature of the variables.
The results of the mixed effects model:
fit <- lmer(length ~ treatment + organ + tissue + (1|tree/organ/sample), data = trees)
were:
Random effects:
Groups Name Variance Std.Dev.
sample:(organ:tree) (Intercept) 9.534e-14 3.088e-07
organ:tree (Intercept) 0.000e+00 0.000e+00
tree (Intercept) 4.939e+01 7.027e+00
Residual 3.603e+02 1.898e+01
Number of obs: 360, groups: sample:(organ:tree), 180; organ:tree, 60; tree, 30
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 79.8623 2.7011 52.5000 29.567 < 2e-16 ***
treatmentT 21.4368 3.2539 28.0000 6.588 3.82e-07 ***
organstem 0.1856 2.0008 328.0000 0.093 0.926
tissuexylem 3.1820 2.0008 328.0000 1.590 0.113
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
How did it work out:
For treatment the intercept without treatment was 79.8623 (I set up a mean of 70), and with treatment it was 79.8623 + 21.4368 = 101.2991 (we set up a mean of 100.
For tissue there was a 3.1820 contribution to the intercept courtesy of xylem, and I had set up a difference between phloem and xylem of 3. The random effects were not part of the model.
For organ, samples from the stem increased the intercept by 0.1856 - I had set up no difference in fixed effects between stem and root. The standard deviation of what I wanted to act as random effects was not reflected.
The tree random effects with a sd of 7 surfaced nicely as 7.027.
As for sample, the initial sd of 5 was underemphasized as 3.088.
site was not part of the model.
So, overall, it seems as though the model matches the structure of the data.
|
Mixed Effects Model with Nesting
|
I read this question and Dr. Bolker's answer, and tried to replicate the data (not caring much, frankly, about what "length" represents in biological terms or units, and then fit the model as above. I
|
Mixed Effects Model with Nesting
I read this question and Dr. Bolker's answer, and tried to replicate the data (not caring much, frankly, about what "length" represents in biological terms or units, and then fit the model as above. I'm posting the results here to share and seek feedback as to the probable presence of misunderstandings.
The code I used to generate this fictional data can be found here, and the data set has the inner structure of the OP:
site tree treatment organ sample tissue length
1 L LT01 T root 1 phloem 108.21230
2 L LT01 T root 1 xylem 138.54267
3 L LT01 T root 2 phloem 68.88804
4 L LT01 T root 2 xylem 107.91239
5 L LT01 T root 3 phloem 96.78523
6 L LT01 T root 3 xylem 88.93194
7 L LT01 T stem 1 phloem 101.84103
8 L LT01 T stem 1 xylem 118.30319
The structure is as follows:
'data.frame': 360 obs. of 7 variables:
$ site : Factor w/ 2 levels "L","R": 1 1 1 1 1 1 1 1 1 1 ...
$ tree : Factor w/ 30 levels "LT01","LT02",..: 1 1 1 1 1 1 1 1 1 1 ...
$ treatment: Factor w/ 2 levels "C","T": 2 2 2 2 2 2 2 2 2 2 ...
$ organ : Factor w/ 2 levels "root","stem": 1 1 1 1 1 1 2 2 2 2 ...
$ sample : num 1 1 2 2 3 3 1 1 2 2 ...
$ tissue : Factor w/ 2 levels "phloem","xylem": 1 2 1 2 1 2 1 2 1 2 ...
$ length : num 108.2 138.5 68.9 107.9 96.8 ...
The data set was "rigged" (feedback here would be welcome) as follows:
For treatment, there is a fixed effect with two distinct intercepts for treatment versus controls (100 versus 70), and no random effects.
I set the values for tissue with prominent fixed effects with very different intercepts for phloem versus xylem (3 versus 6), and random effects with a sd = 3.
For organ there are two random intercept "contributions" from a $N(0,3)$ (i.e. sd = 3) with a fixed effect contribution to the intercept of 6 for both root and stem.
For tree we just have random effects with a sd = 7.
For sample I tried to set up only random effects with sd = 5.
For for site also just random eff's with sd = 3.
There were no slopes set up, due to the categorical nature of the variables.
The results of the mixed effects model:
fit <- lmer(length ~ treatment + organ + tissue + (1|tree/organ/sample), data = trees)
were:
Random effects:
Groups Name Variance Std.Dev.
sample:(organ:tree) (Intercept) 9.534e-14 3.088e-07
organ:tree (Intercept) 0.000e+00 0.000e+00
tree (Intercept) 4.939e+01 7.027e+00
Residual 3.603e+02 1.898e+01
Number of obs: 360, groups: sample:(organ:tree), 180; organ:tree, 60; tree, 30
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 79.8623 2.7011 52.5000 29.567 < 2e-16 ***
treatmentT 21.4368 3.2539 28.0000 6.588 3.82e-07 ***
organstem 0.1856 2.0008 328.0000 0.093 0.926
tissuexylem 3.1820 2.0008 328.0000 1.590 0.113
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
How did it work out:
For treatment the intercept without treatment was 79.8623 (I set up a mean of 70), and with treatment it was 79.8623 + 21.4368 = 101.2991 (we set up a mean of 100.
For tissue there was a 3.1820 contribution to the intercept courtesy of xylem, and I had set up a difference between phloem and xylem of 3. The random effects were not part of the model.
For organ, samples from the stem increased the intercept by 0.1856 - I had set up no difference in fixed effects between stem and root. The standard deviation of what I wanted to act as random effects was not reflected.
The tree random effects with a sd of 7 surfaced nicely as 7.027.
As for sample, the initial sd of 5 was underemphasized as 3.088.
site was not part of the model.
So, overall, it seems as though the model matches the structure of the data.
|
Mixed Effects Model with Nesting
I read this question and Dr. Bolker's answer, and tried to replicate the data (not caring much, frankly, about what "length" represents in biological terms or units, and then fit the model as above. I
|
5,708
|
OpenBugs vs. JAGS
|
BUGS/OpenBugs has a peculiar build system which made compiling the code difficult to impossible on some systems — such as Linux (and IIRC OS X) where people had to resort to Windows emulation etc.
Jags, on the other hand, is a completely new project written with standard GNU tools and hence portable to just about anywhere — and therefore usable anywhere.
So in short, if your system is Windows then you do have a choice, and a potential cost of being stuck to Bugs if you ever move. If you are not on Windows, then Jags is likely to be the better choice.
|
OpenBugs vs. JAGS
|
BUGS/OpenBugs has a peculiar build system which made compiling the code difficult to impossible on some systems — such as Linux (and IIRC OS X) where people had to resort to Windows emulation etc.
Jag
|
OpenBugs vs. JAGS
BUGS/OpenBugs has a peculiar build system which made compiling the code difficult to impossible on some systems — such as Linux (and IIRC OS X) where people had to resort to Windows emulation etc.
Jags, on the other hand, is a completely new project written with standard GNU tools and hence portable to just about anywhere — and therefore usable anywhere.
So in short, if your system is Windows then you do have a choice, and a potential cost of being stuck to Bugs if you ever move. If you are not on Windows, then Jags is likely to be the better choice.
|
OpenBugs vs. JAGS
BUGS/OpenBugs has a peculiar build system which made compiling the code difficult to impossible on some systems — such as Linux (and IIRC OS X) where people had to resort to Windows emulation etc.
Jag
|
5,709
|
OpenBugs vs. JAGS
|
For those who find this question down the road: there's now also Stan. Stan may one day replace OpenBUGS and JAGS, but it does not yet support all the analyses that these other packages do.
|
OpenBugs vs. JAGS
|
For those who find this question down the road: there's now also Stan. Stan may one day replace OpenBUGS and JAGS, but it does not yet support all the analyses that these other packages do.
|
OpenBugs vs. JAGS
For those who find this question down the road: there's now also Stan. Stan may one day replace OpenBUGS and JAGS, but it does not yet support all the analyses that these other packages do.
|
OpenBugs vs. JAGS
For those who find this question down the road: there's now also Stan. Stan may one day replace OpenBUGS and JAGS, but it does not yet support all the analyses that these other packages do.
|
5,710
|
OpenBugs vs. JAGS
|
I recommend you jags over openbugs for speed reasons. I've tried both on a Linux system, and jags is way faster.
|
OpenBugs vs. JAGS
|
I recommend you jags over openbugs for speed reasons. I've tried both on a Linux system, and jags is way faster.
|
OpenBugs vs. JAGS
I recommend you jags over openbugs for speed reasons. I've tried both on a Linux system, and jags is way faster.
|
OpenBugs vs. JAGS
I recommend you jags over openbugs for speed reasons. I've tried both on a Linux system, and jags is way faster.
|
5,711
|
OpenBugs vs. JAGS
|
I find jags works more smoothly in Linux, and is easier to setup, but it does not presently support the spatial analyses that GeoBUGS supports. So, I use OpenBUGS.
|
OpenBugs vs. JAGS
|
I find jags works more smoothly in Linux, and is easier to setup, but it does not presently support the spatial analyses that GeoBUGS supports. So, I use OpenBUGS.
|
OpenBugs vs. JAGS
I find jags works more smoothly in Linux, and is easier to setup, but it does not presently support the spatial analyses that GeoBUGS supports. So, I use OpenBUGS.
|
OpenBugs vs. JAGS
I find jags works more smoothly in Linux, and is easier to setup, but it does not presently support the spatial analyses that GeoBUGS supports. So, I use OpenBUGS.
|
5,712
|
Statistics published in academic papers
|
After all, if a paper has taken years to write and has gone through rigorous peer review, then surely the statistics are going to be rock solid?
My experience of reading papers that attempt to apply statistics across a wide variety of areas (political science, economics, psychology, medicine, biology, finance, actuarial science, accounting, optics, astronomy, and many, many others) is that the quality of the statistical analysis may be anywhere on the spectrum from excellent and well done to egregious nonsense. I have seen good analysis in every one of the areas I have mentioned, and pretty poorly done analysis in almost all of them.
Some journals are generally pretty good, and some can be more like playing darts with a blindfold - you might get most of them not too terribly far off the target, but there's going to be a few in the wall, the floor and the ceiling. And maybe the cat.
I don't plan on naming any culprits, but I will say I have seen academic careers built on faulty use of statistics (i.e. where the same mistakes and misunderstandings were repeated in paper after paper, over more than a decade).
So my advice is let the reader beware; don't trust that the editors and peer reviewers know what they're doing. Over time you may get a good sense of which authors can generally be relied on to not do anything too shocking, and which ones should be treated especially warily. You may get a sense that some journals typically have very high standard for their stats.
But even a typically good author can make a mistake, or referees and editors can fail to pick up errors they might normally find; a typically good journal can publish a howler.
[Sometimes, you'll even see really bad papers win prizes or awards... which doesn't say much for the quality of the people judging the prize, either.]
I wouldn't like to guess what the fraction of "bad" stats I might have seen (in various guises, and at every stage from defining the question, design of the study, data collection, data management, ... right through to analysis and conclusions), but it's not nearly small enough for me to feel comfortable.
I could point to examples, but I don't think this is the right forum to do that. (It would be nice if there was a good forum for that, actually, but then again, it would likely become highly "politicized" quite quickly, and soon fail to serve its purpose.)
I've spent some time trawling through PLOS ONE ... and again, not going to point at specific papers. Some things I noticed: it looks like a large proportion of papers have stats in them, probably more than half having hypothesis tests. The main dangers seem to be lots of tests, either with high $\alpha$ like 0.05 on each (which is not automatically a problem as long as we understand that quite a few really tiny effects might show up as significant by chance), or an incredibly low individual significance level, which will tend to give low power. I also saw a number of cases where about half a dozen different tests were apparently applied to resolving exactly the same question. This strikes me as a generally bad idea. Overall the standard was pretty good across a few dozen papers, but in the past I have seen an absolutely terrible paper there.
[Perhaps I could indulge in just one example, indirectly. This question asks about one doing something quite dubious. It's far from the worst thing I've seen.]
On the other hand, I also see (even more frequently) cases where people are forced to jump through all kinds of unnecessary hoops to get their analysis accepted; perfectly reasonable things to do are not accepted because there's a "right" way to do things according to a reviewer or an editor or a supervisor, or just in the unspoken culture of a particular area.
|
Statistics published in academic papers
|
After all, if a paper has taken years to write and has gone through rigorous peer review, then surely the statistics are going to be rock solid?
My experience of reading papers that attempt to apply
|
Statistics published in academic papers
After all, if a paper has taken years to write and has gone through rigorous peer review, then surely the statistics are going to be rock solid?
My experience of reading papers that attempt to apply statistics across a wide variety of areas (political science, economics, psychology, medicine, biology, finance, actuarial science, accounting, optics, astronomy, and many, many others) is that the quality of the statistical analysis may be anywhere on the spectrum from excellent and well done to egregious nonsense. I have seen good analysis in every one of the areas I have mentioned, and pretty poorly done analysis in almost all of them.
Some journals are generally pretty good, and some can be more like playing darts with a blindfold - you might get most of them not too terribly far off the target, but there's going to be a few in the wall, the floor and the ceiling. And maybe the cat.
I don't plan on naming any culprits, but I will say I have seen academic careers built on faulty use of statistics (i.e. where the same mistakes and misunderstandings were repeated in paper after paper, over more than a decade).
So my advice is let the reader beware; don't trust that the editors and peer reviewers know what they're doing. Over time you may get a good sense of which authors can generally be relied on to not do anything too shocking, and which ones should be treated especially warily. You may get a sense that some journals typically have very high standard for their stats.
But even a typically good author can make a mistake, or referees and editors can fail to pick up errors they might normally find; a typically good journal can publish a howler.
[Sometimes, you'll even see really bad papers win prizes or awards... which doesn't say much for the quality of the people judging the prize, either.]
I wouldn't like to guess what the fraction of "bad" stats I might have seen (in various guises, and at every stage from defining the question, design of the study, data collection, data management, ... right through to analysis and conclusions), but it's not nearly small enough for me to feel comfortable.
I could point to examples, but I don't think this is the right forum to do that. (It would be nice if there was a good forum for that, actually, but then again, it would likely become highly "politicized" quite quickly, and soon fail to serve its purpose.)
I've spent some time trawling through PLOS ONE ... and again, not going to point at specific papers. Some things I noticed: it looks like a large proportion of papers have stats in them, probably more than half having hypothesis tests. The main dangers seem to be lots of tests, either with high $\alpha$ like 0.05 on each (which is not automatically a problem as long as we understand that quite a few really tiny effects might show up as significant by chance), or an incredibly low individual significance level, which will tend to give low power. I also saw a number of cases where about half a dozen different tests were apparently applied to resolving exactly the same question. This strikes me as a generally bad idea. Overall the standard was pretty good across a few dozen papers, but in the past I have seen an absolutely terrible paper there.
[Perhaps I could indulge in just one example, indirectly. This question asks about one doing something quite dubious. It's far from the worst thing I've seen.]
On the other hand, I also see (even more frequently) cases where people are forced to jump through all kinds of unnecessary hoops to get their analysis accepted; perfectly reasonable things to do are not accepted because there's a "right" way to do things according to a reviewer or an editor or a supervisor, or just in the unspoken culture of a particular area.
|
Statistics published in academic papers
After all, if a paper has taken years to write and has gone through rigorous peer review, then surely the statistics are going to be rock solid?
My experience of reading papers that attempt to apply
|
5,713
|
Statistics published in academic papers
|
I respect @Glen_b's stance on the right way to answer here (and certainly don't intend to detract from it), but I can't quite resist pointing to a particularly entertaining example that's close to my home. At the risk of politicizing things and doing this question's purpose a disservice, I recommend Wagenmakers, Wetzels, Boorsboom, and Van Der Maas (2011). I cited this in a related post on the Cognitive Sciences beta SE (How does cognitive science explain distant intentionality and brain function in recipients?), which considers another example of "a dart hitting the cat". Wagenmakers and colleagues' article comments directly on a real "howler" though: it was published in JPSP (one of the biggest journals in psychology) a few years ago. They also argue more generally in favor of Bayesian analysis and that:
In order to convince a skeptical audience of a controversial claim, one needs to conduct strictly confirmatory studies and analyze the results with statistical tests that are conservative rather than liberal.
I probably don't need to tell you that this didn't exactly come across as preaching to the choir. FWIW, there is a rebuttal as well (as there always seems to be between Bayesians and frequentists; (Bem, Utts, & Johnson, 2011), but I get the feeling that it didn't exactly checkmate the debate.
Psychology as a scientific community has been on a bit of a replication kick recently, partly due to this and other high-profile methodological shortcomings. Other comments here point to cases similar to what were once known as voodoo correlations in social neuroscience (how's that for politically incorrect BTW? the paper has been retitled; Vul, Harris, Winkielman, & Pashler, 2009). That too attracted its rebuttal, which you can check out for more debate of highly debatable practices.
For even more edutainment at the (more depersonalized) expense of (pseudo)statisticians behaving badly, see our currently 8th-most-upvoted question here on CV with another (admittedly) politically incorrect title, "What are common statistical sins?" Its OP @MikeLawrence attributes his inspiration to his parallel study of psychology and statistics. It's one of my personal favorites, and its answers are very useful for avoiding the innumerable pitfalls out there yourself.
On the personal side, I've been spending much of my last five months here largely because it's amazingly difficult to get rock-solid statistics on certain data-analytic questions. Frankly, peer review is often not very rigorous at all, especially in terms of statistical scrutiny of research in younger sciences with complex questions and plenty of epistemic complications. Hence I've felt the need to take personal responsibility for polishing the methods in my own work.
While presenting my dissertation research, I got a sense of how important personal responsibility for statistical scrutiny is. Two exceptional psychologists at my alma mater interjected that I was committing one of the most basic sins in my interpretations of correlations. I'd thought myself above it, and had lectured undergrads about it several times already, but I still went there, and got called out on it (early on, thank heavens). I went there because research I was reviewing and replicating went there! Thus I ended up adding several sections to my dissertation that called out those other researchers for assuming causality from quasi-experimental longitudinal studies (sometimes even from cross-sectional correlations) and ignoring alternative explanations prematurely.
My dissertation was accepted without revisions by my committee, which included another exceptional psychometrician and the soon-to-be-president of SPSP (which publishes JPSP), but to be frank once more, I'm not bragging in saying this. I've since managed to poke several rabbit holes in my own methods despite passing the external review process with perfectly good reviewers. I've now fallen into the deep end of stats in trying to plug them with methods more appropriate for predictive modeling of Likert ratings like SEM, IRT, and nonparametric analysis (see Regression testing after dimension reduction). I'm opting voluntarily to spend years on a paper that I could probably just publish as-is instead...I think I even have a simulation study left to do before I can proceed conscientiously.
Yet I emphasize that this is optional – maybe even overzealous and a costly luxury amidst the publish-or-perish culture that often emphasizes quantity over quality in early-career work records. Misapplication of parametric models for continuous data to assumption-violating distributions of ordinal data is all too common in my field, as is the misinterpretation and misrepresentation of statistical significance (see Accommodating entrenched views of p-values). I could totally get away with it (in the short term)...and it's not even all that hard to do better than that. I suppose I have several recent years of amazing advances in R programs to thank for that though! Here's hoping the times are changing.
References
· Bem, D. J., Utts, J., & Johnson, W. O. (2011). Must psychologists change the way they analyze their data? Journal of Personality and Social Psychology, 101(4), 716–719. Retrieved from http://deanradin.com/evidence/Bem2011.pdf.
· Vul, E., Harris, C., Winkielman, P., & Pashler, H. (2009). Puzzlingly high correlations in fMRI studies of emotion, personality, and social cognition. Perspectives on Psychological Science, 4(3), 274–290. Retrieved from http://www.edvul.com/pdf/VulHarrisWinkielmanPashler-PPS-2009.pdf.
· Wagenmakers, E. J., Wetzels, R., Borsboom, D., & Van der Maas, H. (2011). Why psychologists must change the way they analyze their data: The case of psi. Journal of Personality and Social Psychology, 100, 426–432. Retrieved from http://mpdc.mae.cornell.edu/Courses/MAE714/Papers/Bem6.pdf.
|
Statistics published in academic papers
|
I respect @Glen_b's stance on the right way to answer here (and certainly don't intend to detract from it), but I can't quite resist pointing to a particularly entertaining example that's close to my
|
Statistics published in academic papers
I respect @Glen_b's stance on the right way to answer here (and certainly don't intend to detract from it), but I can't quite resist pointing to a particularly entertaining example that's close to my home. At the risk of politicizing things and doing this question's purpose a disservice, I recommend Wagenmakers, Wetzels, Boorsboom, and Van Der Maas (2011). I cited this in a related post on the Cognitive Sciences beta SE (How does cognitive science explain distant intentionality and brain function in recipients?), which considers another example of "a dart hitting the cat". Wagenmakers and colleagues' article comments directly on a real "howler" though: it was published in JPSP (one of the biggest journals in psychology) a few years ago. They also argue more generally in favor of Bayesian analysis and that:
In order to convince a skeptical audience of a controversial claim, one needs to conduct strictly confirmatory studies and analyze the results with statistical tests that are conservative rather than liberal.
I probably don't need to tell you that this didn't exactly come across as preaching to the choir. FWIW, there is a rebuttal as well (as there always seems to be between Bayesians and frequentists; (Bem, Utts, & Johnson, 2011), but I get the feeling that it didn't exactly checkmate the debate.
Psychology as a scientific community has been on a bit of a replication kick recently, partly due to this and other high-profile methodological shortcomings. Other comments here point to cases similar to what were once known as voodoo correlations in social neuroscience (how's that for politically incorrect BTW? the paper has been retitled; Vul, Harris, Winkielman, & Pashler, 2009). That too attracted its rebuttal, which you can check out for more debate of highly debatable practices.
For even more edutainment at the (more depersonalized) expense of (pseudo)statisticians behaving badly, see our currently 8th-most-upvoted question here on CV with another (admittedly) politically incorrect title, "What are common statistical sins?" Its OP @MikeLawrence attributes his inspiration to his parallel study of psychology and statistics. It's one of my personal favorites, and its answers are very useful for avoiding the innumerable pitfalls out there yourself.
On the personal side, I've been spending much of my last five months here largely because it's amazingly difficult to get rock-solid statistics on certain data-analytic questions. Frankly, peer review is often not very rigorous at all, especially in terms of statistical scrutiny of research in younger sciences with complex questions and plenty of epistemic complications. Hence I've felt the need to take personal responsibility for polishing the methods in my own work.
While presenting my dissertation research, I got a sense of how important personal responsibility for statistical scrutiny is. Two exceptional psychologists at my alma mater interjected that I was committing one of the most basic sins in my interpretations of correlations. I'd thought myself above it, and had lectured undergrads about it several times already, but I still went there, and got called out on it (early on, thank heavens). I went there because research I was reviewing and replicating went there! Thus I ended up adding several sections to my dissertation that called out those other researchers for assuming causality from quasi-experimental longitudinal studies (sometimes even from cross-sectional correlations) and ignoring alternative explanations prematurely.
My dissertation was accepted without revisions by my committee, which included another exceptional psychometrician and the soon-to-be-president of SPSP (which publishes JPSP), but to be frank once more, I'm not bragging in saying this. I've since managed to poke several rabbit holes in my own methods despite passing the external review process with perfectly good reviewers. I've now fallen into the deep end of stats in trying to plug them with methods more appropriate for predictive modeling of Likert ratings like SEM, IRT, and nonparametric analysis (see Regression testing after dimension reduction). I'm opting voluntarily to spend years on a paper that I could probably just publish as-is instead...I think I even have a simulation study left to do before I can proceed conscientiously.
Yet I emphasize that this is optional – maybe even overzealous and a costly luxury amidst the publish-or-perish culture that often emphasizes quantity over quality in early-career work records. Misapplication of parametric models for continuous data to assumption-violating distributions of ordinal data is all too common in my field, as is the misinterpretation and misrepresentation of statistical significance (see Accommodating entrenched views of p-values). I could totally get away with it (in the short term)...and it's not even all that hard to do better than that. I suppose I have several recent years of amazing advances in R programs to thank for that though! Here's hoping the times are changing.
References
· Bem, D. J., Utts, J., & Johnson, W. O. (2011). Must psychologists change the way they analyze their data? Journal of Personality and Social Psychology, 101(4), 716–719. Retrieved from http://deanradin.com/evidence/Bem2011.pdf.
· Vul, E., Harris, C., Winkielman, P., & Pashler, H. (2009). Puzzlingly high correlations in fMRI studies of emotion, personality, and social cognition. Perspectives on Psychological Science, 4(3), 274–290. Retrieved from http://www.edvul.com/pdf/VulHarrisWinkielmanPashler-PPS-2009.pdf.
· Wagenmakers, E. J., Wetzels, R., Borsboom, D., & Van der Maas, H. (2011). Why psychologists must change the way they analyze their data: The case of psi. Journal of Personality and Social Psychology, 100, 426–432. Retrieved from http://mpdc.mae.cornell.edu/Courses/MAE714/Papers/Bem6.pdf.
|
Statistics published in academic papers
I respect @Glen_b's stance on the right way to answer here (and certainly don't intend to detract from it), but I can't quite resist pointing to a particularly entertaining example that's close to my
|
5,714
|
Statistics published in academic papers
|
I recall at University being ask by a few final year social science students on different occasions (one of them got a 1st) how to work out an average for their project that had had a handful of data points. (So they were not having problem with using software, just with the concept of how to do the maths with a calculator.)
They just give me blank looks when I ask them what type of average they wanted.
Yet they all felt a need to put some stats in their report, as it was the done thing – I expect they have all read 101 papers that had stats without thinking about what the stats meant if anything.
It is clear that the researcher that taught them over the 3 years did not care about the correctness of stats enough to distil any understanding into the students.
(I was a computer Sci student at the time. I am posting this as an answer as it is a bit long for a comment.)
|
Statistics published in academic papers
|
I recall at University being ask by a few final year social science students on different occasions (one of them got a 1st) how to work out an average for their project that had had a handful of data
|
Statistics published in academic papers
I recall at University being ask by a few final year social science students on different occasions (one of them got a 1st) how to work out an average for their project that had had a handful of data points. (So they were not having problem with using software, just with the concept of how to do the maths with a calculator.)
They just give me blank looks when I ask them what type of average they wanted.
Yet they all felt a need to put some stats in their report, as it was the done thing – I expect they have all read 101 papers that had stats without thinking about what the stats meant if anything.
It is clear that the researcher that taught them over the 3 years did not care about the correctness of stats enough to distil any understanding into the students.
(I was a computer Sci student at the time. I am posting this as an answer as it is a bit long for a comment.)
|
Statistics published in academic papers
I recall at University being ask by a few final year social science students on different occasions (one of them got a 1st) how to work out an average for their project that had had a handful of data
|
5,715
|
Statistics published in academic papers
|
As a woefully incomplete list, I find statistics most frequently correct in 1) physics papers followed by 2) statistical papers and most miserable in 3) medical papers. The reasons for this are straightforward and have to do with the completeness of the requirements imposed upon the prototypical model in each field.
In physics papers, equations and applied statistics have to pay attention to balanced units and have the most frequent occurrence of causal relationships, and testing against physical standards.
In statistics, 1) units and causality are sometimes ignored, the assumptions are sometimes heuristic, and physical testing is too often ignored, but equality (or inequality), i.e., logic is generally preserved along an inductive path, where the latter cannot correct for unphysical assumptions.
In medicine, typically units are ignored, the equations and assumptions are typically heuristic, typically untested and frequently spurious.
Naturally, a field like statistical mechanics is more likely to have testable assumptions than, let us say, economics, and, that does not reflect on the talents of the prospective authors in those fields. It is more related to how much of what is being done is actually testable, and how much testing has been done historically in each field.
|
Statistics published in academic papers
|
As a woefully incomplete list, I find statistics most frequently correct in 1) physics papers followed by 2) statistical papers and most miserable in 3) medical papers. The reasons for this are straig
|
Statistics published in academic papers
As a woefully incomplete list, I find statistics most frequently correct in 1) physics papers followed by 2) statistical papers and most miserable in 3) medical papers. The reasons for this are straightforward and have to do with the completeness of the requirements imposed upon the prototypical model in each field.
In physics papers, equations and applied statistics have to pay attention to balanced units and have the most frequent occurrence of causal relationships, and testing against physical standards.
In statistics, 1) units and causality are sometimes ignored, the assumptions are sometimes heuristic, and physical testing is too often ignored, but equality (or inequality), i.e., logic is generally preserved along an inductive path, where the latter cannot correct for unphysical assumptions.
In medicine, typically units are ignored, the equations and assumptions are typically heuristic, typically untested and frequently spurious.
Naturally, a field like statistical mechanics is more likely to have testable assumptions than, let us say, economics, and, that does not reflect on the talents of the prospective authors in those fields. It is more related to how much of what is being done is actually testable, and how much testing has been done historically in each field.
|
Statistics published in academic papers
As a woefully incomplete list, I find statistics most frequently correct in 1) physics papers followed by 2) statistical papers and most miserable in 3) medical papers. The reasons for this are straig
|
5,716
|
Statistics published in academic papers
|
Any paper that disproves the nil null hypothesis is using worthless statistics (the vast majority of what I have seen). This process can provide no information not already provided by the effect size. Further it tells us nothing about whether a significant result is actually due to the cause theorized by the researcher. This requires thoughtful investigation of the data for evidence of confounds. Most often, if present, the strongest of this evidence is even thrown away as "outliers".
I am not so familiar with evolution/ecology, but in the case of psych and medical research I would call the level of statistical understanding "severely confused" and "an obstacle to scientific progress". People are supposed to be disproving something predicted by their theory, not the opposite of it (zero difference/effect).
There have been thousands of papers written on this topic. Look up NHST hybrid controversy.
Edit:
And I do mean the nill null hypothesis significance test has a maximum of zero scientific value. This person hits the nail on the head:
http://www.johnmyleswhite.com/notebook/2012/05/18/criticism-4-of-nhst-no-mechanism-for-producing-substantive-cumulative-knowledge/
Also:
Paul Meehl. 1967. Theory Testing in Psychology and Physics: A Methodological Paradox
Edit 3:
If someone has arguments in favor of the usefulness of strawman NHST that do not require thinking "reject the hypothesis that the rate of warming is the same, but DO NOT take this to imply that the rate of warming is the not same" is a rational statement, I would welcome your comments.
Edit 4:
What did Fisher mean by the following quote? Does it suggest that he thought "If model/theory A is incompatible with the data, we can say A is false, but nothing about whether not A is true"?
"it is certain that the interest of statistical tests for scientific
workers depends entirely from their use in rejecting hypotheses which
are thereby judged to be incompatible with the observations."
...
It would, therefore, add greatly to the clarity with which the tests
of significance are regarded if it were generally understood that
tests of significance, when used accurately, are capable of rejecting
or invalidating hypotheses, in so far as these are contradicted by the
data; but that they are never capable of establishing them as
certainly true
Karl Pearson and R. A. Fisher on Statistical Tests: A 1935 Exchange from Nature
Is it that he assumed people would only try to invalidate plausible hypotheses rather than strawmen? Or am I wrong?
|
Statistics published in academic papers
|
Any paper that disproves the nil null hypothesis is using worthless statistics (the vast majority of what I have seen). This process can provide no information not already provided by the effect size.
|
Statistics published in academic papers
Any paper that disproves the nil null hypothesis is using worthless statistics (the vast majority of what I have seen). This process can provide no information not already provided by the effect size. Further it tells us nothing about whether a significant result is actually due to the cause theorized by the researcher. This requires thoughtful investigation of the data for evidence of confounds. Most often, if present, the strongest of this evidence is even thrown away as "outliers".
I am not so familiar with evolution/ecology, but in the case of psych and medical research I would call the level of statistical understanding "severely confused" and "an obstacle to scientific progress". People are supposed to be disproving something predicted by their theory, not the opposite of it (zero difference/effect).
There have been thousands of papers written on this topic. Look up NHST hybrid controversy.
Edit:
And I do mean the nill null hypothesis significance test has a maximum of zero scientific value. This person hits the nail on the head:
http://www.johnmyleswhite.com/notebook/2012/05/18/criticism-4-of-nhst-no-mechanism-for-producing-substantive-cumulative-knowledge/
Also:
Paul Meehl. 1967. Theory Testing in Psychology and Physics: A Methodological Paradox
Edit 3:
If someone has arguments in favor of the usefulness of strawman NHST that do not require thinking "reject the hypothesis that the rate of warming is the same, but DO NOT take this to imply that the rate of warming is the not same" is a rational statement, I would welcome your comments.
Edit 4:
What did Fisher mean by the following quote? Does it suggest that he thought "If model/theory A is incompatible with the data, we can say A is false, but nothing about whether not A is true"?
"it is certain that the interest of statistical tests for scientific
workers depends entirely from their use in rejecting hypotheses which
are thereby judged to be incompatible with the observations."
...
It would, therefore, add greatly to the clarity with which the tests
of significance are regarded if it were generally understood that
tests of significance, when used accurately, are capable of rejecting
or invalidating hypotheses, in so far as these are contradicted by the
data; but that they are never capable of establishing them as
certainly true
Karl Pearson and R. A. Fisher on Statistical Tests: A 1935 Exchange from Nature
Is it that he assumed people would only try to invalidate plausible hypotheses rather than strawmen? Or am I wrong?
|
Statistics published in academic papers
Any paper that disproves the nil null hypothesis is using worthless statistics (the vast majority of what I have seen). This process can provide no information not already provided by the effect size.
|
5,717
|
Why is the sampling distribution of variance a chi-squared distribution?
|
[I'll assume from the discussion in your question that you're happy to accept as fact that if $Z_i, i=1,2,\ldots,k$ are independent identically distributed $N(0,1)$ random variables then $\sum_{i=1}^{k}Z_i^2\sim \chi^2_k$.]
Formally, the result you need follows from Cochran's theorem.
(Though it can be shown in other ways)
Less formally, consider that if we knew the population mean, and estimated the variance about it (rather than about the sample mean): $s_0^2 = \frac{1}{n} \sum_{i=1}^{n}(X_i-\mu)^2$, then $s_0^2/\sigma^2 = \frac{1}{n} \sum_{i=1}^{n}\left(\frac{X_i-\mu}{\sigma}\right)^2=\frac{1}{n} \sum_{i=1}^{n}Z_i^2$, ($Z_i=(X_i-\mu)/\sigma$) which will be $\frac{1}{n}$ times a $\chi^2_n$ random variable.
The fact that the sample mean is used, instead of the population mean ($Z_i^*=(X_i-\bar{X})/\sigma$) makes the sum of squares of deviations smaller, but in just such a way that $\sum_{i=1}^{n}(Z_i^*)^2\,\sim\chi^2_{n-1}$ (about which, see Cochran's theorem). That is, rather than $ns_0^2/\sigma^2\sim \chi^2_n$ we now have $(n-1)s^2/\sigma^2\sim\chi^2_{n-1}$.
|
Why is the sampling distribution of variance a chi-squared distribution?
|
[I'll assume from the discussion in your question that you're happy to accept as fact that if $Z_i, i=1,2,\ldots,k$ are independent identically distributed $N(0,1)$ random variables then $\sum_{i=1}^{
|
Why is the sampling distribution of variance a chi-squared distribution?
[I'll assume from the discussion in your question that you're happy to accept as fact that if $Z_i, i=1,2,\ldots,k$ are independent identically distributed $N(0,1)$ random variables then $\sum_{i=1}^{k}Z_i^2\sim \chi^2_k$.]
Formally, the result you need follows from Cochran's theorem.
(Though it can be shown in other ways)
Less formally, consider that if we knew the population mean, and estimated the variance about it (rather than about the sample mean): $s_0^2 = \frac{1}{n} \sum_{i=1}^{n}(X_i-\mu)^2$, then $s_0^2/\sigma^2 = \frac{1}{n} \sum_{i=1}^{n}\left(\frac{X_i-\mu}{\sigma}\right)^2=\frac{1}{n} \sum_{i=1}^{n}Z_i^2$, ($Z_i=(X_i-\mu)/\sigma$) which will be $\frac{1}{n}$ times a $\chi^2_n$ random variable.
The fact that the sample mean is used, instead of the population mean ($Z_i^*=(X_i-\bar{X})/\sigma$) makes the sum of squares of deviations smaller, but in just such a way that $\sum_{i=1}^{n}(Z_i^*)^2\,\sim\chi^2_{n-1}$ (about which, see Cochran's theorem). That is, rather than $ns_0^2/\sigma^2\sim \chi^2_n$ we now have $(n-1)s^2/\sigma^2\sim\chi^2_{n-1}$.
|
Why is the sampling distribution of variance a chi-squared distribution?
[I'll assume from the discussion in your question that you're happy to accept as fact that if $Z_i, i=1,2,\ldots,k$ are independent identically distributed $N(0,1)$ random variables then $\sum_{i=1}^{
|
5,718
|
Empirical relationship between mean, median and mode
|
Denote $\mu$ the mean ($\neq$ average), $m$ the median, $\sigma$ the standard deviation and $M$ the mode. Finally, let $X$ be the sample, a realization of a continuous unimodal distribution $F$ for which the first two moments exist.
It's well known that
$$|\mu-m|\leq\sigma\label{d}\tag{1}$$
This is a frequent textbook exercise:
\begin{eqnarray}
|\mu-m| &=& |E(X-m)| \\
&\leq& E|X-m| \\
&\leq& E|X-\mu| \\
&=& E\sqrt{(X-\mu)^2} \\
&\leq& \sqrt{E(X-\mu)^2} \\
&=& \sigma
\end{eqnarray}
The first equality derives from the definition of the mean, the third comes about because the median is the unique minimiser (among all $c$'s) of $E|X-c|$ and the fourth from Jensen's inequality (i.e. the definition of a convex function). Actually, this inequality can be made tighter. In fact, for any $F$, satisfying the conditions above, it can be shown [3] that
$$|m-\mu|\leq \sqrt{0.6}\sigma\label{f}\tag{2}$$
Even though it is in general not true (Abadir, 2005) that any unimodal distribution must satisfy either one of
$$M\leq m\leq\mu\textit{ or }M\geq m\geq \mu$$
it can still be shown that the inequality
$$|\mu-M|\leq\sqrt{3}\sigma\label{e}\tag{3}$$
holds for any unimodal, square integrable distribution (regardless of skew). This is proven formally in Johnson and Rogers (1951) though the proof depends on many auxiliary lemmas that are hard to fit here. Go see the original paper.
A sufficient condition for a distribution $F$ to satisfy $\mu\leq m\leq M$ is given in [2]. If $F$:
$$F(m−x)+F(m+x)\geq 1 \text{ for all }x\label{g}\tag{4}$$
then $\mu\leq m\leq M$. Furthermore, if $\mu\neq m$, then the inequality is strict. The Pearson Type I to XII distributions are one example of family of distributions satisfying $(4)$ [4] (for example, the Weibull is one common distribution for which $(4)$ does not hold, see [5]).
Now assuming that $(4)$ holds strictly and w.l.o.g. that $\sigma=1$, we have that
$$3(m-\mu)\in(0,3\sqrt{0.6}] \mbox{ and } M-\mu\in(m-\mu,\sqrt{3}]$$
and since the second of these two ranges is not empty, it's certainly possible to find distributions for which the assertion is true (e.g. when $0<m-\mu<\frac{\sqrt{3}}{3}<\sigma=1$) for some range of values of the distribution's parameters but it is not true for all distributions and not even for all distributions satisfying $(4)$.
[0]: The Moment Problem for Unimodal Distributions.
N. L. Johnson and C. A. Rogers. The Annals of Mathematical Statistics, Vol. 22, No. 3 (Sep., 1951), pp. 433-439
[1]: The Mean-Median-Mode Inequality: Counterexamples
Karim M. Abadir
Econometric Theory, Vol. 21, No. 2 (Apr., 2005), pp. 477-482
[2]: W. R. van Zwet, Mean, median, mode II, Statist. Neerlandica, 33 (1979), pp. 1--5.
[3]: The Mean, Median, and Mode of Unimodal Distributions:A Characterization. S. Basu and A. DasGupta (1997). Theory Probab. Appl., 41(2), 210–223.
[4]: Some Remarks On The Mean, Median, Mode And Skewness. Michikazu Sato. Australian Journal of Statistics. Volume 39, Issue 2, pages 219–224, June 1997
[5]: P. T. von Hippel (2005). Mean, Median, and Skew: Correcting a Textbook Rule. Journal of Statistics Education Volume 13, Number 2.
|
Empirical relationship between mean, median and mode
|
Denote $\mu$ the mean ($\neq$ average), $m$ the median, $\sigma$ the standard deviation and $M$ the mode. Finally, let $X$ be the sample, a realization of a continuous unimodal distribution $F$ for wh
|
Empirical relationship between mean, median and mode
Denote $\mu$ the mean ($\neq$ average), $m$ the median, $\sigma$ the standard deviation and $M$ the mode. Finally, let $X$ be the sample, a realization of a continuous unimodal distribution $F$ for which the first two moments exist.
It's well known that
$$|\mu-m|\leq\sigma\label{d}\tag{1}$$
This is a frequent textbook exercise:
\begin{eqnarray}
|\mu-m| &=& |E(X-m)| \\
&\leq& E|X-m| \\
&\leq& E|X-\mu| \\
&=& E\sqrt{(X-\mu)^2} \\
&\leq& \sqrt{E(X-\mu)^2} \\
&=& \sigma
\end{eqnarray}
The first equality derives from the definition of the mean, the third comes about because the median is the unique minimiser (among all $c$'s) of $E|X-c|$ and the fourth from Jensen's inequality (i.e. the definition of a convex function). Actually, this inequality can be made tighter. In fact, for any $F$, satisfying the conditions above, it can be shown [3] that
$$|m-\mu|\leq \sqrt{0.6}\sigma\label{f}\tag{2}$$
Even though it is in general not true (Abadir, 2005) that any unimodal distribution must satisfy either one of
$$M\leq m\leq\mu\textit{ or }M\geq m\geq \mu$$
it can still be shown that the inequality
$$|\mu-M|\leq\sqrt{3}\sigma\label{e}\tag{3}$$
holds for any unimodal, square integrable distribution (regardless of skew). This is proven formally in Johnson and Rogers (1951) though the proof depends on many auxiliary lemmas that are hard to fit here. Go see the original paper.
A sufficient condition for a distribution $F$ to satisfy $\mu\leq m\leq M$ is given in [2]. If $F$:
$$F(m−x)+F(m+x)\geq 1 \text{ for all }x\label{g}\tag{4}$$
then $\mu\leq m\leq M$. Furthermore, if $\mu\neq m$, then the inequality is strict. The Pearson Type I to XII distributions are one example of family of distributions satisfying $(4)$ [4] (for example, the Weibull is one common distribution for which $(4)$ does not hold, see [5]).
Now assuming that $(4)$ holds strictly and w.l.o.g. that $\sigma=1$, we have that
$$3(m-\mu)\in(0,3\sqrt{0.6}] \mbox{ and } M-\mu\in(m-\mu,\sqrt{3}]$$
and since the second of these two ranges is not empty, it's certainly possible to find distributions for which the assertion is true (e.g. when $0<m-\mu<\frac{\sqrt{3}}{3}<\sigma=1$) for some range of values of the distribution's parameters but it is not true for all distributions and not even for all distributions satisfying $(4)$.
[0]: The Moment Problem for Unimodal Distributions.
N. L. Johnson and C. A. Rogers. The Annals of Mathematical Statistics, Vol. 22, No. 3 (Sep., 1951), pp. 433-439
[1]: The Mean-Median-Mode Inequality: Counterexamples
Karim M. Abadir
Econometric Theory, Vol. 21, No. 2 (Apr., 2005), pp. 477-482
[2]: W. R. van Zwet, Mean, median, mode II, Statist. Neerlandica, 33 (1979), pp. 1--5.
[3]: The Mean, Median, and Mode of Unimodal Distributions:A Characterization. S. Basu and A. DasGupta (1997). Theory Probab. Appl., 41(2), 210–223.
[4]: Some Remarks On The Mean, Median, Mode And Skewness. Michikazu Sato. Australian Journal of Statistics. Volume 39, Issue 2, pages 219–224, June 1997
[5]: P. T. von Hippel (2005). Mean, Median, and Skew: Correcting a Textbook Rule. Journal of Statistics Education Volume 13, Number 2.
|
Empirical relationship between mean, median and mode
Denote $\mu$ the mean ($\neq$ average), $m$ the median, $\sigma$ the standard deviation and $M$ the mode. Finally, let $X$ be the sample, a realization of a continuous unimodal distribution $F$ for wh
|
5,719
|
Empirical relationship between mean, median and mode
|
The paper chl points to gives some important information -- showing that it's not close to a general rule (even for continuous, smooth, "nicely behaved" variables, like the Weibull). So while it may often be approximately true, it's frequently not.
So where is Pearson coming from? How did he arrive at this approximation?
Fortunately, Pearson pretty much tells us the answer himself.
The first use of the term "skew" in the sense we're using it seems to be Pearson, 1895 [1] (it appears right in the title). This paper also appears to be where he introduces the term mode (footnote, p345):
I have found it convenient to use the term mode for the abscissa corresponding to the ordinate of maximum frequency. The the "mean," the "mode," and the "median" have all distinct characters important to the statistician.
It also appears to be his first real detailing of of his system of frequency curves.
So in discussing estimation of the shape parameter in the Pearson Type III distribution (what we'd now call a shifted - and possibly flipped - gamma), he says (p375):
The mean, the median, and the mode or maximum-ordinate are marked by bb, cc and aa, respectively, and as soon as the curves were drawn, a remarkable relation manifested itself between the position of the three quantities: the median, so long as $p$ was positive* was seen to be about one-third from the mean towards the maximum$^\dagger$
* this corresponds to the gamma having shape parameter $>1$
$\dagger$ here the intent of "maximum" is the $x$-value of the maximum frequency (the mode), as is clear from the beginning of the quote, not the maximum of the random variable.
And indeed, if we look at the ratio of (mean-mode) to (mean-median) for the gamma distribution, we observe this:
(The blue part marks the region Pearson says that the approximation is reasonable).
Indeed, if we look at some other distributions in the Pearson system - say the beta distributions, for example - the same ratio approximately holds as long as $\alpha$ and $\beta$ are not too small:
(the particular choice of subfamilies of the beta with $\sqrt{\beta}-\sqrt{\alpha}=k$ was taken because of the appearance of $\sqrt{\beta}-\sqrt{\alpha}$ in the moment skewness, in such a way that increasing $\alpha$ for constant $\sqrt{\beta}-\sqrt{\alpha}$ corresponds to decreasing moment skewness. Interestingly, for values of $\alpha$ and $\beta$ such that $\sqrt{\beta}+\sqrt{\alpha}=c$, the curves have almost constant (mean-mode)/(mean-median), which suggests that we might be able to say that the approximation is reasonable if $\sqrt{\beta}+\sqrt{\alpha}$ is large enough, though possibly with some minimum on the smaller of $\alpha$ and $\beta$.)
The inverse gamma is also in the Pearson system; it, too, has the relationship for large values of the shape parameter (say roughly $\alpha>10$):
It should be expected that Pearson was also familiar with the lognormal distribution. In that case the mode, median and mean are respectively $e^{\mu-\sigma^2}, e^{\mu}$ and $e^{\mu+\sigma^2/2}$; it was discussed prior to the development of his system and is often associated with Galton.
Let us again look at (mean-mode)/(mean-median). Cancelling out a factor of $e^{\mu}$ from both numerator and denominator, we're left with $\frac{e^{\sigma^2/2}-e^{-\sigma^2}}{e^{\sigma^2/2}-1}$. To first order (which will be accurate when $\sigma^2$ is small), the numerator will be $\frac{3}{2}\sigma^2$ and the denominator $\frac{1}{2}\sigma^2$, so at least for small $\sigma^2$ it should also hold for the lognormal.
There are a fair number of well known distributions - several of which Pearson was familiar with - for which it is close to true for a wide range of parameter values; he noticed it with the gamma distribution, but would have had the idea confirmed when he came to look at several other distributions he'd be likely to consider.
[1]: Pearson, K. (1895),
"Contributions to the Mathematical Theory of Evolution, II: Skew Variation in Homogeneous Material,"
Philosophical Transactions of the Royal Society, Series A, 186, 343-414
[Out of copyright. Freely available here]
|
Empirical relationship between mean, median and mode
|
The paper chl points to gives some important information -- showing that it's not close to a general rule (even for continuous, smooth, "nicely behaved" variables, like the Weibull). So while it may o
|
Empirical relationship between mean, median and mode
The paper chl points to gives some important information -- showing that it's not close to a general rule (even for continuous, smooth, "nicely behaved" variables, like the Weibull). So while it may often be approximately true, it's frequently not.
So where is Pearson coming from? How did he arrive at this approximation?
Fortunately, Pearson pretty much tells us the answer himself.
The first use of the term "skew" in the sense we're using it seems to be Pearson, 1895 [1] (it appears right in the title). This paper also appears to be where he introduces the term mode (footnote, p345):
I have found it convenient to use the term mode for the abscissa corresponding to the ordinate of maximum frequency. The the "mean," the "mode," and the "median" have all distinct characters important to the statistician.
It also appears to be his first real detailing of of his system of frequency curves.
So in discussing estimation of the shape parameter in the Pearson Type III distribution (what we'd now call a shifted - and possibly flipped - gamma), he says (p375):
The mean, the median, and the mode or maximum-ordinate are marked by bb, cc and aa, respectively, and as soon as the curves were drawn, a remarkable relation manifested itself between the position of the three quantities: the median, so long as $p$ was positive* was seen to be about one-third from the mean towards the maximum$^\dagger$
* this corresponds to the gamma having shape parameter $>1$
$\dagger$ here the intent of "maximum" is the $x$-value of the maximum frequency (the mode), as is clear from the beginning of the quote, not the maximum of the random variable.
And indeed, if we look at the ratio of (mean-mode) to (mean-median) for the gamma distribution, we observe this:
(The blue part marks the region Pearson says that the approximation is reasonable).
Indeed, if we look at some other distributions in the Pearson system - say the beta distributions, for example - the same ratio approximately holds as long as $\alpha$ and $\beta$ are not too small:
(the particular choice of subfamilies of the beta with $\sqrt{\beta}-\sqrt{\alpha}=k$ was taken because of the appearance of $\sqrt{\beta}-\sqrt{\alpha}$ in the moment skewness, in such a way that increasing $\alpha$ for constant $\sqrt{\beta}-\sqrt{\alpha}$ corresponds to decreasing moment skewness. Interestingly, for values of $\alpha$ and $\beta$ such that $\sqrt{\beta}+\sqrt{\alpha}=c$, the curves have almost constant (mean-mode)/(mean-median), which suggests that we might be able to say that the approximation is reasonable if $\sqrt{\beta}+\sqrt{\alpha}$ is large enough, though possibly with some minimum on the smaller of $\alpha$ and $\beta$.)
The inverse gamma is also in the Pearson system; it, too, has the relationship for large values of the shape parameter (say roughly $\alpha>10$):
It should be expected that Pearson was also familiar with the lognormal distribution. In that case the mode, median and mean are respectively $e^{\mu-\sigma^2}, e^{\mu}$ and $e^{\mu+\sigma^2/2}$; it was discussed prior to the development of his system and is often associated with Galton.
Let us again look at (mean-mode)/(mean-median). Cancelling out a factor of $e^{\mu}$ from both numerator and denominator, we're left with $\frac{e^{\sigma^2/2}-e^{-\sigma^2}}{e^{\sigma^2/2}-1}$. To first order (which will be accurate when $\sigma^2$ is small), the numerator will be $\frac{3}{2}\sigma^2$ and the denominator $\frac{1}{2}\sigma^2$, so at least for small $\sigma^2$ it should also hold for the lognormal.
There are a fair number of well known distributions - several of which Pearson was familiar with - for which it is close to true for a wide range of parameter values; he noticed it with the gamma distribution, but would have had the idea confirmed when he came to look at several other distributions he'd be likely to consider.
[1]: Pearson, K. (1895),
"Contributions to the Mathematical Theory of Evolution, II: Skew Variation in Homogeneous Material,"
Philosophical Transactions of the Royal Society, Series A, 186, 343-414
[Out of copyright. Freely available here]
|
Empirical relationship between mean, median and mode
The paper chl points to gives some important information -- showing that it's not close to a general rule (even for continuous, smooth, "nicely behaved" variables, like the Weibull). So while it may o
|
5,720
|
Empirical relationship between mean, median and mode
|
This relationship was not derived. It was noticed to approximately hold on near symmetric distributions empirically. See Yule's exposition in The Introduction to the theory of statistics, (1922), p.121, Chapter VII Section 20. He presents the empirical example.
|
Empirical relationship between mean, median and mode
|
This relationship was not derived. It was noticed to approximately hold on near symmetric distributions empirically. See Yule's exposition in The Introduction to the theory of statistics, (1922), p.12
|
Empirical relationship between mean, median and mode
This relationship was not derived. It was noticed to approximately hold on near symmetric distributions empirically. See Yule's exposition in The Introduction to the theory of statistics, (1922), p.121, Chapter VII Section 20. He presents the empirical example.
|
Empirical relationship between mean, median and mode
This relationship was not derived. It was noticed to approximately hold on near symmetric distributions empirically. See Yule's exposition in The Introduction to the theory of statistics, (1922), p.12
|
5,721
|
Using R online - without installing it [closed]
|
Yes, there are some Rweb interface, like this one (dead as of September 2020), RDDR online REPL, or Repl.it.
Note: Installation of the R software is pretty straightforward and quick, on any platform.
|
Using R online - without installing it [closed]
|
Yes, there are some Rweb interface, like this one (dead as of September 2020), RDDR online REPL, or Repl.it.
Note: Installation of the R software is pretty straightforward and quick, on any platform.
|
Using R online - without installing it [closed]
Yes, there are some Rweb interface, like this one (dead as of September 2020), RDDR online REPL, or Repl.it.
Note: Installation of the R software is pretty straightforward and quick, on any platform.
|
Using R online - without installing it [closed]
Yes, there are some Rweb interface, like this one (dead as of September 2020), RDDR online REPL, or Repl.it.
Note: Installation of the R software is pretty straightforward and quick, on any platform.
|
5,722
|
Using R online - without installing it [closed]
|
Also, if you want to provide a solution to other users, you can set up a webserver with RApache.
|
Using R online - without installing it [closed]
|
Also, if you want to provide a solution to other users, you can set up a webserver with RApache.
|
Using R online - without installing it [closed]
Also, if you want to provide a solution to other users, you can set up a webserver with RApache.
|
Using R online - without installing it [closed]
Also, if you want to provide a solution to other users, you can set up a webserver with RApache.
|
5,723
|
Using R online - without installing it [closed]
|
Sage also has R included with a Python interface. The Sage system is available. Since a couple of years, the prefered way to run SageMath is via CoCalc. It also allows you to run R directly, e.g. in a Jupyter notebook using the R kernel.
Example:
r.data("faithful")
r.lm("eruptions ~ waiting", data=r.faithful)
Output:
Call:
lm(formula = sage2, data = sage0)
Coefficients:
(Intercept) waiting
-1.87402 0.07563
|
Using R online - without installing it [closed]
|
Sage also has R included with a Python interface. The Sage system is available. Since a couple of years, the prefered way to run SageMath is via CoCalc. It also allows you to run R directly, e.g. in a
|
Using R online - without installing it [closed]
Sage also has R included with a Python interface. The Sage system is available. Since a couple of years, the prefered way to run SageMath is via CoCalc. It also allows you to run R directly, e.g. in a Jupyter notebook using the R kernel.
Example:
r.data("faithful")
r.lm("eruptions ~ waiting", data=r.faithful)
Output:
Call:
lm(formula = sage2, data = sage0)
Coefficients:
(Intercept) waiting
-1.87402 0.07563
|
Using R online - without installing it [closed]
Sage also has R included with a Python interface. The Sage system is available. Since a couple of years, the prefered way to run SageMath is via CoCalc. It also allows you to run R directly, e.g. in a
|
5,724
|
Using R online - without installing it [closed]
|
Some of the pastebin services will allow you to enter R code. For example, ideone. Here is a very silly hello world in R. I believe ideone limits you to 15 seconds compute time per run, and no fancy IDE, despite the name.
|
Using R online - without installing it [closed]
|
Some of the pastebin services will allow you to enter R code. For example, ideone. Here is a very silly hello world in R. I believe ideone limits you to 15 seconds compute time per run, and no fancy I
|
Using R online - without installing it [closed]
Some of the pastebin services will allow you to enter R code. For example, ideone. Here is a very silly hello world in R. I believe ideone limits you to 15 seconds compute time per run, and no fancy IDE, despite the name.
|
Using R online - without installing it [closed]
Some of the pastebin services will allow you to enter R code. For example, ideone. Here is a very silly hello world in R. I believe ideone limits you to 15 seconds compute time per run, and no fancy I
|
5,725
|
Using R online - without installing it [closed]
|
Have a look at RStudio This has a desktop and web version. I have used the desktop version and it is pretty cool.
|
Using R online - without installing it [closed]
|
Have a look at RStudio This has a desktop and web version. I have used the desktop version and it is pretty cool.
|
Using R online - without installing it [closed]
Have a look at RStudio This has a desktop and web version. I have used the desktop version and it is pretty cool.
|
Using R online - without installing it [closed]
Have a look at RStudio This has a desktop and web version. I have used the desktop version and it is pretty cool.
|
5,726
|
What is the difference between conditional and unconditional quantile regression?
|
Set-up
Suppose you have a simple regression of the form
$$\ln y_i = \alpha + \beta S_i + \epsilon_i $$
where the outcome are the log earnings of person $i$, $S_i$ is the number of years of schooling, and $\epsilon_i$ is an error term. Instead of only looking at the average effect of education on earnings, which you would get via OLS, you also want to see the effect at different parts of the outcome distribution.
1) What is the difference between the conditional and unconditional setting
First plot the log earnings and let us pick two individuals, $A$ and $B$, where $A$ is in the lower part of the unconditional earnings distribution and $B$ is in the upper part.
It doesn't look extremely normal but that's because I only used 200 observations in the simulation, so don't mind that. Now what happens if we condition our earnings on years of education? For each level of education you would get a "conditional" earnings distribution, i.e. you would come up with a density plot as above but for each level of education separately.
The two dark blue lines are the predicted earnings from linear quantile regressions at the median (lower line) and the 90th percentile (upper line). The red densities at 5 years and 15 years of education give you an estimate of the conditional earnings distribution. As you see, individual $A$ has 5 years of education and individual $B$ has 15 years of education. Apparently, individual $A$ is doing quite well among his pears in the 5-years of education bracket, hence she is in the 90th percentile.
So once you condition on another variable, it has now happened that one person is now in the top part of the conditional distribution whereas that person would be in the lower part of the unconditional distribution - this is what changes the interpretation of the quantile regression coefficients. Why?
You already said that with OLS we can go from $E[y_i|S_i] = E[y_i]$ by applying the law of iterated expectations, however, this is a property of the expectations operator which is not available for quantiles (unfortunately!). Therefore in general $Q_{\tau}(y_i|S_i) \neq Q_{\tau}(y_i)$, at any quantile $\tau$. This can be solved by first performing the conditional quantile regression and then integrate out the conditioning variables in order to obtain the marginalized effect (the unconditional effect) which you can interpret as in OLS. An example of this approach is provided by Powell (2014).
2) How to interpret quantile regression coefficients?
This is the tricky part and I don't claim to possess all the knowledge in the world about this, so maybe someone comes up with a better explanation for this. As you've seen, an individual's rank in the earnings distribution can be very different for whether you consider the conditional or unconditional distribution.
For conditional quantile regression
Since you can't tell where an individual will be in the outcome distribution before and after a treatment you can only make statements about the distribution as a whole. For instance, in the above example a $\beta_{90} = 0.13$ would mean that an additional year of education increases the earnings in the 90th percentile of the conditional earnings distribution (but you don't know who is still in that quantile before you assigned to people an additional year of education). That's why the conditional quantile estimates or conditional quantile treatment effects are often not considered as being "interesting". Normally we would like to know how a treatment affects our individuals at hand, not just the distribution.
For unconditional quantile regression
Those are like the OLS coefficients that you are used to interpret. The difficulty here is not the interpretation but how to get those coefficients which is not always easy (integration may not work, e.g. with very sparse data). Other ways of marginalizing quantile regression coefficients are available such as Firpo's (2009) method using the recentered influence function. The book by Angrist and Pischke (2009) mentioned in the comments states that the marginalization of quantile regression coefficients is still an active research field in econometrics - though as far as I am aware most people nowadays settle for the integration method (an example would be Melly and Santangelo (2015) who apply it to the Changes-in-Changes model).
3) Are conditional quantile regression coefficients biased?
No (assuming you have a correctly specified model), they just measure something different that you may or may not be interested in. An estimated effect on a distribution rather than individuals is as I said not very interesting - most of the times. To give a counter example: consider a policy maker who introduces an additional year of compulsory schooling and they want to know whether this reduces earnings inequality in the population.
The top two panels show a pure location shift where $\beta_{\tau}$ is a constant at all quantiles, i.e. a constant quantile treatment effect, meaning that if $\beta_{10} = \beta_{90} = 0.8$, an additional year of education increases earnings by 8% across the entire earnings distribution.
When the quantile treatment effect is NOT constant (as in the bottom two panels), you also have a scale effect in addition to the location effect. In this example the bottom of the earnings distribution shifts up by more than the top, so the 90-10 differential (a standard measure of earnings inequality) decreases in the population.
You don't know which individuals benefit from it or in what part of the distribution people are who started out in the bottom (to answer THAT question you need the unconditional quantile regression coefficients). Maybe this policy hurts them and puts them in an even lower part relative to others but if the aim was to know whether an additional year of compulsory education reduces the earnings spread then this is informative. An example of such an approach is Brunello et al. (2009).
If you are still interested in the bias of quantile regressions due to sources of endogeneity have a look at Angrist et al (2006) where they derive an omitted variable bias formula for the quantile context.
|
What is the difference between conditional and unconditional quantile regression?
|
Set-up
Suppose you have a simple regression of the form
$$\ln y_i = \alpha + \beta S_i + \epsilon_i $$
where the outcome are the log earnings of person $i$, $S_i$ is the number of years of schooling,
|
What is the difference between conditional and unconditional quantile regression?
Set-up
Suppose you have a simple regression of the form
$$\ln y_i = \alpha + \beta S_i + \epsilon_i $$
where the outcome are the log earnings of person $i$, $S_i$ is the number of years of schooling, and $\epsilon_i$ is an error term. Instead of only looking at the average effect of education on earnings, which you would get via OLS, you also want to see the effect at different parts of the outcome distribution.
1) What is the difference between the conditional and unconditional setting
First plot the log earnings and let us pick two individuals, $A$ and $B$, where $A$ is in the lower part of the unconditional earnings distribution and $B$ is in the upper part.
It doesn't look extremely normal but that's because I only used 200 observations in the simulation, so don't mind that. Now what happens if we condition our earnings on years of education? For each level of education you would get a "conditional" earnings distribution, i.e. you would come up with a density plot as above but for each level of education separately.
The two dark blue lines are the predicted earnings from linear quantile regressions at the median (lower line) and the 90th percentile (upper line). The red densities at 5 years and 15 years of education give you an estimate of the conditional earnings distribution. As you see, individual $A$ has 5 years of education and individual $B$ has 15 years of education. Apparently, individual $A$ is doing quite well among his pears in the 5-years of education bracket, hence she is in the 90th percentile.
So once you condition on another variable, it has now happened that one person is now in the top part of the conditional distribution whereas that person would be in the lower part of the unconditional distribution - this is what changes the interpretation of the quantile regression coefficients. Why?
You already said that with OLS we can go from $E[y_i|S_i] = E[y_i]$ by applying the law of iterated expectations, however, this is a property of the expectations operator which is not available for quantiles (unfortunately!). Therefore in general $Q_{\tau}(y_i|S_i) \neq Q_{\tau}(y_i)$, at any quantile $\tau$. This can be solved by first performing the conditional quantile regression and then integrate out the conditioning variables in order to obtain the marginalized effect (the unconditional effect) which you can interpret as in OLS. An example of this approach is provided by Powell (2014).
2) How to interpret quantile regression coefficients?
This is the tricky part and I don't claim to possess all the knowledge in the world about this, so maybe someone comes up with a better explanation for this. As you've seen, an individual's rank in the earnings distribution can be very different for whether you consider the conditional or unconditional distribution.
For conditional quantile regression
Since you can't tell where an individual will be in the outcome distribution before and after a treatment you can only make statements about the distribution as a whole. For instance, in the above example a $\beta_{90} = 0.13$ would mean that an additional year of education increases the earnings in the 90th percentile of the conditional earnings distribution (but you don't know who is still in that quantile before you assigned to people an additional year of education). That's why the conditional quantile estimates or conditional quantile treatment effects are often not considered as being "interesting". Normally we would like to know how a treatment affects our individuals at hand, not just the distribution.
For unconditional quantile regression
Those are like the OLS coefficients that you are used to interpret. The difficulty here is not the interpretation but how to get those coefficients which is not always easy (integration may not work, e.g. with very sparse data). Other ways of marginalizing quantile regression coefficients are available such as Firpo's (2009) method using the recentered influence function. The book by Angrist and Pischke (2009) mentioned in the comments states that the marginalization of quantile regression coefficients is still an active research field in econometrics - though as far as I am aware most people nowadays settle for the integration method (an example would be Melly and Santangelo (2015) who apply it to the Changes-in-Changes model).
3) Are conditional quantile regression coefficients biased?
No (assuming you have a correctly specified model), they just measure something different that you may or may not be interested in. An estimated effect on a distribution rather than individuals is as I said not very interesting - most of the times. To give a counter example: consider a policy maker who introduces an additional year of compulsory schooling and they want to know whether this reduces earnings inequality in the population.
The top two panels show a pure location shift where $\beta_{\tau}$ is a constant at all quantiles, i.e. a constant quantile treatment effect, meaning that if $\beta_{10} = \beta_{90} = 0.8$, an additional year of education increases earnings by 8% across the entire earnings distribution.
When the quantile treatment effect is NOT constant (as in the bottom two panels), you also have a scale effect in addition to the location effect. In this example the bottom of the earnings distribution shifts up by more than the top, so the 90-10 differential (a standard measure of earnings inequality) decreases in the population.
You don't know which individuals benefit from it or in what part of the distribution people are who started out in the bottom (to answer THAT question you need the unconditional quantile regression coefficients). Maybe this policy hurts them and puts them in an even lower part relative to others but if the aim was to know whether an additional year of compulsory education reduces the earnings spread then this is informative. An example of such an approach is Brunello et al. (2009).
If you are still interested in the bias of quantile regressions due to sources of endogeneity have a look at Angrist et al (2006) where they derive an omitted variable bias formula for the quantile context.
|
What is the difference between conditional and unconditional quantile regression?
Set-up
Suppose you have a simple regression of the form
$$\ln y_i = \alpha + \beta S_i + \epsilon_i $$
where the outcome are the log earnings of person $i$, $S_i$ is the number of years of schooling,
|
5,727
|
How do you use the 'test' dataset after cross-validation?
|
This is similar to another question I answered regarding cross-validation and test sets. The key concept to understand here is independent datasets. Consider just two scenarios:
If you have lot's of resources you would ideally collect one dataset and train your model via cross-validation. Then you would collect another completely independent dataset and test your model. However, as I said previously, this is usually not possible for many researchers.
Now, if I am a researcher who isn't so fortunate what do I do? Well, you can try to mimic that exact scenario:
Before you do any model training you would take a split of your data and leave it to the side (never to be touched during cross-validation). This is to simulate that very same independent dataset mentioned in the ideal scenario above. Even though it comes from the same dataset the model training won't take any information from those samples (where with cross-validation all the data is used). Once you have trained your model you would then apply it to your test set, again that was never seen during training, and get your results. This is done to make sure your model is more generalizable and hasn't just learned your data.
To address your other concerns:
Let's say we've got an accuracy of 70% on test data set, so what do we do next? Do we try an other model, and then an other, untill we will get hight score on our test data set?
Sort of, the idea is that you are creating the best model you can from your data and then evaluating it on some more data it has never seen before. You can re-evaluate your cross-validation scheme but once you have a tuned model (i.e. hyper parameters) you are moving forward with that model because it was the best you could make. The key is to NEVER USE YOUR TEST DATA FOR TUNING. Your result from the test data is your model's performance on 'general' data. Replicating this process would remove the independence of the datasets (which was the entire point). This is also address in another question on test/validation data.
And also, how can we consider this score as general evaluation of the model, if it is calculated on a limited data set? If this score is low, maybe we were unlucky to select "bad" test data.
This is unlikely if you have split your data correctly. You should be splitting your data randomly (although potentially stratified for class balancing). If you dataset is large enough that you are splitting your data in to three parts, your test subset should be large enough that the chance is very low that you just chose bad data. It is more likely that your model has been overfit.
|
How do you use the 'test' dataset after cross-validation?
|
This is similar to another question I answered regarding cross-validation and test sets. The key concept to understand here is independent datasets. Consider just two scenarios:
If you have lot's o
|
How do you use the 'test' dataset after cross-validation?
This is similar to another question I answered regarding cross-validation and test sets. The key concept to understand here is independent datasets. Consider just two scenarios:
If you have lot's of resources you would ideally collect one dataset and train your model via cross-validation. Then you would collect another completely independent dataset and test your model. However, as I said previously, this is usually not possible for many researchers.
Now, if I am a researcher who isn't so fortunate what do I do? Well, you can try to mimic that exact scenario:
Before you do any model training you would take a split of your data and leave it to the side (never to be touched during cross-validation). This is to simulate that very same independent dataset mentioned in the ideal scenario above. Even though it comes from the same dataset the model training won't take any information from those samples (where with cross-validation all the data is used). Once you have trained your model you would then apply it to your test set, again that was never seen during training, and get your results. This is done to make sure your model is more generalizable and hasn't just learned your data.
To address your other concerns:
Let's say we've got an accuracy of 70% on test data set, so what do we do next? Do we try an other model, and then an other, untill we will get hight score on our test data set?
Sort of, the idea is that you are creating the best model you can from your data and then evaluating it on some more data it has never seen before. You can re-evaluate your cross-validation scheme but once you have a tuned model (i.e. hyper parameters) you are moving forward with that model because it was the best you could make. The key is to NEVER USE YOUR TEST DATA FOR TUNING. Your result from the test data is your model's performance on 'general' data. Replicating this process would remove the independence of the datasets (which was the entire point). This is also address in another question on test/validation data.
And also, how can we consider this score as general evaluation of the model, if it is calculated on a limited data set? If this score is low, maybe we were unlucky to select "bad" test data.
This is unlikely if you have split your data correctly. You should be splitting your data randomly (although potentially stratified for class balancing). If you dataset is large enough that you are splitting your data in to three parts, your test subset should be large enough that the chance is very low that you just chose bad data. It is more likely that your model has been overfit.
|
How do you use the 'test' dataset after cross-validation?
This is similar to another question I answered regarding cross-validation and test sets. The key concept to understand here is independent datasets. Consider just two scenarios:
If you have lot's o
|
5,728
|
How do you use the 'test' dataset after cross-validation?
|
If all you are going to do is train a model with default settings on the raw or minimally preprocessed dataset (e.g. one-hot encoding and/or removing NAs), you don't need a separate test set, you can simply train on your train set and test on your validation set, or even better, train on the entire set using cross-validation to estimate your performance.
However, as soon as your knowledge about the data causes you to make any changes from your original strategy, you have now "tainted" your result. Some examples include:
Model choice: You tested logistic, lasso, random forest, XGBoost, and support vector machines and choose the best model
Parameter tuning: You tuned an XGBoost to find the optimal hyperparameters
Feature selection: You used backward selection, genetic algorithm, boruta, etc. to choose an optimal subset of features to include in your model
Missing imputation: You imputed missing variables with the mean, or with a simple model based on the other variables
Feature transformation: You centered and scaled your numeric variables to replace them with a z-score (number of standard deviations from the mean)
In all of the above cases, using a single holdout set, or even cross-validation, is not going to give you a realistic estimate of real-world performance because you are using information you won't have on future data in your decision. Instead, you are cherry-picking the best model, the best hyperparameters, the best feature set, etc. for your data, and you are likely to be slightly "overfitting" you strategy to your data. To get an honest estimate of real-world performance, you need to score it on data that didn't enter into the decision process at all, hence the common practice of using an independent test set separate from your training (modeling) and validation (picking a model, features, hyperparameters, etc.) set.
As an alternative to holding out a test set, you can instead use a technique called nested cross-validation. This requires you to code up your entire modeling strategy (transformation, imputation, feature selection, model selection, hyperparameter tuning) as a non-parametric function and then perform cross-validation on that entire function as if it were simply a model fit function. This is difficult to do in most ML packages, but can be implemented quite easily in R with the mlr package by using wrappers to define your training strategy and then resampling your wrapped learner:
https://mlr.mlr-org.com/articles/tutorial/nested_resampling.html
|
How do you use the 'test' dataset after cross-validation?
|
If all you are going to do is train a model with default settings on the raw or minimally preprocessed dataset (e.g. one-hot encoding and/or removing NAs), you don't need a separate test set, you can
|
How do you use the 'test' dataset after cross-validation?
If all you are going to do is train a model with default settings on the raw or minimally preprocessed dataset (e.g. one-hot encoding and/or removing NAs), you don't need a separate test set, you can simply train on your train set and test on your validation set, or even better, train on the entire set using cross-validation to estimate your performance.
However, as soon as your knowledge about the data causes you to make any changes from your original strategy, you have now "tainted" your result. Some examples include:
Model choice: You tested logistic, lasso, random forest, XGBoost, and support vector machines and choose the best model
Parameter tuning: You tuned an XGBoost to find the optimal hyperparameters
Feature selection: You used backward selection, genetic algorithm, boruta, etc. to choose an optimal subset of features to include in your model
Missing imputation: You imputed missing variables with the mean, or with a simple model based on the other variables
Feature transformation: You centered and scaled your numeric variables to replace them with a z-score (number of standard deviations from the mean)
In all of the above cases, using a single holdout set, or even cross-validation, is not going to give you a realistic estimate of real-world performance because you are using information you won't have on future data in your decision. Instead, you are cherry-picking the best model, the best hyperparameters, the best feature set, etc. for your data, and you are likely to be slightly "overfitting" you strategy to your data. To get an honest estimate of real-world performance, you need to score it on data that didn't enter into the decision process at all, hence the common practice of using an independent test set separate from your training (modeling) and validation (picking a model, features, hyperparameters, etc.) set.
As an alternative to holding out a test set, you can instead use a technique called nested cross-validation. This requires you to code up your entire modeling strategy (transformation, imputation, feature selection, model selection, hyperparameter tuning) as a non-parametric function and then perform cross-validation on that entire function as if it were simply a model fit function. This is difficult to do in most ML packages, but can be implemented quite easily in R with the mlr package by using wrappers to define your training strategy and then resampling your wrapped learner:
https://mlr.mlr-org.com/articles/tutorial/nested_resampling.html
|
How do you use the 'test' dataset after cross-validation?
If all you are going to do is train a model with default settings on the raw or minimally preprocessed dataset (e.g. one-hot encoding and/or removing NAs), you don't need a separate test set, you can
|
5,729
|
How do you use the 'test' dataset after cross-validation?
|
I'm assuming that you're doing classification.
Take your data and split it 70/30 into trainingData/ testData subsets. Take the trainingData subset and split it 70/30 again into trainingData/ validateData subsets. Now you have 3 subsets of your original data - trainingData(.7*.7), validateData(.7*.3), and testData(.3).
You train your model with trainingData. Then, you check that model's performance using validateData, which we can think of as independent of trainingData and therefore a good evaluation of how well the model is generalizing. Let's pretend that you achieve 75% accuracy.
Now you retrain your model an arbitrary number of times. Each retraining, you're evaluating a different set of hyperparameters (the parameters being fed to your model in the first place vs those your model is optimizing for) but still using the trainingData subset. Each retraining, you're also again checking how well the new model generalizes by checking performance on validateData.
Once you've checked every combination of hyperparameters you mean to assess, you choose the set of hyperparameters that gave you your best performance on validateData - let's pretend your best performance on validateData was 80% accuracy. These are your final hyperparameters and the model defined by those hyperparameters is the one you'll use for this next step.
Now you take the model that uses your final hyperparameters and evaluate testData. This is the first time testData has been touched since this whole process started! If you get testData performance that's comparable to your performance on validateData (although usually it will be slightly lower), then you can feel confident that your model works as expected and generalizes well! If that happens, this is your final model!
Why do all of this? You're trying to avoid overfitting. There's always a risk that you are overfitting to the data you use when you're training and tuning (aka validating) your model. If you train, tune (validate), and test using just one data set, there's a good chance you'll overfit that data and it won't generalize well. By breaking training and test data sets apart (and assuming you tune using the test data), you have the chance to check yourself internally, but there's still the chance that you're just overfitting the test data now. That's why we break out a third data set, validate, so we have an additional layer of keeping ourselves internally honest. Tuning with validateData keeps us from overfitting to trainingData. Final testing with testData keeps us from overfitting to validateData.
|
How do you use the 'test' dataset after cross-validation?
|
I'm assuming that you're doing classification.
Take your data and split it 70/30 into trainingData/ testData subsets. Take the trainingData subset and split it 70/30 again into trainingData/ validateD
|
How do you use the 'test' dataset after cross-validation?
I'm assuming that you're doing classification.
Take your data and split it 70/30 into trainingData/ testData subsets. Take the trainingData subset and split it 70/30 again into trainingData/ validateData subsets. Now you have 3 subsets of your original data - trainingData(.7*.7), validateData(.7*.3), and testData(.3).
You train your model with trainingData. Then, you check that model's performance using validateData, which we can think of as independent of trainingData and therefore a good evaluation of how well the model is generalizing. Let's pretend that you achieve 75% accuracy.
Now you retrain your model an arbitrary number of times. Each retraining, you're evaluating a different set of hyperparameters (the parameters being fed to your model in the first place vs those your model is optimizing for) but still using the trainingData subset. Each retraining, you're also again checking how well the new model generalizes by checking performance on validateData.
Once you've checked every combination of hyperparameters you mean to assess, you choose the set of hyperparameters that gave you your best performance on validateData - let's pretend your best performance on validateData was 80% accuracy. These are your final hyperparameters and the model defined by those hyperparameters is the one you'll use for this next step.
Now you take the model that uses your final hyperparameters and evaluate testData. This is the first time testData has been touched since this whole process started! If you get testData performance that's comparable to your performance on validateData (although usually it will be slightly lower), then you can feel confident that your model works as expected and generalizes well! If that happens, this is your final model!
Why do all of this? You're trying to avoid overfitting. There's always a risk that you are overfitting to the data you use when you're training and tuning (aka validating) your model. If you train, tune (validate), and test using just one data set, there's a good chance you'll overfit that data and it won't generalize well. By breaking training and test data sets apart (and assuming you tune using the test data), you have the chance to check yourself internally, but there's still the chance that you're just overfitting the test data now. That's why we break out a third data set, validate, so we have an additional layer of keeping ourselves internally honest. Tuning with validateData keeps us from overfitting to trainingData. Final testing with testData keeps us from overfitting to validateData.
|
How do you use the 'test' dataset after cross-validation?
I'm assuming that you're doing classification.
Take your data and split it 70/30 into trainingData/ testData subsets. Take the trainingData subset and split it 70/30 again into trainingData/ validateD
|
5,730
|
How do you use the 'test' dataset after cross-validation?
|
Let us look at it the following way
Common practice
a) Training data - used for choosing model parameters.
i) E.g., finding intercept and slope parameters for an ordinary linear
regression model.
ii) The noise in the training data-set is used in some extent
in over-fitting model parameters.
b) Validation data - used for choosing hyper-parameters.
i) E.g., we may want to test three different models at step 1.a, say
linear model with one, two or three variables.
ii) The validation data-set is independent from training data, and thus, they provide
'unbiased' evaluation to the models, which help to decide which
hyper-parameter to use.
iii) We note that, a model trained in 1.a, say y = b_0+b_1*x_1, does
not learn anything from this data-set. So, the noise in this data-
set is not used to over-fit the parameters (b_0, b_1), but, over-
fit exists in choosing which linear model to use (in terms of
number of variables).
c) Test data - used to get confidence of the output from the above two steps
i) Used once a model is completely trained
Another way to look at part 1
a) Our model candidate pool is a 5-dimenson set, i.e.,
i) Dimension 1: number of variables to keep in the regression model,
e.g., [1, 2, 3].
ii) Dimension 2-5: (b_0, b_1, b_2, b_3).
b) Step 1a reduce model candidates from 5-dimension to 1-dimension.
c) Step 1b reduce model candidates from 1-dimension to 0-dimension, which a single model.
d) However, the OP may think the ‘final’ output above is not performing well
enough on the test data set, and thus redo the whole process again, say
using ridge regression instead of ordinary linear regression. Then the test
data set is used multiple times and thus the noise in this data might
produce some overfitting in deciding whether to use linear regression or
ridge regression.
e) To deal with a high dimensional model pool with parameters, hyperparameters,
model types and pre-processing methods, any split to the data available to
us is essentially defining a decision-making process which
i) Sequentially reducing the model pool to zero-dimension.
ii) Allocating data noise overfitting to different steps of dimension
reductions (overfitting the noise in the data is not avoidable but
could be allocated smartly).
Conclusion and answers to OP’s question
a) Two-split (training and test), three-split (training, validating and
testing) or higher number of split are essentially about reducing
dimensionality and allocating the data (especially noise and risk of over-
fitting).
b) At some stage, you may come up a ‘final’ model candidate pool, and then,
you can think of how to design the process of reducing the dimension
sequentially such that
i) At each step of reducing the dimensions, the output is satisfactory,
e.g., not using just 10 data points with large noise to estimate a
six-parameter liner model.
ii) There are enough data for you to reduce the dimension to zero
finally.
c) What if you cannot achieve b
i) Use model and data insight to reduce the overall dimensionality of
your model pool. E.g., liner regression is sensitive to outliers thus
not good for data with many large outliers.
ii) Choose robust non-parametric models or models with less number of
parameter if possible.
iii) Smartly allocating the data available at each step of reducing the
dimensionality. There is some goodness of fit tests to help us decide
whether the data we use to train the model is enough or not.
|
How do you use the 'test' dataset after cross-validation?
|
Let us look at it the following way
Common practice
a) Training data - used for choosing model parameters.
i) E.g., finding intercept and slope parameters for an ordinary linear
regression mode
|
How do you use the 'test' dataset after cross-validation?
Let us look at it the following way
Common practice
a) Training data - used for choosing model parameters.
i) E.g., finding intercept and slope parameters for an ordinary linear
regression model.
ii) The noise in the training data-set is used in some extent
in over-fitting model parameters.
b) Validation data - used for choosing hyper-parameters.
i) E.g., we may want to test three different models at step 1.a, say
linear model with one, two or three variables.
ii) The validation data-set is independent from training data, and thus, they provide
'unbiased' evaluation to the models, which help to decide which
hyper-parameter to use.
iii) We note that, a model trained in 1.a, say y = b_0+b_1*x_1, does
not learn anything from this data-set. So, the noise in this data-
set is not used to over-fit the parameters (b_0, b_1), but, over-
fit exists in choosing which linear model to use (in terms of
number of variables).
c) Test data - used to get confidence of the output from the above two steps
i) Used once a model is completely trained
Another way to look at part 1
a) Our model candidate pool is a 5-dimenson set, i.e.,
i) Dimension 1: number of variables to keep in the regression model,
e.g., [1, 2, 3].
ii) Dimension 2-5: (b_0, b_1, b_2, b_3).
b) Step 1a reduce model candidates from 5-dimension to 1-dimension.
c) Step 1b reduce model candidates from 1-dimension to 0-dimension, which a single model.
d) However, the OP may think the ‘final’ output above is not performing well
enough on the test data set, and thus redo the whole process again, say
using ridge regression instead of ordinary linear regression. Then the test
data set is used multiple times and thus the noise in this data might
produce some overfitting in deciding whether to use linear regression or
ridge regression.
e) To deal with a high dimensional model pool with parameters, hyperparameters,
model types and pre-processing methods, any split to the data available to
us is essentially defining a decision-making process which
i) Sequentially reducing the model pool to zero-dimension.
ii) Allocating data noise overfitting to different steps of dimension
reductions (overfitting the noise in the data is not avoidable but
could be allocated smartly).
Conclusion and answers to OP’s question
a) Two-split (training and test), three-split (training, validating and
testing) or higher number of split are essentially about reducing
dimensionality and allocating the data (especially noise and risk of over-
fitting).
b) At some stage, you may come up a ‘final’ model candidate pool, and then,
you can think of how to design the process of reducing the dimension
sequentially such that
i) At each step of reducing the dimensions, the output is satisfactory,
e.g., not using just 10 data points with large noise to estimate a
six-parameter liner model.
ii) There are enough data for you to reduce the dimension to zero
finally.
c) What if you cannot achieve b
i) Use model and data insight to reduce the overall dimensionality of
your model pool. E.g., liner regression is sensitive to outliers thus
not good for data with many large outliers.
ii) Choose robust non-parametric models or models with less number of
parameter if possible.
iii) Smartly allocating the data available at each step of reducing the
dimensionality. There is some goodness of fit tests to help us decide
whether the data we use to train the model is enough or not.
|
How do you use the 'test' dataset after cross-validation?
Let us look at it the following way
Common practice
a) Training data - used for choosing model parameters.
i) E.g., finding intercept and slope parameters for an ordinary linear
regression mode
|
5,731
|
Does down-sampling change logistic regression coefficients?
|
Down-sampling is equivalent to case–control designs in medical statistics—you're fixing the counts of responses & observing the covariate patterns (predictors). Perhaps the key reference is Prentice & Pyke (1979), "Logistic Disease Incidence Models and Case–Control Studies", Biometrika, 66, 3.
They used Bayes' Theorem to rewrite each term in the likelihood for the probability of a given covariate pattern conditional on being a case or control as two factors; one representing an ordinary logistic regression (probability of being a case or control conditional on a covariate pattern), & the other representing the marginal probability of the covariate pattern. They showed that maximizing the overall likelihood subject to the constraint that the marginal probabilities of being a case or control are fixed by the sampling scheme gives the same odds ratio estimates as maximizing the first factor without a constraint (i.e. carrying out an ordinary logistic regression).
The intercept for the population $\beta_0^*$ can be estimated from the case–control intercept $\hat{\beta}_0$ if the population prevalence $\pi$ is known:
$$ \hat{\beta}_0^* = \hat{\beta}_0 - \log\left( \frac{1-\pi}{\pi}\cdot \frac{n_1}{n_0}\right)$$
where $n_0$ & $n_1$ are the number of controls & cases sampled, respectively.
Of course by throwing away data you've gone to the trouble of collecting, albeit the least useful part, you're reducing the precision of your estimates. Constraints on computational resources are the only good reason I know of for doing this, but I mention it because some people seem to think that "a balanced data-set" is important for some other reason I've never been able to ascertain.
|
Does down-sampling change logistic regression coefficients?
|
Down-sampling is equivalent to case–control designs in medical statistics—you're fixing the counts of responses & observing the covariate patterns (predictors). Perhaps the key reference is Prentice &
|
Does down-sampling change logistic regression coefficients?
Down-sampling is equivalent to case–control designs in medical statistics—you're fixing the counts of responses & observing the covariate patterns (predictors). Perhaps the key reference is Prentice & Pyke (1979), "Logistic Disease Incidence Models and Case–Control Studies", Biometrika, 66, 3.
They used Bayes' Theorem to rewrite each term in the likelihood for the probability of a given covariate pattern conditional on being a case or control as two factors; one representing an ordinary logistic regression (probability of being a case or control conditional on a covariate pattern), & the other representing the marginal probability of the covariate pattern. They showed that maximizing the overall likelihood subject to the constraint that the marginal probabilities of being a case or control are fixed by the sampling scheme gives the same odds ratio estimates as maximizing the first factor without a constraint (i.e. carrying out an ordinary logistic regression).
The intercept for the population $\beta_0^*$ can be estimated from the case–control intercept $\hat{\beta}_0$ if the population prevalence $\pi$ is known:
$$ \hat{\beta}_0^* = \hat{\beta}_0 - \log\left( \frac{1-\pi}{\pi}\cdot \frac{n_1}{n_0}\right)$$
where $n_0$ & $n_1$ are the number of controls & cases sampled, respectively.
Of course by throwing away data you've gone to the trouble of collecting, albeit the least useful part, you're reducing the precision of your estimates. Constraints on computational resources are the only good reason I know of for doing this, but I mention it because some people seem to think that "a balanced data-set" is important for some other reason I've never been able to ascertain.
|
Does down-sampling change logistic regression coefficients?
Down-sampling is equivalent to case–control designs in medical statistics—you're fixing the counts of responses & observing the covariate patterns (predictors). Perhaps the key reference is Prentice &
|
5,732
|
what does the numbers in the classification report of sklearn mean?
|
The f1-score gives you the harmonic mean of precision and recall. The scores corresponding to every class will tell you the accuracy of the classifier in classifying the data points in that particular class compared to all other classes.
The support is the number of samples of the true response that lie in that class.
You can find documentation on both measures in the sklearn documentation.
Support - http://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_recall_fscore_support.html
F1-score - http://scikit-learn.org/stable/modules/generated/sklearn.metrics.f1_score.html
EDIT
The last line gives a weighted average of precision, recall and f1-score where the weights are the support values. so for precision the avg is (0.50*1 + 0.0*1 + 1.0*3)/5 = 0.70. The total is just for total support which is 5 here.
|
what does the numbers in the classification report of sklearn mean?
|
The f1-score gives you the harmonic mean of precision and recall. The scores corresponding to every class will tell you the accuracy of the classifier in classifying the data points in that particular
|
what does the numbers in the classification report of sklearn mean?
The f1-score gives you the harmonic mean of precision and recall. The scores corresponding to every class will tell you the accuracy of the classifier in classifying the data points in that particular class compared to all other classes.
The support is the number of samples of the true response that lie in that class.
You can find documentation on both measures in the sklearn documentation.
Support - http://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_recall_fscore_support.html
F1-score - http://scikit-learn.org/stable/modules/generated/sklearn.metrics.f1_score.html
EDIT
The last line gives a weighted average of precision, recall and f1-score where the weights are the support values. so for precision the avg is (0.50*1 + 0.0*1 + 1.0*3)/5 = 0.70. The total is just for total support which is 5 here.
|
what does the numbers in the classification report of sklearn mean?
The f1-score gives you the harmonic mean of precision and recall. The scores corresponding to every class will tell you the accuracy of the classifier in classifying the data points in that particular
|
5,733
|
Can somebody explain to me NUTS in english?
|
The no U-turn bit is how proposals are generated. HMC generates a hypothetical physical system: imagine a ball with a certain kinetic energy rolling around a landscape with valleys and hills (the analogy breaks down with more than 2 dimensions) defined by the posterior you want to sample from. Every time you want to take a new MCMC sample, you randomly pick the kinetic energy and start the ball rolling from where you are. You simulate in discrete time steps, and to make sure you explore the parameter space properly you simulate steps in one direction and the twice as many in the other direction, turn around again etc. At some point you want to stop this and a good way of doing that is when you have done a U-turn (i.e. appear to have gone all over the place).
At this point the proposed next step of your Markov Chain gets picked (with certain limitations) from the points you have visited. I.e. that whole simulation of the hypothetical physical system was "just" to get a proposal that then gets accepted (the next MCMC sample is the proposed point) or rejected (the next MCMC sample is the starting point).
The clever thing about it is that proposals are made based on the shape of the posterior and can be at the other end of the distribution. In contrast Metropolis-Hastings makes proposals within a (possibly skewed) ball, Gibbs sampling only moves along one (or at least very few) dimensions at a time.
|
Can somebody explain to me NUTS in english?
|
The no U-turn bit is how proposals are generated. HMC generates a hypothetical physical system: imagine a ball with a certain kinetic energy rolling around a landscape with valleys and hills (the ana
|
Can somebody explain to me NUTS in english?
The no U-turn bit is how proposals are generated. HMC generates a hypothetical physical system: imagine a ball with a certain kinetic energy rolling around a landscape with valleys and hills (the analogy breaks down with more than 2 dimensions) defined by the posterior you want to sample from. Every time you want to take a new MCMC sample, you randomly pick the kinetic energy and start the ball rolling from where you are. You simulate in discrete time steps, and to make sure you explore the parameter space properly you simulate steps in one direction and the twice as many in the other direction, turn around again etc. At some point you want to stop this and a good way of doing that is when you have done a U-turn (i.e. appear to have gone all over the place).
At this point the proposed next step of your Markov Chain gets picked (with certain limitations) from the points you have visited. I.e. that whole simulation of the hypothetical physical system was "just" to get a proposal that then gets accepted (the next MCMC sample is the proposed point) or rejected (the next MCMC sample is the starting point).
The clever thing about it is that proposals are made based on the shape of the posterior and can be at the other end of the distribution. In contrast Metropolis-Hastings makes proposals within a (possibly skewed) ball, Gibbs sampling only moves along one (or at least very few) dimensions at a time.
|
Can somebody explain to me NUTS in english?
The no U-turn bit is how proposals are generated. HMC generates a hypothetical physical system: imagine a ball with a certain kinetic energy rolling around a landscape with valleys and hills (the ana
|
5,734
|
Can somebody explain to me NUTS in english?
|
You're incorrect that HMC is not a Markov Chain method. Per Wikipedia:
In mathematics and physics, the hybrid Monte Carlo algorithm, also known as Hamiltonian Monte Carlo, is a Markov chain Monte Carlo method for obtaining a sequence of random samples from a probability distribution for which direct sampling is difficult. This sequence can be used to approximate the distribution (i.e., to generate a histogram), or to compute an integral (such as an expected value).
For more clarity, read the arXiv paper by Betancourt, which mentions the NUTS terminating criteria:
... identify when a trajectory is long enough to yield sufficient exploration of the neighborhood around the current energy level set. In particular, we want to avoid both integrating too short, in which case we would not take full advantage of the Hamiltonian trajectories, and integrating too long, in which case we waste precious computational resources on exploration that yields only diminishing returns.
Appendix A.3 talks about something like the trajectory doubling you mention:
We can also expand faster by doubling the length of the trajectory at every iteration, yielding a sampled trajectory t ∼ T(t | z) = U T2L with the corresponding sampled state z′ ∼ T(z′ | t). In this case both the old and new trajectory components at every iteration are equivalent to the leaves of perfect, ordered binary trees (Figure 37). This allows us to build the new trajectory components recursively, propagating a sample at each step in the recursion...
and expands on this in A.4, where it talks about a dynamic implementation (section A.3 talks about a static implementation):
Fortunately, the efficient static schemes discussed in Section A.3 can be iterated to achieve a dynamic implementation once we have chosen a criterion for determining when a trajectory has grown long enough to satisfactory explore the corresponding energy level set.
I think the key is that it doesn't do jumps that double, it calculates its next jump using a technique that doubles the proposed jump's length until a criteria is met. At least that's how I understand the paper so far.
|
Can somebody explain to me NUTS in english?
|
You're incorrect that HMC is not a Markov Chain method. Per Wikipedia:
In mathematics and physics, the hybrid Monte Carlo algorithm, also known as Hamiltonian Monte Carlo, is a Markov chain Monte Car
|
Can somebody explain to me NUTS in english?
You're incorrect that HMC is not a Markov Chain method. Per Wikipedia:
In mathematics and physics, the hybrid Monte Carlo algorithm, also known as Hamiltonian Monte Carlo, is a Markov chain Monte Carlo method for obtaining a sequence of random samples from a probability distribution for which direct sampling is difficult. This sequence can be used to approximate the distribution (i.e., to generate a histogram), or to compute an integral (such as an expected value).
For more clarity, read the arXiv paper by Betancourt, which mentions the NUTS terminating criteria:
... identify when a trajectory is long enough to yield sufficient exploration of the neighborhood around the current energy level set. In particular, we want to avoid both integrating too short, in which case we would not take full advantage of the Hamiltonian trajectories, and integrating too long, in which case we waste precious computational resources on exploration that yields only diminishing returns.
Appendix A.3 talks about something like the trajectory doubling you mention:
We can also expand faster by doubling the length of the trajectory at every iteration, yielding a sampled trajectory t ∼ T(t | z) = U T2L with the corresponding sampled state z′ ∼ T(z′ | t). In this case both the old and new trajectory components at every iteration are equivalent to the leaves of perfect, ordered binary trees (Figure 37). This allows us to build the new trajectory components recursively, propagating a sample at each step in the recursion...
and expands on this in A.4, where it talks about a dynamic implementation (section A.3 talks about a static implementation):
Fortunately, the efficient static schemes discussed in Section A.3 can be iterated to achieve a dynamic implementation once we have chosen a criterion for determining when a trajectory has grown long enough to satisfactory explore the corresponding energy level set.
I think the key is that it doesn't do jumps that double, it calculates its next jump using a technique that doubles the proposed jump's length until a criteria is met. At least that's how I understand the paper so far.
|
Can somebody explain to me NUTS in english?
You're incorrect that HMC is not a Markov Chain method. Per Wikipedia:
In mathematics and physics, the hybrid Monte Carlo algorithm, also known as Hamiltonian Monte Carlo, is a Markov chain Monte Car
|
5,735
|
Is it OK to remove outliers from data?
|
One option is to exclude outliers, but IMHO that is something you should only do if you can argue (with almost certainty) why such points are invalid (e.g. measurement equipment broke down, measurement method was unreliable for some reason, ...).
E.g. in frequency domain measurements, DC is often discarded since many different terms contribute to DC, quite often unrelated to the phenomenon you are trying to observe.
The problem with removing outliers, is that to determine which points are outliers, you need to have a good model of what is or is not "good data". If you are unsure about the model (which factors should be included, what structure does the model have, what are the assumptions of the noise, ...), then you cannot be sure about your outliers. Those outliers might just be samples that are trying to tell you that your model is wrong. In other words: removing outliers will reinforce your (incorrect!) model, instead of allowing you to obtain new insights!
Another option, is to use robust statistics. E.g. the mean and standard deviation are sensitive to outliers, other metrics of "location" and "spread" are more robust. E.g. instead of the mean, use the median. Instead of standard deviation, use inter-quartile range. Instead of standard least-squares regression, you could use robust regression. All those robust methods de-emphasize the outliers in one way or another, but they typically do not remove the outlier data completely (i.e. a good thing).
|
Is it OK to remove outliers from data?
|
One option is to exclude outliers, but IMHO that is something you should only do if you can argue (with almost certainty) why such points are invalid (e.g. measurement equipment broke down, measuremen
|
Is it OK to remove outliers from data?
One option is to exclude outliers, but IMHO that is something you should only do if you can argue (with almost certainty) why such points are invalid (e.g. measurement equipment broke down, measurement method was unreliable for some reason, ...).
E.g. in frequency domain measurements, DC is often discarded since many different terms contribute to DC, quite often unrelated to the phenomenon you are trying to observe.
The problem with removing outliers, is that to determine which points are outliers, you need to have a good model of what is or is not "good data". If you are unsure about the model (which factors should be included, what structure does the model have, what are the assumptions of the noise, ...), then you cannot be sure about your outliers. Those outliers might just be samples that are trying to tell you that your model is wrong. In other words: removing outliers will reinforce your (incorrect!) model, instead of allowing you to obtain new insights!
Another option, is to use robust statistics. E.g. the mean and standard deviation are sensitive to outliers, other metrics of "location" and "spread" are more robust. E.g. instead of the mean, use the median. Instead of standard deviation, use inter-quartile range. Instead of standard least-squares regression, you could use robust regression. All those robust methods de-emphasize the outliers in one way or another, but they typically do not remove the outlier data completely (i.e. a good thing).
|
Is it OK to remove outliers from data?
One option is to exclude outliers, but IMHO that is something you should only do if you can argue (with almost certainty) why such points are invalid (e.g. measurement equipment broke down, measuremen
|
5,736
|
Is it OK to remove outliers from data?
|
I do not recommend excluding any outlier in the main analysis (unless you are really positive they are mistaken). You can do it in a sensitivity analysis, though, and compare the results of the two analyses. In science, often you discover new stuff precisely when focusing on such outliers.
To further elaborate, just think about the seminal Fleming's discovery of penicillin, based on the accidental contamination of his experiments with a mold:
http://www.abpischools.org.uk/page/modules/infectiousdiseases_timeline/timeline6.cfm?coSiteNavigation_allTopic=1
Looking at the near past or present, outlier detection is often used to guide innovation in biomedical sciences. See for instance the following articles (with some suitable R codes):
http://www.la-press.com/a-comparison-of-methods-for-data-driven-cancer-outlier-discovery-and-a-article-a2599-abstract?article_id=2599
http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3394880/
http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0102678
Finally, if you have reasonable grounds to exclude some data, you may do it, preferably in a sensitivity analysis, and not in the primary one. For instance you could exclude all values which are not biologically plausible (such as a temperature of 48 degrees Celsius in a septic patient). Similarly, you could exclude all first and last measurements for any given patient, to minimize movement artifacts. Take notice however that if you do this post-hoc (not based on a pre-specified criteria), this risks amounting to data massaging.
|
Is it OK to remove outliers from data?
|
I do not recommend excluding any outlier in the main analysis (unless you are really positive they are mistaken). You can do it in a sensitivity analysis, though, and compare the results of the two an
|
Is it OK to remove outliers from data?
I do not recommend excluding any outlier in the main analysis (unless you are really positive they are mistaken). You can do it in a sensitivity analysis, though, and compare the results of the two analyses. In science, often you discover new stuff precisely when focusing on such outliers.
To further elaborate, just think about the seminal Fleming's discovery of penicillin, based on the accidental contamination of his experiments with a mold:
http://www.abpischools.org.uk/page/modules/infectiousdiseases_timeline/timeline6.cfm?coSiteNavigation_allTopic=1
Looking at the near past or present, outlier detection is often used to guide innovation in biomedical sciences. See for instance the following articles (with some suitable R codes):
http://www.la-press.com/a-comparison-of-methods-for-data-driven-cancer-outlier-discovery-and-a-article-a2599-abstract?article_id=2599
http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3394880/
http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0102678
Finally, if you have reasonable grounds to exclude some data, you may do it, preferably in a sensitivity analysis, and not in the primary one. For instance you could exclude all values which are not biologically plausible (such as a temperature of 48 degrees Celsius in a septic patient). Similarly, you could exclude all first and last measurements for any given patient, to minimize movement artifacts. Take notice however that if you do this post-hoc (not based on a pre-specified criteria), this risks amounting to data massaging.
|
Is it OK to remove outliers from data?
I do not recommend excluding any outlier in the main analysis (unless you are really positive they are mistaken). You can do it in a sensitivity analysis, though, and compare the results of the two an
|
5,737
|
Is it OK to remove outliers from data?
|
Thought I'd add a cautionary tale about removing outliers:
Remember the problem with the hole in the polar ozone layer? There was a satellite that was put in orbit over the pole specifically to measure ozone concentration. For a few years the post-processed data from the satellite reported that the polar ozone was present at normal levels, even though other sources clearly showed that the ozone was missing. Finally someone went back to check the satellite software. It turned out that someone had written the code to check if the raw measurement was within an expected range about the typical historical level, and to assume that any measurement outside the range was just an instrument 'spike' (i.e an outlier), auto-correcting the value. Fortunately they had also recorded the raw measurements; on checking them they saw that the hole had been reported all along.
|
Is it OK to remove outliers from data?
|
Thought I'd add a cautionary tale about removing outliers:
Remember the problem with the hole in the polar ozone layer? There was a satellite that was put in orbit over the pole specifically to measu
|
Is it OK to remove outliers from data?
Thought I'd add a cautionary tale about removing outliers:
Remember the problem with the hole in the polar ozone layer? There was a satellite that was put in orbit over the pole specifically to measure ozone concentration. For a few years the post-processed data from the satellite reported that the polar ozone was present at normal levels, even though other sources clearly showed that the ozone was missing. Finally someone went back to check the satellite software. It turned out that someone had written the code to check if the raw measurement was within an expected range about the typical historical level, and to assume that any measurement outside the range was just an instrument 'spike' (i.e an outlier), auto-correcting the value. Fortunately they had also recorded the raw measurements; on checking them they saw that the hole had been reported all along.
|
Is it OK to remove outliers from data?
Thought I'd add a cautionary tale about removing outliers:
Remember the problem with the hole in the polar ozone layer? There was a satellite that was put in orbit over the pole specifically to measu
|
5,738
|
Is it OK to remove outliers from data?
|
'Outlier' is a convenient term for collecting data together that doesn't fit what you expect your process to look like, in order to remove from the analysis.
I would suggest never (caveat later) removing outliers. My background is statistical process control, so often deal with large volumes of automatically generated time-series data which is processed using a run chart / moving box plot / etc. depending on the data and distribution.
The thing with outliers is that they will always provide information about your 'process'. Often what you are thinking of as one process is actually many processes and it is far more complex than you give it credit for.
Using the example in your question, I would suggest there could be a number of 'processes'. there will be variation due to ...
samples taken by one conductance device
samples taken between conductance devices
when the subject removed a probe
when the subject moved
differences within one subject's skin across their body or between different sampling days (hair, moisture, oil, etc)
differences between subjects
the training of the person taking the measurements and variations between staff
All of these processes will produce extra variation in the data and will probably move the mean and change the shape of the distribution. Many of these you won't be able to separate into distinct processes.
So going to the idea of removing data points as 'outliers' ... I would only remove data points, when I can definitely attribute them to a particular 'process' that I want to not include in my analysis. You then need to ensure that the reasons for non inclusion are recorded as part of your analysis, so it is obvious. Don't assume attribution, that's the key thing about taking extra notes through observation during your data collection.
I would challenge your statement 'because most of them are errors anyway', as they are not errors, but just part of a different process that you have identified within your measurements as being different.
In your example, I think it is reasonable to exclude data points that you can attribute to a separate process that you don't want to analyse.
|
Is it OK to remove outliers from data?
|
'Outlier' is a convenient term for collecting data together that doesn't fit what you expect your process to look like, in order to remove from the analysis.
I would suggest never (caveat later) remo
|
Is it OK to remove outliers from data?
'Outlier' is a convenient term for collecting data together that doesn't fit what you expect your process to look like, in order to remove from the analysis.
I would suggest never (caveat later) removing outliers. My background is statistical process control, so often deal with large volumes of automatically generated time-series data which is processed using a run chart / moving box plot / etc. depending on the data and distribution.
The thing with outliers is that they will always provide information about your 'process'. Often what you are thinking of as one process is actually many processes and it is far more complex than you give it credit for.
Using the example in your question, I would suggest there could be a number of 'processes'. there will be variation due to ...
samples taken by one conductance device
samples taken between conductance devices
when the subject removed a probe
when the subject moved
differences within one subject's skin across their body or between different sampling days (hair, moisture, oil, etc)
differences between subjects
the training of the person taking the measurements and variations between staff
All of these processes will produce extra variation in the data and will probably move the mean and change the shape of the distribution. Many of these you won't be able to separate into distinct processes.
So going to the idea of removing data points as 'outliers' ... I would only remove data points, when I can definitely attribute them to a particular 'process' that I want to not include in my analysis. You then need to ensure that the reasons for non inclusion are recorded as part of your analysis, so it is obvious. Don't assume attribution, that's the key thing about taking extra notes through observation during your data collection.
I would challenge your statement 'because most of them are errors anyway', as they are not errors, but just part of a different process that you have identified within your measurements as being different.
In your example, I think it is reasonable to exclude data points that you can attribute to a separate process that you don't want to analyse.
|
Is it OK to remove outliers from data?
'Outlier' is a convenient term for collecting data together that doesn't fit what you expect your process to look like, in order to remove from the analysis.
I would suggest never (caveat later) remo
|
5,739
|
Is it OK to remove outliers from data?
|
If you are removing outliers the, in most situations you need to document that you're doing so and why. If this is for a scientific paper, or for regulatory purposes, this could result in having your final statistics discounted and/or rejected.
The better solution is to identify when you think you're getting bad data (e.g. when people pull wires), then identify when people are pulling wires, and pull the data for that reason. This will probably also result in some 'good' data points being dropped, but you now have a 'real' reason to tag and discount those data points at the collection end rather than at the analysis end. As long as you do that cleanly and transparently, it's far more likely to be acceptable to third parties.
If you remove data points related to pulled wires, and you still get outliers, then the probable conclusion is that the pulled wires are not the (only) problem -- the further problem could be with your experiment design, or your theory.
One of the first experiments my mom had when returning to university to finish her BSc was one where students were given a 'bad' theory about how a process worked, and then told to run an experiment. Students who deleted or modified the resulting 'bad' data points failed the assignment. Those who correctly reported that their data was in disagreement with the results predicted by (the bad) theory, passed.
The point of the assignment was to teach students not to 'fix' (falsify) their data when it wasn't what was expected.
Summary: if you're generating bad data, then fix your experiment (or your theory), not the data.
|
Is it OK to remove outliers from data?
|
If you are removing outliers the, in most situations you need to document that you're doing so and why. If this is for a scientific paper, or for regulatory purposes, this could result in having your
|
Is it OK to remove outliers from data?
If you are removing outliers the, in most situations you need to document that you're doing so and why. If this is for a scientific paper, or for regulatory purposes, this could result in having your final statistics discounted and/or rejected.
The better solution is to identify when you think you're getting bad data (e.g. when people pull wires), then identify when people are pulling wires, and pull the data for that reason. This will probably also result in some 'good' data points being dropped, but you now have a 'real' reason to tag and discount those data points at the collection end rather than at the analysis end. As long as you do that cleanly and transparently, it's far more likely to be acceptable to third parties.
If you remove data points related to pulled wires, and you still get outliers, then the probable conclusion is that the pulled wires are not the (only) problem -- the further problem could be with your experiment design, or your theory.
One of the first experiments my mom had when returning to university to finish her BSc was one where students were given a 'bad' theory about how a process worked, and then told to run an experiment. Students who deleted or modified the resulting 'bad' data points failed the assignment. Those who correctly reported that their data was in disagreement with the results predicted by (the bad) theory, passed.
The point of the assignment was to teach students not to 'fix' (falsify) their data when it wasn't what was expected.
Summary: if you're generating bad data, then fix your experiment (or your theory), not the data.
|
Is it OK to remove outliers from data?
If you are removing outliers the, in most situations you need to document that you're doing so and why. If this is for a scientific paper, or for regulatory purposes, this could result in having your
|
5,740
|
Is it OK to remove outliers from data?
|
It's a moral dilemma for sure. On one hand, why should you let a few suspicious data points ruin your model's fit to the bulk of the data? On the other hand, deleting observations that don't agree with your model's concept of reality is a censorship of sorts. To @Egon's point, those outliers could be trying to tell you something about that reality.
In a presentation from statistician Steve MacEachern, he defined outliers as being "[not representative of the phenomenon under study.]" Under that viewpoint, if you feel that these suspicious data points are not representative of the skin conductance phenomenon you are trying to study, maybe they don't belong in the analysis. Or if they're allowed to stay, a method should be used that limits their influence. In that same presentation MacEachern gave examples of robust methods, and I remember that, in those few examples, the classical methods with the outliers removed always agreed with the robust analyses with the outliers still included. Personally, I tend to work with the classical techniques I'm most comfortable with and live with the moral uncertainty of outlier deletion.
|
Is it OK to remove outliers from data?
|
It's a moral dilemma for sure. On one hand, why should you let a few suspicious data points ruin your model's fit to the bulk of the data? On the other hand, deleting observations that don't agree wit
|
Is it OK to remove outliers from data?
It's a moral dilemma for sure. On one hand, why should you let a few suspicious data points ruin your model's fit to the bulk of the data? On the other hand, deleting observations that don't agree with your model's concept of reality is a censorship of sorts. To @Egon's point, those outliers could be trying to tell you something about that reality.
In a presentation from statistician Steve MacEachern, he defined outliers as being "[not representative of the phenomenon under study.]" Under that viewpoint, if you feel that these suspicious data points are not representative of the skin conductance phenomenon you are trying to study, maybe they don't belong in the analysis. Or if they're allowed to stay, a method should be used that limits their influence. In that same presentation MacEachern gave examples of robust methods, and I remember that, in those few examples, the classical methods with the outliers removed always agreed with the robust analyses with the outliers still included. Personally, I tend to work with the classical techniques I'm most comfortable with and live with the moral uncertainty of outlier deletion.
|
Is it OK to remove outliers from data?
It's a moral dilemma for sure. On one hand, why should you let a few suspicious data points ruin your model's fit to the bulk of the data? On the other hand, deleting observations that don't agree wit
|
5,741
|
Is it OK to remove outliers from data?
|
My answer aligns with the majority: Do not remove outliers unless you are certain they are erroneous. What I add is:
A brief overview of published papers on this topic (those that I am aware of and primarily those published in psychology. There are many more).
Based on that, an answer to the question: What method can be used instead of removing outliers when one knows that there are many incorrect data points but not which ones are incorrect?
Overview
It is well-documented that the removal of outliers invalidates statistical results. Wilcox 1998 states: "This approach fails [removing outliers before a standard analysis] because it results in using the wrong standard error. Briefly, if extreme values are thrown out, the remaining observations are no longer independent, so conventional methods for deriving expressions for standard errors no longer apply." For a more detailed explanation, see the paper. Bakker et al. (2014) demonstrated one of the effects of this: substantially inflated type I error rates. Recently, Andre (2022) argued that this is only a problem when the model/hypothesis is considered for removing outliers. To provide a concrete example: He stated that while removing outliers within a group is problematic due to the invalid standard errors, removing outliers across groups is valid. More recently, Karch (2023)(disclaimer: that's me) demonstrated that removing outliers across groups is equally problematic: Among other things, if there are group differences, it almost always invalidates confidence intervals and parameter estimates.
What can be used with noisy data?
All the papers cited so far recommend robust methods for handling noisy data (as suggested in some answers). Importantly, contrary to what is claimed in other answers, robust methods do not always yield the same results as outlier removal + standard methods. Briefly, robust methods use the correct standard errors, while outlier removal + standard methods do not (refer to Wilcox for details).
For the situation the original question asks about (comparing two groups), either the Yuen-Welch test or the Brunner-Munzel test and their corresponding confidence intervals seem like they could be applicable. The Yuen-Welch test is essentially the robust version of Welch's t-test. It's important to note that it considers trimmed means instead of normal means, which can be very different for asymmetric distributions (see example by AdamO). Brunner-Munzel's test is essentially the robust alternative to the Wilcoxon-Mann-Whitney test (see https://stats.stackexchange.com/a/579604/30495). Both tests are readily available in R (see https://rdrr.io/cran/WRS2/man/yuen.html, and https://cran.r-project.org/web/packages/brunnermunzel/index.html)
|
Is it OK to remove outliers from data?
|
My answer aligns with the majority: Do not remove outliers unless you are certain they are erroneous. What I add is:
A brief overview of published papers on this topic (those that I am aware of and p
|
Is it OK to remove outliers from data?
My answer aligns with the majority: Do not remove outliers unless you are certain they are erroneous. What I add is:
A brief overview of published papers on this topic (those that I am aware of and primarily those published in psychology. There are many more).
Based on that, an answer to the question: What method can be used instead of removing outliers when one knows that there are many incorrect data points but not which ones are incorrect?
Overview
It is well-documented that the removal of outliers invalidates statistical results. Wilcox 1998 states: "This approach fails [removing outliers before a standard analysis] because it results in using the wrong standard error. Briefly, if extreme values are thrown out, the remaining observations are no longer independent, so conventional methods for deriving expressions for standard errors no longer apply." For a more detailed explanation, see the paper. Bakker et al. (2014) demonstrated one of the effects of this: substantially inflated type I error rates. Recently, Andre (2022) argued that this is only a problem when the model/hypothesis is considered for removing outliers. To provide a concrete example: He stated that while removing outliers within a group is problematic due to the invalid standard errors, removing outliers across groups is valid. More recently, Karch (2023)(disclaimer: that's me) demonstrated that removing outliers across groups is equally problematic: Among other things, if there are group differences, it almost always invalidates confidence intervals and parameter estimates.
What can be used with noisy data?
All the papers cited so far recommend robust methods for handling noisy data (as suggested in some answers). Importantly, contrary to what is claimed in other answers, robust methods do not always yield the same results as outlier removal + standard methods. Briefly, robust methods use the correct standard errors, while outlier removal + standard methods do not (refer to Wilcox for details).
For the situation the original question asks about (comparing two groups), either the Yuen-Welch test or the Brunner-Munzel test and their corresponding confidence intervals seem like they could be applicable. The Yuen-Welch test is essentially the robust version of Welch's t-test. It's important to note that it considers trimmed means instead of normal means, which can be very different for asymmetric distributions (see example by AdamO). Brunner-Munzel's test is essentially the robust alternative to the Wilcoxon-Mann-Whitney test (see https://stats.stackexchange.com/a/579604/30495). Both tests are readily available in R (see https://rdrr.io/cran/WRS2/man/yuen.html, and https://cran.r-project.org/web/packages/brunnermunzel/index.html)
|
Is it OK to remove outliers from data?
My answer aligns with the majority: Do not remove outliers unless you are certain they are erroneous. What I add is:
A brief overview of published papers on this topic (those that I am aware of and p
|
5,742
|
Is it OK to remove outliers from data?
|
If I conduct a random sample of 100 people, and one of those people happens to be Bill Gates, then as far as I can tell, Bill Gates is representative of 1/100th of the population.
A trimmed mean tells me the average lottery earnings is $0.
|
Is it OK to remove outliers from data?
|
If I conduct a random sample of 100 people, and one of those people happens to be Bill Gates, then as far as I can tell, Bill Gates is representative of 1/100th of the population.
A trimmed mean tell
|
Is it OK to remove outliers from data?
If I conduct a random sample of 100 people, and one of those people happens to be Bill Gates, then as far as I can tell, Bill Gates is representative of 1/100th of the population.
A trimmed mean tells me the average lottery earnings is $0.
|
Is it OK to remove outliers from data?
If I conduct a random sample of 100 people, and one of those people happens to be Bill Gates, then as far as I can tell, Bill Gates is representative of 1/100th of the population.
A trimmed mean tell
|
5,743
|
Is it OK to remove outliers from data?
|
Of course you should remove the outliers, as by definition they do not follow the distribution under scrutiny and are a parasitic phenomenon.
The real question is "how can I reliably detect the outliers" !
|
Is it OK to remove outliers from data?
|
Of course you should remove the outliers, as by definition they do not follow the distribution under scrutiny and are a parasitic phenomenon.
The real question is "how can I reliably detect the outlie
|
Is it OK to remove outliers from data?
Of course you should remove the outliers, as by definition they do not follow the distribution under scrutiny and are a parasitic phenomenon.
The real question is "how can I reliably detect the outliers" !
|
Is it OK to remove outliers from data?
Of course you should remove the outliers, as by definition they do not follow the distribution under scrutiny and are a parasitic phenomenon.
The real question is "how can I reliably detect the outlie
|
5,744
|
What exactly is Big Data?
|
I had the pleasure of attending a lecture given by Dr. Hadley Wickham, of RStudio fame. He defined it such that
Big Data: Can't fit in memory on one computer: > 1 TB
Medium Data: Fits in memory on a server: 10 GB - 1 TB
Small Data: Fits in memory on a laptop: < 10 GB
Hadley also believes that most data can at least be reduced to managable problems, and that a very small amount is actually true big data. He denotes this as the "Big Data Mirage".
90% Can be reduced to a small/ medium data problem with subsetting/sampling/summarising
9% Can be reduced to a very large number of small data problems
1% Is irreducibly big
Slides can be found here.
|
What exactly is Big Data?
|
I had the pleasure of attending a lecture given by Dr. Hadley Wickham, of RStudio fame. He defined it such that
Big Data: Can't fit in memory on one computer: > 1 TB
Medium Data: Fits in memory on a
|
What exactly is Big Data?
I had the pleasure of attending a lecture given by Dr. Hadley Wickham, of RStudio fame. He defined it such that
Big Data: Can't fit in memory on one computer: > 1 TB
Medium Data: Fits in memory on a server: 10 GB - 1 TB
Small Data: Fits in memory on a laptop: < 10 GB
Hadley also believes that most data can at least be reduced to managable problems, and that a very small amount is actually true big data. He denotes this as the "Big Data Mirage".
90% Can be reduced to a small/ medium data problem with subsetting/sampling/summarising
9% Can be reduced to a very large number of small data problems
1% Is irreducibly big
Slides can be found here.
|
What exactly is Big Data?
I had the pleasure of attending a lecture given by Dr. Hadley Wickham, of RStudio fame. He defined it such that
Big Data: Can't fit in memory on one computer: > 1 TB
Medium Data: Fits in memory on a
|
5,745
|
What exactly is Big Data?
|
A data set/stream is called Big Data, if it satisfies all the four V's
Volume
Velocity
Veracity
Variety
Unless and until it isn't satisfied, the data set can't be termed as Big Data.
A similar answer of mine, for reference.
Having said that, as a data scientist; I find the Map-Reduce framework really nice. Splitting your data, mapping it and then the results of the mapper step are reduced into a single result. I find this framework really fascinating, and how it has benefitted the world of data.
And these are some ways how I deal with the data problem during my work everyday:
Columnar Databases: These are a boon for data scientists. I use Aws Red Shift as my columnar data store. It helps in executing complex SQL queries and joins less of a pain. I find it really good, especially when my growth team asks some really complex questions, and I don't need to say "Yeah, ran a query; we'd get it in a day!"
Spark and the Map Reduce Framework: Reasons have been explained above.
And this is how a data experiment is carried out:
The problem to be answered is identified
The possible data sources are now listed out.
Pipelines are designed for getting the data into Redshift from local databases. Yeah, Spark comes here. It really comes handy during the DB's --> S3 --> Redshift data movement.
Then, the queries and SQL analyses are done on the data in Redshift.
Yes, there are Big Data algorithms like hyper loglog, etc; but I haven't found the need to use them.
So, Yes. The data is collected first before generating the hypothesis.
|
What exactly is Big Data?
|
A data set/stream is called Big Data, if it satisfies all the four V's
Volume
Velocity
Veracity
Variety
Unless and until it isn't satisfied, the data set can't be termed as Big Data.
A similar answe
|
What exactly is Big Data?
A data set/stream is called Big Data, if it satisfies all the four V's
Volume
Velocity
Veracity
Variety
Unless and until it isn't satisfied, the data set can't be termed as Big Data.
A similar answer of mine, for reference.
Having said that, as a data scientist; I find the Map-Reduce framework really nice. Splitting your data, mapping it and then the results of the mapper step are reduced into a single result. I find this framework really fascinating, and how it has benefitted the world of data.
And these are some ways how I deal with the data problem during my work everyday:
Columnar Databases: These are a boon for data scientists. I use Aws Red Shift as my columnar data store. It helps in executing complex SQL queries and joins less of a pain. I find it really good, especially when my growth team asks some really complex questions, and I don't need to say "Yeah, ran a query; we'd get it in a day!"
Spark and the Map Reduce Framework: Reasons have been explained above.
And this is how a data experiment is carried out:
The problem to be answered is identified
The possible data sources are now listed out.
Pipelines are designed for getting the data into Redshift from local databases. Yeah, Spark comes here. It really comes handy during the DB's --> S3 --> Redshift data movement.
Then, the queries and SQL analyses are done on the data in Redshift.
Yes, there are Big Data algorithms like hyper loglog, etc; but I haven't found the need to use them.
So, Yes. The data is collected first before generating the hypothesis.
|
What exactly is Big Data?
A data set/stream is called Big Data, if it satisfies all the four V's
Volume
Velocity
Veracity
Variety
Unless and until it isn't satisfied, the data set can't be termed as Big Data.
A similar answe
|
5,746
|
What exactly is Big Data?
|
I think the only useful definition of big data is data which catalogs all information about a particular phenomenon. What I mean by that is that rather than sampling from some population of interest and collecting some measurements on those units, big data collects measurements on the whole population of interest. Suppose you're interested in Amazon.com customers. It's perfectly feasible for Amazon.com to collect information about all of their customers' purchases, rather than only tracking some users or only tracking some transactions.
To my mind, definitions that hinge on the memory size of the data itself to be of somewhat limited utility. By that metric, given a large enough computer, no data is actually big data. At the extreme of an infinitely large computer, this argument might seem reductive, but consider the case of comparing my consumer-grade laptop to Google's servers. Clearly I'd have enormous logistical problems attempting to sift through a terabyte of data, but Google has the resources to mange that task quite handily. More importantly, the size of your computer is not an intrinsic property of the data, so defining the data purely in reference to whatever technology you have at hand is kind of like measuring distance in terms of the length of your arms.
This argument isn't just a formalism. The need for complicated parallelization schemes and distributed computing platforms disappears once you have sufficient computing power. So if we accept the definition that Big Data is too big to fit into RAM (or crashes Excel, or whatever), then after we upgrade our machines, Big Data ceases to exist. This seems silly.
But let's look at some data about big data, and I'll call this "Big Metadata." This blog post observes an important trend: available RAM is increasing more rapidly than data sizes, and provocatively claims that "Big RAM is eating Big Data" -- that is, with sufficient infrastructure, you no longer have a big data problem, you just have data, and you return back to the domain of conventional analysis methods.
Moreover, different representation methods will have different sizes, so it's not precisely clear what it means to have "big data" defined in reference to its size-in-memory. If your data is constructed in such a way that lots of redundant information is stored (that is, you choose an inefficient coding), you can easily cross the threshold of what your computer can readily handle. But why would you want a definition to have this property? To my mind, whether or not the data set is "big data" shouldn't hinge on whether or not you made efficient choices in research design.
From the standpoint of a practitioner, big data as I define it also carries with it computational requirements, but these requirements are application-specific. Thinking through database design (software, hardware, organization) for $10^4$ observations is very different than for $10^7$ observations, and that's perfectly fine. This also implies that big data, as I define it, may not need specialized technology beyond what we've developed in classical statistics: samples and confidence intervals are still perfectly useful and valid inferential tools when you need to extrapolate. Linear models may provide perfectly acceptable answers to some questions. But big data as I define it may require novel technology. Perhaps you need to classify new data in a situation where you have more predictors than training data, or where your predictors grow with your data size. These problems will require newer technology.
As an aside, I think this question is important because it implicitly touches on why definitions are important -- that is, for whom are you defining the topic. A discussion of addition for first-graders doesn't start with set theory, it starts with reference to counting physical objects. It's been my experience that most of the usage of the term "big data" occurs in the popular press or in communications between people who are not specialists in statistics or machine learning (marketing materials soliciting professional analysis, for example), and it's used to express the idea that modern computing practices meant hat there is a wealth of available information that can be exploited. This is almost always in the context of the data revealing information about consumers that is, perhaps if not private, not immediately obvious. The anecdote about a retail chain sending direct mailings to people it assessed were expectant mothers on the basis of their recent purchases is the classic example of this.
So the connotation and analysis surrounding the common usage of "big data" also carries with it the idea that data can reveal obscure, hidden or even private details of a person's life, provided the application of a sufficient inferential method. When the media report on big data, this deterioration of anonymity is usually what they're driving at -- defining what "big data" is seems somewhat misguided in this light, because the popular press and nonspecialists have no concern for the merits of random forests and support vector machines and so on, nor do they have a sense of the challenges of data analysis at different scales. And this is fine. The concern from their perspective is centered on the social , political and legal consequences of the information age. A precise definition for the media or nonspecialists is not really useful because their understanding is not precise either. (Don't think me smug -- I'm simply observing that not everyone can be an expert in everything.)
|
What exactly is Big Data?
|
I think the only useful definition of big data is data which catalogs all information about a particular phenomenon. What I mean by that is that rather than sampling from some population of interest a
|
What exactly is Big Data?
I think the only useful definition of big data is data which catalogs all information about a particular phenomenon. What I mean by that is that rather than sampling from some population of interest and collecting some measurements on those units, big data collects measurements on the whole population of interest. Suppose you're interested in Amazon.com customers. It's perfectly feasible for Amazon.com to collect information about all of their customers' purchases, rather than only tracking some users or only tracking some transactions.
To my mind, definitions that hinge on the memory size of the data itself to be of somewhat limited utility. By that metric, given a large enough computer, no data is actually big data. At the extreme of an infinitely large computer, this argument might seem reductive, but consider the case of comparing my consumer-grade laptop to Google's servers. Clearly I'd have enormous logistical problems attempting to sift through a terabyte of data, but Google has the resources to mange that task quite handily. More importantly, the size of your computer is not an intrinsic property of the data, so defining the data purely in reference to whatever technology you have at hand is kind of like measuring distance in terms of the length of your arms.
This argument isn't just a formalism. The need for complicated parallelization schemes and distributed computing platforms disappears once you have sufficient computing power. So if we accept the definition that Big Data is too big to fit into RAM (or crashes Excel, or whatever), then after we upgrade our machines, Big Data ceases to exist. This seems silly.
But let's look at some data about big data, and I'll call this "Big Metadata." This blog post observes an important trend: available RAM is increasing more rapidly than data sizes, and provocatively claims that "Big RAM is eating Big Data" -- that is, with sufficient infrastructure, you no longer have a big data problem, you just have data, and you return back to the domain of conventional analysis methods.
Moreover, different representation methods will have different sizes, so it's not precisely clear what it means to have "big data" defined in reference to its size-in-memory. If your data is constructed in such a way that lots of redundant information is stored (that is, you choose an inefficient coding), you can easily cross the threshold of what your computer can readily handle. But why would you want a definition to have this property? To my mind, whether or not the data set is "big data" shouldn't hinge on whether or not you made efficient choices in research design.
From the standpoint of a practitioner, big data as I define it also carries with it computational requirements, but these requirements are application-specific. Thinking through database design (software, hardware, organization) for $10^4$ observations is very different than for $10^7$ observations, and that's perfectly fine. This also implies that big data, as I define it, may not need specialized technology beyond what we've developed in classical statistics: samples and confidence intervals are still perfectly useful and valid inferential tools when you need to extrapolate. Linear models may provide perfectly acceptable answers to some questions. But big data as I define it may require novel technology. Perhaps you need to classify new data in a situation where you have more predictors than training data, or where your predictors grow with your data size. These problems will require newer technology.
As an aside, I think this question is important because it implicitly touches on why definitions are important -- that is, for whom are you defining the topic. A discussion of addition for first-graders doesn't start with set theory, it starts with reference to counting physical objects. It's been my experience that most of the usage of the term "big data" occurs in the popular press or in communications between people who are not specialists in statistics or machine learning (marketing materials soliciting professional analysis, for example), and it's used to express the idea that modern computing practices meant hat there is a wealth of available information that can be exploited. This is almost always in the context of the data revealing information about consumers that is, perhaps if not private, not immediately obvious. The anecdote about a retail chain sending direct mailings to people it assessed were expectant mothers on the basis of their recent purchases is the classic example of this.
So the connotation and analysis surrounding the common usage of "big data" also carries with it the idea that data can reveal obscure, hidden or even private details of a person's life, provided the application of a sufficient inferential method. When the media report on big data, this deterioration of anonymity is usually what they're driving at -- defining what "big data" is seems somewhat misguided in this light, because the popular press and nonspecialists have no concern for the merits of random forests and support vector machines and so on, nor do they have a sense of the challenges of data analysis at different scales. And this is fine. The concern from their perspective is centered on the social , political and legal consequences of the information age. A precise definition for the media or nonspecialists is not really useful because their understanding is not precise either. (Don't think me smug -- I'm simply observing that not everyone can be an expert in everything.)
|
What exactly is Big Data?
I think the only useful definition of big data is data which catalogs all information about a particular phenomenon. What I mean by that is that rather than sampling from some population of interest a
|
5,747
|
What exactly is Big Data?
|
Crosschecking the huge literature on Big Data, I have collected up to 14 "V" terms, 13 of them along about 11 dimensions:
Validity,
Value,
Variability/Variance,
Variety,
Velocity,
Veracity/Veraciousness,
Viability,
Virtuality,
Visualization,
Volatility,
Volume.
The 14th term is Vacuity. According to recent a provocative post, Big Data Doesn’t Exist. Its main points are that:
“Big Data” Isn’t Big
Most “Big Data” Isn’t Actually Useful
[We should be] Making The Most Of Small Data
A proper definition of Big Data would evolve with hardware, software, needs and knowledge, and probably should not depend on a fixed size. Hence, the seizable defintion in Big data: The next frontier for innovation, competition, and productivity, June 2011:
"Big data" refers to datasets whose size is beyond the ability of
typical database software tools to capture, store, manage, and
analyze.
|
What exactly is Big Data?
|
Crosschecking the huge literature on Big Data, I have collected up to 14 "V" terms, 13 of them along about 11 dimensions:
Validity,
Value,
Variability/Variance,
Variety,
Velocity,
Veracity/Veraciousn
|
What exactly is Big Data?
Crosschecking the huge literature on Big Data, I have collected up to 14 "V" terms, 13 of them along about 11 dimensions:
Validity,
Value,
Variability/Variance,
Variety,
Velocity,
Veracity/Veraciousness,
Viability,
Virtuality,
Visualization,
Volatility,
Volume.
The 14th term is Vacuity. According to recent a provocative post, Big Data Doesn’t Exist. Its main points are that:
“Big Data” Isn’t Big
Most “Big Data” Isn’t Actually Useful
[We should be] Making The Most Of Small Data
A proper definition of Big Data would evolve with hardware, software, needs and knowledge, and probably should not depend on a fixed size. Hence, the seizable defintion in Big data: The next frontier for innovation, competition, and productivity, June 2011:
"Big data" refers to datasets whose size is beyond the ability of
typical database software tools to capture, store, manage, and
analyze.
|
What exactly is Big Data?
Crosschecking the huge literature on Big Data, I have collected up to 14 "V" terms, 13 of them along about 11 dimensions:
Validity,
Value,
Variability/Variance,
Variety,
Velocity,
Veracity/Veraciousn
|
5,748
|
What exactly is Big Data?
|
People seem to fixate on a big qualifier in Big Data. However, the size is only one of the components of this term (domain). It's not enough that your data set was big to call your problem (domain) a big data, you also need it be difficult to understand and analyze and even process. Some call this feature unstructured, but it's not just the structure it's also unclear relationship between different pieces and elements of data.
Consider the data sets that high energy physicists are working in places such as CERN. They've been working with petabytes size data for years before the Big Data term was coined. Yet even now they don't call this big data as far as I know. Why? Because the data is rather regular, they know what to do with it. They may not be able to explain every observation yet, so they work on new models etc.
Now we call Big Data the problems that deal with data sets that have sizes that could be generated in a few seconds from LHC in CERN. The reason is that these data sets are usually of data elements coming from multitude of sources with different formats, unclear relationships between the data and uncertain value to the business. It could be just 1TB but it's so difficult to process all the audio, vidio, texts, speech etc. So, in terms of complexity and resources required this trumps the petabytes of CERN's data. We don't even know if there's discernible useful information in our data sets.
Hence, Big Data problem solving involves parsing, extracting data elements of unknown value, then linking them to each other. "Parsing" an image can be a big a problem on its own. Say, you're looking for CCTV footage from the streets of the city trying to see whether people are getting angrier and whether it impacts the road accidents involving pedestrians. There's a ton of video, you find the faces, try to gauge their moods by expressions, then link this to the number of accidents data sets, police reports etc., all while controlling for weather (precitipotation, temperature) and traffic congestions... You need the storage and analytical tools that support these large data sets of different kinds, and can efficiently link the data to each other.
Big Data is a complex analysis problem where the complexity stems from both the sheer size and the complexity of structure and information encoding in it.
|
What exactly is Big Data?
|
People seem to fixate on a big qualifier in Big Data. However, the size is only one of the components of this term (domain). It's not enough that your data set was big to call your problem (domain) a
|
What exactly is Big Data?
People seem to fixate on a big qualifier in Big Data. However, the size is only one of the components of this term (domain). It's not enough that your data set was big to call your problem (domain) a big data, you also need it be difficult to understand and analyze and even process. Some call this feature unstructured, but it's not just the structure it's also unclear relationship between different pieces and elements of data.
Consider the data sets that high energy physicists are working in places such as CERN. They've been working with petabytes size data for years before the Big Data term was coined. Yet even now they don't call this big data as far as I know. Why? Because the data is rather regular, they know what to do with it. They may not be able to explain every observation yet, so they work on new models etc.
Now we call Big Data the problems that deal with data sets that have sizes that could be generated in a few seconds from LHC in CERN. The reason is that these data sets are usually of data elements coming from multitude of sources with different formats, unclear relationships between the data and uncertain value to the business. It could be just 1TB but it's so difficult to process all the audio, vidio, texts, speech etc. So, in terms of complexity and resources required this trumps the petabytes of CERN's data. We don't even know if there's discernible useful information in our data sets.
Hence, Big Data problem solving involves parsing, extracting data elements of unknown value, then linking them to each other. "Parsing" an image can be a big a problem on its own. Say, you're looking for CCTV footage from the streets of the city trying to see whether people are getting angrier and whether it impacts the road accidents involving pedestrians. There's a ton of video, you find the faces, try to gauge their moods by expressions, then link this to the number of accidents data sets, police reports etc., all while controlling for weather (precitipotation, temperature) and traffic congestions... You need the storage and analytical tools that support these large data sets of different kinds, and can efficiently link the data to each other.
Big Data is a complex analysis problem where the complexity stems from both the sheer size and the complexity of structure and information encoding in it.
|
What exactly is Big Data?
People seem to fixate on a big qualifier in Big Data. However, the size is only one of the components of this term (domain). It's not enough that your data set was big to call your problem (domain) a
|
5,749
|
What exactly is Big Data?
|
I think the reason why people get confused of what is Big Data is that they doesn't see its benefits. The value of Big Data (technique) is not only on the amount of data that you can collect, but also on the Predictive Modeling, which is eventually more important:
Predictive Modeling changed completely the way we do statistics and predictions, it gives us greater insight on our data, because new models, new techniques can detect better the trends, the noises of the data, can capture "multi"-dimensional database. The more dimentions we have in our database, the better chance we can creat the good model. Predictive Modeling is the heart of Big Data's value.
Big Data (in term of data size) is the preliminary step, and is there for serving the Predictive Modeling by: enrich the database with respect to the: 1.number of predictors (more variables), 2.number of observations.
More predictors because we are now able to capture the data that were impossible to capture before (because of the limited hardware power, limited capacity to work on the unstructured data). More predictors mean more chances to have the significant predictors, i.e better model, better prediction, better decision can be made for the business.
More observations not only make the model more robust over the time, but also help the model learn/detect every possible patterns that can be presented/generated in the reality.
|
What exactly is Big Data?
|
I think the reason why people get confused of what is Big Data is that they doesn't see its benefits. The value of Big Data (technique) is not only on the amount of data that you can collect, but also
|
What exactly is Big Data?
I think the reason why people get confused of what is Big Data is that they doesn't see its benefits. The value of Big Data (technique) is not only on the amount of data that you can collect, but also on the Predictive Modeling, which is eventually more important:
Predictive Modeling changed completely the way we do statistics and predictions, it gives us greater insight on our data, because new models, new techniques can detect better the trends, the noises of the data, can capture "multi"-dimensional database. The more dimentions we have in our database, the better chance we can creat the good model. Predictive Modeling is the heart of Big Data's value.
Big Data (in term of data size) is the preliminary step, and is there for serving the Predictive Modeling by: enrich the database with respect to the: 1.number of predictors (more variables), 2.number of observations.
More predictors because we are now able to capture the data that were impossible to capture before (because of the limited hardware power, limited capacity to work on the unstructured data). More predictors mean more chances to have the significant predictors, i.e better model, better prediction, better decision can be made for the business.
More observations not only make the model more robust over the time, but also help the model learn/detect every possible patterns that can be presented/generated in the reality.
|
What exactly is Big Data?
I think the reason why people get confused of what is Big Data is that they doesn't see its benefits. The value of Big Data (technique) is not only on the amount of data that you can collect, but also
|
5,750
|
What exactly is Big Data?
|
The tricky thing about Big Data vs. its antonym (presumably Small Data?) is that it is a continuum. The big data people have gone to one side of the spectrum, the small data people have gone to the other, but there's no clear line in the sand that everyone can agree upon.
I would look at behavioral differences between the two. In small data situations, you have a "small" dataset, and you seek you squeeze as much information as possible our of every data-point you can. Get more data, you can get more results. However, getting more data can be expensive. The data one collects is often constrained to fit mathematical models, such as doing a partial factorial of tests to screen for interesting behaviors.
In big data situations, you have a "big" dataset, but your dataset tends not to be as constrained. You usually don't get to convince your customers to buy a latin-square of furniture, just to make the analysis easier. Instead you tend to have gobs and gobs of poorly structured data. To solve these problems, the goal tends not to be "select the best data, and squeeze everything you can out of it," like one might naively attempt if one is used to small data. The goal tends to be more along the lines of "if you can just get a tiny smidgen out of every single datapoint, the sum will be huge and profound."
Between them lies the medium sized data sets, with okay structure. These are the "really hard problems," so right now we tend to organize into two camps: one with small data squeezing every last bit out of it, and the other with big data trying to manage to let each data point shine in its own right. As we move forward, I expect to see more small-data processes trying to adapt to larger data-sets, and more big-data processes trying to adapt to leverage more structured data.
|
What exactly is Big Data?
|
The tricky thing about Big Data vs. its antonym (presumably Small Data?) is that it is a continuum. The big data people have gone to one side of the spectrum, the small data people have gone to the o
|
What exactly is Big Data?
The tricky thing about Big Data vs. its antonym (presumably Small Data?) is that it is a continuum. The big data people have gone to one side of the spectrum, the small data people have gone to the other, but there's no clear line in the sand that everyone can agree upon.
I would look at behavioral differences between the two. In small data situations, you have a "small" dataset, and you seek you squeeze as much information as possible our of every data-point you can. Get more data, you can get more results. However, getting more data can be expensive. The data one collects is often constrained to fit mathematical models, such as doing a partial factorial of tests to screen for interesting behaviors.
In big data situations, you have a "big" dataset, but your dataset tends not to be as constrained. You usually don't get to convince your customers to buy a latin-square of furniture, just to make the analysis easier. Instead you tend to have gobs and gobs of poorly structured data. To solve these problems, the goal tends not to be "select the best data, and squeeze everything you can out of it," like one might naively attempt if one is used to small data. The goal tends to be more along the lines of "if you can just get a tiny smidgen out of every single datapoint, the sum will be huge and profound."
Between them lies the medium sized data sets, with okay structure. These are the "really hard problems," so right now we tend to organize into two camps: one with small data squeezing every last bit out of it, and the other with big data trying to manage to let each data point shine in its own right. As we move forward, I expect to see more small-data processes trying to adapt to larger data-sets, and more big-data processes trying to adapt to leverage more structured data.
|
What exactly is Big Data?
The tricky thing about Big Data vs. its antonym (presumably Small Data?) is that it is a continuum. The big data people have gone to one side of the spectrum, the small data people have gone to the o
|
5,751
|
What exactly is Big Data?
|
I'd say there are three components that are essential in defining big data: the direction of analysis, the size of the data with respect to the population, and the size of the data with respect to computational problems.
The question itself posits that hypotheses are developed after data exists. I don't use "collected" because think the word "collected" implies for a purpose and data often exists for no known purpose at the time. The collecting often occurs in big data by bringing existing data together in service of a question.
A second important part is that it's not just any data for which post hoc analysis, what one would call exploratory analysis with smaller datasets, is appropriate. It needs to be of sufficient size that it's believed that estimates gathered from it are close enough to population estimates that many smaller sample issues can be ignored. Because of this I'm a little concerned that there is a push right now in the field toward multiple comparison corrections. If you had the whole population, or an approximation that you have good reason to believe is valid, such corrections should be moot. While I realize that it does occur that sometimes problems are posed that really do turn the "big data" into a small sample (e.g. large logistic regressions), that comes down to understanding what a large sample is for a specific question. Many of the multiple comparison questions should instead be turned to a effect size questions. And, of course, the whole idea you'd use tests with alpha = 0.05, as many still do with big data, is just absurd.
And finally, small populations don't qualify. In some cases there is a small population and one can collect all of the data required to examine it very easily and allow the first two criteria to be met. The data needs to be of sufficient magnitude that it becomes a computational problem. As such, in some ways we must concede that "big data" may be a transient buzz word and perhaps a phenomenon perpetually in search of strict definition. Some of the things that make "big data" big now will vanish in a few short years and definitions like Hadley's, based on computer capacity, will seem quaint. But at another level computational problems are questions that aren't about computer capacity or perhaps about computer capacity that can never be addressed. I think that in that sense the problems of defining "big data" will continue in the future.
One might note that I haven't provided examples or firm definitions of what a hard computational problem is for this domain (there are loads of examples generally in comp sci, and some applicable, that I won't go into). I don't want to make any because I think that will have to remain somewhat open. Over time the collected works of many people come together to make such things easy, more often through software development than hardware at this point. Perhaps the field will have to mature more fully in order to make this last requirement more solidly bounded but the edges will always be fuzzy.
|
What exactly is Big Data?
|
I'd say there are three components that are essential in defining big data: the direction of analysis, the size of the data with respect to the population, and the size of the data with respect to com
|
What exactly is Big Data?
I'd say there are three components that are essential in defining big data: the direction of analysis, the size of the data with respect to the population, and the size of the data with respect to computational problems.
The question itself posits that hypotheses are developed after data exists. I don't use "collected" because think the word "collected" implies for a purpose and data often exists for no known purpose at the time. The collecting often occurs in big data by bringing existing data together in service of a question.
A second important part is that it's not just any data for which post hoc analysis, what one would call exploratory analysis with smaller datasets, is appropriate. It needs to be of sufficient size that it's believed that estimates gathered from it are close enough to population estimates that many smaller sample issues can be ignored. Because of this I'm a little concerned that there is a push right now in the field toward multiple comparison corrections. If you had the whole population, or an approximation that you have good reason to believe is valid, such corrections should be moot. While I realize that it does occur that sometimes problems are posed that really do turn the "big data" into a small sample (e.g. large logistic regressions), that comes down to understanding what a large sample is for a specific question. Many of the multiple comparison questions should instead be turned to a effect size questions. And, of course, the whole idea you'd use tests with alpha = 0.05, as many still do with big data, is just absurd.
And finally, small populations don't qualify. In some cases there is a small population and one can collect all of the data required to examine it very easily and allow the first two criteria to be met. The data needs to be of sufficient magnitude that it becomes a computational problem. As such, in some ways we must concede that "big data" may be a transient buzz word and perhaps a phenomenon perpetually in search of strict definition. Some of the things that make "big data" big now will vanish in a few short years and definitions like Hadley's, based on computer capacity, will seem quaint. But at another level computational problems are questions that aren't about computer capacity or perhaps about computer capacity that can never be addressed. I think that in that sense the problems of defining "big data" will continue in the future.
One might note that I haven't provided examples or firm definitions of what a hard computational problem is for this domain (there are loads of examples generally in comp sci, and some applicable, that I won't go into). I don't want to make any because I think that will have to remain somewhat open. Over time the collected works of many people come together to make such things easy, more often through software development than hardware at this point. Perhaps the field will have to mature more fully in order to make this last requirement more solidly bounded but the edges will always be fuzzy.
|
What exactly is Big Data?
I'd say there are three components that are essential in defining big data: the direction of analysis, the size of the data with respect to the population, and the size of the data with respect to com
|
5,752
|
What exactly is Big Data?
|
Wikipedia provides quite clear definition
Big data is a broad term for data sets so large or complex that
traditional data processing applications are inadequate. (source
https://en.wikipedia.org/wiki/Big_data)
other simple definition I know is
Data that does not fit computer memory.
Unfortunately I do not remember reference for it. Everything else emerges from this definitions - you have to deal somehow with big amounts of data.
|
What exactly is Big Data?
|
Wikipedia provides quite clear definition
Big data is a broad term for data sets so large or complex that
traditional data processing applications are inadequate. (source
https://en.wikipedia.org
|
What exactly is Big Data?
Wikipedia provides quite clear definition
Big data is a broad term for data sets so large or complex that
traditional data processing applications are inadequate. (source
https://en.wikipedia.org/wiki/Big_data)
other simple definition I know is
Data that does not fit computer memory.
Unfortunately I do not remember reference for it. Everything else emerges from this definitions - you have to deal somehow with big amounts of data.
|
What exactly is Big Data?
Wikipedia provides quite clear definition
Big data is a broad term for data sets so large or complex that
traditional data processing applications are inadequate. (source
https://en.wikipedia.org
|
5,753
|
What exactly is Big Data?
|
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
I would add that Big Data is a reference to either working on big data-set (millions and/or billions of rows) or trying to find information/patterns on broad data resources you can collect now everywhere.
|
What exactly is Big Data?
|
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
|
What exactly is Big Data?
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
I would add that Big Data is a reference to either working on big data-set (millions and/or billions of rows) or trying to find information/patterns on broad data resources you can collect now everywhere.
|
What exactly is Big Data?
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
|
5,754
|
Are there any examples of where the central limit theorem does not hold?
|
To understand this, you need to first state a version of the Central Limit Theorem. Here's the "typical" statement of the central limit theorem:
Lindeberg–Lévy CLT. Suppose ${X_1, X_2, \dots}$ is a sequence of i.i.d.
random variables with $E[X_i] = \mu$ and $Var[X_i] = \sigma^2 < \infty$.
Let $S_{n}:={\frac {X_{1}+\cdots +X_{n}}{n}}$. Then as
$n$ approaches infinity, the random variables $\sqrt{n}(S_n − \mu)$ converge
in distribution to a normal $N(0,\sigma^2)$ i.e.
$${\displaystyle {\sqrt {n}}\left(\left({\frac {1}{n}}\sum
_{i=1}^{n}X_{i}\right)-\mu \right)\ {\xrightarrow {d}}\ N\left(0,\sigma ^{2}\right).}$$
So, how does this differ from the informal description, and what are the gaps? There are several differences between your informal description and this description, some of which have been discussed in other answers, but not completely. So, we can turn this into three specific questions:
What happens if the variables are not identically distributed?
What if the variables have infinite variance, or infinite mean?
How important is independence?
Taking these one at a time,
Not identically distributed, The best general results are the Lindeberg and Lyaponov versions of the central limit theorem. Basically, as long as the standard deviations don't grow too wildly, you can get a decent central limit theorem out of it.
Lyapunov CLT.[5] Suppose ${X_1, X_2, \dots}$ is a sequence of independent
random variables, each with finite expected value $\mu_i$ and variance $\sigma^2$
Define: $s_{n}^{2}=\sum _{i=1}^{n}\sigma _{i}^{2}$
If for some $\delta > 0$, Lyapunov’s
condition
${\displaystyle \lim _{n\to \infty }{\frac {1}{s_{n}^{2+\delta }}}\sum_{i=1}^{n}\operatorname {E} \left[|X_{i}-\mu _{i}|^{2+\delta }\right]=0}$ is satisfied, then a sum
of $X_i − \mu_i / s_n$ converges in distribution to a standard normal
random variable, as n goes to infinity:
${{\frac {1}{s_{n}}}\sum _{i=1}^{n}\left(X_{i}-\mu_{i}\right)\ {\xrightarrow {d}}\ N(0,1).}$
Infinite Variance Theorems similar to the central limit theorem exist for variables with infinite variance, but the conditions are significantly more narrow than for the usual central limit theorem. Essentially the tail of the probability distribution must be asymptotic to $|x|^{-\alpha-1}$ for $0 < \alpha < 2$. In this case, appropriate scaled summands converge to a Levy-Alpha stable distribution.
Importance of Independence There are many different central limit theorems for non-independent sequences of $X_i$. They are all highly contextual. As Batman points out, there's one for Martingales. This question is an ongoing area of research, with many, many different variations depending upon the specific context of interest. This Question on Math Exchange is another post related to this question.
|
Are there any examples of where the central limit theorem does not hold?
|
To understand this, you need to first state a version of the Central Limit Theorem. Here's the "typical" statement of the central limit theorem:
Lindeberg–Lévy CLT. Suppose ${X_1, X_2, \dots}$ is a
|
Are there any examples of where the central limit theorem does not hold?
To understand this, you need to first state a version of the Central Limit Theorem. Here's the "typical" statement of the central limit theorem:
Lindeberg–Lévy CLT. Suppose ${X_1, X_2, \dots}$ is a sequence of i.i.d.
random variables with $E[X_i] = \mu$ and $Var[X_i] = \sigma^2 < \infty$.
Let $S_{n}:={\frac {X_{1}+\cdots +X_{n}}{n}}$. Then as
$n$ approaches infinity, the random variables $\sqrt{n}(S_n − \mu)$ converge
in distribution to a normal $N(0,\sigma^2)$ i.e.
$${\displaystyle {\sqrt {n}}\left(\left({\frac {1}{n}}\sum
_{i=1}^{n}X_{i}\right)-\mu \right)\ {\xrightarrow {d}}\ N\left(0,\sigma ^{2}\right).}$$
So, how does this differ from the informal description, and what are the gaps? There are several differences between your informal description and this description, some of which have been discussed in other answers, but not completely. So, we can turn this into three specific questions:
What happens if the variables are not identically distributed?
What if the variables have infinite variance, or infinite mean?
How important is independence?
Taking these one at a time,
Not identically distributed, The best general results are the Lindeberg and Lyaponov versions of the central limit theorem. Basically, as long as the standard deviations don't grow too wildly, you can get a decent central limit theorem out of it.
Lyapunov CLT.[5] Suppose ${X_1, X_2, \dots}$ is a sequence of independent
random variables, each with finite expected value $\mu_i$ and variance $\sigma^2$
Define: $s_{n}^{2}=\sum _{i=1}^{n}\sigma _{i}^{2}$
If for some $\delta > 0$, Lyapunov’s
condition
${\displaystyle \lim _{n\to \infty }{\frac {1}{s_{n}^{2+\delta }}}\sum_{i=1}^{n}\operatorname {E} \left[|X_{i}-\mu _{i}|^{2+\delta }\right]=0}$ is satisfied, then a sum
of $X_i − \mu_i / s_n$ converges in distribution to a standard normal
random variable, as n goes to infinity:
${{\frac {1}{s_{n}}}\sum _{i=1}^{n}\left(X_{i}-\mu_{i}\right)\ {\xrightarrow {d}}\ N(0,1).}$
Infinite Variance Theorems similar to the central limit theorem exist for variables with infinite variance, but the conditions are significantly more narrow than for the usual central limit theorem. Essentially the tail of the probability distribution must be asymptotic to $|x|^{-\alpha-1}$ for $0 < \alpha < 2$. In this case, appropriate scaled summands converge to a Levy-Alpha stable distribution.
Importance of Independence There are many different central limit theorems for non-independent sequences of $X_i$. They are all highly contextual. As Batman points out, there's one for Martingales. This question is an ongoing area of research, with many, many different variations depending upon the specific context of interest. This Question on Math Exchange is another post related to this question.
|
Are there any examples of where the central limit theorem does not hold?
To understand this, you need to first state a version of the Central Limit Theorem. Here's the "typical" statement of the central limit theorem:
Lindeberg–Lévy CLT. Suppose ${X_1, X_2, \dots}$ is a
|
5,755
|
Are there any examples of where the central limit theorem does not hold?
|
Although I'm pretty sure that it has been answered before, here's another one:
There are several versions of the central limit theorem, the most general being that given arbitrary probability density functions, the sum of the variables will be distributed normally with a mean value equal to the sum of mean values, as well as the variance being the sum of the individual variances.
A very important and relevant constraint is that the mean and the variance of the given pdfs have to exist and must be finite.
So, just take any pdf without mean value or variance -- and the central limit theorem will not hold anymore. So take a Lorentzian distribution for example.
|
Are there any examples of where the central limit theorem does not hold?
|
Although I'm pretty sure that it has been answered before, here's another one:
There are several versions of the central limit theorem, the most general being that given arbitrary probability density
|
Are there any examples of where the central limit theorem does not hold?
Although I'm pretty sure that it has been answered before, here's another one:
There are several versions of the central limit theorem, the most general being that given arbitrary probability density functions, the sum of the variables will be distributed normally with a mean value equal to the sum of mean values, as well as the variance being the sum of the individual variances.
A very important and relevant constraint is that the mean and the variance of the given pdfs have to exist and must be finite.
So, just take any pdf without mean value or variance -- and the central limit theorem will not hold anymore. So take a Lorentzian distribution for example.
|
Are there any examples of where the central limit theorem does not hold?
Although I'm pretty sure that it has been answered before, here's another one:
There are several versions of the central limit theorem, the most general being that given arbitrary probability density
|
5,756
|
Are there any examples of where the central limit theorem does not hold?
|
No, CLT always holds when its assumptions hold. Qualifications such as "in most situations" are informal references to the conditions under which CLT should be applied.
For instance, a linear combination of independent variables from Cauchy distribution will not add up to Normal distributed variable. One of the reasons is that the variance is undefined for Cauchy distribution, while CLT puts certain conditions on the variance, e.g. that it has to be finite. An interesting implication is that since Monte Carlo simulations is motivated by CLT, you have to be careful with Monte Carlo simulations when dealing with fat tailed distributions, such as Cauchy.
Note, that there is a generalized version of CLT. It works for infinite or undefined variances, such as Cauchy distribution. Unlike many well behaving distributions, the properly normalized sum of Cauchy numbers remains Cauchy. It doesn't converge to Gaussian.
By the way, not only Gaussian but many other distributions have bell shaped PDFs, e.g. Student t. That's why the description you quoted is quite liberal and imprecise, perhaps on purpose.
|
Are there any examples of where the central limit theorem does not hold?
|
No, CLT always holds when its assumptions hold. Qualifications such as "in most situations" are informal references to the conditions under which CLT should be applied.
For instance, a linear combina
|
Are there any examples of where the central limit theorem does not hold?
No, CLT always holds when its assumptions hold. Qualifications such as "in most situations" are informal references to the conditions under which CLT should be applied.
For instance, a linear combination of independent variables from Cauchy distribution will not add up to Normal distributed variable. One of the reasons is that the variance is undefined for Cauchy distribution, while CLT puts certain conditions on the variance, e.g. that it has to be finite. An interesting implication is that since Monte Carlo simulations is motivated by CLT, you have to be careful with Monte Carlo simulations when dealing with fat tailed distributions, such as Cauchy.
Note, that there is a generalized version of CLT. It works for infinite or undefined variances, such as Cauchy distribution. Unlike many well behaving distributions, the properly normalized sum of Cauchy numbers remains Cauchy. It doesn't converge to Gaussian.
By the way, not only Gaussian but many other distributions have bell shaped PDFs, e.g. Student t. That's why the description you quoted is quite liberal and imprecise, perhaps on purpose.
|
Are there any examples of where the central limit theorem does not hold?
No, CLT always holds when its assumptions hold. Qualifications such as "in most situations" are informal references to the conditions under which CLT should be applied.
For instance, a linear combina
|
5,757
|
Are there any examples of where the central limit theorem does not hold?
|
Here is an illustration of cherub's answer, a histogram of 1e6 draws from scaled (by $\sqrt{n}$) and standardized (by the sample standard deviation) sample means of t-distributions with two degrees of freedom, such that the variance does not exist.
If the CLT did apply, the histogram for $n$ as large as $n=2000$ should resemble the density of a standard normal distribution (which, e.g., has density $1/\sqrt{2\pi}\approx0.4$ at its peak), which it evidently does not.
library(MASS)
n <- 2000
std.t <- function(n){
x <- rt(n, df = 2)
sqrt(n)*mean(x)/sd(x)
}
samples.from.t <- replicate(1e6, std.t(n))
xax <- seq(-5,5, by=0.01)
truehist(samples.from.t, xlim = c(-5,5), ylim = c(0,0.4), col="salmon")
lines(xax, dnorm(xax), col="blue", lwd=2)
|
Are there any examples of where the central limit theorem does not hold?
|
Here is an illustration of cherub's answer, a histogram of 1e6 draws from scaled (by $\sqrt{n}$) and standardized (by the sample standard deviation) sample means of t-distributions with two degrees of
|
Are there any examples of where the central limit theorem does not hold?
Here is an illustration of cherub's answer, a histogram of 1e6 draws from scaled (by $\sqrt{n}$) and standardized (by the sample standard deviation) sample means of t-distributions with two degrees of freedom, such that the variance does not exist.
If the CLT did apply, the histogram for $n$ as large as $n=2000$ should resemble the density of a standard normal distribution (which, e.g., has density $1/\sqrt{2\pi}\approx0.4$ at its peak), which it evidently does not.
library(MASS)
n <- 2000
std.t <- function(n){
x <- rt(n, df = 2)
sqrt(n)*mean(x)/sd(x)
}
samples.from.t <- replicate(1e6, std.t(n))
xax <- seq(-5,5, by=0.01)
truehist(samples.from.t, xlim = c(-5,5), ylim = c(0,0.4), col="salmon")
lines(xax, dnorm(xax), col="blue", lwd=2)
|
Are there any examples of where the central limit theorem does not hold?
Here is an illustration of cherub's answer, a histogram of 1e6 draws from scaled (by $\sqrt{n}$) and standardized (by the sample standard deviation) sample means of t-distributions with two degrees of
|
5,758
|
Are there any examples of where the central limit theorem does not hold?
|
A simple case where the CLT cannot hold for very practical reasons, is when the sequence of random variables approaches its probability limit strictly from the one side. This is encountered for example in estimators that estimate something that lies on a boundary.
The standard example here perhaps is the estimation of $\theta$ in a sample of i.i.d. Uniforms $U(0,\theta)$. The maximum likelihood estimator will be the maximum order statistic, and it will approach $\theta$ necessarily only from below: naively thinking, since its probability limit will be $\theta$, the estimator cannot have a distribution "around" $\theta$ - and the CLT is gone.
The estimator properly scaled does have a limiting distribution - but not of the "CLT variety".
|
Are there any examples of where the central limit theorem does not hold?
|
A simple case where the CLT cannot hold for very practical reasons, is when the sequence of random variables approaches its probability limit strictly from the one side. This is encountered for exampl
|
Are there any examples of where the central limit theorem does not hold?
A simple case where the CLT cannot hold for very practical reasons, is when the sequence of random variables approaches its probability limit strictly from the one side. This is encountered for example in estimators that estimate something that lies on a boundary.
The standard example here perhaps is the estimation of $\theta$ in a sample of i.i.d. Uniforms $U(0,\theta)$. The maximum likelihood estimator will be the maximum order statistic, and it will approach $\theta$ necessarily only from below: naively thinking, since its probability limit will be $\theta$, the estimator cannot have a distribution "around" $\theta$ - and the CLT is gone.
The estimator properly scaled does have a limiting distribution - but not of the "CLT variety".
|
Are there any examples of where the central limit theorem does not hold?
A simple case where the CLT cannot hold for very practical reasons, is when the sequence of random variables approaches its probability limit strictly from the one side. This is encountered for exampl
|
5,759
|
Are there any examples of where the central limit theorem does not hold?
|
You can find a quick solution here.
Exceptions to the central-limit theorem arise
When there are multiple maxima of the same height, and
Where the second derivative vanishes at the maximum.
There are certain other exceptions which are outlined in the answer of @cherub.
The same question has already been asked on math.stackexchange. You can check the answers there.
|
Are there any examples of where the central limit theorem does not hold?
|
You can find a quick solution here.
Exceptions to the central-limit theorem arise
When there are multiple maxima of the same height, and
Where the second derivative vanishes at the maximum.
There
|
Are there any examples of where the central limit theorem does not hold?
You can find a quick solution here.
Exceptions to the central-limit theorem arise
When there are multiple maxima of the same height, and
Where the second derivative vanishes at the maximum.
There are certain other exceptions which are outlined in the answer of @cherub.
The same question has already been asked on math.stackexchange. You can check the answers there.
|
Are there any examples of where the central limit theorem does not hold?
You can find a quick solution here.
Exceptions to the central-limit theorem arise
When there are multiple maxima of the same height, and
Where the second derivative vanishes at the maximum.
There
|
5,760
|
Are there any examples of where the central limit theorem does not hold?
|
The (usual) central limit theorem applies only if the random variables involved are mutually independent with the same distribution and finite mean and variance. If the variables are merely pairwise independent (meaning any two of them are independent of each other, but more than two are not necessarily independent), the theorem need not hold true, and Avanzi et al. (2020) show some examples that the theorem does not work for pairwise independent random variables in general.
REFERENCES:
Avanzi, Benjamin, Guillaume Boglioni Beaulieu, Pierre Lafaye de Micheaux, Frédéric Ouimet, and Bernard Wong. "A counterexample to the central limit theorem for pairwise independent random variables having a common arbitrary margin" arXiv preprint arXiv:2003.01350 (2020).
|
Are there any examples of where the central limit theorem does not hold?
|
The (usual) central limit theorem applies only if the random variables involved are mutually independent with the same distribution and finite mean and variance. If the variables are merely pairwise i
|
Are there any examples of where the central limit theorem does not hold?
The (usual) central limit theorem applies only if the random variables involved are mutually independent with the same distribution and finite mean and variance. If the variables are merely pairwise independent (meaning any two of them are independent of each other, but more than two are not necessarily independent), the theorem need not hold true, and Avanzi et al. (2020) show some examples that the theorem does not work for pairwise independent random variables in general.
REFERENCES:
Avanzi, Benjamin, Guillaume Boglioni Beaulieu, Pierre Lafaye de Micheaux, Frédéric Ouimet, and Bernard Wong. "A counterexample to the central limit theorem for pairwise independent random variables having a common arbitrary margin" arXiv preprint arXiv:2003.01350 (2020).
|
Are there any examples of where the central limit theorem does not hold?
The (usual) central limit theorem applies only if the random variables involved are mutually independent with the same distribution and finite mean and variance. If the variables are merely pairwise i
|
5,761
|
What best practices should I follow when preparing plots?
|
The Tufte principles are very good practices when preparing plots. See also his book Beautiful Evidence
The principles include:
Keep a high data-ink ratio
Remove chart junk
Give graphical element multiple functions
Keep in mind the data density
The term to search for is Information Visualization
|
What best practices should I follow when preparing plots?
|
The Tufte principles are very good practices when preparing plots. See also his book Beautiful Evidence
The principles include:
Keep a high data-ink ratio
Remove chart junk
Give graphical element mul
|
What best practices should I follow when preparing plots?
The Tufte principles are very good practices when preparing plots. See also his book Beautiful Evidence
The principles include:
Keep a high data-ink ratio
Remove chart junk
Give graphical element multiple functions
Keep in mind the data density
The term to search for is Information Visualization
|
What best practices should I follow when preparing plots?
The Tufte principles are very good practices when preparing plots. See also his book Beautiful Evidence
The principles include:
Keep a high data-ink ratio
Remove chart junk
Give graphical element mul
|
5,762
|
What best practices should I follow when preparing plots?
|
We could stay here all day denoting best practices, but you should start by reading Tufte. My primary recommendation:
Keep it simple.
Often people try to load up their charts with information. But you should really just have one main idea that you're trying to convey and if someone doesn't get your message almost immediately, then you should rethink how you have presented it. So don't start working on your chart until the message itself is clear. Occam's razor applies here too.
|
What best practices should I follow when preparing plots?
|
We could stay here all day denoting best practices, but you should start by reading Tufte. My primary recommendation:
Keep it simple.
Often people try to load up their charts with information. But y
|
What best practices should I follow when preparing plots?
We could stay here all day denoting best practices, but you should start by reading Tufte. My primary recommendation:
Keep it simple.
Often people try to load up their charts with information. But you should really just have one main idea that you're trying to convey and if someone doesn't get your message almost immediately, then you should rethink how you have presented it. So don't start working on your chart until the message itself is clear. Occam's razor applies here too.
|
What best practices should I follow when preparing plots?
We could stay here all day denoting best practices, but you should start by reading Tufte. My primary recommendation:
Keep it simple.
Often people try to load up their charts with information. But y
|
5,763
|
What best practices should I follow when preparing plots?
|
One rule of thumb that I don't always follow but which is on occasion useful is to take into account that it is likely that your plot will at some point in its future be
sent by fax,
photocopied, and/or
reproduced in black-and-white.
You need to try and make your plots clear enough that even if they are imprecisely reproduced in the future, the information the plot is trying to convey is still legible.
|
What best practices should I follow when preparing plots?
|
One rule of thumb that I don't always follow but which is on occasion useful is to take into account that it is likely that your plot will at some point in its future be
sent by fax,
photocopied, and
|
What best practices should I follow when preparing plots?
One rule of thumb that I don't always follow but which is on occasion useful is to take into account that it is likely that your plot will at some point in its future be
sent by fax,
photocopied, and/or
reproduced in black-and-white.
You need to try and make your plots clear enough that even if they are imprecisely reproduced in the future, the information the plot is trying to convey is still legible.
|
What best practices should I follow when preparing plots?
One rule of thumb that I don't always follow but which is on occasion useful is to take into account that it is likely that your plot will at some point in its future be
sent by fax,
photocopied, and
|
5,764
|
What best practices should I follow when preparing plots?
|
In the physics field there is a rule that the whole paper/report should be understandable only from quick look at the plots. So I would mainly advise that they should be self-explanatory.
This also implies that you must always check whether your audience is familiar with some kind of plot -- I had once made a big mistake assuming that every scientist knows what boxplots are, and then wasted an hour to explain it.
|
What best practices should I follow when preparing plots?
|
In the physics field there is a rule that the whole paper/report should be understandable only from quick look at the plots. So I would mainly advise that they should be self-explanatory.
This also im
|
What best practices should I follow when preparing plots?
In the physics field there is a rule that the whole paper/report should be understandable only from quick look at the plots. So I would mainly advise that they should be self-explanatory.
This also implies that you must always check whether your audience is familiar with some kind of plot -- I had once made a big mistake assuming that every scientist knows what boxplots are, and then wasted an hour to explain it.
|
What best practices should I follow when preparing plots?
In the physics field there is a rule that the whole paper/report should be understandable only from quick look at the plots. So I would mainly advise that they should be self-explanatory.
This also im
|
5,765
|
What best practices should I follow when preparing plots?
|
In addition to conveying a clear message I always try to remember the plotsmanship:
font sizes for labels and legends should be big enough, preferably the same font size and font used in the final publication.
linewidths should be big enough (1 pt lines tend to disappear if plots are shrunk only slightly). I try to go to linewidths of 3 to 5 pt.
if plotting multiple datasets/curves with color make sure that they can be understood if printed in black-and-white, e.g. by using different symbols or linestyles in addition to color.
always use a lossless (or close to lossless) format, e.g. a vector format like pdf, ps or svg or high resolution png or gif (jpeg doesn't work at all and was never designed for line art).
prepare graphics in the final aspect ratio to be used in the publication. Changing the aspect ratio later can give irritating font or symbol shapes.
always remove useless clutter from the plotting program like unused histogram information, trend lines (hardly useful) or default titles.
I have configured my plotting software (matplotlib, ROOT or root2matplotlib) to do most of this right by default. Before I was using gnuplot which needed extra care here.
|
What best practices should I follow when preparing plots?
|
In addition to conveying a clear message I always try to remember the plotsmanship:
font sizes for labels and legends should be big enough, preferably the same font size and font used in the final pu
|
What best practices should I follow when preparing plots?
In addition to conveying a clear message I always try to remember the plotsmanship:
font sizes for labels and legends should be big enough, preferably the same font size and font used in the final publication.
linewidths should be big enough (1 pt lines tend to disappear if plots are shrunk only slightly). I try to go to linewidths of 3 to 5 pt.
if plotting multiple datasets/curves with color make sure that they can be understood if printed in black-and-white, e.g. by using different symbols or linestyles in addition to color.
always use a lossless (or close to lossless) format, e.g. a vector format like pdf, ps or svg or high resolution png or gif (jpeg doesn't work at all and was never designed for line art).
prepare graphics in the final aspect ratio to be used in the publication. Changing the aspect ratio later can give irritating font or symbol shapes.
always remove useless clutter from the plotting program like unused histogram information, trend lines (hardly useful) or default titles.
I have configured my plotting software (matplotlib, ROOT or root2matplotlib) to do most of this right by default. Before I was using gnuplot which needed extra care here.
|
What best practices should I follow when preparing plots?
In addition to conveying a clear message I always try to remember the plotsmanship:
font sizes for labels and legends should be big enough, preferably the same font size and font used in the final pu
|
5,766
|
What best practices should I follow when preparing plots?
|
Take a look at the R graphics library, ggplot2. Details are at the web page http://had.co.nz/ggplot2/ This package generates very good default plots, that follow the Tufte principles, Cleveland's guidelines and Ihaka's color package.
|
What best practices should I follow when preparing plots?
|
Take a look at the R graphics library, ggplot2. Details are at the web page http://had.co.nz/ggplot2/ This package generates very good default plots, that follow the Tufte principles, Cleveland's guid
|
What best practices should I follow when preparing plots?
Take a look at the R graphics library, ggplot2. Details are at the web page http://had.co.nz/ggplot2/ This package generates very good default plots, that follow the Tufte principles, Cleveland's guidelines and Ihaka's color package.
|
What best practices should I follow when preparing plots?
Take a look at the R graphics library, ggplot2. Details are at the web page http://had.co.nz/ggplot2/ This package generates very good default plots, that follow the Tufte principles, Cleveland's guid
|
5,767
|
What best practices should I follow when preparing plots?
|
If plotting in color, consider that colorblind people may have trouble distinguishing elements by color alone. So:
Use line styles to distinguish lines.
Use extra weight in elements, make linewidth at least 2 pt, etc.
Use different markers as well as colors to distinguish points.
Use labels and annotations, referring to position and style also.
When referring to plot elements in text, describe them by color, relative position and style: "the red, upper, dash-dot curve"
Use a colorblind friendly palette. See this, this. I have a simple python implementation of the palette in the last reference at code.google.com, look for python-cudtools
|
What best practices should I follow when preparing plots?
|
If plotting in color, consider that colorblind people may have trouble distinguishing elements by color alone. So:
Use line styles to distinguish lines.
Use extra weight in elements, make linewidth a
|
What best practices should I follow when preparing plots?
If plotting in color, consider that colorblind people may have trouble distinguishing elements by color alone. So:
Use line styles to distinguish lines.
Use extra weight in elements, make linewidth at least 2 pt, etc.
Use different markers as well as colors to distinguish points.
Use labels and annotations, referring to position and style also.
When referring to plot elements in text, describe them by color, relative position and style: "the red, upper, dash-dot curve"
Use a colorblind friendly palette. See this, this. I have a simple python implementation of the palette in the last reference at code.google.com, look for python-cudtools
|
What best practices should I follow when preparing plots?
If plotting in color, consider that colorblind people may have trouble distinguishing elements by color alone. So:
Use line styles to distinguish lines.
Use extra weight in elements, make linewidth a
|
5,768
|
What best practices should I follow when preparing plots?
|
Here are my guidelines, based on the most common errors I see (in addition to all the other good points mentioned)
Use scatter graphs, not line plots, if element order is not relevant.
When preparing plots that are meant to be compared, use the same scale factor for all of them.
Even better - find a way to combine the data in a single graph (eg: boxplots are a better than several histograms to compare a large number of distributions).
Do not forget to specify units
Use a legend only if you must - it's generally clearer to label curves directly.
If you must use a legend, move it inside the plot, in a blank area.
For line graphs, aim for an aspect ratio which yields lines that are roughly at 45o with the page.
|
What best practices should I follow when preparing plots?
|
Here are my guidelines, based on the most common errors I see (in addition to all the other good points mentioned)
Use scatter graphs, not line plots, if element order is not relevant.
When preparing
|
What best practices should I follow when preparing plots?
Here are my guidelines, based on the most common errors I see (in addition to all the other good points mentioned)
Use scatter graphs, not line plots, if element order is not relevant.
When preparing plots that are meant to be compared, use the same scale factor for all of them.
Even better - find a way to combine the data in a single graph (eg: boxplots are a better than several histograms to compare a large number of distributions).
Do not forget to specify units
Use a legend only if you must - it's generally clearer to label curves directly.
If you must use a legend, move it inside the plot, in a blank area.
For line graphs, aim for an aspect ratio which yields lines that are roughly at 45o with the page.
|
What best practices should I follow when preparing plots?
Here are my guidelines, based on the most common errors I see (in addition to all the other good points mentioned)
Use scatter graphs, not line plots, if element order is not relevant.
When preparing
|
5,769
|
What best practices should I follow when preparing plots?
|
These are wonderful suggestions. We have assembled a lot of materials here. A group of statisticians in the pharma industry, academia, and FDA have also creating a resource that are useful for clinical trials and related research here$^\dagger.$
My personal favorite graphics book is Elements of Graphing Data by William Cleveland.
In terms of software, in my opinion it is hard to beat R's ggplot2 and plotly. Stata also supports some excellent graphics.
$\dagger$ The site is unfortunately temporarily down.
|
What best practices should I follow when preparing plots?
|
These are wonderful suggestions. We have assembled a lot of materials here. A group of statisticians in the pharma industry, academia, and FDA have also creating a resource that are useful for clini
|
What best practices should I follow when preparing plots?
These are wonderful suggestions. We have assembled a lot of materials here. A group of statisticians in the pharma industry, academia, and FDA have also creating a resource that are useful for clinical trials and related research here$^\dagger.$
My personal favorite graphics book is Elements of Graphing Data by William Cleveland.
In terms of software, in my opinion it is hard to beat R's ggplot2 and plotly. Stata also supports some excellent graphics.
$\dagger$ The site is unfortunately temporarily down.
|
What best practices should I follow when preparing plots?
These are wonderful suggestions. We have assembled a lot of materials here. A group of statisticians in the pharma industry, academia, and FDA have also creating a resource that are useful for clini
|
5,770
|
What best practices should I follow when preparing plots?
|
It also depends on where you wan't to publish your plots. You'll save yourself a lot of trouble by consulting the guide for authors before making any plots for a journal.
Also save the plots in a format that is easy to modify or save the code you have used to create them. Chances are that you need to make corrections.
|
What best practices should I follow when preparing plots?
|
It also depends on where you wan't to publish your plots. You'll save yourself a lot of trouble by consulting the guide for authors before making any plots for a journal.
Also save the plots in a for
|
What best practices should I follow when preparing plots?
It also depends on where you wan't to publish your plots. You'll save yourself a lot of trouble by consulting the guide for authors before making any plots for a journal.
Also save the plots in a format that is easy to modify or save the code you have used to create them. Chances are that you need to make corrections.
|
What best practices should I follow when preparing plots?
It also depends on where you wan't to publish your plots. You'll save yourself a lot of trouble by consulting the guide for authors before making any plots for a journal.
Also save the plots in a for
|
5,771
|
What best practices should I follow when preparing plots?
|
Don't use dynamite plots:
http://pablomarin-garcia.blogspot.com/2010/02/why-dynamite-plots-are-bad.html, use violin plots or similar (boxplots family)
|
What best practices should I follow when preparing plots?
|
Don't use dynamite plots:
http://pablomarin-garcia.blogspot.com/2010/02/why-dynamite-plots-are-bad.html, use violin plots or similar (boxplots family)
|
What best practices should I follow when preparing plots?
Don't use dynamite plots:
http://pablomarin-garcia.blogspot.com/2010/02/why-dynamite-plots-are-bad.html, use violin plots or similar (boxplots family)
|
What best practices should I follow when preparing plots?
Don't use dynamite plots:
http://pablomarin-garcia.blogspot.com/2010/02/why-dynamite-plots-are-bad.html, use violin plots or similar (boxplots family)
|
5,772
|
What best practices should I follow when preparing plots?
|
One thing that I seem to remember Tufte mentioning, that isn't in the other answers is mapping - that is, make position, direction, size, etc. on your graph represent reality. What is up on the graph should be up in the real world. What is big should be big (keeping in mind that areas should represent areas, and volumes volumes. Never try to represent a scalar value by an area, it's highly ambiguous!). This also applies to colours, shapes, etc, if they are relevant.
An interesting example is the "skirt series" graph here:
http://a-little-book-of-r-for-time-series.readthedocs.org/en/latest/src/timeseries.html.
While technically it's correct, and a "taller" skirt length occupies a higher position on the graph, it's actually quite confusing, because skirt length starts from the top, and goes down (unlike humans, or trees, where we measure the height from the ground). So increased skirt length actually represents a lower value:
skirts <- scan("http://robjhyndman.com/tsdldata/roberts/skirts.dat",skip=5)
skirtsseries <- ts(skirts, start=c(1866))
plot.ts(skirtsseries, ylim=c(max(skirts), min(skirts)))
There are, as always, difficulties. For example, we generally consider time to move forward, and in the west, at least, we read left to right, so our time-series graphs also usually flow left to right as time increases. So what happens if you want to represent something that's best represented laterally (e.g. east-west measurements of something), over time? In that case, you have to compromise, and either portray time a moving up or down (which one depends again on cultural perceptions, I guess), or choose to map your lateral variable to up/down on your graph.
|
What best practices should I follow when preparing plots?
|
One thing that I seem to remember Tufte mentioning, that isn't in the other answers is mapping - that is, make position, direction, size, etc. on your graph represent reality. What is up on the graph
|
What best practices should I follow when preparing plots?
One thing that I seem to remember Tufte mentioning, that isn't in the other answers is mapping - that is, make position, direction, size, etc. on your graph represent reality. What is up on the graph should be up in the real world. What is big should be big (keeping in mind that areas should represent areas, and volumes volumes. Never try to represent a scalar value by an area, it's highly ambiguous!). This also applies to colours, shapes, etc, if they are relevant.
An interesting example is the "skirt series" graph here:
http://a-little-book-of-r-for-time-series.readthedocs.org/en/latest/src/timeseries.html.
While technically it's correct, and a "taller" skirt length occupies a higher position on the graph, it's actually quite confusing, because skirt length starts from the top, and goes down (unlike humans, or trees, where we measure the height from the ground). So increased skirt length actually represents a lower value:
skirts <- scan("http://robjhyndman.com/tsdldata/roberts/skirts.dat",skip=5)
skirtsseries <- ts(skirts, start=c(1866))
plot.ts(skirtsseries, ylim=c(max(skirts), min(skirts)))
There are, as always, difficulties. For example, we generally consider time to move forward, and in the west, at least, we read left to right, so our time-series graphs also usually flow left to right as time increases. So what happens if you want to represent something that's best represented laterally (e.g. east-west measurements of something), over time? In that case, you have to compromise, and either portray time a moving up or down (which one depends again on cultural perceptions, I guess), or choose to map your lateral variable to up/down on your graph.
|
What best practices should I follow when preparing plots?
One thing that I seem to remember Tufte mentioning, that isn't in the other answers is mapping - that is, make position, direction, size, etc. on your graph represent reality. What is up on the graph
|
5,773
|
What best practices should I follow when preparing plots?
|
I would add that the choice of plot should reflect the type of statistical test used to analyse the data. In other words, whatever characteristics of the data were used for analysis should be shown visually - so you would show means and standard errors if you used a t-test but boxplots if you used a Mann-Whitney test.
|
What best practices should I follow when preparing plots?
|
I would add that the choice of plot should reflect the type of statistical test used to analyse the data. In other words, whatever characteristics of the data were used for analysis should be shown v
|
What best practices should I follow when preparing plots?
I would add that the choice of plot should reflect the type of statistical test used to analyse the data. In other words, whatever characteristics of the data were used for analysis should be shown visually - so you would show means and standard errors if you used a t-test but boxplots if you used a Mann-Whitney test.
|
What best practices should I follow when preparing plots?
I would add that the choice of plot should reflect the type of statistical test used to analyse the data. In other words, whatever characteristics of the data were used for analysis should be shown v
|
5,774
|
What best practices should I follow when preparing plots?
|
The other answers are too formulaic to be convincing, so let me give a more general answer. I've struggled with this question for a while. I offer this process:
Know your message
Know your audience
Know your constraints
Tailor your message to your audience given your constraints
I am skeptical of blanket claims such as "keep it simple" -- what does that mean? Well, it depends on the audience. Some audiences will eat up the Tufte style. But some audiences appreciate a little chart junk now and then. Some people are bored by scatterplots. Some people like colorful backgrounds. Is it so wrong to engage them a little bit even if you compromise "aesthetic" purity? That is up to you to decide.
Your audience's reaction will be an important piece of feedback, but not the only one. If you find a way to measure their understanding before and after your presentation, then you will start to understand the impact you've made.
The "right" answer will depend upon these sorts of questions:
What media will you be using?
Are you creating static or interactive plots?
Are you trying to tell a pre-defined story (exposition) or encourage experimentation (exploration)?
To what degree do you want the audience to draw their own conclusions?
To what degree to you want the audience to follow along with and be convinced by your story?
To what degree to you want the audience to challenge your findings?
In summary, design your materials deliberately given your message, audience, and constraints.
|
What best practices should I follow when preparing plots?
|
The other answers are too formulaic to be convincing, so let me give a more general answer. I've struggled with this question for a while. I offer this process:
Know your message
Know your audience
K
|
What best practices should I follow when preparing plots?
The other answers are too formulaic to be convincing, so let me give a more general answer. I've struggled with this question for a while. I offer this process:
Know your message
Know your audience
Know your constraints
Tailor your message to your audience given your constraints
I am skeptical of blanket claims such as "keep it simple" -- what does that mean? Well, it depends on the audience. Some audiences will eat up the Tufte style. But some audiences appreciate a little chart junk now and then. Some people are bored by scatterplots. Some people like colorful backgrounds. Is it so wrong to engage them a little bit even if you compromise "aesthetic" purity? That is up to you to decide.
Your audience's reaction will be an important piece of feedback, but not the only one. If you find a way to measure their understanding before and after your presentation, then you will start to understand the impact you've made.
The "right" answer will depend upon these sorts of questions:
What media will you be using?
Are you creating static or interactive plots?
Are you trying to tell a pre-defined story (exposition) or encourage experimentation (exploration)?
To what degree do you want the audience to draw their own conclusions?
To what degree to you want the audience to follow along with and be convinced by your story?
To what degree to you want the audience to challenge your findings?
In summary, design your materials deliberately given your message, audience, and constraints.
|
What best practices should I follow when preparing plots?
The other answers are too formulaic to be convincing, so let me give a more general answer. I've struggled with this question for a while. I offer this process:
Know your message
Know your audience
K
|
5,775
|
What best practices should I follow when preparing plots?
|
It depends on the way in which the plots will be discussed.
For instance, if I'm sending out plots for a group meeting that will be done with callers from different locations, I prefer putting them together in Powerpoint as opposed to Excel, so it's easier to flip around.
For one-on-one technical calls, I'll put something in excel so that the client be able to move a plot aside, and view the raw data. Or, I can enter p-values into cells along side regression coefficients, e.g.
Keep in mind: plots are cheap, especially for a slide show, or for emailing to a group. I'd rather make 10 clear plots that we can flip through than 5 plots where I try to put distinct cohorts (e.g. "males and females") on the same graph.
|
What best practices should I follow when preparing plots?
|
It depends on the way in which the plots will be discussed.
For instance, if I'm sending out plots for a group meeting that will be done with callers from different locations, I prefer putting them t
|
What best practices should I follow when preparing plots?
It depends on the way in which the plots will be discussed.
For instance, if I'm sending out plots for a group meeting that will be done with callers from different locations, I prefer putting them together in Powerpoint as opposed to Excel, so it's easier to flip around.
For one-on-one technical calls, I'll put something in excel so that the client be able to move a plot aside, and view the raw data. Or, I can enter p-values into cells along side regression coefficients, e.g.
Keep in mind: plots are cheap, especially for a slide show, or for emailing to a group. I'd rather make 10 clear plots that we can flip through than 5 plots where I try to put distinct cohorts (e.g. "males and females") on the same graph.
|
What best practices should I follow when preparing plots?
It depends on the way in which the plots will be discussed.
For instance, if I'm sending out plots for a group meeting that will be done with callers from different locations, I prefer putting them t
|
5,776
|
What best practices should I follow when preparing plots?
|
Here are my personal best practices (subjective):
Generally important:
Settle for a main message and try to most easily and effectively communicate it
Name your plot axes appropriately, e.g., „hours“, „dollars“, „dollars per hour“
If the axes titles do not already make it fully clear, indicate what unit the axis is representing, e.g., „Expenditure (in percentage of total daily USD spending)“
If your axis scales have a zero position, include it, e.g., in a bar chart with the height representing the count of items or for monetary values
If you use transformed axes, clearly indicate this, e.g., for a log-scale transformation
Use colours to encode information (nowadays, even scientific journal usually print in colour), e.g., food price series in „orange“ and energy price series in „blue“, if you compare two time series of prices
Remember that colours invoke emotions, e.g., „red“ for losses and bad events, „green“ for positive things
People are naturally drawn to bright colours and bold things first in a graph, so encode the most important thing for your main message in the brightest colour, e.g., they will usually spot the red line first and the rest of the plot only later
Otherwise, we (usually) read from left to right, up to down, so place the most important things in a title or graph ideally on the left-upper side
Always include a legend if you use colours
Remember that some people are colour blind
Only use 3-dimensional plots if the third dimension is necessary to convey your message
For bar charts: if you have categorical values on the x-axis and (many) text labels describing these, simply flip your axes so the text labels are on the y-axis instead
Use annotations and text labels to emphasize important values
Most important: do not use pie charts (never ever ;)), but bar charts instead (percentage values in pie charts are hard to read for us humans)
Depending on your audience:
Applied: Use action titles for your main message, e.g., „Prices increased five-fold due to supply chain issues“
Applied: Tell a story with one or multiple plots
Scientific: Neutrally describe what your graph is showing (descriptive language)
Scientific: Leave it to the reader to assess the evidence in the graph and come to a conclusion
|
What best practices should I follow when preparing plots?
|
Here are my personal best practices (subjective):
Generally important:
Settle for a main message and try to most easily and effectively communicate it
Name your plot axes appropriately, e.g., „hours
|
What best practices should I follow when preparing plots?
Here are my personal best practices (subjective):
Generally important:
Settle for a main message and try to most easily and effectively communicate it
Name your plot axes appropriately, e.g., „hours“, „dollars“, „dollars per hour“
If the axes titles do not already make it fully clear, indicate what unit the axis is representing, e.g., „Expenditure (in percentage of total daily USD spending)“
If your axis scales have a zero position, include it, e.g., in a bar chart with the height representing the count of items or for monetary values
If you use transformed axes, clearly indicate this, e.g., for a log-scale transformation
Use colours to encode information (nowadays, even scientific journal usually print in colour), e.g., food price series in „orange“ and energy price series in „blue“, if you compare two time series of prices
Remember that colours invoke emotions, e.g., „red“ for losses and bad events, „green“ for positive things
People are naturally drawn to bright colours and bold things first in a graph, so encode the most important thing for your main message in the brightest colour, e.g., they will usually spot the red line first and the rest of the plot only later
Otherwise, we (usually) read from left to right, up to down, so place the most important things in a title or graph ideally on the left-upper side
Always include a legend if you use colours
Remember that some people are colour blind
Only use 3-dimensional plots if the third dimension is necessary to convey your message
For bar charts: if you have categorical values on the x-axis and (many) text labels describing these, simply flip your axes so the text labels are on the y-axis instead
Use annotations and text labels to emphasize important values
Most important: do not use pie charts (never ever ;)), but bar charts instead (percentage values in pie charts are hard to read for us humans)
Depending on your audience:
Applied: Use action titles for your main message, e.g., „Prices increased five-fold due to supply chain issues“
Applied: Tell a story with one or multiple plots
Scientific: Neutrally describe what your graph is showing (descriptive language)
Scientific: Leave it to the reader to assess the evidence in the graph and come to a conclusion
|
What best practices should I follow when preparing plots?
Here are my personal best practices (subjective):
Generally important:
Settle for a main message and try to most easily and effectively communicate it
Name your plot axes appropriately, e.g., „hours
|
5,777
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying function in econometrics?
|
In the context of linear regression in the social sciences, Gelman and Hill write[1]:
We prefer natural logs (that is, logarithms base $e$) because, as
described above, coefficients on the natural-log scale are directly
interpretable as approximate proportional differences: with a
coefficient of 0.06, a difference of 1 in $x$ corresponds to an
approximate 6% difference in $y$, and so forth.
[1] Andrew Gelman and Jennifer Hill (2007). Data Analysis using Regression and Multilevel/Hierarchical Models. Cambridge University Press: Cambridge; New York, pp. 60-61.
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying functi
|
In the context of linear regression in the social sciences, Gelman and Hill write[1]:
We prefer natural logs (that is, logarithms base $e$) because, as
described above, coefficients on the natural-
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying function in econometrics?
In the context of linear regression in the social sciences, Gelman and Hill write[1]:
We prefer natural logs (that is, logarithms base $e$) because, as
described above, coefficients on the natural-log scale are directly
interpretable as approximate proportional differences: with a
coefficient of 0.06, a difference of 1 in $x$ corresponds to an
approximate 6% difference in $y$, and so forth.
[1] Andrew Gelman and Jennifer Hill (2007). Data Analysis using Regression and Multilevel/Hierarchical Models. Cambridge University Press: Cambridge; New York, pp. 60-61.
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying functi
In the context of linear regression in the social sciences, Gelman and Hill write[1]:
We prefer natural logs (that is, logarithms base $e$) because, as
described above, coefficients on the natural-
|
5,778
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying function in econometrics?
|
There is no very strong reason for preferring natural logarithms. Suppose we are estimating the model:
ln Y = a + b ln X
The relation between natural (ln) and base 10 (log) logarithms is ln X = 2.303 log X (source). Hence the model is equivalent to:
2.303 log Y = a + 2.303b log X
or, putting a / 2.303 = a*:
log Y = a* + b log X
Either form of the model could be estimated, with equivalent results.
A slight advantage of natural logarithms is that their first differential is simpler: d(ln X)/dX = 1/X, while d(log X)/dX = 1 / ((ln 10)X) (source).
For a source in an econometrics textbook saying that either form of logarithms could be used, see Gujarati, Essentials of Econometrics 3rd edition 2006 p 288.
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying functi
|
There is no very strong reason for preferring natural logarithms. Suppose we are estimating the model:
ln Y = a + b ln X
The relation between natural (ln) and base 10 (log) logarithms is ln X = 2.30
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying function in econometrics?
There is no very strong reason for preferring natural logarithms. Suppose we are estimating the model:
ln Y = a + b ln X
The relation between natural (ln) and base 10 (log) logarithms is ln X = 2.303 log X (source). Hence the model is equivalent to:
2.303 log Y = a + 2.303b log X
or, putting a / 2.303 = a*:
log Y = a* + b log X
Either form of the model could be estimated, with equivalent results.
A slight advantage of natural logarithms is that their first differential is simpler: d(ln X)/dX = 1/X, while d(log X)/dX = 1 / ((ln 10)X) (source).
For a source in an econometrics textbook saying that either form of logarithms could be used, see Gujarati, Essentials of Econometrics 3rd edition 2006 p 288.
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying functi
There is no very strong reason for preferring natural logarithms. Suppose we are estimating the model:
ln Y = a + b ln X
The relation between natural (ln) and base 10 (log) logarithms is ln X = 2.30
|
5,779
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying function in econometrics?
|
I think that the natural logarithm is used because the exponential is often used when doing interest/growth calculation.
If you are in continuous time and that you are compounding interests, you will end up having a future value of a certain sum equal to $F(t)=N.e^{rt}$ (where r is the interest rate and N the nominal amount of the sum).
Since you end up with exponential in the calculus, the best way to get rid of it is by using the natural logarithm and if you do the inverse operation, the natural log will give you the time needed to reach a certain growth.
Also, the good thing about logarithms (be it natural or not) is the fact that you can turn multiplications into additions.
As for mathematical explanations of why we end up using an exponential when compounding interest, you can find it here:http://en.wikipedia.org/wiki/Continuously_compounded_interest#Periodic_compounding
Basically, you need to take the limit to have an infinite number of interest rate payment, which ends up being the definition of exponential
Even thought, continuous time is not widely used in real life (you pay your mortgages with monthly payments, not every seconds..), that kind of calculation is often used by quantitative analysts.
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying functi
|
I think that the natural logarithm is used because the exponential is often used when doing interest/growth calculation.
If you are in continuous time and that you are compounding interests, you will
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying function in econometrics?
I think that the natural logarithm is used because the exponential is often used when doing interest/growth calculation.
If you are in continuous time and that you are compounding interests, you will end up having a future value of a certain sum equal to $F(t)=N.e^{rt}$ (where r is the interest rate and N the nominal amount of the sum).
Since you end up with exponential in the calculus, the best way to get rid of it is by using the natural logarithm and if you do the inverse operation, the natural log will give you the time needed to reach a certain growth.
Also, the good thing about logarithms (be it natural or not) is the fact that you can turn multiplications into additions.
As for mathematical explanations of why we end up using an exponential when compounding interest, you can find it here:http://en.wikipedia.org/wiki/Continuously_compounded_interest#Periodic_compounding
Basically, you need to take the limit to have an infinite number of interest rate payment, which ends up being the definition of exponential
Even thought, continuous time is not widely used in real life (you pay your mortgages with monthly payments, not every seconds..), that kind of calculation is often used by quantitative analysts.
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying functi
I think that the natural logarithm is used because the exponential is often used when doing interest/growth calculation.
If you are in continuous time and that you are compounding interests, you will
|
5,780
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying function in econometrics?
|
An additional reason why economists like to use regressions with logarithmic functional forms is an economic one: Coefficients can be understood as elasticities of a Cobb-Douglas function. This function is probably the most common one used among economists to analyze issues regarding microeconomic behaviour (consumers´preferences, technology, production functions) and macroeconomic issues (economic growth). The elasticity term is used to describe the degree of response of a change of a variable with respect to another.
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying functi
|
An additional reason why economists like to use regressions with logarithmic functional forms is an economic one: Coefficients can be understood as elasticities of a Cobb-Douglas function. This functi
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying function in econometrics?
An additional reason why economists like to use regressions with logarithmic functional forms is an economic one: Coefficients can be understood as elasticities of a Cobb-Douglas function. This function is probably the most common one used among economists to analyze issues regarding microeconomic behaviour (consumers´preferences, technology, production functions) and macroeconomic issues (economic growth). The elasticity term is used to describe the degree of response of a change of a variable with respect to another.
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying functi
An additional reason why economists like to use regressions with logarithmic functional forms is an economic one: Coefficients can be understood as elasticities of a Cobb-Douglas function. This functi
|
5,781
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying function in econometrics?
|
The only reason is that the Taylor expansion, gives an intuitive interpretation of the result.
Let's look at a typical variable used in econometrics a lot, the log difference of GDP:
$$\Delta \ln Y_t=\ln Y_t-\ln Y_{t-1}=\ln\frac{Y_{t}}{Y_{t-1}}=\ln\left(1+\frac{\Delta Y_t}{Y_{t-1}}\right)$$
, where $\frac{\Delta Y_t}{Y_{t-1}}$ is GDP growth rate now.
Let's apply Taylor expansion of the log:
$$\Delta\ln Y_t\approx\frac{\Delta Y_t}{Y_{t-1}}-\frac 1 2 \left(\frac{\Delta Y_t}{Y_{t-1}}\right)^2+\dots$$
Since, GDP growth rate is usually small, e.g. for USA around 2% lately, we can drop all the higher order terms then we get:
$$\Delta\ln Y_t\approx\frac{\Delta Y_t}{Y_{t-1}}$$
So, if you're using the log differences of GDP in the right hand side of the equation, e.g. as an explanatory variable in the regression you may have the following:
$$\dots=\dots+\beta\times\Delta\ln Y_t$$
which can be interpreted as "$\beta$ times percentage change in GDP."
Economists like the variables that can be interpreted easily. If you plugged the different log base then the interpretability is weaker. For example, see what happens to the log base 10:
$$\dots=\dots+\beta\times\Delta\log_{10} Y_t\\
\approx\dots+\beta\times\frac 1 {\ln(10)}\frac{\Delta Y_t}{Y_{t-1}}$$
This still works, but now you need to divide $\beta$ by some unintuitive number to get the "percentage change" effect interpretation.
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying functi
|
The only reason is that the Taylor expansion, gives an intuitive interpretation of the result.
Let's look at a typical variable used in econometrics a lot, the log difference of GDP:
$$\Delta \ln Y_t
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying function in econometrics?
The only reason is that the Taylor expansion, gives an intuitive interpretation of the result.
Let's look at a typical variable used in econometrics a lot, the log difference of GDP:
$$\Delta \ln Y_t=\ln Y_t-\ln Y_{t-1}=\ln\frac{Y_{t}}{Y_{t-1}}=\ln\left(1+\frac{\Delta Y_t}{Y_{t-1}}\right)$$
, where $\frac{\Delta Y_t}{Y_{t-1}}$ is GDP growth rate now.
Let's apply Taylor expansion of the log:
$$\Delta\ln Y_t\approx\frac{\Delta Y_t}{Y_{t-1}}-\frac 1 2 \left(\frac{\Delta Y_t}{Y_{t-1}}\right)^2+\dots$$
Since, GDP growth rate is usually small, e.g. for USA around 2% lately, we can drop all the higher order terms then we get:
$$\Delta\ln Y_t\approx\frac{\Delta Y_t}{Y_{t-1}}$$
So, if you're using the log differences of GDP in the right hand side of the equation, e.g. as an explanatory variable in the regression you may have the following:
$$\dots=\dots+\beta\times\Delta\ln Y_t$$
which can be interpreted as "$\beta$ times percentage change in GDP."
Economists like the variables that can be interpreted easily. If you plugged the different log base then the interpretability is weaker. For example, see what happens to the log base 10:
$$\dots=\dots+\beta\times\Delta\log_{10} Y_t\\
\approx\dots+\beta\times\frac 1 {\ln(10)}\frac{\Delta Y_t}{Y_{t-1}}$$
This still works, but now you need to divide $\beta$ by some unintuitive number to get the "percentage change" effect interpretation.
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying functi
The only reason is that the Taylor expansion, gives an intuitive interpretation of the result.
Let's look at a typical variable used in econometrics a lot, the log difference of GDP:
$$\Delta \ln Y_t
|
5,782
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying function in econometrics?
|
Is this unique to economics? The standard normal distribution features an $e^{-{1\over2}x^2}$ in it, and the normal distribution is only one of the large family of exponential distributions that cover a huge swath of statistics. (See GLM's.) It seems like the natural log would be useful in these cases.
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying functi
|
Is this unique to economics? The standard normal distribution features an $e^{-{1\over2}x^2}$ in it, and the normal distribution is only one of the large family of exponential distributions that cover
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying function in econometrics?
Is this unique to economics? The standard normal distribution features an $e^{-{1\over2}x^2}$ in it, and the normal distribution is only one of the large family of exponential distributions that cover a huge swath of statistics. (See GLM's.) It seems like the natural log would be useful in these cases.
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying functi
Is this unique to economics? The standard normal distribution features an $e^{-{1\over2}x^2}$ in it, and the normal distribution is only one of the large family of exponential distributions that cover
|
5,783
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying function in econometrics?
|
There is a good reason to use the log transformation of the variable if you think that the inverse function of logarithm is the exponential function which is a continuous version of conpounding. The economic variable which is growing around 10% at a time can be transformed to the variable with its mean around 10 (plus a constant). You cannot do that with the transformation of logarithm of different base.
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying functi
|
There is a good reason to use the log transformation of the variable if you think that the inverse function of logarithm is the exponential function which is a continuous version of conpounding. The e
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying function in econometrics?
There is a good reason to use the log transformation of the variable if you think that the inverse function of logarithm is the exponential function which is a continuous version of conpounding. The economic variable which is growing around 10% at a time can be transformed to the variable with its mean around 10 (plus a constant). You cannot do that with the transformation of logarithm of different base.
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying functi
There is a good reason to use the log transformation of the variable if you think that the inverse function of logarithm is the exponential function which is a continuous version of conpounding. The e
|
5,784
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying function in econometrics?
|
Not only in econometrics, using base $e$ is more "natural" in almost every domain, including computer science, where dominated by $0,1$ (where $\log_2$ may be natural).
I would like to use some experiments to show the base $e$ is very natural.
Consider following three functions $f_1(x)=2^x$, $f_{2}(x)=10^x$, $f_3(x)=e^x$, which one seems more natural? Many people may say first two seems better, because $2$ and $10$ are small integers, and $e$ is an irrational number.
However, consider following experiment, we want to investigate the relationship between the function's derivative at $x_0$ and the function value at $x_0$.
We pick two random points, say $1.23$ and $2.34$ and we will use $f_1$ as example.
Here are some facts:
$f_1'(1.23)=1.625894, ~f_1'(2.34)= 3.509423$
$f_1(1.23)=2.34567, ~f_1(2.34)=5.063026$
We see there are some patterns: if we calculate $f_1'(x_0)/f_1(x_0)$, it is a constant: $0.6931472 = \log(2)$.
For another function $f_2$, this constant is $2.302585 = \log(10)$. (I will attach the code for some fun experiments)
So, the natural question to ask is when we can get a simplified results, that do not need to scale with this constant (or this constant is equal to $1.0$)?
The answer is when the base is $e$. Where $f_3'(x)=f_3(x)$. Now, we may think base $e$ is more natural?
some code for fun experiments
# suppose we have some exponential functions
# because 2 and 10 are small integers f1, f2 seems pretty natural
f1 <- function(x) 2^x
# f2 <- function(x) 10^x
# simple code to calculate numeric gradient
simpleNumDiff <- function(f, x0){
(f(x0+1e-8)-f(x0))/1e-8
}
# we try to investigate derv value and function value pattern
# note, they are not equal but have very strong pattern
a1 = simpleNumDiff(f1,1.23)
b1 = f1(1.23)
a2 = simpleNumDiff(f1,2.34)
b2 = f1(2.34)
c(a1/b1,a2/b2) # log(2)
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying functi
|
Not only in econometrics, using base $e$ is more "natural" in almost every domain, including computer science, where dominated by $0,1$ (where $\log_2$ may be natural).
I would like to use some experi
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying function in econometrics?
Not only in econometrics, using base $e$ is more "natural" in almost every domain, including computer science, where dominated by $0,1$ (where $\log_2$ may be natural).
I would like to use some experiments to show the base $e$ is very natural.
Consider following three functions $f_1(x)=2^x$, $f_{2}(x)=10^x$, $f_3(x)=e^x$, which one seems more natural? Many people may say first two seems better, because $2$ and $10$ are small integers, and $e$ is an irrational number.
However, consider following experiment, we want to investigate the relationship between the function's derivative at $x_0$ and the function value at $x_0$.
We pick two random points, say $1.23$ and $2.34$ and we will use $f_1$ as example.
Here are some facts:
$f_1'(1.23)=1.625894, ~f_1'(2.34)= 3.509423$
$f_1(1.23)=2.34567, ~f_1(2.34)=5.063026$
We see there are some patterns: if we calculate $f_1'(x_0)/f_1(x_0)$, it is a constant: $0.6931472 = \log(2)$.
For another function $f_2$, this constant is $2.302585 = \log(10)$. (I will attach the code for some fun experiments)
So, the natural question to ask is when we can get a simplified results, that do not need to scale with this constant (or this constant is equal to $1.0$)?
The answer is when the base is $e$. Where $f_3'(x)=f_3(x)$. Now, we may think base $e$ is more natural?
some code for fun experiments
# suppose we have some exponential functions
# because 2 and 10 are small integers f1, f2 seems pretty natural
f1 <- function(x) 2^x
# f2 <- function(x) 10^x
# simple code to calculate numeric gradient
simpleNumDiff <- function(f, x0){
(f(x0+1e-8)-f(x0))/1e-8
}
# we try to investigate derv value and function value pattern
# note, they are not equal but have very strong pattern
a1 = simpleNumDiff(f1,1.23)
b1 = f1(1.23)
a2 = simpleNumDiff(f1,2.34)
b2 = f1(2.34)
c(a1/b1,a2/b2) # log(2)
|
What is the reason why we use natural logarithm (ln) rather than log to base 10 in specifying functi
Not only in econometrics, using base $e$ is more "natural" in almost every domain, including computer science, where dominated by $0,1$ (where $\log_2$ may be natural).
I would like to use some experi
|
5,785
|
How does cross-validation overcome the overfitting problem?
|
I can't think of a sufficiently clear explanation just at the moment, so I'll leave that to someone else; however cross-validation does not completely overcome the over-fitting problem in model selection, it just reduces it. The cross-validation error does not have a negligible variance, especially if the size of the dataset is small; in other words you get a slightly different value depending on the particular sample of data you use. This means that if you have many degrees of freedom in model selection (e.g. lots of features from which to select a small subset, many hyper-parameters to tune, many models from which to choose) you can over-fit the cross-validation criterion as the model is tuned in ways that exploit this random variation rather than in ways that really do improve performance, and you can end up with a model that performs poorly. For a discussion of this, see Cawley and Talbot "On Over-fitting in Model Selection and Subsequent Selection Bias in Performance Evaluation", JMLR, vol. 11, pp. 2079−2107, 2010
Sadly cross-validation is most likely to let you down when you have a small dataset, which is exactly when you need cross-validation the most. Note that k-fold cross-validation is generally more reliable than leave-one-out cross-validation as it has a lower variance, but may be more expensive to compute for some models (which is why LOOCV is sometimes used for model selection, even though it has a high variance).
|
How does cross-validation overcome the overfitting problem?
|
I can't think of a sufficiently clear explanation just at the moment, so I'll leave that to someone else; however cross-validation does not completely overcome the over-fitting problem in model select
|
How does cross-validation overcome the overfitting problem?
I can't think of a sufficiently clear explanation just at the moment, so I'll leave that to someone else; however cross-validation does not completely overcome the over-fitting problem in model selection, it just reduces it. The cross-validation error does not have a negligible variance, especially if the size of the dataset is small; in other words you get a slightly different value depending on the particular sample of data you use. This means that if you have many degrees of freedom in model selection (e.g. lots of features from which to select a small subset, many hyper-parameters to tune, many models from which to choose) you can over-fit the cross-validation criterion as the model is tuned in ways that exploit this random variation rather than in ways that really do improve performance, and you can end up with a model that performs poorly. For a discussion of this, see Cawley and Talbot "On Over-fitting in Model Selection and Subsequent Selection Bias in Performance Evaluation", JMLR, vol. 11, pp. 2079−2107, 2010
Sadly cross-validation is most likely to let you down when you have a small dataset, which is exactly when you need cross-validation the most. Note that k-fold cross-validation is generally more reliable than leave-one-out cross-validation as it has a lower variance, but may be more expensive to compute for some models (which is why LOOCV is sometimes used for model selection, even though it has a high variance).
|
How does cross-validation overcome the overfitting problem?
I can't think of a sufficiently clear explanation just at the moment, so I'll leave that to someone else; however cross-validation does not completely overcome the over-fitting problem in model select
|
5,786
|
How does cross-validation overcome the overfitting problem?
|
Not at all. However, cross validation helps you to assess by how much your method overfits.
For instance, if your training data R-squared of a regression is 0.50 and the crossvalidated R-squared is 0.48, you hardly have any overfitting and you feel good. On the other hand, if the crossvalidated R-squared is only 0.3 here, then a considerable part of your model performance comes due to overfitting and not from true relationships. In such a case you can either accept a lower performance or try different modelling strategies with less overfitting.
|
How does cross-validation overcome the overfitting problem?
|
Not at all. However, cross validation helps you to assess by how much your method overfits.
For instance, if your training data R-squared of a regression is 0.50 and the crossvalidated R-squared is 0
|
How does cross-validation overcome the overfitting problem?
Not at all. However, cross validation helps you to assess by how much your method overfits.
For instance, if your training data R-squared of a regression is 0.50 and the crossvalidated R-squared is 0.48, you hardly have any overfitting and you feel good. On the other hand, if the crossvalidated R-squared is only 0.3 here, then a considerable part of your model performance comes due to overfitting and not from true relationships. In such a case you can either accept a lower performance or try different modelling strategies with less overfitting.
|
How does cross-validation overcome the overfitting problem?
Not at all. However, cross validation helps you to assess by how much your method overfits.
For instance, if your training data R-squared of a regression is 0.50 and the crossvalidated R-squared is 0
|
5,787
|
How does cross-validation overcome the overfitting problem?
|
My answer is more intuitive than rigorous, but maybe it will help...
As I understand it, overfitting is the result of model selection based on training and testing using the same data, where you have a flexible fitting mechanism: you fit your sample of data so closely that you're fitting the noise, outliers, and all the other variance.
Splitting the data into a training and testing set keeps you from doing this. But a static split is not using your data efficiently and your split itself could be an issue. Cross-validation keeps the don't-reward-an-exact-fit-to-training-data advantage of the training-testing split, while also using the data that you have as efficiently as possible (i.e. all of your data is used as training and testing data, just not in the same run).
If you have a flexible fitting mechanism, you need to constrain your model selection so that it doesn't favor "perfect" but complex fits somehow. You can do it with AIC, BIC, or some other penalization method that penalizes fit complexity directly, or you can do it with CV. (Or you can do it by using a fitting method that is not very flexible, which is one reason linear models are nice.)
Another way of looking at it is that learning is about generalizing, and a fit that's too tight is in some sense not generalizing. By varying what you learn on and what you're tested on, you generalize better than if you only learned the answers to a specific set of questions.
|
How does cross-validation overcome the overfitting problem?
|
My answer is more intuitive than rigorous, but maybe it will help...
As I understand it, overfitting is the result of model selection based on training and testing using the same data, where you have
|
How does cross-validation overcome the overfitting problem?
My answer is more intuitive than rigorous, but maybe it will help...
As I understand it, overfitting is the result of model selection based on training and testing using the same data, where you have a flexible fitting mechanism: you fit your sample of data so closely that you're fitting the noise, outliers, and all the other variance.
Splitting the data into a training and testing set keeps you from doing this. But a static split is not using your data efficiently and your split itself could be an issue. Cross-validation keeps the don't-reward-an-exact-fit-to-training-data advantage of the training-testing split, while also using the data that you have as efficiently as possible (i.e. all of your data is used as training and testing data, just not in the same run).
If you have a flexible fitting mechanism, you need to constrain your model selection so that it doesn't favor "perfect" but complex fits somehow. You can do it with AIC, BIC, or some other penalization method that penalizes fit complexity directly, or you can do it with CV. (Or you can do it by using a fitting method that is not very flexible, which is one reason linear models are nice.)
Another way of looking at it is that learning is about generalizing, and a fit that's too tight is in some sense not generalizing. By varying what you learn on and what you're tested on, you generalize better than if you only learned the answers to a specific set of questions.
|
How does cross-validation overcome the overfitting problem?
My answer is more intuitive than rigorous, but maybe it will help...
As I understand it, overfitting is the result of model selection based on training and testing using the same data, where you have
|
5,788
|
How does cross-validation overcome the overfitting problem?
|
Cross-Validation is a good, but not perfect, technique to minimize over-fitting.
Cross-Validation will not perform well to outside data if the data you do have is not representative of the data you'll be trying to predict!
Here are two concrete situations when cross-validation has flaws:
You are using the past to predict the future: it is often a big assumption to assume that past observations will come from the same population with the same distribution as future observations. Cross-validating on a data set drawn from the past won't protect against this.
There is a bias in the data you collect: the data you observe is systematically different from the data you don't observed. For example, we know about respondent bias in those who chose to take a survey.
|
How does cross-validation overcome the overfitting problem?
|
Cross-Validation is a good, but not perfect, technique to minimize over-fitting.
Cross-Validation will not perform well to outside data if the data you do have is not representative of the data you'l
|
How does cross-validation overcome the overfitting problem?
Cross-Validation is a good, but not perfect, technique to minimize over-fitting.
Cross-Validation will not perform well to outside data if the data you do have is not representative of the data you'll be trying to predict!
Here are two concrete situations when cross-validation has flaws:
You are using the past to predict the future: it is often a big assumption to assume that past observations will come from the same population with the same distribution as future observations. Cross-validating on a data set drawn from the past won't protect against this.
There is a bias in the data you collect: the data you observe is systematically different from the data you don't observed. For example, we know about respondent bias in those who chose to take a survey.
|
How does cross-validation overcome the overfitting problem?
Cross-Validation is a good, but not perfect, technique to minimize over-fitting.
Cross-Validation will not perform well to outside data if the data you do have is not representative of the data you'l
|
5,789
|
How does cross-validation overcome the overfitting problem?
|
From a Bayesian perspective, I'm not so sure that cross validation does anything that a "proper" Bayesian analysis doesn't do for comparing models. But I am not 100% certain that it does.
This is because if you are comparing models in a Bayesian way, then you are essentially already doing cross validation. This is because the posterior odds of model A $M_A$ against model B $M_B$, with data $D$ and prior information $I$ has the following form:
$$\frac{P(M_A|D,I)}{P(M_B|D,I)}=\frac{P(M_A|I)}{P(M_B|I)}\times\frac{P(D|M_A,I)}{P(D|M_B,I)}$$
And $P(D|M_A,I)$ is given by:
$$P(D|M_A,I)=\int P(D,\theta_A|M_A,I)d\theta_A=\int P(\theta_A|M_A,I)P(D|M_A,\theta_A,I)d\theta_A$$
Which is called the prior predictive distribution. It basically says how well the model predicted the data that was actually observed, which is exactly what cross validation does, with the "prior" being replaced by the "training" model fitted, and the "data" being replace by the "testing" data. So if model B predicted the data better than model A, its posterior probability increases relative to model A. It seems from this that Bayes theorem will actually do cross validation using all the data, rather than a subset. However, I am not fully convinced of this - seems like we get something for nothing.
Another neat feature of this method is that it has an in built "occam's razor", given by the ratio of normalisation constants of the prior distributions for each model.
However cross validation seems valuable for the dreaded old "something else" or what is sometimes called "model mispecification". I am constantly torn by whether this "something else" matters or not, for it seems like it should matter - but it leaves you paralyzed with no solution at all when it apparently matters. Just something to give you a headache, but nothing you can do about it - except for thinking of what that "something else" might be, and trying it out in your model (so that it is no longer part of "something else").
And further, cross validation is a way to actually do a Bayesian analysis when the integrals above are ridiculously hard. And cross validation "makes sense" to just about anyone - it is "mechanical" rather than "mathematical". So it is easy to understand what is going on. And it also seems to get your head to focus on the important part of models - making good predictions.
|
How does cross-validation overcome the overfitting problem?
|
From a Bayesian perspective, I'm not so sure that cross validation does anything that a "proper" Bayesian analysis doesn't do for comparing models. But I am not 100% certain that it does.
This is bec
|
How does cross-validation overcome the overfitting problem?
From a Bayesian perspective, I'm not so sure that cross validation does anything that a "proper" Bayesian analysis doesn't do for comparing models. But I am not 100% certain that it does.
This is because if you are comparing models in a Bayesian way, then you are essentially already doing cross validation. This is because the posterior odds of model A $M_A$ against model B $M_B$, with data $D$ and prior information $I$ has the following form:
$$\frac{P(M_A|D,I)}{P(M_B|D,I)}=\frac{P(M_A|I)}{P(M_B|I)}\times\frac{P(D|M_A,I)}{P(D|M_B,I)}$$
And $P(D|M_A,I)$ is given by:
$$P(D|M_A,I)=\int P(D,\theta_A|M_A,I)d\theta_A=\int P(\theta_A|M_A,I)P(D|M_A,\theta_A,I)d\theta_A$$
Which is called the prior predictive distribution. It basically says how well the model predicted the data that was actually observed, which is exactly what cross validation does, with the "prior" being replaced by the "training" model fitted, and the "data" being replace by the "testing" data. So if model B predicted the data better than model A, its posterior probability increases relative to model A. It seems from this that Bayes theorem will actually do cross validation using all the data, rather than a subset. However, I am not fully convinced of this - seems like we get something for nothing.
Another neat feature of this method is that it has an in built "occam's razor", given by the ratio of normalisation constants of the prior distributions for each model.
However cross validation seems valuable for the dreaded old "something else" or what is sometimes called "model mispecification". I am constantly torn by whether this "something else" matters or not, for it seems like it should matter - but it leaves you paralyzed with no solution at all when it apparently matters. Just something to give you a headache, but nothing you can do about it - except for thinking of what that "something else" might be, and trying it out in your model (so that it is no longer part of "something else").
And further, cross validation is a way to actually do a Bayesian analysis when the integrals above are ridiculously hard. And cross validation "makes sense" to just about anyone - it is "mechanical" rather than "mathematical". So it is easy to understand what is going on. And it also seems to get your head to focus on the important part of models - making good predictions.
|
How does cross-validation overcome the overfitting problem?
From a Bayesian perspective, I'm not so sure that cross validation does anything that a "proper" Bayesian analysis doesn't do for comparing models. But I am not 100% certain that it does.
This is bec
|
5,790
|
How does cross-validation overcome the overfitting problem?
|
Also I can recomend these videos from the Stanford course in Statistical learning. These videos goes in quite depth regarding how to use cross-valudation effectively.
Cross-Validation and the Bootstrap (14:01)
K-fold Cross-Validation (13:33)
Cross-Validation: The Right and Wrong Ways (10:07)
|
How does cross-validation overcome the overfitting problem?
|
Also I can recomend these videos from the Stanford course in Statistical learning. These videos goes in quite depth regarding how to use cross-valudation effectively.
Cross-Validation and the Bootstra
|
How does cross-validation overcome the overfitting problem?
Also I can recomend these videos from the Stanford course in Statistical learning. These videos goes in quite depth regarding how to use cross-valudation effectively.
Cross-Validation and the Bootstrap (14:01)
K-fold Cross-Validation (13:33)
Cross-Validation: The Right and Wrong Ways (10:07)
|
How does cross-validation overcome the overfitting problem?
Also I can recomend these videos from the Stanford course in Statistical learning. These videos goes in quite depth regarding how to use cross-valudation effectively.
Cross-Validation and the Bootstra
|
5,791
|
Mean absolute percentage error (MAPE) in Scikit-learn [closed]
|
As noted (for example, in Wikipedia), MAPE can be problematic. Most pointedly, it can cause division-by-zero errors. My guess is that this is why it is not included in the sklearn metrics.
However, it is simple to implement.
from sklearn.utils import check_arrays
def mean_absolute_percentage_error(y_true, y_pred):
y_true, y_pred = check_arrays(y_true, y_pred)
## Note: does not handle mix 1d representation
#if _is_1d(y_true):
# y_true, y_pred = _check_1d_array(y_true, y_pred)
return np.mean(np.abs((y_true - y_pred) / y_true)) * 100
Use like any other metric...:
> y_true = [3, -0.5, 2, 7]; y_pred = [2.5, -0.3, 2, 8]
> mean_absolute_percentage_error(y_true, y_pred)
Out[19]: 17.738095238095237
(Note that I'm multiplying by 100 and returning a percentage.)
... but with caution:
> y_true = [3, 0.0, 2, 7]; y_pred = [2.5, -0.3, 2, 8]
> #Note the zero in y_pred
> mean_absolute_percentage_error(y_true, y_pred)
-c:8: RuntimeWarning: divide by zero encountered in divide
Out[21]: inf
|
Mean absolute percentage error (MAPE) in Scikit-learn [closed]
|
As noted (for example, in Wikipedia), MAPE can be problematic. Most pointedly, it can cause division-by-zero errors. My guess is that this is why it is not included in the sklearn metrics.
However, i
|
Mean absolute percentage error (MAPE) in Scikit-learn [closed]
As noted (for example, in Wikipedia), MAPE can be problematic. Most pointedly, it can cause division-by-zero errors. My guess is that this is why it is not included in the sklearn metrics.
However, it is simple to implement.
from sklearn.utils import check_arrays
def mean_absolute_percentage_error(y_true, y_pred):
y_true, y_pred = check_arrays(y_true, y_pred)
## Note: does not handle mix 1d representation
#if _is_1d(y_true):
# y_true, y_pred = _check_1d_array(y_true, y_pred)
return np.mean(np.abs((y_true - y_pred) / y_true)) * 100
Use like any other metric...:
> y_true = [3, -0.5, 2, 7]; y_pred = [2.5, -0.3, 2, 8]
> mean_absolute_percentage_error(y_true, y_pred)
Out[19]: 17.738095238095237
(Note that I'm multiplying by 100 and returning a percentage.)
... but with caution:
> y_true = [3, 0.0, 2, 7]; y_pred = [2.5, -0.3, 2, 8]
> #Note the zero in y_pred
> mean_absolute_percentage_error(y_true, y_pred)
-c:8: RuntimeWarning: divide by zero encountered in divide
Out[21]: inf
|
Mean absolute percentage error (MAPE) in Scikit-learn [closed]
As noted (for example, in Wikipedia), MAPE can be problematic. Most pointedly, it can cause division-by-zero errors. My guess is that this is why it is not included in the sklearn metrics.
However, i
|
5,792
|
Mean absolute percentage error (MAPE) in Scikit-learn [closed]
|
here is an updated version:
import numpy as np
def mean_absolute_percentage_error(y_true, y_pred):
y_true, y_pred = np.array(y_true), np.array(y_pred)
return np.mean(np.abs((y_true - y_pred) / y_true)) * 100
|
Mean absolute percentage error (MAPE) in Scikit-learn [closed]
|
here is an updated version:
import numpy as np
def mean_absolute_percentage_error(y_true, y_pred):
y_true, y_pred = np.array(y_true), np.array(y_pred)
return np.mean(np.abs((y_true - y_pred)
|
Mean absolute percentage error (MAPE) in Scikit-learn [closed]
here is an updated version:
import numpy as np
def mean_absolute_percentage_error(y_true, y_pred):
y_true, y_pred = np.array(y_true), np.array(y_pred)
return np.mean(np.abs((y_true - y_pred) / y_true)) * 100
|
Mean absolute percentage error (MAPE) in Scikit-learn [closed]
here is an updated version:
import numpy as np
def mean_absolute_percentage_error(y_true, y_pred):
y_true, y_pred = np.array(y_true), np.array(y_pred)
return np.mean(np.abs((y_true - y_pred)
|
5,793
|
Should covariates that are not statistically significant be 'kept in' when creating a model?
|
You have gotten several good answers already. There are reasons to keep covariates and reasons to drop covariates. Statistical significance should not be a key factor, in the vast majority of cases.
Covariates may be of such substantive importance that they have to be there.
The effect size of a covariate may be high, even if it is not significant.
The covariate may affect other aspects of the model.
The covariate may be a part of how your hypothesis was worded.
If you are in a very exploratory mode and the covariate is not important in the literature and the effect size is small and the covariate has little effect on your model and the covariate was not in your hypothesis, then you could probably delete it just for simplicity.
|
Should covariates that are not statistically significant be 'kept in' when creating a model?
|
You have gotten several good answers already. There are reasons to keep covariates and reasons to drop covariates. Statistical significance should not be a key factor, in the vast majority of cases.
|
Should covariates that are not statistically significant be 'kept in' when creating a model?
You have gotten several good answers already. There are reasons to keep covariates and reasons to drop covariates. Statistical significance should not be a key factor, in the vast majority of cases.
Covariates may be of such substantive importance that they have to be there.
The effect size of a covariate may be high, even if it is not significant.
The covariate may affect other aspects of the model.
The covariate may be a part of how your hypothesis was worded.
If you are in a very exploratory mode and the covariate is not important in the literature and the effect size is small and the covariate has little effect on your model and the covariate was not in your hypothesis, then you could probably delete it just for simplicity.
|
Should covariates that are not statistically significant be 'kept in' when creating a model?
You have gotten several good answers already. There are reasons to keep covariates and reasons to drop covariates. Statistical significance should not be a key factor, in the vast majority of cases.
|
5,794
|
Should covariates that are not statistically significant be 'kept in' when creating a model?
|
The long answer is "yes". There are few reasons to remove insignificant predictors and many reasons not to. As far as interpreting them you do so ignoring the $P$-value just as you might interpret other predictors: with confidence intervals for effects over interesting ranges of the predictor.
|
Should covariates that are not statistically significant be 'kept in' when creating a model?
|
The long answer is "yes". There are few reasons to remove insignificant predictors and many reasons not to. As far as interpreting them you do so ignoring the $P$-value just as you might interpret o
|
Should covariates that are not statistically significant be 'kept in' when creating a model?
The long answer is "yes". There are few reasons to remove insignificant predictors and many reasons not to. As far as interpreting them you do so ignoring the $P$-value just as you might interpret other predictors: with confidence intervals for effects over interesting ranges of the predictor.
|
Should covariates that are not statistically significant be 'kept in' when creating a model?
The long answer is "yes". There are few reasons to remove insignificant predictors and many reasons not to. As far as interpreting them you do so ignoring the $P$-value just as you might interpret o
|
5,795
|
Should covariates that are not statistically significant be 'kept in' when creating a model?
|
One useful insight is that there is really nothing specific about a covariate statistically speaking, see e.g. Help writing covariates into regression formula. Incidentally, it might explain why there is no covariate tag. Consequently, material here and elsewhere about non-significant terms in a linear model are relevant, as are the well known critics of stepwise regression, even if ANCOVA is not explicitly mentioned.
Generally speaking, it's a bad idea to select predictors based on significance alone. If for some reason you cannot specify the model in advance, you should consider other approaches but if you planned to include them in the first place, collected data accordingly and are not facing specific problems (e.g. collinearity), just keep them.
Regarding the reasons to keep them, the objections you came up with seem sound to me. Another reason would be that removing non-significant predictors biases inferences based on the model. Yet another way to look at all this is to ask what would be gained by removing these covariates after the fact.
|
Should covariates that are not statistically significant be 'kept in' when creating a model?
|
One useful insight is that there is really nothing specific about a covariate statistically speaking, see e.g. Help writing covariates into regression formula. Incidentally, it might explain why there
|
Should covariates that are not statistically significant be 'kept in' when creating a model?
One useful insight is that there is really nothing specific about a covariate statistically speaking, see e.g. Help writing covariates into regression formula. Incidentally, it might explain why there is no covariate tag. Consequently, material here and elsewhere about non-significant terms in a linear model are relevant, as are the well known critics of stepwise regression, even if ANCOVA is not explicitly mentioned.
Generally speaking, it's a bad idea to select predictors based on significance alone. If for some reason you cannot specify the model in advance, you should consider other approaches but if you planned to include them in the first place, collected data accordingly and are not facing specific problems (e.g. collinearity), just keep them.
Regarding the reasons to keep them, the objections you came up with seem sound to me. Another reason would be that removing non-significant predictors biases inferences based on the model. Yet another way to look at all this is to ask what would be gained by removing these covariates after the fact.
|
Should covariates that are not statistically significant be 'kept in' when creating a model?
One useful insight is that there is really nothing specific about a covariate statistically speaking, see e.g. Help writing covariates into regression formula. Incidentally, it might explain why there
|
5,796
|
Should covariates that are not statistically significant be 'kept in' when creating a model?
|
We really need more information about your goals to answer this question. Regressions are used for two main purposes:
Prediction
Inference
Prediction is when your goal is to be able to guess at values of the outcome variable for observations that are not in the sample (although usually they are within the range of the sample data–otherwise, we sometimes use the word "forecasting"). Prediction is useful for advertising purposes, finance, etc. If you are just interested in predicting some outcome variable, I have little to offer you.
Inference is where the fun is (even if it is not where the money is). Inference is where you are trying to make conclusions about specific model parameters–usually to determine a causal effect of one variable on another. Despite common perception, regression analysis is never sufficient for causal inference. You must always know more about the data generating process to know whether your regression captures the causal effect. The key issue for causal inference from regressions is whether the conditional mean of the error (conditional on the regressors) is zero. This cannot be known from p-values on regressors. It is possible to have regression estimators that are unbiased or consistent, but that requires far more effort than just throwing some obvious controls into the regression and hoping you got the important ones. The best coverage I have seen of approaching causal inference with observational data is in two books by Angrist and Pischke (Mastering 'Metrics: The Path from Cause to Effect and Mostly Harmless Econometrics). Mastering Metrics is the easier read and is quite cheap, but be warned that it is not a treatment of how to do regressions but rather of what they mean. For a good coverage of examples of good and bad observational research designs, I recommend David Freedman's (1991) "Statistical Models and Shoe Leather", Sociological Methodology, volume 21 (a short and easy read with fascinating examples).
Aside: the obsession with statistical technique over good research design in most college courses is a pedagogical peeve of mine.
Second aside to motivate the current importance of this issue: the difference between prediction and inference is why big data are not a substitute for science.
|
Should covariates that are not statistically significant be 'kept in' when creating a model?
|
We really need more information about your goals to answer this question. Regressions are used for two main purposes:
Prediction
Inference
Prediction is when your goal is to be able to guess at valu
|
Should covariates that are not statistically significant be 'kept in' when creating a model?
We really need more information about your goals to answer this question. Regressions are used for two main purposes:
Prediction
Inference
Prediction is when your goal is to be able to guess at values of the outcome variable for observations that are not in the sample (although usually they are within the range of the sample data–otherwise, we sometimes use the word "forecasting"). Prediction is useful for advertising purposes, finance, etc. If you are just interested in predicting some outcome variable, I have little to offer you.
Inference is where the fun is (even if it is not where the money is). Inference is where you are trying to make conclusions about specific model parameters–usually to determine a causal effect of one variable on another. Despite common perception, regression analysis is never sufficient for causal inference. You must always know more about the data generating process to know whether your regression captures the causal effect. The key issue for causal inference from regressions is whether the conditional mean of the error (conditional on the regressors) is zero. This cannot be known from p-values on regressors. It is possible to have regression estimators that are unbiased or consistent, but that requires far more effort than just throwing some obvious controls into the regression and hoping you got the important ones. The best coverage I have seen of approaching causal inference with observational data is in two books by Angrist and Pischke (Mastering 'Metrics: The Path from Cause to Effect and Mostly Harmless Econometrics). Mastering Metrics is the easier read and is quite cheap, but be warned that it is not a treatment of how to do regressions but rather of what they mean. For a good coverage of examples of good and bad observational research designs, I recommend David Freedman's (1991) "Statistical Models and Shoe Leather", Sociological Methodology, volume 21 (a short and easy read with fascinating examples).
Aside: the obsession with statistical technique over good research design in most college courses is a pedagogical peeve of mine.
Second aside to motivate the current importance of this issue: the difference between prediction and inference is why big data are not a substitute for science.
|
Should covariates that are not statistically significant be 'kept in' when creating a model?
We really need more information about your goals to answer this question. Regressions are used for two main purposes:
Prediction
Inference
Prediction is when your goal is to be able to guess at valu
|
5,797
|
Difference between LOESS and LOWESS
|
I think it is important to distinguish between methods and their implementations in software. The main difference with respect to the first is that lowess allows only one predictor, whereas loess can be used to smooth multivariate data into a kind of surface. It also gives you confidence intervals. In these senses, loess is a generalization. Both smooth by using tricube weighting around each point, and loess also adds an optional robustification option that re-weights residuals using biweight weighting.
Now for the implementation. In some software, lowess uses a linear polynomial, while loess uses a quadratic polynomial (though you can alter that). The defaults and shortcuts that the algorithms use are often quite different, so that it is hard to get the univariate outputs to match exactly. On the other hand, I am not aware of a case where the choice between the two made a substantive difference.
|
Difference between LOESS and LOWESS
|
I think it is important to distinguish between methods and their implementations in software. The main difference with respect to the first is that lowess allows only one predictor, whereas loess can
|
Difference between LOESS and LOWESS
I think it is important to distinguish between methods and their implementations in software. The main difference with respect to the first is that lowess allows only one predictor, whereas loess can be used to smooth multivariate data into a kind of surface. It also gives you confidence intervals. In these senses, loess is a generalization. Both smooth by using tricube weighting around each point, and loess also adds an optional robustification option that re-weights residuals using biweight weighting.
Now for the implementation. In some software, lowess uses a linear polynomial, while loess uses a quadratic polynomial (though you can alter that). The defaults and shortcuts that the algorithms use are often quite different, so that it is hard to get the univariate outputs to match exactly. On the other hand, I am not aware of a case where the choice between the two made a substantive difference.
|
Difference between LOESS and LOWESS
I think it is important to distinguish between methods and their implementations in software. The main difference with respect to the first is that lowess allows only one predictor, whereas loess can
|
5,798
|
Difference between LOESS and LOWESS
|
lowess and loess are algorithms and software programs created by William Cleveland.
lowess is for adding a smooth curve to a scatterplot, i.e., for univariate smoothing.
loess is for fitting a smooth surface to multivariate data.
Both algorithms use locally-weighted polynomial regression, usually with robustifying iterations.
Local regression is a statistical method for fitting smoothing curves without prior assumptions about the shape or form of the curve.
There have been many implementations of Cleveland's approach, but the most well known and most used are probably the implementations in R.
The R core stats package contains lowess and loess functions, both based quite closely on Cleveland's original code but with R interfaces.
lowess
lowess was published as a mathematical algorithm by Cleveland (1979) and as a Fortran software program by Cleveland (1981).
lowess smoothing become popular when it was included as a function in the New S language in 1988 (Becker et al, 1988) and then later in R.
The original Fortran program (dated 1985) is still available from Netlib (https://www.netlib.org/go/lowess).
The R stats function is based on a translation of the Fortran program to C and was one of the earliest functions in R.
The lowess function in R is designed for adding smooth curves to plots, so the output is just a list of ordered x coordinates and smoothed y values.
This style of output inputs easily into plotting functions in R:
x <- 1:1000
y <- rnorm(1000)
plot(x, y)
l <- lowess(x, y)
lines(l)
The lowess method consists of computing a series of local linear regressions, with each local regression restricted to a window of x-values.
Smoothness is achieved by using overlapping windows and by gradually down-weighting points in each regression according to their distance from the anchor point of the window (tri-cube weighting).
To conserve running time and memory, locally-weighted regressions are computed at only a limited number of anchor x-values, usually 100-200 distinct points.
Anchor points are at least delta apart, where delta is a parameter input to the algorithm.
The amount of smoothing is determined by the span of the overlapping windows, defined as a proportion of the total number of points.
The larger the span, the smoother the curve.
The span parameter is called F in the Fortran code and f in the R stats lowess function.
For each anchor point, a weighted linear regression is performed for a window of neighboring points.
The neighboring points consist of the smallest set of closest neighbors containing at least span proportion of all points.
Each local regression produces a fitted value for that anchor point. Fitted values for other x-values are then obtained by linear interpolation between anchor points.
For the first iteration, the local linear regressions use tri-cube distance weights.
Subsequent iterations multiple the distance weights by robustifying weights.
Points with residuals greater than 6 times the median absolute residual are assigned weights of zero and otherwise Tukey's biweight function is applied to the residuals to obtain the robust weights.
More iterations produce greater robustness.
Cleveland originally suggested 2 robustifying iterations.
The default in the R stats lowess function is 3.
loess
loess was published as a mathematical model by Cleveland & Devlin (1988), as a Fortran routine by Cleveland & Grosse (1991) and as an S function by Cleveland, Grosse & Shyu (1992).
The Netlib repository still contains Cleveland & Grosse's Fortran version from 1990 (http://www.netlib.org/a/loess) and both Fortran and C versions by Cleveland, Grosse & Shyu from 1992 (http://www.netlib.org/a/dloess).
See cloess.pdf for extended documentation.
Professor Brian Ripley ported Cleveland, Grosse & Shyu's code to R in 1998.
The R function was originally part of Prof Ripley's
modreg CRAN package
and was merged into the stats package in 2003.
The loess function in R is designed to behave like other regression fitting functions in R such as lm and glm.
It accepts a model formula:
fit.lo <- loess(y ~ x1 + x2)
and optional prior weights and outputs a fitted model object that can be input to standard R generic functions like summary, fitted, residuals, predict and so on.
The output may need a bit of post-processing however before it can be input to plotting functions like lines.
Results are output in original data order rather than sorted by any of the x-variates.
In principle, loess is a direct generalization of lowess in that locally weighted univariate regressions are simply replaced by locally weighted multiple regressions.
The implementation is more complicated however and it is harder to avoid consuming memory in the multivariate setup.
Comparing lowess to loess
When there is only one x-variable and no prior weights, the R functions lowess and loess are in principle equivalent,
so it is possible to make direct comparisons between them.
loess has several capabilities that lowess doesn't:
It accepts a formula specifying the model rather than the x and y matrices
The model can include multiple predictors, factors and interactions.
It accepts prior weights.
It will estimate the "equivalent number of parameters" implied by the fitted curve.
On the other hand, loess is much slower than lowess and sometimes fails when lowess succeeds, so both programs are kept in R.
The default settings of the two programs are very different. Here is an example in which I force lowess and loess to do precisely the same numerical calculation:
> set.seed(2020617)
> x <- 1:1000
> y <- rnorm(1000)
> out.lowess <- lowess(x, y, f=0.3, iter=3, delta=0)
> out.loess <- loess(y~x, span=0.3, degree=1,
+ family="symmetric", iterations=4,
+ surface="direct")
The smoothed values from the two functions are the same to machine precision:
> out.lowess$y[1:5]
[1] 0.04257433 0.04239860 0.04222676 0.04205882 0.04189474
> fitted(out.loess)[1:5]
[1] 0.04257433 0.04239860 0.04222676 0.04205882 0.04189474
> all.equal(out.lowess$y, fitted(out.loess))
[1] TRUE
Things to note here:
f is the span argument for lowess
loess does quadratic (degree=2) local regression by default instead of linear (degree=1)
Unless you specify family="symmetric", loess will fit the curve by least squares, i.e., won't do any robustness iterations at all.
lowess and loess count iterations differently: iter in lowess means the number of robustness iterations; iterations in loess means the total number of iterations including the least squares fit, i.e., iterations=iter+1
I set delta=0 and surface="direct" to force both functions to avoid interpolation by performing a local regression at every unique x-value.
Large data sets
The only aspect in which it is not possible to make loess and lowess agree exactly is in their treatment of large data sets. When x and y are very long, say 10s of thousands of observations, it is impractical and unnecessary to do the local regression calculation exactly, rather it is usual to interpolate between observations that are very close together. This interpolation is controlled by the delta argument to lowess and by the cell and surface arguments to loess.
When there are a large number of observations, lowess groups together those x-values that are closer than a certain distance apart. Although grouping observations based on distance is in principle the best approach, such an approach is impractical in the multivariate x-space that loess is designed to deal with. So loess instead groups observations together based on the number of observations on a cell rather than on distances. Because of this small difference, lowess and loess will almost always give slightly different numerical results for large data sets. lowess is in principle more accurate but the difference is generally small.
Where the difference between lowess and loess becomes significant is in terms of speed and memory usage.
lowess remains fast and efficient even for very large datasets of millions of points.
On my laptop PC for example lowess takes 3 seconds for a million points with the default span:
> x <- rnorm(1e6)
> y <- rnorm(1e6)
> system.time(l <- lowess(x, y))
user system elapsed
3.00 0.02 3.01
and only half a second if the span is reduced:
> system.time(l <- lowess(x, y, f=0.1))
user system elapsed
0.53 0.00 0.54
Such large datasets are impractical with loess.
Other robust implementations
The weightedLowess function of the
limma
Bioconductor package
provides an implementation of lowess with the added ability
to accept prior weights.
weightedLowess provides a novel C translation of the original Fortran code and tries to preserve as many features of the original algorithm design as possible while generalizing the concept of "span" to account for the prior weights.
In principle, the locfit.robust of the locfit CRAN package has the same functionality as weightedLowess but in practice gives different and (to me) less accurate results.
Unfortunately, locfit has not been maintained by the original authors for a long time and contains bugs.
For example, any attempt to set the iter argument to locfit.robust leads to an error.
The loessFit function of the limma package provides a consistent interface to
(wrapper for) lowess, weightedLowess, locfit and loess.
The SAS PROC LOESS provides an implementation of loess
with the additional ability to estimate the span by minimizing the AICC criterion.
Other non-robust implementations
The following extend local-regression to more general contexts but omit the robustifying steps of the original algorithm.
The gam CRAN package provides the ability to include lowess curves in generalized linear model fits.
The locfit.raw and locfit functions of the locfit CRAN package extend the ideas of loess to generalized linear models and density estimation (Loader, 1999).
The
lowess function of Stata provides an implementation of univariate lowess.
It doesn't appear to implement the robustifying iterations and doesn't use interpolation, meaning that a local regression has to be fitted at every x-value.
The
lpoly function of Stata provides a flexible approach to multivariate locally-weighted polynomial smoothing with different choices of weights to the loess algorithm.
References
Cleveland, W.S. (1979). Robust Locally Weighted Regression and Smoothing Scatterplots.
Journal of the American Statistical Association 74(368), 829-836.
Cleveland, W.S. (1981). LOWESS: A program for smoothing scatterplots by robust locally weighted regression. The American Statistician 35(1), 54.
Becker, R.A., Chambers, J.M. and Wilks, A.R. (1988).
The New S Language: a Programming Environment for Data Analysis and Graphics. Wadsworth & Brooks/Cole, Pacific Grove.
Cleveland, W.S., and Devlin, S.J. (1988). Locally-weighted regression: an approach to regression analysis by local fitting. Journal of the American Statistical Association 83(403), 596-610.
Cleveland, W. S. and Grosse, E. H. (1991). Computational methods for local regression. Statistics and Computing 1, 47–62.
Cleveland, W.S., Grosse, E., and Shyu, W.M. (1992). Local regression models. Chapter 8 In: Statistical Models in S, edited by J.M. Chambers and T.J. Hastie, Chapman & Hall/CRC, Boca Raton.
Cleveland W.S., and Loader C. (1996).
Smoothing by local regression: principles and methods.
In: Härdle W., Schimek M.G. (eds)
Statistical Theory and Computational Aspects of Smoothing.
Physica-Verlag, Heidelberg.
Loader, C. (1999).
Local Regression and Likelihood.
Springer, New York.
|
Difference between LOESS and LOWESS
|
lowess and loess are algorithms and software programs created by William Cleveland.
lowess is for adding a smooth curve to a scatterplot, i.e., for univariate smoothing.
loess is for fitting a smooth
|
Difference between LOESS and LOWESS
lowess and loess are algorithms and software programs created by William Cleveland.
lowess is for adding a smooth curve to a scatterplot, i.e., for univariate smoothing.
loess is for fitting a smooth surface to multivariate data.
Both algorithms use locally-weighted polynomial regression, usually with robustifying iterations.
Local regression is a statistical method for fitting smoothing curves without prior assumptions about the shape or form of the curve.
There have been many implementations of Cleveland's approach, but the most well known and most used are probably the implementations in R.
The R core stats package contains lowess and loess functions, both based quite closely on Cleveland's original code but with R interfaces.
lowess
lowess was published as a mathematical algorithm by Cleveland (1979) and as a Fortran software program by Cleveland (1981).
lowess smoothing become popular when it was included as a function in the New S language in 1988 (Becker et al, 1988) and then later in R.
The original Fortran program (dated 1985) is still available from Netlib (https://www.netlib.org/go/lowess).
The R stats function is based on a translation of the Fortran program to C and was one of the earliest functions in R.
The lowess function in R is designed for adding smooth curves to plots, so the output is just a list of ordered x coordinates and smoothed y values.
This style of output inputs easily into plotting functions in R:
x <- 1:1000
y <- rnorm(1000)
plot(x, y)
l <- lowess(x, y)
lines(l)
The lowess method consists of computing a series of local linear regressions, with each local regression restricted to a window of x-values.
Smoothness is achieved by using overlapping windows and by gradually down-weighting points in each regression according to their distance from the anchor point of the window (tri-cube weighting).
To conserve running time and memory, locally-weighted regressions are computed at only a limited number of anchor x-values, usually 100-200 distinct points.
Anchor points are at least delta apart, where delta is a parameter input to the algorithm.
The amount of smoothing is determined by the span of the overlapping windows, defined as a proportion of the total number of points.
The larger the span, the smoother the curve.
The span parameter is called F in the Fortran code and f in the R stats lowess function.
For each anchor point, a weighted linear regression is performed for a window of neighboring points.
The neighboring points consist of the smallest set of closest neighbors containing at least span proportion of all points.
Each local regression produces a fitted value for that anchor point. Fitted values for other x-values are then obtained by linear interpolation between anchor points.
For the first iteration, the local linear regressions use tri-cube distance weights.
Subsequent iterations multiple the distance weights by robustifying weights.
Points with residuals greater than 6 times the median absolute residual are assigned weights of zero and otherwise Tukey's biweight function is applied to the residuals to obtain the robust weights.
More iterations produce greater robustness.
Cleveland originally suggested 2 robustifying iterations.
The default in the R stats lowess function is 3.
loess
loess was published as a mathematical model by Cleveland & Devlin (1988), as a Fortran routine by Cleveland & Grosse (1991) and as an S function by Cleveland, Grosse & Shyu (1992).
The Netlib repository still contains Cleveland & Grosse's Fortran version from 1990 (http://www.netlib.org/a/loess) and both Fortran and C versions by Cleveland, Grosse & Shyu from 1992 (http://www.netlib.org/a/dloess).
See cloess.pdf for extended documentation.
Professor Brian Ripley ported Cleveland, Grosse & Shyu's code to R in 1998.
The R function was originally part of Prof Ripley's
modreg CRAN package
and was merged into the stats package in 2003.
The loess function in R is designed to behave like other regression fitting functions in R such as lm and glm.
It accepts a model formula:
fit.lo <- loess(y ~ x1 + x2)
and optional prior weights and outputs a fitted model object that can be input to standard R generic functions like summary, fitted, residuals, predict and so on.
The output may need a bit of post-processing however before it can be input to plotting functions like lines.
Results are output in original data order rather than sorted by any of the x-variates.
In principle, loess is a direct generalization of lowess in that locally weighted univariate regressions are simply replaced by locally weighted multiple regressions.
The implementation is more complicated however and it is harder to avoid consuming memory in the multivariate setup.
Comparing lowess to loess
When there is only one x-variable and no prior weights, the R functions lowess and loess are in principle equivalent,
so it is possible to make direct comparisons between them.
loess has several capabilities that lowess doesn't:
It accepts a formula specifying the model rather than the x and y matrices
The model can include multiple predictors, factors and interactions.
It accepts prior weights.
It will estimate the "equivalent number of parameters" implied by the fitted curve.
On the other hand, loess is much slower than lowess and sometimes fails when lowess succeeds, so both programs are kept in R.
The default settings of the two programs are very different. Here is an example in which I force lowess and loess to do precisely the same numerical calculation:
> set.seed(2020617)
> x <- 1:1000
> y <- rnorm(1000)
> out.lowess <- lowess(x, y, f=0.3, iter=3, delta=0)
> out.loess <- loess(y~x, span=0.3, degree=1,
+ family="symmetric", iterations=4,
+ surface="direct")
The smoothed values from the two functions are the same to machine precision:
> out.lowess$y[1:5]
[1] 0.04257433 0.04239860 0.04222676 0.04205882 0.04189474
> fitted(out.loess)[1:5]
[1] 0.04257433 0.04239860 0.04222676 0.04205882 0.04189474
> all.equal(out.lowess$y, fitted(out.loess))
[1] TRUE
Things to note here:
f is the span argument for lowess
loess does quadratic (degree=2) local regression by default instead of linear (degree=1)
Unless you specify family="symmetric", loess will fit the curve by least squares, i.e., won't do any robustness iterations at all.
lowess and loess count iterations differently: iter in lowess means the number of robustness iterations; iterations in loess means the total number of iterations including the least squares fit, i.e., iterations=iter+1
I set delta=0 and surface="direct" to force both functions to avoid interpolation by performing a local regression at every unique x-value.
Large data sets
The only aspect in which it is not possible to make loess and lowess agree exactly is in their treatment of large data sets. When x and y are very long, say 10s of thousands of observations, it is impractical and unnecessary to do the local regression calculation exactly, rather it is usual to interpolate between observations that are very close together. This interpolation is controlled by the delta argument to lowess and by the cell and surface arguments to loess.
When there are a large number of observations, lowess groups together those x-values that are closer than a certain distance apart. Although grouping observations based on distance is in principle the best approach, such an approach is impractical in the multivariate x-space that loess is designed to deal with. So loess instead groups observations together based on the number of observations on a cell rather than on distances. Because of this small difference, lowess and loess will almost always give slightly different numerical results for large data sets. lowess is in principle more accurate but the difference is generally small.
Where the difference between lowess and loess becomes significant is in terms of speed and memory usage.
lowess remains fast and efficient even for very large datasets of millions of points.
On my laptop PC for example lowess takes 3 seconds for a million points with the default span:
> x <- rnorm(1e6)
> y <- rnorm(1e6)
> system.time(l <- lowess(x, y))
user system elapsed
3.00 0.02 3.01
and only half a second if the span is reduced:
> system.time(l <- lowess(x, y, f=0.1))
user system elapsed
0.53 0.00 0.54
Such large datasets are impractical with loess.
Other robust implementations
The weightedLowess function of the
limma
Bioconductor package
provides an implementation of lowess with the added ability
to accept prior weights.
weightedLowess provides a novel C translation of the original Fortran code and tries to preserve as many features of the original algorithm design as possible while generalizing the concept of "span" to account for the prior weights.
In principle, the locfit.robust of the locfit CRAN package has the same functionality as weightedLowess but in practice gives different and (to me) less accurate results.
Unfortunately, locfit has not been maintained by the original authors for a long time and contains bugs.
For example, any attempt to set the iter argument to locfit.robust leads to an error.
The loessFit function of the limma package provides a consistent interface to
(wrapper for) lowess, weightedLowess, locfit and loess.
The SAS PROC LOESS provides an implementation of loess
with the additional ability to estimate the span by minimizing the AICC criterion.
Other non-robust implementations
The following extend local-regression to more general contexts but omit the robustifying steps of the original algorithm.
The gam CRAN package provides the ability to include lowess curves in generalized linear model fits.
The locfit.raw and locfit functions of the locfit CRAN package extend the ideas of loess to generalized linear models and density estimation (Loader, 1999).
The
lowess function of Stata provides an implementation of univariate lowess.
It doesn't appear to implement the robustifying iterations and doesn't use interpolation, meaning that a local regression has to be fitted at every x-value.
The
lpoly function of Stata provides a flexible approach to multivariate locally-weighted polynomial smoothing with different choices of weights to the loess algorithm.
References
Cleveland, W.S. (1979). Robust Locally Weighted Regression and Smoothing Scatterplots.
Journal of the American Statistical Association 74(368), 829-836.
Cleveland, W.S. (1981). LOWESS: A program for smoothing scatterplots by robust locally weighted regression. The American Statistician 35(1), 54.
Becker, R.A., Chambers, J.M. and Wilks, A.R. (1988).
The New S Language: a Programming Environment for Data Analysis and Graphics. Wadsworth & Brooks/Cole, Pacific Grove.
Cleveland, W.S., and Devlin, S.J. (1988). Locally-weighted regression: an approach to regression analysis by local fitting. Journal of the American Statistical Association 83(403), 596-610.
Cleveland, W. S. and Grosse, E. H. (1991). Computational methods for local regression. Statistics and Computing 1, 47–62.
Cleveland, W.S., Grosse, E., and Shyu, W.M. (1992). Local regression models. Chapter 8 In: Statistical Models in S, edited by J.M. Chambers and T.J. Hastie, Chapman & Hall/CRC, Boca Raton.
Cleveland W.S., and Loader C. (1996).
Smoothing by local regression: principles and methods.
In: Härdle W., Schimek M.G. (eds)
Statistical Theory and Computational Aspects of Smoothing.
Physica-Verlag, Heidelberg.
Loader, C. (1999).
Local Regression and Likelihood.
Springer, New York.
|
Difference between LOESS and LOWESS
lowess and loess are algorithms and software programs created by William Cleveland.
lowess is for adding a smooth curve to a scatterplot, i.e., for univariate smoothing.
loess is for fitting a smooth
|
5,799
|
Why is RSS distributed chi square times n-p?
|
I consider the following linear model: ${y} = X \beta + \epsilon$.
The vector of residuals is estimated by
$$\hat{\epsilon} = y - X \hat{\beta}
= (I - X (X'X)^{-1} X') y
= Q y
= Q (X \beta + \epsilon) = Q \epsilon$$
where $Q = I - X (X'X)^{-1} X'$.
Observe that $\textrm{tr}(Q) = n - p$ (the trace is invariant under cyclic permutation) and that $Q'=Q=Q^2$. The eigenvalues of $Q$ are therefore $0$ and $1$ (some details below). Hence, there exists a unitary matrix $V$ such that (matrices are diagonalizable by unitary matrices if and only if they are normal.)
$$V'QV = \Delta = \textrm{diag}(\underbrace{1, \ldots, 1}_{n-p \textrm{ times}}, \underbrace{0, \ldots, 0}_{p \textrm{ times}})$$
Now, let $K = V' \hat{\epsilon}$.
Since $\hat{\epsilon} \sim N(0, \sigma^2 Q)$, we have $K \sim N(0, \sigma^2 \Delta)$ and therefore $K_{n-p+1}=\ldots=K_n=0$. Thus
$$\frac{\|K\|^2}{\sigma^2} = \frac{\|K^{\star}\|^2}{\sigma^2} \sim \chi^2_{n-p}$$
with $K^{\star} = (K_1, \ldots, K_{n-p})'$.
Further, as $V$ is a unitary matrix, we also have
$$\|\hat{\epsilon}\|^2 = \|K\|^2=\|K^{\star}\|^2$$
Thus
$$\frac{\textrm{RSS}}{\sigma^2} \sim \chi^2_{n-p}$$
Finally, observe that this result implies that
$$E\left(\frac{\textrm{RSS}}{n-p}\right) = \sigma^2$$
Since $Q^2 - Q =0$, the minimal polynomial of $Q$ divides the polynomial $z^2 - z$. So, the eigenvalues of $Q$ are among $0$ and $1$. Since $\textrm{tr}(Q) = n-p$ is also the sum of the eigenvalues multiplied by their multiplicity, we necessarily have that $1$ is an eigenvalue with multiplicity $n-p$ and zero is an eigenvalue with multiplicity $p$.
|
Why is RSS distributed chi square times n-p?
|
I consider the following linear model: ${y} = X \beta + \epsilon$.
The vector of residuals is estimated by
$$\hat{\epsilon} = y - X \hat{\beta}
= (I - X (X'X)^{-1} X') y
|
Why is RSS distributed chi square times n-p?
I consider the following linear model: ${y} = X \beta + \epsilon$.
The vector of residuals is estimated by
$$\hat{\epsilon} = y - X \hat{\beta}
= (I - X (X'X)^{-1} X') y
= Q y
= Q (X \beta + \epsilon) = Q \epsilon$$
where $Q = I - X (X'X)^{-1} X'$.
Observe that $\textrm{tr}(Q) = n - p$ (the trace is invariant under cyclic permutation) and that $Q'=Q=Q^2$. The eigenvalues of $Q$ are therefore $0$ and $1$ (some details below). Hence, there exists a unitary matrix $V$ such that (matrices are diagonalizable by unitary matrices if and only if they are normal.)
$$V'QV = \Delta = \textrm{diag}(\underbrace{1, \ldots, 1}_{n-p \textrm{ times}}, \underbrace{0, \ldots, 0}_{p \textrm{ times}})$$
Now, let $K = V' \hat{\epsilon}$.
Since $\hat{\epsilon} \sim N(0, \sigma^2 Q)$, we have $K \sim N(0, \sigma^2 \Delta)$ and therefore $K_{n-p+1}=\ldots=K_n=0$. Thus
$$\frac{\|K\|^2}{\sigma^2} = \frac{\|K^{\star}\|^2}{\sigma^2} \sim \chi^2_{n-p}$$
with $K^{\star} = (K_1, \ldots, K_{n-p})'$.
Further, as $V$ is a unitary matrix, we also have
$$\|\hat{\epsilon}\|^2 = \|K\|^2=\|K^{\star}\|^2$$
Thus
$$\frac{\textrm{RSS}}{\sigma^2} \sim \chi^2_{n-p}$$
Finally, observe that this result implies that
$$E\left(\frac{\textrm{RSS}}{n-p}\right) = \sigma^2$$
Since $Q^2 - Q =0$, the minimal polynomial of $Q$ divides the polynomial $z^2 - z$. So, the eigenvalues of $Q$ are among $0$ and $1$. Since $\textrm{tr}(Q) = n-p$ is also the sum of the eigenvalues multiplied by their multiplicity, we necessarily have that $1$ is an eigenvalue with multiplicity $n-p$ and zero is an eigenvalue with multiplicity $p$.
|
Why is RSS distributed chi square times n-p?
I consider the following linear model: ${y} = X \beta + \epsilon$.
The vector of residuals is estimated by
$$\hat{\epsilon} = y - X \hat{\beta}
= (I - X (X'X)^{-1} X') y
|
5,800
|
Why is RSS distributed chi square times n-p?
|
IMHO, the matricial notation $Y=X\beta+\epsilon$ complicates things. Pure vector space language is cleaner. The model can be written $\boxed{Y=\mu + \sigma G}$ where $G$ has the standard normal distributon on $\mathbb{R}^n$ and $\mu$ is assumed to belong to a vector subspace $W \subset \mathbb{R}^n$.
Now the language of elementary geometry comes into play. The least-squares estimator $\hat\mu$ of $\mu$ is nothing but $P_WY$: the orthogonal projection of the observable $Y$ on the space $W$ to which $\mu$ is assumed to belong. The vector of residuals is $P^\perp_WY$: projection on the orthogonal complement $W^\perp$ of $W$ in $\mathbb{R^n}$. The dimension of $W^\perp$ is $\dim(W^\perp)=n-\dim(W)$.
Finally, $$P^\perp_WY = P^\perp_W(\mu + \sigma G) = 0 + \sigma P^\perp_WG,$$ and $P^\perp_WG$ has the standard normal distribution on $W^\perp$, hence its squared norm has the $\chi^2$ distribution with $\dim(W^\perp)$ degrees of freedom.
This demonstration uses only one theorem, actually a definition-theorem:
Definition and theorem. A random vector in $\mathbb{R}^n$ has the standard normal distribution on a vector space $U \subset \mathbb{R}^n$ if it takes its values in $U$ and its coordinates in one ($\iff$ in all) orthonormal basis of $U$ are independent one-dimensional standard normal distributions
(from this definition-theorem, Cochran's theorem is so obvious that it is not worth to state it)
|
Why is RSS distributed chi square times n-p?
|
IMHO, the matricial notation $Y=X\beta+\epsilon$ complicates things. Pure vector space language is cleaner. The model can be written $\boxed{Y=\mu + \sigma G}$ where $G$ has the standard normal distri
|
Why is RSS distributed chi square times n-p?
IMHO, the matricial notation $Y=X\beta+\epsilon$ complicates things. Pure vector space language is cleaner. The model can be written $\boxed{Y=\mu + \sigma G}$ where $G$ has the standard normal distributon on $\mathbb{R}^n$ and $\mu$ is assumed to belong to a vector subspace $W \subset \mathbb{R}^n$.
Now the language of elementary geometry comes into play. The least-squares estimator $\hat\mu$ of $\mu$ is nothing but $P_WY$: the orthogonal projection of the observable $Y$ on the space $W$ to which $\mu$ is assumed to belong. The vector of residuals is $P^\perp_WY$: projection on the orthogonal complement $W^\perp$ of $W$ in $\mathbb{R^n}$. The dimension of $W^\perp$ is $\dim(W^\perp)=n-\dim(W)$.
Finally, $$P^\perp_WY = P^\perp_W(\mu + \sigma G) = 0 + \sigma P^\perp_WG,$$ and $P^\perp_WG$ has the standard normal distribution on $W^\perp$, hence its squared norm has the $\chi^2$ distribution with $\dim(W^\perp)$ degrees of freedom.
This demonstration uses only one theorem, actually a definition-theorem:
Definition and theorem. A random vector in $\mathbb{R}^n$ has the standard normal distribution on a vector space $U \subset \mathbb{R}^n$ if it takes its values in $U$ and its coordinates in one ($\iff$ in all) orthonormal basis of $U$ are independent one-dimensional standard normal distributions
(from this definition-theorem, Cochran's theorem is so obvious that it is not worth to state it)
|
Why is RSS distributed chi square times n-p?
IMHO, the matricial notation $Y=X\beta+\epsilon$ complicates things. Pure vector space language is cleaner. The model can be written $\boxed{Y=\mu + \sigma G}$ where $G$ has the standard normal distri
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.