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
|
|---|---|---|---|---|---|---|
9,801
|
Pdf of the square of a general normal random variable
|
You have stumbled upon one of the most famous results of probability theory and statistics. I'll write an answer, although I am certain this question has been asked (and answered) before on this site.
First, note that the pdf of $Y = X^2$ cannot be the same as that of $X$ as $Y$ will be nonnegative. To derive the distribution of $Y$ we can use three methods, namely the mgf technique, the cdf technique and the density transformation technique. Let's begin.
Moment generating function technique.
Or characteristic function technique, whatever you like. We have to find the mgf of $Y=X^2$. So we need to compute the expectation
$$E\left[e^{tX^2}\right]$$
Using the Law of the Unconscious Statistician, all we have to do is compute this integral over the distribution of $X$. Thus we need to compute
$$\begin{align} E\left[e^{tX^2}\right] = \int_{-\infty}^{\infty} \frac{1}{\sqrt{2 \pi}} e^{tx^2} e^{-\frac{x^2}{2}} dx &= \int_{-\infty}^{\infty} \frac{1}{\sqrt{2\pi}} \exp\left\{ - \frac{x^2}{2} \left( 1- 2t \right) \right\} dt \\ & = \int_{-\infty}^{\infty} \frac{\left( 1-2t \right)^{1/2}}{\left( 1-2t \right)^{1/2}} \frac{1}{\sqrt{2\pi}} \exp\left\{ - \frac{x^2}{2} \left( 1- 2t \right) \right\} dt \\ & = \left(1-2t\right)^{-1/2} , \quad t<\frac{1}{2} \end{align}$$
where in the last line we have compared the integral with a Gaussian integral with mean zero and variance $\frac{1}{\left(1-2t\right)}$. Of course this integrates to one over the real line. What can you do with that result now? Well, you may apply a very complex inverse transformation and determine the pdf that corresponds to this MGF or you may simply recognise it as the MGF of a chi-squared distribution with one degree of freedom. (Recall that a chi-squared distribution is a special case of a gamma distribution with $\alpha = \frac{r}{2}$, $r$ being the degrees of freedom, and $\beta = 2$).
CDF technique
This is perhaps the easiest thing you can do and it is suggested by Glen_b in the comments. According to this technique, we compute
$$F_Y (y) = P(Y\leq y) = P(X^2 \leq y) = P(|X|\leq \sqrt{y})$$
and since distribution functions define the density functions, after we get a simplified expression we just differentiate with respect to $y$ to get our pdf. We have then
$$ \begin{align} F_Y (y) = P\left( |X|\leq \sqrt{y} \right) = P\left(-\sqrt{y} < X <\sqrt{y} \right) = \Phi\left(\sqrt{y}\right) - \Phi \left(- \sqrt{y}\right) \end{align} $$
where $\Phi(.)$ denotes the CDF of a standard normal variable. Differentiating with respect to $y$ we get,
$$f_Y(y) = F_Y^{\prime} (y) = \frac{1}{2 \sqrt{y}} \phi \left( \sqrt{y} \right) + \frac{1}{2 \sqrt{y}} \phi \left( -\sqrt{y} \right) = \frac{1}{\sqrt{y}} \phi(\sqrt{y}) $$
where $\phi(.)$ is now the pdf of a standard normal variable and we have used the fact that it is symmetric about zero. Hence
$$f_Y (y) = \frac{1}{\sqrt{y}} \frac{1}{\sqrt{2\pi}} e^{-\frac{y}{2}}, \quad 0<y<\infty$$
which we recognize as the pdf of a chi-squared distribution with one degree of freedom (You might be seeing a pattern by now).
Density transformation technique
At this point you might wonder, why we do not simply use the transformation technique you are familiar with, that is, for a function $ Y = g(X)$ we have that the density of $Y$ is given by
$$f_Y (y) = \left| \frac{d}{dy} g^{-1} (y) \right| f_X \left( g^{-1} (y) \right)$$
for $y$ in the range of $g$. Unfortunately this theorem requires the transformation to be one-to-one which is clearly not the case here. Indeed, we can see that two values of $X$ result in the same value of $Y$, $g$ being a quadratic transformation. Therefore, this theorem is not applicable.
What is applicable, nevertheless, is an extension of it. Under this extension, we may decompose the support of $X$ (support means the points where the density is non-zero), into disjoint sets such that $Y= g(X)$ defines a one-to-one transformation from these sets into the range of $g$. The density of $Y$ is then given by the sum over all of these inverse functions and the corresponding absolute Jacobians. In the above notation
$$f_Y (y) = \sum \left| \frac{d}{dy} g^{-1} (y) \right| f_X \left( g^{-1} (y) \right)$$
where the sum runs over all inverse functions. This example will make it clear.
For $y = x^2$, we have two inverse functions, namely $x = \pm \sqrt{y}$ with corresponding absolute Jacobian $\displaystyle{ \frac{1}{2\sqrt{y}} }$ and so the corresponding pdf is found to be
$$f_Y (y) = \frac{1}{2\sqrt{y}} \frac{1}{\sqrt{2\pi} } e^{-y/2} + \frac{1}{2\sqrt{y}} \frac{1}{\sqrt{2\pi} } e^{-y/2} = \frac{1}{\sqrt{y}} \frac{1}{\sqrt{2\pi}} e^{-y/2}, \quad 0<y<\infty$$
the pdf of a chi-squared distribution with one degree of freedom. On a side note, I find this technique particularly useful as you no longer have to derive the CDF of the transformation. But of course, these are personal tastes.
So you can go to bed tonight completely assured that the square of a standard normal random variable follows the chi-squared distribution with one degree of freedom.
|
Pdf of the square of a general normal random variable
|
You have stumbled upon one of the most famous results of probability theory and statistics. I'll write an answer, although I am certain this question has been asked (and answered) before on this site.
|
Pdf of the square of a general normal random variable
You have stumbled upon one of the most famous results of probability theory and statistics. I'll write an answer, although I am certain this question has been asked (and answered) before on this site.
First, note that the pdf of $Y = X^2$ cannot be the same as that of $X$ as $Y$ will be nonnegative. To derive the distribution of $Y$ we can use three methods, namely the mgf technique, the cdf technique and the density transformation technique. Let's begin.
Moment generating function technique.
Or characteristic function technique, whatever you like. We have to find the mgf of $Y=X^2$. So we need to compute the expectation
$$E\left[e^{tX^2}\right]$$
Using the Law of the Unconscious Statistician, all we have to do is compute this integral over the distribution of $X$. Thus we need to compute
$$\begin{align} E\left[e^{tX^2}\right] = \int_{-\infty}^{\infty} \frac{1}{\sqrt{2 \pi}} e^{tx^2} e^{-\frac{x^2}{2}} dx &= \int_{-\infty}^{\infty} \frac{1}{\sqrt{2\pi}} \exp\left\{ - \frac{x^2}{2} \left( 1- 2t \right) \right\} dt \\ & = \int_{-\infty}^{\infty} \frac{\left( 1-2t \right)^{1/2}}{\left( 1-2t \right)^{1/2}} \frac{1}{\sqrt{2\pi}} \exp\left\{ - \frac{x^2}{2} \left( 1- 2t \right) \right\} dt \\ & = \left(1-2t\right)^{-1/2} , \quad t<\frac{1}{2} \end{align}$$
where in the last line we have compared the integral with a Gaussian integral with mean zero and variance $\frac{1}{\left(1-2t\right)}$. Of course this integrates to one over the real line. What can you do with that result now? Well, you may apply a very complex inverse transformation and determine the pdf that corresponds to this MGF or you may simply recognise it as the MGF of a chi-squared distribution with one degree of freedom. (Recall that a chi-squared distribution is a special case of a gamma distribution with $\alpha = \frac{r}{2}$, $r$ being the degrees of freedom, and $\beta = 2$).
CDF technique
This is perhaps the easiest thing you can do and it is suggested by Glen_b in the comments. According to this technique, we compute
$$F_Y (y) = P(Y\leq y) = P(X^2 \leq y) = P(|X|\leq \sqrt{y})$$
and since distribution functions define the density functions, after we get a simplified expression we just differentiate with respect to $y$ to get our pdf. We have then
$$ \begin{align} F_Y (y) = P\left( |X|\leq \sqrt{y} \right) = P\left(-\sqrt{y} < X <\sqrt{y} \right) = \Phi\left(\sqrt{y}\right) - \Phi \left(- \sqrt{y}\right) \end{align} $$
where $\Phi(.)$ denotes the CDF of a standard normal variable. Differentiating with respect to $y$ we get,
$$f_Y(y) = F_Y^{\prime} (y) = \frac{1}{2 \sqrt{y}} \phi \left( \sqrt{y} \right) + \frac{1}{2 \sqrt{y}} \phi \left( -\sqrt{y} \right) = \frac{1}{\sqrt{y}} \phi(\sqrt{y}) $$
where $\phi(.)$ is now the pdf of a standard normal variable and we have used the fact that it is symmetric about zero. Hence
$$f_Y (y) = \frac{1}{\sqrt{y}} \frac{1}{\sqrt{2\pi}} e^{-\frac{y}{2}}, \quad 0<y<\infty$$
which we recognize as the pdf of a chi-squared distribution with one degree of freedom (You might be seeing a pattern by now).
Density transformation technique
At this point you might wonder, why we do not simply use the transformation technique you are familiar with, that is, for a function $ Y = g(X)$ we have that the density of $Y$ is given by
$$f_Y (y) = \left| \frac{d}{dy} g^{-1} (y) \right| f_X \left( g^{-1} (y) \right)$$
for $y$ in the range of $g$. Unfortunately this theorem requires the transformation to be one-to-one which is clearly not the case here. Indeed, we can see that two values of $X$ result in the same value of $Y$, $g$ being a quadratic transformation. Therefore, this theorem is not applicable.
What is applicable, nevertheless, is an extension of it. Under this extension, we may decompose the support of $X$ (support means the points where the density is non-zero), into disjoint sets such that $Y= g(X)$ defines a one-to-one transformation from these sets into the range of $g$. The density of $Y$ is then given by the sum over all of these inverse functions and the corresponding absolute Jacobians. In the above notation
$$f_Y (y) = \sum \left| \frac{d}{dy} g^{-1} (y) \right| f_X \left( g^{-1} (y) \right)$$
where the sum runs over all inverse functions. This example will make it clear.
For $y = x^2$, we have two inverse functions, namely $x = \pm \sqrt{y}$ with corresponding absolute Jacobian $\displaystyle{ \frac{1}{2\sqrt{y}} }$ and so the corresponding pdf is found to be
$$f_Y (y) = \frac{1}{2\sqrt{y}} \frac{1}{\sqrt{2\pi} } e^{-y/2} + \frac{1}{2\sqrt{y}} \frac{1}{\sqrt{2\pi} } e^{-y/2} = \frac{1}{\sqrt{y}} \frac{1}{\sqrt{2\pi}} e^{-y/2}, \quad 0<y<\infty$$
the pdf of a chi-squared distribution with one degree of freedom. On a side note, I find this technique particularly useful as you no longer have to derive the CDF of the transformation. But of course, these are personal tastes.
So you can go to bed tonight completely assured that the square of a standard normal random variable follows the chi-squared distribution with one degree of freedom.
|
Pdf of the square of a general normal random variable
You have stumbled upon one of the most famous results of probability theory and statistics. I'll write an answer, although I am certain this question has been asked (and answered) before on this site.
|
9,802
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
|
Hypothesis tests are still used because they are motivated by a different need in statistical inference than interval estimators are motivated by.
The purpose of a hypothesis test is to make a decision as to whether there is evidence for the alternative hypothesis' expression of the population parameter.
Confidence intervals serve a different purpose: they provide a plausible range of estimates of a population parameter.
All the technical details about estimation (exact vs approximate, bootstrap vs non-probabilistic closed-form estimators, intervals, test statistics and p values, etc.) aside, the above represent fundamentally different motivations in statistical inference.
Aside: sometimes confidence interval coverage has a pretty direct correspondence to a hypothesis tests (a la does it cover the null or not), but this is not always the case, and habitually using confidence intervals for that purpose, in my opinion, obscures the above distinction between "let's make a decision about evidence for the alternative hypothesis" and "let's estimate a plausible range of values for a parameter."
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
|
Hypothesis tests are still used because they are motivated by a different need in statistical inference than interval estimators are motivated by.
The purpose of a hypothesis test is to make a decisio
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
Hypothesis tests are still used because they are motivated by a different need in statistical inference than interval estimators are motivated by.
The purpose of a hypothesis test is to make a decision as to whether there is evidence for the alternative hypothesis' expression of the population parameter.
Confidence intervals serve a different purpose: they provide a plausible range of estimates of a population parameter.
All the technical details about estimation (exact vs approximate, bootstrap vs non-probabilistic closed-form estimators, intervals, test statistics and p values, etc.) aside, the above represent fundamentally different motivations in statistical inference.
Aside: sometimes confidence interval coverage has a pretty direct correspondence to a hypothesis tests (a la does it cover the null or not), but this is not always the case, and habitually using confidence intervals for that purpose, in my opinion, obscures the above distinction between "let's make a decision about evidence for the alternative hypothesis" and "let's estimate a plausible range of values for a parameter."
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
Hypothesis tests are still used because they are motivated by a different need in statistical inference than interval estimators are motivated by.
The purpose of a hypothesis test is to make a decisio
|
9,803
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
|
One reason to use traditional hypothesis testing methods (when they can be used) is that it is computationally efficient to do so compared to bootstrap sampling. Depending upon the number of dimensions in your data, the number of bootstrap samples required to estimate p values (or confidence intervals) can be very large.
Central limit theorem is not always applicable. Sure, the average of a large number of i.i.d. random variables will lead to a Normal distribution. The question is what is large. Also, the problem is that it is not just the mean of the population you are interested in; there are other parameters that you want to estimate where CLT is not applicable. Again, we have asymptotic Normality to rescue (I would not go into details here), but it also requires a large sample. Again, what is large. Note that asymptotic Normality requires other technical conditions to hold which do not always hold.
Edit: An example where CLT is not applicable is when a time series has long-term persistence which means that autocorrelation dies very slowly. Here the assumption of independence is violated to the extent that CLT is not even approximately valid with thousands of samples. Here again you will have t resort to classic sampling distributions for hypothesis testing.
Another point (as detailed nicely by Alexis) is that the hypothesis tests are used for rejecting a plausible explanation (model) of the observed phenomenon. Therefore, hypothesis testing itself will stay relevant whatever method is used to test the hypothesis.
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
|
One reason to use traditional hypothesis testing methods (when they can be used) is that it is computationally efficient to do so compared to bootstrap sampling. Depending upon the number of dimension
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
One reason to use traditional hypothesis testing methods (when they can be used) is that it is computationally efficient to do so compared to bootstrap sampling. Depending upon the number of dimensions in your data, the number of bootstrap samples required to estimate p values (or confidence intervals) can be very large.
Central limit theorem is not always applicable. Sure, the average of a large number of i.i.d. random variables will lead to a Normal distribution. The question is what is large. Also, the problem is that it is not just the mean of the population you are interested in; there are other parameters that you want to estimate where CLT is not applicable. Again, we have asymptotic Normality to rescue (I would not go into details here), but it also requires a large sample. Again, what is large. Note that asymptotic Normality requires other technical conditions to hold which do not always hold.
Edit: An example where CLT is not applicable is when a time series has long-term persistence which means that autocorrelation dies very slowly. Here the assumption of independence is violated to the extent that CLT is not even approximately valid with thousands of samples. Here again you will have t resort to classic sampling distributions for hypothesis testing.
Another point (as detailed nicely by Alexis) is that the hypothesis tests are used for rejecting a plausible explanation (model) of the observed phenomenon. Therefore, hypothesis testing itself will stay relevant whatever method is used to test the hypothesis.
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
One reason to use traditional hypothesis testing methods (when they can be used) is that it is computationally efficient to do so compared to bootstrap sampling. Depending upon the number of dimension
|
9,804
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
|
Let's see what actually happened with your example
You started with a mixture of three normal distributions, where the probability of exceeding $\$80k$ was about $0.32576$
You used this to construct a population of $300000$ with $97751$ cases exceeding $\$80k$, a proportion of about $0.32587$
You sampled $15000$ without replacement from the $300000$ population with (my running of your code) $4865$ cases exceeding $\$80k$, a proportion of about $0.3243$. This is the natural estimate $\hat p$ of the proportion both of the population and of the original mixture distribution.
You then $1000$ times sampled $10500$ without replacement from the $15000$ sample and looked at the cases exceeding $\$80k$ ranging from $3317$ to $3491$ with an average about $3405.8$, so getting proportions ranging from $0.3159$ to $0.3325$ with an average of about $0.3244$ (you seem to report a mean of $0.3259$ but I do not get that running your code - with only $1000$ repetitions the difference is not significant)
That last step is not conventional bootstrapping, which instead would involve sampling $15000$ (or perhaps $285000$) with replacement from the original sample, and doing it many more times. No matter. The real point is that nothing you do after the third step can improve on the knowledge that $4865$ of the $15000$ sample exceeded $\$80k$. What bootstrapping does do is allow estimates of statistics which are theoretically too difficult to calculate, but that is not the case with proportions.
In particular you cannot ensure you improve on $\hat p$ by bootstrapping, though there are some theoretical arguments for using the biased estimates $\frac{4865+\frac12}{15000+1}$ or $\frac{4865+1}{15000+2}$ or $\frac{4865+2}{15000+4}$ instead of $\frac{4865}{15000}$. As for a confidence interval, there are many theoretical suggestions, at least for the original mixture distribution, and here bootstrapping will not improve on these (and will vary since each set of bootstraps will vary). It is easy enough to extend these to confidence intervals for the population here, remembering that the population is finite and you already know $15000$ of the values.
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
|
Let's see what actually happened with your example
You started with a mixture of three normal distributions, where the probability of exceeding $\$80k$ was about $0.32576$
You used this to construct
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
Let's see what actually happened with your example
You started with a mixture of three normal distributions, where the probability of exceeding $\$80k$ was about $0.32576$
You used this to construct a population of $300000$ with $97751$ cases exceeding $\$80k$, a proportion of about $0.32587$
You sampled $15000$ without replacement from the $300000$ population with (my running of your code) $4865$ cases exceeding $\$80k$, a proportion of about $0.3243$. This is the natural estimate $\hat p$ of the proportion both of the population and of the original mixture distribution.
You then $1000$ times sampled $10500$ without replacement from the $15000$ sample and looked at the cases exceeding $\$80k$ ranging from $3317$ to $3491$ with an average about $3405.8$, so getting proportions ranging from $0.3159$ to $0.3325$ with an average of about $0.3244$ (you seem to report a mean of $0.3259$ but I do not get that running your code - with only $1000$ repetitions the difference is not significant)
That last step is not conventional bootstrapping, which instead would involve sampling $15000$ (or perhaps $285000$) with replacement from the original sample, and doing it many more times. No matter. The real point is that nothing you do after the third step can improve on the knowledge that $4865$ of the $15000$ sample exceeded $\$80k$. What bootstrapping does do is allow estimates of statistics which are theoretically too difficult to calculate, but that is not the case with proportions.
In particular you cannot ensure you improve on $\hat p$ by bootstrapping, though there are some theoretical arguments for using the biased estimates $\frac{4865+\frac12}{15000+1}$ or $\frac{4865+1}{15000+2}$ or $\frac{4865+2}{15000+4}$ instead of $\frac{4865}{15000}$. As for a confidence interval, there are many theoretical suggestions, at least for the original mixture distribution, and here bootstrapping will not improve on these (and will vary since each set of bootstraps will vary). It is easy enough to extend these to confidence intervals for the population here, remembering that the population is finite and you already know $15000$ of the values.
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
Let's see what actually happened with your example
You started with a mixture of three normal distributions, where the probability of exceeding $\$80k$ was about $0.32576$
You used this to construct
|
9,805
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
|
Furthermore, the Non-Parametric Bootstrap also allows you to evaluate population inference and confidence intervals - regardless of the population's true distribution. Thus, why do we still use classical hypothesis testing methods? The only reason I can think of, is when there are smaller sample sizes. But are there any other reasons?
If you have a large sample then you can estimate the population very well based on the empirical distribution.
But instead of bootstrapping it can be done much faster with a simple computation. If you observe $p = 0.3258367$ in a sample of size $n = 15000$ then the estimate for the standard error in the estimate $\hat{p}$ is
$$\sigma_{\hat{p}} \approx \sqrt{\frac{p(1-p)}{n}}$$
and for the 80% confidence interval
$$CI = \hat{p} \pm 1.281552 \sigma_{\hat{p}} $$
giving
$$CI = 0.3258367 \pm 0.004904255 $$
Advantage direct computation / disadvantage bootstrap
So this computation did not require all the resampling that you needed to do.
It is also more accurate than the result that you give*.
In addition, the bootstrapping is a black box. It gives you only a single output but there is no information about deeper relationships.
For instance, with the formula for the direct computation you can see the $1/\sqrt{n}$ dependence of the end result. This is useful if you want to determine the best sample size for a certain precision. With bootstrapping you would not be able to see this directly and you would have to simulate many situations.
*some errors must have slipped into your computation since "between (32.59 - 0.0495400 %) and (32.59 - 5.97%)" is wrong. You should get something like (32.59 - 0.49 %) and (32.59 + 0.49 %), so the correct interval size is only about 1% in size.
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
|
Furthermore, the Non-Parametric Bootstrap also allows you to evaluate population inference and confidence intervals - regardless of the population's true distribution. Thus, why do we still use classi
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
Furthermore, the Non-Parametric Bootstrap also allows you to evaluate population inference and confidence intervals - regardless of the population's true distribution. Thus, why do we still use classical hypothesis testing methods? The only reason I can think of, is when there are smaller sample sizes. But are there any other reasons?
If you have a large sample then you can estimate the population very well based on the empirical distribution.
But instead of bootstrapping it can be done much faster with a simple computation. If you observe $p = 0.3258367$ in a sample of size $n = 15000$ then the estimate for the standard error in the estimate $\hat{p}$ is
$$\sigma_{\hat{p}} \approx \sqrt{\frac{p(1-p)}{n}}$$
and for the 80% confidence interval
$$CI = \hat{p} \pm 1.281552 \sigma_{\hat{p}} $$
giving
$$CI = 0.3258367 \pm 0.004904255 $$
Advantage direct computation / disadvantage bootstrap
So this computation did not require all the resampling that you needed to do.
It is also more accurate than the result that you give*.
In addition, the bootstrapping is a black box. It gives you only a single output but there is no information about deeper relationships.
For instance, with the formula for the direct computation you can see the $1/\sqrt{n}$ dependence of the end result. This is useful if you want to determine the best sample size for a certain precision. With bootstrapping you would not be able to see this directly and you would have to simulate many situations.
*some errors must have slipped into your computation since "between (32.59 - 0.0495400 %) and (32.59 - 5.97%)" is wrong. You should get something like (32.59 - 0.49 %) and (32.59 + 0.49 %), so the correct interval size is only about 1% in size.
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
Furthermore, the Non-Parametric Bootstrap also allows you to evaluate population inference and confidence intervals - regardless of the population's true distribution. Thus, why do we still use classi
|
9,806
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
|
The bootstrap cannot resample events that didn't occur in the dataset. If the probability of some event was very low and ends up not occuring -- e.g., the expected number of events in some range or bin is less than 1, and indeed zero are obtained -- the bootstrap procedure will of course never be able to produce (re)samples with a non-zero number of such events. In other words, as opposed to sampling from the true underlying distribution, the bootstrap implicitly assumes that the probability of this event was strictly zero. This can lead to biases in the case of sparse data or long-tailed data.
Of course, sparse data can also be a problem in hypothesis tests, especially those that assume an asymptotic distribution for some underlying metric, and special care is likely to be needed.
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
|
The bootstrap cannot resample events that didn't occur in the dataset. If the probability of some event was very low and ends up not occuring -- e.g., the expected number of events in some range or bi
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
The bootstrap cannot resample events that didn't occur in the dataset. If the probability of some event was very low and ends up not occuring -- e.g., the expected number of events in some range or bin is less than 1, and indeed zero are obtained -- the bootstrap procedure will of course never be able to produce (re)samples with a non-zero number of such events. In other words, as opposed to sampling from the true underlying distribution, the bootstrap implicitly assumes that the probability of this event was strictly zero. This can lead to biases in the case of sparse data or long-tailed data.
Of course, sparse data can also be a problem in hypothesis tests, especially those that assume an asymptotic distribution for some underlying metric, and special care is likely to be needed.
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
The bootstrap cannot resample events that didn't occur in the dataset. If the probability of some event was very low and ends up not occuring -- e.g., the expected number of events in some range or bi
|
9,807
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
|
Take many random samples from any distribution
But your example only has a single sample that you're resampling. You are not taking samples from the population, you are resampling your sample, so you actually just evaluate your sample's parameters that you could've found directly.
The distribution of thee means will follow a Normal Distribution (this result is particularly useful for inferences, e.g. hypothesis testing and confidence intervals).
You are missing the fact that the central limit theorem requires $n \rightarrow \infty$. For the finite case you get something else. If the population follows normal distribution, means will follow Student's t-distribution.
P.S. Please don't take my direct language as an attack. The question is great and it's important to discuss these topics. I just felt these misunderstandings should be countered explicitly and concisely.
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
|
Take many random samples from any distribution
But your example only has a single sample that you're resampling. You are not taking samples from the population, you are resampling your sample, so yo
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
Take many random samples from any distribution
But your example only has a single sample that you're resampling. You are not taking samples from the population, you are resampling your sample, so you actually just evaluate your sample's parameters that you could've found directly.
The distribution of thee means will follow a Normal Distribution (this result is particularly useful for inferences, e.g. hypothesis testing and confidence intervals).
You are missing the fact that the central limit theorem requires $n \rightarrow \infty$. For the finite case you get something else. If the population follows normal distribution, means will follow Student's t-distribution.
P.S. Please don't take my direct language as an attack. The question is great and it's important to discuss these topics. I just felt these misunderstandings should be countered explicitly and concisely.
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
Take many random samples from any distribution
But your example only has a single sample that you're resampling. You are not taking samples from the population, you are resampling your sample, so yo
|
9,808
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
|
Classical methods, designed experiments analyzed with analysis of variance, were designed to work with small samples and complex design structure. Complex design structure includes Latin Squares, Balanced Incomplete Block Designs, Repeated Measures Designs, and others. All of these are used regularly in biological and psychological sciences and chemical engineering.
The original method of analysis, analysis of variance, gives tests of hypotheses and, for the complex designs gives descriptive information that is useful in understanding the scientific conclusions, eg, interval estimates, identification of outliers or failures of assumptions. Analysis of Variance also works well for randomized designs even when there are some deviations from the assumptions. There is a large literature from the 1950s that shows that randomization is a generally good basis for the analysis of variance tests, even though most derivations of tests are based on Gaussian distributions.
Methods for the analysis of binomial and multinomial measurements were developed for many of the designs scientists used and analyzed, perhaps somewhat improperly, with Analysis of Variance. The experimental designs are still in common use with appropriate analyses.
The Bootstrap is a valuable tool. The Bootstrap works with as well with small samples as well as large. The Bootstrap gives estimates of bias and explicit methods that can be used to reduce bias. While most analysis with the bootstrap has focused on estimation there is no reason it can't be used for tests of hypotheses. It also works will with measurements that are somewhat non-normal.
The Bootstrap does not work so well with the complex designs such as Randomized Block Designs, Greco-Latin Squares, etc. I would be happy to see sample reuse methods, the Bootstrap or otherwise, described for such designs. Until it is the classical methods of analysis will continue to be useful. I won't hold my breath waiting.
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
|
Classical methods, designed experiments analyzed with analysis of variance, were designed to work with small samples and complex design structure. Complex design structure includes Latin Squares, Bala
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
Classical methods, designed experiments analyzed with analysis of variance, were designed to work with small samples and complex design structure. Complex design structure includes Latin Squares, Balanced Incomplete Block Designs, Repeated Measures Designs, and others. All of these are used regularly in biological and psychological sciences and chemical engineering.
The original method of analysis, analysis of variance, gives tests of hypotheses and, for the complex designs gives descriptive information that is useful in understanding the scientific conclusions, eg, interval estimates, identification of outliers or failures of assumptions. Analysis of Variance also works well for randomized designs even when there are some deviations from the assumptions. There is a large literature from the 1950s that shows that randomization is a generally good basis for the analysis of variance tests, even though most derivations of tests are based on Gaussian distributions.
Methods for the analysis of binomial and multinomial measurements were developed for many of the designs scientists used and analyzed, perhaps somewhat improperly, with Analysis of Variance. The experimental designs are still in common use with appropriate analyses.
The Bootstrap is a valuable tool. The Bootstrap works with as well with small samples as well as large. The Bootstrap gives estimates of bias and explicit methods that can be used to reduce bias. While most analysis with the bootstrap has focused on estimation there is no reason it can't be used for tests of hypotheses. It also works will with measurements that are somewhat non-normal.
The Bootstrap does not work so well with the complex designs such as Randomized Block Designs, Greco-Latin Squares, etc. I would be happy to see sample reuse methods, the Bootstrap or otherwise, described for such designs. Until it is the classical methods of analysis will continue to be useful. I won't hold my breath waiting.
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
Classical methods, designed experiments analyzed with analysis of variance, were designed to work with small samples and complex design structure. Complex design structure includes Latin Squares, Bala
|
9,809
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
|
There are scenarios, though I will grant that many of them are a bit esoteric, where the bootstrap is not consistent.
For instance: parameters involving ranks, or when a parameter is at the boundary of a space.
The bootstrap can be tricky, or inefficient to implement with non-iid data. For instance, with clustered data, one is forced to resample the highest-level of clustering.
To get efficient estimates of confidence intervals, under the hood of many bootstrap estimators is something that looks like a classical estimator, for instance the studentized bootstrap. Of note, one can't just naively take the 2.5% and 97.5% percentile of the bootstrapped statistic in the resampled data and expect good coverage.
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
|
There are scenarios, though I will grant that many of them are a bit esoteric, where the bootstrap is not consistent.
For instance: parameters involving ranks, or when a parameter is at the boundary o
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
There are scenarios, though I will grant that many of them are a bit esoteric, where the bootstrap is not consistent.
For instance: parameters involving ranks, or when a parameter is at the boundary of a space.
The bootstrap can be tricky, or inefficient to implement with non-iid data. For instance, with clustered data, one is forced to resample the highest-level of clustering.
To get efficient estimates of confidence intervals, under the hood of many bootstrap estimators is something that looks like a classical estimator, for instance the studentized bootstrap. Of note, one can't just naively take the 2.5% and 97.5% percentile of the bootstrapped statistic in the resampled data and expect good coverage.
|
Why are hypothesis tests still used when we have the bootstrap and central limit theorem?
There are scenarios, though I will grant that many of them are a bit esoteric, where the bootstrap is not consistent.
For instance: parameters involving ranks, or when a parameter is at the boundary o
|
9,810
|
What's wrong with Bonferroni adjustments?
|
What is wrong with the Bonferroni correction besides the conservatism mentioned by others is what's wrong with all multiplicity corrections. They do not follow from basic statistical principles and are arbitrary; there is no unique solution to the multiplicity problem in the frequentist world. Secondly, multiplicity adjustments are based on the underlying philosophy that the veracity of one statement depends on which other hypotheses are entertained. This is equivalent to a Bayesian setup where the prior distribution for a parameter of interest keeps getting more conservative as other parameters are considered. This does not seem to be coherent. One could say that this approach comes from researchers having been "burned" by a history of false positive experiments and now they want to make up for their misdeeds.
To expand a bit, consider the following situation. An oncology researcher has made a career of studying efficacy of chemotherapies of a certain class. All previous 20 of her randomized trials have resulted in statistically insignificant efficacy. Now she is testing a new chemotherapy in the same class. The survival benefit is significant with $P=0.04$. A colleague points out that there was a second endpoint studied (tumor shrinkage) and that a multiplicity adjustment needs to be applied to the survival result, making for an insignificant survival benefit. How is it that the colleague emphasized the second endpoint but couldn't care less about adjusting for the 20 previous failed attempts to find an effective drug? And how would you take into account prior knowledge about the 20 previous studies if you weren't Bayesian? What if there had been no second endpoint. Would the colleague believe that a survival benefit had been demonstrated, ignoring all previous knowledge?
|
What's wrong with Bonferroni adjustments?
|
What is wrong with the Bonferroni correction besides the conservatism mentioned by others is what's wrong with all multiplicity corrections. They do not follow from basic statistical principles and a
|
What's wrong with Bonferroni adjustments?
What is wrong with the Bonferroni correction besides the conservatism mentioned by others is what's wrong with all multiplicity corrections. They do not follow from basic statistical principles and are arbitrary; there is no unique solution to the multiplicity problem in the frequentist world. Secondly, multiplicity adjustments are based on the underlying philosophy that the veracity of one statement depends on which other hypotheses are entertained. This is equivalent to a Bayesian setup where the prior distribution for a parameter of interest keeps getting more conservative as other parameters are considered. This does not seem to be coherent. One could say that this approach comes from researchers having been "burned" by a history of false positive experiments and now they want to make up for their misdeeds.
To expand a bit, consider the following situation. An oncology researcher has made a career of studying efficacy of chemotherapies of a certain class. All previous 20 of her randomized trials have resulted in statistically insignificant efficacy. Now she is testing a new chemotherapy in the same class. The survival benefit is significant with $P=0.04$. A colleague points out that there was a second endpoint studied (tumor shrinkage) and that a multiplicity adjustment needs to be applied to the survival result, making for an insignificant survival benefit. How is it that the colleague emphasized the second endpoint but couldn't care less about adjusting for the 20 previous failed attempts to find an effective drug? And how would you take into account prior knowledge about the 20 previous studies if you weren't Bayesian? What if there had been no second endpoint. Would the colleague believe that a survival benefit had been demonstrated, ignoring all previous knowledge?
|
What's wrong with Bonferroni adjustments?
What is wrong with the Bonferroni correction besides the conservatism mentioned by others is what's wrong with all multiplicity corrections. They do not follow from basic statistical principles and a
|
9,811
|
What's wrong with Bonferroni adjustments?
|
He summarized saying that Bonferroni adjustment have, at best, limited applications in biomedical research and should not be used when assessing evidence about specific hypothesis.
The Bonferroni correction is one of the simplest and most conservative multiple comparisons technique. It is also one of the oldest and has been improved upon greatly over time. It is fair to say that the Bonferroni adjustments have limited application in almost all situations. There is almost certainly a better approach. That is to say, you will need to correct for multiple comparisons but you can choose a method that is less conservative and more powerful.
Less Conservative
Multiple comparisons methods protect against getting at least one false positive in a family of tests. If you perform one test at the $\alpha$ level then you are allowing a 5% chance of getting a false positive. In other words, you reject your null hypothesis erroneously. If you perform 10 tests at the $\alpha = 0.05$ level then this increases to $1-(1-0.05)^{10}$ = ~40% chance of getting a false positive
With the Bonferroni method you use an $\alpha_b$ at the lowest end of the scale (i.e. $\alpha_b = \alpha/n$) to protect your family of $n$ tests at the $\alpha$ level. In other words, it is the most conservative. Now, you can increase $\alpha_b$ above the lower limit set by Bonferroni (i.e. make your test less conservative) and still protect your family of tests at the $\alpha$ level. There are many ways to do this, the Holm-Bonferroni method for example or better still False Discovery Rate
More Powerful
A good point brought up in the paper referenced is that the likelihood of type II errors is also increased so that truly important differences are deemed non-significant.
This is very important. A powerful test is one that finds significant results if they exist. By using the Bonferroni correction you end up with a less powerful test. As Bonferroni is conservative, the power is likely to be considerable reduced. Again, one of the alternative methods eg False Discovery Rate, will increase the power of the test. In other words, not only do you protect against false positives, you also improve your ability to find truly significant results.
So yes, you should apply some correction technique when you have multiple comparisons. And yes, Bonferroni should probably be avoided in favour of a less conservative and more powerful method
|
What's wrong with Bonferroni adjustments?
|
He summarized saying that Bonferroni adjustment have, at best, limited applications in biomedical research and should not be used when assessing evidence about specific hypothesis.
The Bonferroni cor
|
What's wrong with Bonferroni adjustments?
He summarized saying that Bonferroni adjustment have, at best, limited applications in biomedical research and should not be used when assessing evidence about specific hypothesis.
The Bonferroni correction is one of the simplest and most conservative multiple comparisons technique. It is also one of the oldest and has been improved upon greatly over time. It is fair to say that the Bonferroni adjustments have limited application in almost all situations. There is almost certainly a better approach. That is to say, you will need to correct for multiple comparisons but you can choose a method that is less conservative and more powerful.
Less Conservative
Multiple comparisons methods protect against getting at least one false positive in a family of tests. If you perform one test at the $\alpha$ level then you are allowing a 5% chance of getting a false positive. In other words, you reject your null hypothesis erroneously. If you perform 10 tests at the $\alpha = 0.05$ level then this increases to $1-(1-0.05)^{10}$ = ~40% chance of getting a false positive
With the Bonferroni method you use an $\alpha_b$ at the lowest end of the scale (i.e. $\alpha_b = \alpha/n$) to protect your family of $n$ tests at the $\alpha$ level. In other words, it is the most conservative. Now, you can increase $\alpha_b$ above the lower limit set by Bonferroni (i.e. make your test less conservative) and still protect your family of tests at the $\alpha$ level. There are many ways to do this, the Holm-Bonferroni method for example or better still False Discovery Rate
More Powerful
A good point brought up in the paper referenced is that the likelihood of type II errors is also increased so that truly important differences are deemed non-significant.
This is very important. A powerful test is one that finds significant results if they exist. By using the Bonferroni correction you end up with a less powerful test. As Bonferroni is conservative, the power is likely to be considerable reduced. Again, one of the alternative methods eg False Discovery Rate, will increase the power of the test. In other words, not only do you protect against false positives, you also improve your ability to find truly significant results.
So yes, you should apply some correction technique when you have multiple comparisons. And yes, Bonferroni should probably be avoided in favour of a less conservative and more powerful method
|
What's wrong with Bonferroni adjustments?
He summarized saying that Bonferroni adjustment have, at best, limited applications in biomedical research and should not be used when assessing evidence about specific hypothesis.
The Bonferroni cor
|
9,812
|
What's wrong with Bonferroni adjustments?
|
Thomas Perneger is not a statistician and his paper is full of mistakes. So I wouldn't take it too seriously. It's actually been heavily criticized by others.
For example, Aickin said Perneger's paper "consists almost entirely of errors": Aickin, "Other method for adjustment of multiple testing exists", BMJ. 1999 Jan 9; 318(7176): 127.
Also, none of the p-values in the original question are < .05 anyway, even without multiplicity adjustment. So it probably doesn't matter what adjustment (if any) is used.
|
What's wrong with Bonferroni adjustments?
|
Thomas Perneger is not a statistician and his paper is full of mistakes. So I wouldn't take it too seriously. It's actually been heavily criticized by others.
For example, Aickin said Perneger's paper
|
What's wrong with Bonferroni adjustments?
Thomas Perneger is not a statistician and his paper is full of mistakes. So I wouldn't take it too seriously. It's actually been heavily criticized by others.
For example, Aickin said Perneger's paper "consists almost entirely of errors": Aickin, "Other method for adjustment of multiple testing exists", BMJ. 1999 Jan 9; 318(7176): 127.
Also, none of the p-values in the original question are < .05 anyway, even without multiplicity adjustment. So it probably doesn't matter what adjustment (if any) is used.
|
What's wrong with Bonferroni adjustments?
Thomas Perneger is not a statistician and his paper is full of mistakes. So I wouldn't take it too seriously. It's actually been heavily criticized by others.
For example, Aickin said Perneger's paper
|
9,813
|
What's wrong with Bonferroni adjustments?
|
A nice discussion of Bonferroni correction and effect size http://beheco.oxfordjournals.org/content/15/6/1044.full.pdf+html
Also, Dunn-Sidak correction and Fisher's combined probabilities approach are worth considering as alternatives. Regardless of the approach, it is worth reporting both adjusted and raw p-values plus effect size, so that the reader can have the freedom of interpreting them.
|
What's wrong with Bonferroni adjustments?
|
A nice discussion of Bonferroni correction and effect size http://beheco.oxfordjournals.org/content/15/6/1044.full.pdf+html
Also, Dunn-Sidak correction and Fisher's combined probabilities approach are
|
What's wrong with Bonferroni adjustments?
A nice discussion of Bonferroni correction and effect size http://beheco.oxfordjournals.org/content/15/6/1044.full.pdf+html
Also, Dunn-Sidak correction and Fisher's combined probabilities approach are worth considering as alternatives. Regardless of the approach, it is worth reporting both adjusted and raw p-values plus effect size, so that the reader can have the freedom of interpreting them.
|
What's wrong with Bonferroni adjustments?
A nice discussion of Bonferroni correction and effect size http://beheco.oxfordjournals.org/content/15/6/1044.full.pdf+html
Also, Dunn-Sidak correction and Fisher's combined probabilities approach are
|
9,814
|
What's wrong with Bonferroni adjustments?
|
Maybe it's good to explain the ''reasoning behind'' multiple testing corrections like the one of Bonferroni. If that is clear then you will be able to judge yourself whether you should apply them or not.
In a hypothesis test one tries to find evidence for some known or assumed fact about the real world. It is similar to ''proof by contradiction'' in mathematics, i.e. if one wants to prove that e.g. a parameter $\mu$ is non-zero, then one will assume that the opposite is true, i.e. one assumes that $H_0: \mu=0$ and one tries to find something that is impossible under that assumption. In statistics things are rarely impossible, but they can be very improbable.
So if we want to show that $H_1: \mu \ne 0$ then we assume the opposite namely $H_0: \mu = 0$ and we try to find something very improbable. Very improbable is defined in terms of a probability lower than an a priori fixed significance level $\alpha$. Note that, because of the analogy I will use terms such as ''statistically proven'' or ''statistical evidence'', these terms aree just used for didactical reasons and are not used in general.
In order to find that ''low probability'' we draw a random sample form a distribution that is known when $H_0$ (our assumption of the ''opposite'' of what we want to prove) is true. As we assumted $H_0$ te be true we can compute the probability of this outcome (more precise something that is at least as extreme as this outcome).
As the sample is a random draw from a distribution, it may be that we obtain a low probability just by ''bad luck with the sample'' and then we reject $H_0$ just because we had bad luck with the sample. Rejecting $H_0$ means that we consider to have found evidence for $H_1$ but it is false evidence in these cases where we have bad luck with the sample.
False evidence is a bad thing in science because we believe to have gained true knowledge about the world, but in fact we may have had bad luck with the sample. This kinds of errors should consequently be controled. Therefore one should put an upper limit on the probability of this kind of evidence, or one should control the type I error. This is done by fixing an acceptable significance level in advance.
So if we fix our significance level at $5\%$ then we are saying that we are ready to reject $H_0$ when it is true (because of bad luck with the sample) with a chance of $5\%$. As (see supra) rejecting $H_0$ is ''statistical evidence'' for $H_1$ this means that we falsely consider $H_1$ as ''statistically proven''.
Assume now that we have two parameters, and we want to show that that at least one is different from zero. Follwing the logic of ''proof by contradiction'' we will assume $H_0: \mu_1=0 \& \mu_2=0$ versus $H_1: \mu1 \ne 0 | \mu_2 \ne 0$ and that we use a signficance level $\alpha=0.05$.
One possibility to do this is to split this hypothesis test and to test $H_0^{(1)}: \mu_1=0$ versus $H_0^{(1)}: \mu_1 \ne 0$ and to test $H_1^{(2)}: \mu_2=0$ versus $H_1^{(2)}: \mu_2 \ne 0$ both at the significance level $\alpha=0.05$.
To do both tests we draw one sample , so we use one and the same sample to do both of these tests. I may have bad luck with that one sample and erroneously reject $H_0^{(1)}$ but with that same sample I may also have bad luck with the sample for the second test and erroneously reject $H_0^{(1)}$
Therefore, the chance that at least one of the two is an erroneous rejection is 1 minus the probability that both are not rejected, i.e. $1-(1-0.05)^2=0.0975$, where it was assumed that both tests are independent. In other words, the type I error has ''inflated'' to 0.0975 which is almost double $\alpha$.
The important fact here is that the two tests are based on one and the sampe sample !
Note that we have assumed independence. If you can not assume independence then you can show, using the Bonferroni inequality$ that the type I error can inflate up to 0.1.
Note that Bonferroni is conservative and that Holm's stepwise procedure holds under the same assumptions as for Bonferroni, but Holm's procedure has more power.
When the variables are discrete it's better to use test statistics based on the minimum p-value and if you are ready to abandon type I error control when doing a massive number of tests then False Discovery Rate procedures may be more powerful.
EDIT :
If e.g. (see the example in the answer by @Frank Harrell)
$H_0^{(1)}: \mu_1=0$ versus $H_1^{(1)}: \mu_1 \ne 0$ is the a test for the effect of a chemotherapy and
$H_0^{(2)}: \mu_1=0$ versus $H_1^{(2)}: \mu_2 \ne 0$ is the test for the effect on tumor shrinkage,
then, in order to control the type I error at 5% for the hypothesis $H_0^{(12)}: \mu_1=0 \& \mu_2 = 0$ versus $H_1^{(12)}: \mu_1 \ne 0 | \mu_2 \ne 0$ (i.e. the test that at least one of them has an effect) can be carried out by testing (on the same sample)
$H_0^{(1)}$ versus $H_1^{(1)}$ at the 2.5% level and also $H_0^{(2)}$ versus $H_1^{(2)}$ at the 2.5% level.
|
What's wrong with Bonferroni adjustments?
|
Maybe it's good to explain the ''reasoning behind'' multiple testing corrections like the one of Bonferroni. If that is clear then you will be able to judge yourself whether you should apply them or
|
What's wrong with Bonferroni adjustments?
Maybe it's good to explain the ''reasoning behind'' multiple testing corrections like the one of Bonferroni. If that is clear then you will be able to judge yourself whether you should apply them or not.
In a hypothesis test one tries to find evidence for some known or assumed fact about the real world. It is similar to ''proof by contradiction'' in mathematics, i.e. if one wants to prove that e.g. a parameter $\mu$ is non-zero, then one will assume that the opposite is true, i.e. one assumes that $H_0: \mu=0$ and one tries to find something that is impossible under that assumption. In statistics things are rarely impossible, but they can be very improbable.
So if we want to show that $H_1: \mu \ne 0$ then we assume the opposite namely $H_0: \mu = 0$ and we try to find something very improbable. Very improbable is defined in terms of a probability lower than an a priori fixed significance level $\alpha$. Note that, because of the analogy I will use terms such as ''statistically proven'' or ''statistical evidence'', these terms aree just used for didactical reasons and are not used in general.
In order to find that ''low probability'' we draw a random sample form a distribution that is known when $H_0$ (our assumption of the ''opposite'' of what we want to prove) is true. As we assumted $H_0$ te be true we can compute the probability of this outcome (more precise something that is at least as extreme as this outcome).
As the sample is a random draw from a distribution, it may be that we obtain a low probability just by ''bad luck with the sample'' and then we reject $H_0$ just because we had bad luck with the sample. Rejecting $H_0$ means that we consider to have found evidence for $H_1$ but it is false evidence in these cases where we have bad luck with the sample.
False evidence is a bad thing in science because we believe to have gained true knowledge about the world, but in fact we may have had bad luck with the sample. This kinds of errors should consequently be controled. Therefore one should put an upper limit on the probability of this kind of evidence, or one should control the type I error. This is done by fixing an acceptable significance level in advance.
So if we fix our significance level at $5\%$ then we are saying that we are ready to reject $H_0$ when it is true (because of bad luck with the sample) with a chance of $5\%$. As (see supra) rejecting $H_0$ is ''statistical evidence'' for $H_1$ this means that we falsely consider $H_1$ as ''statistically proven''.
Assume now that we have two parameters, and we want to show that that at least one is different from zero. Follwing the logic of ''proof by contradiction'' we will assume $H_0: \mu_1=0 \& \mu_2=0$ versus $H_1: \mu1 \ne 0 | \mu_2 \ne 0$ and that we use a signficance level $\alpha=0.05$.
One possibility to do this is to split this hypothesis test and to test $H_0^{(1)}: \mu_1=0$ versus $H_0^{(1)}: \mu_1 \ne 0$ and to test $H_1^{(2)}: \mu_2=0$ versus $H_1^{(2)}: \mu_2 \ne 0$ both at the significance level $\alpha=0.05$.
To do both tests we draw one sample , so we use one and the same sample to do both of these tests. I may have bad luck with that one sample and erroneously reject $H_0^{(1)}$ but with that same sample I may also have bad luck with the sample for the second test and erroneously reject $H_0^{(1)}$
Therefore, the chance that at least one of the two is an erroneous rejection is 1 minus the probability that both are not rejected, i.e. $1-(1-0.05)^2=0.0975$, where it was assumed that both tests are independent. In other words, the type I error has ''inflated'' to 0.0975 which is almost double $\alpha$.
The important fact here is that the two tests are based on one and the sampe sample !
Note that we have assumed independence. If you can not assume independence then you can show, using the Bonferroni inequality$ that the type I error can inflate up to 0.1.
Note that Bonferroni is conservative and that Holm's stepwise procedure holds under the same assumptions as for Bonferroni, but Holm's procedure has more power.
When the variables are discrete it's better to use test statistics based on the minimum p-value and if you are ready to abandon type I error control when doing a massive number of tests then False Discovery Rate procedures may be more powerful.
EDIT :
If e.g. (see the example in the answer by @Frank Harrell)
$H_0^{(1)}: \mu_1=0$ versus $H_1^{(1)}: \mu_1 \ne 0$ is the a test for the effect of a chemotherapy and
$H_0^{(2)}: \mu_1=0$ versus $H_1^{(2)}: \mu_2 \ne 0$ is the test for the effect on tumor shrinkage,
then, in order to control the type I error at 5% for the hypothesis $H_0^{(12)}: \mu_1=0 \& \mu_2 = 0$ versus $H_1^{(12)}: \mu_1 \ne 0 | \mu_2 \ne 0$ (i.e. the test that at least one of them has an effect) can be carried out by testing (on the same sample)
$H_0^{(1)}$ versus $H_1^{(1)}$ at the 2.5% level and also $H_0^{(2)}$ versus $H_1^{(2)}$ at the 2.5% level.
|
What's wrong with Bonferroni adjustments?
Maybe it's good to explain the ''reasoning behind'' multiple testing corrections like the one of Bonferroni. If that is clear then you will be able to judge yourself whether you should apply them or
|
9,815
|
What's wrong with Bonferroni adjustments?
|
For one, it's extremely conservative. The Holm-Bonferroni method accomplishes what the Bonferonni method accomplishes (controlling the Family Wise Error Rate) while also being uniformly more powerful.
|
What's wrong with Bonferroni adjustments?
|
For one, it's extremely conservative. The Holm-Bonferroni method accomplishes what the Bonferonni method accomplishes (controlling the Family Wise Error Rate) while also being uniformly more powerful.
|
What's wrong with Bonferroni adjustments?
For one, it's extremely conservative. The Holm-Bonferroni method accomplishes what the Bonferonni method accomplishes (controlling the Family Wise Error Rate) while also being uniformly more powerful.
|
What's wrong with Bonferroni adjustments?
For one, it's extremely conservative. The Holm-Bonferroni method accomplishes what the Bonferonni method accomplishes (controlling the Family Wise Error Rate) while also being uniformly more powerful.
|
9,816
|
What's wrong with Bonferroni adjustments?
|
One should look at the "False Discovery Rate" methods as a less conservative alternative to Bonferroni. See
John D. Storey, "THE POSITIVE FALSE DISCOVERY RATE: A BAYESIAN
INTERPRETATION AND THE q-VALUE,"
The Annals of Statistics
2003, Vol. 31, No. 6, 2013β2035.
|
What's wrong with Bonferroni adjustments?
|
One should look at the "False Discovery Rate" methods as a less conservative alternative to Bonferroni. See
John D. Storey, "THE POSITIVE FALSE DISCOVERY RATE: A BAYESIAN
INTERPRETATION AND THE q-VA
|
What's wrong with Bonferroni adjustments?
One should look at the "False Discovery Rate" methods as a less conservative alternative to Bonferroni. See
John D. Storey, "THE POSITIVE FALSE DISCOVERY RATE: A BAYESIAN
INTERPRETATION AND THE q-VALUE,"
The Annals of Statistics
2003, Vol. 31, No. 6, 2013β2035.
|
What's wrong with Bonferroni adjustments?
One should look at the "False Discovery Rate" methods as a less conservative alternative to Bonferroni. See
John D. Storey, "THE POSITIVE FALSE DISCOVERY RATE: A BAYESIAN
INTERPRETATION AND THE q-VA
|
9,817
|
What's wrong with Bonferroni adjustments?
|
Suppose we have 20 null hypotheses, all of which happen to be true. Consider two cases:
If 20 scientists each independently pick and test one of the null hypotheses at p=0.05, on average they will correctly accept 19 of the hypotheses and incorrectly reject 1.
If a single scientist does one big study testing all 20 null hypotheses at p=0.05 each without the Bonferroni correction or another multiplicity correction, on average they will correctly accept 19 of the hypotheses and incorrectly reject 1.
Then the scientists in case 1 are each Bonferroni correction-compliant, but the scientist in case 2 is not. Why should the second case be considered any different from the first?
I suspect that studies testing many hypotheses are more likely to speculatively include hypotheses for which the relevant data happens to be available, e.g. "I know how strongly each person in my sample agrees with each of 20 opinions, guess I might as well check for correlation between every possible pair of opinions". So the average prior plausibility of the alternative hypotheses would be smaller. Ideally this would be handled by choosing a custom significance level to test each hypothesis at based on this prior plausibility. The Bonferroni correction could be seen as a step towards this.
|
What's wrong with Bonferroni adjustments?
|
Suppose we have 20 null hypotheses, all of which happen to be true. Consider two cases:
If 20 scientists each independently pick and test one of the null hypotheses at p=0.05, on average they will co
|
What's wrong with Bonferroni adjustments?
Suppose we have 20 null hypotheses, all of which happen to be true. Consider two cases:
If 20 scientists each independently pick and test one of the null hypotheses at p=0.05, on average they will correctly accept 19 of the hypotheses and incorrectly reject 1.
If a single scientist does one big study testing all 20 null hypotheses at p=0.05 each without the Bonferroni correction or another multiplicity correction, on average they will correctly accept 19 of the hypotheses and incorrectly reject 1.
Then the scientists in case 1 are each Bonferroni correction-compliant, but the scientist in case 2 is not. Why should the second case be considered any different from the first?
I suspect that studies testing many hypotheses are more likely to speculatively include hypotheses for which the relevant data happens to be available, e.g. "I know how strongly each person in my sample agrees with each of 20 opinions, guess I might as well check for correlation between every possible pair of opinions". So the average prior plausibility of the alternative hypotheses would be smaller. Ideally this would be handled by choosing a custom significance level to test each hypothesis at based on this prior plausibility. The Bonferroni correction could be seen as a step towards this.
|
What's wrong with Bonferroni adjustments?
Suppose we have 20 null hypotheses, all of which happen to be true. Consider two cases:
If 20 scientists each independently pick and test one of the null hypotheses at p=0.05, on average they will co
|
9,818
|
Is there any advantage of SVD over PCA?
|
As @ttnphns and @nick-cox said, SVD is a numerical method and PCA is an analysis approach (like least squares). You can do PCA using SVD, or you can do PCA doing the eigen-decomposition of $X^T X$ (or $X X^T$), or you can do PCA using many other methods, just like you can solve least squares with a dozen different algorithms like Newton's method or gradient descent or SVD etc.
So there is no "advantage" to SVD over PCA because it's like asking whether Newton's method is better than least squares: the two aren't comparable.
|
Is there any advantage of SVD over PCA?
|
As @ttnphns and @nick-cox said, SVD is a numerical method and PCA is an analysis approach (like least squares). You can do PCA using SVD, or you can do PCA doing the eigen-decomposition of $X^T X$ (or
|
Is there any advantage of SVD over PCA?
As @ttnphns and @nick-cox said, SVD is a numerical method and PCA is an analysis approach (like least squares). You can do PCA using SVD, or you can do PCA doing the eigen-decomposition of $X^T X$ (or $X X^T$), or you can do PCA using many other methods, just like you can solve least squares with a dozen different algorithms like Newton's method or gradient descent or SVD etc.
So there is no "advantage" to SVD over PCA because it's like asking whether Newton's method is better than least squares: the two aren't comparable.
|
Is there any advantage of SVD over PCA?
As @ttnphns and @nick-cox said, SVD is a numerical method and PCA is an analysis approach (like least squares). You can do PCA using SVD, or you can do PCA doing the eigen-decomposition of $X^T X$ (or
|
9,819
|
Is there any advantage of SVD over PCA?
|
The question is really asking if you should do Z-score normalization of the columns before applying the SVD. This is because PCA is the above transformation followed by the SVD. Sometimes doing the normalization is quite harmful. If your data is for example (transformed) word counts which are positive, subtracting the mean is definitely harmful. This is because zeros which represent the absence of a word in a document will be mapped to negative numbers with high magnitude. In linear problems the higher magnitude should be used to represent the range where your features are most sensitive. Also dividing by the standard deviation is harmful for this type of data.
|
Is there any advantage of SVD over PCA?
|
The question is really asking if you should do Z-score normalization of the columns before applying the SVD. This is because PCA is the above transformation followed by the SVD. Sometimes doing the no
|
Is there any advantage of SVD over PCA?
The question is really asking if you should do Z-score normalization of the columns before applying the SVD. This is because PCA is the above transformation followed by the SVD. Sometimes doing the normalization is quite harmful. If your data is for example (transformed) word counts which are positive, subtracting the mean is definitely harmful. This is because zeros which represent the absence of a word in a document will be mapped to negative numbers with high magnitude. In linear problems the higher magnitude should be used to represent the range where your features are most sensitive. Also dividing by the standard deviation is harmful for this type of data.
|
Is there any advantage of SVD over PCA?
The question is really asking if you should do Z-score normalization of the columns before applying the SVD. This is because PCA is the above transformation followed by the SVD. Sometimes doing the no
|
9,820
|
Why and when create a R package?
|
I don't program in R, but I program otherwise, and I see no R-specific issue here.
I imagine that most people first write something because they really want it for themselves. Conversely, any feeling that one should be publishing software because it is the thing to do should be resisted strongly. Smart people can be lousy programmers, and often are.
Going public seems a matter of being confident that you have something that is
as good or better than what is already public and fills a gap. Knowing that other people want to do the same thing is surely a boost.
If you are in doubt, don't publish. In many communities, there is a quality control problem of mediocre or buggy software released by uncritical or inexperienced programmers, although how bad the problem is remains open to debate. Optimists feel that trivia can just be ignored and that users will expose bugs and limitations fast enough; pessimists feel that we are drowning in poor quality stuff and it's hard to tell the winners from the losers. (On the other hand, the experience gained from publication is part of what allows programmers to improve.)
There could be a book on this, but a few pointers spring to mind:
Good quality documentation distinguishes good software as well as good code, indeed sometimes more obviously. Never underestimate how much work will be needed to provide the documentation that the code deserves. R programmers often seem to require that R users know just as much they do about the technique being implemented and document minimally....
As far as possible, test your code so that you can reproduce published solutions with real data from elsewhere. (If you are coding up something totally new, that may be more difficult, but not impossible. Also, you may often find yourself wondering whether it's their bug or yours.)
Programmers often underestimate the ability of users to throw unsuitable data at a program. So, think about what could go wrong, e.g. with missing values, zeros if a program assumes positive, etc., etc. (The benign take here is that it's the job of the users to find the problems and improve the code through their feedback, but a program that breaks down easily won't enhance your reputation.)
|
Why and when create a R package?
|
I don't program in R, but I program otherwise, and I see no R-specific issue here.
I imagine that most people first write something because they really want it for themselves. Conversely, any feeling
|
Why and when create a R package?
I don't program in R, but I program otherwise, and I see no R-specific issue here.
I imagine that most people first write something because they really want it for themselves. Conversely, any feeling that one should be publishing software because it is the thing to do should be resisted strongly. Smart people can be lousy programmers, and often are.
Going public seems a matter of being confident that you have something that is
as good or better than what is already public and fills a gap. Knowing that other people want to do the same thing is surely a boost.
If you are in doubt, don't publish. In many communities, there is a quality control problem of mediocre or buggy software released by uncritical or inexperienced programmers, although how bad the problem is remains open to debate. Optimists feel that trivia can just be ignored and that users will expose bugs and limitations fast enough; pessimists feel that we are drowning in poor quality stuff and it's hard to tell the winners from the losers. (On the other hand, the experience gained from publication is part of what allows programmers to improve.)
There could be a book on this, but a few pointers spring to mind:
Good quality documentation distinguishes good software as well as good code, indeed sometimes more obviously. Never underestimate how much work will be needed to provide the documentation that the code deserves. R programmers often seem to require that R users know just as much they do about the technique being implemented and document minimally....
As far as possible, test your code so that you can reproduce published solutions with real data from elsewhere. (If you are coding up something totally new, that may be more difficult, but not impossible. Also, you may often find yourself wondering whether it's their bug or yours.)
Programmers often underestimate the ability of users to throw unsuitable data at a program. So, think about what could go wrong, e.g. with missing values, zeros if a program assumes positive, etc., etc. (The benign take here is that it's the job of the users to find the problems and improve the code through their feedback, but a program that breaks down easily won't enhance your reputation.)
|
Why and when create a R package?
I don't program in R, but I program otherwise, and I see no R-specific issue here.
I imagine that most people first write something because they really want it for themselves. Conversely, any feeling
|
9,821
|
Why and when create a R package?
|
This is an important and practical question. Let's start by distinguishing between writing a package and publishing it on CRAN.
Reasons not to write a package:
Cost efficiency.
Lack of experience.
Reasons to write an R package:
Sharing with people and platforms.
Forces a tidy code and work process.
Ease of use (even for self) when functions start accumulating.
Reasons to submit a package (CRAN, Bioconductor,...):
Contribution to the community.
Ease of distribution.
|
Why and when create a R package?
|
This is an important and practical question. Let's start by distinguishing between writing a package and publishing it on CRAN.
Reasons not to write a package:
Cost efficiency.
Lack of experience.
|
Why and when create a R package?
This is an important and practical question. Let's start by distinguishing between writing a package and publishing it on CRAN.
Reasons not to write a package:
Cost efficiency.
Lack of experience.
Reasons to write an R package:
Sharing with people and platforms.
Forces a tidy code and work process.
Ease of use (even for self) when functions start accumulating.
Reasons to submit a package (CRAN, Bioconductor,...):
Contribution to the community.
Ease of distribution.
|
Why and when create a R package?
This is an important and practical question. Let's start by distinguishing between writing a package and publishing it on CRAN.
Reasons not to write a package:
Cost efficiency.
Lack of experience.
|
9,822
|
Why and when create a R package?
|
Remember that there is option #3; you may ask the maintainer of a relevant package to include your code or data.
|
Why and when create a R package?
|
Remember that there is option #3; you may ask the maintainer of a relevant package to include your code or data.
|
Why and when create a R package?
Remember that there is option #3; you may ask the maintainer of a relevant package to include your code or data.
|
Why and when create a R package?
Remember that there is option #3; you may ask the maintainer of a relevant package to include your code or data.
|
9,823
|
Why and when create a R package?
|
My personal triggers for packaging are:
I find I'm again using some code that I once wrote for another data analysis project.
I think I'll need the method I just wrote again.
A colleague asks me for code. A substantial part of the code I write is at least as much on request of colleagues (who use R but do not program that much themselves) as for myself.
I use the formal requirements of a package (documentation) to "force" me clean up and document my code.
I agree with @JohnRos that there is quite a difference between writing a package and publishing the package.
I usually package early, but then make the package only "semipublic". That is, it may be available on an internal server (or on r-forge), so my colleagues
can access the package. But I publish to CRAN only after the package has been used for months or even a few years by close colleagues. This doesn't bring up all bugs according to @Nick Cox's point #3, but a fair amount of them.
The versions of the package (I put the date after the dash in the version number) make it easy to fix things ("to do this and that, make sure you intall at least last week's version")
According to my working contract, my employer has the last word on the decision whether and how a package can be published to the outside world.
The thing where I do not yet have a good strategy for packaging is data.
Comments to your list of reasons:
the non-existence of other packages in the same sub-field ;
Not finding a package that does what I need for me triggers writing the code, but it doesn't have to do with the decision whether to package or not.
the need for exchanging with other researchers and allowing reproducibility of experiments ;
Definitively. Possibly already the need to share between several computers I use.
And amongst the points that could lead to a contrary decision :
part of the methods used already present in some other packages;
you could import those methods into your package/code: this is a point against writing such code, but has only indirectly to do with packaging.
number of new functions not sufficient to justify to create a new independent package.
For me, there is no minimum number of functions to start a package. In my experience packages tend to grow "automatically". On the contrary, after I've found myself a few times branching off a new package out of another (because e.g. some helper functions in the end turned out to be thematically different and useful in other situations, too), I'm now rather creating new packages immediately.
Also, if you didn't write documentation and tests, this can be a prohibitive amount of work when a "sufficient" number of functions for creating a package did accumulate.
(If you do write them immediately, then the additional effort of putting it into a package is negligible once you know the workflow).
|
Why and when create a R package?
|
My personal triggers for packaging are:
I find I'm again using some code that I once wrote for another data analysis project.
I think I'll need the method I just wrote again.
A colleague asks me for
|
Why and when create a R package?
My personal triggers for packaging are:
I find I'm again using some code that I once wrote for another data analysis project.
I think I'll need the method I just wrote again.
A colleague asks me for code. A substantial part of the code I write is at least as much on request of colleagues (who use R but do not program that much themselves) as for myself.
I use the formal requirements of a package (documentation) to "force" me clean up and document my code.
I agree with @JohnRos that there is quite a difference between writing a package and publishing the package.
I usually package early, but then make the package only "semipublic". That is, it may be available on an internal server (or on r-forge), so my colleagues
can access the package. But I publish to CRAN only after the package has been used for months or even a few years by close colleagues. This doesn't bring up all bugs according to @Nick Cox's point #3, but a fair amount of them.
The versions of the package (I put the date after the dash in the version number) make it easy to fix things ("to do this and that, make sure you intall at least last week's version")
According to my working contract, my employer has the last word on the decision whether and how a package can be published to the outside world.
The thing where I do not yet have a good strategy for packaging is data.
Comments to your list of reasons:
the non-existence of other packages in the same sub-field ;
Not finding a package that does what I need for me triggers writing the code, but it doesn't have to do with the decision whether to package or not.
the need for exchanging with other researchers and allowing reproducibility of experiments ;
Definitively. Possibly already the need to share between several computers I use.
And amongst the points that could lead to a contrary decision :
part of the methods used already present in some other packages;
you could import those methods into your package/code: this is a point against writing such code, but has only indirectly to do with packaging.
number of new functions not sufficient to justify to create a new independent package.
For me, there is no minimum number of functions to start a package. In my experience packages tend to grow "automatically". On the contrary, after I've found myself a few times branching off a new package out of another (because e.g. some helper functions in the end turned out to be thematically different and useful in other situations, too), I'm now rather creating new packages immediately.
Also, if you didn't write documentation and tests, this can be a prohibitive amount of work when a "sufficient" number of functions for creating a package did accumulate.
(If you do write them immediately, then the additional effort of putting it into a package is negligible once you know the workflow).
|
Why and when create a R package?
My personal triggers for packaging are:
I find I'm again using some code that I once wrote for another data analysis project.
I think I'll need the method I just wrote again.
A colleague asks me for
|
9,824
|
Why and when create a R package?
|
I'd say create a package whenever you are doing a large enough set of similar tasks in R that you would benefit from a package in which you can put things in a namespace (to avoid conflicts with similarly named functions), where you can write documentation. I even have a package on github for bundling up a grab bag of functions that aren't related, but I use so often that I thought they deserved documentation, man files, etc.
Another use case could be when submitting a paper, if you have a number of functions you could easily create a package, including documentation for those functions, examples for each function, and a tutorial on how to use it. And you don't need to put it on CRAN, as said in above answers. This could be awesome for reproducibility.
Three tools I'd say are important:
devtools pkg, to make it super easy to build packages (also see the wiki on the devtools github pages
roxygen2 pkg, to make writing documentation for your package easy
GitHub, You can use install_github (or similarly install_bitbucket, etc.) to install directly from GitHub, which is nice for sharing with others.
|
Why and when create a R package?
|
I'd say create a package whenever you are doing a large enough set of similar tasks in R that you would benefit from a package in which you can put things in a namespace (to avoid conflicts with simil
|
Why and when create a R package?
I'd say create a package whenever you are doing a large enough set of similar tasks in R that you would benefit from a package in which you can put things in a namespace (to avoid conflicts with similarly named functions), where you can write documentation. I even have a package on github for bundling up a grab bag of functions that aren't related, but I use so often that I thought they deserved documentation, man files, etc.
Another use case could be when submitting a paper, if you have a number of functions you could easily create a package, including documentation for those functions, examples for each function, and a tutorial on how to use it. And you don't need to put it on CRAN, as said in above answers. This could be awesome for reproducibility.
Three tools I'd say are important:
devtools pkg, to make it super easy to build packages (also see the wiki on the devtools github pages
roxygen2 pkg, to make writing documentation for your package easy
GitHub, You can use install_github (or similarly install_bitbucket, etc.) to install directly from GitHub, which is nice for sharing with others.
|
Why and when create a R package?
I'd say create a package whenever you are doing a large enough set of similar tasks in R that you would benefit from a package in which you can put things in a namespace (to avoid conflicts with simil
|
9,825
|
Why and when create a R package?
|
I agree with everything I read so far. All those reasons are good programming practice and do not apply to R in particular. However I find myself writing R packages most of the time, and for yet another reason. So I will add:
R-specific reason to write an R package:
because you write in C
Any time you use foreign languages such as C, C++ or FORTRAN (mostly for high performance computing), writing a package is largely worth the trouble. If you have more than one or two functions, you rapidly end up with files all over the place and dependencies between the R and C code that is difficult to maintain and to port.
|
Why and when create a R package?
|
I agree with everything I read so far. All those reasons are good programming practice and do not apply to R in particular. However I find myself writing R packages most of the time, and for yet anoth
|
Why and when create a R package?
I agree with everything I read so far. All those reasons are good programming practice and do not apply to R in particular. However I find myself writing R packages most of the time, and for yet another reason. So I will add:
R-specific reason to write an R package:
because you write in C
Any time you use foreign languages such as C, C++ or FORTRAN (mostly for high performance computing), writing a package is largely worth the trouble. If you have more than one or two functions, you rapidly end up with files all over the place and dependencies between the R and C code that is difficult to maintain and to port.
|
Why and when create a R package?
I agree with everything I read so far. All those reasons are good programming practice and do not apply to R in particular. However I find myself writing R packages most of the time, and for yet anoth
|
9,826
|
Why and when create a R package?
|
One reason not mentioned in the other excellent answers: You have a large or complex data analysis project. Packaging, first, the data as a package, and then extending with useful functions to transform, plot, or compute specific analyses. This way you get a documented version of the data complete with all the functions used to compute the reported analysis. Then the report(s) from the project can be written using knitr or other packages for reproducible research!
This could significantly save time if some reanalysis has to be done, or it could even be published (or semipublished) if the analysis are published.
|
Why and when create a R package?
|
One reason not mentioned in the other excellent answers: You have a large or complex data analysis project. Packaging, first, the data as a package, and then extending with useful functions to trans
|
Why and when create a R package?
One reason not mentioned in the other excellent answers: You have a large or complex data analysis project. Packaging, first, the data as a package, and then extending with useful functions to transform, plot, or compute specific analyses. This way you get a documented version of the data complete with all the functions used to compute the reported analysis. Then the report(s) from the project can be written using knitr or other packages for reproducible research!
This could significantly save time if some reanalysis has to be done, or it could even be published (or semipublished) if the analysis are published.
|
Why and when create a R package?
One reason not mentioned in the other excellent answers: You have a large or complex data analysis project. Packaging, first, the data as a package, and then extending with useful functions to trans
|
9,827
|
How much lung cancer is really caused by smoking? [closed]
|
For the US data:
You are confusing two important but different concepts in epidemiology: prevalence and incidence. A Wikipedia page describes the difference.
The anti-smoking warning that you show says that 9 of every 10 lung cancers that occur are caused by smoking. That's the incidence of smoking-related lung cancers among all lung cancers that occur. Incidence has to do with how frequently in time cases of each type initially occur.
The Table 2 that you present, however, is for "age-adjusted prevalence" of smoking status among people who presently have each of the listed diseases. Prevalence has to do with the fraction of each type of case that is found at a given time. Of people currently having lung cancer, 17.9% have never smoked.
So why can't you say that "17.9% of lung cancer ... occurs in never smokers"? Because that's the prevalence of never smokers among those who are currently lung cancer survivors, not the fraction of all lung cancer cases that occur in never smokers.
There's a big difference between prevalence and incidence here because smokers tend to die of lung cancer (and of other cancers, or from other causes) more quickly than never smokers. So at any given time, never smokers will thus be a higher fraction of all lung cancer survivors (prevalence) than their fraction in the total numbers of original cases (incidence).
For the Norway data:
What you present for Norway isn't directly comparable to the US data in terms of the relation between the risk of lung cancer and tobacco use, as you only show the use of manufactured cigarettes. The reference for cigarette consumption in Norway that you cite shows high use of self-rolled cigarettes and of pipe smoking (Figure 1 in that reference), with manufactured cigarettes representing less than 30% of Norwegian tobacco use until about 1980. These other forms of tobacco use aren't included in your graph for Norway, but would nevertheless be related to risk of lung cancer. In contrast, 75-80% of US tobacco use between 1955 and 2005, from your cited reference, was manufactured cigarettes. So you have to be careful with selective comparisons of tobacco consumption data, as manufactured cigarettes are not the entire story.
|
How much lung cancer is really caused by smoking? [closed]
|
For the US data:
You are confusing two important but different concepts in epidemiology: prevalence and incidence. A Wikipedia page describes the difference.
The anti-smoking warning that you show say
|
How much lung cancer is really caused by smoking? [closed]
For the US data:
You are confusing two important but different concepts in epidemiology: prevalence and incidence. A Wikipedia page describes the difference.
The anti-smoking warning that you show says that 9 of every 10 lung cancers that occur are caused by smoking. That's the incidence of smoking-related lung cancers among all lung cancers that occur. Incidence has to do with how frequently in time cases of each type initially occur.
The Table 2 that you present, however, is for "age-adjusted prevalence" of smoking status among people who presently have each of the listed diseases. Prevalence has to do with the fraction of each type of case that is found at a given time. Of people currently having lung cancer, 17.9% have never smoked.
So why can't you say that "17.9% of lung cancer ... occurs in never smokers"? Because that's the prevalence of never smokers among those who are currently lung cancer survivors, not the fraction of all lung cancer cases that occur in never smokers.
There's a big difference between prevalence and incidence here because smokers tend to die of lung cancer (and of other cancers, or from other causes) more quickly than never smokers. So at any given time, never smokers will thus be a higher fraction of all lung cancer survivors (prevalence) than their fraction in the total numbers of original cases (incidence).
For the Norway data:
What you present for Norway isn't directly comparable to the US data in terms of the relation between the risk of lung cancer and tobacco use, as you only show the use of manufactured cigarettes. The reference for cigarette consumption in Norway that you cite shows high use of self-rolled cigarettes and of pipe smoking (Figure 1 in that reference), with manufactured cigarettes representing less than 30% of Norwegian tobacco use until about 1980. These other forms of tobacco use aren't included in your graph for Norway, but would nevertheless be related to risk of lung cancer. In contrast, 75-80% of US tobacco use between 1955 and 2005, from your cited reference, was manufactured cigarettes. So you have to be careful with selective comparisons of tobacco consumption data, as manufactured cigarettes are not the entire story.
|
How much lung cancer is really caused by smoking? [closed]
For the US data:
You are confusing two important but different concepts in epidemiology: prevalence and incidence. A Wikipedia page describes the difference.
The anti-smoking warning that you show say
|
9,828
|
How much lung cancer is really caused by smoking? [closed]
|
What you're asking about is called the "Population Attributable Fraction"βthe number of cases in the entire population that can be attributed to the exposure (in this case, smoking). The formula for this is:
$$
PAF = \frac{P_{{\rm pop}}\times (RR-1)}{P_{{\rm pop}}\times (RR-1)+1}
$$
Here, $P_{{\rm pop}}$ is the proportion of exposed subjects in the population, and RR is the relative risk of developing the disease if you're exposed.
In the U.S., $P_{{\rm pop}}$ for smokers is $\approx 16\%$.
The RR for smoking is highly variable depending on what cancer you're talking about specifically, but using this document from the CDC, it appears the answer is $\approx 25$. So,
$$
PAF = \frac{0.16\times (24)}{(0.16\times 24)+1} = \frac{3.84}{4.84} = 0.793
$$
So that estimate you've linked to, which is effectively $0.90$ as their PAF, is a little aggressive. Though as @EdM notes, with a higher prevalence due to the time between smoking and developing lung cancer, you can get to a PAF of $0.90$ relatively easily.
|
How much lung cancer is really caused by smoking? [closed]
|
What you're asking about is called the "Population Attributable Fraction"βthe number of cases in the entire population that can be attributed to the exposure (in this case, smoking). The formula for t
|
How much lung cancer is really caused by smoking? [closed]
What you're asking about is called the "Population Attributable Fraction"βthe number of cases in the entire population that can be attributed to the exposure (in this case, smoking). The formula for this is:
$$
PAF = \frac{P_{{\rm pop}}\times (RR-1)}{P_{{\rm pop}}\times (RR-1)+1}
$$
Here, $P_{{\rm pop}}$ is the proportion of exposed subjects in the population, and RR is the relative risk of developing the disease if you're exposed.
In the U.S., $P_{{\rm pop}}$ for smokers is $\approx 16\%$.
The RR for smoking is highly variable depending on what cancer you're talking about specifically, but using this document from the CDC, it appears the answer is $\approx 25$. So,
$$
PAF = \frac{0.16\times (24)}{(0.16\times 24)+1} = \frac{3.84}{4.84} = 0.793
$$
So that estimate you've linked to, which is effectively $0.90$ as their PAF, is a little aggressive. Though as @EdM notes, with a higher prevalence due to the time between smoking and developing lung cancer, you can get to a PAF of $0.90$ relatively easily.
|
How much lung cancer is really caused by smoking? [closed]
What you're asking about is called the "Population Attributable Fraction"βthe number of cases in the entire population that can be attributed to the exposure (in this case, smoking). The formula for t
|
9,829
|
Is it meaningful to test for normality with a very small sample size (e.g., n = 6)?
|
Yes.
All hypothesis tests have two salient properties: their size (or "significance level"), a number which is directly related to confidence and expected false positive rates, and their power, which expresses the chance of false negatives. When sample sizes are small and you continue to insist on a small size (high confidence), the power gets worse. This means that small-sample tests usually cannot detect small or moderate differences. But they are still meaningful.
The K-S test assesses whether the sample appears to have come from a Normal distribution. A sample of six values will have to look highly non-normal indeed to fail this test. But if it does, you can interpret this rejection of the null exactly as you would interpret it with higher sample sizes. On the other hand, if the test fails to reject the null hypothesis, that tells you little, due to the high false negative rate. In particular, it would be relatively risky to act as if the underlying distribution were Normal.
One more thing to watch out for here: some software uses approximations to compute p-values from the test statistics. Often these approximations work well for large sample sizes but act poorly for very small sample sizes. When this is the case, you cannot trust that the p-value has been correctly computed, which means you cannot be sure that the desired test size has been attained. For details, consult your software documentation.
Some advice: The KS test is substantially less powerful for testing normality than other tests specifically constructed for this purpose. The best of them is probably the Shapiro-Wilk test, but others commonly used and almost as powerful are the Shapiro-Francia and Anderson-Darling.
This plot displays the distribution of the Kolmogorov-Smirnov test statistic in 10,000 samples of six normally-distributed variates:
Based on 100,000 additional samples, the upper 95th percentile (which estimates the critical value for this statistic for a test of size $\alpha=5\%$) is 0.520. An example of a sample that passes this test is the dataset
0.000, 0.001, 0.002, 1.000, 1.001, 1000000
The test statistic is 0.5 (which is less than the critical value). Such a sample would be rejected using the other tests of normality.
|
Is it meaningful to test for normality with a very small sample size (e.g., n = 6)?
|
Yes.
All hypothesis tests have two salient properties: their size (or "significance level"), a number which is directly related to confidence and expected false positive rates, and their power, which
|
Is it meaningful to test for normality with a very small sample size (e.g., n = 6)?
Yes.
All hypothesis tests have two salient properties: their size (or "significance level"), a number which is directly related to confidence and expected false positive rates, and their power, which expresses the chance of false negatives. When sample sizes are small and you continue to insist on a small size (high confidence), the power gets worse. This means that small-sample tests usually cannot detect small or moderate differences. But they are still meaningful.
The K-S test assesses whether the sample appears to have come from a Normal distribution. A sample of six values will have to look highly non-normal indeed to fail this test. But if it does, you can interpret this rejection of the null exactly as you would interpret it with higher sample sizes. On the other hand, if the test fails to reject the null hypothesis, that tells you little, due to the high false negative rate. In particular, it would be relatively risky to act as if the underlying distribution were Normal.
One more thing to watch out for here: some software uses approximations to compute p-values from the test statistics. Often these approximations work well for large sample sizes but act poorly for very small sample sizes. When this is the case, you cannot trust that the p-value has been correctly computed, which means you cannot be sure that the desired test size has been attained. For details, consult your software documentation.
Some advice: The KS test is substantially less powerful for testing normality than other tests specifically constructed for this purpose. The best of them is probably the Shapiro-Wilk test, but others commonly used and almost as powerful are the Shapiro-Francia and Anderson-Darling.
This plot displays the distribution of the Kolmogorov-Smirnov test statistic in 10,000 samples of six normally-distributed variates:
Based on 100,000 additional samples, the upper 95th percentile (which estimates the critical value for this statistic for a test of size $\alpha=5\%$) is 0.520. An example of a sample that passes this test is the dataset
0.000, 0.001, 0.002, 1.000, 1.001, 1000000
The test statistic is 0.5 (which is less than the critical value). Such a sample would be rejected using the other tests of normality.
|
Is it meaningful to test for normality with a very small sample size (e.g., n = 6)?
Yes.
All hypothesis tests have two salient properties: their size (or "significance level"), a number which is directly related to confidence and expected false positive rates, and their power, which
|
9,830
|
Is it meaningful to test for normality with a very small sample size (e.g., n = 6)?
|
As @whuber asked in the comments, a validation for my categorical NO. edit : with the shapiro test, as the one-sample ks test is in fact wrongly used. Whuber is correct: For correct use of the Kolmogorov-Smirnov test, you have to specify the distributional parameters and not extract them from the data. This is however what is done in statistical packages like SPSS for a one-sample KS-test.
You try to say something about the distribution, and you want to check if you can apply a t-test. So this test is done to confirm that the data does not depart from normality significantly enough to make the underlying assumptions of the analysis invalid. Hence, You are not interested in the type I-error, but in the type II error.
Now one has to define "significantly different" to be able to calculate the minimum n for acceptable power (say 0.8). With distributions, that's not straightforward to define. Hence, I didn't answer the question, as I can't give a sensible answer apart from the rule-of-thumb I use: n > 15 and n < 50. Based on what? Gut feeling basically, so I can't defend that choice apart from experience.
But I do know that with only 6 values your type II-error is bound to be almost 1, making your power close to 0. With 6 observations, the Shapiro test cannot distinguish between a normal, poisson, uniform or even exponential distribution. With a type II-error being almost 1, your test result is meaningless.
To illustrate normality testing with the shapiro-test :
shapiro.test(rnorm(6)) # test a the normal distribution
shapiro.test(rpois(6,4)) # test a poisson distribution
shapiro.test(runif(6,1,10)) # test a uniform distribution
shapiro.test(rexp(6,2)) # test a exponential distribution
shapiro.test(rlnorm(6)) # test a log-normal distribution
The only where about half of the values are smaller than 0.05, is the last one. Which is also the most extreme case.
if you want to find out what's the minimum n that gives you a power you like with the shapiro test, one can do a simulation like this :
results <- sapply(5:50,function(i){
p.value <- replicate(100,{
y <- rexp(i,2)
shapiro.test(y)$p.value
})
pow <- sum(p.value < 0.05)/100
c(i,pow)
})
which gives you a power analysis like this :
from which I conclude that you need roughly minimum 20 values to distinguish an exponential from a normal distribution in 80% of the cases.
code plot :
plot(lowess(results[2,]~results[1,],f=1/6),type="l",col="red",
main="Power simulation for exponential distribution",
xlab="n",
ylab="power"
)
|
Is it meaningful to test for normality with a very small sample size (e.g., n = 6)?
|
As @whuber asked in the comments, a validation for my categorical NO. edit : with the shapiro test, as the one-sample ks test is in fact wrongly used. Whuber is correct: For correct use of the Kolmogo
|
Is it meaningful to test for normality with a very small sample size (e.g., n = 6)?
As @whuber asked in the comments, a validation for my categorical NO. edit : with the shapiro test, as the one-sample ks test is in fact wrongly used. Whuber is correct: For correct use of the Kolmogorov-Smirnov test, you have to specify the distributional parameters and not extract them from the data. This is however what is done in statistical packages like SPSS for a one-sample KS-test.
You try to say something about the distribution, and you want to check if you can apply a t-test. So this test is done to confirm that the data does not depart from normality significantly enough to make the underlying assumptions of the analysis invalid. Hence, You are not interested in the type I-error, but in the type II error.
Now one has to define "significantly different" to be able to calculate the minimum n for acceptable power (say 0.8). With distributions, that's not straightforward to define. Hence, I didn't answer the question, as I can't give a sensible answer apart from the rule-of-thumb I use: n > 15 and n < 50. Based on what? Gut feeling basically, so I can't defend that choice apart from experience.
But I do know that with only 6 values your type II-error is bound to be almost 1, making your power close to 0. With 6 observations, the Shapiro test cannot distinguish between a normal, poisson, uniform or even exponential distribution. With a type II-error being almost 1, your test result is meaningless.
To illustrate normality testing with the shapiro-test :
shapiro.test(rnorm(6)) # test a the normal distribution
shapiro.test(rpois(6,4)) # test a poisson distribution
shapiro.test(runif(6,1,10)) # test a uniform distribution
shapiro.test(rexp(6,2)) # test a exponential distribution
shapiro.test(rlnorm(6)) # test a log-normal distribution
The only where about half of the values are smaller than 0.05, is the last one. Which is also the most extreme case.
if you want to find out what's the minimum n that gives you a power you like with the shapiro test, one can do a simulation like this :
results <- sapply(5:50,function(i){
p.value <- replicate(100,{
y <- rexp(i,2)
shapiro.test(y)$p.value
})
pow <- sum(p.value < 0.05)/100
c(i,pow)
})
which gives you a power analysis like this :
from which I conclude that you need roughly minimum 20 values to distinguish an exponential from a normal distribution in 80% of the cases.
code plot :
plot(lowess(results[2,]~results[1,],f=1/6),type="l",col="red",
main="Power simulation for exponential distribution",
xlab="n",
ylab="power"
)
|
Is it meaningful to test for normality with a very small sample size (e.g., n = 6)?
As @whuber asked in the comments, a validation for my categorical NO. edit : with the shapiro test, as the one-sample ks test is in fact wrongly used. Whuber is correct: For correct use of the Kolmogo
|
9,831
|
Is it meaningful to test for normality with a very small sample size (e.g., n = 6)?
|
Question posed here have some misconception that why Normality check is required for a sample size of 6. Here the main objective is βto test whether the time spent in the code version A is differ from the time spent in the code version B or not (This is my H1)β. When the word βdifferβ is used, is it one tail test?. However testing of Normality is a second step. The first step is to check the adequacy of predetermined (1-Ξ²) power of the test for a given sample size when the power is very bad then what is the use of testing of normality condition?. Normality condition checking will help us in deciding whether to go Parametric or Non-Parametric test?. If your sample size not having adequate power why one should think of testing of Normality?. When there is no idea about the parent population from which samples are coming and the sample size is very small (< 10) it is always Non-parametric tests are justifiable.
|
Is it meaningful to test for normality with a very small sample size (e.g., n = 6)?
|
Question posed here have some misconception that why Normality check is required for a sample size of 6. Here the main objective is βto test whether the time spent in the code version A is differ fr
|
Is it meaningful to test for normality with a very small sample size (e.g., n = 6)?
Question posed here have some misconception that why Normality check is required for a sample size of 6. Here the main objective is βto test whether the time spent in the code version A is differ from the time spent in the code version B or not (This is my H1)β. When the word βdifferβ is used, is it one tail test?. However testing of Normality is a second step. The first step is to check the adequacy of predetermined (1-Ξ²) power of the test for a given sample size when the power is very bad then what is the use of testing of normality condition?. Normality condition checking will help us in deciding whether to go Parametric or Non-Parametric test?. If your sample size not having adequate power why one should think of testing of Normality?. When there is no idea about the parent population from which samples are coming and the sample size is very small (< 10) it is always Non-parametric tests are justifiable.
|
Is it meaningful to test for normality with a very small sample size (e.g., n = 6)?
Question posed here have some misconception that why Normality check is required for a sample size of 6. Here the main objective is βto test whether the time spent in the code version A is differ fr
|
9,832
|
How to interpret coefficient standard errors in linear regression?
|
Parameter estimates, like a sample mean or an OLS regression coefficient, are sample statistics that we use to draw inferences about the corresponding population parameters. The population parameters are what we really care about, but because we don't have access to the whole population (usually assumed to be infinite), we must use this approach instead. However, there are certain uncomfortable facts that come with this approach. For example, if we took another sample, and calculated the statistic to estimate the parameter again, we would almost certainly find that it differs. Moreover, neither estimate is likely to quite match the true parameter value that we want to know. In fact, if we did this over and over, continuing to sample and estimate forever, we would find that the relative frequency of the different estimate values followed a probability distribution. The central limit theorem suggests that this distribution is likely to be normal. We need a way to quantify the amount of uncertainty in that distribution. That's what the standard error does for you.
In your example, you want to know the slope of the linear relationship between x1 and y in the population, but you only have access to your sample. In your sample, that slope is .51, but without knowing how much variability there is in it's corresponding sampling distribution, it's difficult to know what to make of that number. The standard error, .05 in this case, is the standard deviation of that sampling distribution. To calculate significance, you divide the estimate by the SE and look up the quotient on a t table. Thus, larger SEs mean lower significance.
The residual standard deviation has nothing to do with the sampling distributions of your slopes. It is just the standard deviation of your sample conditional on your model. There is no contradiction, nor could there be. As for how you have a larger SD with a high R^2 and only 40 data points, I would guess you have the opposite of range restriction--your x values are spread very widely.
|
How to interpret coefficient standard errors in linear regression?
|
Parameter estimates, like a sample mean or an OLS regression coefficient, are sample statistics that we use to draw inferences about the corresponding population parameters. The population parameters
|
How to interpret coefficient standard errors in linear regression?
Parameter estimates, like a sample mean or an OLS regression coefficient, are sample statistics that we use to draw inferences about the corresponding population parameters. The population parameters are what we really care about, but because we don't have access to the whole population (usually assumed to be infinite), we must use this approach instead. However, there are certain uncomfortable facts that come with this approach. For example, if we took another sample, and calculated the statistic to estimate the parameter again, we would almost certainly find that it differs. Moreover, neither estimate is likely to quite match the true parameter value that we want to know. In fact, if we did this over and over, continuing to sample and estimate forever, we would find that the relative frequency of the different estimate values followed a probability distribution. The central limit theorem suggests that this distribution is likely to be normal. We need a way to quantify the amount of uncertainty in that distribution. That's what the standard error does for you.
In your example, you want to know the slope of the linear relationship between x1 and y in the population, but you only have access to your sample. In your sample, that slope is .51, but without knowing how much variability there is in it's corresponding sampling distribution, it's difficult to know what to make of that number. The standard error, .05 in this case, is the standard deviation of that sampling distribution. To calculate significance, you divide the estimate by the SE and look up the quotient on a t table. Thus, larger SEs mean lower significance.
The residual standard deviation has nothing to do with the sampling distributions of your slopes. It is just the standard deviation of your sample conditional on your model. There is no contradiction, nor could there be. As for how you have a larger SD with a high R^2 and only 40 data points, I would guess you have the opposite of range restriction--your x values are spread very widely.
|
How to interpret coefficient standard errors in linear regression?
Parameter estimates, like a sample mean or an OLS regression coefficient, are sample statistics that we use to draw inferences about the corresponding population parameters. The population parameters
|
9,833
|
How to test the autocorrelation of the residuals?
|
There are probably many ways to do this but the first one that comes to mind is based on linear regression. You can regress the consecutive residuals against each other and test for a significant slope. If there is auto-correlation, then there should be a linear relationship between consecutive residuals. To finish the code you've written, you could do:
mod = lm(prices[,1] ~ prices[,2])
res = mod$res
n = length(res)
mod2 = lm(res[-n] ~ res[-1])
summary(mod2)
mod2 is a linear regression of the time $t$ error, $\varepsilon_{t}$, against the time $t-1$ error, $\varepsilon_{t-1}$. If the coefficient for res[-1] is significant, you have evidence of autocorrelation in the residuals.
Note: This implicitly assumes that the residuals are autoregressive in the sense that only $\varepsilon_{t-1}$ is important when predicting $\varepsilon_{t}$. In reality there could be longer range dependencies. In that case, this method I've described should be interpreted as the one-lag autoregressive approximation to the true autocorrelation structure in $\varepsilon$.
|
How to test the autocorrelation of the residuals?
|
There are probably many ways to do this but the first one that comes to mind is based on linear regression. You can regress the consecutive residuals against each other and test for a significant slop
|
How to test the autocorrelation of the residuals?
There are probably many ways to do this but the first one that comes to mind is based on linear regression. You can regress the consecutive residuals against each other and test for a significant slope. If there is auto-correlation, then there should be a linear relationship between consecutive residuals. To finish the code you've written, you could do:
mod = lm(prices[,1] ~ prices[,2])
res = mod$res
n = length(res)
mod2 = lm(res[-n] ~ res[-1])
summary(mod2)
mod2 is a linear regression of the time $t$ error, $\varepsilon_{t}$, against the time $t-1$ error, $\varepsilon_{t-1}$. If the coefficient for res[-1] is significant, you have evidence of autocorrelation in the residuals.
Note: This implicitly assumes that the residuals are autoregressive in the sense that only $\varepsilon_{t-1}$ is important when predicting $\varepsilon_{t}$. In reality there could be longer range dependencies. In that case, this method I've described should be interpreted as the one-lag autoregressive approximation to the true autocorrelation structure in $\varepsilon$.
|
How to test the autocorrelation of the residuals?
There are probably many ways to do this but the first one that comes to mind is based on linear regression. You can regress the consecutive residuals against each other and test for a significant slop
|
9,834
|
How to test the autocorrelation of the residuals?
|
Use the Durbin-Watson test, implemented in the lmtest package.
dwtest(prices[,1] ~ prices[,2])
|
How to test the autocorrelation of the residuals?
|
Use the Durbin-Watson test, implemented in the lmtest package.
dwtest(prices[,1] ~ prices[,2])
|
How to test the autocorrelation of the residuals?
Use the Durbin-Watson test, implemented in the lmtest package.
dwtest(prices[,1] ~ prices[,2])
|
How to test the autocorrelation of the residuals?
Use the Durbin-Watson test, implemented in the lmtest package.
dwtest(prices[,1] ~ prices[,2])
|
9,835
|
How to test the autocorrelation of the residuals?
|
The DW Test or the Linear Regression test are not robust to anomalies in the data. If you have Pulses, Seasonal Pulses , Level Shifts or Local Time Trends these tests are useless as these untreated components inflate the variance of the errors thus downward biasing the tests causing you ( as you have found out ) to incorrectly accept the null hypothesis of no auto-correlation. Before these two tests or any other parametric test that I am aware of can be used one has to "prove" that the mean of the residuals is not statistically significantly different from 0.0 EVERYWHERE otherwise the underlying assumptions are invalid. It is well known that one of the constraints of the DW test is its assumption that the regression errors are normally distributed. Note normally distributed means among other things : No anomalies ( see http://homepage.newschool.edu/~canjels/permdw12.pdf ). Additionally the DW test only test for auto-correlation of lag 1. Your data might have a weekly/seasonal effect and this would go undiagnosed and furthermore , untreated , would downward bias the DW test.
|
How to test the autocorrelation of the residuals?
|
The DW Test or the Linear Regression test are not robust to anomalies in the data. If you have Pulses, Seasonal Pulses , Level Shifts or Local Time Trends these tests are useless as these untreated co
|
How to test the autocorrelation of the residuals?
The DW Test or the Linear Regression test are not robust to anomalies in the data. If you have Pulses, Seasonal Pulses , Level Shifts or Local Time Trends these tests are useless as these untreated components inflate the variance of the errors thus downward biasing the tests causing you ( as you have found out ) to incorrectly accept the null hypothesis of no auto-correlation. Before these two tests or any other parametric test that I am aware of can be used one has to "prove" that the mean of the residuals is not statistically significantly different from 0.0 EVERYWHERE otherwise the underlying assumptions are invalid. It is well known that one of the constraints of the DW test is its assumption that the regression errors are normally distributed. Note normally distributed means among other things : No anomalies ( see http://homepage.newschool.edu/~canjels/permdw12.pdf ). Additionally the DW test only test for auto-correlation of lag 1. Your data might have a weekly/seasonal effect and this would go undiagnosed and furthermore , untreated , would downward bias the DW test.
|
How to test the autocorrelation of the residuals?
The DW Test or the Linear Regression test are not robust to anomalies in the data. If you have Pulses, Seasonal Pulses , Level Shifts or Local Time Trends these tests are useless as these untreated co
|
9,836
|
How to test the autocorrelation of the residuals?
|
2021: R Provides an Autocorrelation Function - acf
I'm assuming that the other answers posted were created before the acf function existed in R.
However, in 2021, there is a dedicated function for calculating the autocorrelation.
Here's how to use it:
# calculate the ACF for lags between 1 and 20 (inclusive)
autocorrelation <- acf(your.data.here, lag.max=20, plot=FALSE)
# Plot figure
plot(autocorrelation,
main="Autocorrelation",
xlab="Lag Parameter",
ylab="ACF")
Reference:
https://www.datacamp.com/community/tutorials/autocorrelation-r
|
How to test the autocorrelation of the residuals?
|
2021: R Provides an Autocorrelation Function - acf
I'm assuming that the other answers posted were created before the acf function existed in R.
However, in 2021, there is a dedicated function for cal
|
How to test the autocorrelation of the residuals?
2021: R Provides an Autocorrelation Function - acf
I'm assuming that the other answers posted were created before the acf function existed in R.
However, in 2021, there is a dedicated function for calculating the autocorrelation.
Here's how to use it:
# calculate the ACF for lags between 1 and 20 (inclusive)
autocorrelation <- acf(your.data.here, lag.max=20, plot=FALSE)
# Plot figure
plot(autocorrelation,
main="Autocorrelation",
xlab="Lag Parameter",
ylab="ACF")
Reference:
https://www.datacamp.com/community/tutorials/autocorrelation-r
|
How to test the autocorrelation of the residuals?
2021: R Provides an Autocorrelation Function - acf
I'm assuming that the other answers posted were created before the acf function existed in R.
However, in 2021, there is a dedicated function for cal
|
9,837
|
Why do linear regression and ANOVA give different $p$-value in case of considering interaction between variable?
|
The fit for lm() and aov() are identical but the reporting is different. The t tests are the marginal impact of the variables in question, given the presence of all the other variables. The F tests are sequential - so they test for the importance of time in the presence of nothing but the intercept, of treat in the presence of nothing but the intercept and time, and of the interaction in the presence of all the above.
Assuming you are interested in the significance of treat, I suggest you fit two models, one with, and one without, compare the two by putting both models in anova(), and use that F test. This will test treat and the interaction simultaneously.
Consider the following:
> xx.2 <- as.data.frame(matrix(c(8.788269, 1, 0,
+ 7.964719, 6, 0,
+ 8.204051, 12, 0,
+ 9.041368, 24, 0,
+ 8.181555, 48, 0,
+ 8.041419, 96, 0,
+ 7.992336, 144, 0,
+ 7.948658, 1, 1,
+ 8.090211, 6, 1,
+ 8.031459, 12, 1,
+ 8.118308, 24, 1,
+ 7.699051, 48, 1,
+ 7.537120, 96, 1,
+ 7.268570, 144, 1), byrow=T, ncol=3))
> names(xx.2) <- c("value", "time", "treat")
>
> mod1 <- lm(value~time*treat, data=xx.2)
> anova(mod1)
Analysis of Variance Table
Response: value
Df Sum Sq Mean Sq F value Pr(>F)
time 1 0.77259 0.77259 8.5858 0.01504 *
treat 1 0.88520 0.88520 9.8372 0.01057 *
time:treat 1 0.03260 0.03260 0.3623 0.56064
Residuals 10 0.89985 0.08998
---
Signif. codes: 0 β***β 0.001 β**β 0.01 β*β 0.05 β.β 0.1 β β 1
> mod2 <- aov(value~time*treat, data=xx.2)
> anova(mod2)
Analysis of Variance Table
Response: value
Df Sum Sq Mean Sq F value Pr(>F)
time 1 0.77259 0.77259 8.5858 0.01504 *
treat 1 0.88520 0.88520 9.8372 0.01057 *
time:treat 1 0.03260 0.03260 0.3623 0.56064
Residuals 10 0.89985 0.08998
---
Signif. codes: 0 β***β 0.001 β**β 0.01 β*β 0.05 β.β 0.1 β β 1
> summary(mod2)
Df Sum Sq Mean Sq F value Pr(>F)
time 1 0.7726 0.7726 8.586 0.0150 *
treat 1 0.8852 0.8852 9.837 0.0106 *
time:treat 1 0.0326 0.0326 0.362 0.5606
Residuals 10 0.8998 0.0900
---
Signif. codes: 0 β***β 0.001 β**β 0.01 β*β 0.05 β.β 0.1 β β 1
> summary(mod1)
Call:
lm(formula = value ~ time * treat, data = xx.2)
Residuals:
Min 1Q Median 3Q Max
-0.50627 -0.12345 0.00296 0.04124 0.63785
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 8.493476 0.156345 54.325 1.08e-13 ***
time -0.003748 0.002277 -1.646 0.1307
treat -0.411271 0.221106 -1.860 0.0925 .
time:treat -0.001938 0.003220 -0.602 0.5606
---
Signif. codes: 0 β***β 0.001 β**β 0.01 β*β 0.05 β.β 0.1 β β 1
Residual standard error: 0.3 on 10 degrees of freedom
Multiple R-squared: 0.6526, Adjusted R-squared: 0.5484
F-statistic: 6.262 on 3 and 10 DF, p-value: 0.01154
|
Why do linear regression and ANOVA give different $p$-value in case of considering interaction betwe
|
The fit for lm() and aov() are identical but the reporting is different. The t tests are the marginal impact of the variables in question, given the presence of all the other variables. The F tests
|
Why do linear regression and ANOVA give different $p$-value in case of considering interaction between variable?
The fit for lm() and aov() are identical but the reporting is different. The t tests are the marginal impact of the variables in question, given the presence of all the other variables. The F tests are sequential - so they test for the importance of time in the presence of nothing but the intercept, of treat in the presence of nothing but the intercept and time, and of the interaction in the presence of all the above.
Assuming you are interested in the significance of treat, I suggest you fit two models, one with, and one without, compare the two by putting both models in anova(), and use that F test. This will test treat and the interaction simultaneously.
Consider the following:
> xx.2 <- as.data.frame(matrix(c(8.788269, 1, 0,
+ 7.964719, 6, 0,
+ 8.204051, 12, 0,
+ 9.041368, 24, 0,
+ 8.181555, 48, 0,
+ 8.041419, 96, 0,
+ 7.992336, 144, 0,
+ 7.948658, 1, 1,
+ 8.090211, 6, 1,
+ 8.031459, 12, 1,
+ 8.118308, 24, 1,
+ 7.699051, 48, 1,
+ 7.537120, 96, 1,
+ 7.268570, 144, 1), byrow=T, ncol=3))
> names(xx.2) <- c("value", "time", "treat")
>
> mod1 <- lm(value~time*treat, data=xx.2)
> anova(mod1)
Analysis of Variance Table
Response: value
Df Sum Sq Mean Sq F value Pr(>F)
time 1 0.77259 0.77259 8.5858 0.01504 *
treat 1 0.88520 0.88520 9.8372 0.01057 *
time:treat 1 0.03260 0.03260 0.3623 0.56064
Residuals 10 0.89985 0.08998
---
Signif. codes: 0 β***β 0.001 β**β 0.01 β*β 0.05 β.β 0.1 β β 1
> mod2 <- aov(value~time*treat, data=xx.2)
> anova(mod2)
Analysis of Variance Table
Response: value
Df Sum Sq Mean Sq F value Pr(>F)
time 1 0.77259 0.77259 8.5858 0.01504 *
treat 1 0.88520 0.88520 9.8372 0.01057 *
time:treat 1 0.03260 0.03260 0.3623 0.56064
Residuals 10 0.89985 0.08998
---
Signif. codes: 0 β***β 0.001 β**β 0.01 β*β 0.05 β.β 0.1 β β 1
> summary(mod2)
Df Sum Sq Mean Sq F value Pr(>F)
time 1 0.7726 0.7726 8.586 0.0150 *
treat 1 0.8852 0.8852 9.837 0.0106 *
time:treat 1 0.0326 0.0326 0.362 0.5606
Residuals 10 0.8998 0.0900
---
Signif. codes: 0 β***β 0.001 β**β 0.01 β*β 0.05 β.β 0.1 β β 1
> summary(mod1)
Call:
lm(formula = value ~ time * treat, data = xx.2)
Residuals:
Min 1Q Median 3Q Max
-0.50627 -0.12345 0.00296 0.04124 0.63785
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 8.493476 0.156345 54.325 1.08e-13 ***
time -0.003748 0.002277 -1.646 0.1307
treat -0.411271 0.221106 -1.860 0.0925 .
time:treat -0.001938 0.003220 -0.602 0.5606
---
Signif. codes: 0 β***β 0.001 β**β 0.01 β*β 0.05 β.β 0.1 β β 1
Residual standard error: 0.3 on 10 degrees of freedom
Multiple R-squared: 0.6526, Adjusted R-squared: 0.5484
F-statistic: 6.262 on 3 and 10 DF, p-value: 0.01154
|
Why do linear regression and ANOVA give different $p$-value in case of considering interaction betwe
The fit for lm() and aov() are identical but the reporting is different. The t tests are the marginal impact of the variables in question, given the presence of all the other variables. The F tests
|
9,838
|
Why do linear regression and ANOVA give different $p$-value in case of considering interaction between variable?
|
Peter Ellis' answer is excellent, but there is another point to be made. The $t$-test statistic (and its $p$-value) is a test of whether $\beta = 0$. The $F$-test on the anova() printout is whether the added variable significantly reduces the residual sum of squares.
The $t$-test is order-independent, while the $F$-test is not. Hence Peter's suggestion that you try the variables in different orders. It is also possible that variables significant in one test may not be significant in the other (and vice-versa).
My sense (and other contributors are welcome to correct me) is that when you're trying to predict phenomena (as in a systems application), you are most interested in reducing variance with the fewest predictors, and therefore want the anova() results. If you are trying to establish the marginal effect of $X$ on $y$, however, you will be most concerned with significance of your particular $\beta$ of interest, and all other variables will just control for alternate explanations your peer reviewers will try to find.
|
Why do linear regression and ANOVA give different $p$-value in case of considering interaction betwe
|
Peter Ellis' answer is excellent, but there is another point to be made. The $t$-test statistic (and its $p$-value) is a test of whether $\beta = 0$. The $F$-test on the anova() printout is whether th
|
Why do linear regression and ANOVA give different $p$-value in case of considering interaction between variable?
Peter Ellis' answer is excellent, but there is another point to be made. The $t$-test statistic (and its $p$-value) is a test of whether $\beta = 0$. The $F$-test on the anova() printout is whether the added variable significantly reduces the residual sum of squares.
The $t$-test is order-independent, while the $F$-test is not. Hence Peter's suggestion that you try the variables in different orders. It is also possible that variables significant in one test may not be significant in the other (and vice-versa).
My sense (and other contributors are welcome to correct me) is that when you're trying to predict phenomena (as in a systems application), you are most interested in reducing variance with the fewest predictors, and therefore want the anova() results. If you are trying to establish the marginal effect of $X$ on $y$, however, you will be most concerned with significance of your particular $\beta$ of interest, and all other variables will just control for alternate explanations your peer reviewers will try to find.
|
Why do linear regression and ANOVA give different $p$-value in case of considering interaction betwe
Peter Ellis' answer is excellent, but there is another point to be made. The $t$-test statistic (and its $p$-value) is a test of whether $\beta = 0$. The $F$-test on the anova() printout is whether th
|
9,839
|
Why do linear regression and ANOVA give different $p$-value in case of considering interaction between variable?
|
The above two answers are great, but thought I'd add a bit more. Another nugget of information can be gleaned from here.
When you report the lm() results with the interaction term, you're saying something like: "treat 1 is different than treat 0 (beta != 0, p=0.0925), when time is set to the base value of 1". Whereas the anova() results (as previously mentioned) ignore any other variables and concerns itself only with differences in variance.
You can prove this by removing your interaction term and using a simple model with only two main effects (m1):
> m1 = lm(value~time+treat,data=dat)
> summary(m1)
Call:
lm(formula = value ~ time + treat, data = dat)
Residuals:
Min 1Q Median 3Q Max
-0.54627 -0.10533 -0.04574 0.11975 0.61528
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 8.539293 0.132545 64.426 1.56e-15 ***
time -0.004717 0.001562 -3.019 0.01168 *
treat -0.502906 0.155626 -3.232 0.00799 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.2911 on 11 degrees of freedom
Multiple R-squared: 0.64, Adjusted R-squared: 0.5746
F-statistic: 9.778 on 2 and 11 DF, p-value: 0.003627
> anova(m1)
Analysis of Variance Table
Response: value
Df Sum Sq Mean Sq F value Pr(>F)
time 1 0.77259 0.77259 9.1142 0.011677 *
treat 1 0.88520 0.88520 10.4426 0.007994 **
Residuals 11 0.93245 0.08477
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
In this case we see that the reported p-values are the same; that's because in the case of this simpler model,
|
Why do linear regression and ANOVA give different $p$-value in case of considering interaction betwe
|
The above two answers are great, but thought I'd add a bit more. Another nugget of information can be gleaned from here.
When you report the lm() results with the interaction term, you're saying so
|
Why do linear regression and ANOVA give different $p$-value in case of considering interaction between variable?
The above two answers are great, but thought I'd add a bit more. Another nugget of information can be gleaned from here.
When you report the lm() results with the interaction term, you're saying something like: "treat 1 is different than treat 0 (beta != 0, p=0.0925), when time is set to the base value of 1". Whereas the anova() results (as previously mentioned) ignore any other variables and concerns itself only with differences in variance.
You can prove this by removing your interaction term and using a simple model with only two main effects (m1):
> m1 = lm(value~time+treat,data=dat)
> summary(m1)
Call:
lm(formula = value ~ time + treat, data = dat)
Residuals:
Min 1Q Median 3Q Max
-0.54627 -0.10533 -0.04574 0.11975 0.61528
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 8.539293 0.132545 64.426 1.56e-15 ***
time -0.004717 0.001562 -3.019 0.01168 *
treat -0.502906 0.155626 -3.232 0.00799 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.2911 on 11 degrees of freedom
Multiple R-squared: 0.64, Adjusted R-squared: 0.5746
F-statistic: 9.778 on 2 and 11 DF, p-value: 0.003627
> anova(m1)
Analysis of Variance Table
Response: value
Df Sum Sq Mean Sq F value Pr(>F)
time 1 0.77259 0.77259 9.1142 0.011677 *
treat 1 0.88520 0.88520 10.4426 0.007994 **
Residuals 11 0.93245 0.08477
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
In this case we see that the reported p-values are the same; that's because in the case of this simpler model,
|
Why do linear regression and ANOVA give different $p$-value in case of considering interaction betwe
The above two answers are great, but thought I'd add a bit more. Another nugget of information can be gleaned from here.
When you report the lm() results with the interaction term, you're saying so
|
9,840
|
Why do linear regression and ANOVA give different $p$-value in case of considering interaction between variable?
|
The difference has to do with the type pairwise comparisons of cascading models.
Also, the aov() function has an issue with how it chooses the degrees of freedom. It seems to mix two concepts: 1) the sum of squares from the stepwise comparisons, 2) the degrees of freedom from an overall picture.
PROBLEM REPRODUCTION
> data <- list(value = c (8.788269,7.964719,8.204051,9.041368,8.181555,8.0414149,7.992336,7.948658,8.090211,8.031459,8.118308,7.699051,7.537120,7.268570), time = c(1,6,12,24,48,96,144,1,6,12,24,48,96,144), treat = c(0,0,0,0,0,0,0,1,1,1,1,1,1,1) )
> summary( lm(value ~ treat*time, data=data) )
> summary( aov(value ~ 1 + treat + time + I(treat*time),data=data) )
SOME MODELS USED IN THE EXPLANATION
#all linear models used in the explanation below
> model_0 <- lm(value ~ 1, data)
> model_time <- lm(value ~ 1 + time, data)
> model_treat <- lm(value ~ 1 + treat, data)
> model_interaction <- lm(value ~ 1 + I(treat*time), data)
> model_treat_time <- lm(value ~ 1 + treat + time, data)
> model_treat_interaction <- lm(value ~ 1 + treat + I(treat*time), data)
> model_time_interaction <- lm(value ~ 1 + time + I(treat*time), data)
> model_treat_time_interaction <- lm(value ~ 1 + time + treat + I(treat*time), data)
HOW LM T_TEST WORKS AND RELATES TO F-TEST
# the t-test with the estimator and it's variance, mean square error, is
# related to the F test of pairwise comparison of models by dropping 1
# model parameter
> anova(model_treat_time_interaction, model_time_interaction)
Analysis of Variance Table
Model 1: value ~ 1 + time + treat + I(treat * time)
Model 2: value ~ 1 + time + I(treat * time)
Res.Df RSS Df Sum of Sq F Pr(>F)
1 10 0.89985
2 11 1.21118 -1 -0.31133 3.4598 0.09251 .
---
Signif. codes: 0 β***β 0.001 β**β 0.01 β*β 0.05 β.β 0.1 β β 1
> anova(model_treat_time_interaction, model_treat_interaction)
Analysis of Variance Table
Model 1: value ~ 1 + time + treat + I(treat * time)
Model 2: value ~ 1 + treat + I(treat * time)
Res.Df RSS Df Sum of Sq F Pr(>F)
1 10 0.89985
2 11 1.14374 -1 -0.2439 2.7104 0.1307
> anova(model_treat_time_interaction, model_treat_time)
Analysis of Variance Table
Model 1: value ~ 1 + time + treat + I(treat * time)
Model 2: value ~ 1 + treat + time
Res.Df RSS Df Sum of Sq F Pr(>F)
1 10 0.89985
2 11 0.93245 -1 -0.032599 0.3623 0.5606
> # which is the same as
> drop1(model_treat_time_interaction, scope = ~time+treat+I(treat*time), test="F")
Single term deletions
Model:
value ~ 1 + time + treat + I(treat * time)
Df Sum of Sq RSS AIC F value Pr(>F)
<none> 0.89985 -30.424
time 1 0.243896 1.14374 -29.067 2.7104 0.13072
treat 1 0.311333 1.21118 -28.264 3.4598 0.09251 .
I(treat * time) 1 0.032599 0.93245 -31.926 0.3623 0.56064
---
Signif. codes: 0 β***β 0.001 β**β 0.01 β*β 0.05 β.β 0.1 β β 1
HOW AOV WORKS AND CHOOSES DF IN F-TESTS
> #the aov function makes stepwise additions/drops
>
> #first the time, then treat, then the interaction
> anova(model_0, model_time)
Analysis of Variance Table
Model 1: value ~ 1
Model 2: value ~ 1 + time
Res.Df RSS Df Sum of Sq F Pr(>F)
1 13 2.5902
2 12 1.8176 1 0.7726 5.1006 0.04333 *
---
Signif. codes: 0 β***β 0.001 β**β 0.01 β*β 0.05 β.β 0.1 β β 1
> anova(model_time, model_treat_time)
Analysis of Variance Table
Model 1: value ~ 1 + time
Model 2: value ~ 1 + treat + time
Res.Df RSS Df Sum of Sq F Pr(>F)
1 12 1.81764
2 11 0.93245 1 0.8852 10.443 0.007994 **
---
Signif. codes: 0 β***β 0.001 β**β 0.01 β*β 0.05 β.β 0.1 β β 1
> anova(model_treat_time, model_treat_time_interaction)
Analysis of Variance Table
Model 1: value ~ 1 + treat + time
Model 2: value ~ 1 + time + treat + I(treat * time)
Res.Df RSS Df Sum of Sq F Pr(>F)
1 11 0.93245
2 10 0.89985 1 0.032599 0.3623 0.5606
>
> # note that the sum of squares for within model variation is the same
> # but the F values and p-values are not the same because the aov
> # function somehow chooses to use the degrees of freedom in the
> # complete model in all stepwise changes
>
IMPORTANT NOTE
> # Although the p and F values do not exactly match, it is this effect
> # of order and selection of cascading or not in model comparisons.
> # An important note to make is that the comparisons are made by
> # stepwise additions and changing the order of variables has an
> # influence on the outcome!
>
> # Additional note changing the order of 'treat' and 'time' has no
> # effect because they are not correlated
> summary( aov(value ~ 1 + treat + time +I(treat*time), data=data) )
Df Sum Sq Mean Sq F value Pr(>F)
treat 1 0.8852 0.8852 9.837 0.0106 *
time 1 0.7726 0.7726 8.586 0.0150 *
I(treat * time) 1 0.0326 0.0326 0.362 0.5606
Residuals 10 0.8998 0.0900
---
Signif. codes: 0 β***β 0.001 β**β 0.01 β*β 0.05 β.β 0.1 β β 1
> summary( aov(value ~ 1 + I(treat*time) + treat + time, data=data) )
Df Sum Sq Mean Sq F value Pr(>F)
I(treat * time) 1 1.3144 1.3144 14.606 0.00336 **
treat 1 0.1321 0.1321 1.469 0.25343
time 1 0.2439 0.2439 2.710 0.13072
Residuals 10 0.8998 0.0900
---
Signif. codes: 0 β***β 0.001 β**β 0.01 β*β 0.05 β.β 0.1 β β 1
> # This is an often forgotten quirck
> # best is to use manual comparisons such that you know
> # and understand your hypotheses
> # (which is often forgotten in the click and
> # point anova modelling tools)
> #
> # anova(model1, model2)
> # or use
> # stepAIC from the MASS library
|
Why do linear regression and ANOVA give different $p$-value in case of considering interaction betwe
|
The difference has to do with the type pairwise comparisons of cascading models.
Also, the aov() function has an issue with how it chooses the degrees of freedom. It seems to mix two concepts: 1) the
|
Why do linear regression and ANOVA give different $p$-value in case of considering interaction between variable?
The difference has to do with the type pairwise comparisons of cascading models.
Also, the aov() function has an issue with how it chooses the degrees of freedom. It seems to mix two concepts: 1) the sum of squares from the stepwise comparisons, 2) the degrees of freedom from an overall picture.
PROBLEM REPRODUCTION
> data <- list(value = c (8.788269,7.964719,8.204051,9.041368,8.181555,8.0414149,7.992336,7.948658,8.090211,8.031459,8.118308,7.699051,7.537120,7.268570), time = c(1,6,12,24,48,96,144,1,6,12,24,48,96,144), treat = c(0,0,0,0,0,0,0,1,1,1,1,1,1,1) )
> summary( lm(value ~ treat*time, data=data) )
> summary( aov(value ~ 1 + treat + time + I(treat*time),data=data) )
SOME MODELS USED IN THE EXPLANATION
#all linear models used in the explanation below
> model_0 <- lm(value ~ 1, data)
> model_time <- lm(value ~ 1 + time, data)
> model_treat <- lm(value ~ 1 + treat, data)
> model_interaction <- lm(value ~ 1 + I(treat*time), data)
> model_treat_time <- lm(value ~ 1 + treat + time, data)
> model_treat_interaction <- lm(value ~ 1 + treat + I(treat*time), data)
> model_time_interaction <- lm(value ~ 1 + time + I(treat*time), data)
> model_treat_time_interaction <- lm(value ~ 1 + time + treat + I(treat*time), data)
HOW LM T_TEST WORKS AND RELATES TO F-TEST
# the t-test with the estimator and it's variance, mean square error, is
# related to the F test of pairwise comparison of models by dropping 1
# model parameter
> anova(model_treat_time_interaction, model_time_interaction)
Analysis of Variance Table
Model 1: value ~ 1 + time + treat + I(treat * time)
Model 2: value ~ 1 + time + I(treat * time)
Res.Df RSS Df Sum of Sq F Pr(>F)
1 10 0.89985
2 11 1.21118 -1 -0.31133 3.4598 0.09251 .
---
Signif. codes: 0 β***β 0.001 β**β 0.01 β*β 0.05 β.β 0.1 β β 1
> anova(model_treat_time_interaction, model_treat_interaction)
Analysis of Variance Table
Model 1: value ~ 1 + time + treat + I(treat * time)
Model 2: value ~ 1 + treat + I(treat * time)
Res.Df RSS Df Sum of Sq F Pr(>F)
1 10 0.89985
2 11 1.14374 -1 -0.2439 2.7104 0.1307
> anova(model_treat_time_interaction, model_treat_time)
Analysis of Variance Table
Model 1: value ~ 1 + time + treat + I(treat * time)
Model 2: value ~ 1 + treat + time
Res.Df RSS Df Sum of Sq F Pr(>F)
1 10 0.89985
2 11 0.93245 -1 -0.032599 0.3623 0.5606
> # which is the same as
> drop1(model_treat_time_interaction, scope = ~time+treat+I(treat*time), test="F")
Single term deletions
Model:
value ~ 1 + time + treat + I(treat * time)
Df Sum of Sq RSS AIC F value Pr(>F)
<none> 0.89985 -30.424
time 1 0.243896 1.14374 -29.067 2.7104 0.13072
treat 1 0.311333 1.21118 -28.264 3.4598 0.09251 .
I(treat * time) 1 0.032599 0.93245 -31.926 0.3623 0.56064
---
Signif. codes: 0 β***β 0.001 β**β 0.01 β*β 0.05 β.β 0.1 β β 1
HOW AOV WORKS AND CHOOSES DF IN F-TESTS
> #the aov function makes stepwise additions/drops
>
> #first the time, then treat, then the interaction
> anova(model_0, model_time)
Analysis of Variance Table
Model 1: value ~ 1
Model 2: value ~ 1 + time
Res.Df RSS Df Sum of Sq F Pr(>F)
1 13 2.5902
2 12 1.8176 1 0.7726 5.1006 0.04333 *
---
Signif. codes: 0 β***β 0.001 β**β 0.01 β*β 0.05 β.β 0.1 β β 1
> anova(model_time, model_treat_time)
Analysis of Variance Table
Model 1: value ~ 1 + time
Model 2: value ~ 1 + treat + time
Res.Df RSS Df Sum of Sq F Pr(>F)
1 12 1.81764
2 11 0.93245 1 0.8852 10.443 0.007994 **
---
Signif. codes: 0 β***β 0.001 β**β 0.01 β*β 0.05 β.β 0.1 β β 1
> anova(model_treat_time, model_treat_time_interaction)
Analysis of Variance Table
Model 1: value ~ 1 + treat + time
Model 2: value ~ 1 + time + treat + I(treat * time)
Res.Df RSS Df Sum of Sq F Pr(>F)
1 11 0.93245
2 10 0.89985 1 0.032599 0.3623 0.5606
>
> # note that the sum of squares for within model variation is the same
> # but the F values and p-values are not the same because the aov
> # function somehow chooses to use the degrees of freedom in the
> # complete model in all stepwise changes
>
IMPORTANT NOTE
> # Although the p and F values do not exactly match, it is this effect
> # of order and selection of cascading or not in model comparisons.
> # An important note to make is that the comparisons are made by
> # stepwise additions and changing the order of variables has an
> # influence on the outcome!
>
> # Additional note changing the order of 'treat' and 'time' has no
> # effect because they are not correlated
> summary( aov(value ~ 1 + treat + time +I(treat*time), data=data) )
Df Sum Sq Mean Sq F value Pr(>F)
treat 1 0.8852 0.8852 9.837 0.0106 *
time 1 0.7726 0.7726 8.586 0.0150 *
I(treat * time) 1 0.0326 0.0326 0.362 0.5606
Residuals 10 0.8998 0.0900
---
Signif. codes: 0 β***β 0.001 β**β 0.01 β*β 0.05 β.β 0.1 β β 1
> summary( aov(value ~ 1 + I(treat*time) + treat + time, data=data) )
Df Sum Sq Mean Sq F value Pr(>F)
I(treat * time) 1 1.3144 1.3144 14.606 0.00336 **
treat 1 0.1321 0.1321 1.469 0.25343
time 1 0.2439 0.2439 2.710 0.13072
Residuals 10 0.8998 0.0900
---
Signif. codes: 0 β***β 0.001 β**β 0.01 β*β 0.05 β.β 0.1 β β 1
> # This is an often forgotten quirck
> # best is to use manual comparisons such that you know
> # and understand your hypotheses
> # (which is often forgotten in the click and
> # point anova modelling tools)
> #
> # anova(model1, model2)
> # or use
> # stepAIC from the MASS library
|
Why do linear regression and ANOVA give different $p$-value in case of considering interaction betwe
The difference has to do with the type pairwise comparisons of cascading models.
Also, the aov() function has an issue with how it chooses the degrees of freedom. It seems to mix two concepts: 1) the
|
9,841
|
Extreme Value Theory - Show: Normal to Gumbel
|
An indirect way, is as follows:
For absolutely continuous distributions, Richard von Mises (in a 1936 paper "La distribution de la plus grande de n valeurs", which appears to have been reproduced -in English?- in a 1964 edition with selected papers of his), has provided the following sufficient condition for the maximum of a sample to converge to the standard Gumbel, $G(x)$:
Let $F(x)$ be the common distribution function of $n$ i.i.d. random variables, and $f(x)$ their common density. Then, if
$$\lim_{x\rightarrow F^{-1}(1)}\left (\frac d{dx}\frac {(1-F(x))}{f(x)}\right) =0 \Rightarrow X_{(n)} \xrightarrow{d} G(x)$$
Using the usual notation for the standard normal and calculating the derivative, we have
$$\frac d{dx}\frac {(1-\Phi(x))}{\phi(x)} = \frac {-\phi(x)^2-\phi'(x)(1-\Phi(x))}{\phi(x)^2} = \frac {-\phi'(x)}{\phi(x)}\frac {(1-\Phi(x))}{\phi(x)}-1$$
Note that $\frac {-\phi'(x)}{\phi(x)} =x$. Also, for the normal distribution, $F^{-1}(1) = \infty$. So we have to evaluate the limit
$$\lim_{x\rightarrow \infty}\left (x\frac {(1-\Phi(x))}{\phi(x)}-1\right) $$
But $\frac {(1-\Phi(x))}{\phi(x)}$ is Mill's ratio, and we know that the Mill's ratio for the standard normal tends to $1/x$ as $x$ grows.
So
$$\lim_{x\rightarrow \infty}\left (x\frac {(1-\Phi(x))}{\phi(x)}-1\right) = x\frac {1}{x}-1= 0$$
and the sufficient condition is satisfied.
The associated series are given as
$$a_n = \frac 1{n\phi(b_n)},\;\;\; b_n = \Phi^{-1}(1-1/n)$$
ADDENDUM
This is from ch. 10.5 of the book H.A. David & H.N. Nagaraja (2003), "Order Statistics" (3d edition).
$\xi_a = F^{-1}(a)$. Also, the reference to de Haan is "Haan, L. D. (1976). Sample extremes: an elementary introduction. Statistica Neerlandica, 30(4), 161-172."
But beware because some of the notation has different content in de Haan -for example in the book $f(t)$ is the probability density function, while in de Haan $f(t)$ means the function $w(t)$ of the book (i.e. Mill's ratio). Also, de Haan examines the sufficient condition already differentiated.
|
Extreme Value Theory - Show: Normal to Gumbel
|
An indirect way, is as follows:
For absolutely continuous distributions, Richard von Mises (in a 1936 paper "La distribution de la plus grande de n valeurs", which appears to have been reproduced -in
|
Extreme Value Theory - Show: Normal to Gumbel
An indirect way, is as follows:
For absolutely continuous distributions, Richard von Mises (in a 1936 paper "La distribution de la plus grande de n valeurs", which appears to have been reproduced -in English?- in a 1964 edition with selected papers of his), has provided the following sufficient condition for the maximum of a sample to converge to the standard Gumbel, $G(x)$:
Let $F(x)$ be the common distribution function of $n$ i.i.d. random variables, and $f(x)$ their common density. Then, if
$$\lim_{x\rightarrow F^{-1}(1)}\left (\frac d{dx}\frac {(1-F(x))}{f(x)}\right) =0 \Rightarrow X_{(n)} \xrightarrow{d} G(x)$$
Using the usual notation for the standard normal and calculating the derivative, we have
$$\frac d{dx}\frac {(1-\Phi(x))}{\phi(x)} = \frac {-\phi(x)^2-\phi'(x)(1-\Phi(x))}{\phi(x)^2} = \frac {-\phi'(x)}{\phi(x)}\frac {(1-\Phi(x))}{\phi(x)}-1$$
Note that $\frac {-\phi'(x)}{\phi(x)} =x$. Also, for the normal distribution, $F^{-1}(1) = \infty$. So we have to evaluate the limit
$$\lim_{x\rightarrow \infty}\left (x\frac {(1-\Phi(x))}{\phi(x)}-1\right) $$
But $\frac {(1-\Phi(x))}{\phi(x)}$ is Mill's ratio, and we know that the Mill's ratio for the standard normal tends to $1/x$ as $x$ grows.
So
$$\lim_{x\rightarrow \infty}\left (x\frac {(1-\Phi(x))}{\phi(x)}-1\right) = x\frac {1}{x}-1= 0$$
and the sufficient condition is satisfied.
The associated series are given as
$$a_n = \frac 1{n\phi(b_n)},\;\;\; b_n = \Phi^{-1}(1-1/n)$$
ADDENDUM
This is from ch. 10.5 of the book H.A. David & H.N. Nagaraja (2003), "Order Statistics" (3d edition).
$\xi_a = F^{-1}(a)$. Also, the reference to de Haan is "Haan, L. D. (1976). Sample extremes: an elementary introduction. Statistica Neerlandica, 30(4), 161-172."
But beware because some of the notation has different content in de Haan -for example in the book $f(t)$ is the probability density function, while in de Haan $f(t)$ means the function $w(t)$ of the book (i.e. Mill's ratio). Also, de Haan examines the sufficient condition already differentiated.
|
Extreme Value Theory - Show: Normal to Gumbel
An indirect way, is as follows:
For absolutely continuous distributions, Richard von Mises (in a 1936 paper "La distribution de la plus grande de n valeurs", which appears to have been reproduced -in
|
9,842
|
Extreme Value Theory - Show: Normal to Gumbel
|
The question asks two things: (1) how to show that the maximum $X_{(n)}$ converges, in the sense that $(X_{(n)}-b_n)/a_n$ converges (in distribution) for suitably chosen sequences $(a_n)$ and $(b_n)$, to the Standard Gumbel distribution and (2) how to find such sequences.
The first is well-known and documented in the original papers on the Fisher-Tippett-Gnedenko theorem (FTG). The second appears to be more difficult; that is the issue addressed here.
Please note, to clarify some assertions appearing elsewhere in this thread, that
The maximum does not converge to anything: it diverges (albeit extremely slowly).
There appear to be different conventions concerning the Gumbel distribution. I will adopt the convention that the CDF of a reversed Gumbel distribution is, up to scale and location, given by $1-\exp(-\exp(x))$. A suitably standardized maximum of iid Normal variates converges to a reversed Gumbel distribution.
Intuition
When the $X_i$ are iid with common distribution function $F$, the distribution of the maximum $X_{(n)}$ is
$$F_n(x) = \Pr(X_{(n)}\le x) = \Pr(X_1 \le x)\Pr(X_2 \le x) \cdots \Pr(X_n \le x) = F^n(x).$$
When the support of $F$ has no upper bound, as with a Normal distribution, the sequence of functions $F^n$ marches forever to the right without limit:
Partial graphs of $F_n$ for $n=1,2,2^2, 2^4, 2^8, 2^{16}$ are shown.
To study the shapes of these distributions, we can shift each one back to the left by some amount $b_n$ and rescale it by $a_n$ to make them comparable.
Each of the previous graphs has been shifted to place its median at $0$ and to make its interquartile range of unit length.
FTG asserts that sequences $(a_n)$ and $(b_n)$ can be chosen so that these distribution functions converge pointwise at every $x$ to some extreme value distribution, up to scale and location. When $F$ is a Normal distribution, the particular limiting extreme value distribution is a reversed Gumbel, up to location and scale.
Solution
It is tempting to emulate the Central Limit Theorem by standardizing $F_n$ to have unit mean and unit variance. This is inappropriate, though, in part because FTG applies even to (continuous) distributions that have no first or second moments. Instead, use a percentile (such as the median) to determine the location and a difference of percentiles (such as the IQR) to determine the spread. (This general approach should succeed in finding $a_n$ and $b_n$ for any continuous distribution.)
For the standard Normal distribution, this turns out to be easy! Let $0 \lt q \lt 1$. A quantile of $F_n$ corresponding to $q$ is any value $x_q$ for which $F_n(x_q) = q$. Recalling the definition of $F_n(x) = F^n(x)$, the solution is
$$x_{q;n} = F^{-1}(q^{1/n}).$$
Therefore we may set
$$b_n = x_{1/2;n},\ a_n = x_{3/4;n} - x_{1/4;n};\ G_n(x) = F_n(a_n x + b_n).$$
Because, by construction, the median of $G_n$ is $0$ and its IQR is $1$, the median of the limiting value of $G_n$ (which is some version of a reversed Gumbel) must be $0$ and its IQR must be $1$. Let the scale parameter be $\beta$ and the location parameter be $\alpha$. Since the median is $\alpha + \beta \log\log(2)$ and the IQR is readily found to be $\beta(\log\log(4) - \log\log(4/3))$, the parameters must be
$$\alpha = \frac{\log\log 2}{\log\log(4/3) - \log\log(4)};\ \beta = \frac{1}{\log\log(4) - \log\log(4/3)}.$$
It is not necessary for $a_n$ and $b_n$ to be exactly these values: they need only approximate them, provided the limit of $G_n$ is still this reversed Gumbel distribution. Straightforward (but tedious) analysis for a standard normal $F$ indicates that the approximations
$$a_n^\prime = \frac{\log \left(\left(4 \log^2(2)\right)/\left(\log^2\left(\frac{4}{3}\right)\right)\right)}{2\sqrt{2\log (n)}},\ b_n^\prime = \sqrt{2\log (n)}-\frac{\log (\log (n))+\log \left(4 \pi \log ^2(2)\right)}{2 \sqrt{2\log (n)}}$$
will work fine (and are as simple as possible).
The light blue curves are partial graphs of $G_n$ for $n=2, 2^6, 2^{11}, 2^{16}$ using the approximate sequences $a_n^\prime$ and $b_n^\prime$. The dark red line graphs the reversed Gumbel distribution with parameters $\alpha$ and $\beta$. The convergence is clear (although the rate of convergence for negative $x$ is noticeably slower).
References
B. V. Gnedenko, On The Limiting Distribution of the Maximum Term in a Random Series. In Kotz and Johnson, Breakthroughs in Statistics Volume I: Foundations and Basic Theory, Springer, 1992. Translated by Norman Johnson.
|
Extreme Value Theory - Show: Normal to Gumbel
|
The question asks two things: (1) how to show that the maximum $X_{(n)}$ converges, in the sense that $(X_{(n)}-b_n)/a_n$ converges (in distribution) for suitably chosen sequences $(a_n)$ and $(b_n)$,
|
Extreme Value Theory - Show: Normal to Gumbel
The question asks two things: (1) how to show that the maximum $X_{(n)}$ converges, in the sense that $(X_{(n)}-b_n)/a_n$ converges (in distribution) for suitably chosen sequences $(a_n)$ and $(b_n)$, to the Standard Gumbel distribution and (2) how to find such sequences.
The first is well-known and documented in the original papers on the Fisher-Tippett-Gnedenko theorem (FTG). The second appears to be more difficult; that is the issue addressed here.
Please note, to clarify some assertions appearing elsewhere in this thread, that
The maximum does not converge to anything: it diverges (albeit extremely slowly).
There appear to be different conventions concerning the Gumbel distribution. I will adopt the convention that the CDF of a reversed Gumbel distribution is, up to scale and location, given by $1-\exp(-\exp(x))$. A suitably standardized maximum of iid Normal variates converges to a reversed Gumbel distribution.
Intuition
When the $X_i$ are iid with common distribution function $F$, the distribution of the maximum $X_{(n)}$ is
$$F_n(x) = \Pr(X_{(n)}\le x) = \Pr(X_1 \le x)\Pr(X_2 \le x) \cdots \Pr(X_n \le x) = F^n(x).$$
When the support of $F$ has no upper bound, as with a Normal distribution, the sequence of functions $F^n$ marches forever to the right without limit:
Partial graphs of $F_n$ for $n=1,2,2^2, 2^4, 2^8, 2^{16}$ are shown.
To study the shapes of these distributions, we can shift each one back to the left by some amount $b_n$ and rescale it by $a_n$ to make them comparable.
Each of the previous graphs has been shifted to place its median at $0$ and to make its interquartile range of unit length.
FTG asserts that sequences $(a_n)$ and $(b_n)$ can be chosen so that these distribution functions converge pointwise at every $x$ to some extreme value distribution, up to scale and location. When $F$ is a Normal distribution, the particular limiting extreme value distribution is a reversed Gumbel, up to location and scale.
Solution
It is tempting to emulate the Central Limit Theorem by standardizing $F_n$ to have unit mean and unit variance. This is inappropriate, though, in part because FTG applies even to (continuous) distributions that have no first or second moments. Instead, use a percentile (such as the median) to determine the location and a difference of percentiles (such as the IQR) to determine the spread. (This general approach should succeed in finding $a_n$ and $b_n$ for any continuous distribution.)
For the standard Normal distribution, this turns out to be easy! Let $0 \lt q \lt 1$. A quantile of $F_n$ corresponding to $q$ is any value $x_q$ for which $F_n(x_q) = q$. Recalling the definition of $F_n(x) = F^n(x)$, the solution is
$$x_{q;n} = F^{-1}(q^{1/n}).$$
Therefore we may set
$$b_n = x_{1/2;n},\ a_n = x_{3/4;n} - x_{1/4;n};\ G_n(x) = F_n(a_n x + b_n).$$
Because, by construction, the median of $G_n$ is $0$ and its IQR is $1$, the median of the limiting value of $G_n$ (which is some version of a reversed Gumbel) must be $0$ and its IQR must be $1$. Let the scale parameter be $\beta$ and the location parameter be $\alpha$. Since the median is $\alpha + \beta \log\log(2)$ and the IQR is readily found to be $\beta(\log\log(4) - \log\log(4/3))$, the parameters must be
$$\alpha = \frac{\log\log 2}{\log\log(4/3) - \log\log(4)};\ \beta = \frac{1}{\log\log(4) - \log\log(4/3)}.$$
It is not necessary for $a_n$ and $b_n$ to be exactly these values: they need only approximate them, provided the limit of $G_n$ is still this reversed Gumbel distribution. Straightforward (but tedious) analysis for a standard normal $F$ indicates that the approximations
$$a_n^\prime = \frac{\log \left(\left(4 \log^2(2)\right)/\left(\log^2\left(\frac{4}{3}\right)\right)\right)}{2\sqrt{2\log (n)}},\ b_n^\prime = \sqrt{2\log (n)}-\frac{\log (\log (n))+\log \left(4 \pi \log ^2(2)\right)}{2 \sqrt{2\log (n)}}$$
will work fine (and are as simple as possible).
The light blue curves are partial graphs of $G_n$ for $n=2, 2^6, 2^{11}, 2^{16}$ using the approximate sequences $a_n^\prime$ and $b_n^\prime$. The dark red line graphs the reversed Gumbel distribution with parameters $\alpha$ and $\beta$. The convergence is clear (although the rate of convergence for negative $x$ is noticeably slower).
References
B. V. Gnedenko, On The Limiting Distribution of the Maximum Term in a Random Series. In Kotz and Johnson, Breakthroughs in Statistics Volume I: Foundations and Basic Theory, Springer, 1992. Translated by Norman Johnson.
|
Extreme Value Theory - Show: Normal to Gumbel
The question asks two things: (1) how to show that the maximum $X_{(n)}$ converges, in the sense that $(X_{(n)}-b_n)/a_n$ converges (in distribution) for suitably chosen sequences $(a_n)$ and $(b_n)$,
|
9,843
|
Extreme Value Theory - Show: Normal to Gumbel
|
Here is a "direct" approach. Let $a_n > 0$, $b_n$ to be determined so that $a_nx+b_n \rightarrow +\infty$ for all $x$.
From L'Hospital's rule,
$$
\underset{A \rightarrow \infty }{lim} \frac{\int_A^{+\infty} e^{-u^2/2} du}{A^p e^{-A^2/2}} = 1
$$
when $p=-1$, so we have:
$$
F(a_n x + b_n) = 1 - \frac{1}{\sqrt{2\pi}}\, \frac{e^{-(a_nx+b_n)^2/2}}{(a_nx+b_n)}(1+o(1))
$$
where $o(1) \rightarrow 0$ under the running assumption on $a_n, b_n$.
Then
$$
\begin{align*}
ln\!\left(\ F(a_n x + b_n)^n \right) &=
n\, ln\!\left( 1 - \frac{1}{\sqrt{2\pi}}\, \frac{e^{-(a_nx+b_n)^2/2}}{(a_nx+b_n)}(1+o(1))\right) \\
& = - \frac{n}{\sqrt{2\pi}}\, \frac{e^{-(a_nx+b_n)^2/2}}{(a_nx+b_n)}(1+o(1)) \\
& = - \frac{n}{\sqrt{2\pi}}\, \frac{e^{-a_n^2x^2/2-b_n^2/2 - a_nb_nx}}{(a_nx+b_n)}(1+o(1))
\end{align*}
$$
If we take $a_n = 1/b_n \rightarrow 0^+$, the required assumption $a_nx+b_n \rightarrow +\infty$ for all $x$ is satisfied, and:
$$
\begin{align*}
ln\!\left(\ F(a_n x + b_n)^n \right) &=
- \frac{n}{\sqrt{2\pi}\, b_n \,e^{b_n^2/2} }\, e^{-x}(1+o(1))
\end{align*}
$$
Now all that remains to do to get the result is to show one can choose $b_n$ so that
$$
b_n \,e^{b_n^2/2} ~=~ \frac{n}{\sqrt{2\pi}}(1+o(1)) \ \ ,
$$
which is clearly feasible.
Solving this equation "asymptotically" is amusing. Obviously the big factor on the left is $e^{b_n^2/2}$, which suggests $b_n \approx \sqrt{2\,ln(n)}$. After some trial and error, one possible explicit solution is:
$$
b_n = \sqrt{ ln\!\left( \frac{n^2}{4\pi\, ln(n)} \right) } = \sqrt{2 ln(n) \left( 1 - \frac{ln(4\pi\,ln(n))}{2\, ln(n)} \right)}
$$
|
Extreme Value Theory - Show: Normal to Gumbel
|
Here is a "direct" approach. Let $a_n > 0$, $b_n$ to be determined so that $a_nx+b_n \rightarrow +\infty$ for all $x$.
From L'Hospital's rule,
$$
\underset{A \rightarrow \infty }{lim} \frac{\int_A^{+
|
Extreme Value Theory - Show: Normal to Gumbel
Here is a "direct" approach. Let $a_n > 0$, $b_n$ to be determined so that $a_nx+b_n \rightarrow +\infty$ for all $x$.
From L'Hospital's rule,
$$
\underset{A \rightarrow \infty }{lim} \frac{\int_A^{+\infty} e^{-u^2/2} du}{A^p e^{-A^2/2}} = 1
$$
when $p=-1$, so we have:
$$
F(a_n x + b_n) = 1 - \frac{1}{\sqrt{2\pi}}\, \frac{e^{-(a_nx+b_n)^2/2}}{(a_nx+b_n)}(1+o(1))
$$
where $o(1) \rightarrow 0$ under the running assumption on $a_n, b_n$.
Then
$$
\begin{align*}
ln\!\left(\ F(a_n x + b_n)^n \right) &=
n\, ln\!\left( 1 - \frac{1}{\sqrt{2\pi}}\, \frac{e^{-(a_nx+b_n)^2/2}}{(a_nx+b_n)}(1+o(1))\right) \\
& = - \frac{n}{\sqrt{2\pi}}\, \frac{e^{-(a_nx+b_n)^2/2}}{(a_nx+b_n)}(1+o(1)) \\
& = - \frac{n}{\sqrt{2\pi}}\, \frac{e^{-a_n^2x^2/2-b_n^2/2 - a_nb_nx}}{(a_nx+b_n)}(1+o(1))
\end{align*}
$$
If we take $a_n = 1/b_n \rightarrow 0^+$, the required assumption $a_nx+b_n \rightarrow +\infty$ for all $x$ is satisfied, and:
$$
\begin{align*}
ln\!\left(\ F(a_n x + b_n)^n \right) &=
- \frac{n}{\sqrt{2\pi}\, b_n \,e^{b_n^2/2} }\, e^{-x}(1+o(1))
\end{align*}
$$
Now all that remains to do to get the result is to show one can choose $b_n$ so that
$$
b_n \,e^{b_n^2/2} ~=~ \frac{n}{\sqrt{2\pi}}(1+o(1)) \ \ ,
$$
which is clearly feasible.
Solving this equation "asymptotically" is amusing. Obviously the big factor on the left is $e^{b_n^2/2}$, which suggests $b_n \approx \sqrt{2\,ln(n)}$. After some trial and error, one possible explicit solution is:
$$
b_n = \sqrt{ ln\!\left( \frac{n^2}{4\pi\, ln(n)} \right) } = \sqrt{2 ln(n) \left( 1 - \frac{ln(4\pi\,ln(n))}{2\, ln(n)} \right)}
$$
|
Extreme Value Theory - Show: Normal to Gumbel
Here is a "direct" approach. Let $a_n > 0$, $b_n$ to be determined so that $a_nx+b_n \rightarrow +\infty$ for all $x$.
From L'Hospital's rule,
$$
\underset{A \rightarrow \infty }{lim} \frac{\int_A^{+
|
9,844
|
Example reports for mixed-model analysis using lmer in biology, psychology and medicine?
|
Update 3 (May, 2013): Another really good paper on mixed models in Psychology was released in the Journal of Memory and Language (although I do not agree with the authors conclusions on how to obtain p-values, see package afex instead). It very nicely discusses on how to specify the random effects structure. Go read it!
Barr, D. J., Levy, R., Scheepers, C., & Tily, H. J. (2013). Random effects structure for confirmatory hypothesis testing: Keep it maximal. Journal of Memory and Language, 68(3), 255β278. doi:10.1016/j.jml.2012.11.001
Update 2 (July, 2012): A paper advocating the use in (Social) Psychology when there are crossed (e.g., participants and items) random effects.
The big thing is: It shows how to obtain p-values using the pbkrtest package:
Judd, C. M., Westfall, J., & Kenny, D. A. (2012). Treating stimuli as a random factor in social psychology: A new and comprehensive solution to a pervasive but largely ignored problem. Journal of Personality and Social Psychology, 103(1), 54β69. doi:10.1037/a0028347
(only available as a Word .doc)
Jake Westfall told me (per mail) that an alternative for obtaining p-values to the advocated Kenward-Rogers approximation (used in pbkrtest) is the (less optimal) Satterthwaite approximation, which can be found in the MixMod package using the anovaTab function.
Small update to last update: My R package afex contains function mixed() to conveniently obtain p-values for all effects in a mixed model. Alternatively, the car package now also obtains p-values for mixed models in Anova() using test.statistic = "F"
UPDATE1: Another paper describing lme4
Kliegl, R., Wei, P., Dambacher, M., Yan, M., & Zhou, X. (2011). Experimental effects and individual differences in linear mixed models: estimating the relationship between spatial, object, and attraction effects in visual attention. Frontiers in Quantitative Psychology and Measurement, 1, 238. doi:10.3389/fpsyg.2010.00238
Original Response:
I do not have a number of examples, only one (see below), but know some paper you should cite from Psychology/Cognitive Sciences. The most important one is definitely:
Baayen, R. H., Davidson, D. J., & Bates, D. M. (2008). Mixed-effects modeling with crossed random effects for subjects and items. Journal of Memory and Language, 59(4), 390β412. doi:10.1016/j.jml.2007.12.005
Another one from Baayen is:
Baayen, R. H., & Milin, P. (2010). Analyzing Reaction Times. International Journal of Psychological Research, 3(2), 12β28.
I actually totally liked his book, too, which also has a nice introductory chapter on mixed model (and is pretty cheap for a stats book):
Baayen, R. H. (2008). Analyzing linguistic dataβ―: a practical introduction to statistics using R. Cambridge, UK; New York: Cambridge University Press.
I probably guess he also has a lot of papers using lme4, but as my main interest is not psycholinguistics, you might wanna check his homepage.
From my field (reasoning), I know of this one paper that uses lme4:
Fugard, A. J. B., Pfeifer, N., Mayerhofer, B., & Kleiter, G. D. (2011). How people interpret conditionals: Shifts toward the conditional event. Journal of Experimental Psychology: Learning, Memory, and Cognition, 37(3), 635β648. doi:10.1037/a0022329
(although I have the feeling they use a likelihood ratio test to compare models which only differ in the fixed parameters, which I have heard is not the correct way. I think you should use AIC instead.)
|
Example reports for mixed-model analysis using lmer in biology, psychology and medicine?
|
Update 3 (May, 2013): Another really good paper on mixed models in Psychology was released in the Journal of Memory and Language (although I do not agree with the authors conclusions on how to obtain
|
Example reports for mixed-model analysis using lmer in biology, psychology and medicine?
Update 3 (May, 2013): Another really good paper on mixed models in Psychology was released in the Journal of Memory and Language (although I do not agree with the authors conclusions on how to obtain p-values, see package afex instead). It very nicely discusses on how to specify the random effects structure. Go read it!
Barr, D. J., Levy, R., Scheepers, C., & Tily, H. J. (2013). Random effects structure for confirmatory hypothesis testing: Keep it maximal. Journal of Memory and Language, 68(3), 255β278. doi:10.1016/j.jml.2012.11.001
Update 2 (July, 2012): A paper advocating the use in (Social) Psychology when there are crossed (e.g., participants and items) random effects.
The big thing is: It shows how to obtain p-values using the pbkrtest package:
Judd, C. M., Westfall, J., & Kenny, D. A. (2012). Treating stimuli as a random factor in social psychology: A new and comprehensive solution to a pervasive but largely ignored problem. Journal of Personality and Social Psychology, 103(1), 54β69. doi:10.1037/a0028347
(only available as a Word .doc)
Jake Westfall told me (per mail) that an alternative for obtaining p-values to the advocated Kenward-Rogers approximation (used in pbkrtest) is the (less optimal) Satterthwaite approximation, which can be found in the MixMod package using the anovaTab function.
Small update to last update: My R package afex contains function mixed() to conveniently obtain p-values for all effects in a mixed model. Alternatively, the car package now also obtains p-values for mixed models in Anova() using test.statistic = "F"
UPDATE1: Another paper describing lme4
Kliegl, R., Wei, P., Dambacher, M., Yan, M., & Zhou, X. (2011). Experimental effects and individual differences in linear mixed models: estimating the relationship between spatial, object, and attraction effects in visual attention. Frontiers in Quantitative Psychology and Measurement, 1, 238. doi:10.3389/fpsyg.2010.00238
Original Response:
I do not have a number of examples, only one (see below), but know some paper you should cite from Psychology/Cognitive Sciences. The most important one is definitely:
Baayen, R. H., Davidson, D. J., & Bates, D. M. (2008). Mixed-effects modeling with crossed random effects for subjects and items. Journal of Memory and Language, 59(4), 390β412. doi:10.1016/j.jml.2007.12.005
Another one from Baayen is:
Baayen, R. H., & Milin, P. (2010). Analyzing Reaction Times. International Journal of Psychological Research, 3(2), 12β28.
I actually totally liked his book, too, which also has a nice introductory chapter on mixed model (and is pretty cheap for a stats book):
Baayen, R. H. (2008). Analyzing linguistic dataβ―: a practical introduction to statistics using R. Cambridge, UK; New York: Cambridge University Press.
I probably guess he also has a lot of papers using lme4, but as my main interest is not psycholinguistics, you might wanna check his homepage.
From my field (reasoning), I know of this one paper that uses lme4:
Fugard, A. J. B., Pfeifer, N., Mayerhofer, B., & Kleiter, G. D. (2011). How people interpret conditionals: Shifts toward the conditional event. Journal of Experimental Psychology: Learning, Memory, and Cognition, 37(3), 635β648. doi:10.1037/a0022329
(although I have the feeling they use a likelihood ratio test to compare models which only differ in the fixed parameters, which I have heard is not the correct way. I think you should use AIC instead.)
|
Example reports for mixed-model analysis using lmer in biology, psychology and medicine?
Update 3 (May, 2013): Another really good paper on mixed models in Psychology was released in the Journal of Memory and Language (although I do not agree with the authors conclusions on how to obtain
|
9,845
|
Example reports for mixed-model analysis using lmer in biology, psychology and medicine?
|
This is a highly-cited paper on mixed models for ecology and evolution:
Bolker et al. (2009) Generalized linear mixed models: a practical guide for ecology and evolution Trends in Ecology & Evolution Vol. 24 pp127-135 (PDF) (from ScienceDirect with links to Supplementary Content).
|
Example reports for mixed-model analysis using lmer in biology, psychology and medicine?
|
This is a highly-cited paper on mixed models for ecology and evolution:
Bolker et al. (2009) Generalized linear mixed models: a practical guide for ecology and evolution Trends in Ecology & Evolution
|
Example reports for mixed-model analysis using lmer in biology, psychology and medicine?
This is a highly-cited paper on mixed models for ecology and evolution:
Bolker et al. (2009) Generalized linear mixed models: a practical guide for ecology and evolution Trends in Ecology & Evolution Vol. 24 pp127-135 (PDF) (from ScienceDirect with links to Supplementary Content).
|
Example reports for mixed-model analysis using lmer in biology, psychology and medicine?
This is a highly-cited paper on mixed models for ecology and evolution:
Bolker et al. (2009) Generalized linear mixed models: a practical guide for ecology and evolution Trends in Ecology & Evolution
|
9,846
|
Example reports for mixed-model analysis using lmer in biology, psychology and medicine?
|
The following article endeavours to promote the use of multilevel modelling in social science settings:
Bliese, P. D. & Ployhart, R. E. (2002). Growth Modeling Using Random
Coefficient Models: Model Building, Testing, and Illustrations, Organizational Research Methods, Vol. 5 No. 4, October 2002 362-387. PDF
To quote the abstract:
In this article, the authors illustrate how random coefficient
modeling can be used to develop growth models for the analysis of
longitudinal data. In contrast to previous discussions of random
coefficient models, this article provides step-by-step guidance using
a model comparison framework. By approaching the modeling this way,
the authors are able to build off a regression foundation and
progressively estimate and evaluate more complex models. In the model
comparison framework, the article illustrates the value of using
likelihood tests to contrast alternative models (rather than the
typical reliance on tests of significance involving individual
parameters), and it provides code in the open-source language R to
allow readers to replicate the results. The article concludes with
practical guidelines for estimating growth models.
An examination of the articles listed on Google Scholar as citing this paper suggest several other useful leads.
|
Example reports for mixed-model analysis using lmer in biology, psychology and medicine?
|
The following article endeavours to promote the use of multilevel modelling in social science settings:
Bliese, P. D. & Ployhart, R. E. (2002). Growth Modeling Using Random
Coefficient Models: Model
|
Example reports for mixed-model analysis using lmer in biology, psychology and medicine?
The following article endeavours to promote the use of multilevel modelling in social science settings:
Bliese, P. D. & Ployhart, R. E. (2002). Growth Modeling Using Random
Coefficient Models: Model Building, Testing, and Illustrations, Organizational Research Methods, Vol. 5 No. 4, October 2002 362-387. PDF
To quote the abstract:
In this article, the authors illustrate how random coefficient
modeling can be used to develop growth models for the analysis of
longitudinal data. In contrast to previous discussions of random
coefficient models, this article provides step-by-step guidance using
a model comparison framework. By approaching the modeling this way,
the authors are able to build off a regression foundation and
progressively estimate and evaluate more complex models. In the model
comparison framework, the article illustrates the value of using
likelihood tests to contrast alternative models (rather than the
typical reliance on tests of significance involving individual
parameters), and it provides code in the open-source language R to
allow readers to replicate the results. The article concludes with
practical guidelines for estimating growth models.
An examination of the articles listed on Google Scholar as citing this paper suggest several other useful leads.
|
Example reports for mixed-model analysis using lmer in biology, psychology and medicine?
The following article endeavours to promote the use of multilevel modelling in social science settings:
Bliese, P. D. & Ployhart, R. E. (2002). Growth Modeling Using Random
Coefficient Models: Model
|
9,847
|
Example reports for mixed-model analysis using lmer in biology, psychology and medicine?
|
An excellent example of using mixed models in ecology is:
"Demography and management of the invasive species Hypericum
perforatum. I. Using multi-level mixed-effects models for
characterizing growth, survival and fecundity in a long-term data
set" (Buckely, Briese and Rees 2003).
Unfortunately it uses older R libraries.
|
Example reports for mixed-model analysis using lmer in biology, psychology and medicine?
|
An excellent example of using mixed models in ecology is:
"Demography and management of the invasive species Hypericum
perforatum. I. Using multi-level mixed-effects models for
characterizing growth
|
Example reports for mixed-model analysis using lmer in biology, psychology and medicine?
An excellent example of using mixed models in ecology is:
"Demography and management of the invasive species Hypericum
perforatum. I. Using multi-level mixed-effects models for
characterizing growth, survival and fecundity in a long-term data
set" (Buckely, Briese and Rees 2003).
Unfortunately it uses older R libraries.
|
Example reports for mixed-model analysis using lmer in biology, psychology and medicine?
An excellent example of using mixed models in ecology is:
"Demography and management of the invasive species Hypericum
perforatum. I. Using multi-level mixed-effects models for
characterizing growth
|
9,848
|
Example reports for mixed-model analysis using lmer in biology, psychology and medicine?
|
I am reading Zuur, A. F., Ieno, E. N., Walker, N., Saveliev, A. A., & Smith, G. M. (2009). Mixed effects models and extensions in ecology with R. New York, NY: Springer Science+Business Media, LLC. It is written for ecologists, so the stats are fairly easy to follow; I think it would be useful for people from other disciplines, such as medicine or psychology too. There are many case studies included, and each has a detailed section on how to best write up the stats in a paper.
|
Example reports for mixed-model analysis using lmer in biology, psychology and medicine?
|
I am reading Zuur, A. F., Ieno, E. N., Walker, N., Saveliev, A. A., & Smith, G. M. (2009). Mixed effects models and extensions in ecology with R. New York, NY: Springer Science+Business Media, LLC. It
|
Example reports for mixed-model analysis using lmer in biology, psychology and medicine?
I am reading Zuur, A. F., Ieno, E. N., Walker, N., Saveliev, A. A., & Smith, G. M. (2009). Mixed effects models and extensions in ecology with R. New York, NY: Springer Science+Business Media, LLC. It is written for ecologists, so the stats are fairly easy to follow; I think it would be useful for people from other disciplines, such as medicine or psychology too. There are many case studies included, and each has a detailed section on how to best write up the stats in a paper.
|
Example reports for mixed-model analysis using lmer in biology, psychology and medicine?
I am reading Zuur, A. F., Ieno, E. N., Walker, N., Saveliev, A. A., & Smith, G. M. (2009). Mixed effects models and extensions in ecology with R. New York, NY: Springer Science+Business Media, LLC. It
|
9,849
|
What is the Bayesian justification for privileging analyses conducted earlier than other analyses?
|
Bayes' theorem says the posterior is equal to prior * likelihood after rescaling (so the probability sums to 1). Each observation has a likelihood which can be used to update the prior and create a new posterior:
posterior_1 = prior * likelihood_1
posterior_2 = posterior_1 * likelihood_2
...
posterior_n = posterior_{n-1} * likelihood_n
So that
posterior_n = prior * likelihood_1 * ... * likelihood_n
The commutativity of multiplication implies the updates can be done in any order. So if you start with a single prior, you can mix the observations from Study 1 and Study 2 in any order, apply Bayes' formula and arrive at the same final posterior.
|
What is the Bayesian justification for privileging analyses conducted earlier than other analyses?
|
Bayes' theorem says the posterior is equal to prior * likelihood after rescaling (so the probability sums to 1). Each observation has a likelihood which can be used to update the prior and create a ne
|
What is the Bayesian justification for privileging analyses conducted earlier than other analyses?
Bayes' theorem says the posterior is equal to prior * likelihood after rescaling (so the probability sums to 1). Each observation has a likelihood which can be used to update the prior and create a new posterior:
posterior_1 = prior * likelihood_1
posterior_2 = posterior_1 * likelihood_2
...
posterior_n = posterior_{n-1} * likelihood_n
So that
posterior_n = prior * likelihood_1 * ... * likelihood_n
The commutativity of multiplication implies the updates can be done in any order. So if you start with a single prior, you can mix the observations from Study 1 and Study 2 in any order, apply Bayes' formula and arrive at the same final posterior.
|
What is the Bayesian justification for privileging analyses conducted earlier than other analyses?
Bayes' theorem says the posterior is equal to prior * likelihood after rescaling (so the probability sums to 1). Each observation has a likelihood which can be used to update the prior and create a ne
|
9,850
|
What is the Bayesian justification for privileging analyses conducted earlier than other analyses?
|
First I should point out that:
In your significance-testing approach, you followed up a negative result with a different model that gave you another chance to get a positive result. Such a strategy increases your project-wise type-I error rate. Significance-testing requires choosing your analytic strategy in advance for the $p$-values to be correct.
You're putting a lot of faith in the results of Study 1 by translating your findings from that sample so directly into priors. Remember, a prior is not just a reflection of past findings. It needs to encode the entirety of your preexisting beliefs, including your beliefs before the earlier findings. If you admit that Study 1 involved sampling error as well as other kinds of less tractiable uncertainty, such as model uncertainty, you should be using a more conservative prior.
The second of these points to an important departure you have made from Bayesian convention. You didn't set a prior first and then fit both models in Bayesian fashion. You fit one model in a non-Bayesian fashion and then used that for priors for the other model. If you used the conventional approach, you wouldn't see the dependence on order that you saw here.
|
What is the Bayesian justification for privileging analyses conducted earlier than other analyses?
|
First I should point out that:
In your significance-testing approach, you followed up a negative result with a different model that gave you another chance to get a positive result. Such a strategy i
|
What is the Bayesian justification for privileging analyses conducted earlier than other analyses?
First I should point out that:
In your significance-testing approach, you followed up a negative result with a different model that gave you another chance to get a positive result. Such a strategy increases your project-wise type-I error rate. Significance-testing requires choosing your analytic strategy in advance for the $p$-values to be correct.
You're putting a lot of faith in the results of Study 1 by translating your findings from that sample so directly into priors. Remember, a prior is not just a reflection of past findings. It needs to encode the entirety of your preexisting beliefs, including your beliefs before the earlier findings. If you admit that Study 1 involved sampling error as well as other kinds of less tractiable uncertainty, such as model uncertainty, you should be using a more conservative prior.
The second of these points to an important departure you have made from Bayesian convention. You didn't set a prior first and then fit both models in Bayesian fashion. You fit one model in a non-Bayesian fashion and then used that for priors for the other model. If you used the conventional approach, you wouldn't see the dependence on order that you saw here.
|
What is the Bayesian justification for privileging analyses conducted earlier than other analyses?
First I should point out that:
In your significance-testing approach, you followed up a negative result with a different model that gave you another chance to get a positive result. Such a strategy i
|
9,851
|
What is the Bayesian justification for privileging analyses conducted earlier than other analyses?
|
I thought I might make a series of graphs with a different, but stylized problem, to show you why it can be dangerous to go from Frequentist to Bayesian methods and why using summary statistics can create issues.
Rather than use your example, which is multidimensional, I am going to cut it down to one dimension with two studies whose size is three observations and three observations.
The data I am using is fake. Both samples have been forced to have a median of -1. This matters because it is coming from a simplified density function that I have to commonly work with. The Frequentist density and the Bayesian Likelihood function is $$\frac{1}{\pi}\frac{1}{1+(x-\theta)^2}.$$ This is the Cauchy distribution with unknown median, but with a scale parameter of one. In truncated form, it is seen as the most common case in the stock market, and appears in physics problems with rotating objects such as rocks rolling downhill or in the famous "Gull's Lighthouse Problem."
I am using it because the central limit theorem doesn't apply, it lacks sufficient statistics, extreme observations are common, Chebychev's inequality doesn't hold and a whole host of normally workable solutions fall apart. I am using it because it makes for great examples without having to put too much work into the problem.
There are two samples. In the first study, the data was $\{-5,-1,4\}$. In the second study, the data was $\{-1.5,-1,-.5\}$. This distribution is nice because highly concentrated samples are common and samples with a massive range are common. The 99.99% confidence interval is normally $\pm{669}\sigma$ rather than the $\pm{3}\sigma$ most are used to.
The posterior densities of the two separate studies is
As is visually obvious, taking summary statistics from sample one could be incredibly misleading. If you are used to seeing nice, unimodal, well-defined and named densities, then that can quickly go out the door with Bayesian tools. There is no named distribution like it, but you could certainly describe it with summary statistics had you not visually looked at it. Using a summary statistic could be a problem if you are then going to use that to build a new prior.
The Frequentist confidence distribution for both samples are the same. Because the scale is known, the only unknown parameter is the median. For a sample size of three, the median is the MVUE. While the Cauchy distribution has no mean or variance, the sampling distribution of the median does. It is less efficient than the maximum likelihood estimator, but it takes me no effort to calculate. For large sample sizes Rothenberg's method is the MVUE and there are medium sample size solutions as well.
For the Frequentist distribution, you get
Notice that had you used summary statistics you would have gotten the same ones for both samples. The Frequentist distribution doesn't depend much on the data because the scale parameter is known and they have the same medians. So the summary statistics are invariant to the differences in the samples, because of the common median. While you would rightly point out that this is contrived and this wouldn't really happen, the distortion remains. Using language more correct for Bayesian thinking, the Frequentist model is $\Pr(x|\theta)$ rather than $\Pr(\theta|x)$.
The Frequentist distribution assumes an infinite repetition of sample size three draws and shows the limiting distribution for the distribution of sample medians. The Bayesian distribution is given $x$ so it depends only on the observed sample and ignores the good or bad properties that this sample may have. Indeed, the sample is unusual for Bayesian methods and so one may be given pause to form a strong inference about it. This is why the posterior is so wide, the sample is unusual. The Frequentist method is controlling for unusual samples, while the Bayesian is not. This creates the perverse case where the added certainty of the scale parameter narrows the Frequentist solution, but widens the Bayesian.
The joint posterior is the product of both posteriors and by associativity of multiplication, it does not matter which order you use. Visually, the joint posterior is .
It is obvious that had you imposed some simplified distribution on the posteriors and used their summary statistics, you would likely get a different answer. In fact, it could have been a very different answer. If a 70% credible region been used for study one, it would have resulted in a disconnected credible region. The existence of disconnected intervals happens in Bayesian methods sometimes. The graphic of the highest density interval and the lowest density interval for study one is
You will notice that the HDR is broken by a sliver of a region which is outside the credible set.
While many of these problems commonly disappear in large sets with regression, let me give you an example of a natural difference in how Bayesian and Frequentist methods will handle missing variables differently in regression.
Consider a well constructed regression with one missing variable, the weather. Let us assume that customers behave differently on rainy days and sunny days. If that difference is enough there can easily be two Bayesian posterior modes. One mode reflects the sunny behavior, the other the rainy. You don't know why you have two modes. It could be a statistical run or it could be a missing data point, but either your sample is unusual or your model has an omitted variable.
The Frequentist solution would average the two states and may put the regression line in a region where no customer behavior actually occurs, but which averages out the two types of behavior. It will also be downward biased. The issues may get caught in the analysis of residuals, particularly if there is a large difference in the true variances, but it may not. It may be one of those weird pictures of residuals that will show up on Cross-validated from time to time.
The fact you have two different posteriors from the same data implies that you didn't multiply the two together directly. Either you created a posterior from a Frequentist solution that didn't map one-to-one with the Bayesian posterior, or you created a prior from the summary statistics and the likelihood function wasn't perfectly symmetric, which is common.
|
What is the Bayesian justification for privileging analyses conducted earlier than other analyses?
|
I thought I might make a series of graphs with a different, but stylized problem, to show you why it can be dangerous to go from Frequentist to Bayesian methods and why using summary statistics can cr
|
What is the Bayesian justification for privileging analyses conducted earlier than other analyses?
I thought I might make a series of graphs with a different, but stylized problem, to show you why it can be dangerous to go from Frequentist to Bayesian methods and why using summary statistics can create issues.
Rather than use your example, which is multidimensional, I am going to cut it down to one dimension with two studies whose size is three observations and three observations.
The data I am using is fake. Both samples have been forced to have a median of -1. This matters because it is coming from a simplified density function that I have to commonly work with. The Frequentist density and the Bayesian Likelihood function is $$\frac{1}{\pi}\frac{1}{1+(x-\theta)^2}.$$ This is the Cauchy distribution with unknown median, but with a scale parameter of one. In truncated form, it is seen as the most common case in the stock market, and appears in physics problems with rotating objects such as rocks rolling downhill or in the famous "Gull's Lighthouse Problem."
I am using it because the central limit theorem doesn't apply, it lacks sufficient statistics, extreme observations are common, Chebychev's inequality doesn't hold and a whole host of normally workable solutions fall apart. I am using it because it makes for great examples without having to put too much work into the problem.
There are two samples. In the first study, the data was $\{-5,-1,4\}$. In the second study, the data was $\{-1.5,-1,-.5\}$. This distribution is nice because highly concentrated samples are common and samples with a massive range are common. The 99.99% confidence interval is normally $\pm{669}\sigma$ rather than the $\pm{3}\sigma$ most are used to.
The posterior densities of the two separate studies is
As is visually obvious, taking summary statistics from sample one could be incredibly misleading. If you are used to seeing nice, unimodal, well-defined and named densities, then that can quickly go out the door with Bayesian tools. There is no named distribution like it, but you could certainly describe it with summary statistics had you not visually looked at it. Using a summary statistic could be a problem if you are then going to use that to build a new prior.
The Frequentist confidence distribution for both samples are the same. Because the scale is known, the only unknown parameter is the median. For a sample size of three, the median is the MVUE. While the Cauchy distribution has no mean or variance, the sampling distribution of the median does. It is less efficient than the maximum likelihood estimator, but it takes me no effort to calculate. For large sample sizes Rothenberg's method is the MVUE and there are medium sample size solutions as well.
For the Frequentist distribution, you get
Notice that had you used summary statistics you would have gotten the same ones for both samples. The Frequentist distribution doesn't depend much on the data because the scale parameter is known and they have the same medians. So the summary statistics are invariant to the differences in the samples, because of the common median. While you would rightly point out that this is contrived and this wouldn't really happen, the distortion remains. Using language more correct for Bayesian thinking, the Frequentist model is $\Pr(x|\theta)$ rather than $\Pr(\theta|x)$.
The Frequentist distribution assumes an infinite repetition of sample size three draws and shows the limiting distribution for the distribution of sample medians. The Bayesian distribution is given $x$ so it depends only on the observed sample and ignores the good or bad properties that this sample may have. Indeed, the sample is unusual for Bayesian methods and so one may be given pause to form a strong inference about it. This is why the posterior is so wide, the sample is unusual. The Frequentist method is controlling for unusual samples, while the Bayesian is not. This creates the perverse case where the added certainty of the scale parameter narrows the Frequentist solution, but widens the Bayesian.
The joint posterior is the product of both posteriors and by associativity of multiplication, it does not matter which order you use. Visually, the joint posterior is .
It is obvious that had you imposed some simplified distribution on the posteriors and used their summary statistics, you would likely get a different answer. In fact, it could have been a very different answer. If a 70% credible region been used for study one, it would have resulted in a disconnected credible region. The existence of disconnected intervals happens in Bayesian methods sometimes. The graphic of the highest density interval and the lowest density interval for study one is
You will notice that the HDR is broken by a sliver of a region which is outside the credible set.
While many of these problems commonly disappear in large sets with regression, let me give you an example of a natural difference in how Bayesian and Frequentist methods will handle missing variables differently in regression.
Consider a well constructed regression with one missing variable, the weather. Let us assume that customers behave differently on rainy days and sunny days. If that difference is enough there can easily be two Bayesian posterior modes. One mode reflects the sunny behavior, the other the rainy. You don't know why you have two modes. It could be a statistical run or it could be a missing data point, but either your sample is unusual or your model has an omitted variable.
The Frequentist solution would average the two states and may put the regression line in a region where no customer behavior actually occurs, but which averages out the two types of behavior. It will also be downward biased. The issues may get caught in the analysis of residuals, particularly if there is a large difference in the true variances, but it may not. It may be one of those weird pictures of residuals that will show up on Cross-validated from time to time.
The fact you have two different posteriors from the same data implies that you didn't multiply the two together directly. Either you created a posterior from a Frequentist solution that didn't map one-to-one with the Bayesian posterior, or you created a prior from the summary statistics and the likelihood function wasn't perfectly symmetric, which is common.
|
What is the Bayesian justification for privileging analyses conducted earlier than other analyses?
I thought I might make a series of graphs with a different, but stylized problem, to show you why it can be dangerous to go from Frequentist to Bayesian methods and why using summary statistics can cr
|
9,852
|
Did Statistics.com publish the wrong answer?
|
I believe that you and your colleague are correct. Statistics.com has the correct line of thinking, but makes a simple mistake. Out of the 90 "OK" claims, we expect 20% of them to be incorrectly classified as fraud, not 80%. 20% of 90 is 18, leading to 9 correctly identified claims and 18 incorrect claims, with a ratio of 1/3, exactly what Bayes' rule yields.
|
Did Statistics.com publish the wrong answer?
|
I believe that you and your colleague are correct. Statistics.com has the correct line of thinking, but makes a simple mistake. Out of the 90 "OK" claims, we expect 20% of them to be incorrectly class
|
Did Statistics.com publish the wrong answer?
I believe that you and your colleague are correct. Statistics.com has the correct line of thinking, but makes a simple mistake. Out of the 90 "OK" claims, we expect 20% of them to be incorrectly classified as fraud, not 80%. 20% of 90 is 18, leading to 9 correctly identified claims and 18 incorrect claims, with a ratio of 1/3, exactly what Bayes' rule yields.
|
Did Statistics.com publish the wrong answer?
I believe that you and your colleague are correct. Statistics.com has the correct line of thinking, but makes a simple mistake. Out of the 90 "OK" claims, we expect 20% of them to be incorrectly class
|
9,853
|
Did Statistics.com publish the wrong answer?
|
You are correct. The solution that the website posted is based on a misreading of the problem in that 80% of the nonfraudulent claims are classified as fraudulent instead of the given 20%.
|
Did Statistics.com publish the wrong answer?
|
You are correct. The solution that the website posted is based on a misreading of the problem in that 80% of the nonfraudulent claims are classified as fraudulent instead of the given 20%.
|
Did Statistics.com publish the wrong answer?
You are correct. The solution that the website posted is based on a misreading of the problem in that 80% of the nonfraudulent claims are classified as fraudulent instead of the given 20%.
|
Did Statistics.com publish the wrong answer?
You are correct. The solution that the website posted is based on a misreading of the problem in that 80% of the nonfraudulent claims are classified as fraudulent instead of the given 20%.
|
9,854
|
Scikit correct way to calibrate classifiers with CalibratedClassifierCV
|
There are two things mentioned in the CalibratedClassifierCV docs that hint towards the ways it can be used:
base_estimator: If cv=prefit, the classifier must have been fit already on data.
cv: If βprefitβ is passed, it is assumed that base_estimator has been fitted already and all data is used for calibration.
I may obviously be interpreting this wrong, but it appears you can use the CCCV (short for CalibratedClassifierCV) in two ways:
Number one:
You train your model as usual, your_model.fit(X_train, y_train).
Then, you create your CCCV instance, your_cccv = CalibratedClassifierCV(your_model, cv='prefit'). Notice you set cv to flag that your model has already been fit.
Finally, you call your_cccv.fit(X_validation, y_validation). This validation data is used solely for calibration purposes.
Number two:
You have a new, untrained model.
Then you create your_cccv=CalibratedClassifierCV(your_untrained_model, cv=3). Notice cv is now the number of folds.
Finally, you call your_cccv.fit(X, y). Because your model is untrained, X and y have to be used for both training and calibration. The way to ensure the data is 'disjoint' is cross validation: for any given fold, CCCV will split X and y into your training and calibration data, so they do not overlap.
TLDR: Method one allows you to control what is used for training and for calibration. Method two uses cross validation to try and make the most out of your data for both purposes.
|
Scikit correct way to calibrate classifiers with CalibratedClassifierCV
|
There are two things mentioned in the CalibratedClassifierCV docs that hint towards the ways it can be used:
base_estimator: If cv=prefit, the classifier must have been fit already on data.
cv: If βp
|
Scikit correct way to calibrate classifiers with CalibratedClassifierCV
There are two things mentioned in the CalibratedClassifierCV docs that hint towards the ways it can be used:
base_estimator: If cv=prefit, the classifier must have been fit already on data.
cv: If βprefitβ is passed, it is assumed that base_estimator has been fitted already and all data is used for calibration.
I may obviously be interpreting this wrong, but it appears you can use the CCCV (short for CalibratedClassifierCV) in two ways:
Number one:
You train your model as usual, your_model.fit(X_train, y_train).
Then, you create your CCCV instance, your_cccv = CalibratedClassifierCV(your_model, cv='prefit'). Notice you set cv to flag that your model has already been fit.
Finally, you call your_cccv.fit(X_validation, y_validation). This validation data is used solely for calibration purposes.
Number two:
You have a new, untrained model.
Then you create your_cccv=CalibratedClassifierCV(your_untrained_model, cv=3). Notice cv is now the number of folds.
Finally, you call your_cccv.fit(X, y). Because your model is untrained, X and y have to be used for both training and calibration. The way to ensure the data is 'disjoint' is cross validation: for any given fold, CCCV will split X and y into your training and calibration data, so they do not overlap.
TLDR: Method one allows you to control what is used for training and for calibration. Method two uses cross validation to try and make the most out of your data for both purposes.
|
Scikit correct way to calibrate classifiers with CalibratedClassifierCV
There are two things mentioned in the CalibratedClassifierCV docs that hint towards the ways it can be used:
base_estimator: If cv=prefit, the classifier must have been fit already on data.
cv: If βp
|
9,855
|
Scikit correct way to calibrate classifiers with CalibratedClassifierCV
|
I am interested in this question as well and wanted to add some experiments to better understand CalibratedClassifierCV (CCCV).
As has already been said, there are two ways to use it.
#Method 1, train classifier within CCCV
model = CalibratedClassifierCV(my_clf)
model.fit(X_train_val, y_train_val)
#Method 2, train classifier and then use CCCV on DISJOINT set
my_clf.fit(X_train, y_train)
model = CalibratedClassifierCV(my_clf, cv='prefit')
model.fit(X_val, y_val)
Alternatively, we could try the second method but just calibrate on the same data we fitted on.
#Method 2 Non disjoint, train classifier on set, then use CCCV on SAME set used for training
my_clf.fit(X_train_val, y_train_val)
model = CalibratedClassifierCV(my_clf, cv='prefit')
model.fit(X_train_val, y_train_val)
Although the docs warn to use a disjoint set, this could be useful because it allows you to then inspect my_clf (e.g., to see the coef_, which are unavailable from the CalibratedClassifierCV object). (Does anyone know how to get this from the calibrated classifiers---for one, there are three of them so would you average coefficients?).
I decided to compare these 3 methods in terms of their calibration on a completely held out test set.
Here is a dataset:
X, y = datasets.make_classification(n_samples=500, n_features=200,
n_informative=10, n_redundant=10,
#random_state=42,
n_clusters_per_class=1, weights = [0.8,0.2])
I threw in some class imbalance and only provided 500 samples to make this a difficult problem.
I run 100 trials, each time trying each method and plotting its calibration curve.
Boxplots of the Brier scores over all trials:
Increasing the number of samples to 10,000:
If we change the classifier to Naive Bayes, going back to 500 samples:
This appears not to be enough samples to calibrate. Increasing samples to 10,000
Full code
print(__doc__)
# Based on code by Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
# Jan Hendrik Metzen <jhm@informatik.uni-bremen.de>
import matplotlib.pyplot as plt
from sklearn import datasets
from sklearn.naive_bayes import GaussianNB
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import brier_score_loss
from sklearn.calibration import CalibratedClassifierCV, calibration_curve
from sklearn.model_selection import train_test_split
def plot_calibration_curve(clf, name, ax, X_test, y_test, title):
y_pred = clf.predict(X_test)
if hasattr(clf, "predict_proba"):
prob_pos = clf.predict_proba(X_test)[:, 1]
else: # use decision function
prob_pos = clf.decision_function(X_test)
prob_pos = \
(prob_pos - prob_pos.min()) / (prob_pos.max() - prob_pos.min())
clf_score = brier_score_loss(y_test, prob_pos, pos_label=y.max())
fraction_of_positives, mean_predicted_value = \
calibration_curve(y_test, prob_pos, n_bins=10, normalize=False)
ax.plot(mean_predicted_value, fraction_of_positives, "s-",
label="%s (%1.3f)" % (name, clf_score), alpha=0.5, color='k', marker=None)
ax.set_ylabel("Fraction of positives")
ax.set_ylim([-0.05, 1.05])
ax.set_title(title)
ax.set_xlabel("Mean predicted value")
plt.tight_layout()
return clf_score
fig, (ax1, ax2, ax3) = plt.subplots(nrows=3, ncols=1, figsize=(6,12))
ax1.plot([0, 1], [0, 1], "k:", label="Perfectly calibrated",)
ax2.plot([0, 1], [0, 1], "k:", label="Perfectly calibrated")
ax3.plot([0, 1], [0, 1], "k:", label="Perfectly calibrated")
scores = {'Method 1':[],'Method 2':[],'Method 3':[]}
fig, (ax1, ax2, ax3) = plt.subplots(nrows=3, ncols=1, figsize=(6,12))
ax1.plot([0, 1], [0, 1], "k:", label="Perfectly calibrated",)
ax2.plot([0, 1], [0, 1], "k:", label="Perfectly calibrated")
ax3.plot([0, 1], [0, 1], "k:", label="Perfectly calibrated")
scores = {'Method 1':[],'Method 2':[],'Method 3':[]}
for i in range(0,100):
X, y = datasets.make_classification(n_samples=10000, n_features=200,
n_informative=10, n_redundant=10,
#random_state=42,
n_clusters_per_class=1, weights = [0.8,0.2])
X_train_val, X_test, y_train_val, y_test = train_test_split(X, y, test_size=0.80,
#random_state=42
)
X_train, X_val, y_train, y_val = train_test_split(X_train_val, y_train_val, test_size=0.80,
#random_state=42
)
#my_clf = GaussianNB()
my_clf = LogisticRegression()
#Method 1, train classifier within CCCV
model = CalibratedClassifierCV(my_clf)
model.fit(X_train_val, y_train_val)
r = plot_calibration_curve(model, "all_cal", ax1, X_test, y_test, "Method 1")
scores['Method 1'].append(r)
#Method 2, train classifier and then use CCCV on DISJOINT set
my_clf.fit(X_train, y_train)
model = CalibratedClassifierCV(my_clf, cv='prefit')
model.fit(X_val, y_val)
r = plot_calibration_curve(model, "all_cal", ax2, X_test, y_test, "Method 2")
scores['Method 2'].append(r)
#Method 3, train classifier on set, then use CCCV on SAME set used for training
my_clf.fit(X_train_val, y_train_val)
model = CalibratedClassifierCV(my_clf, cv='prefit')
model.fit(X_train_val, y_train_val)
r = plot_calibration_curve(model, "all_cal", ax3, X_test, y_test, "Method 2 non Dis")
scores['Method 3'].append(r)
import pandas
b = pandas.DataFrame(scores).boxplot()
plt.suptitle('Brier score')
So, the Brier score results are inconclusive, but according to the curves it seems to be best to use the second method.
|
Scikit correct way to calibrate classifiers with CalibratedClassifierCV
|
I am interested in this question as well and wanted to add some experiments to better understand CalibratedClassifierCV (CCCV).
As has already been said, there are two ways to use it.
#Method 1, tra
|
Scikit correct way to calibrate classifiers with CalibratedClassifierCV
I am interested in this question as well and wanted to add some experiments to better understand CalibratedClassifierCV (CCCV).
As has already been said, there are two ways to use it.
#Method 1, train classifier within CCCV
model = CalibratedClassifierCV(my_clf)
model.fit(X_train_val, y_train_val)
#Method 2, train classifier and then use CCCV on DISJOINT set
my_clf.fit(X_train, y_train)
model = CalibratedClassifierCV(my_clf, cv='prefit')
model.fit(X_val, y_val)
Alternatively, we could try the second method but just calibrate on the same data we fitted on.
#Method 2 Non disjoint, train classifier on set, then use CCCV on SAME set used for training
my_clf.fit(X_train_val, y_train_val)
model = CalibratedClassifierCV(my_clf, cv='prefit')
model.fit(X_train_val, y_train_val)
Although the docs warn to use a disjoint set, this could be useful because it allows you to then inspect my_clf (e.g., to see the coef_, which are unavailable from the CalibratedClassifierCV object). (Does anyone know how to get this from the calibrated classifiers---for one, there are three of them so would you average coefficients?).
I decided to compare these 3 methods in terms of their calibration on a completely held out test set.
Here is a dataset:
X, y = datasets.make_classification(n_samples=500, n_features=200,
n_informative=10, n_redundant=10,
#random_state=42,
n_clusters_per_class=1, weights = [0.8,0.2])
I threw in some class imbalance and only provided 500 samples to make this a difficult problem.
I run 100 trials, each time trying each method and plotting its calibration curve.
Boxplots of the Brier scores over all trials:
Increasing the number of samples to 10,000:
If we change the classifier to Naive Bayes, going back to 500 samples:
This appears not to be enough samples to calibrate. Increasing samples to 10,000
Full code
print(__doc__)
# Based on code by Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
# Jan Hendrik Metzen <jhm@informatik.uni-bremen.de>
import matplotlib.pyplot as plt
from sklearn import datasets
from sklearn.naive_bayes import GaussianNB
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import brier_score_loss
from sklearn.calibration import CalibratedClassifierCV, calibration_curve
from sklearn.model_selection import train_test_split
def plot_calibration_curve(clf, name, ax, X_test, y_test, title):
y_pred = clf.predict(X_test)
if hasattr(clf, "predict_proba"):
prob_pos = clf.predict_proba(X_test)[:, 1]
else: # use decision function
prob_pos = clf.decision_function(X_test)
prob_pos = \
(prob_pos - prob_pos.min()) / (prob_pos.max() - prob_pos.min())
clf_score = brier_score_loss(y_test, prob_pos, pos_label=y.max())
fraction_of_positives, mean_predicted_value = \
calibration_curve(y_test, prob_pos, n_bins=10, normalize=False)
ax.plot(mean_predicted_value, fraction_of_positives, "s-",
label="%s (%1.3f)" % (name, clf_score), alpha=0.5, color='k', marker=None)
ax.set_ylabel("Fraction of positives")
ax.set_ylim([-0.05, 1.05])
ax.set_title(title)
ax.set_xlabel("Mean predicted value")
plt.tight_layout()
return clf_score
fig, (ax1, ax2, ax3) = plt.subplots(nrows=3, ncols=1, figsize=(6,12))
ax1.plot([0, 1], [0, 1], "k:", label="Perfectly calibrated",)
ax2.plot([0, 1], [0, 1], "k:", label="Perfectly calibrated")
ax3.plot([0, 1], [0, 1], "k:", label="Perfectly calibrated")
scores = {'Method 1':[],'Method 2':[],'Method 3':[]}
fig, (ax1, ax2, ax3) = plt.subplots(nrows=3, ncols=1, figsize=(6,12))
ax1.plot([0, 1], [0, 1], "k:", label="Perfectly calibrated",)
ax2.plot([0, 1], [0, 1], "k:", label="Perfectly calibrated")
ax3.plot([0, 1], [0, 1], "k:", label="Perfectly calibrated")
scores = {'Method 1':[],'Method 2':[],'Method 3':[]}
for i in range(0,100):
X, y = datasets.make_classification(n_samples=10000, n_features=200,
n_informative=10, n_redundant=10,
#random_state=42,
n_clusters_per_class=1, weights = [0.8,0.2])
X_train_val, X_test, y_train_val, y_test = train_test_split(X, y, test_size=0.80,
#random_state=42
)
X_train, X_val, y_train, y_val = train_test_split(X_train_val, y_train_val, test_size=0.80,
#random_state=42
)
#my_clf = GaussianNB()
my_clf = LogisticRegression()
#Method 1, train classifier within CCCV
model = CalibratedClassifierCV(my_clf)
model.fit(X_train_val, y_train_val)
r = plot_calibration_curve(model, "all_cal", ax1, X_test, y_test, "Method 1")
scores['Method 1'].append(r)
#Method 2, train classifier and then use CCCV on DISJOINT set
my_clf.fit(X_train, y_train)
model = CalibratedClassifierCV(my_clf, cv='prefit')
model.fit(X_val, y_val)
r = plot_calibration_curve(model, "all_cal", ax2, X_test, y_test, "Method 2")
scores['Method 2'].append(r)
#Method 3, train classifier on set, then use CCCV on SAME set used for training
my_clf.fit(X_train_val, y_train_val)
model = CalibratedClassifierCV(my_clf, cv='prefit')
model.fit(X_train_val, y_train_val)
r = plot_calibration_curve(model, "all_cal", ax3, X_test, y_test, "Method 2 non Dis")
scores['Method 3'].append(r)
import pandas
b = pandas.DataFrame(scores).boxplot()
plt.suptitle('Brier score')
So, the Brier score results are inconclusive, but according to the curves it seems to be best to use the second method.
|
Scikit correct way to calibrate classifiers with CalibratedClassifierCV
I am interested in this question as well and wanted to add some experiments to better understand CalibratedClassifierCV (CCCV).
As has already been said, there are two ways to use it.
#Method 1, tra
|
9,856
|
How do I fit a set of data to a Pareto distribution in R?
|
Well, if you have a sample $X_1, ..., X_n$ from a pareto distribution with parameters $m>0$ and $\alpha>0$ (where $m$ is the lower bound parameter and $\alpha$ is the shape parameter) the log-likelihood of that sample is:
$$n \log(\alpha) + n \alpha \log(m) - (\alpha+1) \sum_{i=1}^{n} \log(X_i) $$
this is a monotonically increasing in $m$, so the maximizer is the largest value that is consistent with the observed data. Since the parameter $m$ defines the lower bound of the support for the Pareto distribution, the optimum is
$$\hat{m} = \min_{i} X_i $$
which does not depend on $\alpha$. Next, using ordinary calculus tricks, the MLE for $\alpha$ must satisfy
$$ \frac{n}{\alpha} + n \log( \hat{m} ) - \sum_{i=1}^{n} \log(X_i) = 0$$
some simple algebra tells us the MLE of $\alpha$ is
$$ \hat{\alpha} = \frac{n}{\sum_{i=1}^{n} \log(X_i/\hat{m})} $$
In many important senses (e.g. optimal asymptotic efficiency in that it achieves the Cramer-Rao lower bound), this is the best way to fit data to a Pareto distribution. The R code below calculates the MLE for a given data set,X.
pareto.MLE <- function(X)
{
n <- length(X)
m <- min(X)
a <- n/sum(log(X)-log(m))
return( c(m,a) )
}
# example.
library(VGAM)
set.seed(1)
z = rpareto(1000, 1, 5)
pareto.MLE(z)
[1] 1.000014 5.065213
Edit: Based on the commentary by @cardinal and I below, we can also note that $\hat{\alpha}$ is the reciprocal of the sample mean of the $\log(X_i /\hat{m})$'s, which happen to have an exponential distribution. Therefore, if we have access to software that can fit an exponential distribution (which is more likely, since it seems to arise in many statistical problems), then fitting a Pareto distribution can be accomplished by transforming the data set in this way and fitting it to an exponential distribution on the transformed scale.
|
How do I fit a set of data to a Pareto distribution in R?
|
Well, if you have a sample $X_1, ..., X_n$ from a pareto distribution with parameters $m>0$ and $\alpha>0$ (where $m$ is the lower bound parameter and $\alpha$ is the shape parameter) the log-likeliho
|
How do I fit a set of data to a Pareto distribution in R?
Well, if you have a sample $X_1, ..., X_n$ from a pareto distribution with parameters $m>0$ and $\alpha>0$ (where $m$ is the lower bound parameter and $\alpha$ is the shape parameter) the log-likelihood of that sample is:
$$n \log(\alpha) + n \alpha \log(m) - (\alpha+1) \sum_{i=1}^{n} \log(X_i) $$
this is a monotonically increasing in $m$, so the maximizer is the largest value that is consistent with the observed data. Since the parameter $m$ defines the lower bound of the support for the Pareto distribution, the optimum is
$$\hat{m} = \min_{i} X_i $$
which does not depend on $\alpha$. Next, using ordinary calculus tricks, the MLE for $\alpha$ must satisfy
$$ \frac{n}{\alpha} + n \log( \hat{m} ) - \sum_{i=1}^{n} \log(X_i) = 0$$
some simple algebra tells us the MLE of $\alpha$ is
$$ \hat{\alpha} = \frac{n}{\sum_{i=1}^{n} \log(X_i/\hat{m})} $$
In many important senses (e.g. optimal asymptotic efficiency in that it achieves the Cramer-Rao lower bound), this is the best way to fit data to a Pareto distribution. The R code below calculates the MLE for a given data set,X.
pareto.MLE <- function(X)
{
n <- length(X)
m <- min(X)
a <- n/sum(log(X)-log(m))
return( c(m,a) )
}
# example.
library(VGAM)
set.seed(1)
z = rpareto(1000, 1, 5)
pareto.MLE(z)
[1] 1.000014 5.065213
Edit: Based on the commentary by @cardinal and I below, we can also note that $\hat{\alpha}$ is the reciprocal of the sample mean of the $\log(X_i /\hat{m})$'s, which happen to have an exponential distribution. Therefore, if we have access to software that can fit an exponential distribution (which is more likely, since it seems to arise in many statistical problems), then fitting a Pareto distribution can be accomplished by transforming the data set in this way and fitting it to an exponential distribution on the transformed scale.
|
How do I fit a set of data to a Pareto distribution in R?
Well, if you have a sample $X_1, ..., X_n$ from a pareto distribution with parameters $m>0$ and $\alpha>0$ (where $m$ is the lower bound parameter and $\alpha$ is the shape parameter) the log-likeliho
|
9,857
|
How do I fit a set of data to a Pareto distribution in R?
|
You can use the fitdist function provided in fitdistrplus package:
library(MASS)
library(fitdistrplus)
library(actuar)
# suppose data is in dataPar list
fp <- fitdist(dataPar, "pareto", start=list(shape = 1, scale = 500))
#the mle parameters will be stored in fp$estimate
|
How do I fit a set of data to a Pareto distribution in R?
|
You can use the fitdist function provided in fitdistrplus package:
library(MASS)
library(fitdistrplus)
library(actuar)
# suppose data is in dataPar list
fp <- fitdist(dataPar, "pareto", start=list(sh
|
How do I fit a set of data to a Pareto distribution in R?
You can use the fitdist function provided in fitdistrplus package:
library(MASS)
library(fitdistrplus)
library(actuar)
# suppose data is in dataPar list
fp <- fitdist(dataPar, "pareto", start=list(shape = 1, scale = 500))
#the mle parameters will be stored in fp$estimate
|
How do I fit a set of data to a Pareto distribution in R?
You can use the fitdist function provided in fitdistrplus package:
library(MASS)
library(fitdistrplus)
library(actuar)
# suppose data is in dataPar list
fp <- fitdist(dataPar, "pareto", start=list(sh
|
9,858
|
In a Poisson model, what is the difference between using time as a covariate or an offset?
|
Offsets can be used in any regression model, but they are much more common when working with count data for your response variable. An offset is just a variable that is forced to have a coefficient of $1$ in the model. (See also this excellent CV thread: When to use an offset in a Poisson regression?)
When used correctly with count data, this will let you model rates instead of counts. If that is of interest, then it is something to do. Thus, this is the context in which offsets are used most frequently. Let's consider a Poisson GLiM with a log link (which is the canonical link).
\begin{align}
\ln(\lambda) &= \beta_0 + \beta_1X & ({\rm counts})& \\
\ln\bigg(\frac{\lambda}{{\rm time}}\bigg) &= \beta_0 + \beta_1X & ({\rm rates})& \\
&\Rightarrow \\
\ln(\lambda) - \ln({\rm time}) &= \beta_0 + \beta_1X \\
\ln(\lambda) &= \beta_0 + \beta_1X + 1\times \ln({\rm time}) & ({\rm still\ rates})& \\
&\ne \\
\ln(\lambda) &= \beta_0 + \beta_1X + \beta_2\times \ln({\rm time})\quad {\rm when}\ \beta_2 \ne 1 & ({\rm counts\ again})&
\end{align}
(As you can see, the key to using an offset correctly is to make $\ln({\rm time})$ the offset, not $\rm time$.)
When the coefficient on $\ln({\rm time})$ isn't $1$, you are no longer modeling rates. But since $\beta_2 \in (-\infty, 1)\cup (1, \infty)$ provides much greater flexibility to fit the data, models that don't use $\ln({\rm time})$ as an offset will typically fit better (although they may also overfit).
Whether you should model counts or rates really depends on what your substantive question is. You should model the one that corresponds to what you want to know.
As far as what it might mean for $\beta_2$ not to be $1$, consider an example where time isn't the variable in question. Imagine studying the number of surgical complications at different hospitals. One hospital has many more reported surgical complications, but they might claim that the comparison isn't fair because they do many more surgeries. So you decide to try to control for this. You can simply use the log of the number of surgeries as an offset, which would let you study the rate of complications per surgery. You could also use the log of the number of surgeries as another covariate. Let's say that the coefficient is significantly different from $1$. If $\beta_2 > 1$, then the hospitals that do more surgeries have a higher rate of complications (perhaps because they are rushing the job to get more done). If $\beta_2 < 1$, the hospitals that do the most have fewer complications per surgery (perhaps they have the best doctors, and so do more and do them better).
Seeing how this could happen if the variable in question were time is a little more complicated. The Poisson distribution arises from the Poisson process, in which the time between events is exponentially distributed, and hence there is a natural connection to survival analysis. In survival analysis, the time to events are often not distributed as an exponential, but the baseline hazard can become greater or lesser over time. Thus, consider a case where you are modeling the number of events that occur following some natural starting point. If $\beta_2 > 1$, that means the rate of events is speeding up, whereas if $\beta_2 < 1$, that means the rate of events is slowing down.
For a concrete example of the former, imagine a scan that counts the number of cancer cells a period of time after the initial tumor was surgically removed. For some patients, more time has elapsed since the surgery and you wanted to take that into account. Since once a cancer has regained its foothold it will begin to grow exponentially, the rate will be increasing over the time since the surgery without additional treatment.
For a concrete example of the latter, consider the number of people who die of a disease outbreak for which we have no treatment. At first, lots of people die because they were more susceptible to that disease, or already had a compromised immune system, etc. Over time, as the population of people remaining is less susceptible to the disease, the rate will decrease. (Sorry this example is so morbid.)
|
In a Poisson model, what is the difference between using time as a covariate or an offset?
|
Offsets can be used in any regression model, but they are much more common when working with count data for your response variable. An offset is just a variable that is forced to have a coefficient o
|
In a Poisson model, what is the difference between using time as a covariate or an offset?
Offsets can be used in any regression model, but they are much more common when working with count data for your response variable. An offset is just a variable that is forced to have a coefficient of $1$ in the model. (See also this excellent CV thread: When to use an offset in a Poisson regression?)
When used correctly with count data, this will let you model rates instead of counts. If that is of interest, then it is something to do. Thus, this is the context in which offsets are used most frequently. Let's consider a Poisson GLiM with a log link (which is the canonical link).
\begin{align}
\ln(\lambda) &= \beta_0 + \beta_1X & ({\rm counts})& \\
\ln\bigg(\frac{\lambda}{{\rm time}}\bigg) &= \beta_0 + \beta_1X & ({\rm rates})& \\
&\Rightarrow \\
\ln(\lambda) - \ln({\rm time}) &= \beta_0 + \beta_1X \\
\ln(\lambda) &= \beta_0 + \beta_1X + 1\times \ln({\rm time}) & ({\rm still\ rates})& \\
&\ne \\
\ln(\lambda) &= \beta_0 + \beta_1X + \beta_2\times \ln({\rm time})\quad {\rm when}\ \beta_2 \ne 1 & ({\rm counts\ again})&
\end{align}
(As you can see, the key to using an offset correctly is to make $\ln({\rm time})$ the offset, not $\rm time$.)
When the coefficient on $\ln({\rm time})$ isn't $1$, you are no longer modeling rates. But since $\beta_2 \in (-\infty, 1)\cup (1, \infty)$ provides much greater flexibility to fit the data, models that don't use $\ln({\rm time})$ as an offset will typically fit better (although they may also overfit).
Whether you should model counts or rates really depends on what your substantive question is. You should model the one that corresponds to what you want to know.
As far as what it might mean for $\beta_2$ not to be $1$, consider an example where time isn't the variable in question. Imagine studying the number of surgical complications at different hospitals. One hospital has many more reported surgical complications, but they might claim that the comparison isn't fair because they do many more surgeries. So you decide to try to control for this. You can simply use the log of the number of surgeries as an offset, which would let you study the rate of complications per surgery. You could also use the log of the number of surgeries as another covariate. Let's say that the coefficient is significantly different from $1$. If $\beta_2 > 1$, then the hospitals that do more surgeries have a higher rate of complications (perhaps because they are rushing the job to get more done). If $\beta_2 < 1$, the hospitals that do the most have fewer complications per surgery (perhaps they have the best doctors, and so do more and do them better).
Seeing how this could happen if the variable in question were time is a little more complicated. The Poisson distribution arises from the Poisson process, in which the time between events is exponentially distributed, and hence there is a natural connection to survival analysis. In survival analysis, the time to events are often not distributed as an exponential, but the baseline hazard can become greater or lesser over time. Thus, consider a case where you are modeling the number of events that occur following some natural starting point. If $\beta_2 > 1$, that means the rate of events is speeding up, whereas if $\beta_2 < 1$, that means the rate of events is slowing down.
For a concrete example of the former, imagine a scan that counts the number of cancer cells a period of time after the initial tumor was surgically removed. For some patients, more time has elapsed since the surgery and you wanted to take that into account. Since once a cancer has regained its foothold it will begin to grow exponentially, the rate will be increasing over the time since the surgery without additional treatment.
For a concrete example of the latter, consider the number of people who die of a disease outbreak for which we have no treatment. At first, lots of people die because they were more susceptible to that disease, or already had a compromised immune system, etc. Over time, as the population of people remaining is less susceptible to the disease, the rate will decrease. (Sorry this example is so morbid.)
|
In a Poisson model, what is the difference between using time as a covariate or an offset?
Offsets can be used in any regression model, but they are much more common when working with count data for your response variable. An offset is just a variable that is forced to have a coefficient o
|
9,859
|
In a Poisson model, what is the difference between using time as a covariate or an offset?
|
Time offsets can usually be viewed as your model estimating the rate an event occurs per unit time, with the offset controlling for how long you observed different subjects.
In poisson models you are always estimating a rate that something happens, but you never get to observe this rate directly. You do get to observe the number of times that an event happens over some amount of time. The offset makes the connection between the two concepts.
For example, you observed subjects shooting baskets for varying amounts of time, and you counted the number of successful baskets for each subject. What you are really interested in in how often each subject sinks a basket, i.e. the number of successful baskets each subject expects to sink each minute, as that is a somewhat objective measure of their skill. The number of baskets you actually observed sunk would then be this estimated rate times how long you observed the subject attempting. So you can think in terms of the units of the response, the number of baskets per minute.
Its difficult to think of a situation where you would use time observed as a covariate in a poisson regression, since by its very nature you are estimating a rate.
For example, if I want to asses the effect of being american vs european (very silly example) on the number of basket, adding time as a covariate would allow me to assess that effect "independently" from the time passed shoting, isn't it? Furthermore it would also give me an estimate of the effect of time on the outcome.
Here's an example that hopefully highlights the danger of this. Assume that Americans and Europeans, in truth, sink the same number of baskets each minute. But say that we have observed each European for twice as long as each American, so, on average, we have observed twice as many baskets for each European.
If we set up a model including parameters for both time observed and an indicator for "is European", then both of these models explain the data:
$$ E(\text{baskets}) = 2 c t + 0 x_{\text{Eropean}}$$
$$ E(\text{baskets}) = 0 t + 2 c x_{\text{Eropean}} $$
(where $c$ is some constant, which is the true rate that both types of players make baskets).
As a statistician, we really want, in this situation, our model to inform us that there is no statistical difference between the rate that Europeans make baskets and the rate Americans make baskets. But our model has failed to do so, and we are left confused.
The issue is that we know something that our model does not know. That is, we know that if we observe the same individual for twice as much time, that, in expectation, they will make twice as many baskets. Since we know this, we need to tell our model about it. This is what the offset accomplishes.
Maybe using the offset method is appropriate when we know that the events happen uniformily along time!
Yes, but this is an assumption of the poisson model itself. From the wikipedia page on the poisson distribution
the Poisson distribution, named after French mathematician SimΓ©on Denis Poisson, is a discrete probability distribution that expresses the probability of a given number of events occurring in a fixed interval of time and/or space if these events occur with a known average rate and independently of the time since the last event.
|
In a Poisson model, what is the difference between using time as a covariate or an offset?
|
Time offsets can usually be viewed as your model estimating the rate an event occurs per unit time, with the offset controlling for how long you observed different subjects.
In poisson models you are
|
In a Poisson model, what is the difference between using time as a covariate or an offset?
Time offsets can usually be viewed as your model estimating the rate an event occurs per unit time, with the offset controlling for how long you observed different subjects.
In poisson models you are always estimating a rate that something happens, but you never get to observe this rate directly. You do get to observe the number of times that an event happens over some amount of time. The offset makes the connection between the two concepts.
For example, you observed subjects shooting baskets for varying amounts of time, and you counted the number of successful baskets for each subject. What you are really interested in in how often each subject sinks a basket, i.e. the number of successful baskets each subject expects to sink each minute, as that is a somewhat objective measure of their skill. The number of baskets you actually observed sunk would then be this estimated rate times how long you observed the subject attempting. So you can think in terms of the units of the response, the number of baskets per minute.
Its difficult to think of a situation where you would use time observed as a covariate in a poisson regression, since by its very nature you are estimating a rate.
For example, if I want to asses the effect of being american vs european (very silly example) on the number of basket, adding time as a covariate would allow me to assess that effect "independently" from the time passed shoting, isn't it? Furthermore it would also give me an estimate of the effect of time on the outcome.
Here's an example that hopefully highlights the danger of this. Assume that Americans and Europeans, in truth, sink the same number of baskets each minute. But say that we have observed each European for twice as long as each American, so, on average, we have observed twice as many baskets for each European.
If we set up a model including parameters for both time observed and an indicator for "is European", then both of these models explain the data:
$$ E(\text{baskets}) = 2 c t + 0 x_{\text{Eropean}}$$
$$ E(\text{baskets}) = 0 t + 2 c x_{\text{Eropean}} $$
(where $c$ is some constant, which is the true rate that both types of players make baskets).
As a statistician, we really want, in this situation, our model to inform us that there is no statistical difference between the rate that Europeans make baskets and the rate Americans make baskets. But our model has failed to do so, and we are left confused.
The issue is that we know something that our model does not know. That is, we know that if we observe the same individual for twice as much time, that, in expectation, they will make twice as many baskets. Since we know this, we need to tell our model about it. This is what the offset accomplishes.
Maybe using the offset method is appropriate when we know that the events happen uniformily along time!
Yes, but this is an assumption of the poisson model itself. From the wikipedia page on the poisson distribution
the Poisson distribution, named after French mathematician SimΓ©on Denis Poisson, is a discrete probability distribution that expresses the probability of a given number of events occurring in a fixed interval of time and/or space if these events occur with a known average rate and independently of the time since the last event.
|
In a Poisson model, what is the difference between using time as a covariate or an offset?
Time offsets can usually be viewed as your model estimating the rate an event occurs per unit time, with the offset controlling for how long you observed different subjects.
In poisson models you are
|
9,860
|
If linear regression is related to Pearson's correlation, are there any regression techniques related to Kendall's and Spearman's correlations?
|
There's a very straightforward means by which to use almost any correlation measure to fit linear regressions, and which reproduces least squares when you use the Pearson correlation.
Consider that if the slope of a relationship is $\beta$, the correlation between $y-\beta x$ and $x$ should be expected to be $0$.
Indeed, if it were anything other than $0$, there'd be some uncaptured linear relationship - which is what the correlation measure would be picking up.
We might therefore estimate the slope by finding the slope, $\tilde{\beta}$ that makes the sample correlation between $y-\tilde{\beta} x$ and $x$ be $0$. In many cases -- e.g. when using rank-based measures -- the correlation will be a step-function of the value of the slope estimate, so there may be an interval where it's zero. In that case we normally define the sample estimate to be the center of the interval. Often the step function jumps from above zero to below zero at some point, and in that case the estimate is at the jump point.
This definition works, for example, with all manner of rank based and robust correlations. It can also be used to obtain an interval for the slope (in the usual manner - by finding the slopes that mark the border between just significant correlations and just insignificant correlations).
This only defines the slope, of course; once the slope is estimated, the intercept can be based on a suitable location estimate computed on the residuals $y-\tilde{\beta}x$. With the rank-based correlations the median is a common choice, but there are many other suitable choices.
Here's the correlation plotted against the slope for the car data in R:
The Pearson correlation crosses 0 at the least squares slope, 3.932
The Kendall correlation crosses 0 at the Theil-Sen slope, 3.667
The Spearman correlation crosses 0 giving a "Spearman-line" slope of 3.714
Those are the three slope estimates for our example. Now we need intercepts. For simplicity I'll just use the mean residual for the first intercept and the median for the other two (it doesn't matter very much in this case):
intercept
Pearson: -17.573 *
Kendall: -15.667
Spearman: -16.285
*(the small difference from least squares is due to rounding error in the slope estimate; no doubt there's similar rounding error in the other estimates)
The corresponding fitted lines (using the same color scheme as above) are:
Edit: By comparison, the quadrant-correlation slope is 3.333
Both the Kendall correlation and Spearman correlation slopes are substantially more robust to influential outliers than least squares. See here for a dramatic example in the case of the Kendall.
|
If linear regression is related to Pearson's correlation, are there any regression techniques relate
|
There's a very straightforward means by which to use almost any correlation measure to fit linear regressions, and which reproduces least squares when you use the Pearson correlation.
Consider that if
|
If linear regression is related to Pearson's correlation, are there any regression techniques related to Kendall's and Spearman's correlations?
There's a very straightforward means by which to use almost any correlation measure to fit linear regressions, and which reproduces least squares when you use the Pearson correlation.
Consider that if the slope of a relationship is $\beta$, the correlation between $y-\beta x$ and $x$ should be expected to be $0$.
Indeed, if it were anything other than $0$, there'd be some uncaptured linear relationship - which is what the correlation measure would be picking up.
We might therefore estimate the slope by finding the slope, $\tilde{\beta}$ that makes the sample correlation between $y-\tilde{\beta} x$ and $x$ be $0$. In many cases -- e.g. when using rank-based measures -- the correlation will be a step-function of the value of the slope estimate, so there may be an interval where it's zero. In that case we normally define the sample estimate to be the center of the interval. Often the step function jumps from above zero to below zero at some point, and in that case the estimate is at the jump point.
This definition works, for example, with all manner of rank based and robust correlations. It can also be used to obtain an interval for the slope (in the usual manner - by finding the slopes that mark the border between just significant correlations and just insignificant correlations).
This only defines the slope, of course; once the slope is estimated, the intercept can be based on a suitable location estimate computed on the residuals $y-\tilde{\beta}x$. With the rank-based correlations the median is a common choice, but there are many other suitable choices.
Here's the correlation plotted against the slope for the car data in R:
The Pearson correlation crosses 0 at the least squares slope, 3.932
The Kendall correlation crosses 0 at the Theil-Sen slope, 3.667
The Spearman correlation crosses 0 giving a "Spearman-line" slope of 3.714
Those are the three slope estimates for our example. Now we need intercepts. For simplicity I'll just use the mean residual for the first intercept and the median for the other two (it doesn't matter very much in this case):
intercept
Pearson: -17.573 *
Kendall: -15.667
Spearman: -16.285
*(the small difference from least squares is due to rounding error in the slope estimate; no doubt there's similar rounding error in the other estimates)
The corresponding fitted lines (using the same color scheme as above) are:
Edit: By comparison, the quadrant-correlation slope is 3.333
Both the Kendall correlation and Spearman correlation slopes are substantially more robust to influential outliers than least squares. See here for a dramatic example in the case of the Kendall.
|
If linear regression is related to Pearson's correlation, are there any regression techniques relate
There's a very straightforward means by which to use almost any correlation measure to fit linear regressions, and which reproduces least squares when you use the Pearson correlation.
Consider that if
|
9,861
|
If linear regression is related to Pearson's correlation, are there any regression techniques related to Kendall's and Spearman's correlations?
|
The proportional odds (PO) model generalizes Wilcoxon and Kruskal-Wallis tests. Spearman's correlation when $X$ is binary is the Wilcoxon test statistic simply translated. So you could say that the PO model is a unifying method. Since the PO model can have as many intercepts as there are unique values of $Y$ (less one), it handles both ordinal and continuous $Y$.
The numerator of the score $\chi^2$ statistic in the PO model is exactly the Wilcoxon statistic.
The PO model is a special case of a more general family of cumulative probability (some call cumulative link) models including the probit, proportional hazards, and complementary log-log models. For a case study see Chapter 15 of my Handouts.
|
If linear regression is related to Pearson's correlation, are there any regression techniques relate
|
The proportional odds (PO) model generalizes Wilcoxon and Kruskal-Wallis tests. Spearman's correlation when $X$ is binary is the Wilcoxon test statistic simply translated. So you could say that the
|
If linear regression is related to Pearson's correlation, are there any regression techniques related to Kendall's and Spearman's correlations?
The proportional odds (PO) model generalizes Wilcoxon and Kruskal-Wallis tests. Spearman's correlation when $X$ is binary is the Wilcoxon test statistic simply translated. So you could say that the PO model is a unifying method. Since the PO model can have as many intercepts as there are unique values of $Y$ (less one), it handles both ordinal and continuous $Y$.
The numerator of the score $\chi^2$ statistic in the PO model is exactly the Wilcoxon statistic.
The PO model is a special case of a more general family of cumulative probability (some call cumulative link) models including the probit, proportional hazards, and complementary log-log models. For a case study see Chapter 15 of my Handouts.
|
If linear regression is related to Pearson's correlation, are there any regression techniques relate
The proportional odds (PO) model generalizes Wilcoxon and Kruskal-Wallis tests. Spearman's correlation when $X$ is binary is the Wilcoxon test statistic simply translated. So you could say that the
|
9,862
|
If linear regression is related to Pearson's correlation, are there any regression techniques related to Kendall's and Spearman's correlations?
|
Aaron Han (1987 in econometrics) proposed the Maximum Rank Correlation estimator that fits regression models by maximizing tau. Dougherty and Thomas (2012 in the psychology literature) recently proposed a very similar algorithm. There is an abundance of work on the MRC illustrating its properties.
Aaron K. Han, Non-parametric analysis of a generalized regression model: The maximum rank correlation estimator, Journal of Econometrics, Volume 35, Issues 2β3, July 1987, Pages 303-316, ISSN 0304-4076, http://dx.doi.org/10.1016/0304-4076(87)90030-3.
(http://www.sciencedirect.com/science/article/pii/0304407687900303)
Dougherty, M. R., & Thomas, R. P. (2012). Robust decision making in a nonlinear world. Psychological review, 119 (2), 321. Retrieved from http://damlab.umd.edu/pdf%20articles/DoughertyThomas2012Rev.pdf.
|
If linear regression is related to Pearson's correlation, are there any regression techniques relate
|
Aaron Han (1987 in econometrics) proposed the Maximum Rank Correlation estimator that fits regression models by maximizing tau. Dougherty and Thomas (2012 in the psychology literature) recently propos
|
If linear regression is related to Pearson's correlation, are there any regression techniques related to Kendall's and Spearman's correlations?
Aaron Han (1987 in econometrics) proposed the Maximum Rank Correlation estimator that fits regression models by maximizing tau. Dougherty and Thomas (2012 in the psychology literature) recently proposed a very similar algorithm. There is an abundance of work on the MRC illustrating its properties.
Aaron K. Han, Non-parametric analysis of a generalized regression model: The maximum rank correlation estimator, Journal of Econometrics, Volume 35, Issues 2β3, July 1987, Pages 303-316, ISSN 0304-4076, http://dx.doi.org/10.1016/0304-4076(87)90030-3.
(http://www.sciencedirect.com/science/article/pii/0304407687900303)
Dougherty, M. R., & Thomas, R. P. (2012). Robust decision making in a nonlinear world. Psychological review, 119 (2), 321. Retrieved from http://damlab.umd.edu/pdf%20articles/DoughertyThomas2012Rev.pdf.
|
If linear regression is related to Pearson's correlation, are there any regression techniques relate
Aaron Han (1987 in econometrics) proposed the Maximum Rank Correlation estimator that fits regression models by maximizing tau. Dougherty and Thomas (2012 in the psychology literature) recently propos
|
9,863
|
What if interaction wipes out my direct effects in regression?
|
I think this one is tricky; as you hint, there's 'moral hazard' here: if you hadn't looked at the interaction at all, you'd be free and clear, but now that you have there is a suspicion of data-dredging if you drop it.
The key is probably a change in the meaning of your effects when you go from the main-effects-only to the interaction model. What you get for the 'main effects' depends very much on how your treatments and contrasts are coded. In R, the default is treatment contrasts with the first factor levels (the ones with the first names in alphabetical order unless you have gone out of your way to code them differently) as the baseline levels.
Say (for simplicity) that you have two levels, 'control' and 'trt', for each factor. Without the interaction, the meaning of the 'v1.trt' parameter (assuming treatment contrasts as is the default in R) is "average difference between 'v1.control' and 'v1.trt' group"; the meaning of the 'v2.trt' parameter is "average difference between 'v2.control' and 'v2.trt'".
With the interaction, 'v1.trt' is the average difference between 'v1.control' and 'v1.trt' in the 'v2.control' group, and similarly 'v2.trt' is the average difference between v2 groups in the 'v1.control' group. Thus, if you have fairly small treatment effects in each of the control groups, but a large effect in the treatment groups, you could easily see what you're seeing.
The only way I can see this happening without a significant interaction term, however, is if all the effects are fairly weak (so that what you really mean by "the effect disappeared" is that you went from p=0.06 to p=0.04, across the magic significance line).
Another possibility is that you are 'using up too many degrees of freedom' -- that is, the parameter estimates don't actually change that much, but the residual error term is sufficiently inflated by having to estimate another 4 [ = (2-1)*(5-1)] parameters that your significant terms become non-significant. Again, I would only expect this with a small data set/relatively weak effects.
One possible solution is to move to sum contrasts, although this is also delicate -- you have to be convinced that 'average effect' is meaningful in your case. The very best thing is to plot your data and to look at the coefficients and understand what's happening in terms of the estimated parameters.
Hope that helps.
|
What if interaction wipes out my direct effects in regression?
|
I think this one is tricky; as you hint, there's 'moral hazard' here: if you hadn't looked at the interaction at all, you'd be free and clear, but now that you have there is a suspicion of data-dredgi
|
What if interaction wipes out my direct effects in regression?
I think this one is tricky; as you hint, there's 'moral hazard' here: if you hadn't looked at the interaction at all, you'd be free and clear, but now that you have there is a suspicion of data-dredging if you drop it.
The key is probably a change in the meaning of your effects when you go from the main-effects-only to the interaction model. What you get for the 'main effects' depends very much on how your treatments and contrasts are coded. In R, the default is treatment contrasts with the first factor levels (the ones with the first names in alphabetical order unless you have gone out of your way to code them differently) as the baseline levels.
Say (for simplicity) that you have two levels, 'control' and 'trt', for each factor. Without the interaction, the meaning of the 'v1.trt' parameter (assuming treatment contrasts as is the default in R) is "average difference between 'v1.control' and 'v1.trt' group"; the meaning of the 'v2.trt' parameter is "average difference between 'v2.control' and 'v2.trt'".
With the interaction, 'v1.trt' is the average difference between 'v1.control' and 'v1.trt' in the 'v2.control' group, and similarly 'v2.trt' is the average difference between v2 groups in the 'v1.control' group. Thus, if you have fairly small treatment effects in each of the control groups, but a large effect in the treatment groups, you could easily see what you're seeing.
The only way I can see this happening without a significant interaction term, however, is if all the effects are fairly weak (so that what you really mean by "the effect disappeared" is that you went from p=0.06 to p=0.04, across the magic significance line).
Another possibility is that you are 'using up too many degrees of freedom' -- that is, the parameter estimates don't actually change that much, but the residual error term is sufficiently inflated by having to estimate another 4 [ = (2-1)*(5-1)] parameters that your significant terms become non-significant. Again, I would only expect this with a small data set/relatively weak effects.
One possible solution is to move to sum contrasts, although this is also delicate -- you have to be convinced that 'average effect' is meaningful in your case. The very best thing is to plot your data and to look at the coefficients and understand what's happening in terms of the estimated parameters.
Hope that helps.
|
What if interaction wipes out my direct effects in regression?
I think this one is tricky; as you hint, there's 'moral hazard' here: if you hadn't looked at the interaction at all, you'd be free and clear, but now that you have there is a suspicion of data-dredgi
|
9,864
|
What if interaction wipes out my direct effects in regression?
|
Are you sure the variables have been appropriately expressed? Consider two independent variables $X_1$ and $X_2$. The problem statement asserts that you are getting a good fit in the form
$$Y = \beta_0 + \beta_{12} X_1 X_2 + \epsilon$$
If there is some evidence that the variance of the residuals increases with $Y$, then a better model uses multiplicative error, of which one form is
$$Y = \beta_0 + \left( \beta_{12} X_1 X_2 \right) \delta$$
This can be rewritten
$$\log(Y - \beta_0) = \log(\beta_{12}) + \log(X_1) + \log(X_2) + \log(\delta);$$
that is, if you re-express your variables in the form
$$\eqalign{
\eta =& \log(Y - \beta_0) \cr
\xi_1 =& \log(X_1)\cr
\xi_2 =& \log(X_2)\cr
\zeta =& \log(\delta) \sim N(0, \sigma^2)
}$$
then the model is linear and likely has homoscedastic residuals:
$$\eta = \gamma_0 + \gamma_1 \xi_1 + \gamma_2 \xi_2 + \zeta,$$
and it may just so happen that $\gamma_1$ and $\gamma_2$ are both close to 1.
The value of $\beta_0$ can be discovered through standard methods of exploratory data analysis or, sometimes, is indicated by the nature of the variable. (For instance, it might be a theoretical minimum value attainable by $Y$.)
Alternatively, suppose $\beta_0$ is positive and sizable (within the context of the data) but $\sqrt{\beta_0}$ is inconsequentially small. Then the original fit can be re-expressed as
$$Y = (\theta_1 + X_1) (\theta_2 + X_2) + \epsilon$$
where $\theta_1 \theta_2 = \beta_0$ and both $\theta_1$ and $\theta_2$ are small. Here, the missing cross terms $\theta_1 X_2$ and $\theta_2 X_1$ are presumed small enough to be subsumed within the error term $\epsilon$. Again, assuming a multiplicative error and taking logarithms gives a model with only direct effects and no interaction.
This analysis shows how it is possible--even likely in some applications--to have a model in which the only effects appear to be interactions. This arises when the variables (independent, dependent, or both) are presented to you in an unsuitable form and their logarithms are a more effective target for modeling. The distributions of the variables and of the initial residuals provide the clues needed to determine whether this may be the case: skewed distributions of the variables and heteroscedasticity of the residuals (specifically, having variances roughly proportional to the predicted values) are the indicators.
|
What if interaction wipes out my direct effects in regression?
|
Are you sure the variables have been appropriately expressed? Consider two independent variables $X_1$ and $X_2$. The problem statement asserts that you are getting a good fit in the form
$$Y = \bet
|
What if interaction wipes out my direct effects in regression?
Are you sure the variables have been appropriately expressed? Consider two independent variables $X_1$ and $X_2$. The problem statement asserts that you are getting a good fit in the form
$$Y = \beta_0 + \beta_{12} X_1 X_2 + \epsilon$$
If there is some evidence that the variance of the residuals increases with $Y$, then a better model uses multiplicative error, of which one form is
$$Y = \beta_0 + \left( \beta_{12} X_1 X_2 \right) \delta$$
This can be rewritten
$$\log(Y - \beta_0) = \log(\beta_{12}) + \log(X_1) + \log(X_2) + \log(\delta);$$
that is, if you re-express your variables in the form
$$\eqalign{
\eta =& \log(Y - \beta_0) \cr
\xi_1 =& \log(X_1)\cr
\xi_2 =& \log(X_2)\cr
\zeta =& \log(\delta) \sim N(0, \sigma^2)
}$$
then the model is linear and likely has homoscedastic residuals:
$$\eta = \gamma_0 + \gamma_1 \xi_1 + \gamma_2 \xi_2 + \zeta,$$
and it may just so happen that $\gamma_1$ and $\gamma_2$ are both close to 1.
The value of $\beta_0$ can be discovered through standard methods of exploratory data analysis or, sometimes, is indicated by the nature of the variable. (For instance, it might be a theoretical minimum value attainable by $Y$.)
Alternatively, suppose $\beta_0$ is positive and sizable (within the context of the data) but $\sqrt{\beta_0}$ is inconsequentially small. Then the original fit can be re-expressed as
$$Y = (\theta_1 + X_1) (\theta_2 + X_2) + \epsilon$$
where $\theta_1 \theta_2 = \beta_0$ and both $\theta_1$ and $\theta_2$ are small. Here, the missing cross terms $\theta_1 X_2$ and $\theta_2 X_1$ are presumed small enough to be subsumed within the error term $\epsilon$. Again, assuming a multiplicative error and taking logarithms gives a model with only direct effects and no interaction.
This analysis shows how it is possible--even likely in some applications--to have a model in which the only effects appear to be interactions. This arises when the variables (independent, dependent, or both) are presented to you in an unsuitable form and their logarithms are a more effective target for modeling. The distributions of the variables and of the initial residuals provide the clues needed to determine whether this may be the case: skewed distributions of the variables and heteroscedasticity of the residuals (specifically, having variances roughly proportional to the predicted values) are the indicators.
|
What if interaction wipes out my direct effects in regression?
Are you sure the variables have been appropriately expressed? Consider two independent variables $X_1$ and $X_2$. The problem statement asserts that you are getting a good fit in the form
$$Y = \bet
|
9,865
|
What if interaction wipes out my direct effects in regression?
|
This may be a problem of interpretation, a misunderstanding of what a so-called "direct effect" coefficient really is.
In regression models with continuous predictor variables and no interaction terms -- that is, with no terms that are constructed as the product of other terms -- each variable's coefficient is the slope of the regression surface in the direction of that variable. It is constant, regardless of the values of the variables, and is obviously a measure of the effect of that variable.
In models with interactions -- that is, with terms that are constructed as the products of other terms -- that interpretation can be made without further qualification only for variables that are not involved in any interactions. The coefficient of a variable that is involved in interactions is the slope of the regression surface in the direction of that variable when the values of all the variables that interact with the variable in question are zero, and the significance test of the coefficient refers to the slope of the regression surface only in that region of the predictor space. Since there is no requirement that there actually be data in that region of the space, the apparent direct effect coefficient may bear little resemblance to the slope of the regression surface in the region of the predictor space where data were actually observed. There is no true "direct effect" in such cases; the best substitute is probably the "average effect": the slope of the regression surface in the direction of the variable in question, taken at each data point and averaged over all data points. For more on this, see Why could centering independent variables change the main effects with moderation?
|
What if interaction wipes out my direct effects in regression?
|
This may be a problem of interpretation, a misunderstanding of what a so-called "direct effect" coefficient really is.
In regression models with continuous predictor variables and no interaction terms
|
What if interaction wipes out my direct effects in regression?
This may be a problem of interpretation, a misunderstanding of what a so-called "direct effect" coefficient really is.
In regression models with continuous predictor variables and no interaction terms -- that is, with no terms that are constructed as the product of other terms -- each variable's coefficient is the slope of the regression surface in the direction of that variable. It is constant, regardless of the values of the variables, and is obviously a measure of the effect of that variable.
In models with interactions -- that is, with terms that are constructed as the products of other terms -- that interpretation can be made without further qualification only for variables that are not involved in any interactions. The coefficient of a variable that is involved in interactions is the slope of the regression surface in the direction of that variable when the values of all the variables that interact with the variable in question are zero, and the significance test of the coefficient refers to the slope of the regression surface only in that region of the predictor space. Since there is no requirement that there actually be data in that region of the space, the apparent direct effect coefficient may bear little resemblance to the slope of the regression surface in the region of the predictor space where data were actually observed. There is no true "direct effect" in such cases; the best substitute is probably the "average effect": the slope of the regression surface in the direction of the variable in question, taken at each data point and averaged over all data points. For more on this, see Why could centering independent variables change the main effects with moderation?
|
What if interaction wipes out my direct effects in regression?
This may be a problem of interpretation, a misunderstanding of what a so-called "direct effect" coefficient really is.
In regression models with continuous predictor variables and no interaction terms
|
9,866
|
What if interaction wipes out my direct effects in regression?
|
In a regular multiple regression with two quantitative predictor variables, including their interaction just means including their observation-wise product as an additional predictor variable: $Y = \beta_0 + \beta_1 X_1 + \beta_2 X_2 + \beta_3 (X_1 \cdot X_2) = (b_0 + b_2 X_2) + (b_1 + b_3 X_2) X_1$
This typically introduces high multicollinearity since the product will strongly correlate with both original variables. With multicollinearity, individual parameter estimates depend strongly on which other variables are considered - like in your case. As a counter-measure, centering the variables often reduces multicollinearity when the interaction is considered.
I'm not sure if this directly applies to your case since you seem to have categorical predictors but use the term "regression" instead of "ANOVA". Of course the latter case is essentially the same model, but only after choosing the contrast coding scheme as Ben explained.
|
What if interaction wipes out my direct effects in regression?
|
In a regular multiple regression with two quantitative predictor variables, including their interaction just means including their observation-wise product as an additional predictor variable: $Y = \b
|
What if interaction wipes out my direct effects in regression?
In a regular multiple regression with two quantitative predictor variables, including their interaction just means including their observation-wise product as an additional predictor variable: $Y = \beta_0 + \beta_1 X_1 + \beta_2 X_2 + \beta_3 (X_1 \cdot X_2) = (b_0 + b_2 X_2) + (b_1 + b_3 X_2) X_1$
This typically introduces high multicollinearity since the product will strongly correlate with both original variables. With multicollinearity, individual parameter estimates depend strongly on which other variables are considered - like in your case. As a counter-measure, centering the variables often reduces multicollinearity when the interaction is considered.
I'm not sure if this directly applies to your case since you seem to have categorical predictors but use the term "regression" instead of "ANOVA". Of course the latter case is essentially the same model, but only after choosing the contrast coding scheme as Ben explained.
|
What if interaction wipes out my direct effects in regression?
In a regular multiple regression with two quantitative predictor variables, including their interaction just means including their observation-wise product as an additional predictor variable: $Y = \b
|
9,867
|
How to perform Student's t-test having only sample size, sample average and population average are known?
|
This may surprise many, but to solve this problem you don't necessarily need to estimate s. In fact, you don't need to know anything about the spread of the data (although that would be helpful, of course). For instance, Wall, Boen, and Tweedie in a 2001 article describe how to find a finite confidence interval for the mean of any unimodal distribution based on a single draw.
In the present case, we have some basis to view the sample mean of 112 as a draw from an approximately normal distribution (namely, the sampling distribution of the average of a simple random sample of 49 salaries). We are implicitly assuming there are a fairly large number of factory workers and that their salary distribution is not so skewed or multimodal as to render the central limit theorem inoperable. Then a conservative 90% CI for the mean extends upwards to
$$112 + 5.84\ |112|,$$
clearly covering the true mean of 200. (See Wall et al formula 3.) Given the limited information available and the assumptions made here, we therefore cannot conclude that 112 differs "significantly" from 200.
Reference: "An Effective Confidence Interval for the Mean With Samples of Size One and Two." The American Statistician, May 2001, Vol. 55, No. 2: pp. 102-105. (pdf)
|
How to perform Student's t-test having only sample size, sample average and population average are k
|
This may surprise many, but to solve this problem you don't necessarily need to estimate s. In fact, you don't need to know anything about the spread of the data (although that would be helpful, of c
|
How to perform Student's t-test having only sample size, sample average and population average are known?
This may surprise many, but to solve this problem you don't necessarily need to estimate s. In fact, you don't need to know anything about the spread of the data (although that would be helpful, of course). For instance, Wall, Boen, and Tweedie in a 2001 article describe how to find a finite confidence interval for the mean of any unimodal distribution based on a single draw.
In the present case, we have some basis to view the sample mean of 112 as a draw from an approximately normal distribution (namely, the sampling distribution of the average of a simple random sample of 49 salaries). We are implicitly assuming there are a fairly large number of factory workers and that their salary distribution is not so skewed or multimodal as to render the central limit theorem inoperable. Then a conservative 90% CI for the mean extends upwards to
$$112 + 5.84\ |112|,$$
clearly covering the true mean of 200. (See Wall et al formula 3.) Given the limited information available and the assumptions made here, we therefore cannot conclude that 112 differs "significantly" from 200.
Reference: "An Effective Confidence Interval for the Mean With Samples of Size One and Two." The American Statistician, May 2001, Vol. 55, No. 2: pp. 102-105. (pdf)
|
How to perform Student's t-test having only sample size, sample average and population average are k
This may surprise many, but to solve this problem you don't necessarily need to estimate s. In fact, you don't need to know anything about the spread of the data (although that would be helpful, of c
|
9,868
|
How to perform Student's t-test having only sample size, sample average and population average are known?
|
This does look to be a slightly contrived question. 49 is an exact square of 7. The value of a t-distribution with 48 DoF for a two-sided test of p<0.05 is very nearly 2 (2.01).
We reject the null hypothesis of equality of means if |sample_mean - popn_mean| > 2*StdError, i.e. 200-112 > 2*SE so SE < 44, i.e. SD < 7*44 = 308.
It would be impossible to get a normal distribution with a mean of 112 with a standard deviation of 308 (or more) without negative wages.
Given wages are bounded below, they are likely to be skew, so assuming a log-normal distribution would be more appropriate, but it would still require highly variable wages to avoid a p<0.05 on a t-test.
|
How to perform Student's t-test having only sample size, sample average and population average are k
|
This does look to be a slightly contrived question. 49 is an exact square of 7. The value of a t-distribution with 48 DoF for a two-sided test of p<0.05 is very nearly 2 (2.01).
We reject the null hyp
|
How to perform Student's t-test having only sample size, sample average and population average are known?
This does look to be a slightly contrived question. 49 is an exact square of 7. The value of a t-distribution with 48 DoF for a two-sided test of p<0.05 is very nearly 2 (2.01).
We reject the null hypothesis of equality of means if |sample_mean - popn_mean| > 2*StdError, i.e. 200-112 > 2*SE so SE < 44, i.e. SD < 7*44 = 308.
It would be impossible to get a normal distribution with a mean of 112 with a standard deviation of 308 (or more) without negative wages.
Given wages are bounded below, they are likely to be skew, so assuming a log-normal distribution would be more appropriate, but it would still require highly variable wages to avoid a p<0.05 on a t-test.
|
How to perform Student's t-test having only sample size, sample average and population average are k
This does look to be a slightly contrived question. 49 is an exact square of 7. The value of a t-distribution with 48 DoF for a two-sided test of p<0.05 is very nearly 2 (2.01).
We reject the null hyp
|
9,869
|
How to perform Student's t-test having only sample size, sample average and population average are known?
|
Suppose there are 999 workers at ACME north factory each making a wage of 112, and 1 CEO making 88112. The population mean salary is $\mu = 0.999 * 112 + 0.001 * 88112 = 200.$ The probability of drawing the CEO from a sample of 49 people at the factory is $49 / 1000 < 0.05$ (this is from the hypergeometric distribution), thus with 95% confidence, your population sample mean will be 112. In fact, by adjusting the ratio of workers/CEOs, and the salary of the CEO, we can make it arbitrarily unlikely that a sample of 49 employees will draw a CEO, while fixing the population mean at 200, and the sample mean at 112. Thus, without making some assumptions about the underlying distribution, you cannot draw any inference about the population mean.
|
How to perform Student's t-test having only sample size, sample average and population average are k
|
Suppose there are 999 workers at ACME north factory each making a wage of 112, and 1 CEO making 88112. The population mean salary is $\mu = 0.999 * 112 + 0.001 * 88112 = 200.$ The probability of drawi
|
How to perform Student's t-test having only sample size, sample average and population average are known?
Suppose there are 999 workers at ACME north factory each making a wage of 112, and 1 CEO making 88112. The population mean salary is $\mu = 0.999 * 112 + 0.001 * 88112 = 200.$ The probability of drawing the CEO from a sample of 49 people at the factory is $49 / 1000 < 0.05$ (this is from the hypergeometric distribution), thus with 95% confidence, your population sample mean will be 112. In fact, by adjusting the ratio of workers/CEOs, and the salary of the CEO, we can make it arbitrarily unlikely that a sample of 49 employees will draw a CEO, while fixing the population mean at 200, and the sample mean at 112. Thus, without making some assumptions about the underlying distribution, you cannot draw any inference about the population mean.
|
How to perform Student's t-test having only sample size, sample average and population average are k
Suppose there are 999 workers at ACME north factory each making a wage of 112, and 1 CEO making 88112. The population mean salary is $\mu = 0.999 * 112 + 0.001 * 88112 = 200.$ The probability of drawi
|
9,870
|
How to perform Student's t-test having only sample size, sample average and population average are known?
|
I presume you are referring to a one sample t test. Its goal is to compare the mean of your sample with a hypothetical mean. It then computes (assuming your population is Gaussian) a P value that answers this question: If the population mean really was the hypothetical value, how unlikely would it be to draw a sample whose mean is as far from that value (or further) than you observed? Of course, the answer to that question depends on sample size. But it also depends on variability. If your data have a huge amount of scatter, they are consistent with a broad range of population means. If your data are really tight, they are consistent with a smaller range of population means.
|
How to perform Student's t-test having only sample size, sample average and population average are k
|
I presume you are referring to a one sample t test. Its goal is to compare the mean of your sample with a hypothetical mean. It then computes (assuming your population is Gaussian) a P value that answ
|
How to perform Student's t-test having only sample size, sample average and population average are known?
I presume you are referring to a one sample t test. Its goal is to compare the mean of your sample with a hypothetical mean. It then computes (assuming your population is Gaussian) a P value that answers this question: If the population mean really was the hypothetical value, how unlikely would it be to draw a sample whose mean is as far from that value (or further) than you observed? Of course, the answer to that question depends on sample size. But it also depends on variability. If your data have a huge amount of scatter, they are consistent with a broad range of population means. If your data are really tight, they are consistent with a smaller range of population means.
|
How to perform Student's t-test having only sample size, sample average and population average are k
I presume you are referring to a one sample t test. Its goal is to compare the mean of your sample with a hypothetical mean. It then computes (assuming your population is Gaussian) a P value that answ
|
9,871
|
Continuous generalization of the negative binomial distribution
|
That's an interesting question. My research group has been using the distribution you refer to for some years in our publicly available bioinformatics software. As far as I know, the distribution does not have a name and there is no literature on it. While the paper by Chandra et al (2012) cited by Aksakal is closely related, the distribution they consider seems to be restricted to integer values for $r$ and they don't seem to give an explicit expression for the pdf.
To give you some background, the NB distribution is very heavily used in genomic research to model gene expression data arising from RNA-seq and related technologies. The count data arises as the number of DNA or RNA sequence reads extracted from a biological sample that can be mapped to each gene. Typically there are tens of millions of reads from each biological sample that are mapped to about 25,000 genes. Alternatively one might have DNA samples from which reads are mapped to genomic windows. We and others have popularized an approach whereby NB glms are fitted to the sequence reads for each gene, and empirical Bayes methods are used to moderate the genewise dispersion estimators (dispersion $\phi=1/r$). This approach has been cited in tens of thousands of journal articles in the genomic literature, so you can get an idea of how much it gets used.
My group maintains the edgeR R sofware package. Some years ago we revised the whole package so that it works with fractional counts, using a continuous version of the NB pmf. We simply converted all the binomial coefficients in the NB pmf to ratios of gamma functions and used it as a (mixed) continuous pdf. The motivation for this was that sequence read counts can sometimes be fractional because of (1) ambiguous mapping of reads to the transcriptome or genome and/or (2) normalization of counts to correct for technical effects. So the counts are sometimes expected counts or estimated counts rather than observed counts. And of course the read counts can be exactly zero with positive probability. Our approach ensures that the inference results from our software are continuous in the counts, matching exactly with discrete NB results when the estimated counts happen to be integers.
As far as I know, there is no closed form for the normalizing constant in the pdf, nor are there closed forms for the mean or variance. When one considers that there is no closed form for the integral
$$\int_0^\infty \frac{1}{\Gamma(x)}dz$$
(the Fransen-Robinson constant) it is clear that there cannot be for the integral of the continuous NB pdf either.
However it seems to me that traditional mean and variance formulas for the NB should continue to be good approximations for the continuous NB. Moreover the normalizing constant should vary slowly with the parameters and therefore can be ignored as having negligible influence in the maximum likelihood calculations.
One can confirm these hypotheses by numerical integration. The NB distribution arises in bioinformatics as a gamma mixture of Poisson distributions (see the Wikipedia negative binomial article or McCarthy et al below).
The continuous NB distribution arises simply by replacing the Poisson distribution with its continuous analog with pdf
$$f(x;\lambda)=a(\lambda)\frac{e^{-\lambda}\lambda^x}{\Gamma(x+1)}$$
for $x\ge 0$ where $a(\lambda)$ is a normalizing constant to ensure the density integrates to 1.
Suppose for example that $\lambda=10$. The Poisson distribution has pmf equal the above pdf on the non-negative integers and, with $\lambda=10$, the Poisson mean and variance are equal to 10.
Numerical integration shows that $a(10)=1/0.999875$ and the mean and variance of the continuous distribution are equal to 10 to about 4 significant figures.
So the normalizing constant is virtually 1 and the mean and variance are almost exactly the same as for the discrete Poisson distribution.
The approximation is improved even more if we add a continuity correction, integrating from $-1/2$ to $\infty$ instead of from 0.
With the continuity correction, everything is correct (normalizing constant is 1 and moments agree with discrete Poisson) to about 6 figures.
In our edgeR package, we do not need to make any adjustment for the fact that there is mass at zero, because we always work with conditional log-likelihoods or with log-likelihood differences and any delta functions cancel out of the calculations. This is typical BTW for glms with mixed probability distributions. Alternatively, we could consider the distribution to have no mass at zero but to have support starting at -1/2 instead of at zero. Either theoretical perspective leads to the same calculations in practice.
Although we make active use of the continuous NB distribution, we haven't published anything on it explicitly. The articles cited below explain the NB approach to genomic data but don't discuss the continuous NB distribution explicitly.
In summary, I am not surprised that the article you are studying obtained reasonable results from a continualized version of the NB pdf, because that is our experience also. The key requirement is that we should be modelling the means and variances correctly and that will be fine provided the data, whether integer or not, exhibits the same form of quadratic mean-variance relationship that the NB distribution does.
References
Robinson, M., and Smyth, G. K. (2008). Small sample estimation of negative binomial dispersion, with applications to SAGE data. Biostatistics 9, 321-332.
Robinson, MD, and Smyth, GK (2007). Moderated statistical tests for assessing differences in tag abundance. Bioinformatics 23, 2881-2887.
McCarthy, DJ, Chen, Y, Smyth, GK (2012). Differential expression analysis of multifactor RNA-Seq experiments with respect to biological variation. Nucleic Acids Research 40, 4288-4297.
Chen, Y, Lun, ATL, and Smyth, GK (2014). Differential expression analysis of complex RNA-seq experiments using edgeR. In: Statistical Analysis of Next Generation Sequence Data, Somnath Datta and Daniel S Nettleton (eds), Springer, New York, pages 51--74. Preprint
Lun, ATL, Chen, Y, and Smyth, GK (2016). It's DE-licious: a recipe for differential expression analyses of RNA-seq experiments using quasi-likelihood methods in edgeR. Methods in Molecular Biology 1418, 391-416. Preprint
Chen Y, Lun ATL, and Smyth, GK (2016). From reads to genes to pathways: differential expression analysis of RNA-Seq experiments using Rsubread and the edgeR quasi-likelihood pipeline. F1000Research 5, 1438.
|
Continuous generalization of the negative binomial distribution
|
That's an interesting question. My research group has been using the distribution you refer to for some years in our publicly available bioinformatics software. As far as I know, the distribution does
|
Continuous generalization of the negative binomial distribution
That's an interesting question. My research group has been using the distribution you refer to for some years in our publicly available bioinformatics software. As far as I know, the distribution does not have a name and there is no literature on it. While the paper by Chandra et al (2012) cited by Aksakal is closely related, the distribution they consider seems to be restricted to integer values for $r$ and they don't seem to give an explicit expression for the pdf.
To give you some background, the NB distribution is very heavily used in genomic research to model gene expression data arising from RNA-seq and related technologies. The count data arises as the number of DNA or RNA sequence reads extracted from a biological sample that can be mapped to each gene. Typically there are tens of millions of reads from each biological sample that are mapped to about 25,000 genes. Alternatively one might have DNA samples from which reads are mapped to genomic windows. We and others have popularized an approach whereby NB glms are fitted to the sequence reads for each gene, and empirical Bayes methods are used to moderate the genewise dispersion estimators (dispersion $\phi=1/r$). This approach has been cited in tens of thousands of journal articles in the genomic literature, so you can get an idea of how much it gets used.
My group maintains the edgeR R sofware package. Some years ago we revised the whole package so that it works with fractional counts, using a continuous version of the NB pmf. We simply converted all the binomial coefficients in the NB pmf to ratios of gamma functions and used it as a (mixed) continuous pdf. The motivation for this was that sequence read counts can sometimes be fractional because of (1) ambiguous mapping of reads to the transcriptome or genome and/or (2) normalization of counts to correct for technical effects. So the counts are sometimes expected counts or estimated counts rather than observed counts. And of course the read counts can be exactly zero with positive probability. Our approach ensures that the inference results from our software are continuous in the counts, matching exactly with discrete NB results when the estimated counts happen to be integers.
As far as I know, there is no closed form for the normalizing constant in the pdf, nor are there closed forms for the mean or variance. When one considers that there is no closed form for the integral
$$\int_0^\infty \frac{1}{\Gamma(x)}dz$$
(the Fransen-Robinson constant) it is clear that there cannot be for the integral of the continuous NB pdf either.
However it seems to me that traditional mean and variance formulas for the NB should continue to be good approximations for the continuous NB. Moreover the normalizing constant should vary slowly with the parameters and therefore can be ignored as having negligible influence in the maximum likelihood calculations.
One can confirm these hypotheses by numerical integration. The NB distribution arises in bioinformatics as a gamma mixture of Poisson distributions (see the Wikipedia negative binomial article or McCarthy et al below).
The continuous NB distribution arises simply by replacing the Poisson distribution with its continuous analog with pdf
$$f(x;\lambda)=a(\lambda)\frac{e^{-\lambda}\lambda^x}{\Gamma(x+1)}$$
for $x\ge 0$ where $a(\lambda)$ is a normalizing constant to ensure the density integrates to 1.
Suppose for example that $\lambda=10$. The Poisson distribution has pmf equal the above pdf on the non-negative integers and, with $\lambda=10$, the Poisson mean and variance are equal to 10.
Numerical integration shows that $a(10)=1/0.999875$ and the mean and variance of the continuous distribution are equal to 10 to about 4 significant figures.
So the normalizing constant is virtually 1 and the mean and variance are almost exactly the same as for the discrete Poisson distribution.
The approximation is improved even more if we add a continuity correction, integrating from $-1/2$ to $\infty$ instead of from 0.
With the continuity correction, everything is correct (normalizing constant is 1 and moments agree with discrete Poisson) to about 6 figures.
In our edgeR package, we do not need to make any adjustment for the fact that there is mass at zero, because we always work with conditional log-likelihoods or with log-likelihood differences and any delta functions cancel out of the calculations. This is typical BTW for glms with mixed probability distributions. Alternatively, we could consider the distribution to have no mass at zero but to have support starting at -1/2 instead of at zero. Either theoretical perspective leads to the same calculations in practice.
Although we make active use of the continuous NB distribution, we haven't published anything on it explicitly. The articles cited below explain the NB approach to genomic data but don't discuss the continuous NB distribution explicitly.
In summary, I am not surprised that the article you are studying obtained reasonable results from a continualized version of the NB pdf, because that is our experience also. The key requirement is that we should be modelling the means and variances correctly and that will be fine provided the data, whether integer or not, exhibits the same form of quadratic mean-variance relationship that the NB distribution does.
References
Robinson, M., and Smyth, G. K. (2008). Small sample estimation of negative binomial dispersion, with applications to SAGE data. Biostatistics 9, 321-332.
Robinson, MD, and Smyth, GK (2007). Moderated statistical tests for assessing differences in tag abundance. Bioinformatics 23, 2881-2887.
McCarthy, DJ, Chen, Y, Smyth, GK (2012). Differential expression analysis of multifactor RNA-Seq experiments with respect to biological variation. Nucleic Acids Research 40, 4288-4297.
Chen, Y, Lun, ATL, and Smyth, GK (2014). Differential expression analysis of complex RNA-seq experiments using edgeR. In: Statistical Analysis of Next Generation Sequence Data, Somnath Datta and Daniel S Nettleton (eds), Springer, New York, pages 51--74. Preprint
Lun, ATL, Chen, Y, and Smyth, GK (2016). It's DE-licious: a recipe for differential expression analyses of RNA-seq experiments using quasi-likelihood methods in edgeR. Methods in Molecular Biology 1418, 391-416. Preprint
Chen Y, Lun ATL, and Smyth, GK (2016). From reads to genes to pathways: differential expression analysis of RNA-Seq experiments using Rsubread and the edgeR quasi-likelihood pipeline. F1000Research 5, 1438.
|
Continuous generalization of the negative binomial distribution
That's an interesting question. My research group has been using the distribution you refer to for some years in our publicly available bioinformatics software. As far as I know, the distribution does
|
9,872
|
Continuous generalization of the negative binomial distribution
|
Look at this paper: Chandra, Nimai Kumar, and Dilip Roy. A continuous version of the negative binomial distribution. Statistica 72, no. 1 (2012): 81.
It's defined in the paper as the survival function, which is a natural approach since neg binomial was introduced in reliability analysis:
$$S_r(x)=\begin{cases}q^x & \text{for}\ r=1 \\
\sum_{k=0}^{r-1}\binom {x+k-1}{k}p^kq^x & \text{for}\ r=2,3,\dots \end{cases}$$
where $q=e^{-\lambda},\lambda\ge 0,p+q=1$ and $r\in\mathbb N,r>0$.
|
Continuous generalization of the negative binomial distribution
|
Look at this paper: Chandra, Nimai Kumar, and Dilip Roy. A continuous version of the negative binomial distribution. Statistica 72, no. 1 (2012): 81.
It's defined in the paper as the survival functio
|
Continuous generalization of the negative binomial distribution
Look at this paper: Chandra, Nimai Kumar, and Dilip Roy. A continuous version of the negative binomial distribution. Statistica 72, no. 1 (2012): 81.
It's defined in the paper as the survival function, which is a natural approach since neg binomial was introduced in reliability analysis:
$$S_r(x)=\begin{cases}q^x & \text{for}\ r=1 \\
\sum_{k=0}^{r-1}\binom {x+k-1}{k}p^kq^x & \text{for}\ r=2,3,\dots \end{cases}$$
where $q=e^{-\lambda},\lambda\ge 0,p+q=1$ and $r\in\mathbb N,r>0$.
|
Continuous generalization of the negative binomial distribution
Look at this paper: Chandra, Nimai Kumar, and Dilip Roy. A continuous version of the negative binomial distribution. Statistica 72, no. 1 (2012): 81.
It's defined in the paper as the survival functio
|
9,873
|
Statistics and data mining software tools for dealing with large datasets
|
I'll second @suncoolsu comment: The dimensionality of your data set is not the only criterion that should orient you toward a specific software. For instance, if you're just planning to do unsupervised clustering or use PCA, there are several dedicated tools that cope with large data sets, as commonly encountered in genomic studies.
Now, R (64 bits) handles large data pretty well, and you still have the option to use disk storage instead of RAM access, but see CRAN Task View High-Performance and Parallel Computing with R. Standard GLM will easily accomodate 20,000 obs. (but see also speedglm) within reasonable time, as shown below:
> require(MASS)
> n <- 20000
> X <- mvrnorm(n, mu=c(0,0), Sigma=matrix(c(1,.8,.8,1), 2, 2))
> df <- cbind.data.frame(X, grp=gl(4, n/4), y=sample(c(0,1), n, rep=TRUE))
> system.time(glm(y ~ ., data=df))
user system elapsed
0.361 0.018 0.379
To give a more concrete illustration, I used R to process and analyse large genetic data (800 individuals x 800k SNPs, where the main statistical model was a stratified GLM with several covariates (2 min); that was made possible thanks to efficient R and C codes available in the snpMatrix package (in comparison, the same kind of model took about 8 min using a dedicated C++ software (plink). I also worked on a clinical study (12k patients x 50 variables of interest) and R fits my needs too. Finally, as far as I know, the lme4 package is the only software that allow to fit mixed-effects model with unbalanced and large data sets (as is the case in large-scale educational assessment).
Stata/SE is another software that can handle large data set. SAS and SPSS are file based software, so they will handle large volumes of data. A comparative review of software for datamining is available in Data Mining Tools: Which One is Best for CRM. For visualization, there are also plenty of options; maybe a good start is Graphics of large datasets: visualizing a million (reviewed in the JSS by P Murrell), and all related threads on this site.
|
Statistics and data mining software tools for dealing with large datasets
|
I'll second @suncoolsu comment: The dimensionality of your data set is not the only criterion that should orient you toward a specific software. For instance, if you're just planning to do unsupervise
|
Statistics and data mining software tools for dealing with large datasets
I'll second @suncoolsu comment: The dimensionality of your data set is not the only criterion that should orient you toward a specific software. For instance, if you're just planning to do unsupervised clustering or use PCA, there are several dedicated tools that cope with large data sets, as commonly encountered in genomic studies.
Now, R (64 bits) handles large data pretty well, and you still have the option to use disk storage instead of RAM access, but see CRAN Task View High-Performance and Parallel Computing with R. Standard GLM will easily accomodate 20,000 obs. (but see also speedglm) within reasonable time, as shown below:
> require(MASS)
> n <- 20000
> X <- mvrnorm(n, mu=c(0,0), Sigma=matrix(c(1,.8,.8,1), 2, 2))
> df <- cbind.data.frame(X, grp=gl(4, n/4), y=sample(c(0,1), n, rep=TRUE))
> system.time(glm(y ~ ., data=df))
user system elapsed
0.361 0.018 0.379
To give a more concrete illustration, I used R to process and analyse large genetic data (800 individuals x 800k SNPs, where the main statistical model was a stratified GLM with several covariates (2 min); that was made possible thanks to efficient R and C codes available in the snpMatrix package (in comparison, the same kind of model took about 8 min using a dedicated C++ software (plink). I also worked on a clinical study (12k patients x 50 variables of interest) and R fits my needs too. Finally, as far as I know, the lme4 package is the only software that allow to fit mixed-effects model with unbalanced and large data sets (as is the case in large-scale educational assessment).
Stata/SE is another software that can handle large data set. SAS and SPSS are file based software, so they will handle large volumes of data. A comparative review of software for datamining is available in Data Mining Tools: Which One is Best for CRM. For visualization, there are also plenty of options; maybe a good start is Graphics of large datasets: visualizing a million (reviewed in the JSS by P Murrell), and all related threads on this site.
|
Statistics and data mining software tools for dealing with large datasets
I'll second @suncoolsu comment: The dimensionality of your data set is not the only criterion that should orient you toward a specific software. For instance, if you're just planning to do unsupervise
|
9,874
|
Statistics and data mining software tools for dealing with large datasets
|
Most of the algorithms on Apache Mahout scale way beyond 20M records, even with high-dimensional data. If you only need to build a prediction model, there are specific tools like Vowpal Wabbit (http://hunch.net/~vw/) that can easily scale to billions of records on a single machine.
|
Statistics and data mining software tools for dealing with large datasets
|
Most of the algorithms on Apache Mahout scale way beyond 20M records, even with high-dimensional data. If you only need to build a prediction model, there are specific tools like Vowpal Wabbit (http:/
|
Statistics and data mining software tools for dealing with large datasets
Most of the algorithms on Apache Mahout scale way beyond 20M records, even with high-dimensional data. If you only need to build a prediction model, there are specific tools like Vowpal Wabbit (http://hunch.net/~vw/) that can easily scale to billions of records on a single machine.
|
Statistics and data mining software tools for dealing with large datasets
Most of the algorithms on Apache Mahout scale way beyond 20M records, even with high-dimensional data. If you only need to build a prediction model, there are specific tools like Vowpal Wabbit (http:/
|
9,875
|
Statistics and data mining software tools for dealing with large datasets
|
There is the RHIPE package (R-Hadoop integration). It is can make it very easy (with exceptions) to analyze large amounts of data in R.
|
Statistics and data mining software tools for dealing with large datasets
|
There is the RHIPE package (R-Hadoop integration). It is can make it very easy (with exceptions) to analyze large amounts of data in R.
|
Statistics and data mining software tools for dealing with large datasets
There is the RHIPE package (R-Hadoop integration). It is can make it very easy (with exceptions) to analyze large amounts of data in R.
|
Statistics and data mining software tools for dealing with large datasets
There is the RHIPE package (R-Hadoop integration). It is can make it very easy (with exceptions) to analyze large amounts of data in R.
|
9,876
|
Statistics and data mining software tools for dealing with large datasets
|
It is hard to give a good answer without knowing what kind of models you have in mind.
For linear regression, I have successfully used the biglm package in R.
|
Statistics and data mining software tools for dealing with large datasets
|
It is hard to give a good answer without knowing what kind of models you have in mind.
For linear regression, I have successfully used the biglm package in R.
|
Statistics and data mining software tools for dealing with large datasets
It is hard to give a good answer without knowing what kind of models you have in mind.
For linear regression, I have successfully used the biglm package in R.
|
Statistics and data mining software tools for dealing with large datasets
It is hard to give a good answer without knowing what kind of models you have in mind.
For linear regression, I have successfully used the biglm package in R.
|
9,877
|
Statistics and data mining software tools for dealing with large datasets
|
Since you are building predictive models from large datasets you might benefit from Google's BigQuery (a hosted version of the technology from Google's research paper on massive dataset analysis with Dremel). You can export the query results as CSV for ingestion into a predictive classifier, for example.
BigQuery has a WebUI that allows you to run queries and export results. The beta (v1) version of BigQuery featured a R client, and the production version (v2) will eventually have an R client as well.
|
Statistics and data mining software tools for dealing with large datasets
|
Since you are building predictive models from large datasets you might benefit from Google's BigQuery (a hosted version of the technology from Google's research paper on massive dataset analysis with
|
Statistics and data mining software tools for dealing with large datasets
Since you are building predictive models from large datasets you might benefit from Google's BigQuery (a hosted version of the technology from Google's research paper on massive dataset analysis with Dremel). You can export the query results as CSV for ingestion into a predictive classifier, for example.
BigQuery has a WebUI that allows you to run queries and export results. The beta (v1) version of BigQuery featured a R client, and the production version (v2) will eventually have an R client as well.
|
Statistics and data mining software tools for dealing with large datasets
Since you are building predictive models from large datasets you might benefit from Google's BigQuery (a hosted version of the technology from Google's research paper on massive dataset analysis with
|
9,878
|
Statistics and data mining software tools for dealing with large datasets
|
We trained 3.5M observations and 44 features using 64-bit R on an EC2 instance with 32GB ram and 4 cores. We used random forests and it worked well. Note that we had to preprocess/manipulate the data before training.
|
Statistics and data mining software tools for dealing with large datasets
|
We trained 3.5M observations and 44 features using 64-bit R on an EC2 instance with 32GB ram and 4 cores. We used random forests and it worked well. Note that we had to preprocess/manipulate the data
|
Statistics and data mining software tools for dealing with large datasets
We trained 3.5M observations and 44 features using 64-bit R on an EC2 instance with 32GB ram and 4 cores. We used random forests and it worked well. Note that we had to preprocess/manipulate the data before training.
|
Statistics and data mining software tools for dealing with large datasets
We trained 3.5M observations and 44 features using 64-bit R on an EC2 instance with 32GB ram and 4 cores. We used random forests and it worked well. Note that we had to preprocess/manipulate the data
|
9,879
|
Statistics and data mining software tools for dealing with large datasets
|
SAS Enterprise Miner version 6.2 would have no problem handling 20 million observations, and a variety of models which can be adapted to your situation. The issue with SAS is usually the cost however. Here's a summary of what SAS EM can do:
SAS EM 6.2: What's New
|
Statistics and data mining software tools for dealing with large datasets
|
SAS Enterprise Miner version 6.2 would have no problem handling 20 million observations, and a variety of models which can be adapted to your situation. The issue with SAS is usually the cost however.
|
Statistics and data mining software tools for dealing with large datasets
SAS Enterprise Miner version 6.2 would have no problem handling 20 million observations, and a variety of models which can be adapted to your situation. The issue with SAS is usually the cost however. Here's a summary of what SAS EM can do:
SAS EM 6.2: What's New
|
Statistics and data mining software tools for dealing with large datasets
SAS Enterprise Miner version 6.2 would have no problem handling 20 million observations, and a variety of models which can be adapted to your situation. The issue with SAS is usually the cost however.
|
9,880
|
Statistics and data mining software tools for dealing with large datasets
|
Can you look at ScaVis (http://jwork.org/scavis)? I did not look at 20M, but you may try to check it.
|
Statistics and data mining software tools for dealing with large datasets
|
Can you look at ScaVis (http://jwork.org/scavis)? I did not look at 20M, but you may try to check it.
|
Statistics and data mining software tools for dealing with large datasets
Can you look at ScaVis (http://jwork.org/scavis)? I did not look at 20M, but you may try to check it.
|
Statistics and data mining software tools for dealing with large datasets
Can you look at ScaVis (http://jwork.org/scavis)? I did not look at 20M, but you may try to check it.
|
9,881
|
Statistics and data mining software tools for dealing with large datasets
|
RHIPE is a great solution, and I would probably choose this one, if having this issue! but have you considered NCSS? As far as I know, the newest version 10 can build these models. The full ver. is very expensive, but on several remote desktop services you can run the app only for a small fee but I dunno.. rather check that out
|
Statistics and data mining software tools for dealing with large datasets
|
RHIPE is a great solution, and I would probably choose this one, if having this issue! but have you considered NCSS? As far as I know, the newest version 10 can build these models. The full ver. is ve
|
Statistics and data mining software tools for dealing with large datasets
RHIPE is a great solution, and I would probably choose this one, if having this issue! but have you considered NCSS? As far as I know, the newest version 10 can build these models. The full ver. is very expensive, but on several remote desktop services you can run the app only for a small fee but I dunno.. rather check that out
|
Statistics and data mining software tools for dealing with large datasets
RHIPE is a great solution, and I would probably choose this one, if having this issue! but have you considered NCSS? As far as I know, the newest version 10 can build these models. The full ver. is ve
|
9,882
|
What are alternatives to broken axes?
|
I am very wary of using logarithmic axes on bar graphs. The problem is that you have to choose a starting point of the axis, and this is almost always arbitrary. You can choose to make two bars have very different heights, or almost the same height, merely by changing the minimum value on the axis. These three graphs all plot the same data:
An alternative to discontinuous axes, that no one has mentioned yet,is to simply show a table of values. In many cases, tables are easier to understand than graphs.
|
What are alternatives to broken axes?
|
I am very wary of using logarithmic axes on bar graphs. The problem is that you have to choose a starting point of the axis, and this is almost always arbitrary. You can choose to make two bars have v
|
What are alternatives to broken axes?
I am very wary of using logarithmic axes on bar graphs. The problem is that you have to choose a starting point of the axis, and this is almost always arbitrary. You can choose to make two bars have very different heights, or almost the same height, merely by changing the minimum value on the axis. These three graphs all plot the same data:
An alternative to discontinuous axes, that no one has mentioned yet,is to simply show a table of values. In many cases, tables are easier to understand than graphs.
|
What are alternatives to broken axes?
I am very wary of using logarithmic axes on bar graphs. The problem is that you have to choose a starting point of the axis, and this is almost always arbitrary. You can choose to make two bars have v
|
9,883
|
What are alternatives to broken axes?
|
Some additional ideas:
(1) You needn't confine yourself to a logarithmic transformation. Search this site for the "data-transformation" tag, for example. Some data lend themselves well to certain transformations like a root or a logit. (Such transformations--even logs--are usually to be avoided when publishing graphics for a non-technical audience. On the other hand, they can be excellent tools for seeing patterns in data.)
(2) You can borrow a standard cartographic technique of insetting a detail of a chart within or next to your chart. Specifically, you would plot the extreme values by themselves on one chart and all (or the) rest of the data on another with a more limited axis range, then graphically arrange the two along with indications (visual and/or written) of the relationship between them. Think of a map of the US in which Alaska and Hawaii are inset at different scales. (This won't work with all kinds of charts, but could be effective with the bar charts in your illustration.) [I see this is similar to mbq's recent answer.]
(3) You can show the broken plot side-by-side with the same plot on unbroken axes.
(4) In the case of your bar chart example, choose a suitable (perhaps hugely stretched) vertical axis and provide a panning utility. [This is more of a trick than a genuinely useful technique, IMHO, but it might be useful in some special cases.]
(5) Select a different schema to display the data. Instead of a bar chart that uses length to represent values, choose a chart in which the areas of symbols represent the values, for example. [Obviously trade-offs are involved here.]
Your choice of technique will likely depend on the purpose of the plot: plots created for data exploration often differ from plots for general audiences, for example.
|
What are alternatives to broken axes?
|
Some additional ideas:
(1) You needn't confine yourself to a logarithmic transformation. Search this site for the "data-transformation" tag, for example. Some data lend themselves well to certain tr
|
What are alternatives to broken axes?
Some additional ideas:
(1) You needn't confine yourself to a logarithmic transformation. Search this site for the "data-transformation" tag, for example. Some data lend themselves well to certain transformations like a root or a logit. (Such transformations--even logs--are usually to be avoided when publishing graphics for a non-technical audience. On the other hand, they can be excellent tools for seeing patterns in data.)
(2) You can borrow a standard cartographic technique of insetting a detail of a chart within or next to your chart. Specifically, you would plot the extreme values by themselves on one chart and all (or the) rest of the data on another with a more limited axis range, then graphically arrange the two along with indications (visual and/or written) of the relationship between them. Think of a map of the US in which Alaska and Hawaii are inset at different scales. (This won't work with all kinds of charts, but could be effective with the bar charts in your illustration.) [I see this is similar to mbq's recent answer.]
(3) You can show the broken plot side-by-side with the same plot on unbroken axes.
(4) In the case of your bar chart example, choose a suitable (perhaps hugely stretched) vertical axis and provide a panning utility. [This is more of a trick than a genuinely useful technique, IMHO, but it might be useful in some special cases.]
(5) Select a different schema to display the data. Instead of a bar chart that uses length to represent values, choose a chart in which the areas of symbols represent the values, for example. [Obviously trade-offs are involved here.]
Your choice of technique will likely depend on the purpose of the plot: plots created for data exploration often differ from plots for general audiences, for example.
|
What are alternatives to broken axes?
Some additional ideas:
(1) You needn't confine yourself to a logarithmic transformation. Search this site for the "data-transformation" tag, for example. Some data lend themselves well to certain tr
|
9,884
|
What are alternatives to broken axes?
|
I'd separate the problem of log axes from the problem of bar charts.
Logarithmic axes IMHO are best suited for things that come or happen in multiples (... increased by a factor of 20 when treated with ...).
In that case, 1 = 10β° is the natural origin. There is a whole range of physical/chemical values which are in fact logarithmic, e.g. pH or absorbance $A = lg I_0 - lg I$, and which have "natural" origins. For A that would be $I_0$. For pH in aqeous solutions, e.g. 7.
Bar charts can never be sensible if there is no sensible and fixed origin which takes the role of a control (baseline, blank). But this doesn't have anything to do with the log axes.
The only regular use I have for bar charts are histograms. But I could imagine that they do well to show the difference to this origin (you also immediately see whether the difference is positive or negative). Because the bars depict an area, I tend to think of barcharts as a very discretized version of area under a curve. That is, the x-axis should have a metric meaning (which may be the case with time, but not with cities).
If I'd find myself wondering what origin to use for the log of something that had a "natural" origin at 0, I'd step back and think a bit about what is going on. Very often, such problems are just an indicator that the log is not a sensible transformation here.
Now a bar chart with log axes would emphasize increases or decreases that happen in multiples. Sensible examples that I can think of right now all have some linear relationship to a value of interest. But maybe someone else finds a good example.
So I think the data transformation should be sensible with respect to the meaning of the data at hand. This is the case with the physico-chemical units I mentioned above (A is proportional to concentrations, and pH has, for example, a linear relationship to the voltage in a pH-meter). In fact, it is so much the case, that the log unit gets a new name, and is used in a linear way.
Last, but not least, I come from vibrational spectroscopy, where broken axes are quite regularly used. And I consider this use one of the few examples where the breaking of the axes isn't deceiving.
However, we don't have changes in the order of magnitude. We just have an uninformative region of 30 - 40 % of our x range: Here's an example:
For this sample, the part between 1800 - 2800 /cm cannot contain any useful information.
The uninformative spectral range is therefore removed (which also indicates the spectral ranges we actually use for chemometric modeling):
But for the interpretation of the data, we need precise readings of the x-position. But generally we do not need multiples that span the different ranges (i.e. there are such relations, but most connections are more complicated. E.g.: Signal at 3050/cm, so we have unsaturated or aromatic substance. But no strong signal at 1000/cm, so no mono, meta, nor 1,3,5-substituted aromatic ring ...)
So it is better to depict x with a larger scale (actually we often use millimeter-sheet like guides or label the exact locations). So, we break the axis, and get a larger x scaling:
Actually, it is very much like facetting:
but the broken axis IMHO emphasizes that the scale of the x-axis in both parts is the same. I.e. Intervals within the plotted regions are the same.
To emphasize small intensities (y-axis), we use magnified insets:
[... For details, see the magnified (x 20) Ξ½CH region in blue ....]
And this is certainly possible with the example in the linked plots as well.
|
What are alternatives to broken axes?
|
I'd separate the problem of log axes from the problem of bar charts.
Logarithmic axes IMHO are best suited for things that come or happen in multiples (... increased by a factor of 20 when treated wit
|
What are alternatives to broken axes?
I'd separate the problem of log axes from the problem of bar charts.
Logarithmic axes IMHO are best suited for things that come or happen in multiples (... increased by a factor of 20 when treated with ...).
In that case, 1 = 10β° is the natural origin. There is a whole range of physical/chemical values which are in fact logarithmic, e.g. pH or absorbance $A = lg I_0 - lg I$, and which have "natural" origins. For A that would be $I_0$. For pH in aqeous solutions, e.g. 7.
Bar charts can never be sensible if there is no sensible and fixed origin which takes the role of a control (baseline, blank). But this doesn't have anything to do with the log axes.
The only regular use I have for bar charts are histograms. But I could imagine that they do well to show the difference to this origin (you also immediately see whether the difference is positive or negative). Because the bars depict an area, I tend to think of barcharts as a very discretized version of area under a curve. That is, the x-axis should have a metric meaning (which may be the case with time, but not with cities).
If I'd find myself wondering what origin to use for the log of something that had a "natural" origin at 0, I'd step back and think a bit about what is going on. Very often, such problems are just an indicator that the log is not a sensible transformation here.
Now a bar chart with log axes would emphasize increases or decreases that happen in multiples. Sensible examples that I can think of right now all have some linear relationship to a value of interest. But maybe someone else finds a good example.
So I think the data transformation should be sensible with respect to the meaning of the data at hand. This is the case with the physico-chemical units I mentioned above (A is proportional to concentrations, and pH has, for example, a linear relationship to the voltage in a pH-meter). In fact, it is so much the case, that the log unit gets a new name, and is used in a linear way.
Last, but not least, I come from vibrational spectroscopy, where broken axes are quite regularly used. And I consider this use one of the few examples where the breaking of the axes isn't deceiving.
However, we don't have changes in the order of magnitude. We just have an uninformative region of 30 - 40 % of our x range: Here's an example:
For this sample, the part between 1800 - 2800 /cm cannot contain any useful information.
The uninformative spectral range is therefore removed (which also indicates the spectral ranges we actually use for chemometric modeling):
But for the interpretation of the data, we need precise readings of the x-position. But generally we do not need multiples that span the different ranges (i.e. there are such relations, but most connections are more complicated. E.g.: Signal at 3050/cm, so we have unsaturated or aromatic substance. But no strong signal at 1000/cm, so no mono, meta, nor 1,3,5-substituted aromatic ring ...)
So it is better to depict x with a larger scale (actually we often use millimeter-sheet like guides or label the exact locations). So, we break the axis, and get a larger x scaling:
Actually, it is very much like facetting:
but the broken axis IMHO emphasizes that the scale of the x-axis in both parts is the same. I.e. Intervals within the plotted regions are the same.
To emphasize small intensities (y-axis), we use magnified insets:
[... For details, see the magnified (x 20) Ξ½CH region in blue ....]
And this is certainly possible with the example in the linked plots as well.
|
What are alternatives to broken axes?
I'd separate the problem of log axes from the problem of bar charts.
Logarithmic axes IMHO are best suited for things that come or happen in multiples (... increased by a factor of 20 when treated wit
|
9,885
|
What are alternatives to broken axes?
|
Maybe it can be classified as lattice, but I'll try; plot all the bars scaled to the highest in one panel and put another panel showing zoom on lower ones. I used this technique once in case of a scatterplot, and the result was quite nice.
|
What are alternatives to broken axes?
|
Maybe it can be classified as lattice, but I'll try; plot all the bars scaled to the highest in one panel and put another panel showing zoom on lower ones. I used this technique once in case of a scat
|
What are alternatives to broken axes?
Maybe it can be classified as lattice, but I'll try; plot all the bars scaled to the highest in one panel and put another panel showing zoom on lower ones. I used this technique once in case of a scatterplot, and the result was quite nice.
|
What are alternatives to broken axes?
Maybe it can be classified as lattice, but I'll try; plot all the bars scaled to the highest in one panel and put another panel showing zoom on lower ones. I used this technique once in case of a scat
|
9,886
|
What are alternatives to broken axes?
|
Two ideas that were alluded to, but not explicitly described in when I looked at the excellent answers and comments were that you are using a bar chart "in a manner inconsistent with labelling" and normalized/dimensionless data.
Plot type:
The star/spider/radar-style chart (link)(link) is often very good for comparing several different things along multiple coordinates. There are a number of very useful plots that (sadly) are rare in business presentations, likely because leadership prefers to use conclusions to make decisions rather than using information to get understanding and then use the understanding to make the decisions. In business it is sometimes very difficult to build consensus and so the results-only approach can have higher yield in a consensus-first, decision-next environment. This informs the popularity of the bar/column chart. Please consider the examples of other graph types that are good for gaining understanding (link).
Transformation:
If you divide the values that you are charting by a "characteristic" value then you can transform the scaling to improve readability without losing information. Fluid Dynamicists prefer dimensionless numbers because of their predictive utility and their elasticity in application. They look at things like the Buckingham Pi Theorem as sources for candidate dimensionless forms (link). Popular, and useful, dimensionless numbers include Reynolds Number, Mach number, Biot number, Grashof number, Pi, Raleigh number, Stokes number, and Sherwood number. (link) You don't have to be a physicist to love dimensionless numbers because they are useful in non-physics applications. Measures like density, homogeneity, circularity, and coplanarity can define images, pixel fields, or multivariate probability distributions. Don't just consider taking a logarithm, or a relative distance from a known value - you can also consider inverting the numbers, taking their square roots.
Best of luck. Please let us know how things turn out.
|
What are alternatives to broken axes?
|
Two ideas that were alluded to, but not explicitly described in when I looked at the excellent answers and comments were that you are using a bar chart "in a manner inconsistent with labelling" and
|
What are alternatives to broken axes?
Two ideas that were alluded to, but not explicitly described in when I looked at the excellent answers and comments were that you are using a bar chart "in a manner inconsistent with labelling" and normalized/dimensionless data.
Plot type:
The star/spider/radar-style chart (link)(link) is often very good for comparing several different things along multiple coordinates. There are a number of very useful plots that (sadly) are rare in business presentations, likely because leadership prefers to use conclusions to make decisions rather than using information to get understanding and then use the understanding to make the decisions. In business it is sometimes very difficult to build consensus and so the results-only approach can have higher yield in a consensus-first, decision-next environment. This informs the popularity of the bar/column chart. Please consider the examples of other graph types that are good for gaining understanding (link).
Transformation:
If you divide the values that you are charting by a "characteristic" value then you can transform the scaling to improve readability without losing information. Fluid Dynamicists prefer dimensionless numbers because of their predictive utility and their elasticity in application. They look at things like the Buckingham Pi Theorem as sources for candidate dimensionless forms (link). Popular, and useful, dimensionless numbers include Reynolds Number, Mach number, Biot number, Grashof number, Pi, Raleigh number, Stokes number, and Sherwood number. (link) You don't have to be a physicist to love dimensionless numbers because they are useful in non-physics applications. Measures like density, homogeneity, circularity, and coplanarity can define images, pixel fields, or multivariate probability distributions. Don't just consider taking a logarithm, or a relative distance from a known value - you can also consider inverting the numbers, taking their square roots.
Best of luck. Please let us know how things turn out.
|
What are alternatives to broken axes?
Two ideas that were alluded to, but not explicitly described in when I looked at the excellent answers and comments were that you are using a bar chart "in a manner inconsistent with labelling" and
|
9,887
|
What are alternatives to broken axes?
|
The broken-axis solution works best when there is a clear break right across the plot and the ordinate is labeled so that the gap is obvious. The advantage of this is that the scale is preserved across the two sets of values. Panel plots with different scales may not convey the relative variation within the low and high groups. I do like the idea of the zoom-in plot, which I programmed for scatterplots but hadn't thought of using for bar plots.
|
What are alternatives to broken axes?
|
The broken-axis solution works best when there is a clear break right across the plot and the ordinate is labeled so that the gap is obvious. The advantage of this is that the scale is preserved acros
|
What are alternatives to broken axes?
The broken-axis solution works best when there is a clear break right across the plot and the ordinate is labeled so that the gap is obvious. The advantage of this is that the scale is preserved across the two sets of values. Panel plots with different scales may not convey the relative variation within the low and high groups. I do like the idea of the zoom-in plot, which I programmed for scatterplots but hadn't thought of using for bar plots.
|
What are alternatives to broken axes?
The broken-axis solution works best when there is a clear break right across the plot and the ordinate is labeled so that the gap is obvious. The advantage of this is that the scale is preserved acros
|
9,888
|
Why use Monte Carlo method instead of a simple grid?
|
I found chapter 1 and 2 of these lecture notes helpful when I asked the same question myself a few years ago. A short summary: A grid with $N$ points in 20 dimensional space will demand $N^{20}$ function evaluations. That is a lot. By using Monte Carlo simulation, we dodge the curse of dimensionality to some extent. The convergence of a Monte Carlo simulation is $O(N^{-1/2})$ which is, albeit pretty slow, dimensionally independent.
|
Why use Monte Carlo method instead of a simple grid?
|
I found chapter 1 and 2 of these lecture notes helpful when I asked the same question myself a few years ago. A short summary: A grid with $N$ points in 20 dimensional space will demand $N^{20}$ funct
|
Why use Monte Carlo method instead of a simple grid?
I found chapter 1 and 2 of these lecture notes helpful when I asked the same question myself a few years ago. A short summary: A grid with $N$ points in 20 dimensional space will demand $N^{20}$ function evaluations. That is a lot. By using Monte Carlo simulation, we dodge the curse of dimensionality to some extent. The convergence of a Monte Carlo simulation is $O(N^{-1/2})$ which is, albeit pretty slow, dimensionally independent.
|
Why use Monte Carlo method instead of a simple grid?
I found chapter 1 and 2 of these lecture notes helpful when I asked the same question myself a few years ago. A short summary: A grid with $N$ points in 20 dimensional space will demand $N^{20}$ funct
|
9,889
|
Why use Monte Carlo method instead of a simple grid?
|
Sure it does; however it comes with much larger CPU usage. The problem increases especially in many dimensions, where grids become effectively unusable.
|
Why use Monte Carlo method instead of a simple grid?
|
Sure it does; however it comes with much larger CPU usage. The problem increases especially in many dimensions, where grids become effectively unusable.
|
Why use Monte Carlo method instead of a simple grid?
Sure it does; however it comes with much larger CPU usage. The problem increases especially in many dimensions, where grids become effectively unusable.
|
Why use Monte Carlo method instead of a simple grid?
Sure it does; however it comes with much larger CPU usage. The problem increases especially in many dimensions, where grids become effectively unusable.
|
9,890
|
Why use Monte Carlo method instead of a simple grid?
|
Previous comments are right in that simulation is easier to use in multidimensional problems. However, there are ways to address your concern - take a look at http://en.wikipedia.org/wiki/Halton_sequence and
http://en.wikipedia.org/wiki/Sparse_grid.
|
Why use Monte Carlo method instead of a simple grid?
|
Previous comments are right in that simulation is easier to use in multidimensional problems. However, there are ways to address your concern - take a look at http://en.wikipedia.org/wiki/Halton_seque
|
Why use Monte Carlo method instead of a simple grid?
Previous comments are right in that simulation is easier to use in multidimensional problems. However, there are ways to address your concern - take a look at http://en.wikipedia.org/wiki/Halton_sequence and
http://en.wikipedia.org/wiki/Sparse_grid.
|
Why use Monte Carlo method instead of a simple grid?
Previous comments are right in that simulation is easier to use in multidimensional problems. However, there are ways to address your concern - take a look at http://en.wikipedia.org/wiki/Halton_seque
|
9,891
|
Why use Monte Carlo method instead of a simple grid?
|
While one typically things of rejection sampling when considering Monte Carlo, Markov Chain Monte Carlo allows one to explore a multi-dimensional parameter space more efficiently than with a grid (or rejection sampling for that matter). How MCMC can be used for integration is clearly stated in this tutorial- http://bioinformatics.med.utah.edu/~alun/teach/stats/week09.pdf
|
Why use Monte Carlo method instead of a simple grid?
|
While one typically things of rejection sampling when considering Monte Carlo, Markov Chain Monte Carlo allows one to explore a multi-dimensional parameter space more efficiently than with a grid (or
|
Why use Monte Carlo method instead of a simple grid?
While one typically things of rejection sampling when considering Monte Carlo, Markov Chain Monte Carlo allows one to explore a multi-dimensional parameter space more efficiently than with a grid (or rejection sampling for that matter). How MCMC can be used for integration is clearly stated in this tutorial- http://bioinformatics.med.utah.edu/~alun/teach/stats/week09.pdf
|
Why use Monte Carlo method instead of a simple grid?
While one typically things of rejection sampling when considering Monte Carlo, Markov Chain Monte Carlo allows one to explore a multi-dimensional parameter space more efficiently than with a grid (or
|
9,892
|
Why use Monte Carlo method instead of a simple grid?
|
Two things -
Faster convergence by avoiding curse of dimensionality. Because most points in a grid lie on the same hyper plane without contributing significantly extra information. Random points fill the N-dimensional space evenly. LDS is even better.
Sometimes for Monte carlo methods we need statistically random points in no particular order. An ordered sequence of grid points will result in poor statistical properties.
|
Why use Monte Carlo method instead of a simple grid?
|
Two things -
Faster convergence by avoiding curse of dimensionality. Because most points in a grid lie on the same hyper plane without contributing significantly extra information. Random points fil
|
Why use Monte Carlo method instead of a simple grid?
Two things -
Faster convergence by avoiding curse of dimensionality. Because most points in a grid lie on the same hyper plane without contributing significantly extra information. Random points fill the N-dimensional space evenly. LDS is even better.
Sometimes for Monte carlo methods we need statistically random points in no particular order. An ordered sequence of grid points will result in poor statistical properties.
|
Why use Monte Carlo method instead of a simple grid?
Two things -
Faster convergence by avoiding curse of dimensionality. Because most points in a grid lie on the same hyper plane without contributing significantly extra information. Random points fil
|
9,893
|
How to calculate the p-value of parameters for ARIMA model in R?
|
The "t value" is the ratio of the coefficient to the standard error. The degrees of freedom (ndf) would be the number of observations minus the max order of difference in the model minus the number of estimated coefficients. The "F value " would be the square of the "t value" In order to exactly compute probability you would have to call a non-central chi-square function and pass in the F value and the degrees of freedom (1,ndf) or perhaps simply call an F function lookup.
|
How to calculate the p-value of parameters for ARIMA model in R?
|
The "t value" is the ratio of the coefficient to the standard error. The degrees of freedom (ndf) would be the number of observations minus the max order of difference in the model minus the number of
|
How to calculate the p-value of parameters for ARIMA model in R?
The "t value" is the ratio of the coefficient to the standard error. The degrees of freedom (ndf) would be the number of observations minus the max order of difference in the model minus the number of estimated coefficients. The "F value " would be the square of the "t value" In order to exactly compute probability you would have to call a non-central chi-square function and pass in the F value and the degrees of freedom (1,ndf) or perhaps simply call an F function lookup.
|
How to calculate the p-value of parameters for ARIMA model in R?
The "t value" is the ratio of the coefficient to the standard error. The degrees of freedom (ndf) would be the number of observations minus the max order of difference in the model minus the number of
|
9,894
|
How to calculate the p-value of parameters for ARIMA model in R?
|
Since arima uses maximum likelihood for estimation, the coefficients are assymptoticaly normal. Hence divide coefficients by their standard errors to get the z-statistics and then calculate p-values. Here is the example with in R with the first example from arima help page:
> aa <- arima(lh, order = c(1,0,0))
> aa
Call:
arima(x = lh, order = c(1, 0, 0))
Coefficients:
ar1 intercept
0.5739 2.4133
s.e. 0.1161 0.1466
sigma^2 estimated as 0.1975: log likelihood = -29.38, aic = 64.76
> (1-pnorm(abs(aa$coef)/sqrt(diag(aa$var.coef))))*2
ar1 intercept
1.935776e-07 0.000000e+00
The last line gives the p-values.
|
How to calculate the p-value of parameters for ARIMA model in R?
|
Since arima uses maximum likelihood for estimation, the coefficients are assymptoticaly normal. Hence divide coefficients by their standard errors to get the z-statistics and then calculate p-values.
|
How to calculate the p-value of parameters for ARIMA model in R?
Since arima uses maximum likelihood for estimation, the coefficients are assymptoticaly normal. Hence divide coefficients by their standard errors to get the z-statistics and then calculate p-values. Here is the example with in R with the first example from arima help page:
> aa <- arima(lh, order = c(1,0,0))
> aa
Call:
arima(x = lh, order = c(1, 0, 0))
Coefficients:
ar1 intercept
0.5739 2.4133
s.e. 0.1161 0.1466
sigma^2 estimated as 0.1975: log likelihood = -29.38, aic = 64.76
> (1-pnorm(abs(aa$coef)/sqrt(diag(aa$var.coef))))*2
ar1 intercept
1.935776e-07 0.000000e+00
The last line gives the p-values.
|
How to calculate the p-value of parameters for ARIMA model in R?
Since arima uses maximum likelihood for estimation, the coefficients are assymptoticaly normal. Hence divide coefficients by their standard errors to get the z-statistics and then calculate p-values.
|
9,895
|
How to calculate the p-value of parameters for ARIMA model in R?
|
You could also use coeftest from lmtestpackage:
> aa <- arima(lh, order = c(1,0,0))
> coeftest(aa)
z test of coefficients:
Estimate Std. Error z value Pr(>|z|)
ar1 0.57393 0.11614 4.9417 7.743e-07 ***
intercept 2.41329 0.14661 16.4602 < 2.2e-16 ***
---
Signif. codes: 0 β***β 0.001 β**β 0.01 β*β 0.05 β.β 0.1 β β 1
|
How to calculate the p-value of parameters for ARIMA model in R?
|
You could also use coeftest from lmtestpackage:
> aa <- arima(lh, order = c(1,0,0))
> coeftest(aa)
z test of coefficients:
Estimate Std. Error z value Pr(>|z|)
ar1 0.57393
|
How to calculate the p-value of parameters for ARIMA model in R?
You could also use coeftest from lmtestpackage:
> aa <- arima(lh, order = c(1,0,0))
> coeftest(aa)
z test of coefficients:
Estimate Std. Error z value Pr(>|z|)
ar1 0.57393 0.11614 4.9417 7.743e-07 ***
intercept 2.41329 0.14661 16.4602 < 2.2e-16 ***
---
Signif. codes: 0 β***β 0.001 β**β 0.01 β*β 0.05 β.β 0.1 β β 1
|
How to calculate the p-value of parameters for ARIMA model in R?
You could also use coeftest from lmtestpackage:
> aa <- arima(lh, order = c(1,0,0))
> coeftest(aa)
z test of coefficients:
Estimate Std. Error z value Pr(>|z|)
ar1 0.57393
|
9,896
|
Inference after using Lasso for variable selection
|
To add to the previous responses. You should definitely check out the recent work by Tibshirani and colleagues. They have developed a rigorous framework for inferring selection-corrected p-values and confidence intervals for lasso-type methods and also provide an R-package.
See:
Lee, Jason D., et al. "Exact post-selection inference, with application to the lasso." The Annals of Statistics 44.3 (2016): 907-927.
(https://projecteuclid.org/euclid.aos/1460381681)
Taylor, Jonathan, and Robert J. Tibshirani. "Statistical learning and selective inference." Proceedings of the National Academy of Sciences 112.25 (2015): 7629-7634.
R-package:
https://cran.r-project.org/web/packages/selectiveInference/index.html
|
Inference after using Lasso for variable selection
|
To add to the previous responses. You should definitely check out the recent work by Tibshirani and colleagues. They have developed a rigorous framework for inferring selection-corrected p-values and
|
Inference after using Lasso for variable selection
To add to the previous responses. You should definitely check out the recent work by Tibshirani and colleagues. They have developed a rigorous framework for inferring selection-corrected p-values and confidence intervals for lasso-type methods and also provide an R-package.
See:
Lee, Jason D., et al. "Exact post-selection inference, with application to the lasso." The Annals of Statistics 44.3 (2016): 907-927.
(https://projecteuclid.org/euclid.aos/1460381681)
Taylor, Jonathan, and Robert J. Tibshirani. "Statistical learning and selective inference." Proceedings of the National Academy of Sciences 112.25 (2015): 7629-7634.
R-package:
https://cran.r-project.org/web/packages/selectiveInference/index.html
|
Inference after using Lasso for variable selection
To add to the previous responses. You should definitely check out the recent work by Tibshirani and colleagues. They have developed a rigorous framework for inferring selection-corrected p-values and
|
9,897
|
Inference after using Lasso for variable selection
|
Generally, refitting using no penalty after having done variable selection via the Lasso is considered "cheating" since you have already looked at the data and the resulting p-values and confidence intervals are not valid in the usual sense.
This very recent paper looks at exactly what you want to do, and explains conditions under which fitting a lasso, choosing the important variables, and refitting without lasso penalty leads to valid $p$-values and confidence intervals. Their intuitive reasoning is that
the set of variables selected by the lasso is deterministic and
non-data dependent with high probability.
Thus, peeking at the data twice is not a problem. You will need to see if for your problem the conditions stated in the paper hold or not.
(There are a lot of useful references in the paper as well)
Reference:
Zhao, S., Shojaie, A., & Witten, D. (2017). In defense of the indefensible: A very naive approach to high-dimensional inference. Retrieved from: https://arxiv.org/pdf/1705.05543.pdf
|
Inference after using Lasso for variable selection
|
Generally, refitting using no penalty after having done variable selection via the Lasso is considered "cheating" since you have already looked at the data and the resulting p-values and confidence in
|
Inference after using Lasso for variable selection
Generally, refitting using no penalty after having done variable selection via the Lasso is considered "cheating" since you have already looked at the data and the resulting p-values and confidence intervals are not valid in the usual sense.
This very recent paper looks at exactly what you want to do, and explains conditions under which fitting a lasso, choosing the important variables, and refitting without lasso penalty leads to valid $p$-values and confidence intervals. Their intuitive reasoning is that
the set of variables selected by the lasso is deterministic and
non-data dependent with high probability.
Thus, peeking at the data twice is not a problem. You will need to see if for your problem the conditions stated in the paper hold or not.
(There are a lot of useful references in the paper as well)
Reference:
Zhao, S., Shojaie, A., & Witten, D. (2017). In defense of the indefensible: A very naive approach to high-dimensional inference. Retrieved from: https://arxiv.org/pdf/1705.05543.pdf
|
Inference after using Lasso for variable selection
Generally, refitting using no penalty after having done variable selection via the Lasso is considered "cheating" since you have already looked at the data and the resulting p-values and confidence in
|
9,898
|
Inference after using Lasso for variable selection
|
I wanted to add some papers from the orthogonal/double machine learning literature that is becoming popular in the Applied Econometrics literature.
Belloni, Alexandre, Victor Chernozhukov, and Christian Hansen. "Inference on treatment effects after selection among high-dimensional controls." The Review of Economic Studies 81.2 (2014): 608-650.
This paper addresses the theoretical properties of an OLS estimate of the effect of a variable after selecting the "other" controls using LASSO.
Victor Chernozhukov, Denis Chetverikov, Mert Demirer, Esther Duflo, Christian Hansen, Whitney Newey, James Robins, Double/debiased machine learning for treatment and structural parameters, The Econometrics Journal, Volume 21, Issue 1, 1 February 2018, Pages C1βC68, https://doi.org/10.1111/ectj.12097
This develops the comprehensive theory for using a number of non-parametric methods (ML algorithms) to non-linearly control for a high-dimensional nuisance parameter (confounders) and then study the impact of a specific covariate on the outcome. They deal with partially-linear frameworks and completely parametric frameworks. They also consider situations where the variable of interest is confounded.
|
Inference after using Lasso for variable selection
|
I wanted to add some papers from the orthogonal/double machine learning literature that is becoming popular in the Applied Econometrics literature.
Belloni, Alexandre, Victor Chernozhukov, and Christ
|
Inference after using Lasso for variable selection
I wanted to add some papers from the orthogonal/double machine learning literature that is becoming popular in the Applied Econometrics literature.
Belloni, Alexandre, Victor Chernozhukov, and Christian Hansen. "Inference on treatment effects after selection among high-dimensional controls." The Review of Economic Studies 81.2 (2014): 608-650.
This paper addresses the theoretical properties of an OLS estimate of the effect of a variable after selecting the "other" controls using LASSO.
Victor Chernozhukov, Denis Chetverikov, Mert Demirer, Esther Duflo, Christian Hansen, Whitney Newey, James Robins, Double/debiased machine learning for treatment and structural parameters, The Econometrics Journal, Volume 21, Issue 1, 1 February 2018, Pages C1βC68, https://doi.org/10.1111/ectj.12097
This develops the comprehensive theory for using a number of non-parametric methods (ML algorithms) to non-linearly control for a high-dimensional nuisance parameter (confounders) and then study the impact of a specific covariate on the outcome. They deal with partially-linear frameworks and completely parametric frameworks. They also consider situations where the variable of interest is confounded.
|
Inference after using Lasso for variable selection
I wanted to add some papers from the orthogonal/double machine learning literature that is becoming popular in the Applied Econometrics literature.
Belloni, Alexandre, Victor Chernozhukov, and Christ
|
9,899
|
Difference between regression analysis and analysis of variance?
|
Suppose your data set consists of a set $(x_i,y_i)$ for $i=1,\ldots,n$ and you want to look at the dependence of $y$ on $x$.
Suppose you find the values $\hat\alpha$ and $\hat\beta$ of $\alpha$ and $\beta$ that minimize the residual sum of squares
$$
\sum_{i=1}^n (y_i - (\alpha+\beta x_i))^2.
$$
Then you take $\hat y = \hat\alpha+ \hat\beta x$ to be the predicted $y$-value for any (not necessarily already observed) $x$-value. That's linear regression.
Now consider decomposing the total sum of squares
$$
\sum_{i=1}^n (y_i - \bar y)^2 \qquad\text{where }\bar y = \frac{y_1+\cdots+y_n}{n}
$$
with $n-1$ degrees of freedom, into "explained" and "unexplained" parts:
$$
\underbrace{\sum_{i=1}^n ((\hat\alpha+\hat\beta x_i) - \bar y)^2}_{\text{explained}}\ +\ \underbrace{\sum_{i=1}^n (y_i - (\hat\alpha+\hat\beta x_i))^2}_{\text{unexplained}}.
$$
with $1$ and $n-2$ degrees of freedom, respectively. That's analysis of variance, and one then considers things like F-statistics
$$
F = \frac{\sum_{i=1}^n ((\hat\alpha+\hat\beta x_i) - \bar y)^2/1}{\sum_{i=1}^n (y_i - (\hat\alpha+\hat\beta x_i))^2/(n-2)}.
$$
This F-statistic tests the null hypothesis $\beta=0$.
One often first encounters the term "analysis of variance" when the predictor is categorical, so that you're fitting the model
$$
y = \alpha + \beta_i
$$
where $i$ identifies which category is the value of the predictor. If there are $k$ categories, you'd get $k-1$ degrees of freedom in the numerator in the F-statistic, and usually $n-k$ degrees of freedom in the denominator. But the distinction between regression and analysis of variance is still the same for this kind of model.
A couple of additional points:
To some mathematicians, the account above may make it appear that the whole field is only what is seen above, so it may seem mysterious that both regression and analysis of variance are active research areas. There is much that won't fit into an answer appropriate for posting here.
There is a popular and tempting mistake, which is that it's called "linear" because the graph of $y=\alpha+\beta x$ is a line. That is false. One of my earlier answers explains why it's still called "linear regression" when you're fitting a polynomial via least squares.
|
Difference between regression analysis and analysis of variance?
|
Suppose your data set consists of a set $(x_i,y_i)$ for $i=1,\ldots,n$ and you want to look at the dependence of $y$ on $x$.
Suppose you find the values $\hat\alpha$ and $\hat\beta$ of $\alpha$ and $\
|
Difference between regression analysis and analysis of variance?
Suppose your data set consists of a set $(x_i,y_i)$ for $i=1,\ldots,n$ and you want to look at the dependence of $y$ on $x$.
Suppose you find the values $\hat\alpha$ and $\hat\beta$ of $\alpha$ and $\beta$ that minimize the residual sum of squares
$$
\sum_{i=1}^n (y_i - (\alpha+\beta x_i))^2.
$$
Then you take $\hat y = \hat\alpha+ \hat\beta x$ to be the predicted $y$-value for any (not necessarily already observed) $x$-value. That's linear regression.
Now consider decomposing the total sum of squares
$$
\sum_{i=1}^n (y_i - \bar y)^2 \qquad\text{where }\bar y = \frac{y_1+\cdots+y_n}{n}
$$
with $n-1$ degrees of freedom, into "explained" and "unexplained" parts:
$$
\underbrace{\sum_{i=1}^n ((\hat\alpha+\hat\beta x_i) - \bar y)^2}_{\text{explained}}\ +\ \underbrace{\sum_{i=1}^n (y_i - (\hat\alpha+\hat\beta x_i))^2}_{\text{unexplained}}.
$$
with $1$ and $n-2$ degrees of freedom, respectively. That's analysis of variance, and one then considers things like F-statistics
$$
F = \frac{\sum_{i=1}^n ((\hat\alpha+\hat\beta x_i) - \bar y)^2/1}{\sum_{i=1}^n (y_i - (\hat\alpha+\hat\beta x_i))^2/(n-2)}.
$$
This F-statistic tests the null hypothesis $\beta=0$.
One often first encounters the term "analysis of variance" when the predictor is categorical, so that you're fitting the model
$$
y = \alpha + \beta_i
$$
where $i$ identifies which category is the value of the predictor. If there are $k$ categories, you'd get $k-1$ degrees of freedom in the numerator in the F-statistic, and usually $n-k$ degrees of freedom in the denominator. But the distinction between regression and analysis of variance is still the same for this kind of model.
A couple of additional points:
To some mathematicians, the account above may make it appear that the whole field is only what is seen above, so it may seem mysterious that both regression and analysis of variance are active research areas. There is much that won't fit into an answer appropriate for posting here.
There is a popular and tempting mistake, which is that it's called "linear" because the graph of $y=\alpha+\beta x$ is a line. That is false. One of my earlier answers explains why it's still called "linear regression" when you're fitting a polynomial via least squares.
|
Difference between regression analysis and analysis of variance?
Suppose your data set consists of a set $(x_i,y_i)$ for $i=1,\ldots,n$ and you want to look at the dependence of $y$ on $x$.
Suppose you find the values $\hat\alpha$ and $\hat\beta$ of $\alpha$ and $\
|
9,900
|
Difference between regression analysis and analysis of variance?
|
The main difference is the response variable. While logistic regression deals with a binary response in linear regression analysis and also nonlinear regression the response variable is continuous. You have a variable(s) (aka covariate(s)) that have a functional relationship to the continuous response variable. In the analysis of variance the response is continuous but belongs to a few different categories (e.g. treatment group and control group). In the analysis of variance you look for difference in the mean response between groups. In linear regression you look at how the response changes as the covariates change. Another way to look at the difference is to say that in regression the covariates are continuous whereas in analysis of variance they are a discrete set of groups.
|
Difference between regression analysis and analysis of variance?
|
The main difference is the response variable. While logistic regression deals with a binary response in linear regression analysis and also nonlinear regression the response variable is continuous. Y
|
Difference between regression analysis and analysis of variance?
The main difference is the response variable. While logistic regression deals with a binary response in linear regression analysis and also nonlinear regression the response variable is continuous. You have a variable(s) (aka covariate(s)) that have a functional relationship to the continuous response variable. In the analysis of variance the response is continuous but belongs to a few different categories (e.g. treatment group and control group). In the analysis of variance you look for difference in the mean response between groups. In linear regression you look at how the response changes as the covariates change. Another way to look at the difference is to say that in regression the covariates are continuous whereas in analysis of variance they are a discrete set of groups.
|
Difference between regression analysis and analysis of variance?
The main difference is the response variable. While logistic regression deals with a binary response in linear regression analysis and also nonlinear regression the response variable is continuous. Y
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.