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 |
|---|---|---|---|---|---|---|
18,301 | What are the standard statistical tests to see if data follows exponential or normal distributions? | To test for normality, Anderson-Darling and Shapiro-Wilk are considered the best. For exponential distributions use the Lillerfors test, which is designed specifically for that purpose. | What are the standard statistical tests to see if data follows exponential or normal distributions? | To test for normality, Anderson-Darling and Shapiro-Wilk are considered the best. For exponential distributions use the Lillerfors test, which is designed specifically for that purpose. | What are the standard statistical tests to see if data follows exponential or normal distributions?
To test for normality, Anderson-Darling and Shapiro-Wilk are considered the best. For exponential distributions use the Lillerfors test, which is designed specifically for that purpose. | What are the standard statistical tests to see if data follows exponential or normal distributions?
To test for normality, Anderson-Darling and Shapiro-Wilk are considered the best. For exponential distributions use the Lillerfors test, which is designed specifically for that purpose. |
18,302 | What are the standard statistical tests to see if data follows exponential or normal distributions? | As shown in this table, there are a lot of tests for exponentiality. Please refer to this paper for detail (with table above taken from it): Rahman M, Wu H. Tests for exponentiality: A comparative study[J]. Am. J. Appl. Math. Stat., 2017, 5(4): 125-135.
Of course, many of you guys may just want to use a Python package to test whether your data follows a gaussian or exponential distribution. For this end, I suggest you trying Anderson-Darling test, and here is a link scipy.stats.anderson that shows how to use it in Python. | What are the standard statistical tests to see if data follows exponential or normal distributions? | As shown in this table, there are a lot of tests for exponentiality. Please refer to this paper for detail (with table above taken from it): Rahman M, Wu H. Tests for exponentiality: A comparative stu | What are the standard statistical tests to see if data follows exponential or normal distributions?
As shown in this table, there are a lot of tests for exponentiality. Please refer to this paper for detail (with table above taken from it): Rahman M, Wu H. Tests for exponentiality: A comparative study[J]. Am. J. Appl. Math. Stat., 2017, 5(4): 125-135.
Of course, many of you guys may just want to use a Python package to test whether your data follows a gaussian or exponential distribution. For this end, I suggest you trying Anderson-Darling test, and here is a link scipy.stats.anderson that shows how to use it in Python. | What are the standard statistical tests to see if data follows exponential or normal distributions?
As shown in this table, there are a lot of tests for exponentiality. Please refer to this paper for detail (with table above taken from it): Rahman M, Wu H. Tests for exponentiality: A comparative stu |
18,303 | Proof that if higher moment exists then lower moment also exists | $0<s<r \Longrightarrow \forall X \, |X|^s \le \max(1, |X|^r) $ | Proof that if higher moment exists then lower moment also exists | $0<s<r \Longrightarrow \forall X \, |X|^s \le \max(1, |X|^r) $ | Proof that if higher moment exists then lower moment also exists
$0<s<r \Longrightarrow \forall X \, |X|^s \le \max(1, |X|^r) $ | Proof that if higher moment exists then lower moment also exists
$0<s<r \Longrightarrow \forall X \, |X|^s \le \max(1, |X|^r) $ |
18,304 | Proof that if higher moment exists then lower moment also exists | You can prove it with the help of the monotonicity property of integration,i.e., for functions $f$ and $g$ such that $f \geqslant g$, then $\mathbb{E}[f(X)] \geqslant \mathbb{E}[g(X)]$.
Proof:
Consider the function $g:\mathbb{R} \to \mathbb{R}$ such that $g(x) = |x|^r + 1$ and the function $h: \mathbb{R} \to \mathbb{R}$ such that $h(x) = |x|^s$. Also, consider that $F$ is the cdf of $X$. We can notice that, for every $r \geqslant s$, $g(x) > h(x)$. Then, by monotonicity of integrals, we have
$$
\int_{\mathbb{R}} |x|^r + 1 \, dF = \int_{\mathbb{R}} |x|^r\, dF + \underbrace{\int_{\mathbb{R}} 1 \, dF}_{=1} > \int_{\mathbb{R}} |x|^s \, dF
$$
Since $\int_{\mathbb{R}} |x|^r\, dF = \mathbb{E}|X|^{r}<\infty$, then
$$
\infty > \mathbb{E}|X|^{r} + 1 > \int_{\mathbb{R}} |x|^s \, dF = \mathbb{E}|X|^{s}
$$
There are some comments about using Jensen's Inequality to prove it, but it is wrong to use it, since it becomes a circular proof. From Casella & Berger:
Theorem 4.7.7 (Jensen's Inequality) For any random variable $X$, if $g(x)$ is a convex function, then
$$
\mathbb{E}[g(X)] \geqslant g(\mathbb{E}[X])
$$
This means that, to use this inequality, we must know that $\mathbb{E}[X] < \infty$.
In our case, by applying a function $\varphi: \mathbb{R} \to \mathbb{R}$ such that $\varphi(x) = x^{\frac{r}{s}}$ on $\mathbb{E}[|X|^s]$, we are assuming that $\mathbb{E}[|X|^s] < \infty$, which is exactly what we want to prove. | Proof that if higher moment exists then lower moment also exists | You can prove it with the help of the monotonicity property of integration,i.e., for functions $f$ and $g$ such that $f \geqslant g$, then $\mathbb{E}[f(X)] \geqslant \mathbb{E}[g(X)]$.
Proof:
Conside | Proof that if higher moment exists then lower moment also exists
You can prove it with the help of the monotonicity property of integration,i.e., for functions $f$ and $g$ such that $f \geqslant g$, then $\mathbb{E}[f(X)] \geqslant \mathbb{E}[g(X)]$.
Proof:
Consider the function $g:\mathbb{R} \to \mathbb{R}$ such that $g(x) = |x|^r + 1$ and the function $h: \mathbb{R} \to \mathbb{R}$ such that $h(x) = |x|^s$. Also, consider that $F$ is the cdf of $X$. We can notice that, for every $r \geqslant s$, $g(x) > h(x)$. Then, by monotonicity of integrals, we have
$$
\int_{\mathbb{R}} |x|^r + 1 \, dF = \int_{\mathbb{R}} |x|^r\, dF + \underbrace{\int_{\mathbb{R}} 1 \, dF}_{=1} > \int_{\mathbb{R}} |x|^s \, dF
$$
Since $\int_{\mathbb{R}} |x|^r\, dF = \mathbb{E}|X|^{r}<\infty$, then
$$
\infty > \mathbb{E}|X|^{r} + 1 > \int_{\mathbb{R}} |x|^s \, dF = \mathbb{E}|X|^{s}
$$
There are some comments about using Jensen's Inequality to prove it, but it is wrong to use it, since it becomes a circular proof. From Casella & Berger:
Theorem 4.7.7 (Jensen's Inequality) For any random variable $X$, if $g(x)$ is a convex function, then
$$
\mathbb{E}[g(X)] \geqslant g(\mathbb{E}[X])
$$
This means that, to use this inequality, we must know that $\mathbb{E}[X] < \infty$.
In our case, by applying a function $\varphi: \mathbb{R} \to \mathbb{R}$ such that $\varphi(x) = x^{\frac{r}{s}}$ on $\mathbb{E}[|X|^s]$, we are assuming that $\mathbb{E}[|X|^s] < \infty$, which is exactly what we want to prove. | Proof that if higher moment exists then lower moment also exists
You can prove it with the help of the monotonicity property of integration,i.e., for functions $f$ and $g$ such that $f \geqslant g$, then $\mathbb{E}[f(X)] \geqslant \mathbb{E}[g(X)]$.
Proof:
Conside |
18,305 | Removing factors from a 3-way ANOVA table | I'm guessing the Underwood in question is Experiments in Ecology (Cambridge Press 1991). Its a more-or-less standard reference in the ecological sciences, perhaps third behind Zar and Sokal and Rohlf (and in my opinion the most 'readable' of the three).
If you can find a copy, the relevant section your referee is citing is in 9.7 on p.273. There Underwood suggests a recommended pooling procedure (so not a 'rule' per se) for non-significant factors. It's a 2-step procedure that frankly I don't quite understand, but the upshot is the p = 0.25 is suggested to reduce the probability of Type I error when pooling the non-significant factor (so nothing to do with 'time' in your example, it could be any non-sig factor).
The procedure doesn't actually appear to be Underwood's, he himself cites Winer et al 1991 (Statistical Procedures in Experimental Design McGraw-Hill). You might try there if you can't find a copy of Underwood. | Removing factors from a 3-way ANOVA table | I'm guessing the Underwood in question is Experiments in Ecology (Cambridge Press 1991). Its a more-or-less standard reference in the ecological sciences, perhaps third behind Zar and Sokal and Rohlf | Removing factors from a 3-way ANOVA table
I'm guessing the Underwood in question is Experiments in Ecology (Cambridge Press 1991). Its a more-or-less standard reference in the ecological sciences, perhaps third behind Zar and Sokal and Rohlf (and in my opinion the most 'readable' of the three).
If you can find a copy, the relevant section your referee is citing is in 9.7 on p.273. There Underwood suggests a recommended pooling procedure (so not a 'rule' per se) for non-significant factors. It's a 2-step procedure that frankly I don't quite understand, but the upshot is the p = 0.25 is suggested to reduce the probability of Type I error when pooling the non-significant factor (so nothing to do with 'time' in your example, it could be any non-sig factor).
The procedure doesn't actually appear to be Underwood's, he himself cites Winer et al 1991 (Statistical Procedures in Experimental Design McGraw-Hill). You might try there if you can't find a copy of Underwood. | Removing factors from a 3-way ANOVA table
I'm guessing the Underwood in question is Experiments in Ecology (Cambridge Press 1991). Its a more-or-less standard reference in the ecological sciences, perhaps third behind Zar and Sokal and Rohlf |
18,306 | Removing factors from a 3-way ANOVA table | I loathe these sort of cut-off-based rules. I think it depends on design and what your a priori hypotheses and expectations were. If you expecting the outcome to vary with time then I'd say you should keep time in, as you would for any other 'blocking' factor. On the other hand, if you were replicating the same experiments at different times and had no reason to think the outcome would vary with time but wished to check this was the case, then having done so and found little or no evidence for it varying with time, i'd say it's quite entirely reasonable to then drop time.
I've never heard of Underwood before. It may be a standard text for 'Experiments in Ecology' (the book's title), but there's no obvious reason that experiments in ecology should be treated any differently from any other experiments in this respect, so to view it as "the standard text on this issue" seems unjustified. | Removing factors from a 3-way ANOVA table | I loathe these sort of cut-off-based rules. I think it depends on design and what your a priori hypotheses and expectations were. If you expecting the outcome to vary with time then I'd say you should | Removing factors from a 3-way ANOVA table
I loathe these sort of cut-off-based rules. I think it depends on design and what your a priori hypotheses and expectations were. If you expecting the outcome to vary with time then I'd say you should keep time in, as you would for any other 'blocking' factor. On the other hand, if you were replicating the same experiments at different times and had no reason to think the outcome would vary with time but wished to check this was the case, then having done so and found little or no evidence for it varying with time, i'd say it's quite entirely reasonable to then drop time.
I've never heard of Underwood before. It may be a standard text for 'Experiments in Ecology' (the book's title), but there's no obvious reason that experiments in ecology should be treated any differently from any other experiments in this respect, so to view it as "the standard text on this issue" seems unjustified. | Removing factors from a 3-way ANOVA table
I loathe these sort of cut-off-based rules. I think it depends on design and what your a priori hypotheses and expectations were. If you expecting the outcome to vary with time then I'd say you should |
18,307 | Removing factors from a 3-way ANOVA table | please read the text of Underwood and references therein, it is not a rule, please read. In fact this approach is to control type II error when removing (or pooling) a "non-significanct" term in the model. What if the term you remove has a signficance level of 0.06? Are you really sure that the expected MS do not include an added effect due to the factor?. If you remove that term, you are assuming that the expected MS does not include the added effect due to that treatment BUT YOU MUST BE somewhat protected against type II error!. please excuse my poor and rush english!. | Removing factors from a 3-way ANOVA table | please read the text of Underwood and references therein, it is not a rule, please read. In fact this approach is to control type II error when removing (or pooling) a "non-significanct" term in the m | Removing factors from a 3-way ANOVA table
please read the text of Underwood and references therein, it is not a rule, please read. In fact this approach is to control type II error when removing (or pooling) a "non-significanct" term in the model. What if the term you remove has a signficance level of 0.06? Are you really sure that the expected MS do not include an added effect due to the factor?. If you remove that term, you are assuming that the expected MS does not include the added effect due to that treatment BUT YOU MUST BE somewhat protected against type II error!. please excuse my poor and rush english!. | Removing factors from a 3-way ANOVA table
please read the text of Underwood and references therein, it is not a rule, please read. In fact this approach is to control type II error when removing (or pooling) a "non-significanct" term in the m |
18,308 | What is the major difference between correlation and mutual information? | Correlation measures the linear relationship (Pearson's correlation) or monotonic relationship (Spearman's correlation) between two variables, X and Y.
Mutual information is more general and measures the reduction of uncertainty in Y after observing X. It is the KL distance between the joint density and the product of the individual densities. So MI can measure non-monotonic relationships and other more complicated relationships. | What is the major difference between correlation and mutual information? | Correlation measures the linear relationship (Pearson's correlation) or monotonic relationship (Spearman's correlation) between two variables, X and Y.
Mutual information is more general and measures | What is the major difference between correlation and mutual information?
Correlation measures the linear relationship (Pearson's correlation) or monotonic relationship (Spearman's correlation) between two variables, X and Y.
Mutual information is more general and measures the reduction of uncertainty in Y after observing X. It is the KL distance between the joint density and the product of the individual densities. So MI can measure non-monotonic relationships and other more complicated relationships. | What is the major difference between correlation and mutual information?
Correlation measures the linear relationship (Pearson's correlation) or monotonic relationship (Spearman's correlation) between two variables, X and Y.
Mutual information is more general and measures |
18,309 | What is the major difference between correlation and mutual information? | To add to Rob's answer ... with respect to reverse engineering a network, MI may be preferred over correlation when you want to extract causal rather than associative links in your network. Correlation networks are purely associative. But for MI, you need more data and computing power. | What is the major difference between correlation and mutual information? | To add to Rob's answer ... with respect to reverse engineering a network, MI may be preferred over correlation when you want to extract causal rather than associative links in your network. Correlati | What is the major difference between correlation and mutual information?
To add to Rob's answer ... with respect to reverse engineering a network, MI may be preferred over correlation when you want to extract causal rather than associative links in your network. Correlation networks are purely associative. But for MI, you need more data and computing power. | What is the major difference between correlation and mutual information?
To add to Rob's answer ... with respect to reverse engineering a network, MI may be preferred over correlation when you want to extract causal rather than associative links in your network. Correlati |
18,310 | Is Babe Ruth's statement meaningful? | It is both meaningful and (usually) correct
You are overcomplicating this by bringing probability into a simple non-probabilistic assertion. You need not invoke an omniscient deity in order to accept that there is a reality that exists independently of knowledge of it. (You seem to be operating under the assumption that reality is only admissible to discussion if there is an omniscient being with total knowledge of it; this is a reasonably common misconception of probability, which is examined in this related question.)
The simplest rigorous examination of this statement is a non-statistical analysis based on looking at the underlying population of values pertaining to all the balls Babe Ruth ever hit. Let $X_1,...,X_N$ be the ordered career outcomes of all balls faced by Babe Ruth, with $X_i = \bullet$ denoting a strike and $X_i = \diamond$ denoting a home-run (we need not specify the notation for other possible outcomes). At the end of ball $n$ the number of balls until the next home-run is:
$$B_n \equiv \min \{ k \in \mathbb{N} | X_{n+k} = \diamond \}.$$
Now, we know that a strike and a home-run are mutually exclusive --- i.e., no single ball can be both. Consequently, if ball $n+1$ is a strike (i.e., if $X_{n+1} = \bullet$) and if $B_n<\infty$ (i.e., if Babe has at least one home-run left in his career) then we can easily show that $B_{n+1} = B_n-1$. This confirms Babe's statement that his strike brings him (one ball) closer to his next home-run.
The only exception to this is when Babe gets to the point where he has already hit his last home-run, so that there are no more home-runs left to come in his career. At this point with have $B_n = \infty$ and getting a strike on ball $n+1$ still gives $B_{n+1} = \infty$. In this latter case Babe is no closer to the next home-run, because there is no next home-run.
Of course, at the time of Babe's last home-run, he probably didn't know that would be his last. (According to this historical account, Babe's last home-run was on 25 March 1935. He went on to play five more times without another home-run.) At that point his saying would be wrong, and looking back in hindsight we now know this.
Ultimately, this statement by Babe Ruth is no more controversial than if he asserted, "The elapsing of time spent not getting a home-run brings me closer to my next home-run". That is of course also true, setting aside the situation where he has no future home-runs to get closer to.
Finally, I do not agree with other comments/answers here that assert that this is the gambler's fallacy. It could (but might not) be a manifestation of the gambler's fallacy if he instead said, "Every strike makes it more likely that I will get a home-run in the future". That could be an example of the gambler's fallacy because it would assert that a bad outcome now makes a good outcome in the future more likely. (On the other hand, if strikes are not independent then it might not be.) In any case, merely asserting that the elapsing of time required for a bad outcome to occur now makes a subsequent good outcome closer in time is not the gambler's fallacy, and is not a fallacy at all. | Is Babe Ruth's statement meaningful? | It is both meaningful and (usually) correct
You are overcomplicating this by bringing probability into a simple non-probabilistic assertion. You need not invoke an omniscient deity in order to accept | Is Babe Ruth's statement meaningful?
It is both meaningful and (usually) correct
You are overcomplicating this by bringing probability into a simple non-probabilistic assertion. You need not invoke an omniscient deity in order to accept that there is a reality that exists independently of knowledge of it. (You seem to be operating under the assumption that reality is only admissible to discussion if there is an omniscient being with total knowledge of it; this is a reasonably common misconception of probability, which is examined in this related question.)
The simplest rigorous examination of this statement is a non-statistical analysis based on looking at the underlying population of values pertaining to all the balls Babe Ruth ever hit. Let $X_1,...,X_N$ be the ordered career outcomes of all balls faced by Babe Ruth, with $X_i = \bullet$ denoting a strike and $X_i = \diamond$ denoting a home-run (we need not specify the notation for other possible outcomes). At the end of ball $n$ the number of balls until the next home-run is:
$$B_n \equiv \min \{ k \in \mathbb{N} | X_{n+k} = \diamond \}.$$
Now, we know that a strike and a home-run are mutually exclusive --- i.e., no single ball can be both. Consequently, if ball $n+1$ is a strike (i.e., if $X_{n+1} = \bullet$) and if $B_n<\infty$ (i.e., if Babe has at least one home-run left in his career) then we can easily show that $B_{n+1} = B_n-1$. This confirms Babe's statement that his strike brings him (one ball) closer to his next home-run.
The only exception to this is when Babe gets to the point where he has already hit his last home-run, so that there are no more home-runs left to come in his career. At this point with have $B_n = \infty$ and getting a strike on ball $n+1$ still gives $B_{n+1} = \infty$. In this latter case Babe is no closer to the next home-run, because there is no next home-run.
Of course, at the time of Babe's last home-run, he probably didn't know that would be his last. (According to this historical account, Babe's last home-run was on 25 March 1935. He went on to play five more times without another home-run.) At that point his saying would be wrong, and looking back in hindsight we now know this.
Ultimately, this statement by Babe Ruth is no more controversial than if he asserted, "The elapsing of time spent not getting a home-run brings me closer to my next home-run". That is of course also true, setting aside the situation where he has no future home-runs to get closer to.
Finally, I do not agree with other comments/answers here that assert that this is the gambler's fallacy. It could (but might not) be a manifestation of the gambler's fallacy if he instead said, "Every strike makes it more likely that I will get a home-run in the future". That could be an example of the gambler's fallacy because it would assert that a bad outcome now makes a good outcome in the future more likely. (On the other hand, if strikes are not independent then it might not be.) In any case, merely asserting that the elapsing of time required for a bad outcome to occur now makes a subsequent good outcome closer in time is not the gambler's fallacy, and is not a fallacy at all. | Is Babe Ruth's statement meaningful?
It is both meaningful and (usually) correct
You are overcomplicating this by bringing probability into a simple non-probabilistic assertion. You need not invoke an omniscient deity in order to accept |
18,311 | Is Babe Ruth's statement meaningful? | Suppose that at at-bat $t$ Babe has access to the information in the filtration $\mathcal{F}_t$. Write that Ruth's next home run with be at at-bat $N$. Further suppose that each at-bat has probability $p$ of being a homerun.
Based on the currently available information at at-bat $t$, our best guess of $N$ is $\mathbb{E}[N \mid \mathcal{F}_t] = t + \frac{1-p}{p}$. At time $t+1$,our best guess is $\mathbb{E}[N \mid \mathcal{F}_{t+1}] = t + 1 + \frac{1-p}{p}$. Notice that the expected home run time is always a constant $\frac{1-p}{p}$ at-bats in the future. Ruth is forgetting that the filtration updates. | Is Babe Ruth's statement meaningful? | Suppose that at at-bat $t$ Babe has access to the information in the filtration $\mathcal{F}_t$. Write that Ruth's next home run with be at at-bat $N$. Further suppose that each at-bat has probability | Is Babe Ruth's statement meaningful?
Suppose that at at-bat $t$ Babe has access to the information in the filtration $\mathcal{F}_t$. Write that Ruth's next home run with be at at-bat $N$. Further suppose that each at-bat has probability $p$ of being a homerun.
Based on the currently available information at at-bat $t$, our best guess of $N$ is $\mathbb{E}[N \mid \mathcal{F}_t] = t + \frac{1-p}{p}$. At time $t+1$,our best guess is $\mathbb{E}[N \mid \mathcal{F}_{t+1}] = t + 1 + \frac{1-p}{p}$. Notice that the expected home run time is always a constant $\frac{1-p}{p}$ at-bats in the future. Ruth is forgetting that the filtration updates. | Is Babe Ruth's statement meaningful?
Suppose that at at-bat $t$ Babe has access to the information in the filtration $\mathcal{F}_t$. Write that Ruth's next home run with be at at-bat $N$. Further suppose that each at-bat has probability |
18,312 | Is Babe Ruth's statement meaningful? | As I see it, there are two interpretations to this statement.
The Non-gambler's fallcy interpretation is merely a statement about the deterministic course of events that will occur in the future. In that case, you can index all hit hits that are home runs (i.e. the set $\{k_1, k_2, \dots k_m\}$ where $k_i$ is the index corresponds to his $i$'th homerun (total of $m$ homeruns) out of the set of all his hits. After swinging for his $j$th career ball, for $k_i < j < k_{i+1}$, he is one hit closer to his $k_{i+1}$'th hit, which is a homerun. This is not a probabilistic statement, but a statement that is true if you take a deterministic viewpoint of events.
But, in this interpretation, you could say it's meaningless because the fact that he hit the $j$'th ball has nothing to do with getting closer to his next home run. All that mattered here was the passage of time. You could equally say that sitting at the dinner table, or falling asleep, or sitting in a room and counting to ten also brings him closer to his next homerun.
The gambler's fallacy interpretation would be this:
"After each strike, the expected number of subsequent hits before my next homerun is lower."
This is the Gambler's fallacy, assuming that each hit in isolation has an equal probability and is independent of other hits. (But this is a questionable assumption.) Under this assumption, if the probability of each homerun is $p$, you can calculate that the expected number of swings before the next homerun is
$$
E[\text{number of swings before homerun}] = \sum_{i=1}^\infty i (1-p)^{i-1} p = \frac{1}{p}.
$$
This number is independent of the history of hits, making the statement the gambler's fallacy.
Now, my suspicion is that, if you presented both the interpretations to Babe Ruth, he would suggest that the first interpretation is closer to what he means than the second. | Is Babe Ruth's statement meaningful? | As I see it, there are two interpretations to this statement.
The Non-gambler's fallcy interpretation is merely a statement about the deterministic course of events that will occur in the future. In t | Is Babe Ruth's statement meaningful?
As I see it, there are two interpretations to this statement.
The Non-gambler's fallcy interpretation is merely a statement about the deterministic course of events that will occur in the future. In that case, you can index all hit hits that are home runs (i.e. the set $\{k_1, k_2, \dots k_m\}$ where $k_i$ is the index corresponds to his $i$'th homerun (total of $m$ homeruns) out of the set of all his hits. After swinging for his $j$th career ball, for $k_i < j < k_{i+1}$, he is one hit closer to his $k_{i+1}$'th hit, which is a homerun. This is not a probabilistic statement, but a statement that is true if you take a deterministic viewpoint of events.
But, in this interpretation, you could say it's meaningless because the fact that he hit the $j$'th ball has nothing to do with getting closer to his next home run. All that mattered here was the passage of time. You could equally say that sitting at the dinner table, or falling asleep, or sitting in a room and counting to ten also brings him closer to his next homerun.
The gambler's fallacy interpretation would be this:
"After each strike, the expected number of subsequent hits before my next homerun is lower."
This is the Gambler's fallacy, assuming that each hit in isolation has an equal probability and is independent of other hits. (But this is a questionable assumption.) Under this assumption, if the probability of each homerun is $p$, you can calculate that the expected number of swings before the next homerun is
$$
E[\text{number of swings before homerun}] = \sum_{i=1}^\infty i (1-p)^{i-1} p = \frac{1}{p}.
$$
This number is independent of the history of hits, making the statement the gambler's fallacy.
Now, my suspicion is that, if you presented both the interpretations to Babe Ruth, he would suggest that the first interpretation is closer to what he means than the second. | Is Babe Ruth's statement meaningful?
As I see it, there are two interpretations to this statement.
The Non-gambler's fallcy interpretation is merely a statement about the deterministic course of events that will occur in the future. In t |
18,313 | Is Babe Ruth's statement meaningful? | This is very fun to think about. I will answer in terms of probabilities since that is how you framed your original question. Ben has chosen to provide a non-probabilistic answer by retrospectively looking at the sequence of Babe's observed outcomes.
Let's consider a simplified Bernoulli probability model for whether Babe hits a home run. If we let $X$ be the result of an at-bat where $X=1$ "with probability $p$" for a homerun and $X=0$ otherwise, then $P(X=1|p)=p:=\underset{n\rightarrow \infty}{lim}\frac{1}{n}\sum_{i=1}^n X_i$ is a statement about the proportion of homeruns over many, many (infinite in fact) at-bats. $p$ is an unknown fixed constant. When we use probability we are describing the emergent pattern of events over many, many samples. In order for a pattern to emerge that contains homeruns, an eventual home run is inevitable with enough at-bats. It might be more clear to simply say that each at-bat brings him closer to the next home run. This, then, is a no-brainer, a statement of the obvious − Babe cannot strike out indefinitely. Using our simplified Bernoulli model, does this mean that the long-run probability of Babe hitting a home run depends on his past performance?
Where we sometimes run into trouble is if we try assigning probability statements to single events. We can be confident in a single event occurring based on our knowledge of the long-run performance of the process, but a single event does not have a probability. Probability is a proportion so always ask yourself, "A proportion of what?" A proportion of many samples.
The memoryless property is stating that the emergent pattern over many, many samples is the same no matter how the sequence begins, i.e $P(X=1|p, x_1,...,x_n)=P(X=1|p)$ where we are considering that each at-bat is independent of the others. I don't think these ideas are at odds with Babe's statement. Dave's answer (now since deleted) is correct in terms of expected values, but he is incorrect to apply these probability statements to a single at-bat. In some sense Babe is owed a homerun (in repeated trials) because he cannot strike out indefinitely and still have an expected value of $p$ (or $\frac{1}{p}$ for the geometric distribution of the number of at-bats) where $0<p<1$. Some discuss this idea using the phrase "regression to the mean." Perhaps Babe's statement and your intuition are leading us to the CDF of the geometric distribution, $P(K\le k)=1-(1-p)^{k}$ where $K$ is the number of at-bats until Babe's next homerun. $P(K\le k)$ is also a limiting proportion of many samples or trials, where each homerun constitutes the conclusion of a single sample or trial. Such statements about repeated trials give us confidence in what we should expect to see in our reality since our reality can be viewed as one such trial.
Suppose we had many measurements allowing us to estimate Babe's long-run homerun rate, as well as knowing his observed sequence. We could use this information to calculate a predictive p-value testing a hypothesis about the number of at-bats until Babe's next home run. This predictive p-value is also a long-run probability, but it gives us confidence in our hypothesis regarding the next observed result while incorporating information on Babe's long-run performance AND his most recent performance. This is not a p-value testing a hypothesis about $p$, it is a p-value testing a hypothesis about the next observed result, $H_0$: $K\ge k$ or $H_0$: $K\le k$, unconditional on the unknown fixed true $p$. This is the sort of analysis used to construct prediction intervals for, say, a time series or a Poisson process. Here is an answer discussing the prediction of a single coin toss, analogous to predicting the result of the next at-bat without considering the recent sequence leading up to the next at-bat.
As a separate but related thought experiment, think of flipping a coin with $p=0.4$ for the probability of heads and getting straight tails in 10 flips, where $X=1$ denotes a flip landing on heads and $K=k$ is the number of flips until a heads appears. If we are confident $p$ is indeed close to $0.4$ from earlier experiments based on 1,000 flips (and nothing about the coin or the flipper has changed) then we must be witnessing a rare event and it would only be natural to bet on $K=11$ since the likelihood of such a streak continuing is exceedingly rare. The predictive p-value testing the hypothesis $H_0$: $K\ge 12$ $[X=0$ (tails) on the next flip$]$ is the probability of the discrepancy between the observed result and the hypothesized result or something more extreme, $1-\Phi\bigg(\frac{\frac{400}{1000}-\frac{0}{11}}{\sqrt{0.4(1-0.4)/1000 + 0.4(1-0.4)/11}}\bigg)=0.004,$ approximated using a Wald-type test. We are therefore $100(1-0.004)\%=99.6\%$ confident the next flip will result in a heads. Additionally the p-value testing the hypothesis $H_0$: $K=11$ $[X=1$ (heads) on the next flip$]$ is $\Phi\bigg(\frac{\frac{400}{1000}-\frac{1}{11}}{\sqrt{0.4(1-0.4)/1000 + 0.4(1-0.4)/11}}\bigg)=0.981$. I am not suggesting the coin becomes more likely to land heads or tails in any given flip (see my discussion above regarding probability). I am suggesting that if we were to repeat this experiment many thousands of times, the proportion of times where the coin produces a $\hat{p}=0.4$ in 1,000 flips and then lands on tails after a string of 10 consecutive tails (or something more extreme) is incredibly small.
The key to succeeding in the long run with this predictive p-value strategy is to bet only on the length of a run before any data are observed (Neyman-Pearson's error rate). Otherwise, if you have historical data, are in the middle of a run, and interested not only in the ultimate length of the run but also the result of the next flip, one can view the predictive p-value as a weight of the evidence without error rate guarantees (Fisher's evidential p-value).
If we take it as known that $p=0.4$ and reference the CDF of a geometric distribution we see that the probability of the number of flips being at least 12 until a head is observed is $(1-0.4)^{11}=0.004$. This probability from the geometric CDF could be viewed as a p-value testing the hypothesis $H_0$: $p=0.4$. We could instead retain this hypothesis and call into question whether the next flip will land heads. One might also examine the conditional probability $P(K>k|K\ge 11)$.
Knowing the limiting proportion of heads, if we want a safe bet on the outcome of each coin toss that will pay off in the long run then we should just always bet tails. This is like investing in the S&P500. If we want a safe bet on the length of a run then the geometric distribution would indicate we should bet on shorter-length runs.
Above is a time series of 50 flips from a coin with $p=0.4$. Observing runs of a few heads or tails is not uncommon, but if a run were to continue long enough we would naturally anticipate it to end, e.g. consider the string of tails leading up to flip 21. In order for $p$ to remain a constant $0.4$ the coin cannot land on heads or tails indefinitely. This is the probabilistic way of interpreting Babe's statement without invoking the gambler's fallacy, i.e. that the limiting proportion $p$ changes as a result of what we observe.
Here is a wikipedia page on prediction intervals and predictive p-values. Here is a paper on the topic. | Is Babe Ruth's statement meaningful? | This is very fun to think about. I will answer in terms of probabilities since that is how you framed your original question. Ben has chosen to provide a non-probabilistic answer by retrospectively | Is Babe Ruth's statement meaningful?
This is very fun to think about. I will answer in terms of probabilities since that is how you framed your original question. Ben has chosen to provide a non-probabilistic answer by retrospectively looking at the sequence of Babe's observed outcomes.
Let's consider a simplified Bernoulli probability model for whether Babe hits a home run. If we let $X$ be the result of an at-bat where $X=1$ "with probability $p$" for a homerun and $X=0$ otherwise, then $P(X=1|p)=p:=\underset{n\rightarrow \infty}{lim}\frac{1}{n}\sum_{i=1}^n X_i$ is a statement about the proportion of homeruns over many, many (infinite in fact) at-bats. $p$ is an unknown fixed constant. When we use probability we are describing the emergent pattern of events over many, many samples. In order for a pattern to emerge that contains homeruns, an eventual home run is inevitable with enough at-bats. It might be more clear to simply say that each at-bat brings him closer to the next home run. This, then, is a no-brainer, a statement of the obvious − Babe cannot strike out indefinitely. Using our simplified Bernoulli model, does this mean that the long-run probability of Babe hitting a home run depends on his past performance?
Where we sometimes run into trouble is if we try assigning probability statements to single events. We can be confident in a single event occurring based on our knowledge of the long-run performance of the process, but a single event does not have a probability. Probability is a proportion so always ask yourself, "A proportion of what?" A proportion of many samples.
The memoryless property is stating that the emergent pattern over many, many samples is the same no matter how the sequence begins, i.e $P(X=1|p, x_1,...,x_n)=P(X=1|p)$ where we are considering that each at-bat is independent of the others. I don't think these ideas are at odds with Babe's statement. Dave's answer (now since deleted) is correct in terms of expected values, but he is incorrect to apply these probability statements to a single at-bat. In some sense Babe is owed a homerun (in repeated trials) because he cannot strike out indefinitely and still have an expected value of $p$ (or $\frac{1}{p}$ for the geometric distribution of the number of at-bats) where $0<p<1$. Some discuss this idea using the phrase "regression to the mean." Perhaps Babe's statement and your intuition are leading us to the CDF of the geometric distribution, $P(K\le k)=1-(1-p)^{k}$ where $K$ is the number of at-bats until Babe's next homerun. $P(K\le k)$ is also a limiting proportion of many samples or trials, where each homerun constitutes the conclusion of a single sample or trial. Such statements about repeated trials give us confidence in what we should expect to see in our reality since our reality can be viewed as one such trial.
Suppose we had many measurements allowing us to estimate Babe's long-run homerun rate, as well as knowing his observed sequence. We could use this information to calculate a predictive p-value testing a hypothesis about the number of at-bats until Babe's next home run. This predictive p-value is also a long-run probability, but it gives us confidence in our hypothesis regarding the next observed result while incorporating information on Babe's long-run performance AND his most recent performance. This is not a p-value testing a hypothesis about $p$, it is a p-value testing a hypothesis about the next observed result, $H_0$: $K\ge k$ or $H_0$: $K\le k$, unconditional on the unknown fixed true $p$. This is the sort of analysis used to construct prediction intervals for, say, a time series or a Poisson process. Here is an answer discussing the prediction of a single coin toss, analogous to predicting the result of the next at-bat without considering the recent sequence leading up to the next at-bat.
As a separate but related thought experiment, think of flipping a coin with $p=0.4$ for the probability of heads and getting straight tails in 10 flips, where $X=1$ denotes a flip landing on heads and $K=k$ is the number of flips until a heads appears. If we are confident $p$ is indeed close to $0.4$ from earlier experiments based on 1,000 flips (and nothing about the coin or the flipper has changed) then we must be witnessing a rare event and it would only be natural to bet on $K=11$ since the likelihood of such a streak continuing is exceedingly rare. The predictive p-value testing the hypothesis $H_0$: $K\ge 12$ $[X=0$ (tails) on the next flip$]$ is the probability of the discrepancy between the observed result and the hypothesized result or something more extreme, $1-\Phi\bigg(\frac{\frac{400}{1000}-\frac{0}{11}}{\sqrt{0.4(1-0.4)/1000 + 0.4(1-0.4)/11}}\bigg)=0.004,$ approximated using a Wald-type test. We are therefore $100(1-0.004)\%=99.6\%$ confident the next flip will result in a heads. Additionally the p-value testing the hypothesis $H_0$: $K=11$ $[X=1$ (heads) on the next flip$]$ is $\Phi\bigg(\frac{\frac{400}{1000}-\frac{1}{11}}{\sqrt{0.4(1-0.4)/1000 + 0.4(1-0.4)/11}}\bigg)=0.981$. I am not suggesting the coin becomes more likely to land heads or tails in any given flip (see my discussion above regarding probability). I am suggesting that if we were to repeat this experiment many thousands of times, the proportion of times where the coin produces a $\hat{p}=0.4$ in 1,000 flips and then lands on tails after a string of 10 consecutive tails (or something more extreme) is incredibly small.
The key to succeeding in the long run with this predictive p-value strategy is to bet only on the length of a run before any data are observed (Neyman-Pearson's error rate). Otherwise, if you have historical data, are in the middle of a run, and interested not only in the ultimate length of the run but also the result of the next flip, one can view the predictive p-value as a weight of the evidence without error rate guarantees (Fisher's evidential p-value).
If we take it as known that $p=0.4$ and reference the CDF of a geometric distribution we see that the probability of the number of flips being at least 12 until a head is observed is $(1-0.4)^{11}=0.004$. This probability from the geometric CDF could be viewed as a p-value testing the hypothesis $H_0$: $p=0.4$. We could instead retain this hypothesis and call into question whether the next flip will land heads. One might also examine the conditional probability $P(K>k|K\ge 11)$.
Knowing the limiting proportion of heads, if we want a safe bet on the outcome of each coin toss that will pay off in the long run then we should just always bet tails. This is like investing in the S&P500. If we want a safe bet on the length of a run then the geometric distribution would indicate we should bet on shorter-length runs.
Above is a time series of 50 flips from a coin with $p=0.4$. Observing runs of a few heads or tails is not uncommon, but if a run were to continue long enough we would naturally anticipate it to end, e.g. consider the string of tails leading up to flip 21. In order for $p$ to remain a constant $0.4$ the coin cannot land on heads or tails indefinitely. This is the probabilistic way of interpreting Babe's statement without invoking the gambler's fallacy, i.e. that the limiting proportion $p$ changes as a result of what we observe.
Here is a wikipedia page on prediction intervals and predictive p-values. Here is a paper on the topic. | Is Babe Ruth's statement meaningful?
This is very fun to think about. I will answer in terms of probabilities since that is how you framed your original question. Ben has chosen to provide a non-probabilistic answer by retrospectively |
18,314 | Depth of a decision tree | No, because the data can be split on the same attribute multiple times. And this characteristic of decision trees is important because it allows them to capture nonlinearities in individual attributes.
Edit: In support of the point above, here's the first regression tree I created. Note that volatile acidity and alcohol appear multiple times: | Depth of a decision tree | No, because the data can be split on the same attribute multiple times. And this characteristic of decision trees is important because it allows them to capture nonlinearities in individual attributes | Depth of a decision tree
No, because the data can be split on the same attribute multiple times. And this characteristic of decision trees is important because it allows them to capture nonlinearities in individual attributes.
Edit: In support of the point above, here's the first regression tree I created. Note that volatile acidity and alcohol appear multiple times: | Depth of a decision tree
No, because the data can be split on the same attribute multiple times. And this characteristic of decision trees is important because it allows them to capture nonlinearities in individual attributes |
18,315 | Depth of a decision tree | Well if the features are categorical this above regression answer doesn't really hold true. Then it is dependent on the number of categories how many splits you can do on one feature. If each feature only has two categories, then OP would be correct. | Depth of a decision tree | Well if the features are categorical this above regression answer doesn't really hold true. Then it is dependent on the number of categories how many splits you can do on one feature. If each feature | Depth of a decision tree
Well if the features are categorical this above regression answer doesn't really hold true. Then it is dependent on the number of categories how many splits you can do on one feature. If each feature only has two categories, then OP would be correct. | Depth of a decision tree
Well if the features are categorical this above regression answer doesn't really hold true. Then it is dependent on the number of categories how many splits you can do on one feature. If each feature |
18,316 | Softmax overflow [closed] | Observe that
$$
\frac{e^{x_i}}{\sum_j e^{x_j}} = \frac{e^{-m}}{e^{-m}}\frac{e^{x_i}}{\sum_j e^{x_j}}= \frac{e^{x_i-m}}{\sum_j e^{x_j-m}}
$$
for any constant $m$.
Obviously it is not true that $e^{x_i} = e^{x_i-m}$, but the normalized versions are the same. Your problem is that the $x_i$s are too big, so subtract the same number $m$ from all of them before you take the softmax. Sometimes people set $m$ to be the maximum of all the $x_i$s. | Softmax overflow [closed] | Observe that
$$
\frac{e^{x_i}}{\sum_j e^{x_j}} = \frac{e^{-m}}{e^{-m}}\frac{e^{x_i}}{\sum_j e^{x_j}}= \frac{e^{x_i-m}}{\sum_j e^{x_j-m}}
$$
for any constant $m$.
Obviously it is not true that $e^{x_ | Softmax overflow [closed]
Observe that
$$
\frac{e^{x_i}}{\sum_j e^{x_j}} = \frac{e^{-m}}{e^{-m}}\frac{e^{x_i}}{\sum_j e^{x_j}}= \frac{e^{x_i-m}}{\sum_j e^{x_j-m}}
$$
for any constant $m$.
Obviously it is not true that $e^{x_i} = e^{x_i-m}$, but the normalized versions are the same. Your problem is that the $x_i$s are too big, so subtract the same number $m$ from all of them before you take the softmax. Sometimes people set $m$ to be the maximum of all the $x_i$s. | Softmax overflow [closed]
Observe that
$$
\frac{e^{x_i}}{\sum_j e^{x_j}} = \frac{e^{-m}}{e^{-m}}\frac{e^{x_i}}{\sum_j e^{x_j}}= \frac{e^{x_i-m}}{\sum_j e^{x_j-m}}
$$
for any constant $m$.
Obviously it is not true that $e^{x_ |
18,317 | For i.i.d. random varianbles $X$, $Y$, can $X-Y$ be uniform [0,1]? | No.
If $Y$ is ever (with positive probability) $> X$, then $X - Y < 0$, so it can't be $U[0,1]$. If $X$ and $Y$ are iid, $Y$ can not be guaranteed (i.e., with probability $1$) to not be $> X$ unless $X$ and $Y$ are both the same constants with probability 1. In such case $X - Y$ will equal $0$ with probability $1$. Therefore, there exists no iid $X$ and $Y$ such that $X - Y$ is $U[0,1]$. | For i.i.d. random varianbles $X$, $Y$, can $X-Y$ be uniform [0,1]? | No.
If $Y$ is ever (with positive probability) $> X$, then $X - Y < 0$, so it can't be $U[0,1]$. If $X$ and $Y$ are iid, $Y$ can not be guaranteed (i.e., with probability $1$) to not be $> X$ unless $ | For i.i.d. random varianbles $X$, $Y$, can $X-Y$ be uniform [0,1]?
No.
If $Y$ is ever (with positive probability) $> X$, then $X - Y < 0$, so it can't be $U[0,1]$. If $X$ and $Y$ are iid, $Y$ can not be guaranteed (i.e., with probability $1$) to not be $> X$ unless $X$ and $Y$ are both the same constants with probability 1. In such case $X - Y$ will equal $0$ with probability $1$. Therefore, there exists no iid $X$ and $Y$ such that $X - Y$ is $U[0,1]$. | For i.i.d. random varianbles $X$, $Y$, can $X-Y$ be uniform [0,1]?
No.
If $Y$ is ever (with positive probability) $> X$, then $X - Y < 0$, so it can't be $U[0,1]$. If $X$ and $Y$ are iid, $Y$ can not be guaranteed (i.e., with probability $1$) to not be $> X$ unless $ |
18,318 | For i.i.d. random varianbles $X$, $Y$, can $X-Y$ be uniform [0,1]? | No.
For any i.i.d. $X$ and $Y$ the distribution of their difference is invariant under sign-change, $X - Y \overset{d}{\sim} Y - X$, and thus symmetric around zero, something $U[0, 1]$ is not. | For i.i.d. random varianbles $X$, $Y$, can $X-Y$ be uniform [0,1]? | No.
For any i.i.d. $X$ and $Y$ the distribution of their difference is invariant under sign-change, $X - Y \overset{d}{\sim} Y - X$, and thus symmetric around zero, something $U[0, 1]$ is not. | For i.i.d. random varianbles $X$, $Y$, can $X-Y$ be uniform [0,1]?
No.
For any i.i.d. $X$ and $Y$ the distribution of their difference is invariant under sign-change, $X - Y \overset{d}{\sim} Y - X$, and thus symmetric around zero, something $U[0, 1]$ is not. | For i.i.d. random varianbles $X$, $Y$, can $X-Y$ be uniform [0,1]?
No.
For any i.i.d. $X$ and $Y$ the distribution of their difference is invariant under sign-change, $X - Y \overset{d}{\sim} Y - X$, and thus symmetric around zero, something $U[0, 1]$ is not. |
18,319 | "When to use boxplot and when barplot" rules (of thumb?) | Specifically for graphical illustration of ANOVA:
A box plot or bar chart is much better than nothing graphically for ANOVA, but as commonly plotted, both are indirect or incomplete as a graphical summary.
ANOVA is about comparisons of means in a context of variations of one or more kinds, so the most appropriate graphic would show, minimally, means as well as the raw data. Group standard deviations (SDs) or related quantities would do no harm.
Although some varieties of box plots show means as well as medians, the standard kind shows medians, quartiles and some information in the tails of the distribution. The most common variant seems to be that in which individual data points are shown if and only if they lie more than 1.5 IQR away from the nearer quartile. That is: interquartile range IQR $=$ upper quartile $-$ lower quartile, so plot as points values greater than upper quartile $+$ 1.5 IQR or less than lower quartile $-$ 1.5 IQR. Such a convention can be helpful at showing gross outliers which may be problematic for ANOVA, but neither medians nor quartiles play any part in ANOVA and whether medians approximate means is a point to be checked, not assumed. Commonly, experienced data analysts take e.g. pronounced marked outliers and/or asymmetry of distribution as a sign of a problem that needs action, such as transformation of the data or need for a generalized linear model with a non-identity link function. Nevertheless it is surprising how many textbook and other accounts show box plots when an ANOVA is being presented but don't mention the elephants not in the room, the means that are not plotted.
Conversely, the most common kind of bar chart in this context summarizes data by means and SDs or standard errors, but omits any display of individual data points otherwise. So, for example, outliers or marked asymmetry can only be inferred from out-of-line means or inflated variability within individual groups.
Generally, there are many suggestions of which kinds of graphs are useful but little consensus about which are best. I'd suggest as criteria that a good graph shows
The complete pattern of variation in the data, at least as backdrop or context
Relevant summaries of the data, specifically those relevant to the model being entertained or the descriptors being considered
Indications of possible problems with the data that cast doubt on assumptions being made.
There are several designs that help with ANOVA, such as dot or strip plots with added means and SEs.
This paper by John Tukey explains the difference between propaganda graphs and analytical graphs that is pertinent here. Too many graphical illustrations of ANOVA are propaganda graphs (look! the groups are very different) without much analysis (and what else can we learn about the data or the limitations of the technique in this application?). | "When to use boxplot and when barplot" rules (of thumb?) | Specifically for graphical illustration of ANOVA:
A box plot or bar chart is much better than nothing graphically for ANOVA, but as commonly plotted, both are indirect or incomplete as a graphical s | "When to use boxplot and when barplot" rules (of thumb?)
Specifically for graphical illustration of ANOVA:
A box plot or bar chart is much better than nothing graphically for ANOVA, but as commonly plotted, both are indirect or incomplete as a graphical summary.
ANOVA is about comparisons of means in a context of variations of one or more kinds, so the most appropriate graphic would show, minimally, means as well as the raw data. Group standard deviations (SDs) or related quantities would do no harm.
Although some varieties of box plots show means as well as medians, the standard kind shows medians, quartiles and some information in the tails of the distribution. The most common variant seems to be that in which individual data points are shown if and only if they lie more than 1.5 IQR away from the nearer quartile. That is: interquartile range IQR $=$ upper quartile $-$ lower quartile, so plot as points values greater than upper quartile $+$ 1.5 IQR or less than lower quartile $-$ 1.5 IQR. Such a convention can be helpful at showing gross outliers which may be problematic for ANOVA, but neither medians nor quartiles play any part in ANOVA and whether medians approximate means is a point to be checked, not assumed. Commonly, experienced data analysts take e.g. pronounced marked outliers and/or asymmetry of distribution as a sign of a problem that needs action, such as transformation of the data or need for a generalized linear model with a non-identity link function. Nevertheless it is surprising how many textbook and other accounts show box plots when an ANOVA is being presented but don't mention the elephants not in the room, the means that are not plotted.
Conversely, the most common kind of bar chart in this context summarizes data by means and SDs or standard errors, but omits any display of individual data points otherwise. So, for example, outliers or marked asymmetry can only be inferred from out-of-line means or inflated variability within individual groups.
Generally, there are many suggestions of which kinds of graphs are useful but little consensus about which are best. I'd suggest as criteria that a good graph shows
The complete pattern of variation in the data, at least as backdrop or context
Relevant summaries of the data, specifically those relevant to the model being entertained or the descriptors being considered
Indications of possible problems with the data that cast doubt on assumptions being made.
There are several designs that help with ANOVA, such as dot or strip plots with added means and SEs.
This paper by John Tukey explains the difference between propaganda graphs and analytical graphs that is pertinent here. Too many graphical illustrations of ANOVA are propaganda graphs (look! the groups are very different) without much analysis (and what else can we learn about the data or the limitations of the technique in this application?). | "When to use boxplot and when barplot" rules (of thumb?)
Specifically for graphical illustration of ANOVA:
A box plot or bar chart is much better than nothing graphically for ANOVA, but as commonly plotted, both are indirect or incomplete as a graphical s |
18,320 | "When to use boxplot and when barplot" rules (of thumb?) | Please do not be confused between bar charts (one bar is used to show each quantity of interest) and dynamite plots (one bar shows the average of each group, plus error bars). Dynamite plots are NEVER acceptable because they hide the distribution of the data for no reason at all.
Yes I realize that this is by far the most common type of plot. It is a big problem that reflects the (low) importance that researchers place on the shape of their data. If you were a detective looking for a murder weapon, would it be better if a witness told you 1) only the location and size of the weapon? or 2) the location, size, and shape?
http://biostat.mc.vanderbilt.edu/wiki/pub/Main/TatsukiRcode/Poster3.pdf | "When to use boxplot and when barplot" rules (of thumb?) | Please do not be confused between bar charts (one bar is used to show each quantity of interest) and dynamite plots (one bar shows the average of each group, plus error bars). Dynamite plots are NEVER | "When to use boxplot and when barplot" rules (of thumb?)
Please do not be confused between bar charts (one bar is used to show each quantity of interest) and dynamite plots (one bar shows the average of each group, plus error bars). Dynamite plots are NEVER acceptable because they hide the distribution of the data for no reason at all.
Yes I realize that this is by far the most common type of plot. It is a big problem that reflects the (low) importance that researchers place on the shape of their data. If you were a detective looking for a murder weapon, would it be better if a witness told you 1) only the location and size of the weapon? or 2) the location, size, and shape?
http://biostat.mc.vanderbilt.edu/wiki/pub/Main/TatsukiRcode/Poster3.pdf | "When to use boxplot and when barplot" rules (of thumb?)
Please do not be confused between bar charts (one bar is used to show each quantity of interest) and dynamite plots (one bar shows the average of each group, plus error bars). Dynamite plots are NEVER |
18,321 | Distinction between linear and nonlinear model | With the usual definitions of linear and nonlinear with regard to modelling, it's not linearity with respect to the predictors that's the critical aspect, but linearity with respect to the parameters. A nonlinear model is nonlinear because it's not linear in parameters.
For example, the first sentence here says:
In statistics, nonlinear regression is a form of regression analysis in which observational data are modeled by a function which is a nonlinear combination of the model parameters and depends on one or more independent variables.
By contrast, Generalized Linear Models generally have a nonlinear relationship between response and predictors, but the link-transformed mean response (the linear predictor, $\eta$) is linear in the parameters.
[By that definition, I believe your model is nonlinear in the $\theta$s, though if the $\theta$s are specified (known) then that nonlinearity isn't relevant to estimation. If they're being fitted, then the model is nonlinear.] | Distinction between linear and nonlinear model | With the usual definitions of linear and nonlinear with regard to modelling, it's not linearity with respect to the predictors that's the critical aspect, but linearity with respect to the parameters. | Distinction between linear and nonlinear model
With the usual definitions of linear and nonlinear with regard to modelling, it's not linearity with respect to the predictors that's the critical aspect, but linearity with respect to the parameters. A nonlinear model is nonlinear because it's not linear in parameters.
For example, the first sentence here says:
In statistics, nonlinear regression is a form of regression analysis in which observational data are modeled by a function which is a nonlinear combination of the model parameters and depends on one or more independent variables.
By contrast, Generalized Linear Models generally have a nonlinear relationship between response and predictors, but the link-transformed mean response (the linear predictor, $\eta$) is linear in the parameters.
[By that definition, I believe your model is nonlinear in the $\theta$s, though if the $\theta$s are specified (known) then that nonlinearity isn't relevant to estimation. If they're being fitted, then the model is nonlinear.] | Distinction between linear and nonlinear model
With the usual definitions of linear and nonlinear with regard to modelling, it's not linearity with respect to the predictors that's the critical aspect, but linearity with respect to the parameters. |
18,322 | Distinction between linear and nonlinear model | I agree with Glen_b. In regression problems, the main focus is on the parameters and not on the independent variable or predictor, x. And then one can decide whether one wants to linearise the problem employing simple transformations or proceed it as such.
Linear problems: count the number of parameters in your problem and check whether all of them have power 1. For example, $y = ax + bx^2 + cx^3 + d x^{2/3} + e/x + f x^{-4/7}$. This function is nonlinear in $x$. But for regression problems, the nonlinearity in $x$ is not an issue. One has to check whether the parameters are linear or linear. In this case, $a$, $b$, $c$,.. $f$ all have power 1. So, they are linear.
Remark that, in $y = \exp(ax)$, though a looks like it has power 1, but when expanded
$\exp(ax) = 1 + ax/ 1! + (ax)^2 / 2! + \dots $. You can clearly see that it is a nonlinear parameter since a has a power more than 1. But, this problem can be linearised by invoking a logarithmic transformation. That is, a nonlinear regression problem is converted to a linear regression problem.
Similarly, $y = a / (1+b \exp(cx)$ is a logistic function. It has three parameters, namely $a$, $b$ and $c$. The parameters $b$ and $c$ have power more than 1, and when expanded they multiply with each other bringing nonlinearity. So, they are not linear. But, they can be also linearised using a proper substitution by setting first $(a/y)-1 = Y$ and then invoking a logarithmic function on both the sides to linearise.
Now suppose $y = a_1 / (1+b_1\exp(c_1x)) + a_2 / (1+b_2\exp(c_2x))$. This is once again nonlinear with respect to the parameters. But, it cannot be linearised. One needs to use a nonlinear regression.
In principle, using a linear strategy to solve a nonlinear regression problem is not a good idea. So, tackle linear problems (when all the parameters have power 1) using linear regression and adopt nonlinear regression if your parameters are nonlinear.
In your case, substitute the weighting function back in the main function. The parameter $\beta_0$ would be the only parameter with power 1. All the other parameters are nonlinear ($\beta_1$ eventually multiplies with $\theta_1$ and $\theta_2$ (these two are nonlinear parameters) making it also nonlinear. Therefore, it is a nonlinear regression problem.
Adopt a nonlinear least squares technique to solve it. Choose initial values cleverly and use a multistart approach to find the global minima.
This vide will be helpful (though it does not talk about global solution): http://www.youtube.com/watch?v=3Fd4ukzkxps
Using GRG nonlinear solver in the Excel spreadsheet (install the solver toolpack by going to options - Add-Ins - Excel Add-Ins and then choosing Solver Add-In)and invoking the multistart in the options list by prescribing intervals to the parameters and demanding the constraint precision and the convergence to be small, a global solution can be obtained.
If you are using Matlab, use the global optimisation toolbox. It has multistart and globalsearch options. Certain codes are available here for a global solution, here
and
here.
If you are using Mathematica, look here.
If you are using R, try here. | Distinction between linear and nonlinear model | I agree with Glen_b. In regression problems, the main focus is on the parameters and not on the independent variable or predictor, x. And then one can decide whether one wants to linearise the problem | Distinction between linear and nonlinear model
I agree with Glen_b. In regression problems, the main focus is on the parameters and not on the independent variable or predictor, x. And then one can decide whether one wants to linearise the problem employing simple transformations or proceed it as such.
Linear problems: count the number of parameters in your problem and check whether all of them have power 1. For example, $y = ax + bx^2 + cx^3 + d x^{2/3} + e/x + f x^{-4/7}$. This function is nonlinear in $x$. But for regression problems, the nonlinearity in $x$ is not an issue. One has to check whether the parameters are linear or linear. In this case, $a$, $b$, $c$,.. $f$ all have power 1. So, they are linear.
Remark that, in $y = \exp(ax)$, though a looks like it has power 1, but when expanded
$\exp(ax) = 1 + ax/ 1! + (ax)^2 / 2! + \dots $. You can clearly see that it is a nonlinear parameter since a has a power more than 1. But, this problem can be linearised by invoking a logarithmic transformation. That is, a nonlinear regression problem is converted to a linear regression problem.
Similarly, $y = a / (1+b \exp(cx)$ is a logistic function. It has three parameters, namely $a$, $b$ and $c$. The parameters $b$ and $c$ have power more than 1, and when expanded they multiply with each other bringing nonlinearity. So, they are not linear. But, they can be also linearised using a proper substitution by setting first $(a/y)-1 = Y$ and then invoking a logarithmic function on both the sides to linearise.
Now suppose $y = a_1 / (1+b_1\exp(c_1x)) + a_2 / (1+b_2\exp(c_2x))$. This is once again nonlinear with respect to the parameters. But, it cannot be linearised. One needs to use a nonlinear regression.
In principle, using a linear strategy to solve a nonlinear regression problem is not a good idea. So, tackle linear problems (when all the parameters have power 1) using linear regression and adopt nonlinear regression if your parameters are nonlinear.
In your case, substitute the weighting function back in the main function. The parameter $\beta_0$ would be the only parameter with power 1. All the other parameters are nonlinear ($\beta_1$ eventually multiplies with $\theta_1$ and $\theta_2$ (these two are nonlinear parameters) making it also nonlinear. Therefore, it is a nonlinear regression problem.
Adopt a nonlinear least squares technique to solve it. Choose initial values cleverly and use a multistart approach to find the global minima.
This vide will be helpful (though it does not talk about global solution): http://www.youtube.com/watch?v=3Fd4ukzkxps
Using GRG nonlinear solver in the Excel spreadsheet (install the solver toolpack by going to options - Add-Ins - Excel Add-Ins and then choosing Solver Add-In)and invoking the multistart in the options list by prescribing intervals to the parameters and demanding the constraint precision and the convergence to be small, a global solution can be obtained.
If you are using Matlab, use the global optimisation toolbox. It has multistart and globalsearch options. Certain codes are available here for a global solution, here
and
here.
If you are using Mathematica, look here.
If you are using R, try here. | Distinction between linear and nonlinear model
I agree with Glen_b. In regression problems, the main focus is on the parameters and not on the independent variable or predictor, x. And then one can decide whether one wants to linearise the problem |
18,323 | Distinction between linear and nonlinear model | The main function is linear.
It does not matter if nonlinear known functions==> $B(L;\theta)$ <== appear in the equations.
I would proceed with a linear least squares if I were you.
This is how you confirm or deny linearity:
https://en.wikipedia.org/wiki/Non-linear#Definition
You might also like:
https://en.wikipedia.org/wiki/Linear_combination
https://en.wikipedia.org/wiki/Least_squares
http://en.m.wikipedia.org/wiki/Linear_least_squares_(mathematics) | Distinction between linear and nonlinear model | The main function is linear.
It does not matter if nonlinear known functions==> $B(L;\theta)$ <== appear in the equations.
I would proceed with a linear least squares if I were you.
This is how you co | Distinction between linear and nonlinear model
The main function is linear.
It does not matter if nonlinear known functions==> $B(L;\theta)$ <== appear in the equations.
I would proceed with a linear least squares if I were you.
This is how you confirm or deny linearity:
https://en.wikipedia.org/wiki/Non-linear#Definition
You might also like:
https://en.wikipedia.org/wiki/Linear_combination
https://en.wikipedia.org/wiki/Least_squares
http://en.m.wikipedia.org/wiki/Linear_least_squares_(mathematics) | Distinction between linear and nonlinear model
The main function is linear.
It does not matter if nonlinear known functions==> $B(L;\theta)$ <== appear in the equations.
I would proceed with a linear least squares if I were you.
This is how you co |
18,324 | Distinction between linear and nonlinear model | It will be easy to understand, if I explain it in the context of functions.
Linear: A function which has a constant slope. Algebraically,a polynomial with highest exponent equal to 1. It's a function whose graph is a line. For example, y=2x+3
Non-Linear: A function which has opposite properties of a linear function. A function which has a varying slope. It's a polynomial with exponent equal to 2 or more. It's graph is not a line. For example, y=x^2
[http://study.com/academy/lesson/nonlinear-function-definition-examples.html][1] | Distinction between linear and nonlinear model | It will be easy to understand, if I explain it in the context of functions.
Linear: A function which has a constant slope. Algebraically,a polynomial with highest exponent equal to 1. It's a function | Distinction between linear and nonlinear model
It will be easy to understand, if I explain it in the context of functions.
Linear: A function which has a constant slope. Algebraically,a polynomial with highest exponent equal to 1. It's a function whose graph is a line. For example, y=2x+3
Non-Linear: A function which has opposite properties of a linear function. A function which has a varying slope. It's a polynomial with exponent equal to 2 or more. It's graph is not a line. For example, y=x^2
[http://study.com/academy/lesson/nonlinear-function-definition-examples.html][1] | Distinction between linear and nonlinear model
It will be easy to understand, if I explain it in the context of functions.
Linear: A function which has a constant slope. Algebraically,a polynomial with highest exponent equal to 1. It's a function |
18,325 | What should be the optimal parameters for Random Forest classifier? | Pick a large number of trees, say 100. From what I have read on the Internet, pick $\sqrt{250}$ randomly selected features. However, in the original paper, Breiman used about the closest integer to $\frac{\log{M}}{\log{2}}$.
I would say cross-validation is usually the key to finding optimal parameters, but I do not know enough about random forests. | What should be the optimal parameters for Random Forest classifier? | Pick a large number of trees, say 100. From what I have read on the Internet, pick $\sqrt{250}$ randomly selected features. However, in the original paper, Breiman used about the closest integer to $\ | What should be the optimal parameters for Random Forest classifier?
Pick a large number of trees, say 100. From what I have read on the Internet, pick $\sqrt{250}$ randomly selected features. However, in the original paper, Breiman used about the closest integer to $\frac{\log{M}}{\log{2}}$.
I would say cross-validation is usually the key to finding optimal parameters, but I do not know enough about random forests. | What should be the optimal parameters for Random Forest classifier?
Pick a large number of trees, say 100. From what I have read on the Internet, pick $\sqrt{250}$ randomly selected features. However, in the original paper, Breiman used about the closest integer to $\ |
18,326 | What should be the optimal parameters for Random Forest classifier? | Number of trees the bigger, the better. You almost can't overshoot with this parameter, but of course the upper limit depends on the computational time you want to spend on RF.
The good idea is to make a long forest first and then see (I hope it is available in MATLAB implementation) when the OOB accuracy converges.
Number of tried attributes the default is square root of the whole number of attributes, yet usually the forest is not very sensitive about the value of this parameter -- in fact it is rarely optimized, especially because stochastic aspect of RF may introduce larger variations. | What should be the optimal parameters for Random Forest classifier? | Number of trees the bigger, the better. You almost can't overshoot with this parameter, but of course the upper limit depends on the computational time you want to spend on RF.
The good idea is to mak | What should be the optimal parameters for Random Forest classifier?
Number of trees the bigger, the better. You almost can't overshoot with this parameter, but of course the upper limit depends on the computational time you want to spend on RF.
The good idea is to make a long forest first and then see (I hope it is available in MATLAB implementation) when the OOB accuracy converges.
Number of tried attributes the default is square root of the whole number of attributes, yet usually the forest is not very sensitive about the value of this parameter -- in fact it is rarely optimized, especially because stochastic aspect of RF may introduce larger variations. | What should be the optimal parameters for Random Forest classifier?
Number of trees the bigger, the better. You almost can't overshoot with this parameter, but of course the upper limit depends on the computational time you want to spend on RF.
The good idea is to mak |
18,327 | What should be the optimal parameters for Random Forest classifier? | Number of trees the bigger, the better : agreed.
Number of tried attributes will depend. If you already have some a priori about the way the information is spreading or not among the features. If the information is shared by many features, better results would come up with smaller value of that parameter. While, on the other hand, if only a few features are carrying the information, you should use larger values. In other words, with many relevant variables : smaller values are better and with many irrelevant variables : bigger values are better. | What should be the optimal parameters for Random Forest classifier? | Number of trees the bigger, the better : agreed.
Number of tried attributes will depend. If you already have some a priori about the way the information is spreading or not among the features. If the | What should be the optimal parameters for Random Forest classifier?
Number of trees the bigger, the better : agreed.
Number of tried attributes will depend. If you already have some a priori about the way the information is spreading or not among the features. If the information is shared by many features, better results would come up with smaller value of that parameter. While, on the other hand, if only a few features are carrying the information, you should use larger values. In other words, with many relevant variables : smaller values are better and with many irrelevant variables : bigger values are better. | What should be the optimal parameters for Random Forest classifier?
Number of trees the bigger, the better : agreed.
Number of tried attributes will depend. If you already have some a priori about the way the information is spreading or not among the features. If the |
18,328 | Cross-correlation significance in R | The variance of the cross-correlation coefficient under the null hypothesis of zero correlation is approx $1/n$ where $n$ is the length of the series. The coefficients are also asymptotically normal. So approximate critical values (at the 5% level) are $\pm 2/\sqrt{n}$.
These critical values are plotted automatically in R using ccf(x,y). | Cross-correlation significance in R | The variance of the cross-correlation coefficient under the null hypothesis of zero correlation is approx $1/n$ where $n$ is the length of the series. The coefficients are also asymptotically normal. | Cross-correlation significance in R
The variance of the cross-correlation coefficient under the null hypothesis of zero correlation is approx $1/n$ where $n$ is the length of the series. The coefficients are also asymptotically normal. So approximate critical values (at the 5% level) are $\pm 2/\sqrt{n}$.
These critical values are plotted automatically in R using ccf(x,y). | Cross-correlation significance in R
The variance of the cross-correlation coefficient under the null hypothesis of zero correlation is approx $1/n$ where $n$ is the length of the series. The coefficients are also asymptotically normal. |
18,329 | Cross-correlation significance in R | The cross-correlation coefficient does not measure dependence between time series. The proper tool for it is the coherence function. For example, see Bendat and Piersol, 2010. | Cross-correlation significance in R | The cross-correlation coefficient does not measure dependence between time series. The proper tool for it is the coherence function. For example, see Bendat and Piersol, 2010. | Cross-correlation significance in R
The cross-correlation coefficient does not measure dependence between time series. The proper tool for it is the coherence function. For example, see Bendat and Piersol, 2010. | Cross-correlation significance in R
The cross-correlation coefficient does not measure dependence between time series. The proper tool for it is the coherence function. For example, see Bendat and Piersol, 2010. |
18,330 | MLE for normal distribution with restrictive parameters | Solution
Let $\bar{x}$ denote the sample mean:
$$\bar{x} = \frac{1}{n} \sum_{i=1}^n x_i$$
The constrained maximum likelihood mean $\hat{\mu}$ and variance $\hat{\sigma}^2$ are:
$$\hat{\mu} = \left\{ \begin{array}{cl}
\bar{x} & \bar{x} \ge 0 \\
0 & \text{Otherwise} \\
\end{array} \right.$$
$$\hat{\sigma}^2 = \frac{1}{n} \sum_{i=1}^n (x_i - \hat{\mu})^2$$
That is, we simply take the sample mean and clip it to zero if it's negative. Then, plug it into the usual expression for the (uncorrected) sample variance. I obtained these expressions by setting up the constrained optimization problem, then solving for the parameters that satisfy the KKT conditions, as described below.
Derivation
Objective function
Maximizing the likelihood is equivalent to minimizing the negative log likelihood $L(\mu, \sigma^2)$, which will be more convenient to work with:
$$L(\mu, \sigma^2) =
-\sum_{i=1}^n \log \mathcal{N}(x_i \mid \mu, \sigma^2)$$
$$= \frac{n}{2} \log(2 \pi)
+ \frac{n}{2} \log(\sigma^2)
+ \frac{1}{2 \sigma^2} \sum_{i=1}^n (x_i-\mu)^2$$
We'll also need its partial derivatives w.r.t. $\mu$ and $\sigma^2$:
$$\frac{\partial}{\partial \mu} L(\mu, \sigma^2) =
\frac{n \mu}{\sigma^2}
- \frac{1}{\sigma^2} \sum_{i=1}^n x_i$$
$$\frac{\partial}{\partial \sigma^2} L(\mu, \sigma^2) =
\frac{n}{2 \sigma^2}
- \frac{1}{2 \sigma^4} \sum_{i=1}^n (x_i-\mu)^2$$
Optimization problem
The goal is to find the parameters $\hat{\mu}$ and $\hat{\sigma}^2$ that minimize the negative log likelihood, subject to a non-negativity constraint on the mean. The variance is non-negative by definition and the solution below turns out to automatically respect this constraint, so we don't need to impose it explicitly. The optimization problem can be written as:
$$\hat{\mu}, \hat{\sigma}^2 =
\arg \min_{\mu, \sigma^2} \ L(\mu, \sigma^2)
\quad \text{s.t. } g(\mu, \sigma^2) \le 0$$
$$\text{where } \ g(\mu, \sigma^2) = -\mu$$
I've written the constraint this way to follow convention, which should hopefully make it easier to match this up with other discussions about constrained optimization. In our problem, this just amounts to the constraint $\mu \ge 0$.
KKT conditions
If $(\hat{\mu}, \hat{\sigma}^2)$ is an optimal solution, there must exist a constant $\lambda$ such that the KKT conditions hold: 1) stationarity, 2) primal feasibility, 3) dual feasibility, and 4) complementary slackness. Furthermore, we have a convex loss function with a convex, continuously differentiable constraint. This implies that the KKT conditions are sufficient for optimality, so we can find the solution by solving for the parameters that satisfy these conditions.
Stationarity:
$$\frac{\partial}{\partial \mu} L(\hat{\mu}, \hat{\sigma}^2) + \lambda \frac{\partial}{\partial \mu} g(\hat{\mu}, \hat{\sigma}^2) = 0$$
$$\frac{\partial}{\partial \sigma^2} L(\hat{\mu}, \hat{\sigma}^2) + \lambda \frac{\partial}{\partial \sigma^2} g(\hat{\mu}, \hat{\sigma}^2) = 0$$
Plug in expressions for the derivatives and solve for the parameters:
$$\hat{\mu} = \frac{1}{n} \hat{\sigma}^2 \lambda + \frac{1}{n} \sum_{i=1}^n x_i \tag{1}$$
$$\hat{\sigma}^2 = \frac{1}{n} \sum_{i=1}^n (x_i-\hat{\mu})^2 \tag{2}$$
Primal feasibility:
$$g(\hat{\mu}, \hat{\sigma}^2) \le 0
\implies \hat{\mu} \ge 0$$
This just says the parameters must respect the constraints
Dual feasibility:
$$\lambda \ge 0$$
Complementary slackness:
$$\lambda g(\hat{\mu}, \hat{\sigma}^2) = 0
\implies \lambda \hat{\mu} = 0$$
This says that either $\lambda$ or $\hat{\mu}$ (or both) must be zero.
Solving
Note that the RHS of equation $(1)$ is a multiple of $\lambda$ plus the sample mean $\frac{1}{n} \sum_{i=1}^n x_i$. If the sample mean is non-negative, set $\lambda$ to zero (satisfying the dual feasibility and complementary slackness conditions). It then follows from equation $(1)$ (the stationarity condition) that $\hat{\mu}$ is equal to the sample mean. This also satisfies the primal feasibility condition, since it's non-negative.
Otherwise, if the sample mean is negative, set $\hat{\mu}$ to zero (satisfying the primal feasibility and complementary slackness conditions). To satisfy equation $(1)$ (the stationarity condition), set $\lambda = -\hat{\sigma}^{-2} \sum_{i=1}^n x_i$. Since the sample mean is negative and the variance is positive, $\lambda$ takes a positive value, satisfying the dual feasibility conditionn.
In both cases, we can plug $\hat{\mu}$ into equation $(2)$ to obtain $\hat{\sigma}^2$. | MLE for normal distribution with restrictive parameters | Solution
Let $\bar{x}$ denote the sample mean:
$$\bar{x} = \frac{1}{n} \sum_{i=1}^n x_i$$
The constrained maximum likelihood mean $\hat{\mu}$ and variance $\hat{\sigma}^2$ are:
$$\hat{\mu} = \left\{ \ | MLE for normal distribution with restrictive parameters
Solution
Let $\bar{x}$ denote the sample mean:
$$\bar{x} = \frac{1}{n} \sum_{i=1}^n x_i$$
The constrained maximum likelihood mean $\hat{\mu}$ and variance $\hat{\sigma}^2$ are:
$$\hat{\mu} = \left\{ \begin{array}{cl}
\bar{x} & \bar{x} \ge 0 \\
0 & \text{Otherwise} \\
\end{array} \right.$$
$$\hat{\sigma}^2 = \frac{1}{n} \sum_{i=1}^n (x_i - \hat{\mu})^2$$
That is, we simply take the sample mean and clip it to zero if it's negative. Then, plug it into the usual expression for the (uncorrected) sample variance. I obtained these expressions by setting up the constrained optimization problem, then solving for the parameters that satisfy the KKT conditions, as described below.
Derivation
Objective function
Maximizing the likelihood is equivalent to minimizing the negative log likelihood $L(\mu, \sigma^2)$, which will be more convenient to work with:
$$L(\mu, \sigma^2) =
-\sum_{i=1}^n \log \mathcal{N}(x_i \mid \mu, \sigma^2)$$
$$= \frac{n}{2} \log(2 \pi)
+ \frac{n}{2} \log(\sigma^2)
+ \frac{1}{2 \sigma^2} \sum_{i=1}^n (x_i-\mu)^2$$
We'll also need its partial derivatives w.r.t. $\mu$ and $\sigma^2$:
$$\frac{\partial}{\partial \mu} L(\mu, \sigma^2) =
\frac{n \mu}{\sigma^2}
- \frac{1}{\sigma^2} \sum_{i=1}^n x_i$$
$$\frac{\partial}{\partial \sigma^2} L(\mu, \sigma^2) =
\frac{n}{2 \sigma^2}
- \frac{1}{2 \sigma^4} \sum_{i=1}^n (x_i-\mu)^2$$
Optimization problem
The goal is to find the parameters $\hat{\mu}$ and $\hat{\sigma}^2$ that minimize the negative log likelihood, subject to a non-negativity constraint on the mean. The variance is non-negative by definition and the solution below turns out to automatically respect this constraint, so we don't need to impose it explicitly. The optimization problem can be written as:
$$\hat{\mu}, \hat{\sigma}^2 =
\arg \min_{\mu, \sigma^2} \ L(\mu, \sigma^2)
\quad \text{s.t. } g(\mu, \sigma^2) \le 0$$
$$\text{where } \ g(\mu, \sigma^2) = -\mu$$
I've written the constraint this way to follow convention, which should hopefully make it easier to match this up with other discussions about constrained optimization. In our problem, this just amounts to the constraint $\mu \ge 0$.
KKT conditions
If $(\hat{\mu}, \hat{\sigma}^2)$ is an optimal solution, there must exist a constant $\lambda$ such that the KKT conditions hold: 1) stationarity, 2) primal feasibility, 3) dual feasibility, and 4) complementary slackness. Furthermore, we have a convex loss function with a convex, continuously differentiable constraint. This implies that the KKT conditions are sufficient for optimality, so we can find the solution by solving for the parameters that satisfy these conditions.
Stationarity:
$$\frac{\partial}{\partial \mu} L(\hat{\mu}, \hat{\sigma}^2) + \lambda \frac{\partial}{\partial \mu} g(\hat{\mu}, \hat{\sigma}^2) = 0$$
$$\frac{\partial}{\partial \sigma^2} L(\hat{\mu}, \hat{\sigma}^2) + \lambda \frac{\partial}{\partial \sigma^2} g(\hat{\mu}, \hat{\sigma}^2) = 0$$
Plug in expressions for the derivatives and solve for the parameters:
$$\hat{\mu} = \frac{1}{n} \hat{\sigma}^2 \lambda + \frac{1}{n} \sum_{i=1}^n x_i \tag{1}$$
$$\hat{\sigma}^2 = \frac{1}{n} \sum_{i=1}^n (x_i-\hat{\mu})^2 \tag{2}$$
Primal feasibility:
$$g(\hat{\mu}, \hat{\sigma}^2) \le 0
\implies \hat{\mu} \ge 0$$
This just says the parameters must respect the constraints
Dual feasibility:
$$\lambda \ge 0$$
Complementary slackness:
$$\lambda g(\hat{\mu}, \hat{\sigma}^2) = 0
\implies \lambda \hat{\mu} = 0$$
This says that either $\lambda$ or $\hat{\mu}$ (or both) must be zero.
Solving
Note that the RHS of equation $(1)$ is a multiple of $\lambda$ plus the sample mean $\frac{1}{n} \sum_{i=1}^n x_i$. If the sample mean is non-negative, set $\lambda$ to zero (satisfying the dual feasibility and complementary slackness conditions). It then follows from equation $(1)$ (the stationarity condition) that $\hat{\mu}$ is equal to the sample mean. This also satisfies the primal feasibility condition, since it's non-negative.
Otherwise, if the sample mean is negative, set $\hat{\mu}$ to zero (satisfying the primal feasibility and complementary slackness conditions). To satisfy equation $(1)$ (the stationarity condition), set $\lambda = -\hat{\sigma}^{-2} \sum_{i=1}^n x_i$. Since the sample mean is negative and the variance is positive, $\lambda$ takes a positive value, satisfying the dual feasibility conditionn.
In both cases, we can plug $\hat{\mu}$ into equation $(2)$ to obtain $\hat{\sigma}^2$. | MLE for normal distribution with restrictive parameters
Solution
Let $\bar{x}$ denote the sample mean:
$$\bar{x} = \frac{1}{n} \sum_{i=1}^n x_i$$
The constrained maximum likelihood mean $\hat{\mu}$ and variance $\hat{\sigma}^2$ are:
$$\hat{\mu} = \left\{ \ |
18,331 | MLE for normal distribution with restrictive parameters | (The answer by @user20160 is the principled one, but the asker specified that she does not know about KKT conditions or Lagrange multipliers, so I wanted to avoid those concepts.)
Since there are only two parameters a direct attack will work. The log-likelihood function based on an iid sample of size $n$ is
$$
\ell(\mu,\sigma^2)= -\frac12 n \log( 2\pi) -\frac12 n\log(\sigma^2) - \frac12\sum_i \left( \frac{x_i-\mu}{\sigma} \right)^2
$$
First, consider $\mu$ as known and find the value of $\sigma^2$ that maximizes the likelihood with that value of $\mu$. You will find
$$
\hat{\sigma^2}_\mu = \frac{\sum_i (x_i-\mu)^2}{n}
$$
Then substitute that value into the likelihood function, and the result is the profile (log) likelihood function for $\mu$,
$$
\ell_p(\mu)= \ell(\mu, \hat{\sigma^2}_\mu)
$$ which now only depends on the one parameter $\mu$, and you can maximize it over the interval $(0, \infty)$. Plot it or use a numerical optimization routine. I will leave symbolic solution for you. | MLE for normal distribution with restrictive parameters | (The answer by @user20160 is the principled one, but the asker specified that she does not know about KKT conditions or Lagrange multipliers, so I wanted to avoid those concepts.)
Since there are only | MLE for normal distribution with restrictive parameters
(The answer by @user20160 is the principled one, but the asker specified that she does not know about KKT conditions or Lagrange multipliers, so I wanted to avoid those concepts.)
Since there are only two parameters a direct attack will work. The log-likelihood function based on an iid sample of size $n$ is
$$
\ell(\mu,\sigma^2)= -\frac12 n \log( 2\pi) -\frac12 n\log(\sigma^2) - \frac12\sum_i \left( \frac{x_i-\mu}{\sigma} \right)^2
$$
First, consider $\mu$ as known and find the value of $\sigma^2$ that maximizes the likelihood with that value of $\mu$. You will find
$$
\hat{\sigma^2}_\mu = \frac{\sum_i (x_i-\mu)^2}{n}
$$
Then substitute that value into the likelihood function, and the result is the profile (log) likelihood function for $\mu$,
$$
\ell_p(\mu)= \ell(\mu, \hat{\sigma^2}_\mu)
$$ which now only depends on the one parameter $\mu$, and you can maximize it over the interval $(0, \infty)$. Plot it or use a numerical optimization routine. I will leave symbolic solution for you. | MLE for normal distribution with restrictive parameters
(The answer by @user20160 is the principled one, but the asker specified that she does not know about KKT conditions or Lagrange multipliers, so I wanted to avoid those concepts.)
Since there are only |
18,332 | If each neuron in a neural network is basically a logistic regression function, why multi layer is better? | When using logistic activation functions, it's true that the function relating the inputs of each unit to its output is the same as for logistic regression. But, this isn't really the same as each unit performing logistic regression. The difference is that, in logistic regression, the weights and bias are chosen such that the output best matches given target values (using the log/cross-entropy loss). In contrast, hidden units in a neural net send their outputs to downstream units. There is no target output to match for individual hidden units. Rather, the weights and biases are chosen to minimize some objective function that depends on the final output of the network.
Rather than performing logistic regression, it might make more sense to think of each hidden unit as computing a coordinate in some feature space. From this perspective, the purpose of a hidden layer is to transform its input--the input vector is mapped to a vector of hidden layer activations. You can think of this as mapping the input into a feature space with a dimension corresponding to each hidden unit.
The output layer can often be thought of as a standard learning algorithm that operates in this feature space. For example, in a classification task, using a logistic output unit with cross entropy loss is equivalent to performing logistic regression in feature space (or multinomial logistic regression if using softmax outputs). In a regression task, using a linear output with squared error is equivalent to performing least squares linear regression in feature space.
Training the network amounts to learning the feature space mapping and classification/regression function (in feature space) that, together, give the best performance. Assuming nonlinear hidden units, increasing the width of the hidden layer or stacking multiple hidden layers permits more complex feature space mappings, thereby allowing more complex functions to be fit. | If each neuron in a neural network is basically a logistic regression function, why multi layer is b | When using logistic activation functions, it's true that the function relating the inputs of each unit to its output is the same as for logistic regression. But, this isn't really the same as each uni | If each neuron in a neural network is basically a logistic regression function, why multi layer is better?
When using logistic activation functions, it's true that the function relating the inputs of each unit to its output is the same as for logistic regression. But, this isn't really the same as each unit performing logistic regression. The difference is that, in logistic regression, the weights and bias are chosen such that the output best matches given target values (using the log/cross-entropy loss). In contrast, hidden units in a neural net send their outputs to downstream units. There is no target output to match for individual hidden units. Rather, the weights and biases are chosen to minimize some objective function that depends on the final output of the network.
Rather than performing logistic regression, it might make more sense to think of each hidden unit as computing a coordinate in some feature space. From this perspective, the purpose of a hidden layer is to transform its input--the input vector is mapped to a vector of hidden layer activations. You can think of this as mapping the input into a feature space with a dimension corresponding to each hidden unit.
The output layer can often be thought of as a standard learning algorithm that operates in this feature space. For example, in a classification task, using a logistic output unit with cross entropy loss is equivalent to performing logistic regression in feature space (or multinomial logistic regression if using softmax outputs). In a regression task, using a linear output with squared error is equivalent to performing least squares linear regression in feature space.
Training the network amounts to learning the feature space mapping and classification/regression function (in feature space) that, together, give the best performance. Assuming nonlinear hidden units, increasing the width of the hidden layer or stacking multiple hidden layers permits more complex feature space mappings, thereby allowing more complex functions to be fit. | If each neuron in a neural network is basically a logistic regression function, why multi layer is b
When using logistic activation functions, it's true that the function relating the inputs of each unit to its output is the same as for logistic regression. But, this isn't really the same as each uni |
18,333 | If each neuron in a neural network is basically a logistic regression function, why multi layer is better? | One way to see the power of nonlinearity is to note universal approximation theorem.
Though it's not very significant in practice (it's about capabilities of single layer networks), it tells you that if you use (arbitrary long) sums of sigmoids you can in principle approximate any continuous function to any desired level. If you know Fourier theory or remember Weierstrass approximation theorem it shouldn't be surprising. | If each neuron in a neural network is basically a logistic regression function, why multi layer is b | One way to see the power of nonlinearity is to note universal approximation theorem.
Though it's not very significant in practice (it's about capabilities of single layer networks), it tells you that | If each neuron in a neural network is basically a logistic regression function, why multi layer is better?
One way to see the power of nonlinearity is to note universal approximation theorem.
Though it's not very significant in practice (it's about capabilities of single layer networks), it tells you that if you use (arbitrary long) sums of sigmoids you can in principle approximate any continuous function to any desired level. If you know Fourier theory or remember Weierstrass approximation theorem it shouldn't be surprising. | If each neuron in a neural network is basically a logistic regression function, why multi layer is b
One way to see the power of nonlinearity is to note universal approximation theorem.
Though it's not very significant in practice (it's about capabilities of single layer networks), it tells you that |
18,334 | If each neuron in a neural network is basically a logistic regression function, why multi layer is better? | When there are hidden layers exist in the neural network, we are adding non-linear features. Please check my answer here to get some sense.
what makes neural networks a nonlinear classification model?
Specifically, a nested sigmoid function will be more "powerful" than a linear transformation of original features and one sigmoid function (logistic regression.)
Here is an numerical example to address OP's comments.
Suppose we have data frame $X$, it is a $10 \times 3$ matrix (10 data points, 3 features.). If we want to have $7$ hidden unites, then the weight matrix $W$ is a $3 \times 7$ matrix. The output for the hidden layer (output of matrix multiplication $X \times W$) is a $10 \times 7$ matrix, which for each data point, there are $7$ expended features. | If each neuron in a neural network is basically a logistic regression function, why multi layer is b | When there are hidden layers exist in the neural network, we are adding non-linear features. Please check my answer here to get some sense.
what makes neural networks a nonlinear classification model? | If each neuron in a neural network is basically a logistic regression function, why multi layer is better?
When there are hidden layers exist in the neural network, we are adding non-linear features. Please check my answer here to get some sense.
what makes neural networks a nonlinear classification model?
Specifically, a nested sigmoid function will be more "powerful" than a linear transformation of original features and one sigmoid function (logistic regression.)
Here is an numerical example to address OP's comments.
Suppose we have data frame $X$, it is a $10 \times 3$ matrix (10 data points, 3 features.). If we want to have $7$ hidden unites, then the weight matrix $W$ is a $3 \times 7$ matrix. The output for the hidden layer (output of matrix multiplication $X \times W$) is a $10 \times 7$ matrix, which for each data point, there are $7$ expended features. | If each neuron in a neural network is basically a logistic regression function, why multi layer is b
When there are hidden layers exist in the neural network, we are adding non-linear features. Please check my answer here to get some sense.
what makes neural networks a nonlinear classification model? |
18,335 | If each neuron in a neural network is basically a logistic regression function, why multi layer is better? | In standard logistic regression we have 1 output in the final layer. However with a single hidden layer neural network, we can have multiple intermediate values each of which can be thought of as an output of a different logistic regression model i.e. we are not just performing the same logistic regression again and again. It is then not a large jump to think that it is possible that the combination of these has greater expressive capabilities than the standard logistic regression model (and also has been shown in practice and theory).
You also mention in the comments about how these nodes have different values in the same layer if they have the same inputs? This is because they should have different weights. Each node in a neural network takes $N$ inputs and produces a value $\displaystyle y_j = f\left(\sum_{i = 1}^N w_{ji} \cdot x_i + b_j\right)$ where $f$ is some chosen function, in our case the sigmoid, $w_{ji}$ are the weights, $x_i$ are the inputs, and $b_j$ is some bias. The weights are chosen by an optimisation algorithm to optimise our objective e.g. minimise classification error. Initialisation is very important for the gradient descent algorithms that are usually used to optimise the weights. See https://intoli.com/blog/neural-network-initialization/ where if all the weights start off at 0, the network is unable to learn. | If each neuron in a neural network is basically a logistic regression function, why multi layer is b | In standard logistic regression we have 1 output in the final layer. However with a single hidden layer neural network, we can have multiple intermediate values each of which can be thought of as an o | If each neuron in a neural network is basically a logistic regression function, why multi layer is better?
In standard logistic regression we have 1 output in the final layer. However with a single hidden layer neural network, we can have multiple intermediate values each of which can be thought of as an output of a different logistic regression model i.e. we are not just performing the same logistic regression again and again. It is then not a large jump to think that it is possible that the combination of these has greater expressive capabilities than the standard logistic regression model (and also has been shown in practice and theory).
You also mention in the comments about how these nodes have different values in the same layer if they have the same inputs? This is because they should have different weights. Each node in a neural network takes $N$ inputs and produces a value $\displaystyle y_j = f\left(\sum_{i = 1}^N w_{ji} \cdot x_i + b_j\right)$ where $f$ is some chosen function, in our case the sigmoid, $w_{ji}$ are the weights, $x_i$ are the inputs, and $b_j$ is some bias. The weights are chosen by an optimisation algorithm to optimise our objective e.g. minimise classification error. Initialisation is very important for the gradient descent algorithms that are usually used to optimise the weights. See https://intoli.com/blog/neural-network-initialization/ where if all the weights start off at 0, the network is unable to learn. | If each neuron in a neural network is basically a logistic regression function, why multi layer is b
In standard logistic regression we have 1 output in the final layer. However with a single hidden layer neural network, we can have multiple intermediate values each of which can be thought of as an o |
18,336 | Proof for the standard error of parameters in linear regression | Note $Var(\hat{\beta}_0) = Var(\bar{y} - \hat{\beta}_1\bar{x}) = Var(\bar{y}) + \bar{x}^2Var(\hat{\beta}_1) - 2Cov(\bar{y},\hat{\beta}_1)$. Try to show that the covariance term is 0.
The $Var(\hat{\mu}) = \dfrac{\sigma^2}{n}$ fact (although I'm not a fan of the notation they used here) is used in the calculation, $Var(\bar{y}) = \dfrac{\sigma^2}{n}$. | Proof for the standard error of parameters in linear regression | Note $Var(\hat{\beta}_0) = Var(\bar{y} - \hat{\beta}_1\bar{x}) = Var(\bar{y}) + \bar{x}^2Var(\hat{\beta}_1) - 2Cov(\bar{y},\hat{\beta}_1)$. Try to show that the covariance term is 0.
The $Var(\hat{\m | Proof for the standard error of parameters in linear regression
Note $Var(\hat{\beta}_0) = Var(\bar{y} - \hat{\beta}_1\bar{x}) = Var(\bar{y}) + \bar{x}^2Var(\hat{\beta}_1) - 2Cov(\bar{y},\hat{\beta}_1)$. Try to show that the covariance term is 0.
The $Var(\hat{\mu}) = \dfrac{\sigma^2}{n}$ fact (although I'm not a fan of the notation they used here) is used in the calculation, $Var(\bar{y}) = \dfrac{\sigma^2}{n}$. | Proof for the standard error of parameters in linear regression
Note $Var(\hat{\beta}_0) = Var(\bar{y} - \hat{\beta}_1\bar{x}) = Var(\bar{y}) + \bar{x}^2Var(\hat{\beta}_1) - 2Cov(\bar{y},\hat{\beta}_1)$. Try to show that the covariance term is 0.
The $Var(\hat{\m |
18,337 | Proof for the standard error of parameters in linear regression | Proof for standard error of parameters:
$$\begin{align*}
\mathrm{SE}\left(\hat{\beta}_1\right)^2
&= \mathrm{Var}\left(\frac{\sum_i\left(x_i - \bar{x}\right)\left(y_i - \bar{y}\right)}{\sum_i\left(x_i - \bar{x}\right)^2}\right) \\
&= \mathrm{Var}\left(\frac{\sum_i(x_i - \bar{x})y_i}{\sum_i(x_i - \bar{x})^2}\right) \\
&= \frac{1}{\left(\sum_i\left(x_i - \bar{x}\right)^2\right)^2} \mathrm{Var}\left(\sum_i\left(x_i - \bar{x}\right)y_i\right) \\
&= \frac{1}{\left(\sum_i\left(x_i - \bar{x}\right)^2\right)^2} \sum_i\left(x_i - \bar{x}\right)^2 \mathrm{Var}\left(y_i\right) \\
&= \frac{1}{\left(\sum_i\left(x_i - \bar{x}\right)^2\right)^2} \sum_i\left(x_i - \bar{x}\right)^2\sigma^2 \\
&= \frac{1}{\left(\sum_i\left(x_i - \bar{x}\right)^2\right)^2} \sigma^2\sum_i\left(x_i - \bar{x}\right)^2 \\
&= \frac{\sigma^2}{\sum_i\left(x_i - \bar{x}\right)^2}
\end{align*}$$ | Proof for the standard error of parameters in linear regression | Proof for standard error of parameters:
$$\begin{align*}
\mathrm{SE}\left(\hat{\beta}_1\right)^2
&= \mathrm{Var}\left(\frac{\sum_i\left(x_i - \bar{x}\right)\left(y_i - \bar{y}\right)}{\sum_i\left(x_i | Proof for the standard error of parameters in linear regression
Proof for standard error of parameters:
$$\begin{align*}
\mathrm{SE}\left(\hat{\beta}_1\right)^2
&= \mathrm{Var}\left(\frac{\sum_i\left(x_i - \bar{x}\right)\left(y_i - \bar{y}\right)}{\sum_i\left(x_i - \bar{x}\right)^2}\right) \\
&= \mathrm{Var}\left(\frac{\sum_i(x_i - \bar{x})y_i}{\sum_i(x_i - \bar{x})^2}\right) \\
&= \frac{1}{\left(\sum_i\left(x_i - \bar{x}\right)^2\right)^2} \mathrm{Var}\left(\sum_i\left(x_i - \bar{x}\right)y_i\right) \\
&= \frac{1}{\left(\sum_i\left(x_i - \bar{x}\right)^2\right)^2} \sum_i\left(x_i - \bar{x}\right)^2 \mathrm{Var}\left(y_i\right) \\
&= \frac{1}{\left(\sum_i\left(x_i - \bar{x}\right)^2\right)^2} \sum_i\left(x_i - \bar{x}\right)^2\sigma^2 \\
&= \frac{1}{\left(\sum_i\left(x_i - \bar{x}\right)^2\right)^2} \sigma^2\sum_i\left(x_i - \bar{x}\right)^2 \\
&= \frac{\sigma^2}{\sum_i\left(x_i - \bar{x}\right)^2}
\end{align*}$$ | Proof for the standard error of parameters in linear regression
Proof for standard error of parameters:
$$\begin{align*}
\mathrm{SE}\left(\hat{\beta}_1\right)^2
&= \mathrm{Var}\left(\frac{\sum_i\left(x_i - \bar{x}\right)\left(y_i - \bar{y}\right)}{\sum_i\left(x_i |
18,338 | Proof for the standard error of parameters in linear regression | Once we have @ThorGirl's derivation for $\mathrm{SE}\left(\hat{\beta}_1\right)^2$ we can use that to derive the Standard Error for $\hat{\beta}_0$, i.e. $\mathrm{SE}\left(\hat{\beta}_0\right)^2 $.
Note: If you are looking for a step-by-step explanation of @ThorGirl's
answer take a look at this video.
We are going to use the following assumptions / observations:
Each output $y_i$ is assumed to have the form: $\beta_0 + \beta_1 x_i + \epsilon_i$
$\overline{y} = \frac{1}{n}\sum_{i=1}^{n} y_i$
The error terms $\epsilon_i$ are uncorrelated with constant variance $\sigma^2$
$y_i$, $\hat{\beta}_0$ and $\hat{\beta}_1$ are random variables.
$x_i$ are known constants. $\beta_0$ and $\beta_1$ are the true values of the estimators, hence are also constants.
During the derivation we are going to use the following properties of variance. Here $a$ and $b$ are constants and $X$ and $Y$ are random variables.
$\mathrm{Var}(aX+b) = a^2\mathrm{Var}(X)$
$\mathrm{Var}(aX+bY) = a^2\mathrm{Var}(X) + b^2\mathrm{Var}(y) + 2ab \mathrm{Cov}\left(X,\:Y\right)$
We start with the definition of $\hat{\beta}_0$ :
$$ \hat{\beta}_0 = \overline{y} - \hat{\beta}_1 \overline{x} $$
Therefore we have:
$$ \mathrm{Var}\left(\overline{y} - \hat{\beta}_1 \overline{x}\right) $$
At this point if $\overline{y}$ and $\hat{\beta}_1$ are uncorrelated we can take each term's variance. This uncorrelation is what @Flowsnake's answer refers to.
$$ \mathrm{Var}\left(\overline{y}\right) + \mathrm{Var}\left(-\hat{\beta}_1 \overline{x}\right) $$
As the predictors (inputs) $x_i$ are generally assumed to be known we can treat $\overline{x}$ as a constant.
$$ \mathrm{Var}\left(\overline{y}\right) + \left(-\overline{x}\right)^2 \mathrm{Var}\left(\hat{\beta}_1\right) $$
Using @ThorGirl's answer, we can substitute $\mathrm{Var}\left(\hat{\beta}_1\right)$:
$$ \mathrm{Var}\left(\overline{y}\right) + \overline{x}^2 \frac{\sigma^2}{\sum_{i=1}^n \left(x_i-\overline{x}\right)^2} $$
The following steps will focus on $\mathrm{Var}\left(\overline{y}\right)$. As $y_i$ is not a constant, we must make a few substitutions.
$$ \mathrm{Var}\left(\frac{1}{n} \sum_{i=1}^ny_i\right) + \overline{x}^2 \frac{\sigma^2}{\sum_{i=1}^n \left(x_i-\overline{x}\right)^2} $$
By definition of the statistical model, we can further expand the term.
$$ \mathrm{Var}\left(\frac{1}{n} \sum_{i=1}^n\left(\beta_0 + \beta_1x_i + \epsilon_i\right)\right) + \overline{x}^2 \frac{\sigma^2}{\sum_{i=1}^n \left(x_i-\overline{x}\right)^2} $$
$$ \frac{1}{n^2}\mathrm{Var}\left(\sum_{i=1}^n\left(\beta_0 + \beta_1x_i + \epsilon_i\right)\right) + \overline{x}^2 \frac{\sigma^2}{\sum_{i=1}^n \left(x_i-\overline{x}\right)^2} $$
As $\epsilon_i$ is uncorrelated, the variance of the sum of random variables becomes a sum of individual variances.
$$ \frac{1}{n^2}\sum_{i=1}^n\mathrm{Var}\left(\beta_0 + \beta_1x_i + \epsilon_i\right) + \overline{x}^2 \frac{\sigma^2}{\sum_{i=1}^n \left(x_i-\overline{x}\right)^2} $$
$$ \frac{1}{n^2}\sum_{i=1}^n\mathrm{Var}\left(\epsilon_i\right) + \overline{x}^2 \frac{\sigma^2}{\sum_{i=1}^n \left(x_i-\overline{x}\right)^2} $$
$$ \frac{1}{n^2}\sum_{i=1}^n\sigma^2 + \overline{x}^2 \frac{\sigma^2}{\sum_{i=1}^n \left(x_i-\overline{x}\right)^2} $$
$$ \frac{1}{n}\sigma^2 + \overline{x}^2 \frac{\sigma^2}{\sum_{i=1}^n \left(x_i-\overline{x}\right)^2} $$
$$ \sigma^2 \left[\frac{1}{n} + \frac{\overline{x}^2}{\sum_{i=1}^n\left(x_i - \overline{x}\right)^2}\right] $$ | Proof for the standard error of parameters in linear regression | Once we have @ThorGirl's derivation for $\mathrm{SE}\left(\hat{\beta}_1\right)^2$ we can use that to derive the Standard Error for $\hat{\beta}_0$, i.e. $\mathrm{SE}\left(\hat{\beta}_0\right)^2 $.
No | Proof for the standard error of parameters in linear regression
Once we have @ThorGirl's derivation for $\mathrm{SE}\left(\hat{\beta}_1\right)^2$ we can use that to derive the Standard Error for $\hat{\beta}_0$, i.e. $\mathrm{SE}\left(\hat{\beta}_0\right)^2 $.
Note: If you are looking for a step-by-step explanation of @ThorGirl's
answer take a look at this video.
We are going to use the following assumptions / observations:
Each output $y_i$ is assumed to have the form: $\beta_0 + \beta_1 x_i + \epsilon_i$
$\overline{y} = \frac{1}{n}\sum_{i=1}^{n} y_i$
The error terms $\epsilon_i$ are uncorrelated with constant variance $\sigma^2$
$y_i$, $\hat{\beta}_0$ and $\hat{\beta}_1$ are random variables.
$x_i$ are known constants. $\beta_0$ and $\beta_1$ are the true values of the estimators, hence are also constants.
During the derivation we are going to use the following properties of variance. Here $a$ and $b$ are constants and $X$ and $Y$ are random variables.
$\mathrm{Var}(aX+b) = a^2\mathrm{Var}(X)$
$\mathrm{Var}(aX+bY) = a^2\mathrm{Var}(X) + b^2\mathrm{Var}(y) + 2ab \mathrm{Cov}\left(X,\:Y\right)$
We start with the definition of $\hat{\beta}_0$ :
$$ \hat{\beta}_0 = \overline{y} - \hat{\beta}_1 \overline{x} $$
Therefore we have:
$$ \mathrm{Var}\left(\overline{y} - \hat{\beta}_1 \overline{x}\right) $$
At this point if $\overline{y}$ and $\hat{\beta}_1$ are uncorrelated we can take each term's variance. This uncorrelation is what @Flowsnake's answer refers to.
$$ \mathrm{Var}\left(\overline{y}\right) + \mathrm{Var}\left(-\hat{\beta}_1 \overline{x}\right) $$
As the predictors (inputs) $x_i$ are generally assumed to be known we can treat $\overline{x}$ as a constant.
$$ \mathrm{Var}\left(\overline{y}\right) + \left(-\overline{x}\right)^2 \mathrm{Var}\left(\hat{\beta}_1\right) $$
Using @ThorGirl's answer, we can substitute $\mathrm{Var}\left(\hat{\beta}_1\right)$:
$$ \mathrm{Var}\left(\overline{y}\right) + \overline{x}^2 \frac{\sigma^2}{\sum_{i=1}^n \left(x_i-\overline{x}\right)^2} $$
The following steps will focus on $\mathrm{Var}\left(\overline{y}\right)$. As $y_i$ is not a constant, we must make a few substitutions.
$$ \mathrm{Var}\left(\frac{1}{n} \sum_{i=1}^ny_i\right) + \overline{x}^2 \frac{\sigma^2}{\sum_{i=1}^n \left(x_i-\overline{x}\right)^2} $$
By definition of the statistical model, we can further expand the term.
$$ \mathrm{Var}\left(\frac{1}{n} \sum_{i=1}^n\left(\beta_0 + \beta_1x_i + \epsilon_i\right)\right) + \overline{x}^2 \frac{\sigma^2}{\sum_{i=1}^n \left(x_i-\overline{x}\right)^2} $$
$$ \frac{1}{n^2}\mathrm{Var}\left(\sum_{i=1}^n\left(\beta_0 + \beta_1x_i + \epsilon_i\right)\right) + \overline{x}^2 \frac{\sigma^2}{\sum_{i=1}^n \left(x_i-\overline{x}\right)^2} $$
As $\epsilon_i$ is uncorrelated, the variance of the sum of random variables becomes a sum of individual variances.
$$ \frac{1}{n^2}\sum_{i=1}^n\mathrm{Var}\left(\beta_0 + \beta_1x_i + \epsilon_i\right) + \overline{x}^2 \frac{\sigma^2}{\sum_{i=1}^n \left(x_i-\overline{x}\right)^2} $$
$$ \frac{1}{n^2}\sum_{i=1}^n\mathrm{Var}\left(\epsilon_i\right) + \overline{x}^2 \frac{\sigma^2}{\sum_{i=1}^n \left(x_i-\overline{x}\right)^2} $$
$$ \frac{1}{n^2}\sum_{i=1}^n\sigma^2 + \overline{x}^2 \frac{\sigma^2}{\sum_{i=1}^n \left(x_i-\overline{x}\right)^2} $$
$$ \frac{1}{n}\sigma^2 + \overline{x}^2 \frac{\sigma^2}{\sum_{i=1}^n \left(x_i-\overline{x}\right)^2} $$
$$ \sigma^2 \left[\frac{1}{n} + \frac{\overline{x}^2}{\sum_{i=1}^n\left(x_i - \overline{x}\right)^2}\right] $$ | Proof for the standard error of parameters in linear regression
Once we have @ThorGirl's derivation for $\mathrm{SE}\left(\hat{\beta}_1\right)^2$ we can use that to derive the Standard Error for $\hat{\beta}_0$, i.e. $\mathrm{SE}\left(\hat{\beta}_0\right)^2 $.
No |
18,339 | getting degrees of freedom from lmer | I would instead just create profile likelihood confidence intervals. They’re reliable, and very easy to calculate using the ‘lme4’ package. Example:
> library(lme4)
> fm = lmer(Reaction ~ Days + (Days | Subject),
data=sleepstudy)
> summary(fm)
[…]
Random effects:
Groups Name Variance Std.Dev. Corr
Subject (Intercept) 612.09 24.740
Days 35.07 5.922 0.07
Residual 654.94 25.592
You can now calculate the profile likelihood confidence intervals with the confint() function:
> confint(fm, oldNames=FALSE)
Computing profile confidence intervals ...
2.5 % 97.5 %
sd_(Intercept)|Subject 14.381 37.716
cor_Days.(Intercept)|Subject -0.482 0.685
sd_Days|Subject 3.801 8.753
sigma 22.898 28.858
(Intercept) 237.681 265.130
Days 7.359 13.576
You can also use the parametric bootstrap to calculate confidence intervals. Here’s the R syntax (using the parm argument to restrict which parameters we want confidence intervals for):
> confint(fm, method="boot", nsim=1000, parm=1:3)
Computing bootstrap confidence intervals ...
2.5 % 97.5 %
sd_(Intercept)|Subject 11.886 35.390
cor_Days.(Intercept)|Subject -0.504 0.929
sd_Days|Subject 3.347 8.283
The results will naturally vary somewhat for each run. You can increase nsim to decrease this variation, but this will also increase the time it takes to estimate the confidence intervals. | getting degrees of freedom from lmer | I would instead just create profile likelihood confidence intervals. They’re reliable, and very easy to calculate using the ‘lme4’ package. Example:
> library(lme4)
> fm = lmer(Reaction ~ Days + (Days | getting degrees of freedom from lmer
I would instead just create profile likelihood confidence intervals. They’re reliable, and very easy to calculate using the ‘lme4’ package. Example:
> library(lme4)
> fm = lmer(Reaction ~ Days + (Days | Subject),
data=sleepstudy)
> summary(fm)
[…]
Random effects:
Groups Name Variance Std.Dev. Corr
Subject (Intercept) 612.09 24.740
Days 35.07 5.922 0.07
Residual 654.94 25.592
You can now calculate the profile likelihood confidence intervals with the confint() function:
> confint(fm, oldNames=FALSE)
Computing profile confidence intervals ...
2.5 % 97.5 %
sd_(Intercept)|Subject 14.381 37.716
cor_Days.(Intercept)|Subject -0.482 0.685
sd_Days|Subject 3.801 8.753
sigma 22.898 28.858
(Intercept) 237.681 265.130
Days 7.359 13.576
You can also use the parametric bootstrap to calculate confidence intervals. Here’s the R syntax (using the parm argument to restrict which parameters we want confidence intervals for):
> confint(fm, method="boot", nsim=1000, parm=1:3)
Computing bootstrap confidence intervals ...
2.5 % 97.5 %
sd_(Intercept)|Subject 11.886 35.390
cor_Days.(Intercept)|Subject -0.504 0.929
sd_Days|Subject 3.347 8.283
The results will naturally vary somewhat for each run. You can increase nsim to decrease this variation, but this will also increase the time it takes to estimate the confidence intervals. | getting degrees of freedom from lmer
I would instead just create profile likelihood confidence intervals. They’re reliable, and very easy to calculate using the ‘lme4’ package. Example:
> library(lme4)
> fm = lmer(Reaction ~ Days + (Days |
18,340 | getting degrees of freedom from lmer | Degrees for freedom for mixed-models are "problematic". For reading more on it you can check the lmer, p-values and all that post by Douglas Bates. Also r-sig-mixed-models FAQ summarizes the reasons why it is bothersome:
In general it is not clear that the null distribution of the computed ratio of sums of squares is really an F distribution, for any
choice of denominator degrees of freedom. While this is true for
special cases that correspond to classical experimental designs
(nested, split-plot, randomized block, etc.), it is apparently not
true for more complex designs (unbalanced, GLMMs, temporal or spatial
correlation, etc.).
For each simple degrees-of-freedom recipe that has been suggested (trace of the hat matrix, etc.) there seems to be at least one fairly
simple counterexample where the recipe fails badly.
Other df approximation schemes that have been suggested (Satterthwaite, Kenward-Roger, etc.) would apparently be fairly hard
to implement in lme4/nlme,
(...)
Because the primary authors of lme4 are not convinced of the utility of the general approach of testing with reference to an
approximate null distribution, and because of the overhead of anyone
else digging into the code to enable the relevant functionality (as a
patch or an add-on), this situation is unlikely to change in the
future.
The FAQ gives also some alternatives
use MASS::glmmPQL (uses old nlme rules approximately equivalent to SAS 'inner-outer' rules) for GLMMs, or (n)lme for LMMs
Guess the denominator df from standard rules (for standard designs) and apply them to t or F tests
Run the model in lme (if possible) and use the denominator df reported there (which follow a simple 'inner-outer' rule which should
correspond to the canonical answer for simple/orthogonal designs),
applied to t or F tests. For the explicit specification of the rules
that lme uses, see page 91 of Pinheiro and Bates — this page is
available on Google Books
use SAS, Genstat (AS-REML), Stata?
Assume infinite denominator df (i.e. Z/chi-squared test rather than t/F) if number of groups is large (>45? Various rules of thumb for how
large is "approximately infinite" have been posed, including [in
Angrist and Pischke's ''Mostly Harmless Econometrics''], 42 (in homage
to Douglas Adams)
But if you are interested in confidence intervals there are better approaches, e.g. based on bootstrap as suggested by Karl Ove Hufthammer in his answer, or the ones proposed in the FAQ. | getting degrees of freedom from lmer | Degrees for freedom for mixed-models are "problematic". For reading more on it you can check the lmer, p-values and all that post by Douglas Bates. Also r-sig-mixed-models FAQ summarizes the reasons w | getting degrees of freedom from lmer
Degrees for freedom for mixed-models are "problematic". For reading more on it you can check the lmer, p-values and all that post by Douglas Bates. Also r-sig-mixed-models FAQ summarizes the reasons why it is bothersome:
In general it is not clear that the null distribution of the computed ratio of sums of squares is really an F distribution, for any
choice of denominator degrees of freedom. While this is true for
special cases that correspond to classical experimental designs
(nested, split-plot, randomized block, etc.), it is apparently not
true for more complex designs (unbalanced, GLMMs, temporal or spatial
correlation, etc.).
For each simple degrees-of-freedom recipe that has been suggested (trace of the hat matrix, etc.) there seems to be at least one fairly
simple counterexample where the recipe fails badly.
Other df approximation schemes that have been suggested (Satterthwaite, Kenward-Roger, etc.) would apparently be fairly hard
to implement in lme4/nlme,
(...)
Because the primary authors of lme4 are not convinced of the utility of the general approach of testing with reference to an
approximate null distribution, and because of the overhead of anyone
else digging into the code to enable the relevant functionality (as a
patch or an add-on), this situation is unlikely to change in the
future.
The FAQ gives also some alternatives
use MASS::glmmPQL (uses old nlme rules approximately equivalent to SAS 'inner-outer' rules) for GLMMs, or (n)lme for LMMs
Guess the denominator df from standard rules (for standard designs) and apply them to t or F tests
Run the model in lme (if possible) and use the denominator df reported there (which follow a simple 'inner-outer' rule which should
correspond to the canonical answer for simple/orthogonal designs),
applied to t or F tests. For the explicit specification of the rules
that lme uses, see page 91 of Pinheiro and Bates — this page is
available on Google Books
use SAS, Genstat (AS-REML), Stata?
Assume infinite denominator df (i.e. Z/chi-squared test rather than t/F) if number of groups is large (>45? Various rules of thumb for how
large is "approximately infinite" have been posed, including [in
Angrist and Pischke's ''Mostly Harmless Econometrics''], 42 (in homage
to Douglas Adams)
But if you are interested in confidence intervals there are better approaches, e.g. based on bootstrap as suggested by Karl Ove Hufthammer in his answer, or the ones proposed in the FAQ. | getting degrees of freedom from lmer
Degrees for freedom for mixed-models are "problematic". For reading more on it you can check the lmer, p-values and all that post by Douglas Bates. Also r-sig-mixed-models FAQ summarizes the reasons w |
18,341 | What is the importance of hat matrix, $H=X(X^\top X)^{-1} X^\top$, in linear regression? | In the study of linear regression, the basic starting point is the data generating process
$ \textbf{y= XB + u} \quad $
where $ \textbf{u} \sim N(0,\sigma^2 \boldsymbol I) $ and $\textbf{X}$ deterministic. After minimizing the least squares criterion, one finds an estimator $ \widehat {\textbf{B} }$ for $\textbf{B}$, i. e. $ \widehat {\textbf{B}}= ( \textbf{X} ' \textbf{X})^{-1}\textbf{X} '\textbf{y}$. After plugging in the estimator in the initial formula, one gets $\widehat {\textbf{y}}=\textbf{X}\widehat {\textbf{B}}$ as a linear model of the data generating process. Now, one can substitute the estimator for $\widehat {\textbf{B}}$ and gets $\widehat {\textbf{y}}=\textbf{X}( \textbf{X} ' \textbf{X})^{-1}\textbf{X} '\textbf{y}.$
So, $\textbf{H} = \textbf{X}( \textbf{X} ' \textbf{X})^{-1}\textbf{X} '$ is actually a projection matrix. Imagine you take all variables in $\textbf{X}$. The variables are vectors and span a space. Hence, if you multiply $\textbf{H}$ by $\textbf{y}$, you project your observed values in $\textbf{y}$ onto the space that is spanned by the variables in $\textbf{X}$. It gives one the estimates for $\textbf{y}$ and that is the reason why it is called hat matrix and why it has such an importance. After all, linear regression is nothing more than a projection and with the projection matrix we cannot only calculate the estimates for $\textbf{y}$ but also for $\textbf{u}$ and can for example check whether it is really normally distributed.
I found this nice picture on the internet and it visualizes this projection. Please note, $\beta$ is used instead of $\textbf{B}$. Moreover, the picture emphasizes the vector of the error terms is orthogonal to the projection and hence not correlated with the estimates for $\textbf{y}$ | What is the importance of hat matrix, $H=X(X^\top X)^{-1} X^\top$, in linear regression? | In the study of linear regression, the basic starting point is the data generating process
$ \textbf{y= XB + u} \quad $
where $ \textbf{u} \sim N(0,\sigma^2 \boldsymbol I) $ and $\textbf{X}$ det | What is the importance of hat matrix, $H=X(X^\top X)^{-1} X^\top$, in linear regression?
In the study of linear regression, the basic starting point is the data generating process
$ \textbf{y= XB + u} \quad $
where $ \textbf{u} \sim N(0,\sigma^2 \boldsymbol I) $ and $\textbf{X}$ deterministic. After minimizing the least squares criterion, one finds an estimator $ \widehat {\textbf{B} }$ for $\textbf{B}$, i. e. $ \widehat {\textbf{B}}= ( \textbf{X} ' \textbf{X})^{-1}\textbf{X} '\textbf{y}$. After plugging in the estimator in the initial formula, one gets $\widehat {\textbf{y}}=\textbf{X}\widehat {\textbf{B}}$ as a linear model of the data generating process. Now, one can substitute the estimator for $\widehat {\textbf{B}}$ and gets $\widehat {\textbf{y}}=\textbf{X}( \textbf{X} ' \textbf{X})^{-1}\textbf{X} '\textbf{y}.$
So, $\textbf{H} = \textbf{X}( \textbf{X} ' \textbf{X})^{-1}\textbf{X} '$ is actually a projection matrix. Imagine you take all variables in $\textbf{X}$. The variables are vectors and span a space. Hence, if you multiply $\textbf{H}$ by $\textbf{y}$, you project your observed values in $\textbf{y}$ onto the space that is spanned by the variables in $\textbf{X}$. It gives one the estimates for $\textbf{y}$ and that is the reason why it is called hat matrix and why it has such an importance. After all, linear regression is nothing more than a projection and with the projection matrix we cannot only calculate the estimates for $\textbf{y}$ but also for $\textbf{u}$ and can for example check whether it is really normally distributed.
I found this nice picture on the internet and it visualizes this projection. Please note, $\beta$ is used instead of $\textbf{B}$. Moreover, the picture emphasizes the vector of the error terms is orthogonal to the projection and hence not correlated with the estimates for $\textbf{y}$ | What is the importance of hat matrix, $H=X(X^\top X)^{-1} X^\top$, in linear regression?
In the study of linear regression, the basic starting point is the data generating process
$ \textbf{y= XB + u} \quad $
where $ \textbf{u} \sim N(0,\sigma^2 \boldsymbol I) $ and $\textbf{X}$ det |
18,342 | What is the importance of hat matrix, $H=X(X^\top X)^{-1} X^\top$, in linear regression? | The hat matrix is very useful for a few reasons:
Instead of having $\widehat{y}=Z\widehat{\beta}$, we get that $\widehat{y}=Py$ where $P$ is the hat matrix. This gives us that $\widehat{y}$ is a linear mapping of the observed values.
From the hat matrix $P$, it is easy to calculate the residuals $\widehat{\epsilon}$. We see that $\widehat{\epsilon}=y-\widehat{y}=y-Py=\left(I_n-P\right)y$. | What is the importance of hat matrix, $H=X(X^\top X)^{-1} X^\top$, in linear regression? | The hat matrix is very useful for a few reasons:
Instead of having $\widehat{y}=Z\widehat{\beta}$, we get that $\widehat{y}=Py$ where $P$ is the hat matrix. This gives us that $\widehat{y}$ is a line | What is the importance of hat matrix, $H=X(X^\top X)^{-1} X^\top$, in linear regression?
The hat matrix is very useful for a few reasons:
Instead of having $\widehat{y}=Z\widehat{\beta}$, we get that $\widehat{y}=Py$ where $P$ is the hat matrix. This gives us that $\widehat{y}$ is a linear mapping of the observed values.
From the hat matrix $P$, it is easy to calculate the residuals $\widehat{\epsilon}$. We see that $\widehat{\epsilon}=y-\widehat{y}=y-Py=\left(I_n-P\right)y$. | What is the importance of hat matrix, $H=X(X^\top X)^{-1} X^\top$, in linear regression?
The hat matrix is very useful for a few reasons:
Instead of having $\widehat{y}=Z\widehat{\beta}$, we get that $\widehat{y}=Py$ where $P$ is the hat matrix. This gives us that $\widehat{y}$ is a line |
18,343 | What is the importance of hat matrix, $H=X(X^\top X)^{-1} X^\top$, in linear regression? | It's nothing more than finding the "closest" solution for Ax = b where b is not in the column space of A. We project b onto the column space, and solve for Ax(hat) = p where p is the projection of b onto column space. | What is the importance of hat matrix, $H=X(X^\top X)^{-1} X^\top$, in linear regression? | It's nothing more than finding the "closest" solution for Ax = b where b is not in the column space of A. We project b onto the column space, and solve for Ax(hat) = p where p is the projection of b o | What is the importance of hat matrix, $H=X(X^\top X)^{-1} X^\top$, in linear regression?
It's nothing more than finding the "closest" solution for Ax = b where b is not in the column space of A. We project b onto the column space, and solve for Ax(hat) = p where p is the projection of b onto column space. | What is the importance of hat matrix, $H=X(X^\top X)^{-1} X^\top$, in linear regression?
It's nothing more than finding the "closest" solution for Ax = b where b is not in the column space of A. We project b onto the column space, and solve for Ax(hat) = p where p is the projection of b o |
18,344 | How to compare the strength of two Pearson correlations? | (I assume you're talking about r's obtained from a sample.)
The test on that website applies in the sense that it treats r like any parameter whose value may differ between two populations. How is r any different from any other measure, such as the mean, which you're very confident in comparing, using the t-test? Well, it's different in that it's bound between -1,1, it doesn't have the proper distribution, so you need to Fisher transform it before doing inference (and back transform it afterwards, if you want to e.g. get a CI). The z scores resulting from the test do have the proper form to do inference on. That's what the test you're linking to is doing.
So what you link to is a procedure of inferring what might happen if you could get the r for the entirety of the population(s) from which you're sampling - would the r for one group be higher than for the other, or would they be precisely the same? Let's call this later hypothesis H$_0$. If the test returns a low p value, it implies that based on your sample, you should have little confidence in the hypothesis that the true value for the difference between the two r's would be exactly 0 (as such data would occur rarely if the difference in r was exactly 0). If not, you do not have the data to reject, with confidence, this hypothesis of precisely equal r, either because it is true and/or because your sample is insufficient.
Note that I could have done the same story about the difference in means (using the t-test), or any other measure.
A completely different question is if the difference between the two would be meaningful. Sadly, there is no straight-forward answer to this, and no statistical test can give you the answer. Maybe the true value (the population value, not the one you observe) of r is .5 in one, and .47 in the other group. In this case, the statistical hypothesis of their equivalence (our H$_0$) would be false. But is this a meaningful difference? It depends - is something on the order of 3% more explained variance meaningful, or meaningless?
Cohen has given rough guidelines for interpreting r (and presumably, differences between r's), but did so only under the advice that these are nothing but a starting point. And you do not even know the exact difference, even if you do some inference, e.g. by calculating the CI for the differences between the two correlations. Most likely, a range of possible differences will be compatible with your data.
A comparatively safe bet would be computing the confidence intervals for your r's and possibly the CI for their difference, and letting the reader decide. | How to compare the strength of two Pearson correlations? | (I assume you're talking about r's obtained from a sample.)
The test on that website applies in the sense that it treats r like any parameter whose value may differ between two populations. How is r a | How to compare the strength of two Pearson correlations?
(I assume you're talking about r's obtained from a sample.)
The test on that website applies in the sense that it treats r like any parameter whose value may differ between two populations. How is r any different from any other measure, such as the mean, which you're very confident in comparing, using the t-test? Well, it's different in that it's bound between -1,1, it doesn't have the proper distribution, so you need to Fisher transform it before doing inference (and back transform it afterwards, if you want to e.g. get a CI). The z scores resulting from the test do have the proper form to do inference on. That's what the test you're linking to is doing.
So what you link to is a procedure of inferring what might happen if you could get the r for the entirety of the population(s) from which you're sampling - would the r for one group be higher than for the other, or would they be precisely the same? Let's call this later hypothesis H$_0$. If the test returns a low p value, it implies that based on your sample, you should have little confidence in the hypothesis that the true value for the difference between the two r's would be exactly 0 (as such data would occur rarely if the difference in r was exactly 0). If not, you do not have the data to reject, with confidence, this hypothesis of precisely equal r, either because it is true and/or because your sample is insufficient.
Note that I could have done the same story about the difference in means (using the t-test), or any other measure.
A completely different question is if the difference between the two would be meaningful. Sadly, there is no straight-forward answer to this, and no statistical test can give you the answer. Maybe the true value (the population value, not the one you observe) of r is .5 in one, and .47 in the other group. In this case, the statistical hypothesis of their equivalence (our H$_0$) would be false. But is this a meaningful difference? It depends - is something on the order of 3% more explained variance meaningful, or meaningless?
Cohen has given rough guidelines for interpreting r (and presumably, differences between r's), but did so only under the advice that these are nothing but a starting point. And you do not even know the exact difference, even if you do some inference, e.g. by calculating the CI for the differences between the two correlations. Most likely, a range of possible differences will be compatible with your data.
A comparatively safe bet would be computing the confidence intervals for your r's and possibly the CI for their difference, and letting the reader decide. | How to compare the strength of two Pearson correlations?
(I assume you're talking about r's obtained from a sample.)
The test on that website applies in the sense that it treats r like any parameter whose value may differ between two populations. How is r a |
18,345 | Cut-off point in a ROC curve. Is there a simple function? | You want to compute the Youden Index, and find the highest one in your ROC curve.
Have a look at the OptimalCutpoints and cutpointr packages for R. If you're doing ROC analysis, you can also use the coords function of pROC (a little bit of self-advertisement here):
library(pROC)
data(aSAH)
rocobj <- roc(aSAH$outcome, aSAH$s100b)
coords(rocobj, "best")
coords(rocobj, x="best", input="threshold", best.method="youden") # Same than last line | Cut-off point in a ROC curve. Is there a simple function? | You want to compute the Youden Index, and find the highest one in your ROC curve.
Have a look at the OptimalCutpoints and cutpointr packages for R. If you're doing ROC analysis, you can also use the c | Cut-off point in a ROC curve. Is there a simple function?
You want to compute the Youden Index, and find the highest one in your ROC curve.
Have a look at the OptimalCutpoints and cutpointr packages for R. If you're doing ROC analysis, you can also use the coords function of pROC (a little bit of self-advertisement here):
library(pROC)
data(aSAH)
rocobj <- roc(aSAH$outcome, aSAH$s100b)
coords(rocobj, "best")
coords(rocobj, x="best", input="threshold", best.method="youden") # Same than last line | Cut-off point in a ROC curve. Is there a simple function?
You want to compute the Youden Index, and find the highest one in your ROC curve.
Have a look at the OptimalCutpoints and cutpointr packages for R. If you're doing ROC analysis, you can also use the c |
18,346 | Cut-off point in a ROC curve. Is there a simple function? | As @COOLSerdash mentioned there is a good R package ROCR for doing this kind of analysis.
But my answer is that it is not possible to make an cut-off decision solely based on some information metric.
You should specify a true loss function which has its parameters based on some relative value of various misclassifications. It is easy then to select a cut-off point which maximizes gains or minimizes losses. | Cut-off point in a ROC curve. Is there a simple function? | As @COOLSerdash mentioned there is a good R package ROCR for doing this kind of analysis.
But my answer is that it is not possible to make an cut-off decision solely based on some information metric | Cut-off point in a ROC curve. Is there a simple function?
As @COOLSerdash mentioned there is a good R package ROCR for doing this kind of analysis.
But my answer is that it is not possible to make an cut-off decision solely based on some information metric.
You should specify a true loss function which has its parameters based on some relative value of various misclassifications. It is easy then to select a cut-off point which maximizes gains or minimizes losses. | Cut-off point in a ROC curve. Is there a simple function?
As @COOLSerdash mentioned there is a good R package ROCR for doing this kind of analysis.
But my answer is that it is not possible to make an cut-off decision solely based on some information metric |
18,347 | Intuition Behind Completeness [duplicate] | For completeness
Recall if $E(f(x)) = u$ then $f(x)$ is an unbiased estimate of $u$.
Now so will $g(x) = f(x) + h(x)$ if $E(h(x)) = 0$
So its to assure that $f(x)$ is the unique unbiased estimate.
(The rest and many fine details I have forgotten.)
For sufficiency
The easiest way to appreciate sufficiency is via the relative belief ratio which is just the posterior probability divided by the prior probabilty (this is k * likelihood) calculated via ABC or two stage simulation. After conditioning on a sufficent statistic, conditioning on anything further does not change the posterior distribution. If two different statistics are sufficient, conditioning on either will give the same posterior distribution and the minimal sufficent statistic will give the best approximation of the same posterior distribution. But if this is for a course this will likely just be distracting as you will likely need to answer in terms of that statistic indexing the likelihood function. | Intuition Behind Completeness [duplicate] | For completeness
Recall if $E(f(x)) = u$ then $f(x)$ is an unbiased estimate of $u$.
Now so will $g(x) = f(x) + h(x)$ if $E(h(x)) = 0$
So its to assure that $f(x)$ is the unique unbiased estimate.
| Intuition Behind Completeness [duplicate]
For completeness
Recall if $E(f(x)) = u$ then $f(x)$ is an unbiased estimate of $u$.
Now so will $g(x) = f(x) + h(x)$ if $E(h(x)) = 0$
So its to assure that $f(x)$ is the unique unbiased estimate.
(The rest and many fine details I have forgotten.)
For sufficiency
The easiest way to appreciate sufficiency is via the relative belief ratio which is just the posterior probability divided by the prior probabilty (this is k * likelihood) calculated via ABC or two stage simulation. After conditioning on a sufficent statistic, conditioning on anything further does not change the posterior distribution. If two different statistics are sufficient, conditioning on either will give the same posterior distribution and the minimal sufficent statistic will give the best approximation of the same posterior distribution. But if this is for a course this will likely just be distracting as you will likely need to answer in terms of that statistic indexing the likelihood function. | Intuition Behind Completeness [duplicate]
For completeness
Recall if $E(f(x)) = u$ then $f(x)$ is an unbiased estimate of $u$.
Now so will $g(x) = f(x) + h(x)$ if $E(h(x)) = 0$
So its to assure that $f(x)$ is the unique unbiased estimate.
|
18,348 | Intuition Behind Completeness [duplicate] | By virtue of the Rao-Blackwell theorem, if $\delta(x)$ is an unbiased estimator of $h(\theta)$ and $S$ is a sufficient statistic, then
$$
\mathbb{E}[\delta(X)|S(X)=s] = \delta^*(s)
$$
is a "better" estimator in the sense that it has a smaller variance while being still unbiased. In this restricted sense, using only a sufficient statistic makes sense. (However, the remainder of the data can help in estimating the precision of this estimator and so cannot be discarded.)
When $S$ is in addition complete, there can only be one unbiased estimator based on $S$, as pointed out by phaneron. Following from the Lehmann–Scheffé theorem, this is the best unbiased estimator. | Intuition Behind Completeness [duplicate] | By virtue of the Rao-Blackwell theorem, if $\delta(x)$ is an unbiased estimator of $h(\theta)$ and $S$ is a sufficient statistic, then
$$
\mathbb{E}[\delta(X)|S(X)=s] = \delta^*(s)
$$
is a "better" es | Intuition Behind Completeness [duplicate]
By virtue of the Rao-Blackwell theorem, if $\delta(x)$ is an unbiased estimator of $h(\theta)$ and $S$ is a sufficient statistic, then
$$
\mathbb{E}[\delta(X)|S(X)=s] = \delta^*(s)
$$
is a "better" estimator in the sense that it has a smaller variance while being still unbiased. In this restricted sense, using only a sufficient statistic makes sense. (However, the remainder of the data can help in estimating the precision of this estimator and so cannot be discarded.)
When $S$ is in addition complete, there can only be one unbiased estimator based on $S$, as pointed out by phaneron. Following from the Lehmann–Scheffé theorem, this is the best unbiased estimator. | Intuition Behind Completeness [duplicate]
By virtue of the Rao-Blackwell theorem, if $\delta(x)$ is an unbiased estimator of $h(\theta)$ and $S$ is a sufficient statistic, then
$$
\mathbb{E}[\delta(X)|S(X)=s] = \delta^*(s)
$$
is a "better" es |
18,349 | How to estimate the third quartile of binned data? | You need to fit these binned data with some distributional model, for that is the only way to extrapolate into the upper quartile.
A model
By definition, such a model is given by a cadlag function $F$ rising from $0$ to $1$. The probability it assigns to any interval $(a,b]$ is $F(b)-F(a)$. To make the fit, you need to posit a family of possible functions indexed by a (vector) parameter $\theta$, $\{F_\theta\}$. Assuming that the sample summarizes a collection of people chosen randomly and independently from a population described by some specific (but unknown) $F_\theta$, the probability of the sample (or likelihood, $L$) is the product of the individual probabilities. In the example, it would equal
$$L(\theta) = (F_\theta(8) - F_\theta(6))^{51} (F_\theta(10) - F_\theta(8))^{65} \cdots (F_\theta(\infty) - F_\theta(16))^{182}$$
because $51$ of the people have associated probabilities $F_\theta(8) - F_\theta(6)$, $65$ have probabilities $F_\theta(10) - F_\theta(8)$, and so on.
Fitting the model to the data
The Maximum Likelihood estimate of $\theta$ is a value which maximizes $L$ (or, equivalently, the logarithm of $L$).
Income distributions are often modeled by lognormal distributions (see, for example, http://gdrs.sourceforge.net/docs/PoleStar_TechNote_4.pdf). Writing $\theta = (\mu,\sigma)$, the family of lognormal distributions is
$$F_{(\mu, \sigma)}(x) = \frac{1}{\sqrt{2\pi}}\int_{-\infty}^{(\log(x)-\mu)/\sigma} \exp(-t^2/2) dt.$$
For this family (and many others) it is straightforward to optimize $L$ numerically. For instance, in R we would write a function to compute $\log(L(\theta))$ and then optimize it, because the maximum of $\log(L)$ coincides with the maximum of $L$ itself and (usually) $\log(L)$ is simpler to calculate and numerically more stable to work with:
logL <- function(thresh, pop, mu, sigma) {
l <- function(x1, x2) ifelse(is.na(x2), 1, pnorm(log(x2), mean=mu, sd=sigma))
- pnorm(log(x1), mean=mu, sd=sigma)
logl <- function(n, x1, x2) n * log(l(x1, x2))
sum(mapply(logl, pop, thresh, c(thresh[-1], NA)))
}
thresh <- c(6,8,10,12,14,16)
pop <- c(51,65,68,82,78,182)
fit <- optim(c(0,1), function(theta) -logL(thresh, pop, theta[1], theta[2]))
The solution in this example is $\theta = (\mu,\sigma)=(2.620945, 0.379682)$, found in the value fit$par.
Checking model assumptions
We need at least to check how well this conforms to the assumed lognormality, so we write a function to compute $F$:
predict <- function(a, b, mu, sigma, n) {
n * ( ifelse(is.na(b), 1, pnorm(log(b), mean=mu, sd=sigma))
- pnorm(log(a), mean=mu, sd=sigma) )
It is applied to the data to obtain the fitted or "predicted" bin populations:
pred <- mapply(function(a,b) predict(a,b,fit$par[1], fit$par[2], sum(pop)),
thresh, c(thresh[-1], NA))
We can draw histograms of the data and the prediction to compare them visually, shown in the first row of these plots:
To compare them, we can compute a chi-squared statistic. This is usually referred to a chi-squared distribution to assess significance:
chisq <- sum((pred-pop)^2 / pred)
df <- length(pop) - 2 - 1
pchisq(chisq, df, lower.tail=FALSE)
The "p-value" of $0.0035$ is small enough to make many people feel the fit isn't good. Looking at the plots, the problem evidently focuses in the lowest $6-8$ bin. Perhaps the lower terminus should have been zero? If, in an exploratory fashion, we were to reduce the $6$ to anything less than $3$, we would obtain the fit shown in the bottom row of plots. The chi-squared p-value is now $0.26$, indicating (hypothetically, because we're purely in an exploratory mode now) that this statistic finds no significant difference between the data and the fit.
Using the fit to estimate quantiles
If we accept, then, that (1) the incomes are approximately lognormally distributed and (2) the lower limit of the incomes is less than $6$ (say $3$), then the maximum likelihood estimate is $(\mu, \sigma)$ = $(2.620334, 0.405454)$. Using these parameters we can invert $F$ to obtain the $75^{\text{th}}$ percentile:
exp(qnorm(.75, mean=fit$par[1], sd=fit$par[2]))
The value is $18.06$. (Had we not changed the lower limit of the first bin from $6$ to $3$, we would have obtained instead $17.76$.)
These procedures and this code can be applied in general. The theory of maximum likelihood can be further exploited to compute a confidence interval around the third quartile, if that is of interest. | How to estimate the third quartile of binned data? | You need to fit these binned data with some distributional model, for that is the only way to extrapolate into the upper quartile.
A model
By definition, such a model is given by a cadlag function $F$ | How to estimate the third quartile of binned data?
You need to fit these binned data with some distributional model, for that is the only way to extrapolate into the upper quartile.
A model
By definition, such a model is given by a cadlag function $F$ rising from $0$ to $1$. The probability it assigns to any interval $(a,b]$ is $F(b)-F(a)$. To make the fit, you need to posit a family of possible functions indexed by a (vector) parameter $\theta$, $\{F_\theta\}$. Assuming that the sample summarizes a collection of people chosen randomly and independently from a population described by some specific (but unknown) $F_\theta$, the probability of the sample (or likelihood, $L$) is the product of the individual probabilities. In the example, it would equal
$$L(\theta) = (F_\theta(8) - F_\theta(6))^{51} (F_\theta(10) - F_\theta(8))^{65} \cdots (F_\theta(\infty) - F_\theta(16))^{182}$$
because $51$ of the people have associated probabilities $F_\theta(8) - F_\theta(6)$, $65$ have probabilities $F_\theta(10) - F_\theta(8)$, and so on.
Fitting the model to the data
The Maximum Likelihood estimate of $\theta$ is a value which maximizes $L$ (or, equivalently, the logarithm of $L$).
Income distributions are often modeled by lognormal distributions (see, for example, http://gdrs.sourceforge.net/docs/PoleStar_TechNote_4.pdf). Writing $\theta = (\mu,\sigma)$, the family of lognormal distributions is
$$F_{(\mu, \sigma)}(x) = \frac{1}{\sqrt{2\pi}}\int_{-\infty}^{(\log(x)-\mu)/\sigma} \exp(-t^2/2) dt.$$
For this family (and many others) it is straightforward to optimize $L$ numerically. For instance, in R we would write a function to compute $\log(L(\theta))$ and then optimize it, because the maximum of $\log(L)$ coincides with the maximum of $L$ itself and (usually) $\log(L)$ is simpler to calculate and numerically more stable to work with:
logL <- function(thresh, pop, mu, sigma) {
l <- function(x1, x2) ifelse(is.na(x2), 1, pnorm(log(x2), mean=mu, sd=sigma))
- pnorm(log(x1), mean=mu, sd=sigma)
logl <- function(n, x1, x2) n * log(l(x1, x2))
sum(mapply(logl, pop, thresh, c(thresh[-1], NA)))
}
thresh <- c(6,8,10,12,14,16)
pop <- c(51,65,68,82,78,182)
fit <- optim(c(0,1), function(theta) -logL(thresh, pop, theta[1], theta[2]))
The solution in this example is $\theta = (\mu,\sigma)=(2.620945, 0.379682)$, found in the value fit$par.
Checking model assumptions
We need at least to check how well this conforms to the assumed lognormality, so we write a function to compute $F$:
predict <- function(a, b, mu, sigma, n) {
n * ( ifelse(is.na(b), 1, pnorm(log(b), mean=mu, sd=sigma))
- pnorm(log(a), mean=mu, sd=sigma) )
It is applied to the data to obtain the fitted or "predicted" bin populations:
pred <- mapply(function(a,b) predict(a,b,fit$par[1], fit$par[2], sum(pop)),
thresh, c(thresh[-1], NA))
We can draw histograms of the data and the prediction to compare them visually, shown in the first row of these plots:
To compare them, we can compute a chi-squared statistic. This is usually referred to a chi-squared distribution to assess significance:
chisq <- sum((pred-pop)^2 / pred)
df <- length(pop) - 2 - 1
pchisq(chisq, df, lower.tail=FALSE)
The "p-value" of $0.0035$ is small enough to make many people feel the fit isn't good. Looking at the plots, the problem evidently focuses in the lowest $6-8$ bin. Perhaps the lower terminus should have been zero? If, in an exploratory fashion, we were to reduce the $6$ to anything less than $3$, we would obtain the fit shown in the bottom row of plots. The chi-squared p-value is now $0.26$, indicating (hypothetically, because we're purely in an exploratory mode now) that this statistic finds no significant difference between the data and the fit.
Using the fit to estimate quantiles
If we accept, then, that (1) the incomes are approximately lognormally distributed and (2) the lower limit of the incomes is less than $6$ (say $3$), then the maximum likelihood estimate is $(\mu, \sigma)$ = $(2.620334, 0.405454)$. Using these parameters we can invert $F$ to obtain the $75^{\text{th}}$ percentile:
exp(qnorm(.75, mean=fit$par[1], sd=fit$par[2]))
The value is $18.06$. (Had we not changed the lower limit of the first bin from $6$ to $3$, we would have obtained instead $17.76$.)
These procedures and this code can be applied in general. The theory of maximum likelihood can be further exploited to compute a confidence interval around the third quartile, if that is of interest. | How to estimate the third quartile of binned data?
You need to fit these binned data with some distributional model, for that is the only way to extrapolate into the upper quartile.
A model
By definition, such a model is given by a cadlag function $F$ |
18,350 | How to estimate the third quartile of binned data? | Too long for a comment:
whubers's answer is as good as any, but he does assume right-skewness in his log-normal model. This may be realistic for incomes over a general population, but may not be for incomes for a single employer at a particular grade.
You could alternatively choose to model the distribution as being roughly symmetric in which case you might put about $68$ into the range 16-18, $64$ into 18-20 and $50$ into range 22-24 and this would give you a third quartile estimate of around $17.5$.
You would have a lower estimate if you chose to continue the frequency at about $80$ per double unit which would give you a third quartile estimate of around $17.3$.
Higher estimates are possible with other assumptions. So my conclusion would be that the third quartile point is likely to be above $17$, but that you really do not have enough data to make an accurate estimate without knowing (or assuming) more about the distribution of income at the top end, and that is precisely what you do not know. | How to estimate the third quartile of binned data? | Too long for a comment:
whubers's answer is as good as any, but he does assume right-skewness in his log-normal model. This may be realistic for incomes over a general population, but may not be for | How to estimate the third quartile of binned data?
Too long for a comment:
whubers's answer is as good as any, but he does assume right-skewness in his log-normal model. This may be realistic for incomes over a general population, but may not be for incomes for a single employer at a particular grade.
You could alternatively choose to model the distribution as being roughly symmetric in which case you might put about $68$ into the range 16-18, $64$ into 18-20 and $50$ into range 22-24 and this would give you a third quartile estimate of around $17.5$.
You would have a lower estimate if you chose to continue the frequency at about $80$ per double unit which would give you a third quartile estimate of around $17.3$.
Higher estimates are possible with other assumptions. So my conclusion would be that the third quartile point is likely to be above $17$, but that you really do not have enough data to make an accurate estimate without knowing (or assuming) more about the distribution of income at the top end, and that is precisely what you do not know. | How to estimate the third quartile of binned data?
Too long for a comment:
whubers's answer is as good as any, but he does assume right-skewness in his log-normal model. This may be realistic for incomes over a general population, but may not be for |
18,351 | How to obtain the results of a Tukey HSD post-hoc test in a table showing grouped pairs? | The agricolae::HSD.test function does exactly that, but you will need to let it know that you are interested in an interaction term. Here is an example with a Stata dataset:
library(foreign)
yield <- read.dta("http://www.stata-press.com/data/r12/yield.dta")
tx <- with(yield, interaction(fertilizer, irrigation))
amod <- aov(yield ~ tx, data=yield)
library(agricolae)
HSD.test(amod, "tx", group=TRUE)
This gives the results shown below:
Groups, Treatments and means
a 2.1 51.17547
ab 4.1 50.7529
abc 3.1 47.36229
bcd 1.1 45.81229
cd 5.1 44.55313
de 4.0 41.81757
ef 2.0 38.79482
ef 1.0 36.91257
f 3.0 36.34383
f 5.0 35.69507
They match what we would obtain with the following commands:
. webuse yield
. regress yield fertilizer##irrigation
. pwcompare fertilizer#irrigation, group mcompare(tukey)
-------------------------------------------------------
| Tukey
| Margin Std. Err. Groups
----------------------+--------------------------------
fertilizer#irrigation |
1 0 | 36.91257 1.116571 AB
1 1 | 45.81229 1.116571 CDE
2 0 | 38.79482 1.116571 AB
2 1 | 51.17547 1.116571 F
3 0 | 36.34383 1.116571 A
3 1 | 47.36229 1.116571 DEF
4 0 | 41.81757 1.116571 BC
4 1 | 50.7529 1.116571 EF
5 0 | 35.69507 1.116571 A
5 1 | 44.55313 1.116571 CD
-------------------------------------------------------
Note: Margins sharing a letter in the group label are
not significantly different at the 5% level.
The multcomp package also offers symbolic visualization ('compact letter displays', see Algorithms for Compact Letter Displays: Comparison and Evaluation for more details) of significant pairwise comparisons, although it does not present them in a tabular format. However, it has a plotting method which allows to conveniently display results using boxplots. Presentation order can be altered as well (option decreasing=), and it has lot more options for multiple comparisons. There is also the multcompView package which extends those functionalities.
Here is the same example analyzed with glht:
library(multcomp)
tuk <- glht(amod, linfct = mcp(tx = "Tukey"))
summary(tuk) # standard display
tuk.cld <- cld(tuk) # letter-based display
opar <- par(mai=c(1,1,1.5,1))
plot(tuk.cld)
par(opar)
Treatment sharing the same letter are not significantly different, at the chosen level (default, 5%).
Incidentally, there is a new project, currently hosted on R-Forge, which looks promising: factorplot. It includes line and letter-based displays, as well as a matrix overview (via a level plot) of all pairwise comparisons. A working paper can be found here: factorplot: Improving Presentation of Simple Contrasts in GLMs | How to obtain the results of a Tukey HSD post-hoc test in a table showing grouped pairs? | The agricolae::HSD.test function does exactly that, but you will need to let it know that you are interested in an interaction term. Here is an example with a Stata dataset:
library(foreign)
yield <- | How to obtain the results of a Tukey HSD post-hoc test in a table showing grouped pairs?
The agricolae::HSD.test function does exactly that, but you will need to let it know that you are interested in an interaction term. Here is an example with a Stata dataset:
library(foreign)
yield <- read.dta("http://www.stata-press.com/data/r12/yield.dta")
tx <- with(yield, interaction(fertilizer, irrigation))
amod <- aov(yield ~ tx, data=yield)
library(agricolae)
HSD.test(amod, "tx", group=TRUE)
This gives the results shown below:
Groups, Treatments and means
a 2.1 51.17547
ab 4.1 50.7529
abc 3.1 47.36229
bcd 1.1 45.81229
cd 5.1 44.55313
de 4.0 41.81757
ef 2.0 38.79482
ef 1.0 36.91257
f 3.0 36.34383
f 5.0 35.69507
They match what we would obtain with the following commands:
. webuse yield
. regress yield fertilizer##irrigation
. pwcompare fertilizer#irrigation, group mcompare(tukey)
-------------------------------------------------------
| Tukey
| Margin Std. Err. Groups
----------------------+--------------------------------
fertilizer#irrigation |
1 0 | 36.91257 1.116571 AB
1 1 | 45.81229 1.116571 CDE
2 0 | 38.79482 1.116571 AB
2 1 | 51.17547 1.116571 F
3 0 | 36.34383 1.116571 A
3 1 | 47.36229 1.116571 DEF
4 0 | 41.81757 1.116571 BC
4 1 | 50.7529 1.116571 EF
5 0 | 35.69507 1.116571 A
5 1 | 44.55313 1.116571 CD
-------------------------------------------------------
Note: Margins sharing a letter in the group label are
not significantly different at the 5% level.
The multcomp package also offers symbolic visualization ('compact letter displays', see Algorithms for Compact Letter Displays: Comparison and Evaluation for more details) of significant pairwise comparisons, although it does not present them in a tabular format. However, it has a plotting method which allows to conveniently display results using boxplots. Presentation order can be altered as well (option decreasing=), and it has lot more options for multiple comparisons. There is also the multcompView package which extends those functionalities.
Here is the same example analyzed with glht:
library(multcomp)
tuk <- glht(amod, linfct = mcp(tx = "Tukey"))
summary(tuk) # standard display
tuk.cld <- cld(tuk) # letter-based display
opar <- par(mai=c(1,1,1.5,1))
plot(tuk.cld)
par(opar)
Treatment sharing the same letter are not significantly different, at the chosen level (default, 5%).
Incidentally, there is a new project, currently hosted on R-Forge, which looks promising: factorplot. It includes line and letter-based displays, as well as a matrix overview (via a level plot) of all pairwise comparisons. A working paper can be found here: factorplot: Improving Presentation of Simple Contrasts in GLMs | How to obtain the results of a Tukey HSD post-hoc test in a table showing grouped pairs?
The agricolae::HSD.test function does exactly that, but you will need to let it know that you are interested in an interaction term. Here is an example with a Stata dataset:
library(foreign)
yield <- |
18,352 | How to obtain the results of a Tukey HSD post-hoc test in a table showing grouped pairs? | There's a function called TukeyHSD that, according to the help file, calculates a set of confidence intervals on the differences between the means of the levels of a factor with the specified family-wise probability of coverage. The intervals are based on the Studentized range statistic, Tukey's "Honest Significant Difference" method. Does this do what you want?
http://stat.ethz.ch/R-manual/R-patched/library/stats/html/TukeyHSD.html | How to obtain the results of a Tukey HSD post-hoc test in a table showing grouped pairs? | There's a function called TukeyHSD that, according to the help file, calculates a set of confidence intervals on the differences between the means of the levels of a factor with the specified family-w | How to obtain the results of a Tukey HSD post-hoc test in a table showing grouped pairs?
There's a function called TukeyHSD that, according to the help file, calculates a set of confidence intervals on the differences between the means of the levels of a factor with the specified family-wise probability of coverage. The intervals are based on the Studentized range statistic, Tukey's "Honest Significant Difference" method. Does this do what you want?
http://stat.ethz.ch/R-manual/R-patched/library/stats/html/TukeyHSD.html | How to obtain the results of a Tukey HSD post-hoc test in a table showing grouped pairs?
There's a function called TukeyHSD that, according to the help file, calculates a set of confidence intervals on the differences between the means of the levels of a factor with the specified family-w |
18,353 | Is there a way to disable the parameter tuning (grid) feature in CARET? | You can specify method="none" in trainControl. For example:
train(Species ~ ., data=iris, method="rf", tuneGrid=data.frame(mtry=3),
trControl=trainControl(method="none"))
I'm not sure when this was implemented. | Is there a way to disable the parameter tuning (grid) feature in CARET? | You can specify method="none" in trainControl. For example:
train(Species ~ ., data=iris, method="rf", tuneGrid=data.frame(mtry=3),
trControl=trainControl(method="none"))
I'm not sure when this was | Is there a way to disable the parameter tuning (grid) feature in CARET?
You can specify method="none" in trainControl. For example:
train(Species ~ ., data=iris, method="rf", tuneGrid=data.frame(mtry=3),
trControl=trainControl(method="none"))
I'm not sure when this was implemented. | Is there a way to disable the parameter tuning (grid) feature in CARET?
You can specify method="none" in trainControl. For example:
train(Species ~ ., data=iris, method="rf", tuneGrid=data.frame(mtry=3),
trControl=trainControl(method="none"))
I'm not sure when this was |
18,354 | Is there a way to disable the parameter tuning (grid) feature in CARET? | The best way would be to explicitly supply the tuneGrid dataframe. For instance, random forest has only one tuning parameter, 'mtry', which controls the number of features selected for each tree.
To set mtry at a specific value, you might choose the randomForest default (?randomForest) do this:
model <- train(x = X, y = Y, method = 'rf', tuneGrid = data.frame(.mtry = M))
where M is the one value of the tuning parameter you wish to use.
for multiple tuning parameters do this:
tuneGrid = data.frame(.par1 = P1, .par2 = P2, .par3 = P3) | Is there a way to disable the parameter tuning (grid) feature in CARET? | The best way would be to explicitly supply the tuneGrid dataframe. For instance, random forest has only one tuning parameter, 'mtry', which controls the number of features selected for each tree.
To s | Is there a way to disable the parameter tuning (grid) feature in CARET?
The best way would be to explicitly supply the tuneGrid dataframe. For instance, random forest has only one tuning parameter, 'mtry', which controls the number of features selected for each tree.
To set mtry at a specific value, you might choose the randomForest default (?randomForest) do this:
model <- train(x = X, y = Y, method = 'rf', tuneGrid = data.frame(.mtry = M))
where M is the one value of the tuning parameter you wish to use.
for multiple tuning parameters do this:
tuneGrid = data.frame(.par1 = P1, .par2 = P2, .par3 = P3) | Is there a way to disable the parameter tuning (grid) feature in CARET?
The best way would be to explicitly supply the tuneGrid dataframe. For instance, random forest has only one tuning parameter, 'mtry', which controls the number of features selected for each tree.
To s |
18,355 | Is there a way to disable the parameter tuning (grid) feature in CARET? | I don't think it is possible (at least it was not possible as of a few versions ago). One can reduce the performance impact by setting up just a single resampling partition in training data (but caret would still train a model twice)
This sounds like a useful feature to have so I would ping the author of the package. | Is there a way to disable the parameter tuning (grid) feature in CARET? | I don't think it is possible (at least it was not possible as of a few versions ago). One can reduce the performance impact by setting up just a single resampling partition in training data (but caret | Is there a way to disable the parameter tuning (grid) feature in CARET?
I don't think it is possible (at least it was not possible as of a few versions ago). One can reduce the performance impact by setting up just a single resampling partition in training data (but caret would still train a model twice)
This sounds like a useful feature to have so I would ping the author of the package. | Is there a way to disable the parameter tuning (grid) feature in CARET?
I don't think it is possible (at least it was not possible as of a few versions ago). One can reduce the performance impact by setting up just a single resampling partition in training data (but caret |
18,356 | How to model prices? | "Practical" and "simple" suggest least squares regression. It's easy to set up, easy to do with lots of software (R, Excel, Mathematica, any statistics package), easy to interpret, and can be extended in many ways depending on how accurate you want to be and how hard you're willing to work.
This approach is essentially your "weighting scheme" (2), but it finds the weights easily, guarantees as much accuracy as possible, and is easy and fast to update. There are loads of libraries to perform least squares calculations.
It will help to include not only the variables you listed--engine type, power, etc--but also age of car. Furthermore, make sure to adjust prices for inflation. | How to model prices? | "Practical" and "simple" suggest least squares regression. It's easy to set up, easy to do with lots of software (R, Excel, Mathematica, any statistics package), easy to interpret, and can be extende | How to model prices?
"Practical" and "simple" suggest least squares regression. It's easy to set up, easy to do with lots of software (R, Excel, Mathematica, any statistics package), easy to interpret, and can be extended in many ways depending on how accurate you want to be and how hard you're willing to work.
This approach is essentially your "weighting scheme" (2), but it finds the weights easily, guarantees as much accuracy as possible, and is easy and fast to update. There are loads of libraries to perform least squares calculations.
It will help to include not only the variables you listed--engine type, power, etc--but also age of car. Furthermore, make sure to adjust prices for inflation. | How to model prices?
"Practical" and "simple" suggest least squares regression. It's easy to set up, easy to do with lots of software (R, Excel, Mathematica, any statistics package), easy to interpret, and can be extende |
18,357 | How to model prices? | I agree with @whuber, that linear regression is a way to go, but care must be taken when interpreting results. The problem is that in economics the price is always related to demand. If demand goes up, prices go up, if demand goes down, prices go down. So the price is determined by demand and in return demand is determined by price. So if we model price as a regression from some attributes without the demand there is a real danger that the regression estimates will be wrong due to omitted-variable bias. | How to model prices? | I agree with @whuber, that linear regression is a way to go, but care must be taken when interpreting results. The problem is that in economics the price is always related to demand. If demand goes up | How to model prices?
I agree with @whuber, that linear regression is a way to go, but care must be taken when interpreting results. The problem is that in economics the price is always related to demand. If demand goes up, prices go up, if demand goes down, prices go down. So the price is determined by demand and in return demand is determined by price. So if we model price as a regression from some attributes without the demand there is a real danger that the regression estimates will be wrong due to omitted-variable bias. | How to model prices?
I agree with @whuber, that linear regression is a way to go, but care must be taken when interpreting results. The problem is that in economics the price is always related to demand. If demand goes up |
18,358 | How to model prices? | What I'm looking for is something practical and simple, but I would also like to hear about more complex approaches how to model something like this.
After some sort of a discussion, here is my complete view of the things
The problem
Aim: to understand how to price the cars in a better way
Context: in their decision process people solve several questions: do I need a car, if I do, what attributes I prefer most (including the price, because, being rational, I would like to have a car with best quality/price ratio), compare the number of attributes between different cars and choosing valuing them jointly.
From the seller position, I would like to set the price as high as possible, and sell the car as quickly as possible. So if I set the price too high and am waiting for months it could be considered as not demanded on the market and marked with 0 comparing to very demanded attribute sets.
Observations: real deals that relates the attributes of a particular car with the price set within the bargaining process (regarding the previous remark it is important to know how long it take to set the deal).
Pros: you do observe the things that were actually bought on the market, so you are not guessing if there exist a person with high enough reservation price that wants to buy
a particular car
Cons:
your assumption is that market is efficient, meaning the prices you observe are close to equilibrium
you ignore the variants of car attributes that were not purchased or took too long to set the deal, meaning your insights are biased, so you actually do work with latent variable models
Observing the data for a long time you need to deflate them, though the inclusion of the car age partly compensates this.
Solution methods
The first one, as suggested by whuber, is the classical least squares regression model
Pros:
indeed the simplest solution as it is the work-horse of econometrics
Cons:
ignores that you do observe the things incompletely (latent variables)
acts as the regressors are independent one of the other, so the basic model ignores the fact that you may like blue Ford differently from blue Mercedes, but it is not the sum of marginal influence that comes from blue and Ford
In case of classical regression, since you are not limited in the degrees of freedom, to try also different interaction terms.
Therefore more complicated solution would be either tobit or Heckman model, you may want to consult A.C. Cameron and P.K. Trivedi Microeconometrics: methods and applications for more details on core methods.
Pros:
you do separate the fact that people may not like some sets of attributes at all, or some set of attributes has a small probability to be bought from the actual price setting
your results are not biased (or at least less than in the first case)
in case of Heckman you separate the reasons that motivates to buy the particular car from the pricing decision of how much I would like to pay for this car: the first one is influenced by individual preferences, the second one by budget constraint
Cons:
Both models are more data greedy, i.e. we need to observe either the time length between the ask and bid to equalize (if it is fairly short put 1, else 0), or to observe the sets that were ignored by the market
And, finally, if you simply interested in how price influences the probability to be bought you may work with some kind of logit models.
We agreed, that conjoint analysis is not suitable here, because you do have different context and observations.
Good luck. | How to model prices? | What I'm looking for is something practical and simple, but I would also like to hear about more complex approaches how to model something like this.
After some sort of a discussion, here is my compl | How to model prices?
What I'm looking for is something practical and simple, but I would also like to hear about more complex approaches how to model something like this.
After some sort of a discussion, here is my complete view of the things
The problem
Aim: to understand how to price the cars in a better way
Context: in their decision process people solve several questions: do I need a car, if I do, what attributes I prefer most (including the price, because, being rational, I would like to have a car with best quality/price ratio), compare the number of attributes between different cars and choosing valuing them jointly.
From the seller position, I would like to set the price as high as possible, and sell the car as quickly as possible. So if I set the price too high and am waiting for months it could be considered as not demanded on the market and marked with 0 comparing to very demanded attribute sets.
Observations: real deals that relates the attributes of a particular car with the price set within the bargaining process (regarding the previous remark it is important to know how long it take to set the deal).
Pros: you do observe the things that were actually bought on the market, so you are not guessing if there exist a person with high enough reservation price that wants to buy
a particular car
Cons:
your assumption is that market is efficient, meaning the prices you observe are close to equilibrium
you ignore the variants of car attributes that were not purchased or took too long to set the deal, meaning your insights are biased, so you actually do work with latent variable models
Observing the data for a long time you need to deflate them, though the inclusion of the car age partly compensates this.
Solution methods
The first one, as suggested by whuber, is the classical least squares regression model
Pros:
indeed the simplest solution as it is the work-horse of econometrics
Cons:
ignores that you do observe the things incompletely (latent variables)
acts as the regressors are independent one of the other, so the basic model ignores the fact that you may like blue Ford differently from blue Mercedes, but it is not the sum of marginal influence that comes from blue and Ford
In case of classical regression, since you are not limited in the degrees of freedom, to try also different interaction terms.
Therefore more complicated solution would be either tobit or Heckman model, you may want to consult A.C. Cameron and P.K. Trivedi Microeconometrics: methods and applications for more details on core methods.
Pros:
you do separate the fact that people may not like some sets of attributes at all, or some set of attributes has a small probability to be bought from the actual price setting
your results are not biased (or at least less than in the first case)
in case of Heckman you separate the reasons that motivates to buy the particular car from the pricing decision of how much I would like to pay for this car: the first one is influenced by individual preferences, the second one by budget constraint
Cons:
Both models are more data greedy, i.e. we need to observe either the time length between the ask and bid to equalize (if it is fairly short put 1, else 0), or to observe the sets that were ignored by the market
And, finally, if you simply interested in how price influences the probability to be bought you may work with some kind of logit models.
We agreed, that conjoint analysis is not suitable here, because you do have different context and observations.
Good luck. | How to model prices?
What I'm looking for is something practical and simple, but I would also like to hear about more complex approaches how to model something like this.
After some sort of a discussion, here is my compl |
18,359 | How to model prices? | It looks like a linear regression problem me too, but what about K nearest neighbors KNN. You can come up with a distance formula between each car and compute the price as the average between the K (say 3) nearest. A distance formula can be euclidian based like the difference in cylinders plus the difference in doors, plus difference in horsepower and so on.
If you go with linear regresion I would suggest a couple things:
Scale the dollar value up to modern day to account for inflation.
Divide your data into epochs. I'll bet you'll find you will need one model for pre ww2 and post ww2 for example. This is just a hunch though.
Cross validate your model to avoid over fitting. Divide your data into 5 chunks. Train on 4 and urn the model on the 5th chunk. Sum up the errors, rinse, repeat for the other chunks.
Another idea is to made a hybrid between models. Use regresion and KNN both as datapoints and create the final price as the weighted average or something. | How to model prices? | It looks like a linear regression problem me too, but what about K nearest neighbors KNN. You can come up with a distance formula between each car and compute the price as the average between the K ( | How to model prices?
It looks like a linear regression problem me too, but what about K nearest neighbors KNN. You can come up with a distance formula between each car and compute the price as the average between the K (say 3) nearest. A distance formula can be euclidian based like the difference in cylinders plus the difference in doors, plus difference in horsepower and so on.
If you go with linear regresion I would suggest a couple things:
Scale the dollar value up to modern day to account for inflation.
Divide your data into epochs. I'll bet you'll find you will need one model for pre ww2 and post ww2 for example. This is just a hunch though.
Cross validate your model to avoid over fitting. Divide your data into 5 chunks. Train on 4 and urn the model on the 5th chunk. Sum up the errors, rinse, repeat for the other chunks.
Another idea is to made a hybrid between models. Use regresion and KNN both as datapoints and create the final price as the weighted average or something. | How to model prices?
It looks like a linear regression problem me too, but what about K nearest neighbors KNN. You can come up with a distance formula between each car and compute the price as the average between the K ( |
18,360 | How to model prices? | Besides what have been said, and not really quite different from some of the suggestions already made, you might want to have a look at the vast literature on hedonic pricing models. What it boils down to is a regression model trying to explain the price of a composite good as a function of its attributes.
This would allow you to price a car knowing its attributes (horse power, size, brand, etc.), even if an exactly similar mix of attributes is not present in your sample. It is a very popular approach for valuation of essentially non replicable assets --like real state properties. If you Google for "hedonic models" you will find many references and examples. | How to model prices? | Besides what have been said, and not really quite different from some of the suggestions already made, you might want to have a look at the vast literature on hedonic pricing models. What it boils dow | How to model prices?
Besides what have been said, and not really quite different from some of the suggestions already made, you might want to have a look at the vast literature on hedonic pricing models. What it boils down to is a regression model trying to explain the price of a composite good as a function of its attributes.
This would allow you to price a car knowing its attributes (horse power, size, brand, etc.), even if an exactly similar mix of attributes is not present in your sample. It is a very popular approach for valuation of essentially non replicable assets --like real state properties. If you Google for "hedonic models" you will find many references and examples. | How to model prices?
Besides what have been said, and not really quite different from some of the suggestions already made, you might want to have a look at the vast literature on hedonic pricing models. What it boils dow |
18,361 | Why is R Squared not a good measure for regressions fit using LASSO? | The goal of using LASSO is obtaining a sparse representation (of a predicted quantity) in the sense of not having many covariates. Comparing models with $R^2$ tends to favor models with lots of covariates: in fact, adding covariates unrelated to the outcome will never decrease $R^2$ and almost always increases it at least a little bit. The LASSO model will identify the model with the optimal penalized log-likelihood (an unpenalized log-likelihood is monotonically related to the $R^2$). Validation statistics that are more widely used to compare LASSO models to other types of models are, for instance, the BIC or cross-validated $R^2$. | Why is R Squared not a good measure for regressions fit using LASSO? | The goal of using LASSO is obtaining a sparse representation (of a predicted quantity) in the sense of not having many covariates. Comparing models with $R^2$ tends to favor models with lots of covari | Why is R Squared not a good measure for regressions fit using LASSO?
The goal of using LASSO is obtaining a sparse representation (of a predicted quantity) in the sense of not having many covariates. Comparing models with $R^2$ tends to favor models with lots of covariates: in fact, adding covariates unrelated to the outcome will never decrease $R^2$ and almost always increases it at least a little bit. The LASSO model will identify the model with the optimal penalized log-likelihood (an unpenalized log-likelihood is monotonically related to the $R^2$). Validation statistics that are more widely used to compare LASSO models to other types of models are, for instance, the BIC or cross-validated $R^2$. | Why is R Squared not a good measure for regressions fit using LASSO?
The goal of using LASSO is obtaining a sparse representation (of a predicted quantity) in the sense of not having many covariates. Comparing models with $R^2$ tends to favor models with lots of covari |
18,362 | How does linear base learner works in boosting? And how does it works in the xgboost library? | Short answer to you question:
when the algorithm it fits the residual (or the negative gradient) is it using one feature at each step (i.e. univariate model) or all features (multivariate model)?
The algorithm is using one features or all features depends on your set up. In my long answer listed below, in both decision stump and linear learner examples, they uses all features, but if you want, you can also fit a subset of features. Sampling columns (features) are viewed as reducing the variance of the model or increasing the "robustness" of the model, especially if you have large number of features.
In xgboost, for tree base learner, you can set colsample_bytree to sample features to fit in each iteration. For linear base learner, there are not such options, so, it should be fitting all features. In addition, not too many people use linear learner in xgboost or gradient boosting in general.
Long answer for linear as weak learner for boosting:
In most cases, we may not use linear learner as a base learner. The reason is simple: adding multiple linear models together will still be a linear model.
In boosting our model is a sum of base learners:
$$
f(x)=\sum_{m=1}^M b_m(x)
$$
where $M$ is number of iterations in boosting, $b_m$ is the model for $m^{th}$ iteration.
If the base learner is linear, for example, suppose we just run $2$ iterations, and $b_1=\beta_0+ \beta_1x$ and $b_2=\theta_0+ \theta_1x$, then
$$
f(x)=\sum_{m=1}^2 b_m(x)=\beta_0+ \beta_1x+\theta_0+ \theta_1x=(\beta_0+\theta_0)+ (\beta_1+ \theta_1)x
$$
which is a simple linear model! In other words, the ensemble model have the "same power" with the base learner!
More importantly, if we use linear model as base learner, we can just do it one step by solving the linear system $ X^T X \beta = X^T y $ instead of go though multiple iterations in boosting.
Therefore, people would like to use other models than linear model as base learner. Tree is a good option, since adding two trees is not equal to one tree. I will demo it with a simple case: decision stump, which is a tree with 1 split only.
I am doing a function fitting, where the data is generated by a simple quadratic function, $f(x,y)=x^2+y^2$. Here is the filled contour ground truth (left) and final decision stump boosting fitting (right).
Now, check the first four iterations.
Note, different from linear learner, the model in 4th iteration cannot be achieved by one iteration (one single decision stump) with other parameters.
So far, I explained, why people are not using linear learner as base learner. However, nothing prevent people to do that. If we use linear model as base learner, and restrict number of iterations, it is equal to solving a linear system, but limit the number of the iterations during the solving process.
The same example, but in 3d plot, the red curve are the data, and the green plane is the final fit. You can easily see, final model is a linear model, and it is z=mean(data$label) which is parallel to x,y plane. (You can think why? this is because our data is "symmetric", so any tilt of the plane will increase the loss). Now, check out what happened in first 4 iterations: the fitted model is slowly going up to the optimal value (mean).
Final conclusion, linear learner is not widely used, but nothing prevent people to use it or implement it in a R library. In addition, you can use it and limit number of iterations to regularize the model.
Related post:
Gradient Boosting for Linear Regression - why does it not work?
Is a decision stump a linear model? | How does linear base learner works in boosting? And how does it works in the xgboost library? | Short answer to you question:
when the algorithm it fits the residual (or the negative gradient) is it using one feature at each step (i.e. univariate model) or all features (multivariate model)?
Th | How does linear base learner works in boosting? And how does it works in the xgboost library?
Short answer to you question:
when the algorithm it fits the residual (or the negative gradient) is it using one feature at each step (i.e. univariate model) or all features (multivariate model)?
The algorithm is using one features or all features depends on your set up. In my long answer listed below, in both decision stump and linear learner examples, they uses all features, but if you want, you can also fit a subset of features. Sampling columns (features) are viewed as reducing the variance of the model or increasing the "robustness" of the model, especially if you have large number of features.
In xgboost, for tree base learner, you can set colsample_bytree to sample features to fit in each iteration. For linear base learner, there are not such options, so, it should be fitting all features. In addition, not too many people use linear learner in xgboost or gradient boosting in general.
Long answer for linear as weak learner for boosting:
In most cases, we may not use linear learner as a base learner. The reason is simple: adding multiple linear models together will still be a linear model.
In boosting our model is a sum of base learners:
$$
f(x)=\sum_{m=1}^M b_m(x)
$$
where $M$ is number of iterations in boosting, $b_m$ is the model for $m^{th}$ iteration.
If the base learner is linear, for example, suppose we just run $2$ iterations, and $b_1=\beta_0+ \beta_1x$ and $b_2=\theta_0+ \theta_1x$, then
$$
f(x)=\sum_{m=1}^2 b_m(x)=\beta_0+ \beta_1x+\theta_0+ \theta_1x=(\beta_0+\theta_0)+ (\beta_1+ \theta_1)x
$$
which is a simple linear model! In other words, the ensemble model have the "same power" with the base learner!
More importantly, if we use linear model as base learner, we can just do it one step by solving the linear system $ X^T X \beta = X^T y $ instead of go though multiple iterations in boosting.
Therefore, people would like to use other models than linear model as base learner. Tree is a good option, since adding two trees is not equal to one tree. I will demo it with a simple case: decision stump, which is a tree with 1 split only.
I am doing a function fitting, where the data is generated by a simple quadratic function, $f(x,y)=x^2+y^2$. Here is the filled contour ground truth (left) and final decision stump boosting fitting (right).
Now, check the first four iterations.
Note, different from linear learner, the model in 4th iteration cannot be achieved by one iteration (one single decision stump) with other parameters.
So far, I explained, why people are not using linear learner as base learner. However, nothing prevent people to do that. If we use linear model as base learner, and restrict number of iterations, it is equal to solving a linear system, but limit the number of the iterations during the solving process.
The same example, but in 3d plot, the red curve are the data, and the green plane is the final fit. You can easily see, final model is a linear model, and it is z=mean(data$label) which is parallel to x,y plane. (You can think why? this is because our data is "symmetric", so any tilt of the plane will increase the loss). Now, check out what happened in first 4 iterations: the fitted model is slowly going up to the optimal value (mean).
Final conclusion, linear learner is not widely used, but nothing prevent people to use it or implement it in a R library. In addition, you can use it and limit number of iterations to regularize the model.
Related post:
Gradient Boosting for Linear Regression - why does it not work?
Is a decision stump a linear model? | How does linear base learner works in boosting? And how does it works in the xgboost library?
Short answer to you question:
when the algorithm it fits the residual (or the negative gradient) is it using one feature at each step (i.e. univariate model) or all features (multivariate model)?
Th |
18,363 | Decision Trees and Regression - Can predicted values be outside range of training data? | You are completely right: classical decision trees cannot predict values outside the historically observed range. They will not extrapolate.
The same applies to random forests.
Theoretically, you sometimes see discussions of somewhat more elaborate architectures (botanies?), where the leaves of the tree don't give a single value, but contain a simple regression, e.g., regressing the dependent variable on a particular numerical independent variable. Navigating through the tree would give you a rule set on which numerical IV to regress the DV on in what case. In such a case, this "bottom level" regression could be extrapolated to yield not-yet observed values.
However, I don't think standard machine learning libraries offer this somewhat more complex structure (I recently looked for this through the CRAN Task Views for R), although there should really not be anything complex about it. You might be able to implement your own tree containing regressions in the leaves. | Decision Trees and Regression - Can predicted values be outside range of training data? | You are completely right: classical decision trees cannot predict values outside the historically observed range. They will not extrapolate.
The same applies to random forests.
Theoretically, you some | Decision Trees and Regression - Can predicted values be outside range of training data?
You are completely right: classical decision trees cannot predict values outside the historically observed range. They will not extrapolate.
The same applies to random forests.
Theoretically, you sometimes see discussions of somewhat more elaborate architectures (botanies?), where the leaves of the tree don't give a single value, but contain a simple regression, e.g., regressing the dependent variable on a particular numerical independent variable. Navigating through the tree would give you a rule set on which numerical IV to regress the DV on in what case. In such a case, this "bottom level" regression could be extrapolated to yield not-yet observed values.
However, I don't think standard machine learning libraries offer this somewhat more complex structure (I recently looked for this through the CRAN Task Views for R), although there should really not be anything complex about it. You might be able to implement your own tree containing regressions in the leaves. | Decision Trees and Regression - Can predicted values be outside range of training data?
You are completely right: classical decision trees cannot predict values outside the historically observed range. They will not extrapolate.
The same applies to random forests.
Theoretically, you some |
18,364 | Decision Trees and Regression - Can predicted values be outside range of training data? | Also check out cubist in the caret package. It builds linear regressions in the terminal nodes and can extrapolate predictions above and below the range of response values in the training data. The terminal nodes can also be averaged based on nearest neighbors that is provided as a hyperparameter, so it has potential to provide extremely accurate cross validated predictions. | Decision Trees and Regression - Can predicted values be outside range of training data? | Also check out cubist in the caret package. It builds linear regressions in the terminal nodes and can extrapolate predictions above and below the range of response values in the training data. The t | Decision Trees and Regression - Can predicted values be outside range of training data?
Also check out cubist in the caret package. It builds linear regressions in the terminal nodes and can extrapolate predictions above and below the range of response values in the training data. The terminal nodes can also be averaged based on nearest neighbors that is provided as a hyperparameter, so it has potential to provide extremely accurate cross validated predictions. | Decision Trees and Regression - Can predicted values be outside range of training data?
Also check out cubist in the caret package. It builds linear regressions in the terminal nodes and can extrapolate predictions above and below the range of response values in the training data. The t |
18,365 | Why is the asymptotic relative efficiency of the Wilcoxon test $3/\pi$ compared to Student's t-test for normally distributed data? | Brief sketch of ARE for one-sample $t$-test, signed test and the signed-rank test
I expect the long version of @Glen_b's answer includes detailed analysis for two-sample signed rank test along with the intuitive explanation of the ARE. So I'll skip most of the derivation. (one-sample case, you can find the missing details in Lehmann TSH).
Testing Problem: Let $X_1,\ldots,X_n$ be a random sample from location model $f(x-\theta)$, symmetric about zero. We are to compute ARE of signed test, signed rank test for the hypothesis $H_0: \theta=0$ relative to t-test.
To assess the relative efficiency of tests, only local alternatives are considered because consistent tests have power tending to 1 against fixed alternative.
Local alternatives that give rise to nontrivial asymptotic power is often of the form $\theta_n=h/\sqrt{n}$ for fixed $h$, which is called Pitman drift in some literature.
Our task ahead is
find the limit distribution of each test statistic under the null
find the limit distribution of each test statistic under the alternative
compute the local asymptotic power of each test
Test statisics and asymptotics
t-test (given the existence of $\sigma$) $$t_n=\sqrt{n}\frac{\bar{X}}{\hat{\sigma}}\to_dN(0,1)\quad \text{under the null}$$
$$t_n=\sqrt{n}\frac{\bar{X}}{\hat{\sigma}}\to_dN(h/\sigma,1)\quad \text{under the alternative }\theta=h/\sqrt{n}$$
so the test that rejects if $t_n>z_\alpha$ has asymptotic power function
$$1-\Phi\left(z_\alpha-h\frac{1}{\sigma}\right)$$
signed test $S_n=\frac{1}{n}\sum_{i=1}^{n}1\{X_i>0\}$
$$\sqrt{n}\left(S_n-\frac{1}{2}\right)\to_dN\left(0,\frac{1}{4}\right)\quad \text{under the null }$$
$$\sqrt{n}\left(S_n-\frac{1}{2}\right)\to_dN\left(hf(0),\frac{1}{4}\right)\quad \text{under the alternative }$$ and has local asymptotic power
$$1-\Phi\left(z_\alpha-2hf(0)\right)$$
signed-rank test $$W_n=n^{-2/3}\sum_{i=1}^{n}R_i1\{X_i>0\}\to_dN\left(0,\frac{1}{3}\right)\quad \text{under the null }$$
$$W_n\to_dN\left(2h\int f^2,\frac{1}{3}\right)\quad \text{under the alternative }$$
and has local asymptotic power
$$1-\Phi\left(z_\alpha-\sqrt{12}h\int f^2\right)$$
Therefore, $$ARE(S_n)=(2f(0)\sigma)^2$$
$$ARE(W_n)=(\sqrt{12}\int f^2\sigma)^2$$
If $f$ is standard normal density, $ARE(S_n)=2/\pi$, $ARE(W_n)=3/\pi$
If $f$ is uniform on [-1,1], $ARE(S_n)=1/3$, $ARE(W_n)=1/3$
Remark on the derivation of distribution under the alternative
There are of course many ways to derive the limiting distribution under the alternative. One general approach is to use Le Cam's third lemma. Simplified version of it states
Let $\Delta_n$ be the log of the likelihood ratio. For some statistic
$W_n$, if
$$ (W_n,\Delta_n)\to_d N\left[\left(\begin{array}{c}
\mu\\
-\sigma^2/2
\end{array}\right),\left(\begin{array}{cc}
\sigma^2_W & \tau \\
\tau & \sigma^2/2
\end{array}\right)\right]\\
$$
under the null, then $$W_n\to_d N\left(\mu+\tau,\sigma^2_W\right)\quad\text{under the alternative}$$
For quadratic mean differentiable densities, local asymptotic normality and contiguity are automatically satisfied, which in turn implies Le Cam lemma.
Using this lemma, we only need to compute $\mathrm{cov}(W_n,\Delta_n)$ under the null. $\Delta_n$ obeys LAN $$\Delta_n\approx \frac{h}{\sqrt{n}}\sum_{i=1}^{n}l(X_i)-\frac{1}{2}h^2I_0$$ where $l$ is score function, $I_0$ is information matrix.
Then, for instance, for signed test $S_n$
$$\mathrm{cov}(\sqrt{n}(S_n-1/2),\Delta_n)=-h\mathrm{cov}\left(1\{X_i>0\},\frac{f'}{f}(X_i)\right)=h\int_0^\infty f'=hf(0)$$ | Why is the asymptotic relative efficiency of the Wilcoxon test $3/\pi$ compared to Student's t-test | Brief sketch of ARE for one-sample $t$-test, signed test and the signed-rank test
I expect the long version of @Glen_b's answer includes detailed analysis for two-sample signed rank test along with th | Why is the asymptotic relative efficiency of the Wilcoxon test $3/\pi$ compared to Student's t-test for normally distributed data?
Brief sketch of ARE for one-sample $t$-test, signed test and the signed-rank test
I expect the long version of @Glen_b's answer includes detailed analysis for two-sample signed rank test along with the intuitive explanation of the ARE. So I'll skip most of the derivation. (one-sample case, you can find the missing details in Lehmann TSH).
Testing Problem: Let $X_1,\ldots,X_n$ be a random sample from location model $f(x-\theta)$, symmetric about zero. We are to compute ARE of signed test, signed rank test for the hypothesis $H_0: \theta=0$ relative to t-test.
To assess the relative efficiency of tests, only local alternatives are considered because consistent tests have power tending to 1 against fixed alternative.
Local alternatives that give rise to nontrivial asymptotic power is often of the form $\theta_n=h/\sqrt{n}$ for fixed $h$, which is called Pitman drift in some literature.
Our task ahead is
find the limit distribution of each test statistic under the null
find the limit distribution of each test statistic under the alternative
compute the local asymptotic power of each test
Test statisics and asymptotics
t-test (given the existence of $\sigma$) $$t_n=\sqrt{n}\frac{\bar{X}}{\hat{\sigma}}\to_dN(0,1)\quad \text{under the null}$$
$$t_n=\sqrt{n}\frac{\bar{X}}{\hat{\sigma}}\to_dN(h/\sigma,1)\quad \text{under the alternative }\theta=h/\sqrt{n}$$
so the test that rejects if $t_n>z_\alpha$ has asymptotic power function
$$1-\Phi\left(z_\alpha-h\frac{1}{\sigma}\right)$$
signed test $S_n=\frac{1}{n}\sum_{i=1}^{n}1\{X_i>0\}$
$$\sqrt{n}\left(S_n-\frac{1}{2}\right)\to_dN\left(0,\frac{1}{4}\right)\quad \text{under the null }$$
$$\sqrt{n}\left(S_n-\frac{1}{2}\right)\to_dN\left(hf(0),\frac{1}{4}\right)\quad \text{under the alternative }$$ and has local asymptotic power
$$1-\Phi\left(z_\alpha-2hf(0)\right)$$
signed-rank test $$W_n=n^{-2/3}\sum_{i=1}^{n}R_i1\{X_i>0\}\to_dN\left(0,\frac{1}{3}\right)\quad \text{under the null }$$
$$W_n\to_dN\left(2h\int f^2,\frac{1}{3}\right)\quad \text{under the alternative }$$
and has local asymptotic power
$$1-\Phi\left(z_\alpha-\sqrt{12}h\int f^2\right)$$
Therefore, $$ARE(S_n)=(2f(0)\sigma)^2$$
$$ARE(W_n)=(\sqrt{12}\int f^2\sigma)^2$$
If $f$ is standard normal density, $ARE(S_n)=2/\pi$, $ARE(W_n)=3/\pi$
If $f$ is uniform on [-1,1], $ARE(S_n)=1/3$, $ARE(W_n)=1/3$
Remark on the derivation of distribution under the alternative
There are of course many ways to derive the limiting distribution under the alternative. One general approach is to use Le Cam's third lemma. Simplified version of it states
Let $\Delta_n$ be the log of the likelihood ratio. For some statistic
$W_n$, if
$$ (W_n,\Delta_n)\to_d N\left[\left(\begin{array}{c}
\mu\\
-\sigma^2/2
\end{array}\right),\left(\begin{array}{cc}
\sigma^2_W & \tau \\
\tau & \sigma^2/2
\end{array}\right)\right]\\
$$
under the null, then $$W_n\to_d N\left(\mu+\tau,\sigma^2_W\right)\quad\text{under the alternative}$$
For quadratic mean differentiable densities, local asymptotic normality and contiguity are automatically satisfied, which in turn implies Le Cam lemma.
Using this lemma, we only need to compute $\mathrm{cov}(W_n,\Delta_n)$ under the null. $\Delta_n$ obeys LAN $$\Delta_n\approx \frac{h}{\sqrt{n}}\sum_{i=1}^{n}l(X_i)-\frac{1}{2}h^2I_0$$ where $l$ is score function, $I_0$ is information matrix.
Then, for instance, for signed test $S_n$
$$\mathrm{cov}(\sqrt{n}(S_n-1/2),\Delta_n)=-h\mathrm{cov}\left(1\{X_i>0\},\frac{f'}{f}(X_i)\right)=h\int_0^\infty f'=hf(0)$$ | Why is the asymptotic relative efficiency of the Wilcoxon test $3/\pi$ compared to Student's t-test
Brief sketch of ARE for one-sample $t$-test, signed test and the signed-rank test
I expect the long version of @Glen_b's answer includes detailed analysis for two-sample signed rank test along with th |
18,366 | Why is the asymptotic relative efficiency of the Wilcoxon test $3/\pi$ compared to Student's t-test for normally distributed data? | This has nothing to do with explaining why $\pi$ appears (which was explained nicely by others) but may help intuitively. The Wilcoxon test is a $t$-test on the ranks of $Y$ whereas the parametric test is computed on the raw data. The efficiency of the Wilcoxon test with respect to the $t$-test is the square of the correlation between the scores used for the two tests. As $n\rightarrow \infty$ the squared correlation converges to $\frac{\pi}{3}$. You can easily see this empirically using R:
n <- 1000000; x <- qnorm((1:n)/(n+1)); cor(1:n, x)^2; 3/pi
[1] 0.9549402
[1] 0.9549297
n <- 100000000; x <- qnorm((1:n)/(n+1)); cor(1:n, x)^2; 3/pi
[1] 0.9549298
[1] 0.9549297 | Why is the asymptotic relative efficiency of the Wilcoxon test $3/\pi$ compared to Student's t-test | This has nothing to do with explaining why $\pi$ appears (which was explained nicely by others) but may help intuitively. The Wilcoxon test is a $t$-test on the ranks of $Y$ whereas the parametric te | Why is the asymptotic relative efficiency of the Wilcoxon test $3/\pi$ compared to Student's t-test for normally distributed data?
This has nothing to do with explaining why $\pi$ appears (which was explained nicely by others) but may help intuitively. The Wilcoxon test is a $t$-test on the ranks of $Y$ whereas the parametric test is computed on the raw data. The efficiency of the Wilcoxon test with respect to the $t$-test is the square of the correlation between the scores used for the two tests. As $n\rightarrow \infty$ the squared correlation converges to $\frac{\pi}{3}$. You can easily see this empirically using R:
n <- 1000000; x <- qnorm((1:n)/(n+1)); cor(1:n, x)^2; 3/pi
[1] 0.9549402
[1] 0.9549297
n <- 100000000; x <- qnorm((1:n)/(n+1)); cor(1:n, x)^2; 3/pi
[1] 0.9549298
[1] 0.9549297 | Why is the asymptotic relative efficiency of the Wilcoxon test $3/\pi$ compared to Student's t-test
This has nothing to do with explaining why $\pi$ appears (which was explained nicely by others) but may help intuitively. The Wilcoxon test is a $t$-test on the ranks of $Y$ whereas the parametric te |
18,367 | Why is the asymptotic relative efficiency of the Wilcoxon test $3/\pi$ compared to Student's t-test for normally distributed data? | Short version: The basic reason with the Wilcoxon-Mann-Whitney under a shift alternative is that finding the asymptotic relative efficiency (WMW/t) corresponds to evaluating $12\sigma^2[\int f^2(x) dx]^2$ where $f$ is the common density at the null and $\sigma$ is the common variance.
So at the normal, $f^2$ is effectively a scaled version of $f$; its integral will have a $\frac{1}{\sqrt{\pi}}$ term; when squared, that's the source of the $\frac{ \;}{\pi}$.
The same term - with the same integral - is involved in the ARE for the signed rank test, so it takes the same value.
For the sign test relative to t, the ARE is $4\sigma^2f(0)^2$... and $f(0)^2$ again has a $\frac{ \;}{\pi}$ in it.
So essentially it's as I said in comments; $\pi$ is in the ARE for the Wilcoxon-Mann-Whitney vs the two-sample t test, for the Wilcoxon signed rank test vs the one-sample t and the sign test vs the one-sample t test (in each case at the normal) quite literally because it appears in the normal density.
Reference:
J. L. Hodges and E. L. Lehmann (1956),
"The Efficiency of Some Nonparametric Competitors of the t-Test",
Ann. Math. Statist., 27:2, 324-335. | Why is the asymptotic relative efficiency of the Wilcoxon test $3/\pi$ compared to Student's t-test | Short version: The basic reason with the Wilcoxon-Mann-Whitney under a shift alternative is that finding the asymptotic relative efficiency (WMW/t) corresponds to evaluating $12\sigma^2[\int f^2(x) dx | Why is the asymptotic relative efficiency of the Wilcoxon test $3/\pi$ compared to Student's t-test for normally distributed data?
Short version: The basic reason with the Wilcoxon-Mann-Whitney under a shift alternative is that finding the asymptotic relative efficiency (WMW/t) corresponds to evaluating $12\sigma^2[\int f^2(x) dx]^2$ where $f$ is the common density at the null and $\sigma$ is the common variance.
So at the normal, $f^2$ is effectively a scaled version of $f$; its integral will have a $\frac{1}{\sqrt{\pi}}$ term; when squared, that's the source of the $\frac{ \;}{\pi}$.
The same term - with the same integral - is involved in the ARE for the signed rank test, so it takes the same value.
For the sign test relative to t, the ARE is $4\sigma^2f(0)^2$... and $f(0)^2$ again has a $\frac{ \;}{\pi}$ in it.
So essentially it's as I said in comments; $\pi$ is in the ARE for the Wilcoxon-Mann-Whitney vs the two-sample t test, for the Wilcoxon signed rank test vs the one-sample t and the sign test vs the one-sample t test (in each case at the normal) quite literally because it appears in the normal density.
Reference:
J. L. Hodges and E. L. Lehmann (1956),
"The Efficiency of Some Nonparametric Competitors of the t-Test",
Ann. Math. Statist., 27:2, 324-335. | Why is the asymptotic relative efficiency of the Wilcoxon test $3/\pi$ compared to Student's t-test
Short version: The basic reason with the Wilcoxon-Mann-Whitney under a shift alternative is that finding the asymptotic relative efficiency (WMW/t) corresponds to evaluating $12\sigma^2[\int f^2(x) dx |
18,368 | How to perform cross-validation for PCA to determine the number of principal components? | What you are doing is wrong: it does not make sense to compute PRESS for PCA like that! Specifically, the problem lies in your step #5.
NaĂŻve approach to PRESS for PCA
Let the data set consist of $n$ points in $d$-dimensional space: $\mathbf x^{(i)} \in \mathbb R^d, \, i=1 \dots n$. To compute reconstruction error for a single test data point $\mathbf x^{(i)}$, you perform PCA on the training set $\mathbf X^{(-i)}$ with this point excluded, take a certain number $k$ of principal axes as columns of $\mathbf U^{(-i)}$, and find the reconstruction error as $\left \|\mathbf x^{(i)} - \hat{\mathbf x}^{(i)}\right\|^2 = \left\|\mathbf x^{(i)} - \mathbf U^{(-i)} [\mathbf U^{(-i)}]^\top \mathbf x^{(i)}\right\|^2$. PRESS is then equal to sum over all test samples $i$, so the reasonable equation seems to be: $$\mathrm{PRESS} \overset{?}{=} \sum_{i=1}^n \left\|\mathbf x^{(i)} - \mathbf U^{(-i)} [\mathbf U^{(-i)}]^\top \mathbf x^{(i)}\right\|^2.$$
For simplicity, I am ignoring the issues of centering and scaling here.
The naĂŻve approach is wrong
The problem above is that we use $\mathbf x^{(i)}$ to compute the prediction $ \hat{\mathbf x}^{(i)}$, and that is a Very Bad Thing.
Note the crucial difference to a regression case, where the formula for the reconstruction error is basically the same $\left\|\mathbf y^{(i)} - \hat{\mathbf y}^{(i)}\right\|^2$, but prediction $\hat{\mathbf y}^{(i)}$ is computed using the predictor variables and not using $\mathbf y^{(i)}$. This is not possible in PCA, because in PCA there are no dependent and independent variables: all variables are treated together.
In practice it means that PRESS as computed above can decrease with increasing number of components $k$ and never reach a minimum. Which would lead one to think that all $d$ components are significant. Or maybe in some cases it does reach a minimum, but still tends to overfit and overestimate the optimal dimensionality.
A correct approach
There are several possible approaches, see Bro et al. (2008) Cross-validation of component models: a critical look at current methods for an overview and comparison. One approach is to leave out one dimension of one data point at a time (i.e. $x^{(i)}_j$ instead of $\mathbf x^{(i)}$), so that the training data become a matrix with one missing value, and then to predict ("impute") this missing value with PCA. (One can of course randomly hold out some larger fraction of matrix elements, e.g. 10%). The problem is that computing PCA with missing values can be computationally quite slow (it relies on EM algorithm), but needs to be iterated many times here. Update: see http://alexhwilliams.info/itsneuronalblog/2018/02/26/crossval/ for a nice discussion and Python implementation (PCA with missing values is implemented via alternating least squares).
An approach that I found to be much more practical is to leave out one data point $\mathbf x^{(i)}$ at a time, compute PCA on the training data (exactly as above), but then to loop over dimensions of $\mathbf x^{(i)}$, leave them out one at a time and compute a reconstruction error using the rest. This can be quite confusing in the beginning and the formulas tend to become quite messy, but implementation is rather straightforward. Let me first give the (somewhat scary) formula, and then briefly explain it:
$$\mathrm{PRESS_{PCA}} = \sum_{i=1}^n \sum_{j=1}^d \left|x^{(i)}_j - \left[\mathbf U^{(-i)} \left [\mathbf U^{(-i)}_{-j}\right]^+\mathbf x^{(i)}_{-j}\right]_j\right|^2.$$
Consider the inner loop here. We left out one point $\mathbf x^{(i)}$ and computed $k$ principal components on the training data, $\mathbf U^{(-i)}$. Now we keep each value $x^{(i)}_j$ as the test and use the remaining dimensions $\mathbf x^{(i)}_{-j} \in \mathbb R^{d-1}$ to perform the prediction. The prediction $\hat{x}^{(i)}_j$ is the $j$-th coordinate of "the projection" (in the least squares sense) of $\mathbf x^{(i)}_{-j}$ onto subspace spanned by $\mathbf U^{(-i)}$. To compute it, find a point $\hat{\mathbf z}$ in the PC space $\mathbb R^k$ that is closest to $\mathbf x^{(i)}_{-j}$ by computing $\hat{\mathbf z} = \left [\mathbf U^{(-i)}_{-j}\right]^+\mathbf x^{(i)}_{-j} \in \mathbb R^k$ where $\mathbf U^{(-i)}_{-j}$ is $\mathbf U^{(-i)}$ with $j$-th row kicked out, and $[\cdot]^+$ stands for pseudoinverse. Now map $\hat{\mathbf z}$ back to the original space: $\mathbf U^{(-i)} \left [\mathbf U^{(-i)}_{-j}\right]^+\mathbf x^{(i)}_{-j}$ and take its $j$-th coordinate $[\cdot]_j$.
An approximation to the correct approach
I don't quite understand the additional normalization used in the PLS_Toolbox, but here is one approach that goes in the same direction.
There is another way to map $\mathbf x^{(i)}_{-j}$ onto the space of principal components: $\hat{\mathbf z}_\mathrm{approx} = \left [\mathbf U^{(-i)}_{-j}\right]^\top\mathbf x^{(i)}_{-j}$, i.e. simply take the transpose instead of pseudo-inverse. In other words, the dimension that is left out for testing is not counted at all, and the corresponding weights are also simply kicked out. I think this should be less accurate, but might often be acceptable. The good thing is that the resulting formula can now be vectorized as follows (I omit the computation):
$$\begin{align}
\mathrm{PRESS_{PCA,\,approx}} &= \sum_{i=1}^n \sum_{j=1}^d \left|x^{(i)}_j - \left[\mathbf U^{(-i)} \left [\mathbf U^{(-i)}_{-j}\right]^\top\mathbf x^{(i)}_{-j}\right]_j\right|^2 \\ &= \sum_{i=1}^n \left\|\left(\mathbf I - \mathbf U \mathbf U^\top + \mathrm{diag}\{\mathbf U \mathbf U^\top\}\right) \mathbf x^{(i)}\right\|^2,
\end{align}$$
where I wrote $\mathbf U^{(-i)}$ as $\mathbf U$ for compactness, and $\mathrm{diag}\{\cdot\}$ means setting all non-diagonal elements to zero. Note that this formula looks exactly like the first one (naive PRESS) with a small correction! Note also that this correction only depends on the diagonal of $\mathbf U \mathbf U^\top$, like in the PLS_Toolbox code. However, the formula is still different from what seems to be implemented in PLS_Toolbox, and this difference I cannot explain.
Update (Feb 2018): Above I called one procedure "correct" and another
"approximate" but I am not so sure anymore that this is meaningful.
Both procedures make sense and I think neither is more correct. I really like that the "approximate" procedure has a simpler formula. Also, I remember that I had some dataset where "approximate" procedure yielded results that looked more meaningful. Unfortunately, I don't remember the details anymore.
Examples
Here is how these methods compare for two well-known datasets: Iris dataset and wine dataset. Note that the naive method produces a monotonically decreasing curve, whereas other two methods yield a curve with a minimum. Note further that in the Iris case, approximate method suggests 1 PC as the optimal number but the pseudoinverse method suggests 2 PCs. (And looking at any PCA scatterplot for the Iris dataset, it does seem that both first PCs carry some signal.) And in the wine case the pseudoinverse method clearly points at 3 PCs, whereas the approximate method cannot decide between 3 and 5.
Matlab code to perform cross-validation and plot the results
function pca_loocv(X)
%// loop over data points
for n=1:size(X,1)
Xtrain = X([1:n-1 n+1:end],:);
mu = mean(Xtrain);
Xtrain = bsxfun(@minus, Xtrain, mu);
[~,~,V] = svd(Xtrain, 'econ');
Xtest = X(n,:);
Xtest = bsxfun(@minus, Xtest, mu);
%// loop over the number of PCs
for j=1:min(size(V,2),25)
P = V(:,1:j)*V(:,1:j)'; %//'
err1 = Xtest * (eye(size(P)) - P);
err2 = Xtest * (eye(size(P)) - P + diag(diag(P)));
for k=1:size(Xtest,2)
proj = Xtest(:,[1:k-1 k+1:end])*pinv(V([1:k-1 k+1:end],1:j))'*V(:,1:j)';
err3(k) = Xtest(k) - proj(k);
end
error1(n,j) = sum(err1(:).^2);
error2(n,j) = sum(err2(:).^2);
error3(n,j) = sum(err3(:).^2);
end
end
error1 = sum(error1);
error2 = sum(error2);
error3 = sum(error3);
%// plotting code
figure
hold on
plot(error1, 'k.--')
plot(error2, 'r.-')
plot(error3, 'b.-')
legend({'Naive method', 'Approximate method', 'Pseudoinverse method'}, ...
'Location', 'NorthWest')
legend boxoff
set(gca, 'XTick', 1:length(error1))
set(gca, 'YTick', [])
xlabel('Number of PCs')
ylabel('Cross-validation error') | How to perform cross-validation for PCA to determine the number of principal components? | What you are doing is wrong: it does not make sense to compute PRESS for PCA like that! Specifically, the problem lies in your step #5.
NaĂŻve approach to PRESS for PCA
Let the data set consist of $n | How to perform cross-validation for PCA to determine the number of principal components?
What you are doing is wrong: it does not make sense to compute PRESS for PCA like that! Specifically, the problem lies in your step #5.
NaĂŻve approach to PRESS for PCA
Let the data set consist of $n$ points in $d$-dimensional space: $\mathbf x^{(i)} \in \mathbb R^d, \, i=1 \dots n$. To compute reconstruction error for a single test data point $\mathbf x^{(i)}$, you perform PCA on the training set $\mathbf X^{(-i)}$ with this point excluded, take a certain number $k$ of principal axes as columns of $\mathbf U^{(-i)}$, and find the reconstruction error as $\left \|\mathbf x^{(i)} - \hat{\mathbf x}^{(i)}\right\|^2 = \left\|\mathbf x^{(i)} - \mathbf U^{(-i)} [\mathbf U^{(-i)}]^\top \mathbf x^{(i)}\right\|^2$. PRESS is then equal to sum over all test samples $i$, so the reasonable equation seems to be: $$\mathrm{PRESS} \overset{?}{=} \sum_{i=1}^n \left\|\mathbf x^{(i)} - \mathbf U^{(-i)} [\mathbf U^{(-i)}]^\top \mathbf x^{(i)}\right\|^2.$$
For simplicity, I am ignoring the issues of centering and scaling here.
The naĂŻve approach is wrong
The problem above is that we use $\mathbf x^{(i)}$ to compute the prediction $ \hat{\mathbf x}^{(i)}$, and that is a Very Bad Thing.
Note the crucial difference to a regression case, where the formula for the reconstruction error is basically the same $\left\|\mathbf y^{(i)} - \hat{\mathbf y}^{(i)}\right\|^2$, but prediction $\hat{\mathbf y}^{(i)}$ is computed using the predictor variables and not using $\mathbf y^{(i)}$. This is not possible in PCA, because in PCA there are no dependent and independent variables: all variables are treated together.
In practice it means that PRESS as computed above can decrease with increasing number of components $k$ and never reach a minimum. Which would lead one to think that all $d$ components are significant. Or maybe in some cases it does reach a minimum, but still tends to overfit and overestimate the optimal dimensionality.
A correct approach
There are several possible approaches, see Bro et al. (2008) Cross-validation of component models: a critical look at current methods for an overview and comparison. One approach is to leave out one dimension of one data point at a time (i.e. $x^{(i)}_j$ instead of $\mathbf x^{(i)}$), so that the training data become a matrix with one missing value, and then to predict ("impute") this missing value with PCA. (One can of course randomly hold out some larger fraction of matrix elements, e.g. 10%). The problem is that computing PCA with missing values can be computationally quite slow (it relies on EM algorithm), but needs to be iterated many times here. Update: see http://alexhwilliams.info/itsneuronalblog/2018/02/26/crossval/ for a nice discussion and Python implementation (PCA with missing values is implemented via alternating least squares).
An approach that I found to be much more practical is to leave out one data point $\mathbf x^{(i)}$ at a time, compute PCA on the training data (exactly as above), but then to loop over dimensions of $\mathbf x^{(i)}$, leave them out one at a time and compute a reconstruction error using the rest. This can be quite confusing in the beginning and the formulas tend to become quite messy, but implementation is rather straightforward. Let me first give the (somewhat scary) formula, and then briefly explain it:
$$\mathrm{PRESS_{PCA}} = \sum_{i=1}^n \sum_{j=1}^d \left|x^{(i)}_j - \left[\mathbf U^{(-i)} \left [\mathbf U^{(-i)}_{-j}\right]^+\mathbf x^{(i)}_{-j}\right]_j\right|^2.$$
Consider the inner loop here. We left out one point $\mathbf x^{(i)}$ and computed $k$ principal components on the training data, $\mathbf U^{(-i)}$. Now we keep each value $x^{(i)}_j$ as the test and use the remaining dimensions $\mathbf x^{(i)}_{-j} \in \mathbb R^{d-1}$ to perform the prediction. The prediction $\hat{x}^{(i)}_j$ is the $j$-th coordinate of "the projection" (in the least squares sense) of $\mathbf x^{(i)}_{-j}$ onto subspace spanned by $\mathbf U^{(-i)}$. To compute it, find a point $\hat{\mathbf z}$ in the PC space $\mathbb R^k$ that is closest to $\mathbf x^{(i)}_{-j}$ by computing $\hat{\mathbf z} = \left [\mathbf U^{(-i)}_{-j}\right]^+\mathbf x^{(i)}_{-j} \in \mathbb R^k$ where $\mathbf U^{(-i)}_{-j}$ is $\mathbf U^{(-i)}$ with $j$-th row kicked out, and $[\cdot]^+$ stands for pseudoinverse. Now map $\hat{\mathbf z}$ back to the original space: $\mathbf U^{(-i)} \left [\mathbf U^{(-i)}_{-j}\right]^+\mathbf x^{(i)}_{-j}$ and take its $j$-th coordinate $[\cdot]_j$.
An approximation to the correct approach
I don't quite understand the additional normalization used in the PLS_Toolbox, but here is one approach that goes in the same direction.
There is another way to map $\mathbf x^{(i)}_{-j}$ onto the space of principal components: $\hat{\mathbf z}_\mathrm{approx} = \left [\mathbf U^{(-i)}_{-j}\right]^\top\mathbf x^{(i)}_{-j}$, i.e. simply take the transpose instead of pseudo-inverse. In other words, the dimension that is left out for testing is not counted at all, and the corresponding weights are also simply kicked out. I think this should be less accurate, but might often be acceptable. The good thing is that the resulting formula can now be vectorized as follows (I omit the computation):
$$\begin{align}
\mathrm{PRESS_{PCA,\,approx}} &= \sum_{i=1}^n \sum_{j=1}^d \left|x^{(i)}_j - \left[\mathbf U^{(-i)} \left [\mathbf U^{(-i)}_{-j}\right]^\top\mathbf x^{(i)}_{-j}\right]_j\right|^2 \\ &= \sum_{i=1}^n \left\|\left(\mathbf I - \mathbf U \mathbf U^\top + \mathrm{diag}\{\mathbf U \mathbf U^\top\}\right) \mathbf x^{(i)}\right\|^2,
\end{align}$$
where I wrote $\mathbf U^{(-i)}$ as $\mathbf U$ for compactness, and $\mathrm{diag}\{\cdot\}$ means setting all non-diagonal elements to zero. Note that this formula looks exactly like the first one (naive PRESS) with a small correction! Note also that this correction only depends on the diagonal of $\mathbf U \mathbf U^\top$, like in the PLS_Toolbox code. However, the formula is still different from what seems to be implemented in PLS_Toolbox, and this difference I cannot explain.
Update (Feb 2018): Above I called one procedure "correct" and another
"approximate" but I am not so sure anymore that this is meaningful.
Both procedures make sense and I think neither is more correct. I really like that the "approximate" procedure has a simpler formula. Also, I remember that I had some dataset where "approximate" procedure yielded results that looked more meaningful. Unfortunately, I don't remember the details anymore.
Examples
Here is how these methods compare for two well-known datasets: Iris dataset and wine dataset. Note that the naive method produces a monotonically decreasing curve, whereas other two methods yield a curve with a minimum. Note further that in the Iris case, approximate method suggests 1 PC as the optimal number but the pseudoinverse method suggests 2 PCs. (And looking at any PCA scatterplot for the Iris dataset, it does seem that both first PCs carry some signal.) And in the wine case the pseudoinverse method clearly points at 3 PCs, whereas the approximate method cannot decide between 3 and 5.
Matlab code to perform cross-validation and plot the results
function pca_loocv(X)
%// loop over data points
for n=1:size(X,1)
Xtrain = X([1:n-1 n+1:end],:);
mu = mean(Xtrain);
Xtrain = bsxfun(@minus, Xtrain, mu);
[~,~,V] = svd(Xtrain, 'econ');
Xtest = X(n,:);
Xtest = bsxfun(@minus, Xtest, mu);
%// loop over the number of PCs
for j=1:min(size(V,2),25)
P = V(:,1:j)*V(:,1:j)'; %//'
err1 = Xtest * (eye(size(P)) - P);
err2 = Xtest * (eye(size(P)) - P + diag(diag(P)));
for k=1:size(Xtest,2)
proj = Xtest(:,[1:k-1 k+1:end])*pinv(V([1:k-1 k+1:end],1:j))'*V(:,1:j)';
err3(k) = Xtest(k) - proj(k);
end
error1(n,j) = sum(err1(:).^2);
error2(n,j) = sum(err2(:).^2);
error3(n,j) = sum(err3(:).^2);
end
end
error1 = sum(error1);
error2 = sum(error2);
error3 = sum(error3);
%// plotting code
figure
hold on
plot(error1, 'k.--')
plot(error2, 'r.-')
plot(error3, 'b.-')
legend({'Naive method', 'Approximate method', 'Pseudoinverse method'}, ...
'Location', 'NorthWest')
legend boxoff
set(gca, 'XTick', 1:length(error1))
set(gca, 'YTick', [])
xlabel('Number of PCs')
ylabel('Cross-validation error') | How to perform cross-validation for PCA to determine the number of principal components?
What you are doing is wrong: it does not make sense to compute PRESS for PCA like that! Specifically, the problem lies in your step #5.
NaĂŻve approach to PRESS for PCA
Let the data set consist of $n |
18,369 | How to perform cross-validation for PCA to determine the number of principal components? | To add an even more general point to @amoeba's nice answer:
One practical and crucial difference between supervised and unsupervised models is that for the unsupervised models you need to think much harder what you'd consider equivalent and what not.
Supervised models always have their final output $\hat y$ in a way where you don't need to care much about this: by definition and construction, $\hat y$ claims to have the same meaning as $y$, so you can directly compare it.
In order to construct meaningful performance measures, you need to think what kinds of freedom of the model are meaningless for your application and which are not. That would lead to a PRESS on the scores, possibly (usually?) after some kind of Procrustes-like rotation/flipping.
PRESS on x My guess is (I don't have time now to find out what their 2 lines of code do - but maybe you could step through the lines and have a look?):
In order to get a measure that is useful to determine a good model complexity from a measure that gives a goodness of fit that typically will increase until the full rank model is reached, you need to penalize for too complex models. Which in turn means that this penalization is a) crucial and b) adjusting the penalty will adjust the chosen complexity.
Side note: I'd just like to add that I'd be very careful with this type of automated model complexity optimzation. In my experience many of these algorithms only yield pseudo-objectivity, and often come at the cost of working well only for certain types of data. | How to perform cross-validation for PCA to determine the number of principal components? | To add an even more general point to @amoeba's nice answer:
One practical and crucial difference between supervised and unsupervised models is that for the unsupervised models you need to think much h | How to perform cross-validation for PCA to determine the number of principal components?
To add an even more general point to @amoeba's nice answer:
One practical and crucial difference between supervised and unsupervised models is that for the unsupervised models you need to think much harder what you'd consider equivalent and what not.
Supervised models always have their final output $\hat y$ in a way where you don't need to care much about this: by definition and construction, $\hat y$ claims to have the same meaning as $y$, so you can directly compare it.
In order to construct meaningful performance measures, you need to think what kinds of freedom of the model are meaningless for your application and which are not. That would lead to a PRESS on the scores, possibly (usually?) after some kind of Procrustes-like rotation/flipping.
PRESS on x My guess is (I don't have time now to find out what their 2 lines of code do - but maybe you could step through the lines and have a look?):
In order to get a measure that is useful to determine a good model complexity from a measure that gives a goodness of fit that typically will increase until the full rank model is reached, you need to penalize for too complex models. Which in turn means that this penalization is a) crucial and b) adjusting the penalty will adjust the chosen complexity.
Side note: I'd just like to add that I'd be very careful with this type of automated model complexity optimzation. In my experience many of these algorithms only yield pseudo-objectivity, and often come at the cost of working well only for certain types of data. | How to perform cross-validation for PCA to determine the number of principal components?
To add an even more general point to @amoeba's nice answer:
One practical and crucial difference between supervised and unsupervised models is that for the unsupervised models you need to think much h |
18,370 | Is the MCMC simply a probabilistic gradient descent? | The key difference is that we are not attempting to optimize anything. Instead, we are attempting to estimate a density function - but not by estimating in some optimal manner a small number of parameters, instead by generating a lot of random numbers from the density function and going from there. So MCMC is really a random number generation technique, not an optimization technique.
To see what a gradient descent-like algorithm with a stochastic component looks like, check out stochastic approximation. The simultaneous perturbation variant is quite effective and accessible. | Is the MCMC simply a probabilistic gradient descent? | The key difference is that we are not attempting to optimize anything. Instead, we are attempting to estimate a density function - but not by estimating in some optimal manner a small number of param | Is the MCMC simply a probabilistic gradient descent?
The key difference is that we are not attempting to optimize anything. Instead, we are attempting to estimate a density function - but not by estimating in some optimal manner a small number of parameters, instead by generating a lot of random numbers from the density function and going from there. So MCMC is really a random number generation technique, not an optimization technique.
To see what a gradient descent-like algorithm with a stochastic component looks like, check out stochastic approximation. The simultaneous perturbation variant is quite effective and accessible. | Is the MCMC simply a probabilistic gradient descent?
The key difference is that we are not attempting to optimize anything. Instead, we are attempting to estimate a density function - but not by estimating in some optimal manner a small number of param |
18,371 | Is the MCMC simply a probabilistic gradient descent? | I know this question has been answered, but if anyone is interested in learning more on on jbowman's suggestion of random proposals with an acceptance step see Simulated Annealing:
http://en.wikipedia.org/wiki/Simulated_annealing
Excerpt:
"The method is an adaptation of the Metropolis-Hastings algorithm, a
Monte Carlo method to generate sample states of a thermodynamic
system..."
Typically slower then SGD, it's a good MC-based method for seeking global minima.
Java implementation for reference: https://github.com/wlmiller/BKTSimulatedAnnealing | Is the MCMC simply a probabilistic gradient descent? | I know this question has been answered, but if anyone is interested in learning more on on jbowman's suggestion of random proposals with an acceptance step see Simulated Annealing:
http://en.wikipedia | Is the MCMC simply a probabilistic gradient descent?
I know this question has been answered, but if anyone is interested in learning more on on jbowman's suggestion of random proposals with an acceptance step see Simulated Annealing:
http://en.wikipedia.org/wiki/Simulated_annealing
Excerpt:
"The method is an adaptation of the Metropolis-Hastings algorithm, a
Monte Carlo method to generate sample states of a thermodynamic
system..."
Typically slower then SGD, it's a good MC-based method for seeking global minima.
Java implementation for reference: https://github.com/wlmiller/BKTSimulatedAnnealing | Is the MCMC simply a probabilistic gradient descent?
I know this question has been answered, but if anyone is interested in learning more on on jbowman's suggestion of random proposals with an acceptance step see Simulated Annealing:
http://en.wikipedia |
18,372 | Is the MCMC simply a probabilistic gradient descent? | While the accepted answer here is true, it is a bit misleading in light of recent theoretical work.
When you are doing gradient descent, you are trying to find the maximum a posterior (MAP) - aka the mode of your posterior distribution. While stochastic gradient descent (SGD) will only give you a point estimate, it will give you a trajectory that will allow you to explore the posterior density around your MAP estimate.
There is a ton of emerging literature around this, starting with Neal 2012 / Welling 2011 with Langevin dynamics and later Mandt 2017, Maddox 2019 and Zhang 2021. At this point, it is safe to say that SGD will generate a single MCMC draw from your posterior distribution. | Is the MCMC simply a probabilistic gradient descent? | While the accepted answer here is true, it is a bit misleading in light of recent theoretical work.
When you are doing gradient descent, you are trying to find the maximum a posterior (MAP) - aka the | Is the MCMC simply a probabilistic gradient descent?
While the accepted answer here is true, it is a bit misleading in light of recent theoretical work.
When you are doing gradient descent, you are trying to find the maximum a posterior (MAP) - aka the mode of your posterior distribution. While stochastic gradient descent (SGD) will only give you a point estimate, it will give you a trajectory that will allow you to explore the posterior density around your MAP estimate.
There is a ton of emerging literature around this, starting with Neal 2012 / Welling 2011 with Langevin dynamics and later Mandt 2017, Maddox 2019 and Zhang 2021. At this point, it is safe to say that SGD will generate a single MCMC draw from your posterior distribution. | Is the MCMC simply a probabilistic gradient descent?
While the accepted answer here is true, it is a bit misleading in light of recent theoretical work.
When you are doing gradient descent, you are trying to find the maximum a posterior (MAP) - aka the |
18,373 | PCA on high-dimensional text data before random forest classification? | Leo Breiman wrote that "dimensionality can be a blessing". In general, random forests can run on large data sets without problems. How large is your data? Different fields handle things in different ways depending on subject-matter knowledge. For example, in gene expression studies genes are often discarded based on low variance (no peeking at the outcome) in a process sometimes called non-specific filtering. This can help with the running time on random forests. But it is not required.
Sticking with the gene expression example, sometimes analysts use PCA scores to represent gene expression measurements. The idea is to replace similar profiles with one score that is potentially less messy. Random forests can be run both on the original variables or the PCA scores (a surrogate for the variables). Some have reported better results with this approach, but there are no good comparisons to my knowledge.
In sum, there is no need to do PCA before running RF. But you can. The interpretation could change depending on your goals. If all you want to do is predict, the interpretation may be less important. | PCA on high-dimensional text data before random forest classification? | Leo Breiman wrote that "dimensionality can be a blessing". In general, random forests can run on large data sets without problems. How large is your data? Different fields handle things in different w | PCA on high-dimensional text data before random forest classification?
Leo Breiman wrote that "dimensionality can be a blessing". In general, random forests can run on large data sets without problems. How large is your data? Different fields handle things in different ways depending on subject-matter knowledge. For example, in gene expression studies genes are often discarded based on low variance (no peeking at the outcome) in a process sometimes called non-specific filtering. This can help with the running time on random forests. But it is not required.
Sticking with the gene expression example, sometimes analysts use PCA scores to represent gene expression measurements. The idea is to replace similar profiles with one score that is potentially less messy. Random forests can be run both on the original variables or the PCA scores (a surrogate for the variables). Some have reported better results with this approach, but there are no good comparisons to my knowledge.
In sum, there is no need to do PCA before running RF. But you can. The interpretation could change depending on your goals. If all you want to do is predict, the interpretation may be less important. | PCA on high-dimensional text data before random forest classification?
Leo Breiman wrote that "dimensionality can be a blessing". In general, random forests can run on large data sets without problems. How large is your data? Different fields handle things in different w |
18,374 | PCA on high-dimensional text data before random forest classification? | I'd like to add my two cents to this since I thought the existing answers were incomplete.
Performing PCA can be especially useful before training a random forest (or LightGBM, or any other decision tree-based method) for one particular reason I illustrated in the pic below.
Basically, it can make the process of finding the perfect decision boundary much easier by aligning your training set along the directions with highest variance.
Decision trees are sensitive to rotation of the data, since the decision boundary they create is always vertical/horizontal (i.e. perpendicular to one of the axes). Therefore, if your data looks like the left pic, it will take a much bigger tree to separate these two clusters (in this case it's an 8 layer tree). But if you align your data along its principal components (like in the right pic), you can achieve perfect separation with just one layer!
Of course, not all datasets are distributed like this, so PCA may not always help, but it's still useful to try it and see if it does. And just a reminder, don't forget to normalize your dataset to the unit variance before performing PCA!
P.S.: As for dimensionality reduction, I'll agree with the rest of folks in that it's not usually as big of a problem for random forests as for other algorithms. But still, it might help speed up your training a little. Decision tree training time is O(nmlog(m)), where n is the number of training instances, m - number of dimensions. And although random forests randomly pick a subset of dimensions for each tree to be trained on, the lower fraction of the total number of dimensions you pick, the more trees you need to train to achieve good performance. | PCA on high-dimensional text data before random forest classification? | I'd like to add my two cents to this since I thought the existing answers were incomplete.
Performing PCA can be especially useful before training a random forest (or LightGBM, or any other decision t | PCA on high-dimensional text data before random forest classification?
I'd like to add my two cents to this since I thought the existing answers were incomplete.
Performing PCA can be especially useful before training a random forest (or LightGBM, or any other decision tree-based method) for one particular reason I illustrated in the pic below.
Basically, it can make the process of finding the perfect decision boundary much easier by aligning your training set along the directions with highest variance.
Decision trees are sensitive to rotation of the data, since the decision boundary they create is always vertical/horizontal (i.e. perpendicular to one of the axes). Therefore, if your data looks like the left pic, it will take a much bigger tree to separate these two clusters (in this case it's an 8 layer tree). But if you align your data along its principal components (like in the right pic), you can achieve perfect separation with just one layer!
Of course, not all datasets are distributed like this, so PCA may not always help, but it's still useful to try it and see if it does. And just a reminder, don't forget to normalize your dataset to the unit variance before performing PCA!
P.S.: As for dimensionality reduction, I'll agree with the rest of folks in that it's not usually as big of a problem for random forests as for other algorithms. But still, it might help speed up your training a little. Decision tree training time is O(nmlog(m)), where n is the number of training instances, m - number of dimensions. And although random forests randomly pick a subset of dimensions for each tree to be trained on, the lower fraction of the total number of dimensions you pick, the more trees you need to train to achieve good performance. | PCA on high-dimensional text data before random forest classification?
I'd like to add my two cents to this since I thought the existing answers were incomplete.
Performing PCA can be especially useful before training a random forest (or LightGBM, or any other decision t |
18,375 | PCA on high-dimensional text data before random forest classification? | PCA before random forest can be useful not for dimensionality reduction but to give you data a shape where random forest can perform better.
I am quiet sure that in general if you transform your data with PCA keeping the same dimensionality of the original data you will have a better classification with random forest | PCA on high-dimensional text data before random forest classification? | PCA before random forest can be useful not for dimensionality reduction but to give you data a shape where random forest can perform better.
I am quiet sure that in general if you transform your data | PCA on high-dimensional text data before random forest classification?
PCA before random forest can be useful not for dimensionality reduction but to give you data a shape where random forest can perform better.
I am quiet sure that in general if you transform your data with PCA keeping the same dimensionality of the original data you will have a better classification with random forest | PCA on high-dimensional text data before random forest classification?
PCA before random forest can be useful not for dimensionality reduction but to give you data a shape where random forest can perform better.
I am quiet sure that in general if you transform your data |
18,376 | PCA on high-dimensional text data before random forest classification? | I think an other important observation here is the role of the parameter m_try, indicating the number of directions to try for splitting each individual tree. There the RF model is essentially doing an automatic feature engineering and, if chosen carefully, should remove the need of dimensionality reduction. Of course, m_try should be optimized to a high value if the number of irrelevant features is huge, increasing the computational cost.
Something that is not clear to me is if optimizing parameters of RF, e.g. using the mtry direction, we can remove the need of dimensionality reduction at 100%. | PCA on high-dimensional text data before random forest classification? | I think an other important observation here is the role of the parameter m_try, indicating the number of directions to try for splitting each individual tree. There the RF model is essentially doing a | PCA on high-dimensional text data before random forest classification?
I think an other important observation here is the role of the parameter m_try, indicating the number of directions to try for splitting each individual tree. There the RF model is essentially doing an automatic feature engineering and, if chosen carefully, should remove the need of dimensionality reduction. Of course, m_try should be optimized to a high value if the number of irrelevant features is huge, increasing the computational cost.
Something that is not clear to me is if optimizing parameters of RF, e.g. using the mtry direction, we can remove the need of dimensionality reduction at 100%. | PCA on high-dimensional text data before random forest classification?
I think an other important observation here is the role of the parameter m_try, indicating the number of directions to try for splitting each individual tree. There the RF model is essentially doing a |
18,377 | How to expand data frame in R | While it is a very useful package, I think reshape is overkill in this case, rep can do the job.
Here are some example data:
df <- data.frame(
name=c("Person 1", "Person 2", "Person 3", "Person 1", "Person 2", "Person 3"),
group=c("A", "A", "A", "B", "B", "B"),
count=c(3,1,0,5,0,1))
Now, to “expand” it:
expanded <- data.frame(name = rep(df$name, df$count),
group = rep(df$group, df$count))
I could not find a way to work directly on the data frame off the top of my head so I am working on each variable separately and then reassembling them, which is a bit ugly but should be OK as long as you take care of always using the same variable for the counts. | How to expand data frame in R | While it is a very useful package, I think reshape is overkill in this case, rep can do the job.
Here are some example data:
df <- data.frame(
name=c("Person 1", "Person 2", "Person 3", "Person 1 | How to expand data frame in R
While it is a very useful package, I think reshape is overkill in this case, rep can do the job.
Here are some example data:
df <- data.frame(
name=c("Person 1", "Person 2", "Person 3", "Person 1", "Person 2", "Person 3"),
group=c("A", "A", "A", "B", "B", "B"),
count=c(3,1,0,5,0,1))
Now, to “expand” it:
expanded <- data.frame(name = rep(df$name, df$count),
group = rep(df$group, df$count))
I could not find a way to work directly on the data frame off the top of my head so I am working on each variable separately and then reassembling them, which is a bit ugly but should be OK as long as you take care of always using the same variable for the counts. | How to expand data frame in R
While it is a very useful package, I think reshape is overkill in this case, rep can do the job.
Here are some example data:
df <- data.frame(
name=c("Person 1", "Person 2", "Person 3", "Person 1 |
18,378 | How to expand data frame in R | You can use the untable function from the reshape package.
Given the above df (by @Gaël Laurans)
library(reshape)
expanded<-untable(df[,c(1,2)], num=df[,3])
name group
1 Person 1 A
1.1 Person 1 A
1.2 Person 1 A
2 Person 2 A
4 Person 1 B
4.1 Person 1 B
4.2 Person 1 B
4.3 Person 1 B
4.4 Person 1 B
6 Person 3 B | How to expand data frame in R | You can use the untable function from the reshape package.
Given the above df (by @Gaël Laurans)
library(reshape)
expanded<-untable(df[,c(1,2)], num=df[,3])
name group
1 Person 1 A
1.1 Person | How to expand data frame in R
You can use the untable function from the reshape package.
Given the above df (by @Gaël Laurans)
library(reshape)
expanded<-untable(df[,c(1,2)], num=df[,3])
name group
1 Person 1 A
1.1 Person 1 A
1.2 Person 1 A
2 Person 2 A
4 Person 1 B
4.1 Person 1 B
4.2 Person 1 B
4.3 Person 1 B
4.4 Person 1 B
6 Person 3 B | How to expand data frame in R
You can use the untable function from the reshape package.
Given the above df (by @Gaël Laurans)
library(reshape)
expanded<-untable(df[,c(1,2)], num=df[,3])
name group
1 Person 1 A
1.1 Person |
18,379 | How to expand data frame in R | And uncount from tidyr now gives the same result as above.
library(tidyr)
df %>% uncount(Count) | How to expand data frame in R | And uncount from tidyr now gives the same result as above.
library(tidyr)
df %>% uncount(Count) | How to expand data frame in R
And uncount from tidyr now gives the same result as above.
library(tidyr)
df %>% uncount(Count) | How to expand data frame in R
And uncount from tidyr now gives the same result as above.
library(tidyr)
df %>% uncount(Count) |
18,380 | What are average partial effects? | I don't think there is a consensus on terminology here, but the following is what I think most people have in mind when someone says "average partial effect" or "average marginal effect".
Suppose, for concreteness, that we are analyzing a population of people. Consider the linear model
$$
Y = \beta X + U,
$$
where $(Y,X)$ are observed scalar random variables, and $U$ is an unobserved scalar random variable. Suppose that $\beta$ is an unknown constant. Suppose this is a structural model, meaning that it has a causal interpretation. So, if we could pick a person out of the population and increase their value of $X$ by 1 unit, then their value of $Y$ would increase by $\beta$. Then $\beta$ is called the marginal or causal effect of $X$ on $Y$.
Now, assuming that $\beta$ is a constant means that no matter which person we pick out of the population, a one unit increase in $X$ has the same effect on $Y$ --- it increases $Y$ by $\beta$. This is clearly restrictive. We can relax this constant effect assumption by supposing that $\beta$ itself a random variable --- each person has a different value of $\beta$. Consequently, there is an entire distribution of marginal effects, the distribution of $\beta$. The mean of this distribution, $E(\beta)$, is called the average marginal effect (AME), or average partial effect. If we were to increase everyone's value of $X$ by one unit, then the average change in $Y$ is given by the AME.
Alternatively, consider the nonlinear model
$$
Y = m(X,U),
$$
where again $(Y,X)$ are scalar observables and $U$ is a scalar unobservable, and $m$ is some unknown function (assume it is differentiable for simplicity). Here the causal/marginal effect of $X$ on $Y$ is $\partial m(x,u)/\partial x$. This value may depend on the value of $U$. Thus, even if we look at people who all have the same observed value of $X$, a small increase in $X$ will not necessarily increase $Y$ by the same amount, because each person may have a different value of $U$. Thus there is a distribution of marginal effects, just as in the linear model above. And, again, we can look at the mean of this distribution:
$$
E_{U \mid X} \left[ \frac{\partial m(x,U)}{\partial x} \mid X=x \right].
$$
This mean is called the average marginal effect, given $X=x$. If we assume $U$ is independent of $X$, as is sometimes done, then the AME at $X=x$ is simply
$$
E_{U} \left[ \frac{\partial m(x,U)}{\partial x} \right].
$$
In general, an average marginal effect is just a derivative (or sometimes a finite difference), of a structural function (such as $m(x,u)$ or $\beta x + u$) with respect to an observed variable $X$, averaged over an unobserved variable $U$, perhaps within a particular subgroup of people with $X=x$. The precise form of this effect depends on the specific model under consideration.
Also note that these objects might also be called average treatment effects, especially when considering a finite difference. For example, the difference of the structural function at $X=1$ ('treated') and at $X=0$ ('untreated'), averaged over the unobservables.
Finally, to be clear, note that when I refer to 'distributions' above, I mean distributions over the population of people. Each person in the population has a value of $U$, of $X$, and of $Y$. Hence there is a distribution of these values if I look over all people in the population. The thought experiment here is the following. Take all people with $X=x$. Now take one of these people, and increase their $X$ value by a small amount, but keep their $U$ value the same, and we write down the change in their $Y$ value. We do this for each person with $X=x$, and then average the values. This is what it means to average over $U \mid X=x$. | What are average partial effects? | I don't think there is a consensus on terminology here, but the following is what I think most people have in mind when someone says "average partial effect" or "average marginal effect".
Suppose, for | What are average partial effects?
I don't think there is a consensus on terminology here, but the following is what I think most people have in mind when someone says "average partial effect" or "average marginal effect".
Suppose, for concreteness, that we are analyzing a population of people. Consider the linear model
$$
Y = \beta X + U,
$$
where $(Y,X)$ are observed scalar random variables, and $U$ is an unobserved scalar random variable. Suppose that $\beta$ is an unknown constant. Suppose this is a structural model, meaning that it has a causal interpretation. So, if we could pick a person out of the population and increase their value of $X$ by 1 unit, then their value of $Y$ would increase by $\beta$. Then $\beta$ is called the marginal or causal effect of $X$ on $Y$.
Now, assuming that $\beta$ is a constant means that no matter which person we pick out of the population, a one unit increase in $X$ has the same effect on $Y$ --- it increases $Y$ by $\beta$. This is clearly restrictive. We can relax this constant effect assumption by supposing that $\beta$ itself a random variable --- each person has a different value of $\beta$. Consequently, there is an entire distribution of marginal effects, the distribution of $\beta$. The mean of this distribution, $E(\beta)$, is called the average marginal effect (AME), or average partial effect. If we were to increase everyone's value of $X$ by one unit, then the average change in $Y$ is given by the AME.
Alternatively, consider the nonlinear model
$$
Y = m(X,U),
$$
where again $(Y,X)$ are scalar observables and $U$ is a scalar unobservable, and $m$ is some unknown function (assume it is differentiable for simplicity). Here the causal/marginal effect of $X$ on $Y$ is $\partial m(x,u)/\partial x$. This value may depend on the value of $U$. Thus, even if we look at people who all have the same observed value of $X$, a small increase in $X$ will not necessarily increase $Y$ by the same amount, because each person may have a different value of $U$. Thus there is a distribution of marginal effects, just as in the linear model above. And, again, we can look at the mean of this distribution:
$$
E_{U \mid X} \left[ \frac{\partial m(x,U)}{\partial x} \mid X=x \right].
$$
This mean is called the average marginal effect, given $X=x$. If we assume $U$ is independent of $X$, as is sometimes done, then the AME at $X=x$ is simply
$$
E_{U} \left[ \frac{\partial m(x,U)}{\partial x} \right].
$$
In general, an average marginal effect is just a derivative (or sometimes a finite difference), of a structural function (such as $m(x,u)$ or $\beta x + u$) with respect to an observed variable $X$, averaged over an unobserved variable $U$, perhaps within a particular subgroup of people with $X=x$. The precise form of this effect depends on the specific model under consideration.
Also note that these objects might also be called average treatment effects, especially when considering a finite difference. For example, the difference of the structural function at $X=1$ ('treated') and at $X=0$ ('untreated'), averaged over the unobservables.
Finally, to be clear, note that when I refer to 'distributions' above, I mean distributions over the population of people. Each person in the population has a value of $U$, of $X$, and of $Y$. Hence there is a distribution of these values if I look over all people in the population. The thought experiment here is the following. Take all people with $X=x$. Now take one of these people, and increase their $X$ value by a small amount, but keep their $U$ value the same, and we write down the change in their $Y$ value. We do this for each person with $X=x$, and then average the values. This is what it means to average over $U \mid X=x$. | What are average partial effects?
I don't think there is a consensus on terminology here, but the following is what I think most people have in mind when someone says "average partial effect" or "average marginal effect".
Suppose, for |
18,381 | What are average partial effects? | Average Partial Effects (APE) are the contribution of each variable on the outcome scale, conditional on the other variables involved in the link function transformation of the linear predictor
Average Marginal Effects (AME) are the marginal contribution of each variable on the scale of the linear predictor.
This documentation from the margins package for R is quite useful for understanding. | What are average partial effects? | Average Partial Effects (APE) are the contribution of each variable on the outcome scale, conditional on the other variables involved in the link function transformation of the linear predictor
Averag | What are average partial effects?
Average Partial Effects (APE) are the contribution of each variable on the outcome scale, conditional on the other variables involved in the link function transformation of the linear predictor
Average Marginal Effects (AME) are the marginal contribution of each variable on the scale of the linear predictor.
This documentation from the margins package for R is quite useful for understanding. | What are average partial effects?
Average Partial Effects (APE) are the contribution of each variable on the outcome scale, conditional on the other variables involved in the link function transformation of the linear predictor
Averag |
18,382 | What is the meaning of a gold standard? | Say that you want to measure a certain polluant in drinking water, the golden standard will be the method which detects it with the highest sensitivity and accuracy. Any other method can then be compared to it, knowing that -under certain conditions- the golden standard is the best (e.g.: if you need to measure the polluant on site, the golden standard will not be any method that require huge machinery to be used, as you will not be able to bring it with you).
I think the Wikipedia article explains it quite well:
In medicine and statistics, gold standard test refers to a diagnostic, test or benchmark that is the best available under reasonable conditions. It does not have to be necessarily the best possible test for the condition in absolute terms. For example, in medicine, dealing with conditions that require an autopsy to have a perfect diagnosis, the gold standard test is normally less accurate than the autopsy. Anyway, it is obviously preferred by the patients. | What is the meaning of a gold standard? | Say that you want to measure a certain polluant in drinking water, the golden standard will be the method which detects it with the highest sensitivity and accuracy. Any other method can then be compa | What is the meaning of a gold standard?
Say that you want to measure a certain polluant in drinking water, the golden standard will be the method which detects it with the highest sensitivity and accuracy. Any other method can then be compared to it, knowing that -under certain conditions- the golden standard is the best (e.g.: if you need to measure the polluant on site, the golden standard will not be any method that require huge machinery to be used, as you will not be able to bring it with you).
I think the Wikipedia article explains it quite well:
In medicine and statistics, gold standard test refers to a diagnostic, test or benchmark that is the best available under reasonable conditions. It does not have to be necessarily the best possible test for the condition in absolute terms. For example, in medicine, dealing with conditions that require an autopsy to have a perfect diagnosis, the gold standard test is normally less accurate than the autopsy. Anyway, it is obviously preferred by the patients. | What is the meaning of a gold standard?
Say that you want to measure a certain polluant in drinking water, the golden standard will be the method which detects it with the highest sensitivity and accuracy. Any other method can then be compa |
18,383 | What is the meaning of a gold standard? | A gold standard is a standard accepted as the most valid one and the most used. You can apply the expression for everything... But you can always accept or critic the standard, especially in the case of a dataset. | What is the meaning of a gold standard? | A gold standard is a standard accepted as the most valid one and the most used. You can apply the expression for everything... But you can always accept or critic the standard, especially in the case | What is the meaning of a gold standard?
A gold standard is a standard accepted as the most valid one and the most used. You can apply the expression for everything... But you can always accept or critic the standard, especially in the case of a dataset. | What is the meaning of a gold standard?
A gold standard is a standard accepted as the most valid one and the most used. You can apply the expression for everything... But you can always accept or critic the standard, especially in the case |
18,384 | What is the meaning of a gold standard? | I have observed the term "gold standard" in quotes more times than not, so I take it to mean something that is highly subjective. Even in the Wikipedia article some paragraphs refer to it in quotes. The OP is also referring to a "gold standard dataset" which I take it to mean a "Gold Standard" for descriminant Analysis, as in Fishers' Iris dataset being the "Gold Standard". But I am not 100% sure usage is consistant. | What is the meaning of a gold standard? | I have observed the term "gold standard" in quotes more times than not, so I take it to mean something that is highly subjective. Even in the Wikipedia article some paragraphs refer to it in quotes. T | What is the meaning of a gold standard?
I have observed the term "gold standard" in quotes more times than not, so I take it to mean something that is highly subjective. Even in the Wikipedia article some paragraphs refer to it in quotes. The OP is also referring to a "gold standard dataset" which I take it to mean a "Gold Standard" for descriminant Analysis, as in Fishers' Iris dataset being the "Gold Standard". But I am not 100% sure usage is consistant. | What is the meaning of a gold standard?
I have observed the term "gold standard" in quotes more times than not, so I take it to mean something that is highly subjective. Even in the Wikipedia article some paragraphs refer to it in quotes. T |
18,385 | What is the meaning of a gold standard? | The term "gold standard" has been used a lot with respect to No Child Left Behind. One important component of the legislation is that it established the need for the education field to move towards interventions and practices that have been demonstrated to be effective in rigorous studies. In the NCLB materials, research designs have been classified into three categories based on the strength of the conclusions they warrant. Randomized control trials (i.e. randomized or true experiments) are the only designs that provide "strong evidence" of effectiveness. Thus they have been dubbed the "gold standard" in educational research. Well-designed true experiments are given higher precedence in the awarding of federal research grants. | What is the meaning of a gold standard? | The term "gold standard" has been used a lot with respect to No Child Left Behind. One important component of the legislation is that it established the need for the education field to move towards in | What is the meaning of a gold standard?
The term "gold standard" has been used a lot with respect to No Child Left Behind. One important component of the legislation is that it established the need for the education field to move towards interventions and practices that have been demonstrated to be effective in rigorous studies. In the NCLB materials, research designs have been classified into three categories based on the strength of the conclusions they warrant. Randomized control trials (i.e. randomized or true experiments) are the only designs that provide "strong evidence" of effectiveness. Thus they have been dubbed the "gold standard" in educational research. Well-designed true experiments are given higher precedence in the awarding of federal research grants. | What is the meaning of a gold standard?
The term "gold standard" has been used a lot with respect to No Child Left Behind. One important component of the legislation is that it established the need for the education field to move towards in |
18,386 | What is the meaning of a gold standard? | In a challenge, this usually mean the answer to the test set, previously hidden from participants. | What is the meaning of a gold standard? | In a challenge, this usually mean the answer to the test set, previously hidden from participants. | What is the meaning of a gold standard?
In a challenge, this usually mean the answer to the test set, previously hidden from participants. | What is the meaning of a gold standard?
In a challenge, this usually mean the answer to the test set, previously hidden from participants. |
18,387 | What is the meaning of a gold standard? | Golden standard or Gold standard is a term used to describe a collection of tags that can be gathered from experts. This corpora is costly because you have to get the expert skills to work in tagging, they are high-quality and accurate. | What is the meaning of a gold standard? | Golden standard or Gold standard is a term used to describe a collection of tags that can be gathered from experts. This corpora is costly because you have to get the expert skills to work in tagging, | What is the meaning of a gold standard?
Golden standard or Gold standard is a term used to describe a collection of tags that can be gathered from experts. This corpora is costly because you have to get the expert skills to work in tagging, they are high-quality and accurate. | What is the meaning of a gold standard?
Golden standard or Gold standard is a term used to describe a collection of tags that can be gathered from experts. This corpora is costly because you have to get the expert skills to work in tagging, |
18,388 | What is the meaning of a gold standard? | This question relates only figuratively to gold.
A “gold standard” is an accepted standard that people can look to as an accurate and reliable reference. In medicine, for example, researchers often refer to blood assay as a gold standard for checking patients’ medication adherence. As with many such standards, however, because it is expensive and time-consuming, researchers search for quicker and less expensive, but still consistent ways of achieving comparable results. They gauge the value of their methods by comparing them to those achieved using the so-called gold standard.
In the case of a dataset, a gold standard would be one accepted as the most accurate and reliable of its kind, which could be used as a measure of those qualities in other datasets. | What is the meaning of a gold standard? | This question relates only figuratively to gold.
A “gold standard” is an accepted standard that people can look to as an accurate and reliable reference. In medicine, for example, researchers often re | What is the meaning of a gold standard?
This question relates only figuratively to gold.
A “gold standard” is an accepted standard that people can look to as an accurate and reliable reference. In medicine, for example, researchers often refer to blood assay as a gold standard for checking patients’ medication adherence. As with many such standards, however, because it is expensive and time-consuming, researchers search for quicker and less expensive, but still consistent ways of achieving comparable results. They gauge the value of their methods by comparing them to those achieved using the so-called gold standard.
In the case of a dataset, a gold standard would be one accepted as the most accurate and reliable of its kind, which could be used as a measure of those qualities in other datasets. | What is the meaning of a gold standard?
This question relates only figuratively to gold.
A “gold standard” is an accepted standard that people can look to as an accurate and reliable reference. In medicine, for example, researchers often re |
18,389 | What is the meaning of a gold standard? | The gold standard is randomization of your assigning of sample into different groups for your experiment and a double blind. | What is the meaning of a gold standard? | The gold standard is randomization of your assigning of sample into different groups for your experiment and a double blind. | What is the meaning of a gold standard?
The gold standard is randomization of your assigning of sample into different groups for your experiment and a double blind. | What is the meaning of a gold standard?
The gold standard is randomization of your assigning of sample into different groups for your experiment and a double blind. |
18,390 | Odds made simple | On another thread there is a much broader answer by @gung that also deals with related technical issues such as the odds ratio, but I am going to stick to the topic at hand: how to interpret odds, and particularly the formulation "$a$ to $b$". As a beginner's question, it's worth thinking how "odds" are expressed in everyday speech (especially in betting parlance) as well as what odds mean to a statistician, because discrepancies between the two are problematic for learners.
For odds as expressed by a statistician, your contention is correct. Suppose a bag contains four tokens, of which three are $\color{aquamarine}{\text{aquamarine}}$ and one is $\color{brown}{\text{brown}}$, and one token is selected at random. The probability that the selected token is aquamarine is 3 out of 4, i.e. $\frac{3}{4}$, often read "3 in 4". With equally likely outcomes, the odds for aquamarine would be calculated as the number of favourable outcomes (3) divided by the number of unfavourable outcomes (1), which is $\frac{3}{1} = 3$, often read as $\color{aquamarine}{\text{three}}\text{ to }\color{brown}{\text{one}}$ or just as the number "three". More generally, you could take the fraction of "favourable outcomes over unfavourable outcomes" and cancel (divide) both numerator and denominator by the total number of outcomes, to obtain "the probability of a favourable outcome over the probability of an unfavourable outcome", from which a little algebra gives:
$$\text{Odds} = \frac{p}{1-p} \implies p = \frac{\text{Odds}}{1 + \text{Odds}} $$
Odds as expressed by a bookmaker are usually quoted either as "odds against" or "odds on", and which way they are written seems to be a common cause of confusion. In so-called British odds, fractional odds or traditional odds, the odds for aquamarine would be written "3/1 on" or "3-1 on", read as $\color{aquamarine}{\text{three}}\text{ to }\color{brown}{\text{one}}\text{ on}$.* For a gambler, the fact these are "odds on" indicates that a stake of £3 on aquamarine would return £1 profit if successful (they actually receive £4, of which £3 is simply the return of the original stake) whereas a failed bet results in the loss of the £3 stake. We can see these are "fair odds" because the gambler has three chances of gaining £1 and one chance of losing £3, so on average there is no expected gain or loss. So far, so little discrepancy: "odds on" are simply the "odds in favour" preferred by statisticians.
For events with a 50% probability, such as heads on a coin toss — two equally likely outcomes of success or failure — a statistician would say the odds are "one to one", $\frac{1}{1}$ or simply $1$ whereas a fair bookmaker would give fractional odds of 1/1 (read as "evens"). So no problems here either; however, when the probability falls below 50%, we see the bookmaker resumes quoting the larger number in the ratio before the smaller one.
Consider a race in which all four horses (let's say Foinavon, Gregalach, Mon Mome and Tipperary Tim) are equally likely to win: then in terms of probabilities, we would say each had a "1 in 4" or 0.25 chance of victory. What would the fair odds be for a bet on, say, Foinavon? There is only one favourable outcome (victory for F) versus three unfavourable outcomes (victory for G, M or T), so a statistician would describe the odds as "1 to 3", or numerically as $\frac{1}{3}$. However, a bookmaker using British odds would see the odds as "3 to 1 against", and write them as simply "3/1" or 3-1" (both read "three to one"; the "against" is implicit and goes unspoken). For a gambler, "odds against" means a stake of £1 would return £3 profit if successful (they will actually receive £4, but £1 of this is the return of the original stake) whereas if unsuccessful they lose the £1 stake. The gambler has three chances of losing £1 and one chance of gaining £3, so again there is zero expected profit/loss and the odds are fair. Sadly, "odds against" (the usual form of odds) does not correspond to a statistician's "odds in favour".
Each horse in our hypothetical race achieved fame by once winning the Grand National at odds of 100/1: since these were high ("long") odds against, they were "long shots" considered extremely unlikely to win, and their backers were handsomely rewarded with £100 profit per pound wagered. If we pretend that the bookmakers' odds were the fair odds (which would ignore the bookmaker's overround, or "vig"), it was felt that there were 100 ways the horse could lose for each way the horse could win, so the implied probability of success was $\frac{1}{101}$. On the contrary, if a statistician claimed an event had odds of "100 to 1", that is a claim the event is very likely (with a probability of $\frac{100}{101}$).
If any layperson in your audience comes from a country where fractional odds are used by bookmakers, and regularly quoted in the media (e.g. "Jeremy Corbyn set to beat 100-1 odds to become leader of UK's Labour party", The Guardian, 11 September 2015; "11 million to one: Quadruplet calves born in South Australia", Sydney Morning Herald, 30 July 2015) then quoting odds in the form "$a$ to $b$" is almost certain to cause confusion.
I've seen people try this, perhaps in the belief that "the general public is more familiar with odds than probabilities", but statisticians wise to the bookmaker's overround, and who have therefore never placed a bet in their lives, may be caught by surprise that the popular conception of odds is "the wrong way round". If this confusion is felt to outweigh the advantages of the "$a$ to $b$" formulation (particularly that it makes clear odds express a ratio of favourable to unfavourable) then it might be better to express "statistical odds" as a single number, to distinguish them from a bookmaker's fractional odds. Before presenting statistical odds to such an audience, I would at least make them aware of the following points:
A statistician's odds correspond to a bookmaker's "odds on". If you are used to "odds against", a statistician's odds may seem "the wrong way round". For example, "10 to 1" indicates a very likely event, and "1000 to 1" an extremely likely one!
A statistician need not put the higher number first, so odds like "2 to 3" can be used to indicate "2 chances of success to 3 chances of failure" (i.e. after many trials, the ratio of successes to failures should be around 2:3 and hence the probability of success is $\frac{2}{5}$).
While bookmakers prefer to give odds as a ratio of whole numbers,** statisticians will often simplify their odds into the form "something to one", even if this introduces a decimal (e.g. "5 to 2" becomes "2.5 to 1").
A statistician may leave off the "to one" and quote a single number (e.g. odds of 3.5 mean "3.5 to 1", or "7 to 2", so the long-run ratio of successes to failures is expected to be 7:2, from which the probability of success can easily be seen to be $\frac{7}{9}$).
On this scale, odds of zero represent an impossibility; odds between 0 and 1 indicate a less-than-evens chance; odds of 1 show a 50% chance; odds above 1 indicate the event is more likely than not; a certain event would have infinite odds.
Mathematically, we have
$$\text{Odds}_\text{statistician} = \text{Odds on}_\text{British}; \quad \text{Odds}_\text{statistician} = \frac{1}{\text{Odds against}_\text{British}}$$
Even this may not be sufficient to avoid confusion. Decimal odds, also known as continental odds or European odds, have become more prevalent in an era of online gambling, especially for in-play betting and betting exchanges where fractional odds are unwieldy for displaying small, rapid changes in implied probabilities. European odds quote the payout per unit staked, including the return of the stake. For the aquamarine bet, a winning £3 stake makes a profit of £1, so each £1 staked would make a profit around £0.33 (in a payout of £1.33). The European odds for aquamarine are therefore about $1.33$. For the coin toss, a gambler staking £1 receives a payout of £2 (if successful) or £0 otherwise, so the European odds are $2.00$. For a £1 bet on Foinavon, a gambler has a winning payout of £4, so the European odds are $4.00$. You may have noticed that the European odds are the reciprocal of the implied probability of success: for the odds to be fair on a £1 stake, the expected payout (which is the probability of success multiplied by the winning payout) must equal the £1 wagered, so the winning payout must be the reciprocal of the probability. Since $\text{Odds}_\text{European} = \frac{1}{p}$ we find
$$\text{Odds}_\text{statistician} = \frac{p}{1-p} = \frac{1}{p^{-1}-1} =
\frac{1}{\text{Odds}_\text{European}-1}$$
We might also have deduced this from noting $\text{Odds}_\text{European} = \text{Odds against}_\text{British} + 1$ (because of European odds including the return of the stake in the payout).
European odds have several advantages to the gambler. Comparing two fractional odds (try 8/15 versus 4/7) involves greater feats of mental arithmetic than comparing two decimals. Small changes to the implied probability work "smoothly" for a decimal whereas the form of a fraction may have to completely change as a different denominator is required. Calculating the payout from a win is as simple as multiplying the stake by the European odds (e.g. a winning stake of €300 at European odds of $1.50$ receives a payout of €450, of which €150 is profit). The reciprocal relationship with implied probability is especially useful for spotting "value bets": if a gambler believes the true probability of success on a bet at European odds of $6.00$ is greater than the bet's implied probability of $\frac{1}{6}$, the bet is good value and the gambler's expected profit is positive.
However, it's harder for a statistician to explain mathematical odds to a layperson accustomed to European odds! Like British "odds against", higher European odds indicate an event that's deemed less likely ($1.00$ for a certainty, $2.00$ for an even chance, $\infty$ for an impossibility). Even worse, the numbers are not simply the "wrong way round" but completely misleading: the entire concept of a ratio of favourable and unfavourable outcomes has been lost.
This key conceptual ratio is retained in the moneyline system used in US sports betting, even though it looks more complex at first sight. Positive figures indicate profit (excludes return of stake) on a winning $\$100$ stake, essentially the same idea as "odds against". A figure of +300 indicates $\$300$ of profit on a $\$100$ stake, equivalent to "3/1 [against]" in the British system or "1 to 3" for a statistician (the Foinavon bet). Negative figures indicate the required stake to win a profit of $\$100$, equivalent to "odds on". A figure of -300 shows a $\$300$ stake makes $\$100$ profit, which is "3/1 on" in the British system or "3 to 1" for a statistician (the aquamarine bet).
$$\text{Odds}_\text{statistician} =
\begin{cases}
\frac{|\text{Moneyline}|}{100} & \text{if Moneyline} < 0 \\[5pt]
\frac{100}{\text{Moneyline}} &\text{if Moneyline} > 0
\end{cases}$$
I appreciate much of this answer has concerned betting and pay-offs rather than statistics, but I've found the everyday usage of "odds" differs so markedly from the statistician's technical definition, that a thorough comparison might address some confusion (both of non-technical gamblers, and non-gambling statisticians). There are, of course, deep historical and philosophical links between betting and statistics. The problem of points concerned the fair division of the prize pot in an interrupted gambling game, and had generated discussion since medieval times. When Antoine Gombaud, chevalier de Méré posed a version of the problem in 1654, the subsequent correspondence of Blaise Pascal and Pierre de Fermat on the issue laid the foundations of probability theory. More recently, Frank Ramsey (in the 1920s) and Bruno de Finetti (in the 1930s) examined the coherence of wagers (related to the gambling phenomenon of a Dutch book) as a justification of Bayesian probability: if an agent's subjective probabilities or degrees of belief do not obey the axioms of probability, then they are incoherent and a Dutch book can be made against the agent, exposing them to a certain loss. The Stanford Encyclopedia of Philosophy has an article on the "Dutch Book argument".
($*$) I've deliberately oversimplified here for pedagogical purposes. In fact bookmakers are not consistent on this point: these odds may well be written "1/3" (signifying "one to three against"), though this may still be read aloud as "three to one on"! However, while a bookmaker might write the smaller number first in an odds against bet, they will never frame an odds on bet in this way: "1/3 on" would theoretically be the same as "3/1 [against]", but in practice would always be quoted in the latter form.
($**$) As an aside, bookmakers do not always cancel these whole numbers to their lowest terms: "6/4" is often advertised ("ear'ole"), so perhaps bookmakers believe a £6 profit on a £4 stake is more psychologically enticing than the prospect of £3 profit on a £2 stake. I have heard it argued, though the truth I know not, that "100/30" survives because "10 to 3" could be mistaken for the time of a race. Hong Kong odds are fractional odds (against) cancelled down to a single number, so "5/2 against" becomes 2.5; the profit from a winning bet (excluding return of the stake) is then the Hong Kong odds multiplied by the stake. Hong Kong odds below one indicate a greater than 50% chance; they are the reciprocal of statistical odds. | Odds made simple | On another thread there is a much broader answer by @gung that also deals with related technical issues such as the odds ratio, but I am going to stick to the topic at hand: how to interpret odds, and | Odds made simple
On another thread there is a much broader answer by @gung that also deals with related technical issues such as the odds ratio, but I am going to stick to the topic at hand: how to interpret odds, and particularly the formulation "$a$ to $b$". As a beginner's question, it's worth thinking how "odds" are expressed in everyday speech (especially in betting parlance) as well as what odds mean to a statistician, because discrepancies between the two are problematic for learners.
For odds as expressed by a statistician, your contention is correct. Suppose a bag contains four tokens, of which three are $\color{aquamarine}{\text{aquamarine}}$ and one is $\color{brown}{\text{brown}}$, and one token is selected at random. The probability that the selected token is aquamarine is 3 out of 4, i.e. $\frac{3}{4}$, often read "3 in 4". With equally likely outcomes, the odds for aquamarine would be calculated as the number of favourable outcomes (3) divided by the number of unfavourable outcomes (1), which is $\frac{3}{1} = 3$, often read as $\color{aquamarine}{\text{three}}\text{ to }\color{brown}{\text{one}}$ or just as the number "three". More generally, you could take the fraction of "favourable outcomes over unfavourable outcomes" and cancel (divide) both numerator and denominator by the total number of outcomes, to obtain "the probability of a favourable outcome over the probability of an unfavourable outcome", from which a little algebra gives:
$$\text{Odds} = \frac{p}{1-p} \implies p = \frac{\text{Odds}}{1 + \text{Odds}} $$
Odds as expressed by a bookmaker are usually quoted either as "odds against" or "odds on", and which way they are written seems to be a common cause of confusion. In so-called British odds, fractional odds or traditional odds, the odds for aquamarine would be written "3/1 on" or "3-1 on", read as $\color{aquamarine}{\text{three}}\text{ to }\color{brown}{\text{one}}\text{ on}$.* For a gambler, the fact these are "odds on" indicates that a stake of £3 on aquamarine would return £1 profit if successful (they actually receive £4, of which £3 is simply the return of the original stake) whereas a failed bet results in the loss of the £3 stake. We can see these are "fair odds" because the gambler has three chances of gaining £1 and one chance of losing £3, so on average there is no expected gain or loss. So far, so little discrepancy: "odds on" are simply the "odds in favour" preferred by statisticians.
For events with a 50% probability, such as heads on a coin toss — two equally likely outcomes of success or failure — a statistician would say the odds are "one to one", $\frac{1}{1}$ or simply $1$ whereas a fair bookmaker would give fractional odds of 1/1 (read as "evens"). So no problems here either; however, when the probability falls below 50%, we see the bookmaker resumes quoting the larger number in the ratio before the smaller one.
Consider a race in which all four horses (let's say Foinavon, Gregalach, Mon Mome and Tipperary Tim) are equally likely to win: then in terms of probabilities, we would say each had a "1 in 4" or 0.25 chance of victory. What would the fair odds be for a bet on, say, Foinavon? There is only one favourable outcome (victory for F) versus three unfavourable outcomes (victory for G, M or T), so a statistician would describe the odds as "1 to 3", or numerically as $\frac{1}{3}$. However, a bookmaker using British odds would see the odds as "3 to 1 against", and write them as simply "3/1" or 3-1" (both read "three to one"; the "against" is implicit and goes unspoken). For a gambler, "odds against" means a stake of £1 would return £3 profit if successful (they will actually receive £4, but £1 of this is the return of the original stake) whereas if unsuccessful they lose the £1 stake. The gambler has three chances of losing £1 and one chance of gaining £3, so again there is zero expected profit/loss and the odds are fair. Sadly, "odds against" (the usual form of odds) does not correspond to a statistician's "odds in favour".
Each horse in our hypothetical race achieved fame by once winning the Grand National at odds of 100/1: since these were high ("long") odds against, they were "long shots" considered extremely unlikely to win, and their backers were handsomely rewarded with £100 profit per pound wagered. If we pretend that the bookmakers' odds were the fair odds (which would ignore the bookmaker's overround, or "vig"), it was felt that there were 100 ways the horse could lose for each way the horse could win, so the implied probability of success was $\frac{1}{101}$. On the contrary, if a statistician claimed an event had odds of "100 to 1", that is a claim the event is very likely (with a probability of $\frac{100}{101}$).
If any layperson in your audience comes from a country where fractional odds are used by bookmakers, and regularly quoted in the media (e.g. "Jeremy Corbyn set to beat 100-1 odds to become leader of UK's Labour party", The Guardian, 11 September 2015; "11 million to one: Quadruplet calves born in South Australia", Sydney Morning Herald, 30 July 2015) then quoting odds in the form "$a$ to $b$" is almost certain to cause confusion.
I've seen people try this, perhaps in the belief that "the general public is more familiar with odds than probabilities", but statisticians wise to the bookmaker's overround, and who have therefore never placed a bet in their lives, may be caught by surprise that the popular conception of odds is "the wrong way round". If this confusion is felt to outweigh the advantages of the "$a$ to $b$" formulation (particularly that it makes clear odds express a ratio of favourable to unfavourable) then it might be better to express "statistical odds" as a single number, to distinguish them from a bookmaker's fractional odds. Before presenting statistical odds to such an audience, I would at least make them aware of the following points:
A statistician's odds correspond to a bookmaker's "odds on". If you are used to "odds against", a statistician's odds may seem "the wrong way round". For example, "10 to 1" indicates a very likely event, and "1000 to 1" an extremely likely one!
A statistician need not put the higher number first, so odds like "2 to 3" can be used to indicate "2 chances of success to 3 chances of failure" (i.e. after many trials, the ratio of successes to failures should be around 2:3 and hence the probability of success is $\frac{2}{5}$).
While bookmakers prefer to give odds as a ratio of whole numbers,** statisticians will often simplify their odds into the form "something to one", even if this introduces a decimal (e.g. "5 to 2" becomes "2.5 to 1").
A statistician may leave off the "to one" and quote a single number (e.g. odds of 3.5 mean "3.5 to 1", or "7 to 2", so the long-run ratio of successes to failures is expected to be 7:2, from which the probability of success can easily be seen to be $\frac{7}{9}$).
On this scale, odds of zero represent an impossibility; odds between 0 and 1 indicate a less-than-evens chance; odds of 1 show a 50% chance; odds above 1 indicate the event is more likely than not; a certain event would have infinite odds.
Mathematically, we have
$$\text{Odds}_\text{statistician} = \text{Odds on}_\text{British}; \quad \text{Odds}_\text{statistician} = \frac{1}{\text{Odds against}_\text{British}}$$
Even this may not be sufficient to avoid confusion. Decimal odds, also known as continental odds or European odds, have become more prevalent in an era of online gambling, especially for in-play betting and betting exchanges where fractional odds are unwieldy for displaying small, rapid changes in implied probabilities. European odds quote the payout per unit staked, including the return of the stake. For the aquamarine bet, a winning £3 stake makes a profit of £1, so each £1 staked would make a profit around £0.33 (in a payout of £1.33). The European odds for aquamarine are therefore about $1.33$. For the coin toss, a gambler staking £1 receives a payout of £2 (if successful) or £0 otherwise, so the European odds are $2.00$. For a £1 bet on Foinavon, a gambler has a winning payout of £4, so the European odds are $4.00$. You may have noticed that the European odds are the reciprocal of the implied probability of success: for the odds to be fair on a £1 stake, the expected payout (which is the probability of success multiplied by the winning payout) must equal the £1 wagered, so the winning payout must be the reciprocal of the probability. Since $\text{Odds}_\text{European} = \frac{1}{p}$ we find
$$\text{Odds}_\text{statistician} = \frac{p}{1-p} = \frac{1}{p^{-1}-1} =
\frac{1}{\text{Odds}_\text{European}-1}$$
We might also have deduced this from noting $\text{Odds}_\text{European} = \text{Odds against}_\text{British} + 1$ (because of European odds including the return of the stake in the payout).
European odds have several advantages to the gambler. Comparing two fractional odds (try 8/15 versus 4/7) involves greater feats of mental arithmetic than comparing two decimals. Small changes to the implied probability work "smoothly" for a decimal whereas the form of a fraction may have to completely change as a different denominator is required. Calculating the payout from a win is as simple as multiplying the stake by the European odds (e.g. a winning stake of €300 at European odds of $1.50$ receives a payout of €450, of which €150 is profit). The reciprocal relationship with implied probability is especially useful for spotting "value bets": if a gambler believes the true probability of success on a bet at European odds of $6.00$ is greater than the bet's implied probability of $\frac{1}{6}$, the bet is good value and the gambler's expected profit is positive.
However, it's harder for a statistician to explain mathematical odds to a layperson accustomed to European odds! Like British "odds against", higher European odds indicate an event that's deemed less likely ($1.00$ for a certainty, $2.00$ for an even chance, $\infty$ for an impossibility). Even worse, the numbers are not simply the "wrong way round" but completely misleading: the entire concept of a ratio of favourable and unfavourable outcomes has been lost.
This key conceptual ratio is retained in the moneyline system used in US sports betting, even though it looks more complex at first sight. Positive figures indicate profit (excludes return of stake) on a winning $\$100$ stake, essentially the same idea as "odds against". A figure of +300 indicates $\$300$ of profit on a $\$100$ stake, equivalent to "3/1 [against]" in the British system or "1 to 3" for a statistician (the Foinavon bet). Negative figures indicate the required stake to win a profit of $\$100$, equivalent to "odds on". A figure of -300 shows a $\$300$ stake makes $\$100$ profit, which is "3/1 on" in the British system or "3 to 1" for a statistician (the aquamarine bet).
$$\text{Odds}_\text{statistician} =
\begin{cases}
\frac{|\text{Moneyline}|}{100} & \text{if Moneyline} < 0 \\[5pt]
\frac{100}{\text{Moneyline}} &\text{if Moneyline} > 0
\end{cases}$$
I appreciate much of this answer has concerned betting and pay-offs rather than statistics, but I've found the everyday usage of "odds" differs so markedly from the statistician's technical definition, that a thorough comparison might address some confusion (both of non-technical gamblers, and non-gambling statisticians). There are, of course, deep historical and philosophical links between betting and statistics. The problem of points concerned the fair division of the prize pot in an interrupted gambling game, and had generated discussion since medieval times. When Antoine Gombaud, chevalier de Méré posed a version of the problem in 1654, the subsequent correspondence of Blaise Pascal and Pierre de Fermat on the issue laid the foundations of probability theory. More recently, Frank Ramsey (in the 1920s) and Bruno de Finetti (in the 1930s) examined the coherence of wagers (related to the gambling phenomenon of a Dutch book) as a justification of Bayesian probability: if an agent's subjective probabilities or degrees of belief do not obey the axioms of probability, then they are incoherent and a Dutch book can be made against the agent, exposing them to a certain loss. The Stanford Encyclopedia of Philosophy has an article on the "Dutch Book argument".
($*$) I've deliberately oversimplified here for pedagogical purposes. In fact bookmakers are not consistent on this point: these odds may well be written "1/3" (signifying "one to three against"), though this may still be read aloud as "three to one on"! However, while a bookmaker might write the smaller number first in an odds against bet, they will never frame an odds on bet in this way: "1/3 on" would theoretically be the same as "3/1 [against]", but in practice would always be quoted in the latter form.
($**$) As an aside, bookmakers do not always cancel these whole numbers to their lowest terms: "6/4" is often advertised ("ear'ole"), so perhaps bookmakers believe a £6 profit on a £4 stake is more psychologically enticing than the prospect of £3 profit on a £2 stake. I have heard it argued, though the truth I know not, that "100/30" survives because "10 to 3" could be mistaken for the time of a race. Hong Kong odds are fractional odds (against) cancelled down to a single number, so "5/2 against" becomes 2.5; the profit from a winning bet (excluding return of the stake) is then the Hong Kong odds multiplied by the stake. Hong Kong odds below one indicate a greater than 50% chance; they are the reciprocal of statistical odds. | Odds made simple
On another thread there is a much broader answer by @gung that also deals with related technical issues such as the odds ratio, but I am going to stick to the topic at hand: how to interpret odds, and |
18,391 | Overdispersion and Underdispersion in Negative Binomial/Poisson Regression | For a Poisson distribution with mean $\mu$ the variance is also $\mu$. Within the framework of generalized linear models this implies that the variance function is
$$V(\mu) = \mu$$
for the Poisson model. This model assumption can be wrong for many different reasons. Overdispersed count data with a variance larger than what the Poisson distribution dictates is, for instance, often encountered.
Deviations from the variance assumption can in a regression context take several forms. The simplest one is that the variance function equals
$$V(\mu) = \psi \mu$$
with $\psi > 0$ a dispersion parameter. This is the quasi-Poisson model. It will give the same fitted regression model, but the statistical inference ($p$-values and confidence intervals) is adjusted for over- or underdispersion using an estimated dispersion parameter.
The functional form of the variance function can also be wrong. It could be a second degree polynomial
$$V(\mu) = a\mu^2 + b \mu + c,$$
say. Examples include the binomial, the
negative binomial and the gamma model. Choosing any of these models as an alternative to the Poisson model will affect the fitted regression model as well as the subsequent statistical inference. For the negative binomial distribution with shape parameter $\lambda > 0$ the variance function is
$$V(\mu) = \mu\left( 1 + \frac{\mu}{\lambda}\right).$$
We can see from this that if $\lambda \to \infty$ we get the variance function for the Poisson distribution.
To determine if the variance function for the Poisson model is appropriate for the data, we can estimate the dispersion parameter as the OP suggests and check if it is approximately 1 (perhaps using a formal test). Such a test does not suggest a specific alternative, but it is most clearly understood within the quasi-Poisson model. To test if the functional form of the variance function is appropriate, w e could construct a likelihood ratio test of the Poisson model ($\lambda = \infty$) against the negative binomial model ($\lambda < \infty$). Note that it has a nonstandard distribution under the null hypothesis. Or we could use AIC-based methods in general for comparing non-nested models. Regression-based tests for overdispersion in the Poisson model explores a class of tests for general variance functions.
However, I would recommend to first of all study residual plots, e.g. a plot of the Pearson or deviance residuals (or their squared value) against the fitted values. If the functional form of the variance is wrong, you will see this as a funnel shape (or a trend for the squared residuals) in the residual plot. If the functional form is correct, that is, no funnel or trend, there could still be over- or underdispersion, but this can be accounted for by estimating the dispersion parameter. The benefit of the residual plot is that it suggests more clearly than a test what is wrong with the variance function if anything.
In the OP's concrete case it is not possible to say if 0.8 indicates underdispersion from the given information. Instead of focusing on the 5 and 0.8 estimates, I suggest to first of all investigate the fit of the variance functions of the Poisson model and the negative binomial model. Once the most appropriate functional form of the variance function is determined, a dispersion parameter can be included, if needed, in either model to adjust the statistical inference for any additional over- or underdispersion. How to do that easily in SAS, say, is unfortunately not something I can help with. | Overdispersion and Underdispersion in Negative Binomial/Poisson Regression | For a Poisson distribution with mean $\mu$ the variance is also $\mu$. Within the framework of generalized linear models this implies that the variance function is
$$V(\mu) = \mu$$
for the Poisson m | Overdispersion and Underdispersion in Negative Binomial/Poisson Regression
For a Poisson distribution with mean $\mu$ the variance is also $\mu$. Within the framework of generalized linear models this implies that the variance function is
$$V(\mu) = \mu$$
for the Poisson model. This model assumption can be wrong for many different reasons. Overdispersed count data with a variance larger than what the Poisson distribution dictates is, for instance, often encountered.
Deviations from the variance assumption can in a regression context take several forms. The simplest one is that the variance function equals
$$V(\mu) = \psi \mu$$
with $\psi > 0$ a dispersion parameter. This is the quasi-Poisson model. It will give the same fitted regression model, but the statistical inference ($p$-values and confidence intervals) is adjusted for over- or underdispersion using an estimated dispersion parameter.
The functional form of the variance function can also be wrong. It could be a second degree polynomial
$$V(\mu) = a\mu^2 + b \mu + c,$$
say. Examples include the binomial, the
negative binomial and the gamma model. Choosing any of these models as an alternative to the Poisson model will affect the fitted regression model as well as the subsequent statistical inference. For the negative binomial distribution with shape parameter $\lambda > 0$ the variance function is
$$V(\mu) = \mu\left( 1 + \frac{\mu}{\lambda}\right).$$
We can see from this that if $\lambda \to \infty$ we get the variance function for the Poisson distribution.
To determine if the variance function for the Poisson model is appropriate for the data, we can estimate the dispersion parameter as the OP suggests and check if it is approximately 1 (perhaps using a formal test). Such a test does not suggest a specific alternative, but it is most clearly understood within the quasi-Poisson model. To test if the functional form of the variance function is appropriate, w e could construct a likelihood ratio test of the Poisson model ($\lambda = \infty$) against the negative binomial model ($\lambda < \infty$). Note that it has a nonstandard distribution under the null hypothesis. Or we could use AIC-based methods in general for comparing non-nested models. Regression-based tests for overdispersion in the Poisson model explores a class of tests for general variance functions.
However, I would recommend to first of all study residual plots, e.g. a plot of the Pearson or deviance residuals (or their squared value) against the fitted values. If the functional form of the variance is wrong, you will see this as a funnel shape (or a trend for the squared residuals) in the residual plot. If the functional form is correct, that is, no funnel or trend, there could still be over- or underdispersion, but this can be accounted for by estimating the dispersion parameter. The benefit of the residual plot is that it suggests more clearly than a test what is wrong with the variance function if anything.
In the OP's concrete case it is not possible to say if 0.8 indicates underdispersion from the given information. Instead of focusing on the 5 and 0.8 estimates, I suggest to first of all investigate the fit of the variance functions of the Poisson model and the negative binomial model. Once the most appropriate functional form of the variance function is determined, a dispersion parameter can be included, if needed, in either model to adjust the statistical inference for any additional over- or underdispersion. How to do that easily in SAS, say, is unfortunately not something I can help with. | Overdispersion and Underdispersion in Negative Binomial/Poisson Regression
For a Poisson distribution with mean $\mu$ the variance is also $\mu$. Within the framework of generalized linear models this implies that the variance function is
$$V(\mu) = \mu$$
for the Poisson m |
18,392 | Overdispersion and Underdispersion in Negative Binomial/Poisson Regression | No, it doesn't --- it means a good fit (with some caveats)
In this context, the Pearson chi-squared test is used to assess the goodness of fit of the estimated distribution under your assumed model form. If it is giving you a low value for the test statistic (and more importantly a high corresponding p-value) then this means that the evidence to reject the null hypothesis of a good fit is weak. This means that the estimated distribution coming out of your model fits the empirical data well, which suggests that it is accurately capturing the level of dispersion in the data.
Now, as a caveat to this, it is worth noting that the Pearson chi-squared test is not designed to take account of the optimisation process that occurs when you estimate a distribution from a broad class of distributions (e.g., using the negative binomial regression model). A better choice of goodness-of-fit test in this context is the likelihood-ratio test, since it takes account of this optimisation. Nevertheless, in cases with a substantial amount of data and relatively few parameters these should give similar types of inferences. | Overdispersion and Underdispersion in Negative Binomial/Poisson Regression | No, it doesn't --- it means a good fit (with some caveats)
In this context, the Pearson chi-squared test is used to assess the goodness of fit of the estimated distribution under your assumed model fo | Overdispersion and Underdispersion in Negative Binomial/Poisson Regression
No, it doesn't --- it means a good fit (with some caveats)
In this context, the Pearson chi-squared test is used to assess the goodness of fit of the estimated distribution under your assumed model form. If it is giving you a low value for the test statistic (and more importantly a high corresponding p-value) then this means that the evidence to reject the null hypothesis of a good fit is weak. This means that the estimated distribution coming out of your model fits the empirical data well, which suggests that it is accurately capturing the level of dispersion in the data.
Now, as a caveat to this, it is worth noting that the Pearson chi-squared test is not designed to take account of the optimisation process that occurs when you estimate a distribution from a broad class of distributions (e.g., using the negative binomial regression model). A better choice of goodness-of-fit test in this context is the likelihood-ratio test, since it takes account of this optimisation. Nevertheless, in cases with a substantial amount of data and relatively few parameters these should give similar types of inferences. | Overdispersion and Underdispersion in Negative Binomial/Poisson Regression
No, it doesn't --- it means a good fit (with some caveats)
In this context, the Pearson chi-squared test is used to assess the goodness of fit of the estimated distribution under your assumed model fo |
18,393 | Ridge regression – Bayesian interpretation | No, in the sense that other priors do logically relate to other penalties. In general you do want more mass near zero effect ($\beta=0$) to reduce overfitting/over-interpretation. Ridge is a quadratic (L2, Gaussian) penalty, lasso is an $|\beta|$ (L1, Laplace or double exponential distribution) penalty. Many other penalties (priors) are available. The Bayesian approach has the advantage of yielding a solid interpretation (and solid credible intervals) whereas penalized maximum likelihood estimation (ridge, lasso, etc.) yields $P$-values and confidence intervals that are hard to interpret, because the frequentist approach is somewhat confused by biased (shrunk towards zero) estimators. | Ridge regression – Bayesian interpretation | No, in the sense that other priors do logically relate to other penalties. In general you do want more mass near zero effect ($\beta=0$) to reduce overfitting/over-interpretation. Ridge is a quadrat | Ridge regression – Bayesian interpretation
No, in the sense that other priors do logically relate to other penalties. In general you do want more mass near zero effect ($\beta=0$) to reduce overfitting/over-interpretation. Ridge is a quadratic (L2, Gaussian) penalty, lasso is an $|\beta|$ (L1, Laplace or double exponential distribution) penalty. Many other penalties (priors) are available. The Bayesian approach has the advantage of yielding a solid interpretation (and solid credible intervals) whereas penalized maximum likelihood estimation (ridge, lasso, etc.) yields $P$-values and confidence intervals that are hard to interpret, because the frequentist approach is somewhat confused by biased (shrunk towards zero) estimators. | Ridge regression – Bayesian interpretation
No, in the sense that other priors do logically relate to other penalties. In general you do want more mass near zero effect ($\beta=0$) to reduce overfitting/over-interpretation. Ridge is a quadrat |
18,394 | Ridge regression – Bayesian interpretation | Two points:
The posterior distribution in the Bayesian case is a distribution. The ridge regression estimate is simply a vector $\hat{\beta}$ and not a distribution. Thus they're not completely equivalent.
It is true that in the case of a multivariate normal prior and multivariate normal likelihood, the posterior is multivariate normal with a mean that is the ridge regression estimate for an appropriately chosen ridge parameter.
The proof of this depends on the particular form of the prior and likelihood and doesn't work for more general priors or likelihood functions. | Ridge regression – Bayesian interpretation | Two points:
The posterior distribution in the Bayesian case is a distribution. The ridge regression estimate is simply a vector $\hat{\beta}$ and not a distribution. Thus they're not completely equi | Ridge regression – Bayesian interpretation
Two points:
The posterior distribution in the Bayesian case is a distribution. The ridge regression estimate is simply a vector $\hat{\beta}$ and not a distribution. Thus they're not completely equivalent.
It is true that in the case of a multivariate normal prior and multivariate normal likelihood, the posterior is multivariate normal with a mean that is the ridge regression estimate for an appropriately chosen ridge parameter.
The proof of this depends on the particular form of the prior and likelihood and doesn't work for more general priors or likelihood functions. | Ridge regression – Bayesian interpretation
Two points:
The posterior distribution in the Bayesian case is a distribution. The ridge regression estimate is simply a vector $\hat{\beta}$ and not a distribution. Thus they're not completely equi |
18,395 | What is the difference between linearly dependent and linearly correlated? | Two variables are linearly dependent if one can be written as a linear function of the other. If two variable are linearly dependent the correlation between them is 1 or -1. Linearly correlated just means that two variables have a non-zero correlation but not necessarily having an exact linear relationship. Correlation is sometimes called linear correlation because the Pearson product moment correlation coefficient is a measure of the strength of the linearity in the relationship between the variables. | What is the difference between linearly dependent and linearly correlated? | Two variables are linearly dependent if one can be written as a linear function of the other. If two variable are linearly dependent the correlation between them is 1 or -1. Linearly correlated just | What is the difference between linearly dependent and linearly correlated?
Two variables are linearly dependent if one can be written as a linear function of the other. If two variable are linearly dependent the correlation between them is 1 or -1. Linearly correlated just means that two variables have a non-zero correlation but not necessarily having an exact linear relationship. Correlation is sometimes called linear correlation because the Pearson product moment correlation coefficient is a measure of the strength of the linearity in the relationship between the variables. | What is the difference between linearly dependent and linearly correlated?
Two variables are linearly dependent if one can be written as a linear function of the other. If two variable are linearly dependent the correlation between them is 1 or -1. Linearly correlated just |
18,396 | What is the difference between linearly dependent and linearly correlated? | In $\mathbf{R}^2$ linear dependence implies that one vector is a linear function of the other:
$$
\textbf{v}_{1}=a\textbf{v}_2.
$$
It's clear from this definition that the two variables would move in lock-step, implying a correlation of $1$ or $-1$ depending on the value of $a$. To more fully understand the differences and connections between the concepts, however, I think it's beneficial to consider the geometry involved.
The graph below shows an example of the formula for linear dependence. You can see that the vectors are linearly dependent because one is simply a multiple of the other.
This is in contrast to linear independence, which in $\mathbf{R}^2$ is described by:
$$
\textbf{v}_{1}\neq a\textbf{v}_2
$$
for vectors $\textbf{v}_1, \textbf{v}_2 \neq \textbf{0}.$ An example of linear independence can be seen in the graphic below.
The most extreme version of linear independence is orthogonality, defined for vectors $\textbf{v}_1, \textbf{v}_2$ as:
$$
\textbf{v}_{1}^T \textbf{v}_{2} = 0.
$$
When graphed in $\mathbf{R}^2$, orthogonality corresponds to the vectors $\textbf{v}_{1}$ and $\textbf{v}_2$ being perpendicular to one another:
Now, consider Pearson's correlation coefficient:
$$
\rho_{\textbf{v}_{1}\textbf{v}_{2}} = \frac{(\textbf{v}_{1}-\bar{v}_{1}\textbf{1})^T(\textbf{v}_{2}-\bar{v}_{2}\textbf{1})}{\sigma_{\textbf{v}_{1}}\sigma_{\textbf{v}_{2}}}.
$$
Note that if the vectors $(\textbf{v}_{1}-\bar{v}_{1}\textbf{1})$ and $(\textbf{v}_{2}-\bar{v}_{2}\textbf{1})$ are orthogonal then the numerator of Pearson's coefficient is zero, implying that the variables $\textbf{v}_{1}$ and $\textbf{v}_{2}$ are uncorrelated. This illustrates an interesting connection between linear independence and correlation: linear dependence between the centered versions of the variables $\textbf{v}_{1}$ and $\textbf{v}_{2}$ corresponds to a correlation of $1$ or $-1$, non-orthogonal linear independence between the centered versions of $\textbf{v}_{1}$ and $\textbf{v}_{2}$ corresponds to a correlation between $0$ and $1$ in absolute value, and orthogonality between the centered versions of $\textbf{v}_{1}$ and $\textbf{v}_{2}$ corresponds to a correlation of $0$.
Thus, if two vectors are linearly dependent the centered versions of the vectors will also be linearly dependent, i.e. the vectors are perfectly correlated. When two linearly independent vectors (orthogonal or not) are centered the angle between the vectors may or may not change. Thus for linearly independent vectors the correlation may be positive, negative, or zero. | What is the difference between linearly dependent and linearly correlated? | In $\mathbf{R}^2$ linear dependence implies that one vector is a linear function of the other:
$$
\textbf{v}_{1}=a\textbf{v}_2.
$$
It's clear from this definition that the two variables would move in | What is the difference between linearly dependent and linearly correlated?
In $\mathbf{R}^2$ linear dependence implies that one vector is a linear function of the other:
$$
\textbf{v}_{1}=a\textbf{v}_2.
$$
It's clear from this definition that the two variables would move in lock-step, implying a correlation of $1$ or $-1$ depending on the value of $a$. To more fully understand the differences and connections between the concepts, however, I think it's beneficial to consider the geometry involved.
The graph below shows an example of the formula for linear dependence. You can see that the vectors are linearly dependent because one is simply a multiple of the other.
This is in contrast to linear independence, which in $\mathbf{R}^2$ is described by:
$$
\textbf{v}_{1}\neq a\textbf{v}_2
$$
for vectors $\textbf{v}_1, \textbf{v}_2 \neq \textbf{0}.$ An example of linear independence can be seen in the graphic below.
The most extreme version of linear independence is orthogonality, defined for vectors $\textbf{v}_1, \textbf{v}_2$ as:
$$
\textbf{v}_{1}^T \textbf{v}_{2} = 0.
$$
When graphed in $\mathbf{R}^2$, orthogonality corresponds to the vectors $\textbf{v}_{1}$ and $\textbf{v}_2$ being perpendicular to one another:
Now, consider Pearson's correlation coefficient:
$$
\rho_{\textbf{v}_{1}\textbf{v}_{2}} = \frac{(\textbf{v}_{1}-\bar{v}_{1}\textbf{1})^T(\textbf{v}_{2}-\bar{v}_{2}\textbf{1})}{\sigma_{\textbf{v}_{1}}\sigma_{\textbf{v}_{2}}}.
$$
Note that if the vectors $(\textbf{v}_{1}-\bar{v}_{1}\textbf{1})$ and $(\textbf{v}_{2}-\bar{v}_{2}\textbf{1})$ are orthogonal then the numerator of Pearson's coefficient is zero, implying that the variables $\textbf{v}_{1}$ and $\textbf{v}_{2}$ are uncorrelated. This illustrates an interesting connection between linear independence and correlation: linear dependence between the centered versions of the variables $\textbf{v}_{1}$ and $\textbf{v}_{2}$ corresponds to a correlation of $1$ or $-1$, non-orthogonal linear independence between the centered versions of $\textbf{v}_{1}$ and $\textbf{v}_{2}$ corresponds to a correlation between $0$ and $1$ in absolute value, and orthogonality between the centered versions of $\textbf{v}_{1}$ and $\textbf{v}_{2}$ corresponds to a correlation of $0$.
Thus, if two vectors are linearly dependent the centered versions of the vectors will also be linearly dependent, i.e. the vectors are perfectly correlated. When two linearly independent vectors (orthogonal or not) are centered the angle between the vectors may or may not change. Thus for linearly independent vectors the correlation may be positive, negative, or zero. | What is the difference between linearly dependent and linearly correlated?
In $\mathbf{R}^2$ linear dependence implies that one vector is a linear function of the other:
$$
\textbf{v}_{1}=a\textbf{v}_2.
$$
It's clear from this definition that the two variables would move in |
18,397 | What is the difference between linearly dependent and linearly correlated? | Let f(x) and g(x) be functions.
For f(x) and g(x) to be linearly independent we must have
a*f(x) + b*g(x) = 0 if and only if a=b=0.
In other words there is no c such that a or b is not zero but
a*f(c) + b*g(c) = 0
If there is such a c, then we say that f(x) and g(x) are linearly dependent.
e.g.
f(x) = sin(x) and g(x) = cos(x) are linearly independent
f(x) = sin(x) and g(x) = sin(2x) are not linearly dependent (Why?) | What is the difference between linearly dependent and linearly correlated? | Let f(x) and g(x) be functions.
For f(x) and g(x) to be linearly independent we must have
a*f(x) + b*g(x) = 0 if and only if a=b=0.
In other words there is no c such that a or b is not zero but
a*f(c) | What is the difference between linearly dependent and linearly correlated?
Let f(x) and g(x) be functions.
For f(x) and g(x) to be linearly independent we must have
a*f(x) + b*g(x) = 0 if and only if a=b=0.
In other words there is no c such that a or b is not zero but
a*f(c) + b*g(c) = 0
If there is such a c, then we say that f(x) and g(x) are linearly dependent.
e.g.
f(x) = sin(x) and g(x) = cos(x) are linearly independent
f(x) = sin(x) and g(x) = sin(2x) are not linearly dependent (Why?) | What is the difference between linearly dependent and linearly correlated?
Let f(x) and g(x) be functions.
For f(x) and g(x) to be linearly independent we must have
a*f(x) + b*g(x) = 0 if and only if a=b=0.
In other words there is no c such that a or b is not zero but
a*f(c) |
18,398 | Conceptual understanding of root mean squared error and mean bias deviation | I think these concepts are easy to explain. So I would rather just describe it here. I am sure many elementary statistics books cover this including my book "The Essentials of Biostatistics for Physicians, Nurses and Clinicians."
Think of a target with a bulls-eye in the middle. The mean square error represent the average squared distance from an arrow shot on the target and the center. Now if your arrows scatter evenly arround the center then the shooter has no aiming bias and the mean square error is the same as the variance.
But in general the arrows can scatter around a point away from the target. The average squared distance of the arrows from the center of the arrows is the variance. This center could be looked at as the shooters aim point. The distance from this shooters center or aimpoint to the center of the target is the absolute value of the bias.
Thinking of a right triangle where the square of the hypotenuse is the sum of the sqaures of the two sides. So a squared distance from the arrow to the target is the square of the distance from the arrow to the aim point and the square of the distance between the center of the target and the aimpoint. Averaging all these square distances gives the mean square error as the sum of the bias squared and the variance. | Conceptual understanding of root mean squared error and mean bias deviation | I think these concepts are easy to explain. So I would rather just describe it here. I am sure many elementary statistics books cover this including my book "The Essentials of Biostatistics for Phys | Conceptual understanding of root mean squared error and mean bias deviation
I think these concepts are easy to explain. So I would rather just describe it here. I am sure many elementary statistics books cover this including my book "The Essentials of Biostatistics for Physicians, Nurses and Clinicians."
Think of a target with a bulls-eye in the middle. The mean square error represent the average squared distance from an arrow shot on the target and the center. Now if your arrows scatter evenly arround the center then the shooter has no aiming bias and the mean square error is the same as the variance.
But in general the arrows can scatter around a point away from the target. The average squared distance of the arrows from the center of the arrows is the variance. This center could be looked at as the shooters aim point. The distance from this shooters center or aimpoint to the center of the target is the absolute value of the bias.
Thinking of a right triangle where the square of the hypotenuse is the sum of the sqaures of the two sides. So a squared distance from the arrow to the target is the square of the distance from the arrow to the aim point and the square of the distance between the center of the target and the aimpoint. Averaging all these square distances gives the mean square error as the sum of the bias squared and the variance. | Conceptual understanding of root mean squared error and mean bias deviation
I think these concepts are easy to explain. So I would rather just describe it here. I am sure many elementary statistics books cover this including my book "The Essentials of Biostatistics for Phys |
18,399 | Conceptual understanding of root mean squared error and mean bias deviation | RMSE is a way of measuring how good our predictive model is over the actual data, the smaller RMSE the better way of the model behaving, that is if we tested that on a new data set (not on our training set) but then again having an RMSE of 0.37 over a range of 0 to 1, accounts for a lot of errors versus having an RMSE of 0.01 as a better model. BIAS is for overestimating or underestimation. | Conceptual understanding of root mean squared error and mean bias deviation | RMSE is a way of measuring how good our predictive model is over the actual data, the smaller RMSE the better way of the model behaving, that is if we tested that on a new data set (not on our trainin | Conceptual understanding of root mean squared error and mean bias deviation
RMSE is a way of measuring how good our predictive model is over the actual data, the smaller RMSE the better way of the model behaving, that is if we tested that on a new data set (not on our training set) but then again having an RMSE of 0.37 over a range of 0 to 1, accounts for a lot of errors versus having an RMSE of 0.01 as a better model. BIAS is for overestimating or underestimation. | Conceptual understanding of root mean squared error and mean bias deviation
RMSE is a way of measuring how good our predictive model is over the actual data, the smaller RMSE the better way of the model behaving, that is if we tested that on a new data set (not on our trainin |
18,400 | Conceptual understanding of root mean squared error and mean bias deviation | As far I can understand, a RMSE give a more accurate value of the error between model and observed, however the BIAS, in addition to give a value of the error (less accurate than the RMSE), it can also determine if the model is positive bias or negative bias, if the model is underestimating or overestimating the observed values. | Conceptual understanding of root mean squared error and mean bias deviation | As far I can understand, a RMSE give a more accurate value of the error between model and observed, however the BIAS, in addition to give a value of the error (less accurate than the RMSE), it can als | Conceptual understanding of root mean squared error and mean bias deviation
As far I can understand, a RMSE give a more accurate value of the error between model and observed, however the BIAS, in addition to give a value of the error (less accurate than the RMSE), it can also determine if the model is positive bias or negative bias, if the model is underestimating or overestimating the observed values. | Conceptual understanding of root mean squared error and mean bias deviation
As far I can understand, a RMSE give a more accurate value of the error between model and observed, however the BIAS, in addition to give a value of the error (less accurate than the RMSE), it can als |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.