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
35,601
Scaling dataset in Random Forest
Any monotonic injective transformation of the features won't change the model wrt how it splits the data. The reason is the same as for why scaling is unnecessary: the random forest looks for partitions, and partitions only depend on how the data are sorted. If there is an optimal split on some scale, then by the definition of monotonic injective, the same split exists after transformation, and it's just as good (at splitting the training data, at least).
Scaling dataset in Random Forest
Any monotonic injective transformation of the features won't change the model wrt how it splits the data. The reason is the same as for why scaling is unnecessary: the random forest looks for partitio
Scaling dataset in Random Forest Any monotonic injective transformation of the features won't change the model wrt how it splits the data. The reason is the same as for why scaling is unnecessary: the random forest looks for partitions, and partitions only depend on how the data are sorted. If there is an optimal split on some scale, then by the definition of monotonic injective, the same split exists after transformation, and it's just as good (at splitting the training data, at least).
Scaling dataset in Random Forest Any monotonic injective transformation of the features won't change the model wrt how it splits the data. The reason is the same as for why scaling is unnecessary: the random forest looks for partitio
35,602
History of the term "early stopping"
It depends on how deep you want to go. Abraham Wald was studying sequential testing and stopping criteria in 1945. It was further studied in the 1960 and 1970s (cf Ferguson, 1989). In 1989 Pocock and Hughes described using early stopping for clinical trials (I'm not sure if this is the earliest paper like this). As about first citations of using it in machine learning, the paper by Morgan and Bourlard (1990) is sometimes quoted, for example by Prechelt (1997) or Finoff et al (1993).
History of the term "early stopping"
It depends on how deep you want to go. Abraham Wald was studying sequential testing and stopping criteria in 1945. It was further studied in the 1960 and 1970s (cf Ferguson, 1989). In 1989 Pocock and
History of the term "early stopping" It depends on how deep you want to go. Abraham Wald was studying sequential testing and stopping criteria in 1945. It was further studied in the 1960 and 1970s (cf Ferguson, 1989). In 1989 Pocock and Hughes described using early stopping for clinical trials (I'm not sure if this is the earliest paper like this). As about first citations of using it in machine learning, the paper by Morgan and Bourlard (1990) is sometimes quoted, for example by Prechelt (1997) or Finoff et al (1993).
History of the term "early stopping" It depends on how deep you want to go. Abraham Wald was studying sequential testing and stopping criteria in 1945. It was further studied in the 1960 and 1970s (cf Ferguson, 1989). In 1989 Pocock and
35,603
History of the term "early stopping"
The earliest reference I can find is a 1997 paper as shown - PubMed is a powerful tool to analyze trends in academic litearture. I obviously can't search "early stopping" apropos of nothing because it's apparently quite intuitive to terminate any laborious procedure early when desired precision is achieved, whether in ecological sampling, chemical and biochemical processes, medical imaging, and so on. But which terms to combine to address the specific question becomes vague, and a matter of capturing exogenous trends. Note: Cross-validation is not an algorithm which guarantees any form of "convergence". "Early stopping" according to these searches is not well defined. You may, for instance, put a "cap" on the number of iterations allowed, or allow a more generous "convergence" criterion. Regularization and cross-validation are different concepts, too. This question is tagged "machine learning" which, even itself, is a late entry to the field of methods. Prior to ML, there are, for instance, "one-step" estimators which are estimators such as GLS, GLMs, NLMMs, non-linear least squares, etc. which are estimated from iterative processes such as EM, NR, BGFS and whose theoretical results are known. A one-step estimator merely performs one iteration of the algorithm and produces an interesting and well behaved estimator in some cases whose variance is easy to express, and provides consistent tests of hypotheses. Theoretical work on one-step estimators has been explored since the 1980s.
History of the term "early stopping"
The earliest reference I can find is a 1997 paper as shown - PubMed is a powerful tool to analyze trends in academic litearture. I obviously can't search "early stopping" apropos of nothing because it
History of the term "early stopping" The earliest reference I can find is a 1997 paper as shown - PubMed is a powerful tool to analyze trends in academic litearture. I obviously can't search "early stopping" apropos of nothing because it's apparently quite intuitive to terminate any laborious procedure early when desired precision is achieved, whether in ecological sampling, chemical and biochemical processes, medical imaging, and so on. But which terms to combine to address the specific question becomes vague, and a matter of capturing exogenous trends. Note: Cross-validation is not an algorithm which guarantees any form of "convergence". "Early stopping" according to these searches is not well defined. You may, for instance, put a "cap" on the number of iterations allowed, or allow a more generous "convergence" criterion. Regularization and cross-validation are different concepts, too. This question is tagged "machine learning" which, even itself, is a late entry to the field of methods. Prior to ML, there are, for instance, "one-step" estimators which are estimators such as GLS, GLMs, NLMMs, non-linear least squares, etc. which are estimated from iterative processes such as EM, NR, BGFS and whose theoretical results are known. A one-step estimator merely performs one iteration of the algorithm and produces an interesting and well behaved estimator in some cases whose variance is easy to express, and provides consistent tests of hypotheses. Theoretical work on one-step estimators has been explored since the 1980s.
History of the term "early stopping" The earliest reference I can find is a 1997 paper as shown - PubMed is a powerful tool to analyze trends in academic litearture. I obviously can't search "early stopping" apropos of nothing because it
35,604
Bayes risk estimator under quartic loss
Unless the posterior is symmetric around $\mathbb{E}[\theta|y]$ there is no reason for the estimator to be equal to $\mathbb{E}[\theta|y]$. It is one of the solutions to a third degree polynomial equation. Take the following counter-example of a Gamma $\mathfrak G(\alpha,\beta)$ posterior. The posterior risk function is then $$R(\pi,\hat\theta)=\hat\theta^4-4\hat\theta^3\mathbb E^\pi[\theta|y]+6\hat\theta^2\mathbb E^\pi[\theta^2|y]-4\hat\theta\mathbb E^\pi[\theta^3|y]+\mathbb E^\pi[\theta^4|y]$$ and $$\mathbb E^\pi[\theta^k|y]=\beta^{-k}(k+\alpha)\cdots\alpha$$ hence $$R(\pi,\hat\theta)=\hat\theta^4-4\hat\theta^3\alpha\beta^{-1}+6\hat\theta^2\alpha(\alpha+1)\beta^{-2}-4\hat\theta\alpha(\alpha+1)(\alpha+2)(\alpha+3)\beta^{-3}+\mathbb E^\pi[\theta^4|y]$$ Without loss of generality, we can take $\beta=1$. Here is an illustration of the risk function when $\alpha=3.1415...$: The solution is clearly different from $\alpha/\beta$, the posterior mean.
Bayes risk estimator under quartic loss
Unless the posterior is symmetric around $\mathbb{E}[\theta|y]$ there is no reason for the estimator to be equal to $\mathbb{E}[\theta|y]$. It is one of the solutions to a third degree polynomial equa
Bayes risk estimator under quartic loss Unless the posterior is symmetric around $\mathbb{E}[\theta|y]$ there is no reason for the estimator to be equal to $\mathbb{E}[\theta|y]$. It is one of the solutions to a third degree polynomial equation. Take the following counter-example of a Gamma $\mathfrak G(\alpha,\beta)$ posterior. The posterior risk function is then $$R(\pi,\hat\theta)=\hat\theta^4-4\hat\theta^3\mathbb E^\pi[\theta|y]+6\hat\theta^2\mathbb E^\pi[\theta^2|y]-4\hat\theta\mathbb E^\pi[\theta^3|y]+\mathbb E^\pi[\theta^4|y]$$ and $$\mathbb E^\pi[\theta^k|y]=\beta^{-k}(k+\alpha)\cdots\alpha$$ hence $$R(\pi,\hat\theta)=\hat\theta^4-4\hat\theta^3\alpha\beta^{-1}+6\hat\theta^2\alpha(\alpha+1)\beta^{-2}-4\hat\theta\alpha(\alpha+1)(\alpha+2)(\alpha+3)\beta^{-3}+\mathbb E^\pi[\theta^4|y]$$ Without loss of generality, we can take $\beta=1$. Here is an illustration of the risk function when $\alpha=3.1415...$: The solution is clearly different from $\alpha/\beta$, the posterior mean.
Bayes risk estimator under quartic loss Unless the posterior is symmetric around $\mathbb{E}[\theta|y]$ there is no reason for the estimator to be equal to $\mathbb{E}[\theta|y]$. It is one of the solutions to a third degree polynomial equa
35,605
Prove that Kurtosis is at least one more than the square of the skewness
This demonstration uses the clever (yet elementary) method employed in Fisher's reference Burnside & Panton vol. II, section 142. It assumes a familiarity with the basics of determinants: their definition, computing them with row-reduction, and expanding them by minors. I also make liberal use of block-matrix notation to simplify the presentation. (Lurking here is a more modern theorem about the norms of alternating multilinear forms, aka "antisymmetric tensors,* but I will avoid using this language.) To help you see the progress of the argument, I have highlighted three equivalent statements of the inequality as they are obtained. Part of the interest in this solution lies in the incidental but elegant formula for that determinant shown in the question and labeled $(*)$ below. Otherwise we could take a more direct route to the conclusion by first centering the data (to make their sum $S_1=0$) and scaling them to unit variance (whence their sum of squares is $S_2=n$) and proceeding from the observation that the cross-product $\mathbb X \mathbb X^\prime$ must be positive-semidefinite directly to the inequality by evaluating its determinant. That is, after these preliminary normalization steps, we have $$0 \le \left|\mathbb X \mathbb X^\prime\right| = \left| \matrix{n & 0 & n\\0 & n & n\beta \\ n & n\beta & n\kappa}\right| = n^3\left| \matrix{1 & 0 & 1\\0 & 1 & \beta \\ 1 & \beta & 1\kappa}\right| = \kappa - \beta^2 - 1.$$ Let a dataset be represented by a vector of its values $(x_1, x_2, \ldots, x_n).$ We are going to create a matrix of dimensions $(n+3)\times (n+3)$ out of four blocks based on the $3\times n$ matrix $$\mathbb X = \pmatrix{1&1&\cdots & 1 \\ x_1 & x_2 & \cdots & x_n\\x_1^2 & x_2^2 & \cdots & x_n^2},$$ the $n\times n$ identity matrix $\mathbb{I}_n,$ and the $3\times 3$ zero matrix $\mathbb{O}_3;$ namely, $$\mathbb A = \pmatrix{\mathbb{X} & \mathbb{O}_3 \\ -\mathbb{I}_n & \mathbb{X}^\prime}.$$ The kurtosis-skewness inequality will amount to (a) relating the determinant of $\mathbb A$ to the determinant of a $3\times 3$ matrix formed from sums of powers of the data and then (b) showing $\mathbb A$ has a non-negative determinant. To achieve the first reduction, zero out the upper left $\mathbb X$ block using row operations (which leave the determinant unchanged). This amounts to left-multiplying $\mathbb{A}$ by the block matrix $$\mathbb Q = \pmatrix{\mathbb{I}_3 & \mathbb X \\ \mathbb{O}_{n\times 3} & \mathbb{I}_n}$$ where $\mathbb{O}_{n\times 3}$ is the $n\times 3$ matrix of zeros. We obtain $$\mathbb{Q}\mathbb{A} = \pmatrix{\mathbb{O}_{3\times n} & \mathbb{X}\mathbb{X}^\prime \\ -\mathbb{I}_n & \mathbb{X}^\prime}.$$ Similarly, the lower $\mathbb{X}^\prime$ block can be zeroed out by column operations--but these leave the upper right block untouched. The result is $$|\mathbb A| = \left|\matrix{\mathbb O_{3\times n}&\mathbb X \mathbb X^\prime \\ -\mathbb{I}_n & \mathbb O_{n\times 3}}\right| = (-1)^{3n}\left|-\mathbb{I}_n\right| \left| \mathbb X \mathbb X^\prime\right| = \left| \mathbb X \mathbb X^\prime\right|.$$ Another way to find the determinant of $\mathbb A$ returns to its definition and employs Laplace's expansion in $3\times 3$ minors across the top row. A representative term in this expansion is the determinant of the principal $3\times 3$ minor times the determinant of its complement. That minor is $$\mathbb{A}_{(1,2,3); (1,2,3)} = \pmatrix{1&1&1 \\ x_1 & x_2 & x_3 \\ x_1^2 & x_2^2 & x_3^2}$$ and its complement has the form $$\mathbb{A}^0_{(1,2,3); (1,2,3)} = \pmatrix{\mathbb{O}_{3\times n} & \mathbb{A}_{(1,2,3); (1,2,3)}^\prime \\ -\mathbb{I}_{n-3} & *}$$ Both determinants evidently equal the determinant of that minor, $$\left|\mathbb{A}_{(1,2,3); (1,2,3)} \right| = \left|\mathbb{A}^0_{(1,2,3); (1,2,3)}\right| = (x_3-x_2)(x_3-x_1)(x_2-x_1).$$ Thus the product of the determinants of this minor and its complement is the square of the value on the right hand side. The expansion has one such term for each (not structurally zero) minor, $$\left| \mathbb A \right| = \sum_{n \ge k \gt j \gt i \ge 1} \left[(x_k-x_j)(x_k-x_i)(x_j-x_i)\right]^2.\tag{*}$$ ("Not structurally zero" means that all minors involving any of the last three columns must be zero and so don't appear explicitly in this sum.) This quantity, being a sum of squares, is non-negative, whence $$0 \le \left| \mathbb A \right| = \left|\mathbb X\mathbb X^\prime\right|.$$ The rest is just mopping up but, to be complete, I will give the details. For any $k=0, 1, 2, \ldots, $ writing $$S_k = \sum_{i=1}^n x_i^k$$ for the sum of $k^\text{th}$ powers of the data enables us to represent the cross-product of $\mathbb X$ in the simple form $$\mathbb X \mathbb X^\prime = \pmatrix{S_0 & S_1 & S_2 \\ S_1 & S_2 & S_3 \\ S_2 & S_3 & S_4}.$$ This simplifies, because $(*)$ shows it is a function only of the differences among the data, quantities that do not change when a constant is added to all the data values. Add the negative of their mean to each term (that is, center the data) to make $S_1=0.$ Obviously $S_0=n,$ giving $$ 0 \le \left|\matrix{n & 0 & S_2 \\ 0 & S_2 & S_3 \\ S_2 & S_3 & S_4}\right| = n\left|\matrix{S_2 & S_3 \\ S_3 & S_4}\right| - S_2\left|\matrix{0 & S_2 \\ S_2 & S_3}\right| = n(S_2S_4 - S_3^2) - S_2^3.$$ The kurtosis $\kappa = (S_4/n)/(S_2/n)^2$ and skewness $\beta = (S_3/n)/(S_2/n)^{3/2}$ are defined only when the variance is nonzero, which implies $S_2$ is nonzero. We may therefore divide both sides of this inequality by the positive quantity $n^3S_2^3$ to give $$0 \le \frac{n(S_2S_4 - S_3^2) - S_2^3}{n^3 S_2^3} = \kappa - \beta^2 - 1$$ to conclude $$\kappa \ge \beta^2 + 1.$$ Finally, since the kurtosis and skewness of any distribution can be approximated arbitrarily well by a finite discrete distribution (at least when both are defined and finite), this equality must hold for all distributions for which the kurtosis and skewness are defined and finite, QED.
Prove that Kurtosis is at least one more than the square of the skewness
This demonstration uses the clever (yet elementary) method employed in Fisher's reference Burnside & Panton vol. II, section 142. It assumes a familiarity with the basics of determinants: their defin
Prove that Kurtosis is at least one more than the square of the skewness This demonstration uses the clever (yet elementary) method employed in Fisher's reference Burnside & Panton vol. II, section 142. It assumes a familiarity with the basics of determinants: their definition, computing them with row-reduction, and expanding them by minors. I also make liberal use of block-matrix notation to simplify the presentation. (Lurking here is a more modern theorem about the norms of alternating multilinear forms, aka "antisymmetric tensors,* but I will avoid using this language.) To help you see the progress of the argument, I have highlighted three equivalent statements of the inequality as they are obtained. Part of the interest in this solution lies in the incidental but elegant formula for that determinant shown in the question and labeled $(*)$ below. Otherwise we could take a more direct route to the conclusion by first centering the data (to make their sum $S_1=0$) and scaling them to unit variance (whence their sum of squares is $S_2=n$) and proceeding from the observation that the cross-product $\mathbb X \mathbb X^\prime$ must be positive-semidefinite directly to the inequality by evaluating its determinant. That is, after these preliminary normalization steps, we have $$0 \le \left|\mathbb X \mathbb X^\prime\right| = \left| \matrix{n & 0 & n\\0 & n & n\beta \\ n & n\beta & n\kappa}\right| = n^3\left| \matrix{1 & 0 & 1\\0 & 1 & \beta \\ 1 & \beta & 1\kappa}\right| = \kappa - \beta^2 - 1.$$ Let a dataset be represented by a vector of its values $(x_1, x_2, \ldots, x_n).$ We are going to create a matrix of dimensions $(n+3)\times (n+3)$ out of four blocks based on the $3\times n$ matrix $$\mathbb X = \pmatrix{1&1&\cdots & 1 \\ x_1 & x_2 & \cdots & x_n\\x_1^2 & x_2^2 & \cdots & x_n^2},$$ the $n\times n$ identity matrix $\mathbb{I}_n,$ and the $3\times 3$ zero matrix $\mathbb{O}_3;$ namely, $$\mathbb A = \pmatrix{\mathbb{X} & \mathbb{O}_3 \\ -\mathbb{I}_n & \mathbb{X}^\prime}.$$ The kurtosis-skewness inequality will amount to (a) relating the determinant of $\mathbb A$ to the determinant of a $3\times 3$ matrix formed from sums of powers of the data and then (b) showing $\mathbb A$ has a non-negative determinant. To achieve the first reduction, zero out the upper left $\mathbb X$ block using row operations (which leave the determinant unchanged). This amounts to left-multiplying $\mathbb{A}$ by the block matrix $$\mathbb Q = \pmatrix{\mathbb{I}_3 & \mathbb X \\ \mathbb{O}_{n\times 3} & \mathbb{I}_n}$$ where $\mathbb{O}_{n\times 3}$ is the $n\times 3$ matrix of zeros. We obtain $$\mathbb{Q}\mathbb{A} = \pmatrix{\mathbb{O}_{3\times n} & \mathbb{X}\mathbb{X}^\prime \\ -\mathbb{I}_n & \mathbb{X}^\prime}.$$ Similarly, the lower $\mathbb{X}^\prime$ block can be zeroed out by column operations--but these leave the upper right block untouched. The result is $$|\mathbb A| = \left|\matrix{\mathbb O_{3\times n}&\mathbb X \mathbb X^\prime \\ -\mathbb{I}_n & \mathbb O_{n\times 3}}\right| = (-1)^{3n}\left|-\mathbb{I}_n\right| \left| \mathbb X \mathbb X^\prime\right| = \left| \mathbb X \mathbb X^\prime\right|.$$ Another way to find the determinant of $\mathbb A$ returns to its definition and employs Laplace's expansion in $3\times 3$ minors across the top row. A representative term in this expansion is the determinant of the principal $3\times 3$ minor times the determinant of its complement. That minor is $$\mathbb{A}_{(1,2,3); (1,2,3)} = \pmatrix{1&1&1 \\ x_1 & x_2 & x_3 \\ x_1^2 & x_2^2 & x_3^2}$$ and its complement has the form $$\mathbb{A}^0_{(1,2,3); (1,2,3)} = \pmatrix{\mathbb{O}_{3\times n} & \mathbb{A}_{(1,2,3); (1,2,3)}^\prime \\ -\mathbb{I}_{n-3} & *}$$ Both determinants evidently equal the determinant of that minor, $$\left|\mathbb{A}_{(1,2,3); (1,2,3)} \right| = \left|\mathbb{A}^0_{(1,2,3); (1,2,3)}\right| = (x_3-x_2)(x_3-x_1)(x_2-x_1).$$ Thus the product of the determinants of this minor and its complement is the square of the value on the right hand side. The expansion has one such term for each (not structurally zero) minor, $$\left| \mathbb A \right| = \sum_{n \ge k \gt j \gt i \ge 1} \left[(x_k-x_j)(x_k-x_i)(x_j-x_i)\right]^2.\tag{*}$$ ("Not structurally zero" means that all minors involving any of the last three columns must be zero and so don't appear explicitly in this sum.) This quantity, being a sum of squares, is non-negative, whence $$0 \le \left| \mathbb A \right| = \left|\mathbb X\mathbb X^\prime\right|.$$ The rest is just mopping up but, to be complete, I will give the details. For any $k=0, 1, 2, \ldots, $ writing $$S_k = \sum_{i=1}^n x_i^k$$ for the sum of $k^\text{th}$ powers of the data enables us to represent the cross-product of $\mathbb X$ in the simple form $$\mathbb X \mathbb X^\prime = \pmatrix{S_0 & S_1 & S_2 \\ S_1 & S_2 & S_3 \\ S_2 & S_3 & S_4}.$$ This simplifies, because $(*)$ shows it is a function only of the differences among the data, quantities that do not change when a constant is added to all the data values. Add the negative of their mean to each term (that is, center the data) to make $S_1=0.$ Obviously $S_0=n,$ giving $$ 0 \le \left|\matrix{n & 0 & S_2 \\ 0 & S_2 & S_3 \\ S_2 & S_3 & S_4}\right| = n\left|\matrix{S_2 & S_3 \\ S_3 & S_4}\right| - S_2\left|\matrix{0 & S_2 \\ S_2 & S_3}\right| = n(S_2S_4 - S_3^2) - S_2^3.$$ The kurtosis $\kappa = (S_4/n)/(S_2/n)^2$ and skewness $\beta = (S_3/n)/(S_2/n)^{3/2}$ are defined only when the variance is nonzero, which implies $S_2$ is nonzero. We may therefore divide both sides of this inequality by the positive quantity $n^3S_2^3$ to give $$0 \le \frac{n(S_2S_4 - S_3^2) - S_2^3}{n^3 S_2^3} = \kappa - \beta^2 - 1$$ to conclude $$\kappa \ge \beta^2 + 1.$$ Finally, since the kurtosis and skewness of any distribution can be approximated arbitrarily well by a finite discrete distribution (at least when both are defined and finite), this equality must hold for all distributions for which the kurtosis and skewness are defined and finite, QED.
Prove that Kurtosis is at least one more than the square of the skewness This demonstration uses the clever (yet elementary) method employed in Fisher's reference Burnside & Panton vol. II, section 142. It assumes a familiarity with the basics of determinants: their defin
35,606
Prove that Kurtosis is at least one more than the square of the skewness
Consider the quadratic form \begin{align} Q(a, ~b,~c) & := \frac1n\sum \left(a + xb+ x^2 c\right)^2 \\ &= a^2\cdot v_0 + b^2\cdot v_2 + c^2\cdot v_4+ 2ab\cdot v_1+ 2bc\cdot v_3+ 2ca\cdot v_2,\tag 1\label 1\end{align} that is, $v_i:= \frac{\sum x^i}n,~i\in \{0,~1,~2,~3,~4\}.$ $\eqref{1}$ is positive semi-definite. Then the determinant of the matrix of the quadratic form $\eqref{1}$ $$\begin{vmatrix}v_0 & v_1 & v_2\\ v_1 & v_2 & v_3\\ v_2 & v_3 & v_4\end{vmatrix},\tag 2\label 2$$ would be non-negative. Now, take $v_1 = 0,~ v_2 = 1.$ Then $\eqref{2}$ reduces to $$\begin{vmatrix}1 & 0& 1\\ 0 & 1& \gamma_3\\ 1 & \gamma_3 & \gamma_4\end{vmatrix}\geq 0.\tag 3\label 3$$ The rest follows by expanding $\eqref{3}.$ Reference: $\rm [I]$ A Note on Skewness and Kurtosis, J. Ernest Wilkins, Jr., Ann. Math. Stat. $15 ~(1944),$ p. $334.$
Prove that Kurtosis is at least one more than the square of the skewness
Consider the quadratic form \begin{align} Q(a, ~b,~c) & := \frac1n\sum \left(a + xb+ x^2 c\right)^2 \\ &= a^2\cdot v_0 + b^2\cdot v_2 + c^2\cdot v_4+ 2ab\cdot v_1+ 2bc\cdot v_3+ 2ca\cdot v_2,\tag 1\la
Prove that Kurtosis is at least one more than the square of the skewness Consider the quadratic form \begin{align} Q(a, ~b,~c) & := \frac1n\sum \left(a + xb+ x^2 c\right)^2 \\ &= a^2\cdot v_0 + b^2\cdot v_2 + c^2\cdot v_4+ 2ab\cdot v_1+ 2bc\cdot v_3+ 2ca\cdot v_2,\tag 1\label 1\end{align} that is, $v_i:= \frac{\sum x^i}n,~i\in \{0,~1,~2,~3,~4\}.$ $\eqref{1}$ is positive semi-definite. Then the determinant of the matrix of the quadratic form $\eqref{1}$ $$\begin{vmatrix}v_0 & v_1 & v_2\\ v_1 & v_2 & v_3\\ v_2 & v_3 & v_4\end{vmatrix},\tag 2\label 2$$ would be non-negative. Now, take $v_1 = 0,~ v_2 = 1.$ Then $\eqref{2}$ reduces to $$\begin{vmatrix}1 & 0& 1\\ 0 & 1& \gamma_3\\ 1 & \gamma_3 & \gamma_4\end{vmatrix}\geq 0.\tag 3\label 3$$ The rest follows by expanding $\eqref{3}.$ Reference: $\rm [I]$ A Note on Skewness and Kurtosis, J. Ernest Wilkins, Jr., Ann. Math. Stat. $15 ~(1944),$ p. $334.$
Prove that Kurtosis is at least one more than the square of the skewness Consider the quadratic form \begin{align} Q(a, ~b,~c) & := \frac1n\sum \left(a + xb+ x^2 c\right)^2 \\ &= a^2\cdot v_0 + b^2\cdot v_2 + c^2\cdot v_4+ 2ab\cdot v_1+ 2bc\cdot v_3+ 2ca\cdot v_2,\tag 1\la
35,607
Maximum Likelihood Estimator on birthday paradox
This is a problem amenable to maximum likelihood estimation, provided one can write down the likelihood or design a latent variable representation to run an EM algorithm. Let us denote $\bar N$ for the number of days/boxes (like $\bar N=365$ in the original problem) and $M$ for the number of individuals. Borrowing from this paper by Fisher, Funk, and Sams, the probability to have $r$ distinct birth-days in a population of $M=m$ individuals writes as $$\mathbb P(R=r)=\frac{\bar N!}{(\bar N-r)!}\frac{m!}{\bar N^m} \sum_{(r_1,\ldots,r_m);\\\sum_1^m r_i=r\ \&\\\sum_1^m ir_i=m}1\Big/\prod_{j=1}^m r_j! (j!)^{r_j}\tag{1}$$ where the $r_j$'s correspond to the number of days with exactly $j$ simultaneous or shared birthdays. But Feller (1970, p.102) gives the simpler representation $$\mathbb P(R=r)={\bar{N} \choose r}\sum_{\nu=0}^r (-1)^{\nu}{r\choose\nu}\left(1-\frac{T-r+\nu}T \right)^m$$ which fits well an empirical distribution when $\bar N$ is small enough. Feller (1970, pp.103-104) justifies an asymptotic Poisson approximation with parameter$$\lambda(M)=\bar{N}\exp\{-M/\bar N\}$$from which an estimate of $M$ can be derived. With the birthday problem as illustration (pp.105-106)! And if I understand properly the "strong birthday" problem in Das Gupta (2005)](https://www.math.ucdavis.edu/~tracy/courses/math135A/UsefullCourseMaterial/birthday.pdf) the number of "unique" people (not sharing a birthday with anyone else) is distributed as: $$\mathbb P(R'=r)=\sum_{i=r}^m (-1)^{i-r} \frac{i!}{r!(i-r)!}\frac{\bar N!m!(\bar N-i)^{m-i}}{i!(\bar N-i)!(m-i)!\bar N^m}\tag{2}$$
Maximum Likelihood Estimator on birthday paradox
This is a problem amenable to maximum likelihood estimation, provided one can write down the likelihood or design a latent variable representation to run an EM algorithm. Let us denote $\bar N$ for th
Maximum Likelihood Estimator on birthday paradox This is a problem amenable to maximum likelihood estimation, provided one can write down the likelihood or design a latent variable representation to run an EM algorithm. Let us denote $\bar N$ for the number of days/boxes (like $\bar N=365$ in the original problem) and $M$ for the number of individuals. Borrowing from this paper by Fisher, Funk, and Sams, the probability to have $r$ distinct birth-days in a population of $M=m$ individuals writes as $$\mathbb P(R=r)=\frac{\bar N!}{(\bar N-r)!}\frac{m!}{\bar N^m} \sum_{(r_1,\ldots,r_m);\\\sum_1^m r_i=r\ \&\\\sum_1^m ir_i=m}1\Big/\prod_{j=1}^m r_j! (j!)^{r_j}\tag{1}$$ where the $r_j$'s correspond to the number of days with exactly $j$ simultaneous or shared birthdays. But Feller (1970, p.102) gives the simpler representation $$\mathbb P(R=r)={\bar{N} \choose r}\sum_{\nu=0}^r (-1)^{\nu}{r\choose\nu}\left(1-\frac{T-r+\nu}T \right)^m$$ which fits well an empirical distribution when $\bar N$ is small enough. Feller (1970, pp.103-104) justifies an asymptotic Poisson approximation with parameter$$\lambda(M)=\bar{N}\exp\{-M/\bar N\}$$from which an estimate of $M$ can be derived. With the birthday problem as illustration (pp.105-106)! And if I understand properly the "strong birthday" problem in Das Gupta (2005)](https://www.math.ucdavis.edu/~tracy/courses/math135A/UsefullCourseMaterial/birthday.pdf) the number of "unique" people (not sharing a birthday with anyone else) is distributed as: $$\mathbb P(R'=r)=\sum_{i=r}^m (-1)^{i-r} \frac{i!}{r!(i-r)!}\frac{\bar N!m!(\bar N-i)^{m-i}}{i!(\bar N-i)!(m-i)!\bar N^m}\tag{2}$$
Maximum Likelihood Estimator on birthday paradox This is a problem amenable to maximum likelihood estimation, provided one can write down the likelihood or design a latent variable representation to run an EM algorithm. Let us denote $\bar N$ for th
35,608
heteroskedasticity and logistic regression
Except in a very technical sense (which @BigBendRegion's answer gets at) heteroskedasticity isn't a "thing' in a logistic regression model. Heteroskedasticity is when the standard deviation of the errors around the regression line (that is the average distance between the predicted Y value at a given X value and the actual Y values in your dataset for cases with those X values) gets bigger or smaller as X increase. Now, many people (myself included) would argue that heteroskedasticity isn't even that big of a problem for LINEAR regression, except when it's caused by other more serious issues (like nonlinearity or omitted variable bias). But this whole concept doesn't make sense in logit because logit models don't even HAVE error terms, or rather they don't have error terms that come from the data. To oversimplify greatly, what a logit model actually "does" is run an OLS model on an unobserved latent variable (call it y*) that represents the "propensity" to do whatever it is your binary variable Y is measuring (we assume that people with a y* over some arbitrary threshold get a Y of 1 and everyone else gets a zero). Obviously we don't know what y* looks like, so in order to specify this model we assume that the errors in this OLS model have a logistic distribution (hence the name of the model) with a standard deviation of of $π/\sqrt{3}$ (the probit model assumes they are normally distributed with a standard deviation of 1). Through some calculus we use this assumption about the distribution of the errors in y* to get us to the logit model of Y itself. This means that the logit model doesn't have an error term, because the distribution of the errors is build into the assumptions of the model itself. So it doesn't make sense to talk about whether the errors get bigger or smaller as X increases, which is what heteroskedasticity is.
heteroskedasticity and logistic regression
Except in a very technical sense (which @BigBendRegion's answer gets at) heteroskedasticity isn't a "thing' in a logistic regression model. Heteroskedasticity is when the standard deviation of the err
heteroskedasticity and logistic regression Except in a very technical sense (which @BigBendRegion's answer gets at) heteroskedasticity isn't a "thing' in a logistic regression model. Heteroskedasticity is when the standard deviation of the errors around the regression line (that is the average distance between the predicted Y value at a given X value and the actual Y values in your dataset for cases with those X values) gets bigger or smaller as X increase. Now, many people (myself included) would argue that heteroskedasticity isn't even that big of a problem for LINEAR regression, except when it's caused by other more serious issues (like nonlinearity or omitted variable bias). But this whole concept doesn't make sense in logit because logit models don't even HAVE error terms, or rather they don't have error terms that come from the data. To oversimplify greatly, what a logit model actually "does" is run an OLS model on an unobserved latent variable (call it y*) that represents the "propensity" to do whatever it is your binary variable Y is measuring (we assume that people with a y* over some arbitrary threshold get a Y of 1 and everyone else gets a zero). Obviously we don't know what y* looks like, so in order to specify this model we assume that the errors in this OLS model have a logistic distribution (hence the name of the model) with a standard deviation of of $π/\sqrt{3}$ (the probit model assumes they are normally distributed with a standard deviation of 1). Through some calculus we use this assumption about the distribution of the errors in y* to get us to the logit model of Y itself. This means that the logit model doesn't have an error term, because the distribution of the errors is build into the assumptions of the model itself. So it doesn't make sense to talk about whether the errors get bigger or smaller as X increases, which is what heteroskedasticity is.
heteroskedasticity and logistic regression Except in a very technical sense (which @BigBendRegion's answer gets at) heteroskedasticity isn't a "thing' in a logistic regression model. Heteroskedasticity is when the standard deviation of the err
35,609
heteroskedasticity and logistic regression
With the logistic regression model, heteroscedasticity is automatically assumed to exist. The conditional distribution of $Y$ given $X=x$ is assumed to be Bernoulli with parameter $\pi(x)$, a probability. The variance of this distribution is $\pi(x)\times (1-\pi(x))$, a nonconstant function of $x$. Likewise, you do not need to worry about normality. You still need to consider the linearity (in the logits) and independence assumptions, however.
heteroskedasticity and logistic regression
With the logistic regression model, heteroscedasticity is automatically assumed to exist. The conditional distribution of $Y$ given $X=x$ is assumed to be Bernoulli with parameter $\pi(x)$, a probabi
heteroskedasticity and logistic regression With the logistic regression model, heteroscedasticity is automatically assumed to exist. The conditional distribution of $Y$ given $X=x$ is assumed to be Bernoulli with parameter $\pi(x)$, a probability. The variance of this distribution is $\pi(x)\times (1-\pi(x))$, a nonconstant function of $x$. Likewise, you do not need to worry about normality. You still need to consider the linearity (in the logits) and independence assumptions, however.
heteroskedasticity and logistic regression With the logistic regression model, heteroscedasticity is automatically assumed to exist. The conditional distribution of $Y$ given $X=x$ is assumed to be Bernoulli with parameter $\pi(x)$, a probabi
35,610
Which loss function has a less optimal answer for w?
Since the data is linearly separable, other loss functions can be made $0$ via a suitable choice of weights, $w$. However, second one has a regularisation term, so the loss function doesn't only favor the linear separability, but the norm of the weights as well. Notes: Given a loss function, I assumed the chosen optimizer with initial condition will find the optimum point for that loss. So, it'll optimize $L_2$ as well (i.e. $L_2$ will reach its minimum). Although it's typically not a good idea to compare the values of the loss functions since the expressions are different, $L_2$ will always be $\geq L_i$ for other $i$, since other loss functions can be made $0$, but $L_2$ most probably won't be. If the optimality is measured wrt separability of the dataset, i.e. a $w$ that separates the dataset is called optimum and another that doesn't is not, $L_2$ will probably be less optimum as well because it's not guaranteed to separate the dataset.
Which loss function has a less optimal answer for w?
Since the data is linearly separable, other loss functions can be made $0$ via a suitable choice of weights, $w$. However, second one has a regularisation term, so the loss function doesn't only favor
Which loss function has a less optimal answer for w? Since the data is linearly separable, other loss functions can be made $0$ via a suitable choice of weights, $w$. However, second one has a regularisation term, so the loss function doesn't only favor the linear separability, but the norm of the weights as well. Notes: Given a loss function, I assumed the chosen optimizer with initial condition will find the optimum point for that loss. So, it'll optimize $L_2$ as well (i.e. $L_2$ will reach its minimum). Although it's typically not a good idea to compare the values of the loss functions since the expressions are different, $L_2$ will always be $\geq L_i$ for other $i$, since other loss functions can be made $0$, but $L_2$ most probably won't be. If the optimality is measured wrt separability of the dataset, i.e. a $w$ that separates the dataset is called optimum and another that doesn't is not, $L_2$ will probably be less optimum as well because it's not guaranteed to separate the dataset.
Which loss function has a less optimal answer for w? Since the data is linearly separable, other loss functions can be made $0$ via a suitable choice of weights, $w$. However, second one has a regularisation term, so the loss function doesn't only favor
35,611
Which loss function has a less optimal answer for w?
Your data are lineary separable, this means that all linear classifier will make accurate separation of the data. A linear regression is a linear classifier, i.e it uses a line to separate data. So either you use a linear regression with no penalty or a linear regression with penalty you are still going to separate correctly your data. However, what a penalty means, is that you will have an additional term in your loss function. So, a loss function $L$ will be $L^{'} = L+\frac{1}{2}f(w)$ in penalty case, where $f(w)$ can be what ever norm you prefer. So, you will have that $L^{'} > L$. But as we said both linear classifier separate the data accurately (the one that correspond to $L^{'}$ and the one that correspond to $L$) but we know that $L^{'}$ is less optimal, in the sense that it is larger than the $L$. I'm not quite sure however, if that is the optimality meaning that you refer to. I hope that helps. Some further discussion, for the exact loss functions that you have: $L_{1}(w)= \frac{1}{n}\sum_{i=1}^{n}max(0,-y_{i}w^{T}x)$ A correct classification means that $y_{i}>0$ and $w^{T}x>0$ or $y_{i}<0$ and $w^{T}x<0$. In both cases the $max(0,-y_{i}w^{T}x)=0$ because you do not have to minimize something on correct classifications. Thus, because your data are linearly separable the $L_{1}(w)=0$. For the $L_{3}(w)$, for this loss function to be meaningful I assume that the step function $u$ is defined as follows: if $y_{i}w^{T}x>0$ then $u=0$ and if $y_{i}w^{T}x<0$ then $u=1$, i.e for misclassifications the loss function is increased. Again, because your data are linearly separable you will not have missclasifications so the $L_{3}(w)=0$ Similar for the $L_{4}(w)=0$ Lastly, for the $L_{2}(w)$, the term $C\sum_{i=1}^{n}max(0,-y_{i}w^{T}x)$ is equal to zero prior of $C$ reaching infinity, because the sum is zero due to linear separability. So, the $L_{2}(w)$ is left with the penalty term, and that penalty term cannot be zero, because then all your weights will be zero so you will be full of misclassifications. Hence, with that in mind $L_{2}(w)>0$.
Which loss function has a less optimal answer for w?
Your data are lineary separable, this means that all linear classifier will make accurate separation of the data. A linear regression is a linear classifier, i.e it uses a line to separate data. So ei
Which loss function has a less optimal answer for w? Your data are lineary separable, this means that all linear classifier will make accurate separation of the data. A linear regression is a linear classifier, i.e it uses a line to separate data. So either you use a linear regression with no penalty or a linear regression with penalty you are still going to separate correctly your data. However, what a penalty means, is that you will have an additional term in your loss function. So, a loss function $L$ will be $L^{'} = L+\frac{1}{2}f(w)$ in penalty case, where $f(w)$ can be what ever norm you prefer. So, you will have that $L^{'} > L$. But as we said both linear classifier separate the data accurately (the one that correspond to $L^{'}$ and the one that correspond to $L$) but we know that $L^{'}$ is less optimal, in the sense that it is larger than the $L$. I'm not quite sure however, if that is the optimality meaning that you refer to. I hope that helps. Some further discussion, for the exact loss functions that you have: $L_{1}(w)= \frac{1}{n}\sum_{i=1}^{n}max(0,-y_{i}w^{T}x)$ A correct classification means that $y_{i}>0$ and $w^{T}x>0$ or $y_{i}<0$ and $w^{T}x<0$. In both cases the $max(0,-y_{i}w^{T}x)=0$ because you do not have to minimize something on correct classifications. Thus, because your data are linearly separable the $L_{1}(w)=0$. For the $L_{3}(w)$, for this loss function to be meaningful I assume that the step function $u$ is defined as follows: if $y_{i}w^{T}x>0$ then $u=0$ and if $y_{i}w^{T}x<0$ then $u=1$, i.e for misclassifications the loss function is increased. Again, because your data are linearly separable you will not have missclasifications so the $L_{3}(w)=0$ Similar for the $L_{4}(w)=0$ Lastly, for the $L_{2}(w)$, the term $C\sum_{i=1}^{n}max(0,-y_{i}w^{T}x)$ is equal to zero prior of $C$ reaching infinity, because the sum is zero due to linear separability. So, the $L_{2}(w)$ is left with the penalty term, and that penalty term cannot be zero, because then all your weights will be zero so you will be full of misclassifications. Hence, with that in mind $L_{2}(w)>0$.
Which loss function has a less optimal answer for w? Your data are lineary separable, this means that all linear classifier will make accurate separation of the data. A linear regression is a linear classifier, i.e it uses a line to separate data. So ei
35,612
How to prove $s^2$ is a consistent estimator of $\sigma^2$?
It's a very well known result that : If $X_1, X_2, \cdots, X_n \stackrel{\text{iid}}{\sim} N(\mu,\sigma^2)$ , then $$Z_n = \dfrac{\displaystyle\sum(X_i - \bar{X})^2}{\sigma^2} \sim \chi^2_{n-1}$$ Thus, $ \mathbb{E}(Z_n) = n-1 $ and $ \text{var}(Z_n) = 2(n-1)$ . If you wish to see a proof of the above result, please refer to this link. Now, since you already know that $s^2$ is an unbiased estimator of $\sigma^2$ , so for any $\varepsilon>0$ , we have : \begin{align*} &\mathbb{P}(\mid s^2 - \sigma^2 \mid > \varepsilon )\\ &= \mathbb{P}(\mid s^2 - \mathbb{E}(s^2) \mid > \varepsilon )\\ &\leqslant \dfrac{\text{var}(s^2)}{\varepsilon^2}\\ &=\dfrac{1}{(n-1)^2}\cdot \text{var}\left[\sum (X_i - \overline{X})^2)\right]\\ &=\dfrac{\sigma^4}{(n-1)^2}\cdot \text{var}\left[\frac{\sum (X_i - \overline{X})^2}{\sigma^2}\right]\\ &=\dfrac{\sigma^4}{(n-1)^2}\cdot\text{var}(Z_n)\\ &=\dfrac{\sigma^4}{(n-1)^2}\cdot 2(n-1) = \dfrac{2\sigma^4}{n-1} \stackrel{n\to\infty}{\longrightarrow} 0 \end{align*} Thus, $ \displaystyle\lim_{n\to\infty} \mathbb{P}(\mid s^2 - \sigma^2 \mid > \varepsilon ) = 0$ , i.e. $ s^2 \stackrel{\mathbb{P}}{\longrightarrow} \sigma^2 $ as $n\to\infty$ , which tells us that $s^2$ is a consistent estimator of $\sigma^2$ . Note : I have used Chebyshev's inequality in the first inequality step used above. Hope my answer serves your purpose. Thank you.
How to prove $s^2$ is a consistent estimator of $\sigma^2$?
It's a very well known result that : If $X_1, X_2, \cdots, X_n \stackrel{\text{iid}}{\sim} N(\mu,\sigma^2)$ , then $$Z_n = \dfrac{\displaystyle\sum(X_i - \bar{X})^2}{\sigma^2} \sim \chi^2_{n-1}$$ Thu
How to prove $s^2$ is a consistent estimator of $\sigma^2$? It's a very well known result that : If $X_1, X_2, \cdots, X_n \stackrel{\text{iid}}{\sim} N(\mu,\sigma^2)$ , then $$Z_n = \dfrac{\displaystyle\sum(X_i - \bar{X})^2}{\sigma^2} \sim \chi^2_{n-1}$$ Thus, $ \mathbb{E}(Z_n) = n-1 $ and $ \text{var}(Z_n) = 2(n-1)$ . If you wish to see a proof of the above result, please refer to this link. Now, since you already know that $s^2$ is an unbiased estimator of $\sigma^2$ , so for any $\varepsilon>0$ , we have : \begin{align*} &\mathbb{P}(\mid s^2 - \sigma^2 \mid > \varepsilon )\\ &= \mathbb{P}(\mid s^2 - \mathbb{E}(s^2) \mid > \varepsilon )\\ &\leqslant \dfrac{\text{var}(s^2)}{\varepsilon^2}\\ &=\dfrac{1}{(n-1)^2}\cdot \text{var}\left[\sum (X_i - \overline{X})^2)\right]\\ &=\dfrac{\sigma^4}{(n-1)^2}\cdot \text{var}\left[\frac{\sum (X_i - \overline{X})^2}{\sigma^2}\right]\\ &=\dfrac{\sigma^4}{(n-1)^2}\cdot\text{var}(Z_n)\\ &=\dfrac{\sigma^4}{(n-1)^2}\cdot 2(n-1) = \dfrac{2\sigma^4}{n-1} \stackrel{n\to\infty}{\longrightarrow} 0 \end{align*} Thus, $ \displaystyle\lim_{n\to\infty} \mathbb{P}(\mid s^2 - \sigma^2 \mid > \varepsilon ) = 0$ , i.e. $ s^2 \stackrel{\mathbb{P}}{\longrightarrow} \sigma^2 $ as $n\to\infty$ , which tells us that $s^2$ is a consistent estimator of $\sigma^2$ . Note : I have used Chebyshev's inequality in the first inequality step used above. Hope my answer serves your purpose. Thank you.
How to prove $s^2$ is a consistent estimator of $\sigma^2$? It's a very well known result that : If $X_1, X_2, \cdots, X_n \stackrel{\text{iid}}{\sim} N(\mu,\sigma^2)$ , then $$Z_n = \dfrac{\displaystyle\sum(X_i - \bar{X})^2}{\sigma^2} \sim \chi^2_{n-1}$$ Thu
35,613
Hacking linear regression
You decreased the (total) variance in the data making it easier to explain. Thanks to the same $y$-axis limits, it can be easily seen that the data of your first example is much more spread in this direction than in the $x$-axis direction. Your linear regression model does capture the slight trend of increasing $y$ with increasing $x$, but it doesn't tell you anything about the variation along the $y$-axis when differences in $x$ are small, i.e. around the regression line. This is measured by residual sum of squares ($\text{RSS}$) you included. In other words, there is still a lot of "error", which hasn't been accounted for in this model. Since $R^2$ represents the ratio between the explained variance and total variance, it remains small. In your second set of data, most of the variation is explained by that same linear relationship between $x$ and $y$. Only a small part of the variance is left unexplained. This is reflected both in a smaller ratio $\frac{\text{RSS}}{\text{TSS}}$ as well as a smaller value of total sum of squares ($\text{TSS}$) as well. To conclude, the same model performs much better in the second case, because that set of data is much easier to explain (with this type of model). You also asked when, if ever, this would be a good statistical approach. It depends on what problem you are approaching with this. If you wanted to show that your model fits well to your data and only selected a subset of data for which it performs particularly well, that is an example of cherry picking, which is a deceitful practice when done intentionally. On the other hand, if you consider the variation in the direction of $y$-axis to be noise and you just want to give a succinct summary of your data, it might be acceptable to give it in some sort of average (like binning your data as you did). However, the regression line also serves the purpose of illustrating the upward trend well without manipulating the data itself. It also makes clear what is your data and what your model: the assumption of $y$ variance being noise (or error) is implicit here.
Hacking linear regression
You decreased the (total) variance in the data making it easier to explain. Thanks to the same $y$-axis limits, it can be easily seen that the data of your first example is much more spread in this di
Hacking linear regression You decreased the (total) variance in the data making it easier to explain. Thanks to the same $y$-axis limits, it can be easily seen that the data of your first example is much more spread in this direction than in the $x$-axis direction. Your linear regression model does capture the slight trend of increasing $y$ with increasing $x$, but it doesn't tell you anything about the variation along the $y$-axis when differences in $x$ are small, i.e. around the regression line. This is measured by residual sum of squares ($\text{RSS}$) you included. In other words, there is still a lot of "error", which hasn't been accounted for in this model. Since $R^2$ represents the ratio between the explained variance and total variance, it remains small. In your second set of data, most of the variation is explained by that same linear relationship between $x$ and $y$. Only a small part of the variance is left unexplained. This is reflected both in a smaller ratio $\frac{\text{RSS}}{\text{TSS}}$ as well as a smaller value of total sum of squares ($\text{TSS}$) as well. To conclude, the same model performs much better in the second case, because that set of data is much easier to explain (with this type of model). You also asked when, if ever, this would be a good statistical approach. It depends on what problem you are approaching with this. If you wanted to show that your model fits well to your data and only selected a subset of data for which it performs particularly well, that is an example of cherry picking, which is a deceitful practice when done intentionally. On the other hand, if you consider the variation in the direction of $y$-axis to be noise and you just want to give a succinct summary of your data, it might be acceptable to give it in some sort of average (like binning your data as you did). However, the regression line also serves the purpose of illustrating the upward trend well without manipulating the data itself. It also makes clear what is your data and what your model: the assumption of $y$ variance being noise (or error) is implicit here.
Hacking linear regression You decreased the (total) variance in the data making it easier to explain. Thanks to the same $y$-axis limits, it can be easily seen that the data of your first example is much more spread in this di
35,614
Hacking linear regression
The edited question asks: "When (if ever) is this a valid statistical approach?" I can't think of a good reason. One COULD argue that, by taking averages by binning, you've "de-noised" the data. However, that implicitly assumes that all of the observed variance is noise. That seems like a highly dubious assumption. By eye, your alt-model shows the same linear trend that the model on the raw data does. So you haven't gained any understandings there. But your 2nd model greatly overstates its explanatory power, and I can't envision a use case where that is ever a legit thing to do. Also ... binning/averaging the data like this before the modeling process essentially eliminates the possibility that you can find OTHER predictor variables that will improve your model. If the best model you can fit has an R-sq of 0.083 ... so be it. It happens. Some data series just inherently have a lot of unexplainable noise.
Hacking linear regression
The edited question asks: "When (if ever) is this a valid statistical approach?" I can't think of a good reason. One COULD argue that, by taking averages by binning, you've "de-noised" the data. Howev
Hacking linear regression The edited question asks: "When (if ever) is this a valid statistical approach?" I can't think of a good reason. One COULD argue that, by taking averages by binning, you've "de-noised" the data. However, that implicitly assumes that all of the observed variance is noise. That seems like a highly dubious assumption. By eye, your alt-model shows the same linear trend that the model on the raw data does. So you haven't gained any understandings there. But your 2nd model greatly overstates its explanatory power, and I can't envision a use case where that is ever a legit thing to do. Also ... binning/averaging the data like this before the modeling process essentially eliminates the possibility that you can find OTHER predictor variables that will improve your model. If the best model you can fit has an R-sq of 0.083 ... so be it. It happens. Some data series just inherently have a lot of unexplainable noise.
Hacking linear regression The edited question asks: "When (if ever) is this a valid statistical approach?" I can't think of a good reason. One COULD argue that, by taking averages by binning, you've "de-noised" the data. Howev
35,615
Clarification on the definition of "population"
It is true that populations are usually broad but they do not have to be. For example, according to Newbold, Carlson, & Thorne (2013) Statistics for business and economics, textbook: A population is the complete set of all items that interest an investigator. Population size, $N$, can be very large or even infinite. A sample is an observed subset (or portion) of a population with sample size given by $n$. The first sentence is the most important. What is population depends on what is of your interest. If a person's interest is to examine how their own children change their behavior when introduced to some reward, then the population would be the number of their own children even if the number of children might be small 1-2 for example. However, in statistics and econometrics more general we are most of the time interested in answering broad useful questions. In the above example it is not very interesting from scientific perspective to discover how some reward changes behavior of your own children, a scientist would most likely want to know how it changes behavior of all children. However, in your case since you are interested in broad terms how women and men perform on that particular show then your population actually would consist of all possible contestants and you can treat those 50 observations as a sample. Whether we can call this sample random (in sense of simple random sapling) depends on whether you can justify that in principle any member of a population had equal chance of being selected for the show.
Clarification on the definition of "population"
It is true that populations are usually broad but they do not have to be. For example, according to Newbold, Carlson, & Thorne (2013) Statistics for business and economics, textbook: A population is
Clarification on the definition of "population" It is true that populations are usually broad but they do not have to be. For example, according to Newbold, Carlson, & Thorne (2013) Statistics for business and economics, textbook: A population is the complete set of all items that interest an investigator. Population size, $N$, can be very large or even infinite. A sample is an observed subset (or portion) of a population with sample size given by $n$. The first sentence is the most important. What is population depends on what is of your interest. If a person's interest is to examine how their own children change their behavior when introduced to some reward, then the population would be the number of their own children even if the number of children might be small 1-2 for example. However, in statistics and econometrics more general we are most of the time interested in answering broad useful questions. In the above example it is not very interesting from scientific perspective to discover how some reward changes behavior of your own children, a scientist would most likely want to know how it changes behavior of all children. However, in your case since you are interested in broad terms how women and men perform on that particular show then your population actually would consist of all possible contestants and you can treat those 50 observations as a sample. Whether we can call this sample random (in sense of simple random sapling) depends on whether you can justify that in principle any member of a population had equal chance of being selected for the show.
Clarification on the definition of "population" It is true that populations are usually broad but they do not have to be. For example, according to Newbold, Carlson, & Thorne (2013) Statistics for business and economics, textbook: A population is
35,616
Clarification on the definition of "population"
The gist is that the instances of the game show are a sample of the results that conceivable could have happened. Think about flipping a coin and trying to figure out the probability of getting H or T. You’ve flipped 50 times and gotten 30 H and 20 T. It is inarguable that you got H on 60% of the flips. However, it is conceivable that the coin’s true probability of H, for the population, is 61% or 59%. This is why you might use inferential statistics even though you have observed every instance. You want to know about the data-generating process (DGP), not just the data that happened to be generated.
Clarification on the definition of "population"
The gist is that the instances of the game show are a sample of the results that conceivable could have happened. Think about flipping a coin and trying to figure out the probability of getting H or T
Clarification on the definition of "population" The gist is that the instances of the game show are a sample of the results that conceivable could have happened. Think about flipping a coin and trying to figure out the probability of getting H or T. You’ve flipped 50 times and gotten 30 H and 20 T. It is inarguable that you got H on 60% of the flips. However, it is conceivable that the coin’s true probability of H, for the population, is 61% or 59%. This is why you might use inferential statistics even though you have observed every instance. You want to know about the data-generating process (DGP), not just the data that happened to be generated.
Clarification on the definition of "population" The gist is that the instances of the game show are a sample of the results that conceivable could have happened. Think about flipping a coin and trying to figure out the probability of getting H or T
35,617
Clarification on the definition of "population"
Others have answered perfectly to the first question, I'll consider the part about random samples: No, your sample is not random. But don't worry, it's fine. Statisticians use non-random samples all the time! For instance, typically, when you do research about some disease progression, you decide a date and you pick every patient you have in one specific hospital, from that date on, until you get a sample as large as you want. That's the sample and it's not random at all! It doesn't consider patients from other time spans and from other hospitals, so what's the point on making inference on it? The point is to get an idea of what is the data generating process: you know that any patient could have had complications, so you want to discover what's the chances for each of them, what are the risk factors, etc... Your results stand true, in principle, just for people who get treated in that hospital in that period (not a useful population, is it?), but truth is, the usefulness of the study depends on the degree of belief you have that what's good for those patients is also good for other people who got sick around the world. Coming back to your case, if you believe that competitors in that show will keep behaving similarly, than you can trust on analysis carried on that data. On the other hand you can expect competitors to learn from the past and change their behaviour. It's really hard to tell, but in that case your analysis may be less reliable. That's also true for medical research, by the way. Patients around the world are not granted to react to illness and treatment the same way a sample from Swedland does.
Clarification on the definition of "population"
Others have answered perfectly to the first question, I'll consider the part about random samples: No, your sample is not random. But don't worry, it's fine. Statisticians use non-random samples all t
Clarification on the definition of "population" Others have answered perfectly to the first question, I'll consider the part about random samples: No, your sample is not random. But don't worry, it's fine. Statisticians use non-random samples all the time! For instance, typically, when you do research about some disease progression, you decide a date and you pick every patient you have in one specific hospital, from that date on, until you get a sample as large as you want. That's the sample and it's not random at all! It doesn't consider patients from other time spans and from other hospitals, so what's the point on making inference on it? The point is to get an idea of what is the data generating process: you know that any patient could have had complications, so you want to discover what's the chances for each of them, what are the risk factors, etc... Your results stand true, in principle, just for people who get treated in that hospital in that period (not a useful population, is it?), but truth is, the usefulness of the study depends on the degree of belief you have that what's good for those patients is also good for other people who got sick around the world. Coming back to your case, if you believe that competitors in that show will keep behaving similarly, than you can trust on analysis carried on that data. On the other hand you can expect competitors to learn from the past and change their behaviour. It's really hard to tell, but in that case your analysis may be less reliable. That's also true for medical research, by the way. Patients around the world are not granted to react to illness and treatment the same way a sample from Swedland does.
Clarification on the definition of "population" Others have answered perfectly to the first question, I'll consider the part about random samples: No, your sample is not random. But don't worry, it's fine. Statisticians use non-random samples all t
35,618
Historically, did pseudo RNGs have range [0,1] because of the ease of drawing from $f$ using $F^{-1}(p)$, or for some other reason?
In principle, any continuous distribution can serve as a starting point for a random number generator. Nevertheless, the standard continuous uniform distribution is a natural starting place for a pseudo-random number generator (PRNG) for a few main reasons: The method of inverse transformation sampling allows us to generate any random variable from a standard uniform random variable, and the latter is a natural starting place for this computation. In particular, the mathematics of transforming a standard uniform random variable to a random variable with another distribution is particularly simple and intuitive. The standard uniform distribution has particularly simple properties for the purposes of testing the accuracy of the PRNG method. These methods are subject to a battery of tests to ensure that they have desirable properties for a random number generator. These tests are particularly easy to frame for a PRNG that generates a standard continuous uniform random variable. For example, standard occupancy tests are particularly easy to deploy for uniform random variables. Computational methods that generate real numbers are subject to rounding error. In most platforms the numbers are stored in double-precision floating point format, and this format has a fixed level of accuracy in the fractional part. When generating a standard continuous uniform random variable the interval between values of the fractional part have fixed probability, so no intervals are larger or smaller than others. (Contra this reasoning, note that this is also arguably a reason to prefer an exponential random variable as the starting point for analysis, since the floating point format uses an exponent.)
Historically, did pseudo RNGs have range [0,1] because of the ease of drawing from $f$ using $F^{-1}
In principle, any continuous distribution can serve as a starting point for a random number generator. Nevertheless, the standard continuous uniform distribution is a natural starting place for a pse
Historically, did pseudo RNGs have range [0,1] because of the ease of drawing from $f$ using $F^{-1}(p)$, or for some other reason? In principle, any continuous distribution can serve as a starting point for a random number generator. Nevertheless, the standard continuous uniform distribution is a natural starting place for a pseudo-random number generator (PRNG) for a few main reasons: The method of inverse transformation sampling allows us to generate any random variable from a standard uniform random variable, and the latter is a natural starting place for this computation. In particular, the mathematics of transforming a standard uniform random variable to a random variable with another distribution is particularly simple and intuitive. The standard uniform distribution has particularly simple properties for the purposes of testing the accuracy of the PRNG method. These methods are subject to a battery of tests to ensure that they have desirable properties for a random number generator. These tests are particularly easy to frame for a PRNG that generates a standard continuous uniform random variable. For example, standard occupancy tests are particularly easy to deploy for uniform random variables. Computational methods that generate real numbers are subject to rounding error. In most platforms the numbers are stored in double-precision floating point format, and this format has a fixed level of accuracy in the fractional part. When generating a standard continuous uniform random variable the interval between values of the fractional part have fixed probability, so no intervals are larger or smaller than others. (Contra this reasoning, note that this is also arguably a reason to prefer an exponential random variable as the starting point for analysis, since the floating point format uses an exponent.)
Historically, did pseudo RNGs have range [0,1] because of the ease of drawing from $f$ using $F^{-1} In principle, any continuous distribution can serve as a starting point for a random number generator. Nevertheless, the standard continuous uniform distribution is a natural starting place for a pse
35,619
Historically, did pseudo RNGs have range [0,1] because of the ease of drawing from $f$ using $F^{-1}(p)$, or for some other reason?
Vetting a PRNG. First, the standard uniform distribution $\mathsf{Unif}(0,1)$ is mathematically simple. So given pseudorandom numbers that are purported to be indistiguishable, for practical purposes, from a random sample from a standard uniform population, it is easy to test whether the claim is true. For example, close to $1/10$th of the observations should lie in each of the intervals $(0.1k, 0.1k+.1),$ for $k = 0, \dots, 9,$ and we can do a chi-squared goodness of fit test to see if that is true. Today in R, the procedure runif(10^4) generates $10\,000$ observations supposedly from $\mathsf{Unif}(0,1).$ set.seed(510) u = runif(10^4) hist(u, br=seq(0,1,by=.1), ylim=c(0,1200), label=T) x = hist(u, br=seq(0,1,by=.1), plot=F)$counts; x [1] 959 960 1044 1048 966 1001 1044 1001 990 987 So we see that the $10\,000$ observations are consistent with a sample from $\mathsf{Unif}(0,1).$ [In chisq.test equal probabilities for groups are assumed if no other probabilities are supplied.] chisq.test(x) Chi-squared test for given probabilities data: x X-squared = 10.884, df = 9, p-value = 0.2837 Chi-squared test for given probabilities data: x X-squared = 10.884, df = 9, p-value = 0.2837 And so on, through many more tests to vet the random number generator as useful. Quantile method for continuous distributions. Second, as you say, it is possible to use the quantile (inverse CDF) transform to get samples from a vast variety of other distributions. So that the transform below should give us a pseudo-random sample from $\mathsf{Exp}(1).$ w = qexp(runif(10^5), 1) hist(w, prob=T, br=50, col="skyblue2") curve(dexp(x,1), add=T, col="red", n=10001) In the figure above, a standard uniform density curve seems a good fit to a density histogram of the data. Also, a Kolmogorov-Smirnov test does not reject the null hypothesis that the first 5000 values in w are a sample from a standard uniform distribution. [The test does not allow samples larger than 5000.] ks.test(w[1:5000], pexp, 1) One-sample Kolmogorov-Smirnov test data: w[1:5000] D = 0.0054447, p-value = 0.9984 alternative hypothesis: two-sided The test statistic $D$ of the K-S test is the maximum vertical discrepancy between the target CDF and the empirical CDF of the sample (a stairstep function of sample values that approximates the CDF). We illustrate with a sample of size 100. ks.test(w[1:100], pexp, 1) One-sample Kolmogorov-Smirnov test data: w[1:100] D = 0.076693, p-value = 0.5988 alternative hypothesis: two-sided plot(ecdf(w[1:100])) curve(pexp(x,1), add=T, col="red", lwd=2) Quantile method for discrete distributions. The quantile transform method also works for discrete random variables (provided that the quantile function is carefully programmed, as it is in R). So let's simulate a sample from $\mathsf{Binom}(10, .5):$ [The R procedure ks.test does not apply to discrete distriubtions.] v = qbinom(runif(5000), 10, .5) hist(v, prob=T, br = (-1:10)+.5, col="skyblue2") vv = 0:10; pdf = dbinom(vv, 10, .5) points(vv, pdf, col="red") Notes: (1) In R, the quantile method us used to generate normal random samples—even though the normal CDF cannot be expressed in closed form and thus cannot be inverted analytically. R uses Michael Wichura's (piecewise) rational approximation to the standard normal CDF, and his inversion of it. Results are accurate up to double-precision arithmetic. set.seed(2020); rnorm(1) [1] 0.3769721 set.seed(2020); qnorm(runif(1)) [1] 0.3769721 Earlier methods of simulating standard normal variates were (a) to use $\sum_{i=1}^2 U_i - 6,$ where $U_i \stackrel{iid}{\sim} \mathsf{Unif}(0,1),$ which relies on the quick convergence of the CLT for uniform random variables and requires only simple arithmetic operations, and (b) to use the Box-Muller transformation, which is somewhat more accurate and requires computing logarithmic and trigonometric functions. (2) Undoubtely, there are many other reasons: some of them lost history from the mid-1950s, and some possibly yet to come here in additional answers or comments.
Historically, did pseudo RNGs have range [0,1] because of the ease of drawing from $f$ using $F^{-1}
Vetting a PRNG. First, the standard uniform distribution $\mathsf{Unif}(0,1)$ is mathematically simple. So given pseudorandom numbers that are purported to be indistiguishable, for practical purposes,
Historically, did pseudo RNGs have range [0,1] because of the ease of drawing from $f$ using $F^{-1}(p)$, or for some other reason? Vetting a PRNG. First, the standard uniform distribution $\mathsf{Unif}(0,1)$ is mathematically simple. So given pseudorandom numbers that are purported to be indistiguishable, for practical purposes, from a random sample from a standard uniform population, it is easy to test whether the claim is true. For example, close to $1/10$th of the observations should lie in each of the intervals $(0.1k, 0.1k+.1),$ for $k = 0, \dots, 9,$ and we can do a chi-squared goodness of fit test to see if that is true. Today in R, the procedure runif(10^4) generates $10\,000$ observations supposedly from $\mathsf{Unif}(0,1).$ set.seed(510) u = runif(10^4) hist(u, br=seq(0,1,by=.1), ylim=c(0,1200), label=T) x = hist(u, br=seq(0,1,by=.1), plot=F)$counts; x [1] 959 960 1044 1048 966 1001 1044 1001 990 987 So we see that the $10\,000$ observations are consistent with a sample from $\mathsf{Unif}(0,1).$ [In chisq.test equal probabilities for groups are assumed if no other probabilities are supplied.] chisq.test(x) Chi-squared test for given probabilities data: x X-squared = 10.884, df = 9, p-value = 0.2837 Chi-squared test for given probabilities data: x X-squared = 10.884, df = 9, p-value = 0.2837 And so on, through many more tests to vet the random number generator as useful. Quantile method for continuous distributions. Second, as you say, it is possible to use the quantile (inverse CDF) transform to get samples from a vast variety of other distributions. So that the transform below should give us a pseudo-random sample from $\mathsf{Exp}(1).$ w = qexp(runif(10^5), 1) hist(w, prob=T, br=50, col="skyblue2") curve(dexp(x,1), add=T, col="red", n=10001) In the figure above, a standard uniform density curve seems a good fit to a density histogram of the data. Also, a Kolmogorov-Smirnov test does not reject the null hypothesis that the first 5000 values in w are a sample from a standard uniform distribution. [The test does not allow samples larger than 5000.] ks.test(w[1:5000], pexp, 1) One-sample Kolmogorov-Smirnov test data: w[1:5000] D = 0.0054447, p-value = 0.9984 alternative hypothesis: two-sided The test statistic $D$ of the K-S test is the maximum vertical discrepancy between the target CDF and the empirical CDF of the sample (a stairstep function of sample values that approximates the CDF). We illustrate with a sample of size 100. ks.test(w[1:100], pexp, 1) One-sample Kolmogorov-Smirnov test data: w[1:100] D = 0.076693, p-value = 0.5988 alternative hypothesis: two-sided plot(ecdf(w[1:100])) curve(pexp(x,1), add=T, col="red", lwd=2) Quantile method for discrete distributions. The quantile transform method also works for discrete random variables (provided that the quantile function is carefully programmed, as it is in R). So let's simulate a sample from $\mathsf{Binom}(10, .5):$ [The R procedure ks.test does not apply to discrete distriubtions.] v = qbinom(runif(5000), 10, .5) hist(v, prob=T, br = (-1:10)+.5, col="skyblue2") vv = 0:10; pdf = dbinom(vv, 10, .5) points(vv, pdf, col="red") Notes: (1) In R, the quantile method us used to generate normal random samples—even though the normal CDF cannot be expressed in closed form and thus cannot be inverted analytically. R uses Michael Wichura's (piecewise) rational approximation to the standard normal CDF, and his inversion of it. Results are accurate up to double-precision arithmetic. set.seed(2020); rnorm(1) [1] 0.3769721 set.seed(2020); qnorm(runif(1)) [1] 0.3769721 Earlier methods of simulating standard normal variates were (a) to use $\sum_{i=1}^2 U_i - 6,$ where $U_i \stackrel{iid}{\sim} \mathsf{Unif}(0,1),$ which relies on the quick convergence of the CLT for uniform random variables and requires only simple arithmetic operations, and (b) to use the Box-Muller transformation, which is somewhat more accurate and requires computing logarithmic and trigonometric functions. (2) Undoubtely, there are many other reasons: some of them lost history from the mid-1950s, and some possibly yet to come here in additional answers or comments.
Historically, did pseudo RNGs have range [0,1] because of the ease of drawing from $f$ using $F^{-1} Vetting a PRNG. First, the standard uniform distribution $\mathsf{Unif}(0,1)$ is mathematically simple. So given pseudorandom numbers that are purported to be indistiguishable, for practical purposes,
35,620
Why are there many lines in the graph of random forest?
Unfortunately, ?plot.randomForest is not helpful at all. However, it does tell us that plot.randomForest invisibly returns the data that is plotted (try (plot(rf)) with the brackets), which is a three column matrix with columns called OOB, M and R. The first is pretty obviously the overall out-of-bag error. The other two are equally obviously the out-of-bag errors for the two possible classes, which are M and R. As to which line corresponds to which column, we inspect the output matrix, specifically the last few lines: > tail(plot(rf)) OOB M R [495,] 0.22 0.09259259 0.3695652 [496,] 0.22 0.09259259 0.3695652 [497,] 0.22 0.09259259 0.3695652 [498,] 0.22 0.09259259 0.3695652 [499,] 0.22 0.09259259 0.3695652 [500,] 0.22 0.09259259 0.3695652 Thus, the bottom line is M, the middle one is OOB, the top one is R.
Why are there many lines in the graph of random forest?
Unfortunately, ?plot.randomForest is not helpful at all. However, it does tell us that plot.randomForest invisibly returns the data that is plotted (try (plot(rf)) with the brackets), which is a three
Why are there many lines in the graph of random forest? Unfortunately, ?plot.randomForest is not helpful at all. However, it does tell us that plot.randomForest invisibly returns the data that is plotted (try (plot(rf)) with the brackets), which is a three column matrix with columns called OOB, M and R. The first is pretty obviously the overall out-of-bag error. The other two are equally obviously the out-of-bag errors for the two possible classes, which are M and R. As to which line corresponds to which column, we inspect the output matrix, specifically the last few lines: > tail(plot(rf)) OOB M R [495,] 0.22 0.09259259 0.3695652 [496,] 0.22 0.09259259 0.3695652 [497,] 0.22 0.09259259 0.3695652 [498,] 0.22 0.09259259 0.3695652 [499,] 0.22 0.09259259 0.3695652 [500,] 0.22 0.09259259 0.3695652 Thus, the bottom line is M, the middle one is OOB, the top one is R.
Why are there many lines in the graph of random forest? Unfortunately, ?plot.randomForest is not helpful at all. However, it does tell us that plot.randomForest invisibly returns the data that is plotted (try (plot(rf)) with the brackets), which is a three
35,621
( 3 level ) random intercept at level 2 & random slope and random intercept at level 3
In this type of scenario it is useful to recall that (1 | A / B) is the same as (1 | A) + (1 | A:B) which also generalises to models with more levels. Thus, in the case mentioned in the question, where we want random slopes only on the higher level, we would have: (time | therapist) + (1 | therapist:subject) In the case of further hierarchy of nesting, with subject nested in therapist and therapist nested in clinic, where we wanted random slopes for the fixed effect time only at the middle level, we can specify this as: (1 | clinic) + (time | clinic:therapist) + (1 | clinic:therapist:subject)
( 3 level ) random intercept at level 2 & random slope and random intercept at level 3
In this type of scenario it is useful to recall that (1 | A / B) is the same as (1 | A) + (1 | A:B) which also generalises to models with more levels. Thus, in the case mentioned in the question,
( 3 level ) random intercept at level 2 & random slope and random intercept at level 3 In this type of scenario it is useful to recall that (1 | A / B) is the same as (1 | A) + (1 | A:B) which also generalises to models with more levels. Thus, in the case mentioned in the question, where we want random slopes only on the higher level, we would have: (time | therapist) + (1 | therapist:subject) In the case of further hierarchy of nesting, with subject nested in therapist and therapist nested in clinic, where we wanted random slopes for the fixed effect time only at the middle level, we can specify this as: (1 | clinic) + (time | clinic:therapist) + (1 | clinic:therapist:subject)
( 3 level ) random intercept at level 2 & random slope and random intercept at level 3 In this type of scenario it is useful to recall that (1 | A / B) is the same as (1 | A) + (1 | A:B) which also generalises to models with more levels. Thus, in the case mentioned in the question,
35,622
How to test for the best parameters for transformed independent variable in linear model
This is a standard least squares problem and, as such, is solved by finding parameters that minimize the sum of squared residuals. A general approach is first to fit the model $$E[Y] = \beta_0 + \beta_1 x_1 + \cdots + \beta_k x_k.$$ Replace the $y_i$ by their residuals $$e_i = y_i - (\hat\beta_0 + \hat\beta_1 x_1 + \cdots + \hat\beta_k x_k).$$ The nonlinear part of the model can be written as a function $$f(x_{k+1}, (A,B,\beta_{k+1})) = \beta_{k+1} \arctan\left(B(x_{k+1} - A)\right).$$ Now estimate how the residuals are related to $x_{k+1}$ by minimizing the expression $$f_{\text{obj}}(A, B, \beta_{k+1}) = f_{\text{obj}}(\mathbf{\theta}) = \frac{1}{n}\sum_{i=1}^n \left(e_i - f(x_{k+1}, \theta)\right)^2.\tag{*}$$ (To avoid potential problems with division by zero during the solution, I have replaced $B$ by $1/B$ in this formulation.) Rather than re-inventing an efficient, accurate, stable, test method to solve $(*),$ employ one that is available, such as the nlm function in R. Here is the R code to compute this fit, beginning with a data frame X containing variables x and y and an arbitrary universal starting value $\theta_0 = (0,1,0)$ for the search: f <- function(x, theta) theta[3] * atan(theta[2] * (x - theta[1])) obj <- function(theta, y, x) mean((residuals(lm(y ~ 1)) - f(x, theta))^2) fit <- with(X, nlm(obj, c(a=0, b=1, beta=0), y=y, x=x)) To demonstrate this, I simulated eight datasets like yours with $\theta=(200, 1/100, 50),$ $k=0,$ $\beta_0=550,$ and iid Normal errors of variance $\sigma^2=50^2$ (the code appears at the end of this post). Here they are along with the true model (gray line) and least-squares fits (red curve): The main lesson is that this model has a tendency to select large values of $B$ resulting in abrupt jumps in the fit. That's not a problem with the solution or even with the model; it's a manifestation of the limited amount of data and the relatively large value of $\sigma$ they exhibit. With, say, ten times as much data, here is what a typical fit would look like: It's good: the graph of the fit is scarcely distinguishable from the true model. The parameter estimate, however, is $\hat\theta = (198, 0.0012, 253),$ far from the true value $\theta = (200, 0.01, 50).$ This reveals a near lack of identifiability, making it difficult to pin down all three parameters. The problem is that you can achieve very nearly the same model by rescaling $B$ (to some extent) and applying a compensating change in $\beta_{k+1}.$ Geometrically, you are zooming into the graph of the arctangent function near $x=0$ which is nearly linear over large intervals surrounding that point, whence the change of scale changes nothing (to first order). One way to resolve this problem is to specify either $B$ or $\beta_{k+1}$ and fit the remaining parameters. I recommend specifying $B,$ for then you can use standard tools like ridge regression to regularize $\beta_{k+1},$ thereby avoiding the sharp jumps in the solution. (You can use regularization in any event, but it will be easier to apply it to a linear parameter like $\beta_{k+1}$ than to the nonlinear parameters $A$ and $B.$) You can obtain standard errors of estimate (and even a full covariance matrix) in the usual ways, because this approach yields the Maximum Likelihood estimates of all the coefficients. Here is the R code used for simulation and plotting the first figure. f <- function(x, theta) theta[3] * atan(theta[2] * (x - theta[1])) obj <- function(theta, y, x) mean((residuals(lm(y ~ 1)) - f(x, theta))^2) # # Create constant values for repeated simulations. # x <- c(seq(0, 10, length.out=39), seq(0, 700, length.out=92-39)) x. <- seq(min(X$x), max(X$x), length.out=101) theta <- c(A=200, `1/B`=1/100, beta=50) mu <- 550 # # Simulate. # set.seed(17) sim <- lapply(1:8, function(i) { X <- data.frame(Iteration=i, x = x, y = mu + f(x, theta) + rnorm(length(x), 0, 150)) fit <- with(X, nlm(obj, c(a=0, b=1, beta=0), y=y, x=x)) Y <- with(fit, data.frame(Iteration=i, x = x., y = mean(X$y) + f(x., estimate))) list(Data=X, Fit=Y) }) # # Combine all simulated data into a data frame `X` and all fitted data into `Y`. # X <- do.call(rbind, lapply(sim, `[[`, i=1)) Y <- do.call(rbind, lapply(sim, `[[`, i=2)) Z <- data.frame(x = x., y = mu + f(x., theta)) # # Plot everything. # library(ggplot2) ggplot(X, aes(x, y)) + geom_line(data=Z, size=1, color="Black", linetype=1) + geom_point(alpha=0.5, shape=21, fill="Gray") + geom_line(data=Y, size=1, color="#e01010") + xlab(expression(x[1])) + ylab(expression(y)) + facet_wrap(~ Iteration, nrow=2)
How to test for the best parameters for transformed independent variable in linear model
This is a standard least squares problem and, as such, is solved by finding parameters that minimize the sum of squared residuals. A general approach is first to fit the model $$E[Y] = \beta_0 + \beta
How to test for the best parameters for transformed independent variable in linear model This is a standard least squares problem and, as such, is solved by finding parameters that minimize the sum of squared residuals. A general approach is first to fit the model $$E[Y] = \beta_0 + \beta_1 x_1 + \cdots + \beta_k x_k.$$ Replace the $y_i$ by their residuals $$e_i = y_i - (\hat\beta_0 + \hat\beta_1 x_1 + \cdots + \hat\beta_k x_k).$$ The nonlinear part of the model can be written as a function $$f(x_{k+1}, (A,B,\beta_{k+1})) = \beta_{k+1} \arctan\left(B(x_{k+1} - A)\right).$$ Now estimate how the residuals are related to $x_{k+1}$ by minimizing the expression $$f_{\text{obj}}(A, B, \beta_{k+1}) = f_{\text{obj}}(\mathbf{\theta}) = \frac{1}{n}\sum_{i=1}^n \left(e_i - f(x_{k+1}, \theta)\right)^2.\tag{*}$$ (To avoid potential problems with division by zero during the solution, I have replaced $B$ by $1/B$ in this formulation.) Rather than re-inventing an efficient, accurate, stable, test method to solve $(*),$ employ one that is available, such as the nlm function in R. Here is the R code to compute this fit, beginning with a data frame X containing variables x and y and an arbitrary universal starting value $\theta_0 = (0,1,0)$ for the search: f <- function(x, theta) theta[3] * atan(theta[2] * (x - theta[1])) obj <- function(theta, y, x) mean((residuals(lm(y ~ 1)) - f(x, theta))^2) fit <- with(X, nlm(obj, c(a=0, b=1, beta=0), y=y, x=x)) To demonstrate this, I simulated eight datasets like yours with $\theta=(200, 1/100, 50),$ $k=0,$ $\beta_0=550,$ and iid Normal errors of variance $\sigma^2=50^2$ (the code appears at the end of this post). Here they are along with the true model (gray line) and least-squares fits (red curve): The main lesson is that this model has a tendency to select large values of $B$ resulting in abrupt jumps in the fit. That's not a problem with the solution or even with the model; it's a manifestation of the limited amount of data and the relatively large value of $\sigma$ they exhibit. With, say, ten times as much data, here is what a typical fit would look like: It's good: the graph of the fit is scarcely distinguishable from the true model. The parameter estimate, however, is $\hat\theta = (198, 0.0012, 253),$ far from the true value $\theta = (200, 0.01, 50).$ This reveals a near lack of identifiability, making it difficult to pin down all three parameters. The problem is that you can achieve very nearly the same model by rescaling $B$ (to some extent) and applying a compensating change in $\beta_{k+1}.$ Geometrically, you are zooming into the graph of the arctangent function near $x=0$ which is nearly linear over large intervals surrounding that point, whence the change of scale changes nothing (to first order). One way to resolve this problem is to specify either $B$ or $\beta_{k+1}$ and fit the remaining parameters. I recommend specifying $B,$ for then you can use standard tools like ridge regression to regularize $\beta_{k+1},$ thereby avoiding the sharp jumps in the solution. (You can use regularization in any event, but it will be easier to apply it to a linear parameter like $\beta_{k+1}$ than to the nonlinear parameters $A$ and $B.$) You can obtain standard errors of estimate (and even a full covariance matrix) in the usual ways, because this approach yields the Maximum Likelihood estimates of all the coefficients. Here is the R code used for simulation and plotting the first figure. f <- function(x, theta) theta[3] * atan(theta[2] * (x - theta[1])) obj <- function(theta, y, x) mean((residuals(lm(y ~ 1)) - f(x, theta))^2) # # Create constant values for repeated simulations. # x <- c(seq(0, 10, length.out=39), seq(0, 700, length.out=92-39)) x. <- seq(min(X$x), max(X$x), length.out=101) theta <- c(A=200, `1/B`=1/100, beta=50) mu <- 550 # # Simulate. # set.seed(17) sim <- lapply(1:8, function(i) { X <- data.frame(Iteration=i, x = x, y = mu + f(x, theta) + rnorm(length(x), 0, 150)) fit <- with(X, nlm(obj, c(a=0, b=1, beta=0), y=y, x=x)) Y <- with(fit, data.frame(Iteration=i, x = x., y = mean(X$y) + f(x., estimate))) list(Data=X, Fit=Y) }) # # Combine all simulated data into a data frame `X` and all fitted data into `Y`. # X <- do.call(rbind, lapply(sim, `[[`, i=1)) Y <- do.call(rbind, lapply(sim, `[[`, i=2)) Z <- data.frame(x = x., y = mu + f(x., theta)) # # Plot everything. # library(ggplot2) ggplot(X, aes(x, y)) + geom_line(data=Z, size=1, color="Black", linetype=1) + geom_point(alpha=0.5, shape=21, fill="Gray") + geom_line(data=Y, size=1, color="#e01010") + xlab(expression(x[1])) + ylab(expression(y)) + facet_wrap(~ Iteration, nrow=2)
How to test for the best parameters for transformed independent variable in linear model This is a standard least squares problem and, as such, is solved by finding parameters that minimize the sum of squared residuals. A general approach is first to fit the model $$E[Y] = \beta_0 + \beta
35,623
How to test for the best parameters for transformed independent variable in linear model
Thanks for the data. Although this is just your graph with a smoother added, I suggest that -- beyond eyeballing the data -- the graph isn't supportive of any idea that there is an underlying sigmoid. There is nothing magic about the bandwidth used, and I tried lower and higher values with the same conclusion. Naturally I can't exclude the possibility that a pattern would emerge if the other predictors were taken into consideration, but on that front the only suggestions that I can make, as in comments, are nonlinear least squares using $Xb$ for the other predictors and then looking at the residuals from that. I have to be puzzled at the idea that $Xb$ should be fine for 13 predictors, and this one is different. In my field with any bundle of 13 predictors I would expect that some would need transformation and I might need to think about interaction terms too. I don't know what these data are, or what literature you're drawing on, but quite often something a little exotic -- here the use of an arctangent -- somehow acquires the status of what people use without a very strong rationale. To me an arctangent is tied up with the idea that the response is bounded in principle, which isn't obviously the case here. I have a prejudice against functions with more than about 3 parameters any way: not only are they often freakishly hard to fit, they are suspect without an independent rationale. 1 intercept, 13 vanilla coefficients and 4 extra (or even 2) coefficients are in total 18 (or 16) parameters; many would find 92 uncomfortably few data points for that exercise. This is not very constructive, or even at all, but I tried. I also appreciate that you would rather discussion didn't focus on these data alone, but with no other information on the other variables, only broad comments seem possible.
How to test for the best parameters for transformed independent variable in linear model
Thanks for the data. Although this is just your graph with a smoother added, I suggest that -- beyond eyeballing the data -- the graph isn't supportive of any idea that there is an underlying sigmoid.
How to test for the best parameters for transformed independent variable in linear model Thanks for the data. Although this is just your graph with a smoother added, I suggest that -- beyond eyeballing the data -- the graph isn't supportive of any idea that there is an underlying sigmoid. There is nothing magic about the bandwidth used, and I tried lower and higher values with the same conclusion. Naturally I can't exclude the possibility that a pattern would emerge if the other predictors were taken into consideration, but on that front the only suggestions that I can make, as in comments, are nonlinear least squares using $Xb$ for the other predictors and then looking at the residuals from that. I have to be puzzled at the idea that $Xb$ should be fine for 13 predictors, and this one is different. In my field with any bundle of 13 predictors I would expect that some would need transformation and I might need to think about interaction terms too. I don't know what these data are, or what literature you're drawing on, but quite often something a little exotic -- here the use of an arctangent -- somehow acquires the status of what people use without a very strong rationale. To me an arctangent is tied up with the idea that the response is bounded in principle, which isn't obviously the case here. I have a prejudice against functions with more than about 3 parameters any way: not only are they often freakishly hard to fit, they are suspect without an independent rationale. 1 intercept, 13 vanilla coefficients and 4 extra (or even 2) coefficients are in total 18 (or 16) parameters; many would find 92 uncomfortably few data points for that exercise. This is not very constructive, or even at all, but I tried. I also appreciate that you would rather discussion didn't focus on these data alone, but with no other information on the other variables, only broad comments seem possible.
How to test for the best parameters for transformed independent variable in linear model Thanks for the data. Although this is just your graph with a smoother added, I suggest that -- beyond eyeballing the data -- the graph isn't supportive of any idea that there is an underlying sigmoid.
35,624
How to test for the best parameters for transformed independent variable in linear model
A possible mistake that you're doing is not displaying the effect of $x_{k+1}$ after the effect of all other $x_i$. For this, rather than directly plotting $y$ against $x_{k+1}$ you should Partial Regression Plots (aka added variable plots; Wiki, or here). The three steps are (from Wiki): Computing the residuals of regressing the response variable against the independent variables but omitting $X_{k+1}$ Computing the residuals from regressing $X_{k+1} against the remaining independent variables Plotting the residuals from (1) against the residuals from (2). Maybe plotting the parameters found by your gridsearch in a added variable plot will help you understand the found parameters.
How to test for the best parameters for transformed independent variable in linear model
A possible mistake that you're doing is not displaying the effect of $x_{k+1}$ after the effect of all other $x_i$. For this, rather than directly plotting $y$ against $x_{k+1}$ you should Partial Reg
How to test for the best parameters for transformed independent variable in linear model A possible mistake that you're doing is not displaying the effect of $x_{k+1}$ after the effect of all other $x_i$. For this, rather than directly plotting $y$ against $x_{k+1}$ you should Partial Regression Plots (aka added variable plots; Wiki, or here). The three steps are (from Wiki): Computing the residuals of regressing the response variable against the independent variables but omitting $X_{k+1}$ Computing the residuals from regressing $X_{k+1} against the remaining independent variables Plotting the residuals from (1) against the residuals from (2). Maybe plotting the parameters found by your gridsearch in a added variable plot will help you understand the found parameters.
How to test for the best parameters for transformed independent variable in linear model A possible mistake that you're doing is not displaying the effect of $x_{k+1}$ after the effect of all other $x_i$. For this, rather than directly plotting $y$ against $x_{k+1}$ you should Partial Reg
35,625
Is this a valid argument why null hypothesis should always be equality?
No, that isn't valid. For instance, suppose you are interested in the relative heights of adult men and women in different parts of the world. You could find the usual difference across a broad population (say it's 9 cm, just for a guess). Then you look at (say) a tribe in New Guinea. Your null could be "Men in New Guinea are 9 cm taller than women". The reason many introductory books say that the null is equality is that a) It usually is and b) That's simpler and statistics is hard enough.
Is this a valid argument why null hypothesis should always be equality?
No, that isn't valid. For instance, suppose you are interested in the relative heights of adult men and women in different parts of the world. You could find the usual difference across a broad popula
Is this a valid argument why null hypothesis should always be equality? No, that isn't valid. For instance, suppose you are interested in the relative heights of adult men and women in different parts of the world. You could find the usual difference across a broad population (say it's 9 cm, just for a guess). Then you look at (say) a tribe in New Guinea. Your null could be "Men in New Guinea are 9 cm taller than women". The reason many introductory books say that the null is equality is that a) It usually is and b) That's simpler and statistics is hard enough.
Is this a valid argument why null hypothesis should always be equality? No, that isn't valid. For instance, suppose you are interested in the relative heights of adult men and women in different parts of the world. You could find the usual difference across a broad popula
35,626
The difference of Standard Error between glm(y~x, family=poisson(link=identity)) and optim() in R
In statistical likelihood theory, minus the second derivative of the log-likelihood function is called the observed information. We might write this as $$ I = -\ddot \ell(y; \theta) $$ where the dots indicate differentiation with respect to $\theta$. The expected value of the observed information $$ {\cal I} = E(I) $$ is called Fisher information or expected information. Observed and expected information are asymptotically equivalent (by the law of large numbers) under the same regularity conditions that guarantee that the maximum likelihood estimators are consistent. This implies that the observed and expected information will usually be close, in relative as well as absolute terms, when the standard errors are small. In glm theory, Fisher information is preferred over observed information because it (1) has a much simpler analytic form, (2) is guaranteed to be positive definite (which observed information is not) and (3) is the same as the Cramer-Rao Lower Bound for the variance of unbiased estimators. If the glm model has a canonical link, then the distinction is less important because observed and expected information are in that case identical when computed at the maximum likelihood estimator of $\theta$. If you use optim to maximize the log-likelihood of a glm model, then the maximum likelihood estimates returned by glm and optim will be the same apart from rounding errors if both algorithms are run to convergence. The standard errors from glm however will generally differ from those from optim because glm returns Fisher information whereas optim computes observed information and glm uses an exact analytic formula for Fisher information whereas optim approximates the Hessian numerically from second differences of the log-likelihood. Had you had used a log-link instead of identity link for your example, then item 1 would no longer cause any difference because the log-link is canonical and observed and expected information would then become identical at convergence. Note on terminology Some authors use "observed Fisher information" as a synonym for "observed information" and "expected Fisher information" as a synonym for "Fisher information". I think this terminology probably originates from Efron & Hinkley (1978): B. Efron and D.V. Hinkley (1978). Assessing the accuracy of the maximum likelihood estimator: Observed versus expected Fisher information. Biometrika 65(3), 457–483.
The difference of Standard Error between glm(y~x, family=poisson(link=identity)) and optim() in R
In statistical likelihood theory, minus the second derivative of the log-likelihood function is called the observed information. We might write this as $$ I = -\ddot \ell(y; \theta) $$ where the dots
The difference of Standard Error between glm(y~x, family=poisson(link=identity)) and optim() in R In statistical likelihood theory, minus the second derivative of the log-likelihood function is called the observed information. We might write this as $$ I = -\ddot \ell(y; \theta) $$ where the dots indicate differentiation with respect to $\theta$. The expected value of the observed information $$ {\cal I} = E(I) $$ is called Fisher information or expected information. Observed and expected information are asymptotically equivalent (by the law of large numbers) under the same regularity conditions that guarantee that the maximum likelihood estimators are consistent. This implies that the observed and expected information will usually be close, in relative as well as absolute terms, when the standard errors are small. In glm theory, Fisher information is preferred over observed information because it (1) has a much simpler analytic form, (2) is guaranteed to be positive definite (which observed information is not) and (3) is the same as the Cramer-Rao Lower Bound for the variance of unbiased estimators. If the glm model has a canonical link, then the distinction is less important because observed and expected information are in that case identical when computed at the maximum likelihood estimator of $\theta$. If you use optim to maximize the log-likelihood of a glm model, then the maximum likelihood estimates returned by glm and optim will be the same apart from rounding errors if both algorithms are run to convergence. The standard errors from glm however will generally differ from those from optim because glm returns Fisher information whereas optim computes observed information and glm uses an exact analytic formula for Fisher information whereas optim approximates the Hessian numerically from second differences of the log-likelihood. Had you had used a log-link instead of identity link for your example, then item 1 would no longer cause any difference because the log-link is canonical and observed and expected information would then become identical at convergence. Note on terminology Some authors use "observed Fisher information" as a synonym for "observed information" and "expected Fisher information" as a synonym for "Fisher information". I think this terminology probably originates from Efron & Hinkley (1978): B. Efron and D.V. Hinkley (1978). Assessing the accuracy of the maximum likelihood estimator: Observed versus expected Fisher information. Biometrika 65(3), 457–483.
The difference of Standard Error between glm(y~x, family=poisson(link=identity)) and optim() in R In statistical likelihood theory, minus the second derivative of the log-likelihood function is called the observed information. We might write this as $$ I = -\ddot \ell(y; \theta) $$ where the dots
35,627
Omitted Variables and their consequences for other variables
Intuitively, the answer is that $\hat{\beta}_2$ will be biased whenever $x_2$ is correlated with $x_1$. This is because the correlation of $x_2$ with $x_1$ causes $\hat{\beta}_2$ to be correlated with $\hat{\beta}_1$; as a consequence, when $\hat{\beta}_1$ differs from $\beta_1$, $\hat{\beta}_2$ will differ from $\beta_2$ in expectation, and, writing loosely, since we expect $\hat{\beta}_1$ to be biased, $\hat{\beta}_2$ will be too. I'll assume away the intercept term for simplicity of exposition, without loss of generality. Writing out the expression for $\mathbb{E}\hat{\beta}$ gives us: $$\mathbb{E}\hat{\beta} = \mathbb{E}(X^TX)^{-1}X^TY = \mathbb{E}(X^TX)^{-1}X^T(X\beta + e) = \beta + \mathbb{E}(X^TX)^{-1}X^Te$$ Under the assumptions of the question, $\mathbb{E}X^Te$ can be written as $(\theta,0)$, where $\theta$ is a function of the nonzero covariance between $x_1$ and $e$. Substituting gives us: $$ \mathbb{E}\hat{\beta} - \beta = [(X^TX)^{-1}_{1,1}\theta, (X^TX)^{-1}_{2,1}\theta]$$ The subscripts designate which element of the $2 \times 2$ matrix $(X^TX)^{-1}$ is being referred to. Since $(X^TX)^{-1}_{1,1} > 0$ unless $x_1$ is identically equal to $0$, we can see that $\hat{\beta}_1$ will be biased; however, $\hat{\beta}_2$ will be biased if and only if $(X^TX)^{-1}_{2,1} \ne 0$, i.e., if $x_1$ and $x_2$ are correlated. Here's a simple example in R, where the true values of $\beta_1$ and $\beta_2$ are both equal to $1$: bhat_1 <- rep(0, 10000) V <- matrix(c(1,0.6,0.6,1), 2, 2) for (i in 1:length(bhat_1)) { x <- rmvn(100, c(0,0), V) y <- x[,1] + x[,2] + rnorm(100) bhat_1[i] <- coef(lm(y~x[,1]))[2] } hist(bhat_1) that produces the following histogram:
Omitted Variables and their consequences for other variables
Intuitively, the answer is that $\hat{\beta}_2$ will be biased whenever $x_2$ is correlated with $x_1$. This is because the correlation of $x_2$ with $x_1$ causes $\hat{\beta}_2$ to be correlated wit
Omitted Variables and their consequences for other variables Intuitively, the answer is that $\hat{\beta}_2$ will be biased whenever $x_2$ is correlated with $x_1$. This is because the correlation of $x_2$ with $x_1$ causes $\hat{\beta}_2$ to be correlated with $\hat{\beta}_1$; as a consequence, when $\hat{\beta}_1$ differs from $\beta_1$, $\hat{\beta}_2$ will differ from $\beta_2$ in expectation, and, writing loosely, since we expect $\hat{\beta}_1$ to be biased, $\hat{\beta}_2$ will be too. I'll assume away the intercept term for simplicity of exposition, without loss of generality. Writing out the expression for $\mathbb{E}\hat{\beta}$ gives us: $$\mathbb{E}\hat{\beta} = \mathbb{E}(X^TX)^{-1}X^TY = \mathbb{E}(X^TX)^{-1}X^T(X\beta + e) = \beta + \mathbb{E}(X^TX)^{-1}X^Te$$ Under the assumptions of the question, $\mathbb{E}X^Te$ can be written as $(\theta,0)$, where $\theta$ is a function of the nonzero covariance between $x_1$ and $e$. Substituting gives us: $$ \mathbb{E}\hat{\beta} - \beta = [(X^TX)^{-1}_{1,1}\theta, (X^TX)^{-1}_{2,1}\theta]$$ The subscripts designate which element of the $2 \times 2$ matrix $(X^TX)^{-1}$ is being referred to. Since $(X^TX)^{-1}_{1,1} > 0$ unless $x_1$ is identically equal to $0$, we can see that $\hat{\beta}_1$ will be biased; however, $\hat{\beta}_2$ will be biased if and only if $(X^TX)^{-1}_{2,1} \ne 0$, i.e., if $x_1$ and $x_2$ are correlated. Here's a simple example in R, where the true values of $\beta_1$ and $\beta_2$ are both equal to $1$: bhat_1 <- rep(0, 10000) V <- matrix(c(1,0.6,0.6,1), 2, 2) for (i in 1:length(bhat_1)) { x <- rmvn(100, c(0,0), V) y <- x[,1] + x[,2] + rnorm(100) bhat_1[i] <- coef(lm(y~x[,1]))[2] } hist(bhat_1) that produces the following histogram:
Omitted Variables and their consequences for other variables Intuitively, the answer is that $\hat{\beta}_2$ will be biased whenever $x_2$ is correlated with $x_1$. This is because the correlation of $x_2$ with $x_1$ causes $\hat{\beta}_2$ to be correlated wit
35,628
Omitted Variables and their consequences for other variables
Here's what happens for any number of predictors and omitted variables. The answer ends up similar to what @jbowman (+1) showed for two predictors (one correlated with omitted variables and one not). Since I'd already started writing this, I'll post it in case it's useful to see another approach. To summarize the answer below: Suppose $X_u$ contains predictors that are uncorrelated with all omitted variables and $X_c$ contains predictors that are correlated with at least one omitted variable. Then, under standard assumptions, OLS coefficients for predictors in $X_u$ are unbiased if and only if $X_u$ and $X_c$ are uncorrelated. Setup Let $y \in \mathbb{R}^n$ be a vector of responses and $X \in \mathbb{R}^{n \times p}$ be a matrix of predictors. We also have predictors $Z \in \mathbb{R}^{n \times q}$ that will be omitted. Assume the predictors and responses have been centered, so there's no need for an intercept term. I'll also assume that predictors may be correlated but not perfectly collinear (this implies that $X$ and $Z$ have full rank, and $n \ge p+q$). Suppose true model is: $$y = X w + Z v + \epsilon \quad \quad \epsilon \sim \mathcal{N}(\vec{0}, \sigma^2 I)$$ where $w \in \mathbb{R}^p$ and $v \in \mathbb{R}^q$ are the true coefficients, and $\epsilon$ is a random vector representing i.i.d. Gaussian noise with mean zero and variance $\sigma^2$. Say we fit an ordinary least squares regression model, omitting $Z$. The estimated coefficients are: $$\hat{w} = (X^T X)^{-1} X^T y$$ The bias is a vector containing the expected difference between the estimated and true coefficients (see derivation below): $$\text{bias} = E[\hat{w} - w] = (X^T X)^{-1} X^T Z v$$ Multiplying both sides by $X^T X$ gives: $$X^T X \ \text{bias} = X^T Z v$$ For predictors uncorrelated with the omitted variables Suppose the predictors are partitioned as $X = [X_u, X_c]$, where $X_u$ contains columns uncorrelated with all omitted variables and $X_c$ contains columns correlated with at least one omitted variable. So, $X_u^T Z = \mathbf{0}$ and $X_c^T Z \ne \mathbf{0}$. Similarly, suppose the bias is partitioned into subvectors $\text{bias}_u$ (for predictors in $X_u$) and $\text{bias}_c$ (for predictors in $X_c$). Rewrite the preceding equation in the partitioned form: $$\begin{bmatrix} X_u^T X_u & X_u^T X_c \\ X_c^T X_u & X_c^T X_c \end{bmatrix} \begin{bmatrix} \text{bias}_u \\ \text{bias}_c \end{bmatrix} = \begin{bmatrix} \mathbf{0} \\ X_c^T Z \end{bmatrix} v$$ Break this into two systems: $$X_u^T X_u \text{bias}_u + X_u^T X_c \text{bias}_c = \vec{0}$$ $$X_c^T X_u \text{bias}_u + X_c^T X_c \text{bias}_c = X_c^T Z v$$ $\text{bias}_c$ is nonzero, since assuming it's zero leads to a contradiction, given our assumptions. This recapitulates the standard statement about omitted variable bias. More interestingly, the question concerns $\text{bias}_u$, the bias of predictors that are uncorrelated with the omitted variables. The first equation in the above pair leads to two conclusions: 1) If $X_u$ and $X_c$ are uncorrelated so $X_u^T X_c = \mathbf{0}$, then the only solution is $\text{bias}_u = \vec{0}$. Recall that $X$ has full rank so $X_u$ does too, and the null space of $X_u^T X_u$ includes only the zero vector. 2) Since $\text{bias}_c$ is nonzero, $\text{bias}_u = \vec{0}$ would imply that $X_u^T X_c = \mathbf{0}$. Therefore, coefficients for predictors in $X_u$ have zero bias if and only if $X_u$ and $X_c$ are uncorrelated: $$\text{bias}_u = \vec{0} \ \iff \ X_u^T X_c = \mathbf{0}$$ Derivation of the bias The bias is the expected difference between the estimated and true coefficients, where the expectation is taken w.r.t. $\epsilon$: $$\begin{array}{ccl} \text{bias} & = & E[\hat{w} - w] \\ & = & E\big[ (X^T X)^{-1} X^T y - w \big] \\ & = & E\big[ (X^T X)^{-1} X^T X w + (X^T X)^{-1} X^T Z v + (X^T X)^{-1} X^T \epsilon - w \big] \\ & = & E\big[ (X^T X)^{-1} X^T Z v + (X^T X)^{-1} X^T \epsilon \big] \\ & = & (X^T X)^{-1} X^T Z v + E\big[ (X^T X)^{-1} X^T \epsilon \big] \\ & = & (X^T X)^{-1} X^T Z v \\ \end{array}$$ Line 2 substitutes in the expression for $\hat{w}$. Line 3 substitutes the true model in for $y$. Line 4 is an algebraic simplification. Line 5 uses linearity of expectation. Since noise has zero mean and is uncorrelated with the predictors, the expectation in the last term is zero, giving line 6.
Omitted Variables and their consequences for other variables
Here's what happens for any number of predictors and omitted variables. The answer ends up similar to what @jbowman (+1) showed for two predictors (one correlated with omitted variables and one not).
Omitted Variables and their consequences for other variables Here's what happens for any number of predictors and omitted variables. The answer ends up similar to what @jbowman (+1) showed for two predictors (one correlated with omitted variables and one not). Since I'd already started writing this, I'll post it in case it's useful to see another approach. To summarize the answer below: Suppose $X_u$ contains predictors that are uncorrelated with all omitted variables and $X_c$ contains predictors that are correlated with at least one omitted variable. Then, under standard assumptions, OLS coefficients for predictors in $X_u$ are unbiased if and only if $X_u$ and $X_c$ are uncorrelated. Setup Let $y \in \mathbb{R}^n$ be a vector of responses and $X \in \mathbb{R}^{n \times p}$ be a matrix of predictors. We also have predictors $Z \in \mathbb{R}^{n \times q}$ that will be omitted. Assume the predictors and responses have been centered, so there's no need for an intercept term. I'll also assume that predictors may be correlated but not perfectly collinear (this implies that $X$ and $Z$ have full rank, and $n \ge p+q$). Suppose true model is: $$y = X w + Z v + \epsilon \quad \quad \epsilon \sim \mathcal{N}(\vec{0}, \sigma^2 I)$$ where $w \in \mathbb{R}^p$ and $v \in \mathbb{R}^q$ are the true coefficients, and $\epsilon$ is a random vector representing i.i.d. Gaussian noise with mean zero and variance $\sigma^2$. Say we fit an ordinary least squares regression model, omitting $Z$. The estimated coefficients are: $$\hat{w} = (X^T X)^{-1} X^T y$$ The bias is a vector containing the expected difference between the estimated and true coefficients (see derivation below): $$\text{bias} = E[\hat{w} - w] = (X^T X)^{-1} X^T Z v$$ Multiplying both sides by $X^T X$ gives: $$X^T X \ \text{bias} = X^T Z v$$ For predictors uncorrelated with the omitted variables Suppose the predictors are partitioned as $X = [X_u, X_c]$, where $X_u$ contains columns uncorrelated with all omitted variables and $X_c$ contains columns correlated with at least one omitted variable. So, $X_u^T Z = \mathbf{0}$ and $X_c^T Z \ne \mathbf{0}$. Similarly, suppose the bias is partitioned into subvectors $\text{bias}_u$ (for predictors in $X_u$) and $\text{bias}_c$ (for predictors in $X_c$). Rewrite the preceding equation in the partitioned form: $$\begin{bmatrix} X_u^T X_u & X_u^T X_c \\ X_c^T X_u & X_c^T X_c \end{bmatrix} \begin{bmatrix} \text{bias}_u \\ \text{bias}_c \end{bmatrix} = \begin{bmatrix} \mathbf{0} \\ X_c^T Z \end{bmatrix} v$$ Break this into two systems: $$X_u^T X_u \text{bias}_u + X_u^T X_c \text{bias}_c = \vec{0}$$ $$X_c^T X_u \text{bias}_u + X_c^T X_c \text{bias}_c = X_c^T Z v$$ $\text{bias}_c$ is nonzero, since assuming it's zero leads to a contradiction, given our assumptions. This recapitulates the standard statement about omitted variable bias. More interestingly, the question concerns $\text{bias}_u$, the bias of predictors that are uncorrelated with the omitted variables. The first equation in the above pair leads to two conclusions: 1) If $X_u$ and $X_c$ are uncorrelated so $X_u^T X_c = \mathbf{0}$, then the only solution is $\text{bias}_u = \vec{0}$. Recall that $X$ has full rank so $X_u$ does too, and the null space of $X_u^T X_u$ includes only the zero vector. 2) Since $\text{bias}_c$ is nonzero, $\text{bias}_u = \vec{0}$ would imply that $X_u^T X_c = \mathbf{0}$. Therefore, coefficients for predictors in $X_u$ have zero bias if and only if $X_u$ and $X_c$ are uncorrelated: $$\text{bias}_u = \vec{0} \ \iff \ X_u^T X_c = \mathbf{0}$$ Derivation of the bias The bias is the expected difference between the estimated and true coefficients, where the expectation is taken w.r.t. $\epsilon$: $$\begin{array}{ccl} \text{bias} & = & E[\hat{w} - w] \\ & = & E\big[ (X^T X)^{-1} X^T y - w \big] \\ & = & E\big[ (X^T X)^{-1} X^T X w + (X^T X)^{-1} X^T Z v + (X^T X)^{-1} X^T \epsilon - w \big] \\ & = & E\big[ (X^T X)^{-1} X^T Z v + (X^T X)^{-1} X^T \epsilon \big] \\ & = & (X^T X)^{-1} X^T Z v + E\big[ (X^T X)^{-1} X^T \epsilon \big] \\ & = & (X^T X)^{-1} X^T Z v \\ \end{array}$$ Line 2 substitutes in the expression for $\hat{w}$. Line 3 substitutes the true model in for $y$. Line 4 is an algebraic simplification. Line 5 uses linearity of expectation. Since noise has zero mean and is uncorrelated with the predictors, the expectation in the last term is zero, giving line 6.
Omitted Variables and their consequences for other variables Here's what happens for any number of predictors and omitted variables. The answer ends up similar to what @jbowman (+1) showed for two predictors (one correlated with omitted variables and one not).
35,629
VIF for Categorical Variable with More Than 2 Categories
The "generalized variance inflation factors" (GVIF) implemented in the vif() function of the R car package were designed by Fox and Monette specifically to handle situations like this, where there are groups of predictor variables that should be considered together rather than separately. Such situations include multi-level categorical variables and polynomial terms in a single variable. The standard VIF calculation described on the Wikipedia page (and evidently as implemented in the Python variance_inflation_factor() function) treats each predictor separately. A $k$-level categorical variable then counts as $k-1$ predictors, and the result of that type of VIF calculation will depend on how that variable is coded, specifically which category is considered the reference level. Allison alluded to that in the post you linked, recommending use of the most frequent category as the reference when performing that type of VIF calculation. The GVIF approach provides a combined measure of collinearity for each group of predictors that should be considered together, like each of your multi-level categorical variables. It does this in a way that is independent of the details of how those predictors are coded. The GVIF^(1/(2*Df)) calculation then provides comparability among predictor sets having different dimensions. So in your case the GVIF approach is most applicable, and there seems to be no substantial evidence of multicollinearity.
VIF for Categorical Variable with More Than 2 Categories
The "generalized variance inflation factors" (GVIF) implemented in the vif() function of the R car package were designed by Fox and Monette specifically to handle situations like this, where there are
VIF for Categorical Variable with More Than 2 Categories The "generalized variance inflation factors" (GVIF) implemented in the vif() function of the R car package were designed by Fox and Monette specifically to handle situations like this, where there are groups of predictor variables that should be considered together rather than separately. Such situations include multi-level categorical variables and polynomial terms in a single variable. The standard VIF calculation described on the Wikipedia page (and evidently as implemented in the Python variance_inflation_factor() function) treats each predictor separately. A $k$-level categorical variable then counts as $k-1$ predictors, and the result of that type of VIF calculation will depend on how that variable is coded, specifically which category is considered the reference level. Allison alluded to that in the post you linked, recommending use of the most frequent category as the reference when performing that type of VIF calculation. The GVIF approach provides a combined measure of collinearity for each group of predictors that should be considered together, like each of your multi-level categorical variables. It does this in a way that is independent of the details of how those predictors are coded. The GVIF^(1/(2*Df)) calculation then provides comparability among predictor sets having different dimensions. So in your case the GVIF approach is most applicable, and there seems to be no substantial evidence of multicollinearity.
VIF for Categorical Variable with More Than 2 Categories The "generalized variance inflation factors" (GVIF) implemented in the vif() function of the R car package were designed by Fox and Monette specifically to handle situations like this, where there are
35,630
Why do we not always use the closed testing principle for multiple comparisons?
It is actually used quite often (in fact, Bonferroni and Bonferroni-Holm can be shown to be valid tests using the closed testing principle - see below). Part of the reason why some simple procedures like Bonferroni are still so popular is of course, that they are very easy to implement and it is easy to communicate what you did. E.g. even for the simple Bonferroni or Bonferroni-Holm writing down the tests for the intersection null hypotheses is a bit tedious. That's why the graphical approach to constructing closed testing procedures is very popular - at least in the clinical trials setting (where there is usually a trained statistician at hand that can help pre-specify a tailored testing procedure for a specific trial). This graphical approach provides a really easy way to construct valid testing procedures and makes communication easier. Various variants, extensions and improvements such as exploiting correlations, prioritization of certain hypotheses depending on which hypotheses are already rejected etc. have been proposed over the years. Bonferroni vs. Bonferroni-Holm as closed testing procedures example The Bonferroni test can be easily written down in terms of the closed testing principle, e.g. in the case of two null hypotheses as Test for $H_1 \cap H_2$: $p_1 \leq \alpha/2$ and $p_2 \leq \alpha/2$ Test for elementary null hypothesis $H_1$: $p_1 \leq \alpha/2$ Test for elementary null hypothesis $H_2$: $p_2 \leq \alpha/2$ with $H_1$ rejected overall, if both $H_1$ and $H_1 \cap H_2$ are rejected. Thus, we know it is a valid test. You also immediately see that for the elementary null hypotheses $H_1$ and $H_2$ you are using a test that is not exhausting the significance level and that the Bonferroni-Holm test Test for $H_1$ and $H_2$: $p_1 \leq \alpha/2$ and $p_2 \leq \alpha/2$ Test for $H_1$: $p_1 \leq \alpha$ Test for $H_2$: $p_2 \leq \alpha$ is uniformly more powerful. Figure 1: Illustration of the graphical approach for displaying these two procedures Power considerations and other considerations Usually, there's no downside in terms of power to using a closed testing procedure - if anything it tends to be easier to make sure the test fully exhausts the significance level. It can sometimes be a bit tricky to build in some desired features (e.g. exploiting a known correlation) while keep some other desired contraints (e.g. that the closed testing procedure can be easily displayed graphically due to the consistency requirement on the testing procedure).
Why do we not always use the closed testing principle for multiple comparisons?
It is actually used quite often (in fact, Bonferroni and Bonferroni-Holm can be shown to be valid tests using the closed testing principle - see below). Part of the reason why some simple procedures l
Why do we not always use the closed testing principle for multiple comparisons? It is actually used quite often (in fact, Bonferroni and Bonferroni-Holm can be shown to be valid tests using the closed testing principle - see below). Part of the reason why some simple procedures like Bonferroni are still so popular is of course, that they are very easy to implement and it is easy to communicate what you did. E.g. even for the simple Bonferroni or Bonferroni-Holm writing down the tests for the intersection null hypotheses is a bit tedious. That's why the graphical approach to constructing closed testing procedures is very popular - at least in the clinical trials setting (where there is usually a trained statistician at hand that can help pre-specify a tailored testing procedure for a specific trial). This graphical approach provides a really easy way to construct valid testing procedures and makes communication easier. Various variants, extensions and improvements such as exploiting correlations, prioritization of certain hypotheses depending on which hypotheses are already rejected etc. have been proposed over the years. Bonferroni vs. Bonferroni-Holm as closed testing procedures example The Bonferroni test can be easily written down in terms of the closed testing principle, e.g. in the case of two null hypotheses as Test for $H_1 \cap H_2$: $p_1 \leq \alpha/2$ and $p_2 \leq \alpha/2$ Test for elementary null hypothesis $H_1$: $p_1 \leq \alpha/2$ Test for elementary null hypothesis $H_2$: $p_2 \leq \alpha/2$ with $H_1$ rejected overall, if both $H_1$ and $H_1 \cap H_2$ are rejected. Thus, we know it is a valid test. You also immediately see that for the elementary null hypotheses $H_1$ and $H_2$ you are using a test that is not exhausting the significance level and that the Bonferroni-Holm test Test for $H_1$ and $H_2$: $p_1 \leq \alpha/2$ and $p_2 \leq \alpha/2$ Test for $H_1$: $p_1 \leq \alpha$ Test for $H_2$: $p_2 \leq \alpha$ is uniformly more powerful. Figure 1: Illustration of the graphical approach for displaying these two procedures Power considerations and other considerations Usually, there's no downside in terms of power to using a closed testing procedure - if anything it tends to be easier to make sure the test fully exhausts the significance level. It can sometimes be a bit tricky to build in some desired features (e.g. exploiting a known correlation) while keep some other desired contraints (e.g. that the closed testing procedure can be easily displayed graphically due to the consistency requirement on the testing procedure).
Why do we not always use the closed testing principle for multiple comparisons? It is actually used quite often (in fact, Bonferroni and Bonferroni-Holm can be shown to be valid tests using the closed testing principle - see below). Part of the reason why some simple procedures l
35,631
Expected min distance between N Uniform RVs
You are correct. One route to the solution, using only well-known relationships among these variables, is the following: Generate iid Gamma$(1)$ variates $V_i,$ $i=0,1,2,\ldots, N.$ (These are exponentially distributed variables.) Set $Y_1=V_0$ and $Y_i=Y_{i-1}+V_{i-1}$ for $i=1,\ldots, N+1.$ These are the partial cumulative sums of the $V_i.$ The order statistics of the $X_i,$ written $0 \le X_{(1)} \le X_{(2)}\le \cdots \le X_{(N)},$ have the same distribution as the $Y_i/Y_{N+1}$ for $i$ between $1$ and $N.$ The minimum of the $|X_i-X_j|, i\ne j,$ must be the minimum of the difference of two consecutive order statistics $X_{(k+1)}-X_{(k)} = V_{k^*}/Y_{N+1}$ for $k^*$ between $1$ and $N-1.$ $V_{k^*}$ is the minimum of the $N-1$ iid exponential variables $V_1,V_2,\ldots,V_{N-1}.$ Thus, when multiplied by $N-1,$ it has a Gamma$(1)$ distribution. Conditional on the minimum, the remaining $N-2$ Gamma variates in $(5)$ are each distributed as $V_{k^*}$ plus iid Gamma$(1)$ variates. Letting the sum of the latter be $W,$ of which there are $N-2$ terms, that sum can be expressed as $V_{k^*}$ itself plus $(N-2)V_{k^*}$ plus an independent Gamma$(N-2)$ variable $W.$ The denominator in $(3),$ $Y_{N+1}$ itself, is obtained by adding the independent Gamma$(1)$ variables $V_0$ and $V_N$ to that. Their sum with $W$ creates a Gamma$(N-2+1+1)$ = Gamma$(N)$ variable $Z.$ Consequently the minimum distance among the $X_i$ has the distribution of $V_{k^*}/((N-1)V_{k^*}+Z)$ where $(N-1)\,V_{k^*}\sim\Gamma(1)$ and independently $Z\sim \Gamma(N).$ Any ratio of $U$ to $U+Z,$ where independently $U$ has a Gamma$(a)$ distribution and $Z$ has a Gamma$(b)$ distribution, has a Beta$(a,b)$ distribution. Thus, with $a=1$ and $b=N$ and accounting for the scale factor of $N-1$ in $(8),$ $N-1$ times the minimum distance among the $X_i$ has a Beta$(1,N)$ distribution. Because the expectation of that Beta distribution is $1/(N+1),$ the expectation of the minimum distance is $1/(N-1)\times 1/(N+1) = 1/(N^2-1),$ as claimed. Deviations from this formula will be clearest for small $N,$ so here is a histogram of a sample of size 100,000 from the minimum $X$ distance for $N=3$ with a graph of the (scaled) Beta density superimposed. The agreement is excellent. N <- 3 n <- 1e5 set.seed(17) u <- matrix(runif(N*n), nrow=N) # IID uniform variates, in `n` columns u <- apply(u, 2, sort) # Their order statistics u <- apply(u, 2, diff) # The gaps between them x <- apply(matrix(u, nrow=N-1), 2, min) # The smallest gap hist(x, breaks=50, freq=FALSE) curve(dbeta(x*(N-1), 1, N)*(N-1), add=TRUE, col="Red", lwd=2, n=1001)
Expected min distance between N Uniform RVs
You are correct. One route to the solution, using only well-known relationships among these variables, is the following: Generate iid Gamma$(1)$ variates $V_i,$ $i=0,1,2,\ldots, N.$ (These are expon
Expected min distance between N Uniform RVs You are correct. One route to the solution, using only well-known relationships among these variables, is the following: Generate iid Gamma$(1)$ variates $V_i,$ $i=0,1,2,\ldots, N.$ (These are exponentially distributed variables.) Set $Y_1=V_0$ and $Y_i=Y_{i-1}+V_{i-1}$ for $i=1,\ldots, N+1.$ These are the partial cumulative sums of the $V_i.$ The order statistics of the $X_i,$ written $0 \le X_{(1)} \le X_{(2)}\le \cdots \le X_{(N)},$ have the same distribution as the $Y_i/Y_{N+1}$ for $i$ between $1$ and $N.$ The minimum of the $|X_i-X_j|, i\ne j,$ must be the minimum of the difference of two consecutive order statistics $X_{(k+1)}-X_{(k)} = V_{k^*}/Y_{N+1}$ for $k^*$ between $1$ and $N-1.$ $V_{k^*}$ is the minimum of the $N-1$ iid exponential variables $V_1,V_2,\ldots,V_{N-1}.$ Thus, when multiplied by $N-1,$ it has a Gamma$(1)$ distribution. Conditional on the minimum, the remaining $N-2$ Gamma variates in $(5)$ are each distributed as $V_{k^*}$ plus iid Gamma$(1)$ variates. Letting the sum of the latter be $W,$ of which there are $N-2$ terms, that sum can be expressed as $V_{k^*}$ itself plus $(N-2)V_{k^*}$ plus an independent Gamma$(N-2)$ variable $W.$ The denominator in $(3),$ $Y_{N+1}$ itself, is obtained by adding the independent Gamma$(1)$ variables $V_0$ and $V_N$ to that. Their sum with $W$ creates a Gamma$(N-2+1+1)$ = Gamma$(N)$ variable $Z.$ Consequently the minimum distance among the $X_i$ has the distribution of $V_{k^*}/((N-1)V_{k^*}+Z)$ where $(N-1)\,V_{k^*}\sim\Gamma(1)$ and independently $Z\sim \Gamma(N).$ Any ratio of $U$ to $U+Z,$ where independently $U$ has a Gamma$(a)$ distribution and $Z$ has a Gamma$(b)$ distribution, has a Beta$(a,b)$ distribution. Thus, with $a=1$ and $b=N$ and accounting for the scale factor of $N-1$ in $(8),$ $N-1$ times the minimum distance among the $X_i$ has a Beta$(1,N)$ distribution. Because the expectation of that Beta distribution is $1/(N+1),$ the expectation of the minimum distance is $1/(N-1)\times 1/(N+1) = 1/(N^2-1),$ as claimed. Deviations from this formula will be clearest for small $N,$ so here is a histogram of a sample of size 100,000 from the minimum $X$ distance for $N=3$ with a graph of the (scaled) Beta density superimposed. The agreement is excellent. N <- 3 n <- 1e5 set.seed(17) u <- matrix(runif(N*n), nrow=N) # IID uniform variates, in `n` columns u <- apply(u, 2, sort) # Their order statistics u <- apply(u, 2, diff) # The gaps between them x <- apply(matrix(u, nrow=N-1), 2, min) # The smallest gap hist(x, breaks=50, freq=FALSE) curve(dbeta(x*(N-1), 1, N)*(N-1), add=TRUE, col="Red", lwd=2, n=1001)
Expected min distance between N Uniform RVs You are correct. One route to the solution, using only well-known relationships among these variables, is the following: Generate iid Gamma$(1)$ variates $V_i,$ $i=0,1,2,\ldots, N.$ (These are expon
35,632
Low effective sample size but good R-hat is this a problem?
In BDA3 on page 285, they mention that $\hat{R}$ is an estimate of "the factor by which the scale of the current distribution for [a particular univariate parameter] might be reduced if the simulations were continued in the limit $n \to \infty$." Because your $\hat{R}$ is so close to $1$, this means that it's unlikely that running the simulation any longer will be of much use. You mention that, for a particular parameter, it appears the "distribution is wider than the other parameters." This might be a property of the marginal posterior of that parameter, which is fine. A few of your suggestions might actually be invalidating some of the theory you're using to justify your estimates. For example, I wouldn't fiddle with the burn-ins too much, and changing the priors after you don't like simulation results is generally a no-no. Edit: Regarding your request for more information about effective sample size, close after the portion I cited above in the same book, they discuss $\hat{R}$'s connection with effective sample size $n_{\text{eff}}$ as well as recommended settings for both. In particular, they mention that it might suffice to have as few as $10$ or $100$ as an effective sample size, and only aiming for more if an increased amount of precision is desired. Here's a quote: As a default rule, we suggest running the simulation until $\hat{n}_{\text{eff}}$ is at least $5m$... Having an effective sample size of $10$ per sequence should typically correspond to stability of all the simulated sequences. Here, $m$ is the "number of chains (after splitting)" BDA3 pg. 284 you're simulating . Notice that in particular that the desired number they suggest does not depend on the number of draws, retained or otherwise. The reason why these two metrics are "typically" related is because their formulas make use of the same quantities. However, they are getting at the dispersion of two different quantities. $\hat{R}$ measures the potential reduction in scale for the posterior distribution, while effective sample size gives you the reduction in the variance of the estimate for an expected value of this distribution. In the ideal case, we wouldn't have to resort to sampling, and we could just derive, say, the posterior expected value; here, we would have zero error on the latter, but a possibly very large number for the former. For more information take a look at page 286 and 287.
Low effective sample size but good R-hat is this a problem?
In BDA3 on page 285, they mention that $\hat{R}$ is an estimate of "the factor by which the scale of the current distribution for [a particular univariate parameter] might be reduced if the simulation
Low effective sample size but good R-hat is this a problem? In BDA3 on page 285, they mention that $\hat{R}$ is an estimate of "the factor by which the scale of the current distribution for [a particular univariate parameter] might be reduced if the simulations were continued in the limit $n \to \infty$." Because your $\hat{R}$ is so close to $1$, this means that it's unlikely that running the simulation any longer will be of much use. You mention that, for a particular parameter, it appears the "distribution is wider than the other parameters." This might be a property of the marginal posterior of that parameter, which is fine. A few of your suggestions might actually be invalidating some of the theory you're using to justify your estimates. For example, I wouldn't fiddle with the burn-ins too much, and changing the priors after you don't like simulation results is generally a no-no. Edit: Regarding your request for more information about effective sample size, close after the portion I cited above in the same book, they discuss $\hat{R}$'s connection with effective sample size $n_{\text{eff}}$ as well as recommended settings for both. In particular, they mention that it might suffice to have as few as $10$ or $100$ as an effective sample size, and only aiming for more if an increased amount of precision is desired. Here's a quote: As a default rule, we suggest running the simulation until $\hat{n}_{\text{eff}}$ is at least $5m$... Having an effective sample size of $10$ per sequence should typically correspond to stability of all the simulated sequences. Here, $m$ is the "number of chains (after splitting)" BDA3 pg. 284 you're simulating . Notice that in particular that the desired number they suggest does not depend on the number of draws, retained or otherwise. The reason why these two metrics are "typically" related is because their formulas make use of the same quantities. However, they are getting at the dispersion of two different quantities. $\hat{R}$ measures the potential reduction in scale for the posterior distribution, while effective sample size gives you the reduction in the variance of the estimate for an expected value of this distribution. In the ideal case, we wouldn't have to resort to sampling, and we could just derive, say, the posterior expected value; here, we would have zero error on the latter, but a possibly very large number for the former. For more information take a look at page 286 and 287.
Low effective sample size but good R-hat is this a problem? In BDA3 on page 285, they mention that $\hat{R}$ is an estimate of "the factor by which the scale of the current distribution for [a particular univariate parameter] might be reduced if the simulation
35,633
Low effective sample size but good R-hat is this a problem?
An old thread, but still likely relevant to many users. Instead of increasing adapt_delta, you can try decreasing it to, say, 0.8 or a value that still does not lead to divergent iterations. My understanding is this increases the mixing and, thus, may increase the ESS.
Low effective sample size but good R-hat is this a problem?
An old thread, but still likely relevant to many users. Instead of increasing adapt_delta, you can try decreasing it to, say, 0.8 or a value that still does not lead to divergent iterations. My under
Low effective sample size but good R-hat is this a problem? An old thread, but still likely relevant to many users. Instead of increasing adapt_delta, you can try decreasing it to, say, 0.8 or a value that still does not lead to divergent iterations. My understanding is this increases the mixing and, thus, may increase the ESS.
Low effective sample size but good R-hat is this a problem? An old thread, but still likely relevant to many users. Instead of increasing adapt_delta, you can try decreasing it to, say, 0.8 or a value that still does not lead to divergent iterations. My under
35,634
Mean centering interaction terms
You don't have to mean-center variables that are included in interaction terms. Back in the dark ages when people did statistical calculations by hand on mechanical (not electronic) calculators having limited precision, there might have been some practical advantages to centering first. But modern computing hardware and software make that unnecessary. Frank Harrell has commented here: "I almost never use centering, finding it completely unncessary and confusing." But if you do center, you will still get the correct results because of your observation that "when I multiply two negative scores, I will have a positive score." Say that all regression coefficients (including for interactions) and the variables in their original scales are positive. Then a two-way interaction term adds a more positive contribution to the final prediction than either of the variables would contribute individually. Now say that you center the data, and you have a situation where both predictor variables have values below their means. You still want that two-way interaction to add a more positive contribution to the final prediction than either of the variables would contribute individually. So their "positive score" in the interaction is just what you want. The difference is that, after centering, the individual contributions of both predictors will have been negative relative to the (new) intercept of the mean-centered model. Between centering and not, the intercept and coefficients for variables involved in interactions with centered variables will change. The coefficient for a centered predictor will not change, however, unless it is involved in an interaction with another centered variable. To see this, consider the following linear model for $y$ using predictor $x$ centered around its mean value $\bar x$ and uncentered $z$: $$y = \beta_0 +\beta_1(x-\bar x)+\beta_2z+\beta_3(x-\bar x)z$$ Collecting together terms that are constant, those that change only with $x$, those that change only with $z$, and those involving the interaction, we get: $$y = (\beta_0 - \beta_1\bar x)+\beta_1 x+ (\beta_2 - \beta_3\bar x)z+\beta_3xz$$ Compare that against the corresponding model with neither $x$ nor $z$ centered: $$y=\beta_0' + \beta_1'x+\beta_2'z +\beta_3' xz$$ So centering $x$ changes the intercept and the coefficient for $z$ from the uncentered model, but leaves the coefficients for $x$ and for the $xz$ interaction unchanged. The reported p-values for the coefficient for $z$ will differ between the uncentered and $x$-centered models. That might seem troubling at first, but that's OK. The correct test for significance of a predictor involved in an interaction must involve both its individual coefficient and its interaction coefficient, and the result of that test is unchanged by centering.
Mean centering interaction terms
You don't have to mean-center variables that are included in interaction terms. Back in the dark ages when people did statistical calculations by hand on mechanical (not electronic) calculators having
Mean centering interaction terms You don't have to mean-center variables that are included in interaction terms. Back in the dark ages when people did statistical calculations by hand on mechanical (not electronic) calculators having limited precision, there might have been some practical advantages to centering first. But modern computing hardware and software make that unnecessary. Frank Harrell has commented here: "I almost never use centering, finding it completely unncessary and confusing." But if you do center, you will still get the correct results because of your observation that "when I multiply two negative scores, I will have a positive score." Say that all regression coefficients (including for interactions) and the variables in their original scales are positive. Then a two-way interaction term adds a more positive contribution to the final prediction than either of the variables would contribute individually. Now say that you center the data, and you have a situation where both predictor variables have values below their means. You still want that two-way interaction to add a more positive contribution to the final prediction than either of the variables would contribute individually. So their "positive score" in the interaction is just what you want. The difference is that, after centering, the individual contributions of both predictors will have been negative relative to the (new) intercept of the mean-centered model. Between centering and not, the intercept and coefficients for variables involved in interactions with centered variables will change. The coefficient for a centered predictor will not change, however, unless it is involved in an interaction with another centered variable. To see this, consider the following linear model for $y$ using predictor $x$ centered around its mean value $\bar x$ and uncentered $z$: $$y = \beta_0 +\beta_1(x-\bar x)+\beta_2z+\beta_3(x-\bar x)z$$ Collecting together terms that are constant, those that change only with $x$, those that change only with $z$, and those involving the interaction, we get: $$y = (\beta_0 - \beta_1\bar x)+\beta_1 x+ (\beta_2 - \beta_3\bar x)z+\beta_3xz$$ Compare that against the corresponding model with neither $x$ nor $z$ centered: $$y=\beta_0' + \beta_1'x+\beta_2'z +\beta_3' xz$$ So centering $x$ changes the intercept and the coefficient for $z$ from the uncentered model, but leaves the coefficients for $x$ and for the $xz$ interaction unchanged. The reported p-values for the coefficient for $z$ will differ between the uncentered and $x$-centered models. That might seem troubling at first, but that's OK. The correct test for significance of a predictor involved in an interaction must involve both its individual coefficient and its interaction coefficient, and the result of that test is unchanged by centering.
Mean centering interaction terms You don't have to mean-center variables that are included in interaction terms. Back in the dark ages when people did statistical calculations by hand on mechanical (not electronic) calculators having
35,635
Argument on Interactions in The Book of Why
You are conflating linear in parameters with linear in variables. Linearity here refers to the relationship between the variables. Their point in the book is that, if the model is not linear in the variables, then neither the equation $$\text{Total Effect} = \text{Direct Effect} + \text{Indirect Effect} $$ holds, nor the regression coefficient gives you the proper backdoor adjustment directly. Regarding the last case, for instance, consider the conditional expectation $E[Y|x,z] = \beta x + \gamma z$, which is linear with respect to $X$ and $Z$. If $Z$ satisfies the backdoor criterion for the causal effect of $X$ on $Y$, then $$ \frac{\partial E[Y|do(x)]}{\partial x} = \frac{\partial E[E[Y|x, Z]]}{\partial x} = \beta $$ That is, the regression coefficient $\beta$ equals the average marginal causal effect. This is what is meant by "regression based adjustment works" in this case, you don't need any extra steps here---all the averaging required for backdoor adjustment is automatically done by regression. Now consider the conditional expectation $E[Y|x,z] = \beta x + \gamma z + \delta (x \times z)$. Note this is not linear with respect to $x$ and $z$ (although it is linear in the parameters). Note in this case if $Z$ satisfies the backdoor criterion for the causal effect of $X$ on $Y$, then $$ \frac{\partial E[Y|do(x)]}{\partial x} = \frac{\partial E[E[Y|x, Z]]}{\partial x} = \beta + \delta E[z] $$ That is, the correct backdoor adjustment is not given by the regression coefficient on $X$ only. More generally, Pearl is saying that if $Z$ satifies the backdoor criterion, you can use any non-parametric estimator you prefer to compute the post-intervention distribution $ E[Y|do(x)] = E[E[Y|x, Z]]$.
Argument on Interactions in The Book of Why
You are conflating linear in parameters with linear in variables. Linearity here refers to the relationship between the variables. Their point in the book is that, if the model is not linear in the v
Argument on Interactions in The Book of Why You are conflating linear in parameters with linear in variables. Linearity here refers to the relationship between the variables. Their point in the book is that, if the model is not linear in the variables, then neither the equation $$\text{Total Effect} = \text{Direct Effect} + \text{Indirect Effect} $$ holds, nor the regression coefficient gives you the proper backdoor adjustment directly. Regarding the last case, for instance, consider the conditional expectation $E[Y|x,z] = \beta x + \gamma z$, which is linear with respect to $X$ and $Z$. If $Z$ satisfies the backdoor criterion for the causal effect of $X$ on $Y$, then $$ \frac{\partial E[Y|do(x)]}{\partial x} = \frac{\partial E[E[Y|x, Z]]}{\partial x} = \beta $$ That is, the regression coefficient $\beta$ equals the average marginal causal effect. This is what is meant by "regression based adjustment works" in this case, you don't need any extra steps here---all the averaging required for backdoor adjustment is automatically done by regression. Now consider the conditional expectation $E[Y|x,z] = \beta x + \gamma z + \delta (x \times z)$. Note this is not linear with respect to $x$ and $z$ (although it is linear in the parameters). Note in this case if $Z$ satisfies the backdoor criterion for the causal effect of $X$ on $Y$, then $$ \frac{\partial E[Y|do(x)]}{\partial x} = \frac{\partial E[E[Y|x, Z]]}{\partial x} = \beta + \delta E[z] $$ That is, the correct backdoor adjustment is not given by the regression coefficient on $X$ only. More generally, Pearl is saying that if $Z$ satifies the backdoor criterion, you can use any non-parametric estimator you prefer to compute the post-intervention distribution $ E[Y|do(x)] = E[E[Y|x, Z]]$.
Argument on Interactions in The Book of Why You are conflating linear in parameters with linear in variables. Linearity here refers to the relationship between the variables. Their point in the book is that, if the model is not linear in the v
35,636
Argument on Interactions in The Book of Why
"Purely linear" models do not allow for that. If you want to model an interaction using a particular case of the General Linear Model (do not mistake this for a Generalized Linear Model), you have to introduce an artificial extra variable like the product of the two interacting ones. This new model is still linear with regards to its parameters (this is what matters for getting the estimators), but it is no longer linear with regards to its variables (you can no longer talk about a linear relationship between regressors and target)
Argument on Interactions in The Book of Why
"Purely linear" models do not allow for that. If you want to model an interaction using a particular case of the General Linear Model (do not mistake this for a Generalized Linear Model), you have to
Argument on Interactions in The Book of Why "Purely linear" models do not allow for that. If you want to model an interaction using a particular case of the General Linear Model (do not mistake this for a Generalized Linear Model), you have to introduce an artificial extra variable like the product of the two interacting ones. This new model is still linear with regards to its parameters (this is what matters for getting the estimators), but it is no longer linear with regards to its variables (you can no longer talk about a linear relationship between regressors and target)
Argument on Interactions in The Book of Why "Purely linear" models do not allow for that. If you want to model an interaction using a particular case of the General Linear Model (do not mistake this for a Generalized Linear Model), you have to
35,637
What is the relationship between minimizing prediction error versus parameter estimation error?
With the advent of statistical learning techniques, people are talking a lot about prediction error, while in classical statistics, one is focusing on parameter estimation error. Exactly. This difference can be properly understood only if we realize and keep in mind that the scope of model like regression, first of all linear regression as your true model suggest, can be different (read here: Regression: Causation vs Prediction vs Description). If your goal is prediction, as usual in supervised/predictive machine learning, you have to minimize the prediction error; parameters value per se not matters therefore endogeneity is not the core issue. At the other side if your goal is description or causal inference you have to focus on parameters estimation. For example in econometrics the usual focus is (or was) in causal inference (conflated with description if we follow the argument suggested in previous link), then endogeneity is treated as the main issue. In this literature prediction is treated as secondary problem, or ad hoc one in time series context (ARMA models for example). In most case is given the impression that if endogeneity go away, as consequence, the best prediction/forecasting model is achieved too. If this thing was true, the two minimization problem that you write above would be equivalent. However this is not true, infact in prediction/forecasting endogeneity are not the main problem while overfitting is (read here: Endogeneity in forecasting) In order to understand this distinction the bias-variance tradeoff is the crucial point. Infact at the start of most machine learning books this topic is exhaustively treated and overfitting problem come as consequence. Indeed in most generalistic econometric books the bias-variance tradeoff is completely forget, for overfitting problem the same is true or, at best, it is vaguely treated. I started to study topic like those we treat here from econometrics side and when I realized this fact I remained badly surprised. The article that underscore at best this problem is probably: To Explain or to Predict – Shmueli (2010). Read here (Minimizing bias in explanatory modeling, why? (Galit Shmueli's "To Explain or to Predict")) In other terms, if a model minimizes estimation error, does it necessarily minimize prediction error under the assumption of a linear model? No, definitely not. For prediction scope, more precisely in term of Expected Prediction Error, the "wrong model" (incorrectly specified regression) can be better then the "right one" (correctly specified regression). Obviously this fact is irrelevant if, as in causal inference, parameters is the core of analysis. In the article is given an example that involve an underspecified model. I used this argument here (Are inconsistent estimators ever preferable?). The proof is in the appendix of the article but the main issue are write down also in this strongly related question (Paradox in model selection (AIC, BIC, to explain or to predict?)). Warning: if the true model is noiseless or the amount of data we have go to infinity, therefore never in practice, the bias-variance tradeoff disappear and the two minimization problem become equivalent. This discussion is related: Minimizing bias in explanatory modeling, why? (Galit Shmueli's "To Explain or to Predict")
What is the relationship between minimizing prediction error versus parameter estimation error?
With the advent of statistical learning techniques, people are talking a lot about prediction error, while in classical statistics, one is focusing on parameter estimation error. Exactly. This differ
What is the relationship between minimizing prediction error versus parameter estimation error? With the advent of statistical learning techniques, people are talking a lot about prediction error, while in classical statistics, one is focusing on parameter estimation error. Exactly. This difference can be properly understood only if we realize and keep in mind that the scope of model like regression, first of all linear regression as your true model suggest, can be different (read here: Regression: Causation vs Prediction vs Description). If your goal is prediction, as usual in supervised/predictive machine learning, you have to minimize the prediction error; parameters value per se not matters therefore endogeneity is not the core issue. At the other side if your goal is description or causal inference you have to focus on parameters estimation. For example in econometrics the usual focus is (or was) in causal inference (conflated with description if we follow the argument suggested in previous link), then endogeneity is treated as the main issue. In this literature prediction is treated as secondary problem, or ad hoc one in time series context (ARMA models for example). In most case is given the impression that if endogeneity go away, as consequence, the best prediction/forecasting model is achieved too. If this thing was true, the two minimization problem that you write above would be equivalent. However this is not true, infact in prediction/forecasting endogeneity are not the main problem while overfitting is (read here: Endogeneity in forecasting) In order to understand this distinction the bias-variance tradeoff is the crucial point. Infact at the start of most machine learning books this topic is exhaustively treated and overfitting problem come as consequence. Indeed in most generalistic econometric books the bias-variance tradeoff is completely forget, for overfitting problem the same is true or, at best, it is vaguely treated. I started to study topic like those we treat here from econometrics side and when I realized this fact I remained badly surprised. The article that underscore at best this problem is probably: To Explain or to Predict – Shmueli (2010). Read here (Minimizing bias in explanatory modeling, why? (Galit Shmueli's "To Explain or to Predict")) In other terms, if a model minimizes estimation error, does it necessarily minimize prediction error under the assumption of a linear model? No, definitely not. For prediction scope, more precisely in term of Expected Prediction Error, the "wrong model" (incorrectly specified regression) can be better then the "right one" (correctly specified regression). Obviously this fact is irrelevant if, as in causal inference, parameters is the core of analysis. In the article is given an example that involve an underspecified model. I used this argument here (Are inconsistent estimators ever preferable?). The proof is in the appendix of the article but the main issue are write down also in this strongly related question (Paradox in model selection (AIC, BIC, to explain or to predict?)). Warning: if the true model is noiseless or the amount of data we have go to infinity, therefore never in practice, the bias-variance tradeoff disappear and the two minimization problem become equivalent. This discussion is related: Minimizing bias in explanatory modeling, why? (Galit Shmueli's "To Explain or to Predict")
What is the relationship between minimizing prediction error versus parameter estimation error? With the advent of statistical learning techniques, people are talking a lot about prediction error, while in classical statistics, one is focusing on parameter estimation error. Exactly. This differ
35,638
What is the relationship between minimizing prediction error versus parameter estimation error?
Multicollinearity You could have multicollinearity which can make the variance in the error of estimates of $y$ and $\beta$ a lot different (typically the error in $y$ will have lower relative variance). See for more background: https://stats.stackexchange.com/tags/multicollinearity and https://en.wikipedia.org/wiki/Multicollinearity Assuming a true linear model $y = X\beta_0 + \varepsilon$, estimate $\hat\beta$ and prediction $\hat y=X\hat\beta$. One can define, with $\lVert.\rVert$ the mean square error norm for example: Prediction error: $\lVert y-\hat y\rVert = \lVert X(\beta -\hat\beta)\rVert$ (note this definition omits the part related to the error term ) Estimation error: $\lVert \beta -\hat\beta\rVert$ Let's express the variation of this prediction error $y-\hat y$ in terms of the estimation error $\beta -\hat\beta$. $$\begin{array}{} \text{Var}[{y_k}-{\hat{y_k}}] &=& \text{Var}[\mathbf{X_k}(\boldsymbol{\beta} - \boldsymbol{\hat \beta})] \\ &=& \text{Var}[\sum_{i=1}^n X_{ik}(\beta_i - \hat \beta_i) ] \\ \\ &=& \sum_{i=1}^n X_{ik}^2 \text{Var}[\beta_i - \hat \beta_i] \\ && \quad + \, 2 \sum_\limits{1 \leq i<j\leq n} X_{ik} X_{jk} \text{Cov} [\beta_i - \hat \beta_i,\beta_j - \hat \beta_j] \\ \end{array}$$ This last line has an additional term with covariances. This makes that the error (variance) of $y$ can be a lot different from the error (variance) of $\beta$. A very common issue is that the $\beta_i$ have a negative correlation (due to a positive correlation between the $X_i$, ie multicollinearity) and the variance of the predictions/estimates of $y$ might be (relatively) much smaller than the variance of the estimates of $\beta$. Prediction versus Estimation In addition to the issue of multicollinearity, there might be several other issues. The terms 'prediction' and 'estimation' can be ambiguous. In this particular question, the terms are linked to the estimation of $y$ versus the estimation of $\beta$. However I can see the estimation/prediction of $y$ in various ways. When we fit data $y_i$ with a curve $\hat y_i$ (like the typical fitting, e.g. as in regression) then the $\hat y_i$ are in my vocabulary estimates of $y_i$ and not predictions of $y_i$. With prediction, I am thinking about issues like generating prediction intervals (which differ from confidence intervals) or issues like extrapolating curves (e.g. extending trends, predicting new values based on old values). This prediction of values of $y$ based on estimates of $\beta$ contains the same issue as the multicollinearity explained above, but it is more than that and I feel it is not right to conflate these two. The biggest issue is often the discrepance between 'estimating $y$ versus *estimating $\beta$'. In addition you have the discrepance between 'predicting $y$ versus *estimating $\beta$', which contains 'estimating $y$ versus *estimating $\beta$', but is also more than that (e.g. optimizing different loss functions, reducing the loss of our predictions, according to some loss function, is different from reducing the error of our estimates, according to some probability model/likelihood).
What is the relationship between minimizing prediction error versus parameter estimation error?
Multicollinearity You could have multicollinearity which can make the variance in the error of estimates of $y$ and $\beta$ a lot different (typically the error in $y$ will have lower relative varianc
What is the relationship between minimizing prediction error versus parameter estimation error? Multicollinearity You could have multicollinearity which can make the variance in the error of estimates of $y$ and $\beta$ a lot different (typically the error in $y$ will have lower relative variance). See for more background: https://stats.stackexchange.com/tags/multicollinearity and https://en.wikipedia.org/wiki/Multicollinearity Assuming a true linear model $y = X\beta_0 + \varepsilon$, estimate $\hat\beta$ and prediction $\hat y=X\hat\beta$. One can define, with $\lVert.\rVert$ the mean square error norm for example: Prediction error: $\lVert y-\hat y\rVert = \lVert X(\beta -\hat\beta)\rVert$ (note this definition omits the part related to the error term ) Estimation error: $\lVert \beta -\hat\beta\rVert$ Let's express the variation of this prediction error $y-\hat y$ in terms of the estimation error $\beta -\hat\beta$. $$\begin{array}{} \text{Var}[{y_k}-{\hat{y_k}}] &=& \text{Var}[\mathbf{X_k}(\boldsymbol{\beta} - \boldsymbol{\hat \beta})] \\ &=& \text{Var}[\sum_{i=1}^n X_{ik}(\beta_i - \hat \beta_i) ] \\ \\ &=& \sum_{i=1}^n X_{ik}^2 \text{Var}[\beta_i - \hat \beta_i] \\ && \quad + \, 2 \sum_\limits{1 \leq i<j\leq n} X_{ik} X_{jk} \text{Cov} [\beta_i - \hat \beta_i,\beta_j - \hat \beta_j] \\ \end{array}$$ This last line has an additional term with covariances. This makes that the error (variance) of $y$ can be a lot different from the error (variance) of $\beta$. A very common issue is that the $\beta_i$ have a negative correlation (due to a positive correlation between the $X_i$, ie multicollinearity) and the variance of the predictions/estimates of $y$ might be (relatively) much smaller than the variance of the estimates of $\beta$. Prediction versus Estimation In addition to the issue of multicollinearity, there might be several other issues. The terms 'prediction' and 'estimation' can be ambiguous. In this particular question, the terms are linked to the estimation of $y$ versus the estimation of $\beta$. However I can see the estimation/prediction of $y$ in various ways. When we fit data $y_i$ with a curve $\hat y_i$ (like the typical fitting, e.g. as in regression) then the $\hat y_i$ are in my vocabulary estimates of $y_i$ and not predictions of $y_i$. With prediction, I am thinking about issues like generating prediction intervals (which differ from confidence intervals) or issues like extrapolating curves (e.g. extending trends, predicting new values based on old values). This prediction of values of $y$ based on estimates of $\beta$ contains the same issue as the multicollinearity explained above, but it is more than that and I feel it is not right to conflate these two. The biggest issue is often the discrepance between 'estimating $y$ versus *estimating $\beta$'. In addition you have the discrepance between 'predicting $y$ versus *estimating $\beta$', which contains 'estimating $y$ versus *estimating $\beta$', but is also more than that (e.g. optimizing different loss functions, reducing the loss of our predictions, according to some loss function, is different from reducing the error of our estimates, according to some probability model/likelihood).
What is the relationship between minimizing prediction error versus parameter estimation error? Multicollinearity You could have multicollinearity which can make the variance in the error of estimates of $y$ and $\beta$ a lot different (typically the error in $y$ will have lower relative varianc
35,639
VAE: why we do not sample again after decoding and before reconstruction loss?
The most important point stems from the confusion that the tilde $\sim$ implies a sampling operation. But $\sim$ does not imply that something is sampled, which is an algorithmic/computational operation. It indicates that something is distributed according to some distribution. Now, when we train a VAE, we want to get gradients of the ELBO. The form of the ELBO used in VAEs is typically $$\mathcal{L} = \mathbb{E}_{z \sim q}\left[ \log p(x|z) \right] - \mathop{KL}\left[ q(z|x) || p(z)\right].$$ In its vanilla form, the KL of the VAE's ELBO can be computed efficiently with Monte Carlo estimates from $q$. The first term, the reconstruction term or likelihood term, can often be computed in closed form if $z$ is given. Especially in the two most prevalent cases–that of a Bernoulli and that of a Gaussian log likelihood. Hence, if $x|z \sim D$ with $D$ being some tractable distribution, there is no need to sample from it, as what we are interested in is $\log p(x|z)$, which is often tractable by itself.
VAE: why we do not sample again after decoding and before reconstruction loss?
The most important point stems from the confusion that the tilde $\sim$ implies a sampling operation. But $\sim$ does not imply that something is sampled, which is an algorithmic/computational operati
VAE: why we do not sample again after decoding and before reconstruction loss? The most important point stems from the confusion that the tilde $\sim$ implies a sampling operation. But $\sim$ does not imply that something is sampled, which is an algorithmic/computational operation. It indicates that something is distributed according to some distribution. Now, when we train a VAE, we want to get gradients of the ELBO. The form of the ELBO used in VAEs is typically $$\mathcal{L} = \mathbb{E}_{z \sim q}\left[ \log p(x|z) \right] - \mathop{KL}\left[ q(z|x) || p(z)\right].$$ In its vanilla form, the KL of the VAE's ELBO can be computed efficiently with Monte Carlo estimates from $q$. The first term, the reconstruction term or likelihood term, can often be computed in closed form if $z$ is given. Especially in the two most prevalent cases–that of a Bernoulli and that of a Gaussian log likelihood. Hence, if $x|z \sim D$ with $D$ being some tractable distribution, there is no need to sample from it, as what we are interested in is $\log p(x|z)$, which is often tractable by itself.
VAE: why we do not sample again after decoding and before reconstruction loss? The most important point stems from the confusion that the tilde $\sim$ implies a sampling operation. But $\sim$ does not imply that something is sampled, which is an algorithmic/computational operati
35,640
VAE: why we do not sample again after decoding and before reconstruction loss?
In the case of image generation, the network will usually output a reconstructed image $\hat{\mathbf{x}}$ and you will compute the reconstruction term as \begin{equation} \mathcal{L}_{\text{reconstr}}(\theta) = {\lVert \mathbf{x} - f_\theta(\mathbf{x}_i,\mathbf{z}) \rVert}^2 = {\lVert \mathbf{x} - \hat{\mathbf{x}} \rVert}^2 \end{equation} Were $f_\theta(\mathbf{x}_i,\mathbf{z})$ is the decoder. This is the same thing that happens when you do linear regression. In normal linear regression, you estimate the mean of the likelihood with $\mathbf w^\top\mathbf x_i=\hat y_i$, then evaluate the normal likelihood in the true point $y_i$. And that's what you try to maximise. If you work out the math, and you assume $\sigma$ to be fixed, then maximizing the likelihood is equivalent to minimizing the squared error. \begin{equation} \max\;\mathcal{N}\left(y_i|\hat{y}_i,\sigma\right) \Leftrightarrow \min\;{\lVert y_i - \hat{y}_i \rVert}^2 \end{equation} Here you are doing the same thing. The decoder is generating the mean of a $N\times M$ normal (where $N\times M$ is the size of the image), and you are essentially doing \begin{equation} \max\;\mathcal{N}\left(\mathbf x_i|f_\theta(\mathbf{x}_i,\mathbf{z}),\mathbf{\sigma}\right) \Leftrightarrow \min\;{\lVert \mathbf x_i - \hat{\mathbf x}_i \rVert}^2 \end{equation} while assuming that $\mathbf{\sigma}$ is fixed. Technically, you could also make the network generate $\mathbf{\sigma}$, and then optimize a more refined L2 loss that also includes $\mathbf{\sigma}$ somewhere. That way, your network would generate all parameters of a normal distribution, not just the mean, and for each latent vector $\mathbf z$ you could actually sample several synthetic images $\hat{\mathbf x}$. However, we are often happy with generating one image for each $\mathbf z$. Thus, it is okay if we only take the most likely one, i.e. the mean of the resulting predictive posterior. After all, this is also what we do with point estimation in linear regression.
VAE: why we do not sample again after decoding and before reconstruction loss?
In the case of image generation, the network will usually output a reconstructed image $\hat{\mathbf{x}}$ and you will compute the reconstruction term as \begin{equation} \mathcal{L}_{\text{recons
VAE: why we do not sample again after decoding and before reconstruction loss? In the case of image generation, the network will usually output a reconstructed image $\hat{\mathbf{x}}$ and you will compute the reconstruction term as \begin{equation} \mathcal{L}_{\text{reconstr}}(\theta) = {\lVert \mathbf{x} - f_\theta(\mathbf{x}_i,\mathbf{z}) \rVert}^2 = {\lVert \mathbf{x} - \hat{\mathbf{x}} \rVert}^2 \end{equation} Were $f_\theta(\mathbf{x}_i,\mathbf{z})$ is the decoder. This is the same thing that happens when you do linear regression. In normal linear regression, you estimate the mean of the likelihood with $\mathbf w^\top\mathbf x_i=\hat y_i$, then evaluate the normal likelihood in the true point $y_i$. And that's what you try to maximise. If you work out the math, and you assume $\sigma$ to be fixed, then maximizing the likelihood is equivalent to minimizing the squared error. \begin{equation} \max\;\mathcal{N}\left(y_i|\hat{y}_i,\sigma\right) \Leftrightarrow \min\;{\lVert y_i - \hat{y}_i \rVert}^2 \end{equation} Here you are doing the same thing. The decoder is generating the mean of a $N\times M$ normal (where $N\times M$ is the size of the image), and you are essentially doing \begin{equation} \max\;\mathcal{N}\left(\mathbf x_i|f_\theta(\mathbf{x}_i,\mathbf{z}),\mathbf{\sigma}\right) \Leftrightarrow \min\;{\lVert \mathbf x_i - \hat{\mathbf x}_i \rVert}^2 \end{equation} while assuming that $\mathbf{\sigma}$ is fixed. Technically, you could also make the network generate $\mathbf{\sigma}$, and then optimize a more refined L2 loss that also includes $\mathbf{\sigma}$ somewhere. That way, your network would generate all parameters of a normal distribution, not just the mean, and for each latent vector $\mathbf z$ you could actually sample several synthetic images $\hat{\mathbf x}$. However, we are often happy with generating one image for each $\mathbf z$. Thus, it is okay if we only take the most likely one, i.e. the mean of the resulting predictive posterior. After all, this is also what we do with point estimation in linear regression.
VAE: why we do not sample again after decoding and before reconstruction loss? In the case of image generation, the network will usually output a reconstructed image $\hat{\mathbf{x}}$ and you will compute the reconstruction term as \begin{equation} \mathcal{L}_{\text{recons
35,641
Is there a standard way to Determine Sample Size when doing Bayesian Inference?
There is something corresponding to power analysis for Bayesians, it is called preposterior analysis. The preposterior expectation is the prior expectation of the posterior. One example can be found here. Another post where this concept is used is Minimizing variance of an estimator under sampling cost penalty. Some other links: Is power analysis necessary in Bayesian Statistics? and Power analysis from Bayesian point of view. Here is a stored google scholar search
Is there a standard way to Determine Sample Size when doing Bayesian Inference?
There is something corresponding to power analysis for Bayesians, it is called preposterior analysis. The preposterior expectation is the prior expectation of the posterior. One example can be found h
Is there a standard way to Determine Sample Size when doing Bayesian Inference? There is something corresponding to power analysis for Bayesians, it is called preposterior analysis. The preposterior expectation is the prior expectation of the posterior. One example can be found here. Another post where this concept is used is Minimizing variance of an estimator under sampling cost penalty. Some other links: Is power analysis necessary in Bayesian Statistics? and Power analysis from Bayesian point of view. Here is a stored google scholar search
Is there a standard way to Determine Sample Size when doing Bayesian Inference? There is something corresponding to power analysis for Bayesians, it is called preposterior analysis. The preposterior expectation is the prior expectation of the posterior. One example can be found h
35,642
Is there a standard way to Determine Sample Size when doing Bayesian Inference?
One of the more obvious approach is to simulate with model parameters drawn from your prior beliefs, then draw your Bayesian inference and assess what proportion of simulations looks they way you'd like them to look. Alternatively, you could make frequentist style assumptions (at least with respect to the size of the quantity of interest - perhaps reflecting the uncertainty about nuisance parameters is rather useful) and then simulate your planned Bayesian analysis.
Is there a standard way to Determine Sample Size when doing Bayesian Inference?
One of the more obvious approach is to simulate with model parameters drawn from your prior beliefs, then draw your Bayesian inference and assess what proportion of simulations looks they way you'd li
Is there a standard way to Determine Sample Size when doing Bayesian Inference? One of the more obvious approach is to simulate with model parameters drawn from your prior beliefs, then draw your Bayesian inference and assess what proportion of simulations looks they way you'd like them to look. Alternatively, you could make frequentist style assumptions (at least with respect to the size of the quantity of interest - perhaps reflecting the uncertainty about nuisance parameters is rather useful) and then simulate your planned Bayesian analysis.
Is there a standard way to Determine Sample Size when doing Bayesian Inference? One of the more obvious approach is to simulate with model parameters drawn from your prior beliefs, then draw your Bayesian inference and assess what proportion of simulations looks they way you'd li
35,643
What is this "phenomenon" called?
This answer is not a direct answer to your question, because it relates to a different cause of the pattern. But it does relate to the same graphical appearance, and therefore I post it as an answer rather than a comment (before reading your Matlab script I actually thought the pattern in your histogram was due to this different cause). Your question made me revisit a histogram that I plotted in an answer to a recent question. I used binsize 1, while the distance between the (discrete) results was 0.538. Making the bars of the histogram to be plotted occasionally with the counts for a single value instead of the counts for two values. After adjusting the bin sizes the histogram appeared more typical In this case, we could call the pattern a Moiré pattern, which is the appearance of artificial light and dark bands due to a misalignment of two discrete scales. In your case, however, the periodic pattern is not an artificial effect in the histogram but a truly periodic behavior in the probability mass function. Anyway, I thought it was useful to mention this related Moiré pattern.
What is this "phenomenon" called?
This answer is not a direct answer to your question, because it relates to a different cause of the pattern. But it does relate to the same graphical appearance, and therefore I post it as an answer
What is this "phenomenon" called? This answer is not a direct answer to your question, because it relates to a different cause of the pattern. But it does relate to the same graphical appearance, and therefore I post it as an answer rather than a comment (before reading your Matlab script I actually thought the pattern in your histogram was due to this different cause). Your question made me revisit a histogram that I plotted in an answer to a recent question. I used binsize 1, while the distance between the (discrete) results was 0.538. Making the bars of the histogram to be plotted occasionally with the counts for a single value instead of the counts for two values. After adjusting the bin sizes the histogram appeared more typical In this case, we could call the pattern a Moiré pattern, which is the appearance of artificial light and dark bands due to a misalignment of two discrete scales. In your case, however, the periodic pattern is not an artificial effect in the histogram but a truly periodic behavior in the probability mass function. Anyway, I thought it was useful to mention this related Moiré pattern.
What is this "phenomenon" called? This answer is not a direct answer to your question, because it relates to a different cause of the pattern. But it does relate to the same graphical appearance, and therefore I post it as an answer
35,644
What is this "phenomenon" called?
UPDATE: Re-reading this four years later, let me attempt to answer the first part too, what to call it. If it is due to two distinct distributions, as I suggest below, then the combination is called a mixture distribution; I more often hear the term mixture model, which is what we'd use to model it. If an artifact of how the data is displayed graphically, the other answer mentions moiré pattern. Or simply visual artifact? And in comments, whuber calls it aliasing, which I think I like best. should I separate the odd and even values or fit a normal distribution to the whole set? I think you should separate them. Your analysis has discovered that the most important factor/predictor is if the input is odd or even, so to merge them would be to blur both of the distributions, and make them less useful (*). *: Of course, it really depends on your definition of useful. I'm approaching it from the viewpoint of you have some inputs and want to make a model to predict some output. Once we know it is significant, I'd want to give the model the hint that the parity of one/some of the inputs matters. By the way, as in Martijn Weterings's answer, when I've had jagged histograms like this before, it has been related to the choice of bin size. It made me realize that experimentation with bin size is yet another tool in the Lying With Stats toolbox :-)
What is this "phenomenon" called?
UPDATE: Re-reading this four years later, let me attempt to answer the first part too, what to call it. If it is due to two distinct distributions, as I suggest below, then the combination is called a
What is this "phenomenon" called? UPDATE: Re-reading this four years later, let me attempt to answer the first part too, what to call it. If it is due to two distinct distributions, as I suggest below, then the combination is called a mixture distribution; I more often hear the term mixture model, which is what we'd use to model it. If an artifact of how the data is displayed graphically, the other answer mentions moiré pattern. Or simply visual artifact? And in comments, whuber calls it aliasing, which I think I like best. should I separate the odd and even values or fit a normal distribution to the whole set? I think you should separate them. Your analysis has discovered that the most important factor/predictor is if the input is odd or even, so to merge them would be to blur both of the distributions, and make them less useful (*). *: Of course, it really depends on your definition of useful. I'm approaching it from the viewpoint of you have some inputs and want to make a model to predict some output. Once we know it is significant, I'd want to give the model the hint that the parity of one/some of the inputs matters. By the way, as in Martijn Weterings's answer, when I've had jagged histograms like this before, it has been related to the choice of bin size. It made me realize that experimentation with bin size is yet another tool in the Lying With Stats toolbox :-)
What is this "phenomenon" called? UPDATE: Re-reading this four years later, let me attempt to answer the first part too, what to call it. If it is due to two distinct distributions, as I suggest below, then the combination is called a
35,645
Why does larger perplexity tend to produce clearer clusters in t-SNE?
The larger the perplexity, the more non-local information will be retained in the dimensionality reduction result. Yes, I believe that this is a correct intuition. The way I think about perplexity parameter in t-SNE is that it sets the effective number of neighbours that each point is attracted to. In t-SNE optimisation, all pairs of points are repulsed from each other, but only a small number of pairs feel attractive forces. So if your perplexity is very small, then there will be fewer pairs that feel any attraction and the resulting embedding will tend to be "fluffy": repulsive forces will dominate and will inflate the whole embedding to a bubble-like round shape. On the other hand, if your perplexity is large, clusters will tend to shrink into denser structures. This is a very handway explanation and I must say that I have never seen a good mathematical analysis of this phenomenon (I suspect such an analysis would be nontrivial), but I think it's roughly correct. It is instructive to see it in a simulation. Here I generated a dataset with six 10-dimensional Gaussian balls ($n=1000$ in each ball) that are located very far away from each other --- so far that even for perplexity 100 all attractive forces are within-cluster. So for perplexities between 5 and 100, shown below, there are never any attractive forces between clusters. However, one can clearly see that the clusters "shrink" when perplexity grows. In fact, one can get rid of perplexity entirely, and make each point feel equally strong attraction to its closest $K$ neighbours. This means that I replace the Gaussian kernel in the high-dimensional space with the "uniform" kernel over the closest $K$ neighbours. This should simplify any mathematical analysis and is arguably more intuitive. People are often surprised to see that the result very often looks very similar to the real t-SNE. Here it is for various values of $K$: Code %matplotlib notebook import numpy as np import pylab as plt import seaborn as sns sns.set_style('ticks') # https://github.com/KlugerLab/FIt-SNE import sys; sys.path.append('/home/localadmin/github/FIt-SNE') from fast_tsne import fast_tsne col = np.array(['#a6cee3','#1f78b4','#b2df8a','#33a02c','#fb9a99', '#e31a1c','#fdbf6f','#ff7f00','#cab2d6','#6a3d9a']) n = 1000 # sample size per class p = 10 # dimensionality k = 6 # number of classes d = 10 # distance between each class mean and 0 np.random.seed(42) X = np.random.randn(k*n, p) for i in range(k): X[i*n:(i+1)*n, i] += d perpl = [5, 30, 100] Z1 = [] for p in perpl: Z = fast_tsne(X, perplexity=p, seed=42) Z1.append(Z) ks = [5, 30, 100] Z2 = [] for kk in ks: Z = fast_tsne(X, K=kk, sigma=10000, seed=42) Z2.append(Z) fig = plt.figure(figsize=(7, 3)) for i,Z in enumerate(Z1): plt.subplot(1,3,i+1) plt.axis('equal', adjustable='box') plt.scatter(Z[:,0], Z[:,1], s=1, c=col[np.floor(np.arange(n*k)/n).astype(int)]) plt.title('Perplexity {}'.format(perpl[i])) plt.gca().get_xaxis().set_visible(False) plt.gca().get_yaxis().set_visible(False) sns.despine(left=True, bottom=True) plt.tight_layout() fig = plt.figure(figsize=(7, 3)) for i,Z in enumerate(Z2): plt.subplot(1,3,i+1) plt.axis('equal', adjustable='box') plt.scatter(Z[:,0], Z[:,1], s=1, c=col[np.floor(np.arange(n*k)/n).astype(int)]) plt.title('K = {}'.format(perpl[i])) plt.gca().get_xaxis().set_visible(False) plt.gca().get_yaxis().set_visible(False) sns.despine(left=True, bottom=True) plt.tight_layout()
Why does larger perplexity tend to produce clearer clusters in t-SNE?
The larger the perplexity, the more non-local information will be retained in the dimensionality reduction result. Yes, I believe that this is a correct intuition. The way I think about perplexity p
Why does larger perplexity tend to produce clearer clusters in t-SNE? The larger the perplexity, the more non-local information will be retained in the dimensionality reduction result. Yes, I believe that this is a correct intuition. The way I think about perplexity parameter in t-SNE is that it sets the effective number of neighbours that each point is attracted to. In t-SNE optimisation, all pairs of points are repulsed from each other, but only a small number of pairs feel attractive forces. So if your perplexity is very small, then there will be fewer pairs that feel any attraction and the resulting embedding will tend to be "fluffy": repulsive forces will dominate and will inflate the whole embedding to a bubble-like round shape. On the other hand, if your perplexity is large, clusters will tend to shrink into denser structures. This is a very handway explanation and I must say that I have never seen a good mathematical analysis of this phenomenon (I suspect such an analysis would be nontrivial), but I think it's roughly correct. It is instructive to see it in a simulation. Here I generated a dataset with six 10-dimensional Gaussian balls ($n=1000$ in each ball) that are located very far away from each other --- so far that even for perplexity 100 all attractive forces are within-cluster. So for perplexities between 5 and 100, shown below, there are never any attractive forces between clusters. However, one can clearly see that the clusters "shrink" when perplexity grows. In fact, one can get rid of perplexity entirely, and make each point feel equally strong attraction to its closest $K$ neighbours. This means that I replace the Gaussian kernel in the high-dimensional space with the "uniform" kernel over the closest $K$ neighbours. This should simplify any mathematical analysis and is arguably more intuitive. People are often surprised to see that the result very often looks very similar to the real t-SNE. Here it is for various values of $K$: Code %matplotlib notebook import numpy as np import pylab as plt import seaborn as sns sns.set_style('ticks') # https://github.com/KlugerLab/FIt-SNE import sys; sys.path.append('/home/localadmin/github/FIt-SNE') from fast_tsne import fast_tsne col = np.array(['#a6cee3','#1f78b4','#b2df8a','#33a02c','#fb9a99', '#e31a1c','#fdbf6f','#ff7f00','#cab2d6','#6a3d9a']) n = 1000 # sample size per class p = 10 # dimensionality k = 6 # number of classes d = 10 # distance between each class mean and 0 np.random.seed(42) X = np.random.randn(k*n, p) for i in range(k): X[i*n:(i+1)*n, i] += d perpl = [5, 30, 100] Z1 = [] for p in perpl: Z = fast_tsne(X, perplexity=p, seed=42) Z1.append(Z) ks = [5, 30, 100] Z2 = [] for kk in ks: Z = fast_tsne(X, K=kk, sigma=10000, seed=42) Z2.append(Z) fig = plt.figure(figsize=(7, 3)) for i,Z in enumerate(Z1): plt.subplot(1,3,i+1) plt.axis('equal', adjustable='box') plt.scatter(Z[:,0], Z[:,1], s=1, c=col[np.floor(np.arange(n*k)/n).astype(int)]) plt.title('Perplexity {}'.format(perpl[i])) plt.gca().get_xaxis().set_visible(False) plt.gca().get_yaxis().set_visible(False) sns.despine(left=True, bottom=True) plt.tight_layout() fig = plt.figure(figsize=(7, 3)) for i,Z in enumerate(Z2): plt.subplot(1,3,i+1) plt.axis('equal', adjustable='box') plt.scatter(Z[:,0], Z[:,1], s=1, c=col[np.floor(np.arange(n*k)/n).astype(int)]) plt.title('K = {}'.format(perpl[i])) plt.gca().get_xaxis().set_visible(False) plt.gca().get_yaxis().set_visible(False) sns.despine(left=True, bottom=True) plt.tight_layout()
Why does larger perplexity tend to produce clearer clusters in t-SNE? The larger the perplexity, the more non-local information will be retained in the dimensionality reduction result. Yes, I believe that this is a correct intuition. The way I think about perplexity p
35,646
Why does larger perplexity tend to produce clearer clusters in t-SNE?
I believe this is because of this mismatch in t-SNE between the input (Gaussian) and output (student-t) distributions. It is beneficial to make such blobs in order to separate from everything else as required by the long tail of the t-distribution. The repulsive forces dominate. In such cases SNE may work better. Have you tried?
Why does larger perplexity tend to produce clearer clusters in t-SNE?
I believe this is because of this mismatch in t-SNE between the input (Gaussian) and output (student-t) distributions. It is beneficial to make such blobs in order to separate from everything else as
Why does larger perplexity tend to produce clearer clusters in t-SNE? I believe this is because of this mismatch in t-SNE between the input (Gaussian) and output (student-t) distributions. It is beneficial to make such blobs in order to separate from everything else as required by the long tail of the t-distribution. The repulsive forces dominate. In such cases SNE may work better. Have you tried?
Why does larger perplexity tend to produce clearer clusters in t-SNE? I believe this is because of this mismatch in t-SNE between the input (Gaussian) and output (student-t) distributions. It is beneficial to make such blobs in order to separate from everything else as
35,647
What is the $p$ in Bernoulli distribution?
In the Bayesian theory of probability, probability is our expression of knowledge about a certain thing, not a property of that thing. However, I always see people treat $p$ as a parameter that needs to be estimated. They set up a prior for $p$, usually in the form of a beta function and then update it as "realizations" of this variable come in. This is irrelevant. It has nothing to do with interpreting the meaning of probability, since this is not about philosophy, but about well defined mathematical object. You see people discussing estimating value of $p$ because you look into statistics handbooks and statistics is about estimating things, but $p$ is a parameter of distribution, it can be known, or unknown. If $X$ is a Bernoulli random variable with probability of "success" $p$, then $\Pr(X=1) = p$ by definition. So $p$ is a parameter of this distribution, but it is also probability of "success". This makes me confused, because $p$ is not a probability, since it is a property of the random variable and it is not a frequency, since the variable represents a single event. Yes, random variable describes some "single event", so if you are going to toss a coin, the possible outcome is a random variable because it is uncertain. After you tossed the coin and know the outcome, it is no more random, the outcome is certain. As about probability, in frequentist setting you consider hypothetical scenario where you would repeat the coin tossing experiment huge number of times and the probability would be equal to the proportion of heads among those repetitions. In subjective, Bayesian setting, the probability is a measure of how much do you believe that you will observe heads. The above is however irrelevant to question what $p$ is. It is a parameter that is also equal to probability of "success". The question how do you interpret the probability and what does it mean is a different question.
What is the $p$ in Bernoulli distribution?
In the Bayesian theory of probability, probability is our expression of knowledge about a certain thing, not a property of that thing. However, I always see people treat $p$ as a parameter that ne
What is the $p$ in Bernoulli distribution? In the Bayesian theory of probability, probability is our expression of knowledge about a certain thing, not a property of that thing. However, I always see people treat $p$ as a parameter that needs to be estimated. They set up a prior for $p$, usually in the form of a beta function and then update it as "realizations" of this variable come in. This is irrelevant. It has nothing to do with interpreting the meaning of probability, since this is not about philosophy, but about well defined mathematical object. You see people discussing estimating value of $p$ because you look into statistics handbooks and statistics is about estimating things, but $p$ is a parameter of distribution, it can be known, or unknown. If $X$ is a Bernoulli random variable with probability of "success" $p$, then $\Pr(X=1) = p$ by definition. So $p$ is a parameter of this distribution, but it is also probability of "success". This makes me confused, because $p$ is not a probability, since it is a property of the random variable and it is not a frequency, since the variable represents a single event. Yes, random variable describes some "single event", so if you are going to toss a coin, the possible outcome is a random variable because it is uncertain. After you tossed the coin and know the outcome, it is no more random, the outcome is certain. As about probability, in frequentist setting you consider hypothetical scenario where you would repeat the coin tossing experiment huge number of times and the probability would be equal to the proportion of heads among those repetitions. In subjective, Bayesian setting, the probability is a measure of how much do you believe that you will observe heads. The above is however irrelevant to question what $p$ is. It is a parameter that is also equal to probability of "success". The question how do you interpret the probability and what does it mean is a different question.
What is the $p$ in Bernoulli distribution? In the Bayesian theory of probability, probability is our expression of knowledge about a certain thing, not a property of that thing. However, I always see people treat $p$ as a parameter that ne
35,648
What is the $p$ in Bernoulli distribution?
$p$ is a parameter which specifies the "success probability", for which we have prior and posterior probability distributions. We may for example have a coin for which we are not sure if it is fair ($p=0.5$) or not ($p\neq 0.5$). Even so, fairness, or lack thereof, is a property of the coin. We just happen to be unsure about that property of the coin. We then, for example, specify a beta prior distribution as a prior probability distribution over the possible success probabilites in $[0,1]$. That prior may, for example, be inspired by looking at the coin, assessing if it "looks" fair. If it looks fair, we will be inclined to specify a prior with lots of probability mass around $p=0.5$. In other cases, say, when forming a prior belief about the probability with which a football player will be successful at his next penalty - also a Bernoulli outcome, either a goal or not - we will be inclined to put more probability mass on $p$ around 0.8, because professional football players score on most penalties. We then toss the coin/observe the player a couple of times, and summarize the information in the likelihood function, to obtain the update, i.e., the posterior.
What is the $p$ in Bernoulli distribution?
$p$ is a parameter which specifies the "success probability", for which we have prior and posterior probability distributions. We may for example have a coin for which we are not sure if it is fair (
What is the $p$ in Bernoulli distribution? $p$ is a parameter which specifies the "success probability", for which we have prior and posterior probability distributions. We may for example have a coin for which we are not sure if it is fair ($p=0.5$) or not ($p\neq 0.5$). Even so, fairness, or lack thereof, is a property of the coin. We just happen to be unsure about that property of the coin. We then, for example, specify a beta prior distribution as a prior probability distribution over the possible success probabilites in $[0,1]$. That prior may, for example, be inspired by looking at the coin, assessing if it "looks" fair. If it looks fair, we will be inclined to specify a prior with lots of probability mass around $p=0.5$. In other cases, say, when forming a prior belief about the probability with which a football player will be successful at his next penalty - also a Bernoulli outcome, either a goal or not - we will be inclined to put more probability mass on $p$ around 0.8, because professional football players score on most penalties. We then toss the coin/observe the player a couple of times, and summarize the information in the likelihood function, to obtain the update, i.e., the posterior.
What is the $p$ in Bernoulli distribution? $p$ is a parameter which specifies the "success probability", for which we have prior and posterior probability distributions. We may for example have a coin for which we are not sure if it is fair (
35,649
What is the $p$ in Bernoulli distribution?
For a random variable $X \sim \operatorname{Bernoulli}(p)$ defined on a probability space $(\Omega, \mathcal{F}, P)$, the parameter $p$ (a number) is the probability of a certain event, namely, the event $\{X = 1\}$. That is, $$ p = P(X = 1). $$ The single number $p$ completely determines the distribution of $X$ since for any Borel set $B \subseteq \mathbb{R}$ we have $$ \begin{aligned} P(X \in B) &= \mathbf{1}_B(0)P(X = 0) + \mathbf{1}_B(1) P(X = 1) \\ &= (1 - p) \mathbf{1}_B(0) + p \mathbf{1}_B(1). \end{aligned} $$ (Here $\mathbf{1}_B$ is the indicator function of $B$.) This is why the family of Bernoulli distributions is parametereized by the interval $[0, 1]$. This fact is independent of a frequentist or Bayesian interpretation of statistics: it is just a fact of probability. If we're being Bayesians, then we'd want the parameter $p$ to be a random variable itself with some prior distribution. Formally, we can say that our parameter is a random variable $\Pi$ supported on $[0, 1]$ and we have $$ X \mid \Pi \sim \operatorname{Bernoulli}(\Pi), $$ which means that $$ \begin{aligned} P(X = 1 \mid \Pi) &= \Pi, & P(X = 0 \mid \Pi) &= 1 - \Pi \end{aligned} $$ almost surely (or $$ \begin{aligned} P(X = 1 \mid \Pi = p) &= p, & P(X = 0 \mid \Pi = p) &= 1 - p \end{aligned} $$ for any $p \in [0, 1]$). In this case, the parameter $\Pi$ (a random variable) is the conditional probability of the event $\{X = 1\}$ given $\Pi$. This conditional probability, together with the distribution of $\Pi$ (the prior distribution), completely determines the distribution of $X$ since$$ \begin{aligned} P(X \in B) &= E[P(X \in B \mid \Pi)] \\ &= E[\mathbf{1}_B(0)P(X = 0 \mid \Pi) + \mathbf{1}_B(1) P(X = 1 \mid \Pi)] \\ &= E[(1 - \Pi) \mathbf{1}_B(0) + \Pi \mathbf{1}_B(1)] \\ &= (1 - E[\Pi]) \mathbf{1}_B(0) + E[\Pi] \mathbf{1}_B(1) \end{aligned} $$ for any Borel set $B \subseteq \mathbb{R}$. In any case, frequentist or Bayesian, the usual parameter of Bernoulli data is the probability (either marginal or conditional) of some event.
What is the $p$ in Bernoulli distribution?
For a random variable $X \sim \operatorname{Bernoulli}(p)$ defined on a probability space $(\Omega, \mathcal{F}, P)$, the parameter $p$ (a number) is the probability of a certain event, namely, the ev
What is the $p$ in Bernoulli distribution? For a random variable $X \sim \operatorname{Bernoulli}(p)$ defined on a probability space $(\Omega, \mathcal{F}, P)$, the parameter $p$ (a number) is the probability of a certain event, namely, the event $\{X = 1\}$. That is, $$ p = P(X = 1). $$ The single number $p$ completely determines the distribution of $X$ since for any Borel set $B \subseteq \mathbb{R}$ we have $$ \begin{aligned} P(X \in B) &= \mathbf{1}_B(0)P(X = 0) + \mathbf{1}_B(1) P(X = 1) \\ &= (1 - p) \mathbf{1}_B(0) + p \mathbf{1}_B(1). \end{aligned} $$ (Here $\mathbf{1}_B$ is the indicator function of $B$.) This is why the family of Bernoulli distributions is parametereized by the interval $[0, 1]$. This fact is independent of a frequentist or Bayesian interpretation of statistics: it is just a fact of probability. If we're being Bayesians, then we'd want the parameter $p$ to be a random variable itself with some prior distribution. Formally, we can say that our parameter is a random variable $\Pi$ supported on $[0, 1]$ and we have $$ X \mid \Pi \sim \operatorname{Bernoulli}(\Pi), $$ which means that $$ \begin{aligned} P(X = 1 \mid \Pi) &= \Pi, & P(X = 0 \mid \Pi) &= 1 - \Pi \end{aligned} $$ almost surely (or $$ \begin{aligned} P(X = 1 \mid \Pi = p) &= p, & P(X = 0 \mid \Pi = p) &= 1 - p \end{aligned} $$ for any $p \in [0, 1]$). In this case, the parameter $\Pi$ (a random variable) is the conditional probability of the event $\{X = 1\}$ given $\Pi$. This conditional probability, together with the distribution of $\Pi$ (the prior distribution), completely determines the distribution of $X$ since$$ \begin{aligned} P(X \in B) &= E[P(X \in B \mid \Pi)] \\ &= E[\mathbf{1}_B(0)P(X = 0 \mid \Pi) + \mathbf{1}_B(1) P(X = 1 \mid \Pi)] \\ &= E[(1 - \Pi) \mathbf{1}_B(0) + \Pi \mathbf{1}_B(1)] \\ &= (1 - E[\Pi]) \mathbf{1}_B(0) + E[\Pi] \mathbf{1}_B(1) \end{aligned} $$ for any Borel set $B \subseteq \mathbb{R}$. In any case, frequentist or Bayesian, the usual parameter of Bernoulli data is the probability (either marginal or conditional) of some event.
What is the $p$ in Bernoulli distribution? For a random variable $X \sim \operatorname{Bernoulli}(p)$ defined on a probability space $(\Omega, \mathcal{F}, P)$, the parameter $p$ (a number) is the probability of a certain event, namely, the ev
35,650
Expectation of Inverse Logit of Normal Random Variable
As mentioned already in the question comments and answer by @Martijn there doesn't appear to be an analytical solution for $E(Y)$ apart from the special case where $\mu = 0$ which gives $E(Y) = 0.5$. Additionally by Jensen's inequality we have that $E(Y) = E(f(X)) < f(E(X))$ if $\mu > 0$ and conversely that $E(Y) = E(f(X)) > f(E(X))$ if $\mu < 0$. Since $f(x) = \frac{e^x}{1 + e^x}$ is convex when $x < 0$ and concave when $x > 0$ and most of the normal density mass will lie in those regions depending on the value of $\mu$. There are many ways to approximate $E(Y)$, I have detailed a few I am familiar with and included some R code at the end. Sampling This is quite easy to understand/implement: $$ E(Y) = \int_\infty^\infty f(x) \mathcal{N}(x|\mu, \sigma^2) dx \approx \frac{1}{n} \Sigma_{i = 1}^{n}f(x_i) $$ where we draw samples $x_1, \ldots, x_n$ from $\mathcal{N}(\mu, \sigma^2)$. Numerical integration This includes many methods of approximating the integral above - in the code I used R's integrate function which uses adaptive quadrature. Unscented transform See for example The Unscented Kalman Filter for Nonlinear Estimation by Eric A. Wan and Rudolph van der Merwe which describes: The unscented transformation (UT) is a method for calculating the statistics of a random variable which undergoes a nonlinear transformation The method involves calculating a small number of "sigma points" which are then transformed by $f$ and a weighted mean is taken. This is in contrast to randomly sampling many points, transforming them with $f$ and taking the mean. This method is much more computationally efficient than random sampling. Unfortunately I couldn't find an R implementation online so haven't included it in the code below. Code The following code creates data with different values of $\mu$ and fixed $\sigma$. It outputs f_mu which is $f(E(X))$, and approximations of $E(Y) = E(f(X))$ via sampling and integration. integrate_approx <- function(mu, sigma) { f <- function(x) { plogis(x) * dnorm(x, mu, sigma) } int <- integrate(f, lower = -Inf, upper = Inf) int$value } sampling_approx <- function(mu, sigma, n = 1e6) { x <- rnorm(n, mu, sigma) mean(plogis(x)) } mu <- seq(-2.0, 2.0, by = 0.5) data <- data.frame(mu = mu, sigma = 3.14, f_mu = plogis(mu), sampling = NA, integration = NA) for (i in seq_len(nrow(data))) { mu <- data$mu[i] sigma <- data$sigma[i] data$sampling[i] <- sampling_approx(mu, sigma) data$integration[i] <- integrate_approx(mu, sigma) } output: mu sigma f_mu sampling integration 1 -2.0 3.14 0.1192029 0.2891102 0.2892540 2 -1.5 3.14 0.1824255 0.3382486 0.3384099 3 -1.0 3.14 0.2689414 0.3902008 0.3905315 4 -0.5 3.14 0.3775407 0.4450018 0.4447307 5 0.0 3.14 0.5000000 0.4999657 0.5000000 6 0.5 3.14 0.6224593 0.5553955 0.5552693 7 1.0 3.14 0.7310586 0.6088106 0.6094685 8 1.5 3.14 0.8175745 0.6613919 0.6615901 9 2.0 3.14 0.8807971 0.7105594 0.7107460 EDIT I actually found an easy to use unscented transformation in the python package filterpy (although it is actually quite quick to implement from scratch): import filterpy.kalman as fp import numpy as np import pandas as pd def sigmoid(x): return 1.0 / (1.0 + np.exp(-x)) m = 9 n = 1 z = 1_000_000 alpha = 1e-3 beta = 2.0 kappa = 0.0 means = np.linspace(-2.0, 2.0, m) sigma = 3.14 points = fp.MerweScaledSigmaPoints(n, alpha, beta, kappa) ut = np.empty_like(means) sampling = np.empty_like(means) for i, mean in enumerate(means): sigmas = points.sigma_points(mean, sigma**2) trans_sigmas = sigmoid(sigmas) ut[i], _ = fp.unscented_transform(trans_sigmas, points.Wm, points.Wc) x = np.random.normal(mean, sigma, z) sampling[i] = np.mean(sigmoid(x)) print(pd.DataFrame({"mu": means, "sigma": sigma, "ut": ut, "sampling": sampling})) which outputs: mu sigma ut sampling 0 -2.0 3.14 0.513402 0.288771 1 -1.5 3.14 0.649426 0.338220 2 -1.0 3.14 0.716851 0.390582 3 -0.5 3.14 0.661284 0.444856 4 0.0 3.14 0.500000 0.500382 5 0.5 3.14 0.338716 0.555246 6 1.0 3.14 0.283149 0.609282 7 1.5 3.14 0.350574 0.662106 8 2.0 3.14 0.486598 0.710284 So the unscented transform seems to perform quite poorly for these values of $\mu$ and $\sigma$. This is maybe not surprising since the unscented transform attempts to find the best normal approximation to $Y = f(X)$ and in this case it is far from normal: import matplotlib.pyplot as plt x = np.random.normal(means[0], sigma, z) plt.hist(sigmoid(x), bins=50) plt.title("mu = {}, sigma = {}".format(means[0], sigma)) plt.xlabel("f(x)") plt.show() For smaller values of $\sigma$ it seems to be OK.
Expectation of Inverse Logit of Normal Random Variable
As mentioned already in the question comments and answer by @Martijn there doesn't appear to be an analytical solution for $E(Y)$ apart from the special case where $\mu = 0$ which gives $E(Y) = 0.5$.
Expectation of Inverse Logit of Normal Random Variable As mentioned already in the question comments and answer by @Martijn there doesn't appear to be an analytical solution for $E(Y)$ apart from the special case where $\mu = 0$ which gives $E(Y) = 0.5$. Additionally by Jensen's inequality we have that $E(Y) = E(f(X)) < f(E(X))$ if $\mu > 0$ and conversely that $E(Y) = E(f(X)) > f(E(X))$ if $\mu < 0$. Since $f(x) = \frac{e^x}{1 + e^x}$ is convex when $x < 0$ and concave when $x > 0$ and most of the normal density mass will lie in those regions depending on the value of $\mu$. There are many ways to approximate $E(Y)$, I have detailed a few I am familiar with and included some R code at the end. Sampling This is quite easy to understand/implement: $$ E(Y) = \int_\infty^\infty f(x) \mathcal{N}(x|\mu, \sigma^2) dx \approx \frac{1}{n} \Sigma_{i = 1}^{n}f(x_i) $$ where we draw samples $x_1, \ldots, x_n$ from $\mathcal{N}(\mu, \sigma^2)$. Numerical integration This includes many methods of approximating the integral above - in the code I used R's integrate function which uses adaptive quadrature. Unscented transform See for example The Unscented Kalman Filter for Nonlinear Estimation by Eric A. Wan and Rudolph van der Merwe which describes: The unscented transformation (UT) is a method for calculating the statistics of a random variable which undergoes a nonlinear transformation The method involves calculating a small number of "sigma points" which are then transformed by $f$ and a weighted mean is taken. This is in contrast to randomly sampling many points, transforming them with $f$ and taking the mean. This method is much more computationally efficient than random sampling. Unfortunately I couldn't find an R implementation online so haven't included it in the code below. Code The following code creates data with different values of $\mu$ and fixed $\sigma$. It outputs f_mu which is $f(E(X))$, and approximations of $E(Y) = E(f(X))$ via sampling and integration. integrate_approx <- function(mu, sigma) { f <- function(x) { plogis(x) * dnorm(x, mu, sigma) } int <- integrate(f, lower = -Inf, upper = Inf) int$value } sampling_approx <- function(mu, sigma, n = 1e6) { x <- rnorm(n, mu, sigma) mean(plogis(x)) } mu <- seq(-2.0, 2.0, by = 0.5) data <- data.frame(mu = mu, sigma = 3.14, f_mu = plogis(mu), sampling = NA, integration = NA) for (i in seq_len(nrow(data))) { mu <- data$mu[i] sigma <- data$sigma[i] data$sampling[i] <- sampling_approx(mu, sigma) data$integration[i] <- integrate_approx(mu, sigma) } output: mu sigma f_mu sampling integration 1 -2.0 3.14 0.1192029 0.2891102 0.2892540 2 -1.5 3.14 0.1824255 0.3382486 0.3384099 3 -1.0 3.14 0.2689414 0.3902008 0.3905315 4 -0.5 3.14 0.3775407 0.4450018 0.4447307 5 0.0 3.14 0.5000000 0.4999657 0.5000000 6 0.5 3.14 0.6224593 0.5553955 0.5552693 7 1.0 3.14 0.7310586 0.6088106 0.6094685 8 1.5 3.14 0.8175745 0.6613919 0.6615901 9 2.0 3.14 0.8807971 0.7105594 0.7107460 EDIT I actually found an easy to use unscented transformation in the python package filterpy (although it is actually quite quick to implement from scratch): import filterpy.kalman as fp import numpy as np import pandas as pd def sigmoid(x): return 1.0 / (1.0 + np.exp(-x)) m = 9 n = 1 z = 1_000_000 alpha = 1e-3 beta = 2.0 kappa = 0.0 means = np.linspace(-2.0, 2.0, m) sigma = 3.14 points = fp.MerweScaledSigmaPoints(n, alpha, beta, kappa) ut = np.empty_like(means) sampling = np.empty_like(means) for i, mean in enumerate(means): sigmas = points.sigma_points(mean, sigma**2) trans_sigmas = sigmoid(sigmas) ut[i], _ = fp.unscented_transform(trans_sigmas, points.Wm, points.Wc) x = np.random.normal(mean, sigma, z) sampling[i] = np.mean(sigmoid(x)) print(pd.DataFrame({"mu": means, "sigma": sigma, "ut": ut, "sampling": sampling})) which outputs: mu sigma ut sampling 0 -2.0 3.14 0.513402 0.288771 1 -1.5 3.14 0.649426 0.338220 2 -1.0 3.14 0.716851 0.390582 3 -0.5 3.14 0.661284 0.444856 4 0.0 3.14 0.500000 0.500382 5 0.5 3.14 0.338716 0.555246 6 1.0 3.14 0.283149 0.609282 7 1.5 3.14 0.350574 0.662106 8 2.0 3.14 0.486598 0.710284 So the unscented transform seems to perform quite poorly for these values of $\mu$ and $\sigma$. This is maybe not surprising since the unscented transform attempts to find the best normal approximation to $Y = f(X)$ and in this case it is far from normal: import matplotlib.pyplot as plt x = np.random.normal(means[0], sigma, z) plt.hist(sigmoid(x), bins=50) plt.title("mu = {}, sigma = {}".format(means[0], sigma)) plt.xlabel("f(x)") plt.show() For smaller values of $\sigma$ it seems to be OK.
Expectation of Inverse Logit of Normal Random Variable As mentioned already in the question comments and answer by @Martijn there doesn't appear to be an analytical solution for $E(Y)$ apart from the special case where $\mu = 0$ which gives $E(Y) = 0.5$.
35,651
Expectation of Inverse Logit of Normal Random Variable
The variable $Y$ has a logit normal or logistic normal distribution whose moments have no known analytical description. You can obtain the values computationally. More about these distributions is described in a freely available article: Atchison, J., and Sheng M. Shen. "Logistic-normal distributions: Some properties and uses." Biometrika 67.2 (1980): 261-272. In that text they do not give any expressions for limits, approximations or behavior of the moments (except mentioning that they exist). But, they do continue with expressions for the expectation value for the ratio of two components in a multivariate logistic normal distributed variable.
Expectation of Inverse Logit of Normal Random Variable
The variable $Y$ has a logit normal or logistic normal distribution whose moments have no known analytical description. You can obtain the values computationally. More about these distributions is des
Expectation of Inverse Logit of Normal Random Variable The variable $Y$ has a logit normal or logistic normal distribution whose moments have no known analytical description. You can obtain the values computationally. More about these distributions is described in a freely available article: Atchison, J., and Sheng M. Shen. "Logistic-normal distributions: Some properties and uses." Biometrika 67.2 (1980): 261-272. In that text they do not give any expressions for limits, approximations or behavior of the moments (except mentioning that they exist). But, they do continue with expressions for the expectation value for the ratio of two components in a multivariate logistic normal distributed variable.
Expectation of Inverse Logit of Normal Random Variable The variable $Y$ has a logit normal or logistic normal distribution whose moments have no known analytical description. You can obtain the values computationally. More about these distributions is des
35,652
What is the difference between $E[\varepsilon\mid X]=0$ and $E[\varepsilon X]=0$ in OLS regression?
I'm just looking from a probabilistic perspective, and looking forward to hear other ideas. Using law of iterated expectations, we have $$E[\epsilon X]=E[E[\epsilon X\mid X]]=E[X E[\epsilon\mid X]]$$ If $E[\epsilon\mid X]$ is $0,$ then automatically, $E[\epsilon X]$ is $0.$ But, the other way around is not true, which means $E[\epsilon X]$ is a weaker condition.
What is the difference between $E[\varepsilon\mid X]=0$ and $E[\varepsilon X]=0$ in OLS regression?
I'm just looking from a probabilistic perspective, and looking forward to hear other ideas. Using law of iterated expectations, we have $$E[\epsilon X]=E[E[\epsilon X\mid X]]=E[X E[\epsilon\mid X]]$$
What is the difference between $E[\varepsilon\mid X]=0$ and $E[\varepsilon X]=0$ in OLS regression? I'm just looking from a probabilistic perspective, and looking forward to hear other ideas. Using law of iterated expectations, we have $$E[\epsilon X]=E[E[\epsilon X\mid X]]=E[X E[\epsilon\mid X]]$$ If $E[\epsilon\mid X]$ is $0,$ then automatically, $E[\epsilon X]$ is $0.$ But, the other way around is not true, which means $E[\epsilon X]$ is a weaker condition.
What is the difference between $E[\varepsilon\mid X]=0$ and $E[\varepsilon X]=0$ in OLS regression? I'm just looking from a probabilistic perspective, and looking forward to hear other ideas. Using law of iterated expectations, we have $$E[\epsilon X]=E[E[\epsilon X\mid X]]=E[X E[\epsilon\mid X]]$$
35,653
Consistent unbiased estimator for the location parameter of $\mathcal{Cauchy} (\theta, 1)$
By googling the keyword 'estimation of location parameter of Cauchy distribution', I gather that this has been a pretty well-studied problem. Similar to the answer by Robin Ryder, I suggest taking a look at the paper A Note on Estimation from a Cauchy Sample (Rothenberg et al., 1964) for an unbiased estimator of $\theta$ for a $C(\theta,1)$ distribution based on a sample of size $n$. Quoting the relevant result from Exercise 8.8.6 (page 237) of Order Statistics, third edition, by David and Nagaraja, which cites the above paper as reference: For samples of $n=2m+1 \quad(m=0,1,\ldots)$ from the Cauchy distribution $$f(x)=\frac{1}{\pi(1+(x-\theta)^2)}\qquad,\,-\infty<x<\infty$$ , the trimmed mean $$\frac{1}{n-2[nk]}\sum_{i=m-[nk]}^{m+[nk]}X_{(i)}\qquad,\,0\le k\le \frac{1}{2}$$ is an unbiased estimator of $\theta$ with asymptotic variance $$\frac{1}{nk}\left[\frac{1-k}{k}\tan^2\left(\frac{\pi k}{2}\right)+\frac{2}{\pi k}\tan\left(\frac{\pi k}{2}\right)-1\right]$$ This is a minimum for $k=0.24$, when the trimmed mean is almost the midmean.
Consistent unbiased estimator for the location parameter of $\mathcal{Cauchy} (\theta, 1)$
By googling the keyword 'estimation of location parameter of Cauchy distribution', I gather that this has been a pretty well-studied problem. Similar to the answer by Robin Ryder, I suggest taking a l
Consistent unbiased estimator for the location parameter of $\mathcal{Cauchy} (\theta, 1)$ By googling the keyword 'estimation of location parameter of Cauchy distribution', I gather that this has been a pretty well-studied problem. Similar to the answer by Robin Ryder, I suggest taking a look at the paper A Note on Estimation from a Cauchy Sample (Rothenberg et al., 1964) for an unbiased estimator of $\theta$ for a $C(\theta,1)$ distribution based on a sample of size $n$. Quoting the relevant result from Exercise 8.8.6 (page 237) of Order Statistics, third edition, by David and Nagaraja, which cites the above paper as reference: For samples of $n=2m+1 \quad(m=0,1,\ldots)$ from the Cauchy distribution $$f(x)=\frac{1}{\pi(1+(x-\theta)^2)}\qquad,\,-\infty<x<\infty$$ , the trimmed mean $$\frac{1}{n-2[nk]}\sum_{i=m-[nk]}^{m+[nk]}X_{(i)}\qquad,\,0\le k\le \frac{1}{2}$$ is an unbiased estimator of $\theta$ with asymptotic variance $$\frac{1}{nk}\left[\frac{1-k}{k}\tan^2\left(\frac{\pi k}{2}\right)+\frac{2}{\pi k}\tan\left(\frac{\pi k}{2}\right)-1\right]$$ This is a minimum for $k=0.24$, when the trimmed mean is almost the midmean.
Consistent unbiased estimator for the location parameter of $\mathcal{Cauchy} (\theta, 1)$ By googling the keyword 'estimation of location parameter of Cauchy distribution', I gather that this has been a pretty well-studied problem. Similar to the answer by Robin Ryder, I suggest taking a l
35,654
Consistent unbiased estimator for the location parameter of $\mathcal{Cauchy} (\theta, 1)$
Indeed, computing the MLE is complicated. The most straightforward choice is to use the sample median, which is consistent, but there are more efficient estimators available. Zhang (2010) shows that a more efficient estimator is to take the mean of the central 24% of the data, i.e. use the order statistics $X_{(1)}\leq X_{(2)}\leq\ldots\leq X_{(n)}$, take $r=\lfloor 0.38n\rfloor$ and $$T_n = \frac{1}{n-2r}\sum_{i=r+1}^{n-r}X_{(i)}$$ The efficiency of the estimator $T_n$ is 88% of the Cramér-Rao bound, whereas the sample median has an efficiency of 81%. The paper by Zhang also suggests other estimators, which are more complicated but can achieve a higher efficiency.
Consistent unbiased estimator for the location parameter of $\mathcal{Cauchy} (\theta, 1)$
Indeed, computing the MLE is complicated. The most straightforward choice is to use the sample median, which is consistent, but there are more efficient estimators available. Zhang (2010) shows that a
Consistent unbiased estimator for the location parameter of $\mathcal{Cauchy} (\theta, 1)$ Indeed, computing the MLE is complicated. The most straightforward choice is to use the sample median, which is consistent, but there are more efficient estimators available. Zhang (2010) shows that a more efficient estimator is to take the mean of the central 24% of the data, i.e. use the order statistics $X_{(1)}\leq X_{(2)}\leq\ldots\leq X_{(n)}$, take $r=\lfloor 0.38n\rfloor$ and $$T_n = \frac{1}{n-2r}\sum_{i=r+1}^{n-r}X_{(i)}$$ The efficiency of the estimator $T_n$ is 88% of the Cramér-Rao bound, whereas the sample median has an efficiency of 81%. The paper by Zhang also suggests other estimators, which are more complicated but can achieve a higher efficiency.
Consistent unbiased estimator for the location parameter of $\mathcal{Cauchy} (\theta, 1)$ Indeed, computing the MLE is complicated. The most straightforward choice is to use the sample median, which is consistent, but there are more efficient estimators available. Zhang (2010) shows that a
35,655
Consistent unbiased estimator for the location parameter of $\mathcal{Cauchy} (\theta, 1)$
This is an answer I've only just come up with, so there might be a mistake somewhere. First I use a demonstration to show you how this works, and then give you a consistent estimator. Assume for the sake of demonstraton that $EX$ exists. That is, $EX < \infty$, and take it as the mode of the distribution as with other symmetric bell-curve distributions. It can be proven that under certain regularity conditions, order statistics are consistent estimators of their associated quantiles. For example, let $\tau \in (0,1)$, let $f$ be a continuous density function such that $f(\tau) > 0$ Define $k = [n\tau]$ where $n$ is your sample size and $[-]$ denotes the integer part of $n\tau$. Finally, define $\epsilon_\tau$ as the $\tau$th quantile of the density $f$. That is, $\epsilon_\tau$ is the smallest value such that $F(\epsilon_\tau) = \tau$ Then given the continuity of $f$ along with $f(\tau) > 0$ we can prove that $$X_{(k)} \to \epsilon_\tau$$ almost surely, where $k$ is the $k$th order statistic of the sample $X_1, \dots, X_n$ (the $k$th largest value). But note the following! The Cauchy density is continuous and $f(0.5) > 0$. The mean (if it existed!) of the Cauchy distribution is also the median $$P(X < m)=P(X>m)=0.5$$ Hence taking $\tau = 0.5$ and noting that since the Cauchy as equal mean and median, the above statement implies that $$X_{(k)} \to E[X]$$ almost surely, where again $k = [\tau n] = [0.5 n]$. Hence the $k$th order statistic is a consistent estimator of $E[X]$. Returning to your problem The above shows that if you can find a value $\tau_\theta$ such that $F(\theta) = \tau_\theta$, then $X_{(k)}$ will be a consistent estimator of $\theta$, where once again $k =[n \tau_\theta]$. The CDF of the $Cauchy(\theta,1)$ distribution is $$F(x) = \frac{1}{\pi} \tan^{-1} \left( x-\theta \right) + \frac{1}{2}$$ So to obtain $\tau_\theta$ we simply need to solve the following for $y$: $$y = \frac{1}{\pi} \tan^{-1} \left( \theta-\theta \right) + \frac{1}{2}$$ But $\tan^{-1}(0) = 0$, hence $$y = \frac{1}{2}$$. Thus, finally, a consistent estimator of $\theta$ is $X_{(k)}$ where $k = [0.5 n]$ and $X_{(k)}$ is again the $k$th order statistic. That is, the median is a consistent estimator of $\theta$.
Consistent unbiased estimator for the location parameter of $\mathcal{Cauchy} (\theta, 1)$
This is an answer I've only just come up with, so there might be a mistake somewhere. First I use a demonstration to show you how this works, and then give you a consistent estimator. Assume for the
Consistent unbiased estimator for the location parameter of $\mathcal{Cauchy} (\theta, 1)$ This is an answer I've only just come up with, so there might be a mistake somewhere. First I use a demonstration to show you how this works, and then give you a consistent estimator. Assume for the sake of demonstraton that $EX$ exists. That is, $EX < \infty$, and take it as the mode of the distribution as with other symmetric bell-curve distributions. It can be proven that under certain regularity conditions, order statistics are consistent estimators of their associated quantiles. For example, let $\tau \in (0,1)$, let $f$ be a continuous density function such that $f(\tau) > 0$ Define $k = [n\tau]$ where $n$ is your sample size and $[-]$ denotes the integer part of $n\tau$. Finally, define $\epsilon_\tau$ as the $\tau$th quantile of the density $f$. That is, $\epsilon_\tau$ is the smallest value such that $F(\epsilon_\tau) = \tau$ Then given the continuity of $f$ along with $f(\tau) > 0$ we can prove that $$X_{(k)} \to \epsilon_\tau$$ almost surely, where $k$ is the $k$th order statistic of the sample $X_1, \dots, X_n$ (the $k$th largest value). But note the following! The Cauchy density is continuous and $f(0.5) > 0$. The mean (if it existed!) of the Cauchy distribution is also the median $$P(X < m)=P(X>m)=0.5$$ Hence taking $\tau = 0.5$ and noting that since the Cauchy as equal mean and median, the above statement implies that $$X_{(k)} \to E[X]$$ almost surely, where again $k = [\tau n] = [0.5 n]$. Hence the $k$th order statistic is a consistent estimator of $E[X]$. Returning to your problem The above shows that if you can find a value $\tau_\theta$ such that $F(\theta) = \tau_\theta$, then $X_{(k)}$ will be a consistent estimator of $\theta$, where once again $k =[n \tau_\theta]$. The CDF of the $Cauchy(\theta,1)$ distribution is $$F(x) = \frac{1}{\pi} \tan^{-1} \left( x-\theta \right) + \frac{1}{2}$$ So to obtain $\tau_\theta$ we simply need to solve the following for $y$: $$y = \frac{1}{\pi} \tan^{-1} \left( \theta-\theta \right) + \frac{1}{2}$$ But $\tan^{-1}(0) = 0$, hence $$y = \frac{1}{2}$$. Thus, finally, a consistent estimator of $\theta$ is $X_{(k)}$ where $k = [0.5 n]$ and $X_{(k)}$ is again the $k$th order statistic. That is, the median is a consistent estimator of $\theta$.
Consistent unbiased estimator for the location parameter of $\mathcal{Cauchy} (\theta, 1)$ This is an answer I've only just come up with, so there might be a mistake somewhere. First I use a demonstration to show you how this works, and then give you a consistent estimator. Assume for the
35,656
Connection between filters and feature map in CNN
Your confusion stems from the fact that channels (feature maps) are treated somewhat differently than other dimensions. Let's say you have a grayscale image input to the first layer and 32 kernels of shape (3,3) as per your example. But in fact, those kernels have shape (3,3,1) - 1 for the number of channels in the input. For a RGB input image it would be 3. The number of channels is simply omitted in the code because it is inferred automatically from the number of channels of the layer input. The output of this layer has 32 channels (1 per each kernel). In the second layer in your example, you have 64 kernels of shape (3,3), but they are in fact (3,3,32)! Each of these kernels is aggregating information from all input feature maps. Typically I would think that with 64 filters and 32 feature maps from the previous layer we would get 64*32 feature maps in the next layer (all features are connected to each filter). I hope that from the above explanation it is clear that you are not applying each of the 64 kernels on each of the 32 feature maps individually. Instead, each of these 64 kernels is looking at all of the 32 feature maps at the same time, having different weights for each of them.
Connection between filters and feature map in CNN
Your confusion stems from the fact that channels (feature maps) are treated somewhat differently than other dimensions. Let's say you have a grayscale image input to the first layer and 32 kernels of
Connection between filters and feature map in CNN Your confusion stems from the fact that channels (feature maps) are treated somewhat differently than other dimensions. Let's say you have a grayscale image input to the first layer and 32 kernels of shape (3,3) as per your example. But in fact, those kernels have shape (3,3,1) - 1 for the number of channels in the input. For a RGB input image it would be 3. The number of channels is simply omitted in the code because it is inferred automatically from the number of channels of the layer input. The output of this layer has 32 channels (1 per each kernel). In the second layer in your example, you have 64 kernels of shape (3,3), but they are in fact (3,3,32)! Each of these kernels is aggregating information from all input feature maps. Typically I would think that with 64 filters and 32 feature maps from the previous layer we would get 64*32 feature maps in the next layer (all features are connected to each filter). I hope that from the above explanation it is clear that you are not applying each of the 64 kernels on each of the 32 feature maps individually. Instead, each of these 64 kernels is looking at all of the 32 feature maps at the same time, having different weights for each of them.
Connection between filters and feature map in CNN Your confusion stems from the fact that channels (feature maps) are treated somewhat differently than other dimensions. Let's say you have a grayscale image input to the first layer and 32 kernels of
35,657
Does Regularized Logistic Regression Produce Calibrated Results?
The answer depends entirely on the amount of penalization used. If too little, the model will be seen to be overfitted when evaluated on an independent sample. If too much penality, it will be found to be underfitted. The goal is to solve for the penalty that gets it "just right". Two ways to do this are cross-validation (e.g., 100 repeats of 10-fold cross-validation) or computing the effective AIC and solving for the penalty that optimizes it. The calibration curve is the plot of x=predicted probability of the event vs. y=actual probability of the event. The actual probability is obtained (in an independent sample, or using the bootstrap to correct the "apparent" calibration) by running a smoother on $(\hat{P}, Y)$, where $Y$ is the vector of binary outcomes. If the calibration curve is linear, it can be summarized by its intercept and slope. When the slope is greater than 1 there is underfitting, and when the slope is less than 1 there is overfitting (regression to the mean; low $\hat{P}$ are too low and high ones are too high). The Bayesian approach to this has major advantages over what is described above, including: the penalty is automatically estimated if you do a reasonable job of specifying a prior distribution for the penalty parameters (usually stated in terms of the reciprocal, i.e., the variance of random effects) once finished, the Bayesian posterior distribution works exactly as it should, whereas the frequentist approach does not give us confidence intervals or hypothesis tests once penalization is used
Does Regularized Logistic Regression Produce Calibrated Results?
The answer depends entirely on the amount of penalization used. If too little, the model will be seen to be overfitted when evaluated on an independent sample. If too much penality, it will be found
Does Regularized Logistic Regression Produce Calibrated Results? The answer depends entirely on the amount of penalization used. If too little, the model will be seen to be overfitted when evaluated on an independent sample. If too much penality, it will be found to be underfitted. The goal is to solve for the penalty that gets it "just right". Two ways to do this are cross-validation (e.g., 100 repeats of 10-fold cross-validation) or computing the effective AIC and solving for the penalty that optimizes it. The calibration curve is the plot of x=predicted probability of the event vs. y=actual probability of the event. The actual probability is obtained (in an independent sample, or using the bootstrap to correct the "apparent" calibration) by running a smoother on $(\hat{P}, Y)$, where $Y$ is the vector of binary outcomes. If the calibration curve is linear, it can be summarized by its intercept and slope. When the slope is greater than 1 there is underfitting, and when the slope is less than 1 there is overfitting (regression to the mean; low $\hat{P}$ are too low and high ones are too high). The Bayesian approach to this has major advantages over what is described above, including: the penalty is automatically estimated if you do a reasonable job of specifying a prior distribution for the penalty parameters (usually stated in terms of the reciprocal, i.e., the variance of random effects) once finished, the Bayesian posterior distribution works exactly as it should, whereas the frequentist approach does not give us confidence intervals or hypothesis tests once penalization is used
Does Regularized Logistic Regression Produce Calibrated Results? The answer depends entirely on the amount of penalization used. If too little, the model will be seen to be overfitted when evaluated on an independent sample. If too much penality, it will be found
35,658
General conditional distributions for multivariate Gaussian mixtures
So, after a little while, I am able to answer my own question :) According to the definition of conditional density, we have $$ f(\vec{x_a} | \vec{x_b}) = \frac{f(\vec{x_a}, \vec{x_b})}{f(\vec{x_b})} = \sum_{k=1}^{n} \frac{\pi_k}{f(\vec{x_b})} \mathcal{N}(\vec{x} | \mu_k, \Sigma_k). $$ where $ f(\vec{x_b}) $ is the marginal distribution. This can be calculated in terms of 1) the marginals and conditionals of multivariate Gaussians 2) the marginals of multivariate Gaussian mixtures. Suppose that $ \mu $ and $ \Sigma $ is partitioned as $$ \mu = (\mu_a, \mu_b) \text{ and } \Sigma = \begin{pmatrix} \Sigma_{aa} & \Sigma_{ab} \\ \Sigma_{ba} & \Sigma_{bb} \end{pmatrix}. $$ According to Bishop, Pattern Recognition and Machine Learning, Chapter 2.3.1-2.3.2, the conditional distributions of multivariate Gaussians can be calculated as $$ \mathcal{N}(\vec{x_a} | \vec{x_b}, \mu, \Sigma) = \mathcal{N}(\vec{x_a} | \mu_{a|b}, \Sigma_{a|b}), $$ where $$ \begin{aligned} \mu_{a|b} & = \mu_a + \Sigma_{ab}\Sigma_{bb}^{-1}(x_b - \mu_b) \\ \Sigma_{a|b} & = \Sigma_{aa} - \Sigma_{ab}\Sigma_{bb}^{-1} \Sigma_{ba}, \end{aligned} $$ while the marginal is simply given by $ \mathcal{N}(\vec{x_b} | \mu_b, \Sigma_{bb}) $. Regarding the marginal of the MGM, we simply have $$ f(\vec{x_b}) = \sum_{k=1}^{n} \pi_k \mathcal{N}(\vec{x_b} | \mu_{k, b}, \Sigma_{k, bb}), $$ so by continuing the calculation, we have $$ \begin{aligned} f(\vec{x_a} | \vec{x_b}) &= \sum_{k=1}^{n} \frac{\pi_k}{f(\vec{x_b})} \mathcal{N}(\vec{x} | \mu_k, \Sigma_k) \\ & = \sum_{k=1}^{n} \frac{\pi_k \mathcal{N}(\vec{x_b} | \mu_{k, b}, \Sigma_{k, bb})}{f(\vec{x_b})} \mathcal{N}(\vec{x_a} | \mu_{k, a|b}, \Sigma_{k, a|b}) \\ & = \sum_{k=1}^{n} \frac{\pi_k \mathcal{N}(\vec{x_b} | \mu_{k, b}, \Sigma_{k, bb})}{\sum_{l=1}^{n} \pi_l \mathcal{N}(\vec{x_b} | \mu_{l, b}, \Sigma_{l, bb})} \mathcal{N}(\vec{x_a} | \mu_{k, a|b}, \Sigma_{k, a|b}). \end{aligned} $$ Thus, it is indeed a multivariate Gaussian mixture with components $ \mathcal{N}(\vec{x_a} | \mu_{k, a|b}, \Sigma_{k, a|b}) $ and mixing coefficients $$ \pi_{k, a|b} = \frac{\pi_k \mathcal{N}(\vec{x_b} | \mu_{k, b}, \Sigma_{k, bb})}{\sum_{l=1}^{n} \pi_l \mathcal{N}(\vec{x_b} | \mu_{l, b}, \Sigma_{l, bb})}. $$
General conditional distributions for multivariate Gaussian mixtures
So, after a little while, I am able to answer my own question :) According to the definition of conditional density, we have $$ f(\vec{x_a} | \vec{x_b}) = \frac{f(\vec{x_a}, \vec{x_b})}{f(\vec{x_b})}
General conditional distributions for multivariate Gaussian mixtures So, after a little while, I am able to answer my own question :) According to the definition of conditional density, we have $$ f(\vec{x_a} | \vec{x_b}) = \frac{f(\vec{x_a}, \vec{x_b})}{f(\vec{x_b})} = \sum_{k=1}^{n} \frac{\pi_k}{f(\vec{x_b})} \mathcal{N}(\vec{x} | \mu_k, \Sigma_k). $$ where $ f(\vec{x_b}) $ is the marginal distribution. This can be calculated in terms of 1) the marginals and conditionals of multivariate Gaussians 2) the marginals of multivariate Gaussian mixtures. Suppose that $ \mu $ and $ \Sigma $ is partitioned as $$ \mu = (\mu_a, \mu_b) \text{ and } \Sigma = \begin{pmatrix} \Sigma_{aa} & \Sigma_{ab} \\ \Sigma_{ba} & \Sigma_{bb} \end{pmatrix}. $$ According to Bishop, Pattern Recognition and Machine Learning, Chapter 2.3.1-2.3.2, the conditional distributions of multivariate Gaussians can be calculated as $$ \mathcal{N}(\vec{x_a} | \vec{x_b}, \mu, \Sigma) = \mathcal{N}(\vec{x_a} | \mu_{a|b}, \Sigma_{a|b}), $$ where $$ \begin{aligned} \mu_{a|b} & = \mu_a + \Sigma_{ab}\Sigma_{bb}^{-1}(x_b - \mu_b) \\ \Sigma_{a|b} & = \Sigma_{aa} - \Sigma_{ab}\Sigma_{bb}^{-1} \Sigma_{ba}, \end{aligned} $$ while the marginal is simply given by $ \mathcal{N}(\vec{x_b} | \mu_b, \Sigma_{bb}) $. Regarding the marginal of the MGM, we simply have $$ f(\vec{x_b}) = \sum_{k=1}^{n} \pi_k \mathcal{N}(\vec{x_b} | \mu_{k, b}, \Sigma_{k, bb}), $$ so by continuing the calculation, we have $$ \begin{aligned} f(\vec{x_a} | \vec{x_b}) &= \sum_{k=1}^{n} \frac{\pi_k}{f(\vec{x_b})} \mathcal{N}(\vec{x} | \mu_k, \Sigma_k) \\ & = \sum_{k=1}^{n} \frac{\pi_k \mathcal{N}(\vec{x_b} | \mu_{k, b}, \Sigma_{k, bb})}{f(\vec{x_b})} \mathcal{N}(\vec{x_a} | \mu_{k, a|b}, \Sigma_{k, a|b}) \\ & = \sum_{k=1}^{n} \frac{\pi_k \mathcal{N}(\vec{x_b} | \mu_{k, b}, \Sigma_{k, bb})}{\sum_{l=1}^{n} \pi_l \mathcal{N}(\vec{x_b} | \mu_{l, b}, \Sigma_{l, bb})} \mathcal{N}(\vec{x_a} | \mu_{k, a|b}, \Sigma_{k, a|b}). \end{aligned} $$ Thus, it is indeed a multivariate Gaussian mixture with components $ \mathcal{N}(\vec{x_a} | \mu_{k, a|b}, \Sigma_{k, a|b}) $ and mixing coefficients $$ \pi_{k, a|b} = \frac{\pi_k \mathcal{N}(\vec{x_b} | \mu_{k, b}, \Sigma_{k, bb})}{\sum_{l=1}^{n} \pi_l \mathcal{N}(\vec{x_b} | \mu_{l, b}, \Sigma_{l, bb})}. $$
General conditional distributions for multivariate Gaussian mixtures So, after a little while, I am able to answer my own question :) According to the definition of conditional density, we have $$ f(\vec{x_a} | \vec{x_b}) = \frac{f(\vec{x_a}, \vec{x_b})}{f(\vec{x_b})}
35,659
In binary classification, in what specific case should I use accuracy, AUROC, logloss or Brier score to choose model?
To elaborate on some of the comments. Most models give a probability output--- say 0.78. If you convert this to a 1, then you have made a "decision". Accuracy, ROC, precision, recall, are all functions of decisions; log likelihood, brier score are functions of probabilities. Often, it's best to leave the decision to the end user, but there are notable exceptions (machine translation, speech recognition (the end user is the computer), self driving cars). Accuracy Better to not. Perhaps with balanced classes. AUROC This just gives sensitivity and specificity as you vary the threshold. Applications include validation in poorly written papers on risk prediction :). Seriously, though, use it if you are interested in providing binary decisions (1 or 0) as output, not a probability estimate. This is important for example when you are guiding a self driving car that must make decisions quickly as to what is road and what is not---and the cost of a false positive is identical to the cost of a false negative. F1 score A combination of precision and recall. Application: document retrieval. Generally document retrieval and NLP tasks like machine translation use these metrics because a decision is made (e.g., in machine translation, you want a sentence as output, not some probability distribution over sentences). Precision, in contrast to sensitivity and specificity, depends on prevalence. Therefore it is a good metric for very rare classes, like in document retrieval. logloss If you're interested in probability estimates and have a well-specified predictive model. This is the loss function when you minimize the negative log likelihood of a collection of independent Bernoulli random variables. This is related to the probability of your dataset using your estimated parameters. Application: risk score, prediction. Eg, what's the probability of disease or of defaulting on a loan. Brier score If you're interested in probability estimates, this is basically a measure of how close (using mean squared error) your estimates are numerically to the actual probabilities. This is nice because it's kind of bounded as opposed to log loss, but I have found it to be kind of insensitive.
In binary classification, in what specific case should I use accuracy, AUROC, logloss or Brier score
To elaborate on some of the comments. Most models give a probability output--- say 0.78. If you convert this to a 1, then you have made a "decision". Accuracy, ROC, precision, recall, are all funct
In binary classification, in what specific case should I use accuracy, AUROC, logloss or Brier score to choose model? To elaborate on some of the comments. Most models give a probability output--- say 0.78. If you convert this to a 1, then you have made a "decision". Accuracy, ROC, precision, recall, are all functions of decisions; log likelihood, brier score are functions of probabilities. Often, it's best to leave the decision to the end user, but there are notable exceptions (machine translation, speech recognition (the end user is the computer), self driving cars). Accuracy Better to not. Perhaps with balanced classes. AUROC This just gives sensitivity and specificity as you vary the threshold. Applications include validation in poorly written papers on risk prediction :). Seriously, though, use it if you are interested in providing binary decisions (1 or 0) as output, not a probability estimate. This is important for example when you are guiding a self driving car that must make decisions quickly as to what is road and what is not---and the cost of a false positive is identical to the cost of a false negative. F1 score A combination of precision and recall. Application: document retrieval. Generally document retrieval and NLP tasks like machine translation use these metrics because a decision is made (e.g., in machine translation, you want a sentence as output, not some probability distribution over sentences). Precision, in contrast to sensitivity and specificity, depends on prevalence. Therefore it is a good metric for very rare classes, like in document retrieval. logloss If you're interested in probability estimates and have a well-specified predictive model. This is the loss function when you minimize the negative log likelihood of a collection of independent Bernoulli random variables. This is related to the probability of your dataset using your estimated parameters. Application: risk score, prediction. Eg, what's the probability of disease or of defaulting on a loan. Brier score If you're interested in probability estimates, this is basically a measure of how close (using mean squared error) your estimates are numerically to the actual probabilities. This is nice because it's kind of bounded as opposed to log loss, but I have found it to be kind of insensitive.
In binary classification, in what specific case should I use accuracy, AUROC, logloss or Brier score To elaborate on some of the comments. Most models give a probability output--- say 0.78. If you convert this to a 1, then you have made a "decision". Accuracy, ROC, precision, recall, are all funct
35,660
In binary classification, in what specific case should I use accuracy, AUROC, logloss or Brier score to choose model?
Never use accuracy to evaluate a binary classifier. Here’s an extremely accurate prediction you can make at any party you attend: no one present is an astronaut. Because there are about 8 billion people in the world and only about 600 astronauts, this prediction will almost always be 100% accurate. It will also never correctly predict an astronaut. In any binary classification problem, pick the label that occurs most frequently in the training set and your accuracy will be at least 50%. The metrics to use for binary classification are precision and recall (and in some applications additional metrics like time-to-detect or computational cost). The relative value placed on these metrics depends on the application and the cost of false positives vs false negatives. If you value them equally, F1 is commonly used; otherwise F0.5 or F2 are common too. But really, look at precision and recall separately to understand what’s going on. Precision and recall work well in theory, and they work well in practice. They’re easy to communicate to stakeholders. Many data-driven CEOs know what precision and recall are and how to reason about them effectively. Log-loss (cross entropy) is usually best as the score function for training a classifier (binary or multilabel). It measures the relative uncertainty between the classes your model predicts and the true classes. Brier score is sometimes used for non-ordinal multilabel classification, but is in general inferior to log-loss. If you’re deeply interested in the theory behind this topic, Some Comparisons among Quadratic, Spherical, and Logarithmic Scoring Rules (2007, Bickel) has a gentle introduction. Tl;dr: use log-loss.
In binary classification, in what specific case should I use accuracy, AUROC, logloss or Brier score
Never use accuracy to evaluate a binary classifier. Here’s an extremely accurate prediction you can make at any party you attend: no one present is an astronaut. Because there are about 8 billion peop
In binary classification, in what specific case should I use accuracy, AUROC, logloss or Brier score to choose model? Never use accuracy to evaluate a binary classifier. Here’s an extremely accurate prediction you can make at any party you attend: no one present is an astronaut. Because there are about 8 billion people in the world and only about 600 astronauts, this prediction will almost always be 100% accurate. It will also never correctly predict an astronaut. In any binary classification problem, pick the label that occurs most frequently in the training set and your accuracy will be at least 50%. The metrics to use for binary classification are precision and recall (and in some applications additional metrics like time-to-detect or computational cost). The relative value placed on these metrics depends on the application and the cost of false positives vs false negatives. If you value them equally, F1 is commonly used; otherwise F0.5 or F2 are common too. But really, look at precision and recall separately to understand what’s going on. Precision and recall work well in theory, and they work well in practice. They’re easy to communicate to stakeholders. Many data-driven CEOs know what precision and recall are and how to reason about them effectively. Log-loss (cross entropy) is usually best as the score function for training a classifier (binary or multilabel). It measures the relative uncertainty between the classes your model predicts and the true classes. Brier score is sometimes used for non-ordinal multilabel classification, but is in general inferior to log-loss. If you’re deeply interested in the theory behind this topic, Some Comparisons among Quadratic, Spherical, and Logarithmic Scoring Rules (2007, Bickel) has a gentle introduction. Tl;dr: use log-loss.
In binary classification, in what specific case should I use accuracy, AUROC, logloss or Brier score Never use accuracy to evaluate a binary classifier. Here’s an extremely accurate prediction you can make at any party you attend: no one present is an astronaut. Because there are about 8 billion peop
35,661
What is the "binary:logistic" objective function in XGBoost?
It appears there is an option objective: "binary:logistic" “binary:logistic” –logistic regression for binary classification, output probability “binary:logitraw” –logistic regression for binary classification, output score before logistic transformation See http://xgboost.readthedocs.io/en/latest/parameter.html (so log loss)
What is the "binary:logistic" objective function in XGBoost?
It appears there is an option objective: "binary:logistic" “binary:logistic” –logistic regression for binary classification, output probability “binary:logitraw” –logistic regression for binary class
What is the "binary:logistic" objective function in XGBoost? It appears there is an option objective: "binary:logistic" “binary:logistic” –logistic regression for binary classification, output probability “binary:logitraw” –logistic regression for binary classification, output score before logistic transformation See http://xgboost.readthedocs.io/en/latest/parameter.html (so log loss)
What is the "binary:logistic" objective function in XGBoost? It appears there is an option objective: "binary:logistic" “binary:logistic” –logistic regression for binary classification, output probability “binary:logitraw” –logistic regression for binary class
35,662
What is the "binary:logistic" objective function in XGBoost?
I'm just summarizing the comments under the problem description: $l$ is the log likelihood of the bernoulli distribution, where $\text{logistic}(\hat{y}_i^{(t-1)} + f_t(x_i))$ is the probability. So the formula should be $$l = y_i \log(\text{logistic}(\hat{y}_i^{(t-1)} + f_t(x_i))) + (1-y_i)\log(1-\text{logistic}(\hat{y}_i^{(t-1)} + f_t(x_i)))$$ or algebraically equivelent, $$l = y_i (\hat y_i^{t-1} + f_t(x_i)) - \log(1 + \exp (\hat y_i^{t-1} + f_t(x_i)))$$ using the property that $\sigma(-z)=1 - \sigma(z)$.
What is the "binary:logistic" objective function in XGBoost?
I'm just summarizing the comments under the problem description: $l$ is the log likelihood of the bernoulli distribution, where $\text{logistic}(\hat{y}_i^{(t-1)} + f_t(x_i))$ is the probability. So
What is the "binary:logistic" objective function in XGBoost? I'm just summarizing the comments under the problem description: $l$ is the log likelihood of the bernoulli distribution, where $\text{logistic}(\hat{y}_i^{(t-1)} + f_t(x_i))$ is the probability. So the formula should be $$l = y_i \log(\text{logistic}(\hat{y}_i^{(t-1)} + f_t(x_i))) + (1-y_i)\log(1-\text{logistic}(\hat{y}_i^{(t-1)} + f_t(x_i)))$$ or algebraically equivelent, $$l = y_i (\hat y_i^{t-1} + f_t(x_i)) - \log(1 + \exp (\hat y_i^{t-1} + f_t(x_i)))$$ using the property that $\sigma(-z)=1 - \sigma(z)$.
What is the "binary:logistic" objective function in XGBoost? I'm just summarizing the comments under the problem description: $l$ is the log likelihood of the bernoulli distribution, where $\text{logistic}(\hat{y}_i^{(t-1)} + f_t(x_i))$ is the probability. So
35,663
What are soft policies in reinforcement learning?
what are soft policies in reinforcement learning? A "soft" policy is one that has some, usually small but finite, probability of selecting any possible action. Having a policy which has some chance of selecting any action is important theoretically when rewards and/or state transitions are stochastic - you are never 100% certain of your estimates for the true value of an action. Soft policies are important for practical purposes of exploring alternative actions, and they can give theoretical guarantees of convergence for RL algorithms. Does it mean using soft-max function as π(s,a) instead of deterministic policies? This is one way to create a soft policy. Another very common approach is $\epsilon$-greedy action selection over $Q(s,a)$, where the action with the highest value estimate is used preferentially with $p=1-\epsilon$, or with $p=\epsilon$ a random action is chosen with equal chance of any action. You may also see the term $\epsilon$-soft policy, which is a policy where every action has at least $p=\frac{\epsilon}{|\mathcal{A}|}$ chance of being selected. The $\epsilon$-greedy policy is also an $\epsilon$-soft policy, but a softmax function will not be in general (depending on what features you are using as input to the softmax).
What are soft policies in reinforcement learning?
what are soft policies in reinforcement learning? A "soft" policy is one that has some, usually small but finite, probability of selecting any possible action. Having a policy which has some chance o
What are soft policies in reinforcement learning? what are soft policies in reinforcement learning? A "soft" policy is one that has some, usually small but finite, probability of selecting any possible action. Having a policy which has some chance of selecting any action is important theoretically when rewards and/or state transitions are stochastic - you are never 100% certain of your estimates for the true value of an action. Soft policies are important for practical purposes of exploring alternative actions, and they can give theoretical guarantees of convergence for RL algorithms. Does it mean using soft-max function as π(s,a) instead of deterministic policies? This is one way to create a soft policy. Another very common approach is $\epsilon$-greedy action selection over $Q(s,a)$, where the action with the highest value estimate is used preferentially with $p=1-\epsilon$, or with $p=\epsilon$ a random action is chosen with equal chance of any action. You may also see the term $\epsilon$-soft policy, which is a policy where every action has at least $p=\frac{\epsilon}{|\mathcal{A}|}$ chance of being selected. The $\epsilon$-greedy policy is also an $\epsilon$-soft policy, but a softmax function will not be in general (depending on what features you are using as input to the softmax).
What are soft policies in reinforcement learning? what are soft policies in reinforcement learning? A "soft" policy is one that has some, usually small but finite, probability of selecting any possible action. Having a policy which has some chance o
35,664
What values should initial weights for a ReLU network be?
There has been quite a lot of theoretical work on Neural Network initialization in the last 5 years, which apparently hasn't still propagated to the wider Deep Learning community. While it's true that there isn't still an initialization which works for all architectures and for all activation functions (and most likely there will never be, from what we have understood so far about the dynamics of deep neural networks) , in practice this isn't a huge limit because most users use two or three activation functions (ReLU for CNNs, tanh and sigmoid for LSTMs, AKA the only RNNs used by most people) and two or three architectures (i.e., ResNets for image classification and LSTMs for sequence prediction or time series forecasting). For these things we do have some powerful results. Granted, they won't work for the Universal Transformer just presented at ICML 2018, but frankly, right now there are much more people trying to apply "standard" architectures such as ResNets to interesting business problems, who need better initializations than the Xavier one, than there are people inventing bleeding-edge architectures, who will always have to use the classic, infallible initialization strategy: elbow grease, also known as "long and boring computational experiments, supported by careful book-keeping". Deep Linear Networks One of the first main results is shown in the seminal work "Exact solutions to the nonlinear dynamics of learning in deep linear neural networks" of Andrew Saxe et al., 2014, on optimal activation for deep linear network, which used results from random matrix theory and in particular from free probability theory (AKA the theory of probability for noncommutative random variables, such as random matrices, precisely), to show that using random orthogonal weights provides far superior results than the usual scaled Normal initializations. The theoretical concept behind this result is that of dynamical isometry, i.e., having the product of Jacobians associated with error signal backpropagation act as a near isometry, up to some overall global $O(1)$ scaling, on a subspace (of the weight space) of as high a dimension as possible. This is equivalent to having as many singular values of the product of Jacobians as possible within a small range around an $O(1)$ constant, and is closely related to the notion of restricted isometry in compressed sensing and random projections. Deep Nonlinear Networks However, the results from Saxe don't easily translate to "real" NNs, with nonlinear activation functions. One can try and apply the random orthogonal matrix initialization, and there are "regimes", such as "the edge of chaos", where it will indeed work incredibly well for an architecture otherwise horribly hard to train (a fully connected neural network with 100 layers, 1000 units per layer and tanh activations (!!!)). But outside of this regime, there's no guarantee: results can even be worse than Xe initialization, so you're back to "try and see". However, 3 years after, two different papers appeared which extended Saxe's work to nonlinear neural networks by trying to achieve dynamical isometry for nonlinear networks. One is the work by Pennington et al, "Resurrecting the sigmoid in deep learning through dynamical isometry: theory and practice", 31st Conference on Neural Information Processing Systems (NIPS 2017), Long Beach, CA, USA. This paper fails to find a useful initialization for ReLU networks, while it finds a very good one for tanh networks. Since you're interested in the latter, I'll skip this one, just listing it here for completeness. The other is Balduzzi et al.'s well-known Shattered Gradients paper (Balduzzi et al., "The Shattered Gradients Problem: if resnets are the answer, then what is the question?", arXiv:1702.08591v2, 2018) which proposes to Saxe's random orthogonal weights with the so-called Looks-Linear (LL) activation. The approach is as follows: substitute all ReLU with CReLU, i.e., concatenated rectifiers: basically, these are very similar to a ReLU unit, but instead than $$ \sigma(x) = \max(0,x)$$ we have $$ \boldsymbol{\rho}(x) = (\max(0,x), \max(0,-x)) $$ (note that $\boldsymbol{\rho}(x):\mathbb{R}\to\mathbb{R}^2$). While you're here, you would probably like to reduce the number of units by 2, to keep the same number of parameters as before. now, each layer has a weight matrix $W_l$, which has twice as many elements as before, if you didn't reduce the number of units in each layer to achieve parameter parity with your initial architecture. In any case, it's a matrix with an odd number of columns, because of the CReLU activation function, thus $W_l=[W_{1l}, W_{2l}]$ where $W_{1l}$ and $W_{2l}$ have the same shape. Now, for each layer sample a matrix $W'_l$ with orthogonal columns, of the same shape as $W_{1l}$, and initialize $W_l$ as $W^0_l=[W'_l, -W'_l]$. Clearly, at initialization you now have a linear network because $$ \boldsymbol{\rho}(W^0_l \mathbf{x})=W'_l\sigma(\mathbf{x})-W'_l\sigma(-\mathbf{x})=W'_l\mathbf{x} $$ which is why we call this initalization LL (looks-linear). The LL-init can be "extended" easily to CNNs (see the cited paper for details). It does have the disadvantage of forcing you to change your architecture, though it's admittedly a simple change. Finally, the most impressive result, based on a mix of theory and experiments is the Delta-Orthogonal initialization of Xiao et al.,"Dynamical Isometry and a Mean Field Theory of CNNs: How to Train 10,000-Layer Vanilla Convolutional Neural Networks", arXiv:1806.05393v2, 2018. This initializer has obtained amazing results, such as allowing successful training of a 10000 layers vanilla CNN with tanh activations, without nearly any regularization techinque (no dropout, no residual connections, no Batch Norm, no weight decay and no learning rate decay: the network relies only on SGD with momentum for regularization). The initialization is even included in Tensorflow as the ConvolutionOrthogonal initializer in the suite of initialization operators of Tensorflow. Sadly, this initializer only works its magic on tanh CNNs, while it's not guaranteed to deliver its amazing speedups for ReLU CNNs. And tanh CNNs do suck at object classification: the current SOTA for a tanh CNN on CIFAR-10 is a test error of more than 10%, while with modified ReLU ResNets we go below 3%.
What values should initial weights for a ReLU network be?
There has been quite a lot of theoretical work on Neural Network initialization in the last 5 years, which apparently hasn't still propagated to the wider Deep Learning community. While it's true that
What values should initial weights for a ReLU network be? There has been quite a lot of theoretical work on Neural Network initialization in the last 5 years, which apparently hasn't still propagated to the wider Deep Learning community. While it's true that there isn't still an initialization which works for all architectures and for all activation functions (and most likely there will never be, from what we have understood so far about the dynamics of deep neural networks) , in practice this isn't a huge limit because most users use two or three activation functions (ReLU for CNNs, tanh and sigmoid for LSTMs, AKA the only RNNs used by most people) and two or three architectures (i.e., ResNets for image classification and LSTMs for sequence prediction or time series forecasting). For these things we do have some powerful results. Granted, they won't work for the Universal Transformer just presented at ICML 2018, but frankly, right now there are much more people trying to apply "standard" architectures such as ResNets to interesting business problems, who need better initializations than the Xavier one, than there are people inventing bleeding-edge architectures, who will always have to use the classic, infallible initialization strategy: elbow grease, also known as "long and boring computational experiments, supported by careful book-keeping". Deep Linear Networks One of the first main results is shown in the seminal work "Exact solutions to the nonlinear dynamics of learning in deep linear neural networks" of Andrew Saxe et al., 2014, on optimal activation for deep linear network, which used results from random matrix theory and in particular from free probability theory (AKA the theory of probability for noncommutative random variables, such as random matrices, precisely), to show that using random orthogonal weights provides far superior results than the usual scaled Normal initializations. The theoretical concept behind this result is that of dynamical isometry, i.e., having the product of Jacobians associated with error signal backpropagation act as a near isometry, up to some overall global $O(1)$ scaling, on a subspace (of the weight space) of as high a dimension as possible. This is equivalent to having as many singular values of the product of Jacobians as possible within a small range around an $O(1)$ constant, and is closely related to the notion of restricted isometry in compressed sensing and random projections. Deep Nonlinear Networks However, the results from Saxe don't easily translate to "real" NNs, with nonlinear activation functions. One can try and apply the random orthogonal matrix initialization, and there are "regimes", such as "the edge of chaos", where it will indeed work incredibly well for an architecture otherwise horribly hard to train (a fully connected neural network with 100 layers, 1000 units per layer and tanh activations (!!!)). But outside of this regime, there's no guarantee: results can even be worse than Xe initialization, so you're back to "try and see". However, 3 years after, two different papers appeared which extended Saxe's work to nonlinear neural networks by trying to achieve dynamical isometry for nonlinear networks. One is the work by Pennington et al, "Resurrecting the sigmoid in deep learning through dynamical isometry: theory and practice", 31st Conference on Neural Information Processing Systems (NIPS 2017), Long Beach, CA, USA. This paper fails to find a useful initialization for ReLU networks, while it finds a very good one for tanh networks. Since you're interested in the latter, I'll skip this one, just listing it here for completeness. The other is Balduzzi et al.'s well-known Shattered Gradients paper (Balduzzi et al., "The Shattered Gradients Problem: if resnets are the answer, then what is the question?", arXiv:1702.08591v2, 2018) which proposes to Saxe's random orthogonal weights with the so-called Looks-Linear (LL) activation. The approach is as follows: substitute all ReLU with CReLU, i.e., concatenated rectifiers: basically, these are very similar to a ReLU unit, but instead than $$ \sigma(x) = \max(0,x)$$ we have $$ \boldsymbol{\rho}(x) = (\max(0,x), \max(0,-x)) $$ (note that $\boldsymbol{\rho}(x):\mathbb{R}\to\mathbb{R}^2$). While you're here, you would probably like to reduce the number of units by 2, to keep the same number of parameters as before. now, each layer has a weight matrix $W_l$, which has twice as many elements as before, if you didn't reduce the number of units in each layer to achieve parameter parity with your initial architecture. In any case, it's a matrix with an odd number of columns, because of the CReLU activation function, thus $W_l=[W_{1l}, W_{2l}]$ where $W_{1l}$ and $W_{2l}$ have the same shape. Now, for each layer sample a matrix $W'_l$ with orthogonal columns, of the same shape as $W_{1l}$, and initialize $W_l$ as $W^0_l=[W'_l, -W'_l]$. Clearly, at initialization you now have a linear network because $$ \boldsymbol{\rho}(W^0_l \mathbf{x})=W'_l\sigma(\mathbf{x})-W'_l\sigma(-\mathbf{x})=W'_l\mathbf{x} $$ which is why we call this initalization LL (looks-linear). The LL-init can be "extended" easily to CNNs (see the cited paper for details). It does have the disadvantage of forcing you to change your architecture, though it's admittedly a simple change. Finally, the most impressive result, based on a mix of theory and experiments is the Delta-Orthogonal initialization of Xiao et al.,"Dynamical Isometry and a Mean Field Theory of CNNs: How to Train 10,000-Layer Vanilla Convolutional Neural Networks", arXiv:1806.05393v2, 2018. This initializer has obtained amazing results, such as allowing successful training of a 10000 layers vanilla CNN with tanh activations, without nearly any regularization techinque (no dropout, no residual connections, no Batch Norm, no weight decay and no learning rate decay: the network relies only on SGD with momentum for regularization). The initialization is even included in Tensorflow as the ConvolutionOrthogonal initializer in the suite of initialization operators of Tensorflow. Sadly, this initializer only works its magic on tanh CNNs, while it's not guaranteed to deliver its amazing speedups for ReLU CNNs. And tanh CNNs do suck at object classification: the current SOTA for a tanh CNN on CIFAR-10 is a test error of more than 10%, while with modified ReLU ResNets we go below 3%.
What values should initial weights for a ReLU network be? There has been quite a lot of theoretical work on Neural Network initialization in the last 5 years, which apparently hasn't still propagated to the wider Deep Learning community. While it's true that
35,665
What values should initial weights for a ReLU network be?
Initializations are a topic where only two, rather unhelpful, facts are known for certain: Neural networks can be very sensitive to the initialization strategy that you use. There is no universal "best choice" that is consistently good across different problem types, network architectures, activation functions, and data sets. There's a lot of experimentation involved. This is why there are often a large number of different initialization strategies implemented in any modern neural network software. Each of these also has a uniform variant. Glorot Normal (aka Xavier initialization) "It draws samples from a truncated normal distribution centered on 0 with stddev = sqrt(2 / (fan_in + fan_out)) where fan_in is the number of input units in the weight tensor and fan_out is the number of output units in the weight tensor." - Keras documentation He Normal initialization "It draws samples from a truncated normal distribution centered on 0 with stddev = sqrt(2 / fan_in) where fan_in is the number of input units in the weight tensor." - Keras documentation LeCun Normal initializer. "It draws samples from a truncated normal distribution centered on 0 with stddev = sqrt(1 / fan_in) where fan_in is the number of input units in the weight tensor." - Keras documentation
What values should initial weights for a ReLU network be?
Initializations are a topic where only two, rather unhelpful, facts are known for certain: Neural networks can be very sensitive to the initialization strategy that you use. There is no universal "b
What values should initial weights for a ReLU network be? Initializations are a topic where only two, rather unhelpful, facts are known for certain: Neural networks can be very sensitive to the initialization strategy that you use. There is no universal "best choice" that is consistently good across different problem types, network architectures, activation functions, and data sets. There's a lot of experimentation involved. This is why there are often a large number of different initialization strategies implemented in any modern neural network software. Each of these also has a uniform variant. Glorot Normal (aka Xavier initialization) "It draws samples from a truncated normal distribution centered on 0 with stddev = sqrt(2 / (fan_in + fan_out)) where fan_in is the number of input units in the weight tensor and fan_out is the number of output units in the weight tensor." - Keras documentation He Normal initialization "It draws samples from a truncated normal distribution centered on 0 with stddev = sqrt(2 / fan_in) where fan_in is the number of input units in the weight tensor." - Keras documentation LeCun Normal initializer. "It draws samples from a truncated normal distribution centered on 0 with stddev = sqrt(1 / fan_in) where fan_in is the number of input units in the weight tensor." - Keras documentation
What values should initial weights for a ReLU network be? Initializations are a topic where only two, rather unhelpful, facts are known for certain: Neural networks can be very sensitive to the initialization strategy that you use. There is no universal "b
35,666
Technical point about convergence with conditional expectation
Yes, $X_{n} \to 0$ almost surely. The argument I have is a little convoluted, so bear with me. First, consider the events $F_{k} = \bigcup_{n \geq k} \{ C_{n} > 2 \}$. By the almost sure convergence of the $C_{n}$ it follows that $P( \bigcap_{k} F_{k} ) = 0$, and since $F_{1} \supseteq F_{2} \supseteq \cdots$ we have $P(F_{k}) \to 0$. So it suffices to show that $X_{n} \to 0$ a.s. within $F_{k}^{c}$, for any $k$. Now fix a $k$ and an $\varepsilon > 0$. Using the notation $E[X; A]$ to represent $E[X 1_{A}]$, we have for $n \geq k$ \begin{equation} E[X_{n} ; F_{k}^{c}] \leq E[X_{n} ; C_{n} \leq 2] = E[ E(X_{n} | C_{n}) ; C_{n} \leq 2] = E[ C_{n} / n^{2} ; C_{n} \leq 2 ] \leq 2 / n^{2}. \end{equation} This is kind of the key part. (Note, too, that we used the nonnegativity of $X_{n}$ in the first step, to pass from $F_{k}^{c}$ to the larger event $C_{n} \leq 2$.) From here we just need some fairly run-of-the-mill measure theoretic arguments. The bound above, together with the nonnegativity of $X_{n}$, implies that $P(F_{k}^{c} \cap \{ X_{n} > \varepsilon \}) \leq \frac{2}{n^{2} \varepsilon}$ (for $n \geq k$), so that \begin{equation} \sum_{n \geq k} P(F_{k}^{c} \cap \{ X_{n} > \varepsilon \}) < \infty. \end{equation} By the Borel-Cantelli Lemma we can now say that the event \begin{equation} F_{k}^{c} \cap \{ X_{n} > \varepsilon \, \text{for infinitely many $n$} \} \end{equation} has probability zero. Since $\varepsilon$ was arbitary, this gets us $X_{n} \to 0$ a.s. on $F_{k}^{c}$.
Technical point about convergence with conditional expectation
Yes, $X_{n} \to 0$ almost surely. The argument I have is a little convoluted, so bear with me. First, consider the events $F_{k} = \bigcup_{n \geq k} \{ C_{n} > 2 \}$. By the almost sure convergence o
Technical point about convergence with conditional expectation Yes, $X_{n} \to 0$ almost surely. The argument I have is a little convoluted, so bear with me. First, consider the events $F_{k} = \bigcup_{n \geq k} \{ C_{n} > 2 \}$. By the almost sure convergence of the $C_{n}$ it follows that $P( \bigcap_{k} F_{k} ) = 0$, and since $F_{1} \supseteq F_{2} \supseteq \cdots$ we have $P(F_{k}) \to 0$. So it suffices to show that $X_{n} \to 0$ a.s. within $F_{k}^{c}$, for any $k$. Now fix a $k$ and an $\varepsilon > 0$. Using the notation $E[X; A]$ to represent $E[X 1_{A}]$, we have for $n \geq k$ \begin{equation} E[X_{n} ; F_{k}^{c}] \leq E[X_{n} ; C_{n} \leq 2] = E[ E(X_{n} | C_{n}) ; C_{n} \leq 2] = E[ C_{n} / n^{2} ; C_{n} \leq 2 ] \leq 2 / n^{2}. \end{equation} This is kind of the key part. (Note, too, that we used the nonnegativity of $X_{n}$ in the first step, to pass from $F_{k}^{c}$ to the larger event $C_{n} \leq 2$.) From here we just need some fairly run-of-the-mill measure theoretic arguments. The bound above, together with the nonnegativity of $X_{n}$, implies that $P(F_{k}^{c} \cap \{ X_{n} > \varepsilon \}) \leq \frac{2}{n^{2} \varepsilon}$ (for $n \geq k$), so that \begin{equation} \sum_{n \geq k} P(F_{k}^{c} \cap \{ X_{n} > \varepsilon \}) < \infty. \end{equation} By the Borel-Cantelli Lemma we can now say that the event \begin{equation} F_{k}^{c} \cap \{ X_{n} > \varepsilon \, \text{for infinitely many $n$} \} \end{equation} has probability zero. Since $\varepsilon$ was arbitary, this gets us $X_{n} \to 0$ a.s. on $F_{k}^{c}$.
Technical point about convergence with conditional expectation Yes, $X_{n} \to 0$ almost surely. The argument I have is a little convoluted, so bear with me. First, consider the events $F_{k} = \bigcup_{n \geq k} \{ C_{n} > 2 \}$. By the almost sure convergence o
35,667
Technical point about convergence with conditional expectation
Set $Z_n=X_n/C_n$. Then $E[Z_n]=1/n^2$ and $Z_n\ge 0$. By Markov's inequality, $P(Z_n>\epsilon)\le E[Z_n]/\epsilon = 1/(n^2\epsilon)$ which has finite sum, so by Borel Cantelli, $P(Z_n>\epsilon \text{ infinitely often})=0$ and $Z_n\to 0$ almost surely. If $Z_n\to0$ almost surely and $C_n\to 1$ almost surely then $X_n=Z_nC_n\to 0$ almost surely.
Technical point about convergence with conditional expectation
Set $Z_n=X_n/C_n$. Then $E[Z_n]=1/n^2$ and $Z_n\ge 0$. By Markov's inequality, $P(Z_n>\epsilon)\le E[Z_n]/\epsilon = 1/(n^2\epsilon)$ which has finite sum, so by Borel Cantelli, $P(Z_n>\epsilon \text{
Technical point about convergence with conditional expectation Set $Z_n=X_n/C_n$. Then $E[Z_n]=1/n^2$ and $Z_n\ge 0$. By Markov's inequality, $P(Z_n>\epsilon)\le E[Z_n]/\epsilon = 1/(n^2\epsilon)$ which has finite sum, so by Borel Cantelli, $P(Z_n>\epsilon \text{ infinitely often})=0$ and $Z_n\to 0$ almost surely. If $Z_n\to0$ almost surely and $C_n\to 1$ almost surely then $X_n=Z_nC_n\to 0$ almost surely.
Technical point about convergence with conditional expectation Set $Z_n=X_n/C_n$. Then $E[Z_n]=1/n^2$ and $Z_n\ge 0$. By Markov's inequality, $P(Z_n>\epsilon)\le E[Z_n]/\epsilon = 1/(n^2\epsilon)$ which has finite sum, so by Borel Cantelli, $P(Z_n>\epsilon \text{
35,668
Interpretation of "score"
This one is an interesting historical curiosity. The term "score" was initially used in Fisher (1935) in a statistical problem involving the analysis of genetic properties of families with a parent that has a genetic abnormality. Fisher noted that the children of an abnormal parent can be classified into four classes, being the combinations of their binary inheritance status (inheritance or non-inheritance of the abnormality), and their binary zygosity (homozygous or heterozygous). Fisher proposed that a family observed in the data could be given a "score" based on the number of children in each of these four categories, and this score could be used to estimate the linkage parameter describing the inheritance probability of interest in his problem. He measured the efficiency of his proposed score, and an alternative scoring rule by another author, by comparing both to the "ideal score" obtained by assigning each data point a score equal to the derivative of the logarithm of the sampling density (p. 193). In later work, other authors followed Fisher's method of analysis but applied it to more general contexts where they were no longer trying to allocate a "score" to a family in a genetic problem. In this later work, authors still speak of the "score" or "efficient score", but they use this in a more generalised sense, as a direct referent to the derivative of the log-likelihood. This progression culminated in a paper by Rao (1948) where the author introduces "efficient score tests" using the derivative of the log-likelihood function. So, the term "score" initially arose as a term that Fisher used in a specific application of statistics to a problem involving the genetic properties of children in a family. He estimated a genetic probability by giving each family a "score" based on the number of children in four categories of interest. The term was then deployed more broadly by other authors to refer to what Fisher had called the "ideal score", which was the derivative of the log-likelihood. Note on reading Fisher's paper: This paper is a bit hard to read, since it uses statistical inference methods but describes them in an antiquated way. Fisher makes reference to statistical inference methods and information theory, but does not give references for his steps. Essentially what he is saying is the following. Suppose we let $f(x| \xi)$ be the density for the observed values, and let $\ell_{x}(\xi) \equiv \ln f(x | \xi)$ be the corresponding log-density, with parameter $\xi$. The "ideal score" assigned to a single data point (e.g., a count of children in a genetic category) is: $$\text{Ideal score for }x_i = \frac{1}{f(x_i | \xi)} \cdot \frac{df}{d \xi}(x_i | \xi) = \frac{d\ell_{x_i}}{d \xi} (\xi).$$ The ideal score for the entire data set (e.g., counts of a family of children in several genetic categories) is obtained by adding up the individual scores for the data points, yielding: $$\text{Ideal score for data set }\boldsymbol{x} = \sum_{i=1}^k \frac{d\ell_{x_i}}{d \xi} (\xi) = \frac{d\ell_\boldsymbol{x}}{d \xi}(\xi).$$ As you can see, this is just the derivative of the log-likelihood function for the entire data set (what we now refer to as the "score function"). Fisher uses the term "score" in the generic sense of a quantity applied to a unit (a family) to rank those units on a scale for his purposes. He was clearly able to see that the derivative of the log-likelihood represented an "ideal" of this "score" for the purposes of his work.
Interpretation of "score"
This one is an interesting historical curiosity. The term "score" was initially used in Fisher (1935) in a statistical problem involving the analysis of genetic properties of families with a parent t
Interpretation of "score" This one is an interesting historical curiosity. The term "score" was initially used in Fisher (1935) in a statistical problem involving the analysis of genetic properties of families with a parent that has a genetic abnormality. Fisher noted that the children of an abnormal parent can be classified into four classes, being the combinations of their binary inheritance status (inheritance or non-inheritance of the abnormality), and their binary zygosity (homozygous or heterozygous). Fisher proposed that a family observed in the data could be given a "score" based on the number of children in each of these four categories, and this score could be used to estimate the linkage parameter describing the inheritance probability of interest in his problem. He measured the efficiency of his proposed score, and an alternative scoring rule by another author, by comparing both to the "ideal score" obtained by assigning each data point a score equal to the derivative of the logarithm of the sampling density (p. 193). In later work, other authors followed Fisher's method of analysis but applied it to more general contexts where they were no longer trying to allocate a "score" to a family in a genetic problem. In this later work, authors still speak of the "score" or "efficient score", but they use this in a more generalised sense, as a direct referent to the derivative of the log-likelihood. This progression culminated in a paper by Rao (1948) where the author introduces "efficient score tests" using the derivative of the log-likelihood function. So, the term "score" initially arose as a term that Fisher used in a specific application of statistics to a problem involving the genetic properties of children in a family. He estimated a genetic probability by giving each family a "score" based on the number of children in four categories of interest. The term was then deployed more broadly by other authors to refer to what Fisher had called the "ideal score", which was the derivative of the log-likelihood. Note on reading Fisher's paper: This paper is a bit hard to read, since it uses statistical inference methods but describes them in an antiquated way. Fisher makes reference to statistical inference methods and information theory, but does not give references for his steps. Essentially what he is saying is the following. Suppose we let $f(x| \xi)$ be the density for the observed values, and let $\ell_{x}(\xi) \equiv \ln f(x | \xi)$ be the corresponding log-density, with parameter $\xi$. The "ideal score" assigned to a single data point (e.g., a count of children in a genetic category) is: $$\text{Ideal score for }x_i = \frac{1}{f(x_i | \xi)} \cdot \frac{df}{d \xi}(x_i | \xi) = \frac{d\ell_{x_i}}{d \xi} (\xi).$$ The ideal score for the entire data set (e.g., counts of a family of children in several genetic categories) is obtained by adding up the individual scores for the data points, yielding: $$\text{Ideal score for data set }\boldsymbol{x} = \sum_{i=1}^k \frac{d\ell_{x_i}}{d \xi} (\xi) = \frac{d\ell_\boldsymbol{x}}{d \xi}(\xi).$$ As you can see, this is just the derivative of the log-likelihood function for the entire data set (what we now refer to as the "score function"). Fisher uses the term "score" in the generic sense of a quantity applied to a unit (a family) to rank those units on a scale for his purposes. He was clearly able to see that the derivative of the log-likelihood represented an "ideal" of this "score" for the purposes of his work.
Interpretation of "score" This one is an interesting historical curiosity. The term "score" was initially used in Fisher (1935) in a statistical problem involving the analysis of genetic properties of families with a parent t
35,669
Should k-means only be applied if the variables are normally distributed?
The k-means algorithm minimizes the following objective function $\displaystyle\sum_{i=1}^n\left\|x_i-\mu_i\right\|^2=\sum_{i=1}^n\sum_{j=1}^p\left(x_i^{(j)}-\mu_i^{(j)}\right)^2=\sum_{j=1}^p\sum_{i=1}^n\left(x_i^{(j)}-\mu_i^{(j)}\right)^2$ where $\mu_i$ is the mean of the cluster associated with observation $i$ and $x_i^{(j)}$ denotes the $j$th coordinate of observation $x_i$. Notice that this is a sort of generalization of the variance. The last sum can be expressed as an estimate of the variance of each of the clusters with respect to each of the variables. So standardizing the variables to have equal variance is important because it means they get weighted equally with respect to each other. It's reasonable to weight the variables the same if you have no reason to think one is more important than the others. Note that that has nothing to do with whether the variables belong to some known distribution such as the normal distribution. Further note that the most popular algorithm for k-means (Lloyd's algorithm) always takes steps that decrease the variance. So, you will always get a local optimum in a finite number of steps. It is always advisable to run the algorithm multiple times to make sure that you are close to the global optimum. A full answer to your question hinges on the term 'reasonable'. Given that I've covered that you will get an answer and how the answer might depend on the variables, a question you might ask is whether that answer is stable. The solution might indeed be more stable with Gaussian distributed variables because the variance is sensitive to outliers. So outliers could certainly be driving the solutions you arrive at. For instance, consider a single outlier: if it's large enough it could force a center to be allocated to it in order to reduce its contribution to the objective function.
Should k-means only be applied if the variables are normally distributed?
The k-means algorithm minimizes the following objective function $\displaystyle\sum_{i=1}^n\left\|x_i-\mu_i\right\|^2=\sum_{i=1}^n\sum_{j=1}^p\left(x_i^{(j)}-\mu_i^{(j)}\right)^2=\sum_{j=1}^p\sum_{i=1
Should k-means only be applied if the variables are normally distributed? The k-means algorithm minimizes the following objective function $\displaystyle\sum_{i=1}^n\left\|x_i-\mu_i\right\|^2=\sum_{i=1}^n\sum_{j=1}^p\left(x_i^{(j)}-\mu_i^{(j)}\right)^2=\sum_{j=1}^p\sum_{i=1}^n\left(x_i^{(j)}-\mu_i^{(j)}\right)^2$ where $\mu_i$ is the mean of the cluster associated with observation $i$ and $x_i^{(j)}$ denotes the $j$th coordinate of observation $x_i$. Notice that this is a sort of generalization of the variance. The last sum can be expressed as an estimate of the variance of each of the clusters with respect to each of the variables. So standardizing the variables to have equal variance is important because it means they get weighted equally with respect to each other. It's reasonable to weight the variables the same if you have no reason to think one is more important than the others. Note that that has nothing to do with whether the variables belong to some known distribution such as the normal distribution. Further note that the most popular algorithm for k-means (Lloyd's algorithm) always takes steps that decrease the variance. So, you will always get a local optimum in a finite number of steps. It is always advisable to run the algorithm multiple times to make sure that you are close to the global optimum. A full answer to your question hinges on the term 'reasonable'. Given that I've covered that you will get an answer and how the answer might depend on the variables, a question you might ask is whether that answer is stable. The solution might indeed be more stable with Gaussian distributed variables because the variance is sensitive to outliers. So outliers could certainly be driving the solutions you arrive at. For instance, consider a single outlier: if it's large enough it could force a center to be allocated to it in order to reduce its contribution to the objective function.
Should k-means only be applied if the variables are normally distributed? The k-means algorithm minimizes the following objective function $\displaystyle\sum_{i=1}^n\left\|x_i-\mu_i\right\|^2=\sum_{i=1}^n\sum_{j=1}^p\left(x_i^{(j)}-\mu_i^{(j)}\right)^2=\sum_{j=1}^p\sum_{i=1
35,670
Should k-means only be applied if the variables are normally distributed?
It would help if you were to provide information regarding the magnitude of the noise or overdispersion in these features. This can be as simple as providing means, medians and std deviations in a tabular format. My experience is that K-means, as with many traditional methods, is fairly robust to violations of normality when the magnitude of the noise is not large. In this sense, K-means differs significantly from, e.g., OLS regression assumptions that the errors be normally distributed (not the inputs). K-means does not have similar assumptions. In fact and for the most part, assumptions wrt K-means are rules of thumb, conventions and heuristics that vary from discipline to discipline as well as varying as a function of highly subjective decisions made by the analyst. For you this means that there is no 'cookbook of rules' in existence wrt K-means which stipulates what you, the analyst, should or should not do in driving to a solution. This suggests additional K-means limitations: It's not recommended for use with longitudinal information (time series) Solutions are sensitive to dependence among features The number of clusters has to be pre-specified and, given that number, K-means always finds a solution. This solution may or may not accurately represent the behavior of the data Solutions are always spherical around the cluster centroids. If the 'real' clusters in the data are differently shaped, K-means will not capture patterning other than spherical It does not return reasonable results with noncontinuous features or mixtures of continuous and discrete information If the seeds used in forming the clusters are automatically created from random data draws, extreme values in the features can cause sparsity and nonrepresentative distortion in the results As aksakal notes, k-medians is one workaround to the issue you've raised. Assuming the ready availability of that routine, its results should be compared with solutions using k-means. Wrt rules of thumb, a common prescription in marketing is first, standardize the features to a mean of 0 and std dev of 1 then, second, reduce the dimensionality of the data using PCA (or similar methods). In part, this helps mitigate feature dependence. This also smoothes 'lumpiness' that can result from using the full or unreduced matrix of features. Finally and for your purposes dimension reduction could also help blunt the impact of extreme or overdispersed information. I've found such pre-clustering, dimension reduction methods helpful, that is when they work -- which is most of the time. However, what does one do in the case of large magnitude noise? To facilitate a deeper understanding of the issues that raises, Xie and Xing's paper Cauchy Principal Component Analysis (ungated here ... http://www.cs.cmu.edu/~pengtaox/papers/cpca.pdf) presents a typology of data matrices as a function of sparsity and noise. Despite its focus on PCA, their discussion is informative as it can be generalized to K-means. If Xie and Xing's discussion is too technical, there are many simpler transformations that can be applied to the extreme features. For positive valued features, the natural log transformation compresses heavy tails. Other possibilities include the Box-Cox transformation, the inverse hyperbolic sine, Lambert's W, and so on. Formulas for all of these are readily obtainable online. The bottom line is that there is no 'one size fits all' answer to your question.
Should k-means only be applied if the variables are normally distributed?
It would help if you were to provide information regarding the magnitude of the noise or overdispersion in these features. This can be as simple as providing means, medians and std deviations in a tab
Should k-means only be applied if the variables are normally distributed? It would help if you were to provide information regarding the magnitude of the noise or overdispersion in these features. This can be as simple as providing means, medians and std deviations in a tabular format. My experience is that K-means, as with many traditional methods, is fairly robust to violations of normality when the magnitude of the noise is not large. In this sense, K-means differs significantly from, e.g., OLS regression assumptions that the errors be normally distributed (not the inputs). K-means does not have similar assumptions. In fact and for the most part, assumptions wrt K-means are rules of thumb, conventions and heuristics that vary from discipline to discipline as well as varying as a function of highly subjective decisions made by the analyst. For you this means that there is no 'cookbook of rules' in existence wrt K-means which stipulates what you, the analyst, should or should not do in driving to a solution. This suggests additional K-means limitations: It's not recommended for use with longitudinal information (time series) Solutions are sensitive to dependence among features The number of clusters has to be pre-specified and, given that number, K-means always finds a solution. This solution may or may not accurately represent the behavior of the data Solutions are always spherical around the cluster centroids. If the 'real' clusters in the data are differently shaped, K-means will not capture patterning other than spherical It does not return reasonable results with noncontinuous features or mixtures of continuous and discrete information If the seeds used in forming the clusters are automatically created from random data draws, extreme values in the features can cause sparsity and nonrepresentative distortion in the results As aksakal notes, k-medians is one workaround to the issue you've raised. Assuming the ready availability of that routine, its results should be compared with solutions using k-means. Wrt rules of thumb, a common prescription in marketing is first, standardize the features to a mean of 0 and std dev of 1 then, second, reduce the dimensionality of the data using PCA (or similar methods). In part, this helps mitigate feature dependence. This also smoothes 'lumpiness' that can result from using the full or unreduced matrix of features. Finally and for your purposes dimension reduction could also help blunt the impact of extreme or overdispersed information. I've found such pre-clustering, dimension reduction methods helpful, that is when they work -- which is most of the time. However, what does one do in the case of large magnitude noise? To facilitate a deeper understanding of the issues that raises, Xie and Xing's paper Cauchy Principal Component Analysis (ungated here ... http://www.cs.cmu.edu/~pengtaox/papers/cpca.pdf) presents a typology of data matrices as a function of sparsity and noise. Despite its focus on PCA, their discussion is informative as it can be generalized to K-means. If Xie and Xing's discussion is too technical, there are many simpler transformations that can be applied to the extreme features. For positive valued features, the natural log transformation compresses heavy tails. Other possibilities include the Box-Cox transformation, the inverse hyperbolic sine, Lambert's W, and so on. Formulas for all of these are readily obtainable online. The bottom line is that there is no 'one size fits all' answer to your question.
Should k-means only be applied if the variables are normally distributed? It would help if you were to provide information regarding the magnitude of the noise or overdispersion in these features. This can be as simple as providing means, medians and std deviations in a tab
35,671
Confusion around Bellman (update) operator
The precise terminology might differ across sources, but according to the source I learned from, the first one is called the Bellman optimality equation or simply the Bellman equation. The second one is the Bellman expectation equation. The expectation equation is linear in $V$, so you can solve for $V$ using simple linear algebra. The optimality equation, on the other hand, is nonlinear (due to the max operation) so there is no closed-form solution... which is why there are many algorithms to find the optimal solution (Q-learning, value iteration, policy iteration etc.). The expectation equation is usually used to evaluate a known policy $\pi$, whereas the optimality equation is used to learn the optimal policy $\pi^*$.
Confusion around Bellman (update) operator
The precise terminology might differ across sources, but according to the source I learned from, the first one is called the Bellman optimality equation or simply the Bellman equation. The second one
Confusion around Bellman (update) operator The precise terminology might differ across sources, but according to the source I learned from, the first one is called the Bellman optimality equation or simply the Bellman equation. The second one is the Bellman expectation equation. The expectation equation is linear in $V$, so you can solve for $V$ using simple linear algebra. The optimality equation, on the other hand, is nonlinear (due to the max operation) so there is no closed-form solution... which is why there are many algorithms to find the optimal solution (Q-learning, value iteration, policy iteration etc.). The expectation equation is usually used to evaluate a known policy $\pi$, whereas the optimality equation is used to learn the optimal policy $\pi^*$.
Confusion around Bellman (update) operator The precise terminology might differ across sources, but according to the source I learned from, the first one is called the Bellman optimality equation or simply the Bellman equation. The second one
35,672
Confusion around Bellman (update) operator
A good resource will be the classical textbook on reinforcement learning Reinforcement Learning: An Introduction, mostly the part about dynamic programming. Another good resource will be Berkeley's opencourse on Artificial Intelligence on EdX. The difference in their name (Bellman operator vs Bellman update operator) does not matter here. You will see other names like Bellman backup operator. They are all the same thing. Basically it refers to the operation of updating the value of state $s$ from the value of other states that could be potentially reached from state $s$. The definition of Bellman operator requires also a policy $\pi(x)$ indicating the probability of possible actions to take at state $s$. The second definition of Bellman operator in your example means updating the value of state $s$ by taking actions with probability from any predefined policy $\pi$. On the other hand, the first definition of Bellman operator is only specific to one policy, which is to take action on state $s$ that gives the highest value of state $s$ with 100% probability. Therefore, the first definition can be regarded as a specific example of the second definition: the second definition works for any policy, while the first definition only works for the optimal policy that gives the highest value.
Confusion around Bellman (update) operator
A good resource will be the classical textbook on reinforcement learning Reinforcement Learning: An Introduction, mostly the part about dynamic programming. Another good resource will be Berkeley's op
Confusion around Bellman (update) operator A good resource will be the classical textbook on reinforcement learning Reinforcement Learning: An Introduction, mostly the part about dynamic programming. Another good resource will be Berkeley's opencourse on Artificial Intelligence on EdX. The difference in their name (Bellman operator vs Bellman update operator) does not matter here. You will see other names like Bellman backup operator. They are all the same thing. Basically it refers to the operation of updating the value of state $s$ from the value of other states that could be potentially reached from state $s$. The definition of Bellman operator requires also a policy $\pi(x)$ indicating the probability of possible actions to take at state $s$. The second definition of Bellman operator in your example means updating the value of state $s$ by taking actions with probability from any predefined policy $\pi$. On the other hand, the first definition of Bellman operator is only specific to one policy, which is to take action on state $s$ that gives the highest value of state $s$ with 100% probability. Therefore, the first definition can be regarded as a specific example of the second definition: the second definition works for any policy, while the first definition only works for the optimal policy that gives the highest value.
Confusion around Bellman (update) operator A good resource will be the classical textbook on reinforcement learning Reinforcement Learning: An Introduction, mostly the part about dynamic programming. Another good resource will be Berkeley's op
35,673
Looking for advice regarding model selection for forecasting (dynamic?) panel data
Excellent question(s). Benny_dref's suggestions are useful. The first sentence of the OPs query is concerned with "selecting an appropriate forecasting model for panel data." With several DVs, more than a few predictors and a wide variety of possible methods and models to pursue, one has two broad avenues wrt model selection. The first is theoretical -- Wooldridge (referenced below) and the link to the DPM method(s) in the body of the OPs question provide guidance along those lines. The second avenue is empirical, e.g., which model has the most predictive power? explains the most variance? minimizes error? and/or minimizes AIC/BIC metrics? In other words, there are multiple possible criteria for model selection. You can pick one or triangulate across several metrics in distilling the information down to make that decision. The (linked) DPM deck in the body of the OPs query is exhaustive in covering theoretical issues wrt small T panel data, GMMs and instrumental variables (IVs). Note, however, that their approach is confirmatory and presumes that many, if not all, of the OPs more applied and practical concerns have been addressed and answered. Also, its high level of technical rigor can take an inexperienced modeller down a bewildered rabbit hole. My recommendation would be to step back from immediate pursuit of their prescriptions by building up to them using less demanding, more easily digested and exploratory approaches, methods and models. For instance, instead of GMMs, why not build up to their use with simpler, more tractable, easily implemented and understood OLS models? Or consider IVs: econometricians prefer IV solutions to issues wrt endogeneity but noneconometricians question whether or not they create as many problems as they solve. Of course, these problems begin with simply identifying an appropriate IV(s). Why not put these theoretical, last step issues aside until you know more about the behavior of the data? This also raises the possibility of stepping outside a purely econometric framework to consider methods and models proposed in other disciplines. As the OP notes in question 1), there are some exploratory issues to resolve wrt variable selection. PCA is widely employed but has the drawback of blurring the specificity inherent in the individual predictors. Why not use the Lasso for variable selection? Another approach to variable selection could be relative variable importance. Ulrike Groemping's RELAIMPO is one such (https://cran.r-project.org/web/packages/relaimpo/relaimpo.pdf). RELAIMPO is an R module that can be easily implemented within the framework of OLS regression and helpful in terms of generating qualitative insights wrt panel data. In addition, Groemping exhaustively reviews the many approaches to variable importance that have been proposed over the years. Wrt 2), the three (A,B,C) correlated dependent variables (DVs) could be simultaneously modeled with canonical correlation or MANOVA-type approaches. This would be informative as it would tell you how the importance of a predictor varies as a function of the DV. Assuming the DVs are non-negative, a useful normalizing transformation different from first-differencing would be the natural log. There are many advantages to natural logs including the fact that the resulting parameters are expressed as elasticities and they minimize retransformation bias when converting predictions back into their original units. If the DVs contain negative values Lee Cooper suggests log-centering (Market Share Analysis, http://www.anderson.ucla.edu/faculty/lee.cooper/MCI_Book/BOOKI2010.pdf). Cooper's book is a goldmine of applied ideas and suggestions wrt exploring panel data structures (his term is pooled time series models). Wrt 3), the short answer is yes, a multi-step, exploratory process makes sense, until you know more...much more. Within the context of econometric literature, Wooldridge's Econometric Analysis of Cross Section and Panel Data is the "go-to" resource. His book has the disadvantage of being almost purely theoretical with little in the way of practical, applied guidance. A good complement to Wooldridge is Badi Baltagi's Econometric Analysis of Panel Data which considers the inevitably messy nature of real world data. M. Hashem Pesaran's papers cover many panel data model issues not otherwise discussed in the econometric literature such as weak cross-sectional dependence and nonstationarity. I would recommend a google search using 'filetype:pdf hashem pesaran' to uncover his published papers. Linear models are not the only game in town. Weiss' reviews nonlinear mixed effects models in his lecture notes (http://www.unc.edu/courses/2008fall/ecol/563/001/docs/lectures/lecture27.htm). Similarly, Rob Hyndman's suggestion of 'boosted additive quantile regression' is another excellent example of a rigorous methodology for exploring complex, nonlinear panel data structures (http://ieeexplore.ieee.org/document/7423794/). An additional advantage to BAQR is that, being nonparametric and distribution free, it controls for extreme values (aka outliers) much more effectively than a natural log transformation which, in the presence of truly extreme valued data, does not capture heavy-tails. Econometric panel data models are only one type in the broader class of event data modelling. There is a large literature on the closely related topics of growth and hierarchical models, e.g., Gelman and Hill's Data Analysis Using Regression and Multilevel/Hierarchical Models, Singer and Willett's Applied Longitudinal Data Analysis or Raudenbush and Bryk's Hierarchical Linear Models are all excellent references covering a broad class of noneconometric models and methods including marketing science, education, health, the environment, and more.
Looking for advice regarding model selection for forecasting (dynamic?) panel data
Excellent question(s). Benny_dref's suggestions are useful. The first sentence of the OPs query is concerned with "selecting an appropriate forecasting model for panel data." With several DVs, more th
Looking for advice regarding model selection for forecasting (dynamic?) panel data Excellent question(s). Benny_dref's suggestions are useful. The first sentence of the OPs query is concerned with "selecting an appropriate forecasting model for panel data." With several DVs, more than a few predictors and a wide variety of possible methods and models to pursue, one has two broad avenues wrt model selection. The first is theoretical -- Wooldridge (referenced below) and the link to the DPM method(s) in the body of the OPs question provide guidance along those lines. The second avenue is empirical, e.g., which model has the most predictive power? explains the most variance? minimizes error? and/or minimizes AIC/BIC metrics? In other words, there are multiple possible criteria for model selection. You can pick one or triangulate across several metrics in distilling the information down to make that decision. The (linked) DPM deck in the body of the OPs query is exhaustive in covering theoretical issues wrt small T panel data, GMMs and instrumental variables (IVs). Note, however, that their approach is confirmatory and presumes that many, if not all, of the OPs more applied and practical concerns have been addressed and answered. Also, its high level of technical rigor can take an inexperienced modeller down a bewildered rabbit hole. My recommendation would be to step back from immediate pursuit of their prescriptions by building up to them using less demanding, more easily digested and exploratory approaches, methods and models. For instance, instead of GMMs, why not build up to their use with simpler, more tractable, easily implemented and understood OLS models? Or consider IVs: econometricians prefer IV solutions to issues wrt endogeneity but noneconometricians question whether or not they create as many problems as they solve. Of course, these problems begin with simply identifying an appropriate IV(s). Why not put these theoretical, last step issues aside until you know more about the behavior of the data? This also raises the possibility of stepping outside a purely econometric framework to consider methods and models proposed in other disciplines. As the OP notes in question 1), there are some exploratory issues to resolve wrt variable selection. PCA is widely employed but has the drawback of blurring the specificity inherent in the individual predictors. Why not use the Lasso for variable selection? Another approach to variable selection could be relative variable importance. Ulrike Groemping's RELAIMPO is one such (https://cran.r-project.org/web/packages/relaimpo/relaimpo.pdf). RELAIMPO is an R module that can be easily implemented within the framework of OLS regression and helpful in terms of generating qualitative insights wrt panel data. In addition, Groemping exhaustively reviews the many approaches to variable importance that have been proposed over the years. Wrt 2), the three (A,B,C) correlated dependent variables (DVs) could be simultaneously modeled with canonical correlation or MANOVA-type approaches. This would be informative as it would tell you how the importance of a predictor varies as a function of the DV. Assuming the DVs are non-negative, a useful normalizing transformation different from first-differencing would be the natural log. There are many advantages to natural logs including the fact that the resulting parameters are expressed as elasticities and they minimize retransformation bias when converting predictions back into their original units. If the DVs contain negative values Lee Cooper suggests log-centering (Market Share Analysis, http://www.anderson.ucla.edu/faculty/lee.cooper/MCI_Book/BOOKI2010.pdf). Cooper's book is a goldmine of applied ideas and suggestions wrt exploring panel data structures (his term is pooled time series models). Wrt 3), the short answer is yes, a multi-step, exploratory process makes sense, until you know more...much more. Within the context of econometric literature, Wooldridge's Econometric Analysis of Cross Section and Panel Data is the "go-to" resource. His book has the disadvantage of being almost purely theoretical with little in the way of practical, applied guidance. A good complement to Wooldridge is Badi Baltagi's Econometric Analysis of Panel Data which considers the inevitably messy nature of real world data. M. Hashem Pesaran's papers cover many panel data model issues not otherwise discussed in the econometric literature such as weak cross-sectional dependence and nonstationarity. I would recommend a google search using 'filetype:pdf hashem pesaran' to uncover his published papers. Linear models are not the only game in town. Weiss' reviews nonlinear mixed effects models in his lecture notes (http://www.unc.edu/courses/2008fall/ecol/563/001/docs/lectures/lecture27.htm). Similarly, Rob Hyndman's suggestion of 'boosted additive quantile regression' is another excellent example of a rigorous methodology for exploring complex, nonlinear panel data structures (http://ieeexplore.ieee.org/document/7423794/). An additional advantage to BAQR is that, being nonparametric and distribution free, it controls for extreme values (aka outliers) much more effectively than a natural log transformation which, in the presence of truly extreme valued data, does not capture heavy-tails. Econometric panel data models are only one type in the broader class of event data modelling. There is a large literature on the closely related topics of growth and hierarchical models, e.g., Gelman and Hill's Data Analysis Using Regression and Multilevel/Hierarchical Models, Singer and Willett's Applied Longitudinal Data Analysis or Raudenbush and Bryk's Hierarchical Linear Models are all excellent references covering a broad class of noneconometric models and methods including marketing science, education, health, the environment, and more.
Looking for advice regarding model selection for forecasting (dynamic?) panel data Excellent question(s). Benny_dref's suggestions are useful. The first sentence of the OPs query is concerned with "selecting an appropriate forecasting model for panel data." With several DVs, more th
35,674
Looking for advice regarding model selection for forecasting (dynamic?) panel data
Without seeing data this is difficult to answer but because the data is quarterly, it appears you have time-series data with categorical dimensions. If you're trying to build a regression and use the outputs for forecasting, building a multivariate model with only 30 observations is going to be difficult, and your model-fit will reflect that (either adjusted R2 or F-Stat). If you have to brute force this thing, I'd try a few of these steps: Run a correlation of all metrics to one-another to determine multicollinearity, this way you can see what metrics move together and can execute a form of 'manual' dimension reduction, as some metrics can be a proxy for another Select no more than three x-variables and run a single multivariate model for one of the companies, OR Pool your data and run a mixed-model (using company name as a categorical variable), which will greatly increase the amount of observations you have and therefore strengthen the model and it's predictive capacity OR Run an ARIMA on each companies quarterly data, see what you get
Looking for advice regarding model selection for forecasting (dynamic?) panel data
Without seeing data this is difficult to answer but because the data is quarterly, it appears you have time-series data with categorical dimensions. If you're trying to build a regression and use the
Looking for advice regarding model selection for forecasting (dynamic?) panel data Without seeing data this is difficult to answer but because the data is quarterly, it appears you have time-series data with categorical dimensions. If you're trying to build a regression and use the outputs for forecasting, building a multivariate model with only 30 observations is going to be difficult, and your model-fit will reflect that (either adjusted R2 or F-Stat). If you have to brute force this thing, I'd try a few of these steps: Run a correlation of all metrics to one-another to determine multicollinearity, this way you can see what metrics move together and can execute a form of 'manual' dimension reduction, as some metrics can be a proxy for another Select no more than three x-variables and run a single multivariate model for one of the companies, OR Pool your data and run a mixed-model (using company name as a categorical variable), which will greatly increase the amount of observations you have and therefore strengthen the model and it's predictive capacity OR Run an ARIMA on each companies quarterly data, see what you get
Looking for advice regarding model selection for forecasting (dynamic?) panel data Without seeing data this is difficult to answer but because the data is quarterly, it appears you have time-series data with categorical dimensions. If you're trying to build a regression and use the
35,675
Different variance-covariance matrices of random effects per fixed-effect group in lme4
Thanks to @amoeba and using @BenBolker's brief remark here Extensions such as allowing different residual variances or different variance-covariance matrices of random effects per (fixed-effect) group can be achieved, somewhat clunkily, by using the dummy() helper function to construct an indicator variable to multiply by individual levels of interest. we got to the bottom of the problem. The solution is following: Y ~ X*Condition + (X*Condition | Subject) + (0 + dummy(Condition, "A") + X:dummy(Condition, "A") | Trial) + (0 + dummy(Condition, "B") + X:dummy(Condition, "B") | Trial) The summary(model) in random effects yields: Groups Name Variance Std.Dev. Corr subject (Intercept) 0.89343 0.9452 X 0.11695 0.3420 -0.85 ConditionB 0.66731 0.8169 -0.33 0.06 X:ConditionB 0.07391 0.2719 0.34 -0.05 -0.47 Trial dummy(Condition, "A") 0.63854 0.7991 dummy(Condition, "A"):X 0.09372 0.3061 -0.76 Trial.1 dummy(Condition, "B") 0.88833 0.9425 dummy(Condition, "B"):X 0.12175 0.3489 -0.60 which now makes perfect sense, because only correlations that can be calculated are between intercepts and slopes for a certain condition (because they are estimated for the same trials). Correlations between Conditions are senseless. Furthermore, coef(model)$Trial now shows logical values: dummy(Condition, "A") dummy(Condition, "A"):X dummy(Condition, "B") dummy(Condition, "B"):X (Intercept) X ConditionB X:ConditionB A1 0.9198822 0.0209849 0 0 2.703544 -0.9929765 -0.07102448 0.2415836 A2 -1.3029020 0.3894812 0 0 2.703544 -0.9929765 -0.07102448 0.2415836 A3 1.1294702 -0.2475288 0 0 2.703544 -0.9929765 -0.07102448 0.2415836 B1 0.000000000 0.0000000000 1.21725268 -0.305314643 2.703544 -0.9929765 -0.07102448 0.2415836 B2 0.000000000 0.0000000000 0.88317976 -0.209529267 2.703544 -0.9929765 -0.07102448 0.2415836 B3 0.000000000 0.0000000000 0.27859781 -0.065708851 2.703544 -0.9929765 -0.07102448 0.2415836 Fixed effects are the same for all trials dummy(Condition, "A") intercepts and dummy(Condition, "A"):X slopes are calculated only for Condition A, in Condition B trials they are estimated to be 0, and vice versa. N.B. When specifying random effects for this purpose, it is important to: specify random effects for different groups of trials independently, not under the same |Trial. If you don't do that, lme4 will estimate random effects for all trials, not just for the given condition. include 0, so as to prevent lme4 from including a general random intercept across all trials.
Different variance-covariance matrices of random effects per fixed-effect group in lme4
Thanks to @amoeba and using @BenBolker's brief remark here Extensions such as allowing different residual variances or different variance-covariance matrices of random effects per (fixed-effect) grou
Different variance-covariance matrices of random effects per fixed-effect group in lme4 Thanks to @amoeba and using @BenBolker's brief remark here Extensions such as allowing different residual variances or different variance-covariance matrices of random effects per (fixed-effect) group can be achieved, somewhat clunkily, by using the dummy() helper function to construct an indicator variable to multiply by individual levels of interest. we got to the bottom of the problem. The solution is following: Y ~ X*Condition + (X*Condition | Subject) + (0 + dummy(Condition, "A") + X:dummy(Condition, "A") | Trial) + (0 + dummy(Condition, "B") + X:dummy(Condition, "B") | Trial) The summary(model) in random effects yields: Groups Name Variance Std.Dev. Corr subject (Intercept) 0.89343 0.9452 X 0.11695 0.3420 -0.85 ConditionB 0.66731 0.8169 -0.33 0.06 X:ConditionB 0.07391 0.2719 0.34 -0.05 -0.47 Trial dummy(Condition, "A") 0.63854 0.7991 dummy(Condition, "A"):X 0.09372 0.3061 -0.76 Trial.1 dummy(Condition, "B") 0.88833 0.9425 dummy(Condition, "B"):X 0.12175 0.3489 -0.60 which now makes perfect sense, because only correlations that can be calculated are between intercepts and slopes for a certain condition (because they are estimated for the same trials). Correlations between Conditions are senseless. Furthermore, coef(model)$Trial now shows logical values: dummy(Condition, "A") dummy(Condition, "A"):X dummy(Condition, "B") dummy(Condition, "B"):X (Intercept) X ConditionB X:ConditionB A1 0.9198822 0.0209849 0 0 2.703544 -0.9929765 -0.07102448 0.2415836 A2 -1.3029020 0.3894812 0 0 2.703544 -0.9929765 -0.07102448 0.2415836 A3 1.1294702 -0.2475288 0 0 2.703544 -0.9929765 -0.07102448 0.2415836 B1 0.000000000 0.0000000000 1.21725268 -0.305314643 2.703544 -0.9929765 -0.07102448 0.2415836 B2 0.000000000 0.0000000000 0.88317976 -0.209529267 2.703544 -0.9929765 -0.07102448 0.2415836 B3 0.000000000 0.0000000000 0.27859781 -0.065708851 2.703544 -0.9929765 -0.07102448 0.2415836 Fixed effects are the same for all trials dummy(Condition, "A") intercepts and dummy(Condition, "A"):X slopes are calculated only for Condition A, in Condition B trials they are estimated to be 0, and vice versa. N.B. When specifying random effects for this purpose, it is important to: specify random effects for different groups of trials independently, not under the same |Trial. If you don't do that, lme4 will estimate random effects for all trials, not just for the given condition. include 0, so as to prevent lme4 from including a general random intercept across all trials.
Different variance-covariance matrices of random effects per fixed-effect group in lme4 Thanks to @amoeba and using @BenBolker's brief remark here Extensions such as allowing different residual variances or different variance-covariance matrices of random effects per (fixed-effect) grou
35,676
How to test if multiple regression coefficients are not statistically different?
You can use the $F$ test to test any linear restrictions $L$ on your coefficients. Let your null hypothesis be $H_0:L\beta = c$ and your design matrix $X$ with rank $k$. Then the $F$ statistic will be: $$ F = \frac{(L\hat{\beta}- c)'(\hat{\sigma}^2L(X'X)^{-1}L')^{-1}(L\hat{\beta} - c)}{q} $$ where $q$ is the number of restrictions you are testing. Under the null this will have an $F$ distribution with degrees of freedom $q$ and $n-k$. In R you can easily do that with the function linearHypothesis of the car package. For example: library(car) lm.model <- lm(mtcars) linearHypothesis(lm.model, c("cyl = 0", "disp = 0", "hp = 0")) # all 3 zero linearHypothesis(lm.model, c("cyl = disp", "disp = hp")) # all 3 equal
How to test if multiple regression coefficients are not statistically different?
You can use the $F$ test to test any linear restrictions $L$ on your coefficients. Let your null hypothesis be $H_0:L\beta = c$ and your design matrix $X$ with rank $k$. Then the $F$ statistic will be
How to test if multiple regression coefficients are not statistically different? You can use the $F$ test to test any linear restrictions $L$ on your coefficients. Let your null hypothesis be $H_0:L\beta = c$ and your design matrix $X$ with rank $k$. Then the $F$ statistic will be: $$ F = \frac{(L\hat{\beta}- c)'(\hat{\sigma}^2L(X'X)^{-1}L')^{-1}(L\hat{\beta} - c)}{q} $$ where $q$ is the number of restrictions you are testing. Under the null this will have an $F$ distribution with degrees of freedom $q$ and $n-k$. In R you can easily do that with the function linearHypothesis of the car package. For example: library(car) lm.model <- lm(mtcars) linearHypothesis(lm.model, c("cyl = 0", "disp = 0", "hp = 0")) # all 3 zero linearHypothesis(lm.model, c("cyl = disp", "disp = hp")) # all 3 equal
How to test if multiple regression coefficients are not statistically different? You can use the $F$ test to test any linear restrictions $L$ on your coefficients. Let your null hypothesis be $H_0:L\beta = c$ and your design matrix $X$ with rank $k$. Then the $F$ statistic will be
35,677
Simulate AR(1) process in R with specified nonzero mean and AR coefficient
Notice that this is the same model as $$ X_t - 10 = .5(X_{t-1} - 10) + Z_t . $$ $10$ is the mean, while $5$ was the intercept. This means we can add ten to the mean zero series. In other words, if you define $Y_t = X_t - 10$, then $$ Y_t = .5 Y_{t-1} + Z_t $$ and use arima.sim to simulate that. After you have $\{Y_t\}$, then add $10$ to each value. Code would look like this: yt <- arima.sim(list(order=c(1,0,0), ar=.5), n=500) xt <- yt + 10 Regarding the standard deviation issue, that is covered in the documentation.
Simulate AR(1) process in R with specified nonzero mean and AR coefficient
Notice that this is the same model as $$ X_t - 10 = .5(X_{t-1} - 10) + Z_t . $$ $10$ is the mean, while $5$ was the intercept. This means we can add ten to the mean zero series. In other words, if y
Simulate AR(1) process in R with specified nonzero mean and AR coefficient Notice that this is the same model as $$ X_t - 10 = .5(X_{t-1} - 10) + Z_t . $$ $10$ is the mean, while $5$ was the intercept. This means we can add ten to the mean zero series. In other words, if you define $Y_t = X_t - 10$, then $$ Y_t = .5 Y_{t-1} + Z_t $$ and use arima.sim to simulate that. After you have $\{Y_t\}$, then add $10$ to each value. Code would look like this: yt <- arima.sim(list(order=c(1,0,0), ar=.5), n=500) xt <- yt + 10 Regarding the standard deviation issue, that is covered in the documentation.
Simulate AR(1) process in R with specified nonzero mean and AR coefficient Notice that this is the same model as $$ X_t - 10 = .5(X_{t-1} - 10) + Z_t . $$ $10$ is the mean, while $5$ was the intercept. This means we can add ten to the mean zero series. In other words, if y
35,678
Question on Covariance for sampling without replacement
Problems in sampling from finite populations without replacement can usually be solved in terms of the sample inclusion probabilities $\pi(x)$, $\pi(x,y)$, etc. Let $\pi(x) = \Pr(X_1 = x)$ for any $x$ in the population $\mathcal P$ (with $n=10$ elements) and let $\pi(x,y)=\Pr((X_1,X_2)=(x,y))$ for any $x$ and $y$ in $\mathcal P$. By definition of expectation, $$E(X_1) = \sum_{x\in\mathcal P} \pi(x)x\tag{1}$$ and $$E(X_1X_2) = \sum_{(x,y)\in\mathcal{P}^2} \pi(x,y)x y \tag{2}.$$ For this sampling procedure $X_1$ has equal chances of being any of the $n$ elements of $\mathcal P $, whence $$\pi(x)=\frac{1}{n}\tag{3}$$ for all $x$. Because sampling is without replacement, only the pairs $(x,y)$ with $x\ne y$ are possible, but all $n(n-1)$ of those are equally likely. Therefore $$\pi(x,y) = \left\{\matrix{\frac{1}{n(n-1)} & x\ne y \\ 0 & x=y} \right.\tag{4}$$ That's the general result. For any particular population, you just have to do the arithmetic implied by formulae $(1)$ through $(4)$. Suppose now that $\mathcal{P} = \{1,2,\ldots, n\}$. Formulae $(1)$ and $(3)$ give $$E(X_1) = \sum_{i=1}^{n} \frac{1}{n} i = \frac{n+1}{2}$$ while formulae $(2)$ and $(4)$ give $$\eqalign{E(X_1X_2) &= \sum_{i,j=1;\, i\ne j}^{n} \frac{1}{n(n-1)} i j \\ &= \frac{1}{n(n-1)}\left(\sum_{i=1}^{n}\sum_{j=1}^{n} i j - \sum_{i=1}^{n} i^2\right)\\ &= \frac{1}{n(n-1)}\left(\sum_{i=1}^{n}i\ \sum_{j=1}^{n} j - \sum_{i=1}^{n} i^2\right)\\ &= \frac{1}{n(n-1)}\left(\left(\frac{n(n+1)}{2}\right)^2 - \frac{n(1+n)(1+2n)}{6}\right) \\ &= \frac{3n^2 + 5n + 2}{12}. }$$ Because there is no distinction among any of the $X_i$, these results hold for any $i \ne j$, not just $i=1$ and $j=2$. In particular, $$\operatorname{Cov}(X_i,X_j) = E(X_iX_j) - E(X_i)E(X_j) = \frac{3n^2 + 5n + 2}{12} - \left(\frac{n+1}{2}\right)^2 = -\frac{n+1}{12}.$$ When $n=10$, the covariance of $X_i$ and $X_j$ is $-11/12 \approx -0.917$. As a check, here is a simulation of a million such samples (using R): > cov(t(replicate(1e6, sample.int(10, 5)))) The output is the $5\times 5$ covariance matrix of $(X_1, \ldots, X_5)$. Because this is a simulation the output is random; but because it's a largish simulation, it's reasonably stable from one run to the next. In the first simulation I did, the off-diagonal elements of this covariance matrix ranged from $-0.9277$ to $-0.9080$ with a mean of $-0.9169$: narrowly spread around $-11/12$ as one would expect.
Question on Covariance for sampling without replacement
Problems in sampling from finite populations without replacement can usually be solved in terms of the sample inclusion probabilities $\pi(x)$, $\pi(x,y)$, etc. Let $\pi(x) = \Pr(X_1 = x)$ for any $x
Question on Covariance for sampling without replacement Problems in sampling from finite populations without replacement can usually be solved in terms of the sample inclusion probabilities $\pi(x)$, $\pi(x,y)$, etc. Let $\pi(x) = \Pr(X_1 = x)$ for any $x$ in the population $\mathcal P$ (with $n=10$ elements) and let $\pi(x,y)=\Pr((X_1,X_2)=(x,y))$ for any $x$ and $y$ in $\mathcal P$. By definition of expectation, $$E(X_1) = \sum_{x\in\mathcal P} \pi(x)x\tag{1}$$ and $$E(X_1X_2) = \sum_{(x,y)\in\mathcal{P}^2} \pi(x,y)x y \tag{2}.$$ For this sampling procedure $X_1$ has equal chances of being any of the $n$ elements of $\mathcal P $, whence $$\pi(x)=\frac{1}{n}\tag{3}$$ for all $x$. Because sampling is without replacement, only the pairs $(x,y)$ with $x\ne y$ are possible, but all $n(n-1)$ of those are equally likely. Therefore $$\pi(x,y) = \left\{\matrix{\frac{1}{n(n-1)} & x\ne y \\ 0 & x=y} \right.\tag{4}$$ That's the general result. For any particular population, you just have to do the arithmetic implied by formulae $(1)$ through $(4)$. Suppose now that $\mathcal{P} = \{1,2,\ldots, n\}$. Formulae $(1)$ and $(3)$ give $$E(X_1) = \sum_{i=1}^{n} \frac{1}{n} i = \frac{n+1}{2}$$ while formulae $(2)$ and $(4)$ give $$\eqalign{E(X_1X_2) &= \sum_{i,j=1;\, i\ne j}^{n} \frac{1}{n(n-1)} i j \\ &= \frac{1}{n(n-1)}\left(\sum_{i=1}^{n}\sum_{j=1}^{n} i j - \sum_{i=1}^{n} i^2\right)\\ &= \frac{1}{n(n-1)}\left(\sum_{i=1}^{n}i\ \sum_{j=1}^{n} j - \sum_{i=1}^{n} i^2\right)\\ &= \frac{1}{n(n-1)}\left(\left(\frac{n(n+1)}{2}\right)^2 - \frac{n(1+n)(1+2n)}{6}\right) \\ &= \frac{3n^2 + 5n + 2}{12}. }$$ Because there is no distinction among any of the $X_i$, these results hold for any $i \ne j$, not just $i=1$ and $j=2$. In particular, $$\operatorname{Cov}(X_i,X_j) = E(X_iX_j) - E(X_i)E(X_j) = \frac{3n^2 + 5n + 2}{12} - \left(\frac{n+1}{2}\right)^2 = -\frac{n+1}{12}.$$ When $n=10$, the covariance of $X_i$ and $X_j$ is $-11/12 \approx -0.917$. As a check, here is a simulation of a million such samples (using R): > cov(t(replicate(1e6, sample.int(10, 5)))) The output is the $5\times 5$ covariance matrix of $(X_1, \ldots, X_5)$. Because this is a simulation the output is random; but because it's a largish simulation, it's reasonably stable from one run to the next. In the first simulation I did, the off-diagonal elements of this covariance matrix ranged from $-0.9277$ to $-0.9080$ with a mean of $-0.9169$: narrowly spread around $-11/12$ as one would expect.
Question on Covariance for sampling without replacement Problems in sampling from finite populations without replacement can usually be solved in terms of the sample inclusion probabilities $\pi(x)$, $\pi(x,y)$, etc. Let $\pi(x) = \Pr(X_1 = x)$ for any $x
35,679
Visualizing a multilevel model (HLM) in ggplot2
When you fit an lmer model, you can use the coef() function to extract the coefficients from the model. Your code would look something like: mod1 <- lmer(GDP ~ 1 + CO2.Emissions + (1 + CO2.Emissions | Country), data=dat) Then you can call coef() and extract the coefficients for each group by specifying: coef(mod1)$Country This will give you a vector of intercepts (the '1' you specified in the random term) and slopes (for 'C02.Emissions'). You can then save each of these into their own vector: intercepts <- coef(mod1)$Country[,1] # Specifying the first column only slopes <- coef(mod1)$Country[,2] # Specifying the second column only Instead of calling geom_smooth(), you could then specify specific slopes and intercepts by adding this to your plot: geom_abline(slope=slopes, intercept=intercepts) The positive of this is that it is using the model-implied slopes and intercepts. The downside is that it will extrapolate the lines beyond the values for each cluster (in this case, 'Country'). I would then add another geom_abline that is the average slope and intercept, which you can get from: summary(mod1)$coef Another way of doing this—that is not using the model-implied slopes and intercepts—is by specifying group=cluster. Using this, it fits a different OLS line for each cluster (which is not what the multilevel model fit with lmer() is doing, obviously). I've done this before, and it adapted to your variables would look something like: ggplot(datalong, aes(x=CO2.Emissions, y=GDP, group=Country))+ stat_smooth(method="lm", se=FALSE, size=.5, color="springgreen") + # slopes for different countries stat_smooth(aes(group=1), method="lm", color="blue", size=1.5) + # average slope with SE This might be slightly easier to do, but it will not match up with the model-implied slopes and intercepts you get from the coef(lmer(...))$cluster approach.
Visualizing a multilevel model (HLM) in ggplot2
When you fit an lmer model, you can use the coef() function to extract the coefficients from the model. Your code would look something like: mod1 <- lmer(GDP ~ 1 + CO2.Emissions + (1 + CO2.Emissions |
Visualizing a multilevel model (HLM) in ggplot2 When you fit an lmer model, you can use the coef() function to extract the coefficients from the model. Your code would look something like: mod1 <- lmer(GDP ~ 1 + CO2.Emissions + (1 + CO2.Emissions | Country), data=dat) Then you can call coef() and extract the coefficients for each group by specifying: coef(mod1)$Country This will give you a vector of intercepts (the '1' you specified in the random term) and slopes (for 'C02.Emissions'). You can then save each of these into their own vector: intercepts <- coef(mod1)$Country[,1] # Specifying the first column only slopes <- coef(mod1)$Country[,2] # Specifying the second column only Instead of calling geom_smooth(), you could then specify specific slopes and intercepts by adding this to your plot: geom_abline(slope=slopes, intercept=intercepts) The positive of this is that it is using the model-implied slopes and intercepts. The downside is that it will extrapolate the lines beyond the values for each cluster (in this case, 'Country'). I would then add another geom_abline that is the average slope and intercept, which you can get from: summary(mod1)$coef Another way of doing this—that is not using the model-implied slopes and intercepts—is by specifying group=cluster. Using this, it fits a different OLS line for each cluster (which is not what the multilevel model fit with lmer() is doing, obviously). I've done this before, and it adapted to your variables would look something like: ggplot(datalong, aes(x=CO2.Emissions, y=GDP, group=Country))+ stat_smooth(method="lm", se=FALSE, size=.5, color="springgreen") + # slopes for different countries stat_smooth(aes(group=1), method="lm", color="blue", size=1.5) + # average slope with SE This might be slightly easier to do, but it will not match up with the model-implied slopes and intercepts you get from the coef(lmer(...))$cluster approach.
Visualizing a multilevel model (HLM) in ggplot2 When you fit an lmer model, you can use the coef() function to extract the coefficients from the model. Your code would look something like: mod1 <- lmer(GDP ~ 1 + CO2.Emissions + (1 + CO2.Emissions |
35,680
Visualizing a multilevel model (HLM) in ggplot2
When you want to plot lmer()objects, I find it easiest to use predict(). First you fit your model: random.coef.model <- lmer(GDP ~ 1 + CO2.Emissions + (1 + CO2.Emissions | Country), data=dat) Then you predict GDP values corresponding to your predictor variable (CO2.Emissions): dat$random.coefficients.predictions <- predict(random.coef.model) And then you are free to plot them either using geom_smooth(se=FALSE) or geom_line(). If you want to have a scatterplot at the same time, you need to feed geom_point() new aes(), as the existing y-values would be the predicted values. So: random.coef.graph <- ggplot(aes(x = CO2.Emissions, y = random.coefficients.predictions, color = as.factor(Country)), data = dat) + geom_line(size=.3) + geom_point(aes(y = GDP)) + ggthemes::theme_tufte() #just to make it nice!
Visualizing a multilevel model (HLM) in ggplot2
When you want to plot lmer()objects, I find it easiest to use predict(). First you fit your model: random.coef.model <- lmer(GDP ~ 1 + CO2.Emissions + (1 + CO2.Emissions | Country),
Visualizing a multilevel model (HLM) in ggplot2 When you want to plot lmer()objects, I find it easiest to use predict(). First you fit your model: random.coef.model <- lmer(GDP ~ 1 + CO2.Emissions + (1 + CO2.Emissions | Country), data=dat) Then you predict GDP values corresponding to your predictor variable (CO2.Emissions): dat$random.coefficients.predictions <- predict(random.coef.model) And then you are free to plot them either using geom_smooth(se=FALSE) or geom_line(). If you want to have a scatterplot at the same time, you need to feed geom_point() new aes(), as the existing y-values would be the predicted values. So: random.coef.graph <- ggplot(aes(x = CO2.Emissions, y = random.coefficients.predictions, color = as.factor(Country)), data = dat) + geom_line(size=.3) + geom_point(aes(y = GDP)) + ggthemes::theme_tufte() #just to make it nice!
Visualizing a multilevel model (HLM) in ggplot2 When you want to plot lmer()objects, I find it easiest to use predict(). First you fit your model: random.coef.model <- lmer(GDP ~ 1 + CO2.Emissions + (1 + CO2.Emissions | Country),
35,681
Is there an accepted name for this error metric?
This is related to a coefficient of determination ($R^2$), actually, it's $1-R^2$, also called fraction of variance unexplained
Is there an accepted name for this error metric?
This is related to a coefficient of determination ($R^2$), actually, it's $1-R^2$, also called fraction of variance unexplained
Is there an accepted name for this error metric? This is related to a coefficient of determination ($R^2$), actually, it's $1-R^2$, also called fraction of variance unexplained
Is there an accepted name for this error metric? This is related to a coefficient of determination ($R^2$), actually, it's $1-R^2$, also called fraction of variance unexplained
35,682
Is it ever okay to drop missing observations?
The important distinction is in your case not the distinction between MCAR, MAR, and NMAR, but between real missing values and mechanical missing values. Real missing values are values that exist, but for some reason weren't recorded. Mechanical missing values don't exist, but the rectangular structure of a dataset forces us to give it a value, e.g. pregnancy status if your dataset also includes males. Imputation techniques are designed for real missing values. Your example is a case of mechanical missing values; the decision has not been made, so its value does not exist. If a substantial portion of migrants move on then that is an important feature of the migration process, and imputing those values hides that feature.
Is it ever okay to drop missing observations?
The important distinction is in your case not the distinction between MCAR, MAR, and NMAR, but between real missing values and mechanical missing values. Real missing values are values that exist, but
Is it ever okay to drop missing observations? The important distinction is in your case not the distinction between MCAR, MAR, and NMAR, but between real missing values and mechanical missing values. Real missing values are values that exist, but for some reason weren't recorded. Mechanical missing values don't exist, but the rectangular structure of a dataset forces us to give it a value, e.g. pregnancy status if your dataset also includes males. Imputation techniques are designed for real missing values. Your example is a case of mechanical missing values; the decision has not been made, so its value does not exist. If a substantial portion of migrants move on then that is an important feature of the migration process, and imputing those values hides that feature.
Is it ever okay to drop missing observations? The important distinction is in your case not the distinction between MCAR, MAR, and NMAR, but between real missing values and mechanical missing values. Real missing values are values that exist, but
35,683
Is it ever okay to drop missing observations?
It is clear a mix of at least 2 different missingness processes. People that die from procedure unrelated causes/abandon/etc. due to reasons other than the likely outcome of the procedure. Here some imputation under MAR makes sense (if you can clearly identify the cases). People that give up/withdraw/drop-out due to not fulfilling some rules and/or thinking they are unlikely to be successful or that it is too much hassle. Here it depends on whether you can from the data you have assess their chances if they had continued. If you can a MAR assumption is fine, otherwise you have a difficult MNAR situation. What to do about MNAR is difficult. Assuming such cases had no success may be a bit extreme (or very appropriate, after all they did not succeed). Or impute under MAR and look at making these cases less successful until you hit 0% and contemplate that range of values.
Is it ever okay to drop missing observations?
It is clear a mix of at least 2 different missingness processes. People that die from procedure unrelated causes/abandon/etc. due to reasons other than the likely outcome of the procedure. Here some
Is it ever okay to drop missing observations? It is clear a mix of at least 2 different missingness processes. People that die from procedure unrelated causes/abandon/etc. due to reasons other than the likely outcome of the procedure. Here some imputation under MAR makes sense (if you can clearly identify the cases). People that give up/withdraw/drop-out due to not fulfilling some rules and/or thinking they are unlikely to be successful or that it is too much hassle. Here it depends on whether you can from the data you have assess their chances if they had continued. If you can a MAR assumption is fine, otherwise you have a difficult MNAR situation. What to do about MNAR is difficult. Assuming such cases had no success may be a bit extreme (or very appropriate, after all they did not succeed). Or impute under MAR and look at making these cases less successful until you hit 0% and contemplate that range of values.
Is it ever okay to drop missing observations? It is clear a mix of at least 2 different missingness processes. People that die from procedure unrelated causes/abandon/etc. due to reasons other than the likely outcome of the procedure. Here some
35,684
Scaling/Normalization not need for tree based models
If you are scaling the outcome variable, all you are doing is multiplying everything by a constant and/or adding a constant. So, any effect that it has is irrelevant (i.e., it does not change the relativities of anything). In the case of the predictors, the scale of the predictor variables is not a determinant of the predictions in any way with a traditional tree-based model. For example, consider the following simple example with 4 observation, where y is the outcome and x is the predictor. y x 0 5 1 5 2 6 3 6 The optimal split for predicting y given x is somewhere between x being 5 and 6. Let's say 5.5 Now, if we scale x, by multipling it by 100, we change our optimal split to being, say, 550. But, our predictions (and thus our error) are completely unchanged. y x 0 500 1 500 2 600 3 600
Scaling/Normalization not need for tree based models
If you are scaling the outcome variable, all you are doing is multiplying everything by a constant and/or adding a constant. So, any effect that it has is irrelevant (i.e., it does not change the rela
Scaling/Normalization not need for tree based models If you are scaling the outcome variable, all you are doing is multiplying everything by a constant and/or adding a constant. So, any effect that it has is irrelevant (i.e., it does not change the relativities of anything). In the case of the predictors, the scale of the predictor variables is not a determinant of the predictions in any way with a traditional tree-based model. For example, consider the following simple example with 4 observation, where y is the outcome and x is the predictor. y x 0 5 1 5 2 6 3 6 The optimal split for predicting y given x is somewhere between x being 5 and 6. Let's say 5.5 Now, if we scale x, by multipling it by 100, we change our optimal split to being, say, 550. But, our predictions (and thus our error) are completely unchanged. y x 0 500 1 500 2 600 3 600
Scaling/Normalization not need for tree based models If you are scaling the outcome variable, all you are doing is multiplying everything by a constant and/or adding a constant. So, any effect that it has is irrelevant (i.e., it does not change the rela
35,685
Benefits of SVM as a tool for digit recognition
Tutorials for many different classifiers are based on digit recognition, particularly the MNIST data set. I think this is largely because this dataset is readily available, easy to understand, and requires minimal preprocessing. It's also a common benchmark dataset in the literature. I'm not aware of arguments that any particular family of classifiers is intrinsically most suitable for digit recognition. I think this would be a difficult argument to make because 1) The distribution of digits comes from the real world and we don't have a comprehensive mathematical description of it, and 2) The set of all SVMs, all neural nets, etc. is infinite, and we've only managed to explore a tiny subset. Perhaps the best known neural net is better than the best known SVM, but a new kernel function is lurking somewhere in that vast, undiscovered space that would make SVMs better. Perhaps there's another neural net architecture that would be better still. I suppose arguments could be made in certain cases (e.g. naive Bayes on raw pixels is probably a bad idea because its assumptions are blatantly violated). There are many reasons to prefer each type of classifier over others in different circumstances (e.g. time/memory required for training/evaluation, amount of tweaking/exploration required to get a decent working model, etc.). These reasons aren't specific to digit recognition, so I won't go into them here. There are certainly domain-specific tricks than can make classifiers more suitable for digit recognition. Some of these tricks work by increasing invariance to particular transformations that one would expect in handwritten digits (e.g. translation, rotation, scaling, deformation). For example, the digit '0' should mean the same thing, even if it's shifted to the left and warped a little bit. Some of the tricks are specific to the family of classifiers. For example, this kind of invariance can be had using certain SVM kernels, spatial transformer layers in neural nets, or probably an invariant distance metric for K nearest neighbors. Other tricks can be used with many classifiers. For example, the dataset can be augmented with many transformed copies of the digits, which can help the classifier learn the proper invariance. SVMs, neural nets, and even kNN have achieved good performance on the MNIST dataset. Other methods work too. The best performance I've personally heard of has been with neural nets. Some results are accumulated across different papers here and here.
Benefits of SVM as a tool for digit recognition
Tutorials for many different classifiers are based on digit recognition, particularly the MNIST data set. I think this is largely because this dataset is readily available, easy to understand, and req
Benefits of SVM as a tool for digit recognition Tutorials for many different classifiers are based on digit recognition, particularly the MNIST data set. I think this is largely because this dataset is readily available, easy to understand, and requires minimal preprocessing. It's also a common benchmark dataset in the literature. I'm not aware of arguments that any particular family of classifiers is intrinsically most suitable for digit recognition. I think this would be a difficult argument to make because 1) The distribution of digits comes from the real world and we don't have a comprehensive mathematical description of it, and 2) The set of all SVMs, all neural nets, etc. is infinite, and we've only managed to explore a tiny subset. Perhaps the best known neural net is better than the best known SVM, but a new kernel function is lurking somewhere in that vast, undiscovered space that would make SVMs better. Perhaps there's another neural net architecture that would be better still. I suppose arguments could be made in certain cases (e.g. naive Bayes on raw pixels is probably a bad idea because its assumptions are blatantly violated). There are many reasons to prefer each type of classifier over others in different circumstances (e.g. time/memory required for training/evaluation, amount of tweaking/exploration required to get a decent working model, etc.). These reasons aren't specific to digit recognition, so I won't go into them here. There are certainly domain-specific tricks than can make classifiers more suitable for digit recognition. Some of these tricks work by increasing invariance to particular transformations that one would expect in handwritten digits (e.g. translation, rotation, scaling, deformation). For example, the digit '0' should mean the same thing, even if it's shifted to the left and warped a little bit. Some of the tricks are specific to the family of classifiers. For example, this kind of invariance can be had using certain SVM kernels, spatial transformer layers in neural nets, or probably an invariant distance metric for K nearest neighbors. Other tricks can be used with many classifiers. For example, the dataset can be augmented with many transformed copies of the digits, which can help the classifier learn the proper invariance. SVMs, neural nets, and even kNN have achieved good performance on the MNIST dataset. Other methods work too. The best performance I've personally heard of has been with neural nets. Some results are accumulated across different papers here and here.
Benefits of SVM as a tool for digit recognition Tutorials for many different classifiers are based on digit recognition, particularly the MNIST data set. I think this is largely because this dataset is readily available, easy to understand, and req
35,686
Covariance in Gaussian Process
Noise parameter, $\sigma^2$, is the parameter of the likelihood function a.k.a noise function. The one with $+\sigma^2$ is the variance of $y$ (observation). The one without is the variance of $f$ (latent variable = observation - noise). So they are off from each other by $\sigma^2$ which is the same for all values of input variable $x$. The formulas look right to me. As you see the variance of $y$ (the noiseless observation) is also dependent on the noise parameter. It make sense too. Your estimation of noise would affect the uncertainty estimate (i.e. variance) of the (noiseless) latent variable. To avoid confusion I would refer to them by $\mathrm{var}(y)$ and $\mathrm{var}(f)$. One more thing: the two expressions you denoted by $\Sigma$ are scalars, not matrices. The covariance matrix is $K$ not $\Sigma$. $\Sigma$ is variance not covariance since it is about a single $1$-D variable (either $y$ or $f$).
Covariance in Gaussian Process
Noise parameter, $\sigma^2$, is the parameter of the likelihood function a.k.a noise function. The one with $+\sigma^2$ is the variance of $y$ (observation). The one without is the variance of $f$ (l
Covariance in Gaussian Process Noise parameter, $\sigma^2$, is the parameter of the likelihood function a.k.a noise function. The one with $+\sigma^2$ is the variance of $y$ (observation). The one without is the variance of $f$ (latent variable = observation - noise). So they are off from each other by $\sigma^2$ which is the same for all values of input variable $x$. The formulas look right to me. As you see the variance of $y$ (the noiseless observation) is also dependent on the noise parameter. It make sense too. Your estimation of noise would affect the uncertainty estimate (i.e. variance) of the (noiseless) latent variable. To avoid confusion I would refer to them by $\mathrm{var}(y)$ and $\mathrm{var}(f)$. One more thing: the two expressions you denoted by $\Sigma$ are scalars, not matrices. The covariance matrix is $K$ not $\Sigma$. $\Sigma$ is variance not covariance since it is about a single $1$-D variable (either $y$ or $f$).
Covariance in Gaussian Process Noise parameter, $\sigma^2$, is the parameter of the likelihood function a.k.a noise function. The one with $+\sigma^2$ is the variance of $y$ (observation). The one without is the variance of $f$ (l
35,687
R polynomial expansion error on "unique points" and degree
In R, the poly function generates a polynomial and then does a QR decomposition to make it orthogonal. For high degree polynomial input, you'll get a high condition number for the Vandermode matrix, and when poly tries to make the columns orthogonal, it's going to throw an error (because the input looks rank deficient within the limits of double precision floating point). Consider: x <- poly(runif(100),30,raw=TRUE) QR <- qr(x) QR$rank This is basically what's in the source code of poly. QR$rank is going to be far lower than the degree.
R polynomial expansion error on "unique points" and degree
In R, the poly function generates a polynomial and then does a QR decomposition to make it orthogonal. For high degree polynomial input, you'll get a high condition number for the Vandermode matrix, a
R polynomial expansion error on "unique points" and degree In R, the poly function generates a polynomial and then does a QR decomposition to make it orthogonal. For high degree polynomial input, you'll get a high condition number for the Vandermode matrix, and when poly tries to make the columns orthogonal, it's going to throw an error (because the input looks rank deficient within the limits of double precision floating point). Consider: x <- poly(runif(100),30,raw=TRUE) QR <- qr(x) QR$rank This is basically what's in the source code of poly. QR$rank is going to be far lower than the degree.
R polynomial expansion error on "unique points" and degree In R, the poly function generates a polynomial and then does a QR decomposition to make it orthogonal. For high degree polynomial input, you'll get a high condition number for the Vandermode matrix, a
35,688
How to Estimate Population Variance from Multiple Samples
A comment clarified that the best estimator of the variance is intended to be unbiased. A standard way to find such an estimator is to restrict one's attention to linear combinations of the estimators (because almost anything else would be difficult to analyze). Let there be $k$ independent samples indexed by $i=1,2,\ldots, k$, each with its own unbiased variance estimator $\hat\sigma_i^2$. Let the unknown weights of the linear combination be $w_i$, so that the combined estimator will be $$\hat\sigma^2 = \sum_{i=1}^k w_i \hat \sigma_i^2.$$ Because this is supposed to be unbiased for any population, by definition the population variance will equal its expected value: $$\sigma^2 = \mathbb{E}(\hat\sigma^2) = \sum_{i=1}^k w_i \mathbb{E}(\hat\sigma_i^2) = \sum_{i=1}^k w_i \sigma^2 = \left(\sum_{i=1}^k w_i\right)\sigma^2.$$ Since $\sigma^2 \ne 0$ is possible, division of both sides by $\sigma^2$ implies the weights sum to unity: $$1 = \sum_{i=1}^k w_i.$$ Let the sample size for estimator $\hat\sigma_i$ be $n_i$. (In the question all the $n_i$ are equal to $n$.) Because each estimator $\hat\sigma_i^2$ has $n_i-1$ degrees of freedom, its variance will be approximately proportional to $1/(n-1)$ times some value that is an (unknown) property $f$ of the population. (This unknown property depends on the first four moments of the population.) In fact, for a Normal population this is not an approximation at all: the variances of the estimators are exactly proportional to $1/(n_i-1)$. Therefore we may approximate the variance of the combined estimator as $$\operatorname{Var}(\hat\sigma^2) = \operatorname{Var}\left(\sum_{i=1}^k w_i \hat\sigma_i^2\right) = \sum_{i=1}^k w_i^2 \operatorname{Var}(\hat\sigma_i^2) \approx \sum_{i=1}^k w_i^2 \frac{f}{n_i-1}.$$ The second equality is due to the independence of the $k$ samples. Subject to the sum-to-unity constraint, this variance is minimized when the $w_i$ are proportional to $n_i-1$. Therefore an (approximate) minimum variance unbiased linear estimator of the population variance is $$\hat\sigma^2 = \frac{1}{n_1+\cdots n_k - k}\sum_{i=1}^k (n_i-1)\hat\sigma_i^2.$$ When all the $n_i$ are equal to a common value $n$, this reduces to the arithmetic mean of the individual variance estimators. It should be intuitively obvious that some kind of equally-weighted average of all $k$ estimators would be the best one in this case.
How to Estimate Population Variance from Multiple Samples
A comment clarified that the best estimator of the variance is intended to be unbiased. A standard way to find such an estimator is to restrict one's attention to linear combinations of the estimator
How to Estimate Population Variance from Multiple Samples A comment clarified that the best estimator of the variance is intended to be unbiased. A standard way to find such an estimator is to restrict one's attention to linear combinations of the estimators (because almost anything else would be difficult to analyze). Let there be $k$ independent samples indexed by $i=1,2,\ldots, k$, each with its own unbiased variance estimator $\hat\sigma_i^2$. Let the unknown weights of the linear combination be $w_i$, so that the combined estimator will be $$\hat\sigma^2 = \sum_{i=1}^k w_i \hat \sigma_i^2.$$ Because this is supposed to be unbiased for any population, by definition the population variance will equal its expected value: $$\sigma^2 = \mathbb{E}(\hat\sigma^2) = \sum_{i=1}^k w_i \mathbb{E}(\hat\sigma_i^2) = \sum_{i=1}^k w_i \sigma^2 = \left(\sum_{i=1}^k w_i\right)\sigma^2.$$ Since $\sigma^2 \ne 0$ is possible, division of both sides by $\sigma^2$ implies the weights sum to unity: $$1 = \sum_{i=1}^k w_i.$$ Let the sample size for estimator $\hat\sigma_i$ be $n_i$. (In the question all the $n_i$ are equal to $n$.) Because each estimator $\hat\sigma_i^2$ has $n_i-1$ degrees of freedom, its variance will be approximately proportional to $1/(n-1)$ times some value that is an (unknown) property $f$ of the population. (This unknown property depends on the first four moments of the population.) In fact, for a Normal population this is not an approximation at all: the variances of the estimators are exactly proportional to $1/(n_i-1)$. Therefore we may approximate the variance of the combined estimator as $$\operatorname{Var}(\hat\sigma^2) = \operatorname{Var}\left(\sum_{i=1}^k w_i \hat\sigma_i^2\right) = \sum_{i=1}^k w_i^2 \operatorname{Var}(\hat\sigma_i^2) \approx \sum_{i=1}^k w_i^2 \frac{f}{n_i-1}.$$ The second equality is due to the independence of the $k$ samples. Subject to the sum-to-unity constraint, this variance is minimized when the $w_i$ are proportional to $n_i-1$. Therefore an (approximate) minimum variance unbiased linear estimator of the population variance is $$\hat\sigma^2 = \frac{1}{n_1+\cdots n_k - k}\sum_{i=1}^k (n_i-1)\hat\sigma_i^2.$$ When all the $n_i$ are equal to a common value $n$, this reduces to the arithmetic mean of the individual variance estimators. It should be intuitively obvious that some kind of equally-weighted average of all $k$ estimators would be the best one in this case.
How to Estimate Population Variance from Multiple Samples A comment clarified that the best estimator of the variance is intended to be unbiased. A standard way to find such an estimator is to restrict one's attention to linear combinations of the estimator
35,689
How to Estimate Population Variance from Multiple Samples
How about putting a hat on your estimates of the variance for each of the N samples $\hat{\sigma}_{i}^{2}\simeq s_{i}^{2}\frac{n-1}{n}$ and appealing to the Law of Propagation of Uncertainty, add them in quadrature to get the estimate of the overall variance $\tilde{\sigma}^{2}=\sum_{i=1}^{N}\hat{\sigma}_{i}^{2}$
How to Estimate Population Variance from Multiple Samples
How about putting a hat on your estimates of the variance for each of the N samples $\hat{\sigma}_{i}^{2}\simeq s_{i}^{2}\frac{n-1}{n}$ and appealing to the Law of Propagation of Uncertainty, add them
How to Estimate Population Variance from Multiple Samples How about putting a hat on your estimates of the variance for each of the N samples $\hat{\sigma}_{i}^{2}\simeq s_{i}^{2}\frac{n-1}{n}$ and appealing to the Law of Propagation of Uncertainty, add them in quadrature to get the estimate of the overall variance $\tilde{\sigma}^{2}=\sum_{i=1}^{N}\hat{\sigma}_{i}^{2}$
How to Estimate Population Variance from Multiple Samples How about putting a hat on your estimates of the variance for each of the N samples $\hat{\sigma}_{i}^{2}\simeq s_{i}^{2}\frac{n-1}{n}$ and appealing to the Law of Propagation of Uncertainty, add them
35,690
How to Estimate Population Variance from Multiple Samples
I presume this is the issue where you have k samples size n of a population that are all random with a given mean m and sample unbiassed variance s^2. As you do not have the real population mean, NOR the population variance that is used in all the textbooks, you have to find a means to not only calculate this population mean (rather easy), but also have a good estimator of the population variance. I did not find a description how to do this in the HANDBOOK OF PARAMETRIC AND NONPARAMETRIC STATISTICAL PROCEDURES (2000 pages, really quite complete) and that leaves us two ways. Theory (approach each sample of the same parameter as RANDOM and thus state the population is a sum of the INDEPENDENT samples with a weight 1/k of each, giving you a resulting population variance if you pull another sample size n. Then multiply that population variance with n to obtain the population variance when pulling single size samples). Another way is to pragmatically create a program that simulates your population (does not have to be exact) to calculate variances of many sample sizes using your guessed formula and then see what method is actually (after 1000 repetitions, computers are patient) most robust. I propose you use the theoretical approach.
How to Estimate Population Variance from Multiple Samples
I presume this is the issue where you have k samples size n of a population that are all random with a given mean m and sample unbiassed variance s^2. As you do not have the real population mean, NOR
How to Estimate Population Variance from Multiple Samples I presume this is the issue where you have k samples size n of a population that are all random with a given mean m and sample unbiassed variance s^2. As you do not have the real population mean, NOR the population variance that is used in all the textbooks, you have to find a means to not only calculate this population mean (rather easy), but also have a good estimator of the population variance. I did not find a description how to do this in the HANDBOOK OF PARAMETRIC AND NONPARAMETRIC STATISTICAL PROCEDURES (2000 pages, really quite complete) and that leaves us two ways. Theory (approach each sample of the same parameter as RANDOM and thus state the population is a sum of the INDEPENDENT samples with a weight 1/k of each, giving you a resulting population variance if you pull another sample size n. Then multiply that population variance with n to obtain the population variance when pulling single size samples). Another way is to pragmatically create a program that simulates your population (does not have to be exact) to calculate variances of many sample sizes using your guessed formula and then see what method is actually (after 1000 repetitions, computers are patient) most robust. I propose you use the theoretical approach.
How to Estimate Population Variance from Multiple Samples I presume this is the issue where you have k samples size n of a population that are all random with a given mean m and sample unbiassed variance s^2. As you do not have the real population mean, NOR
35,691
Formula for Newey West Standard Error
Take your model of $$y_t=\beta_0+\beta_1x_t+u_t,$$ where $t=1,...,T$. We will assume there are no other regressors and that the serial correlation only lasts up to one period (so shocks do not persist for very long). To get the Newey-West/HAC standard error of $\beta_1$ that is robust to heteroskedasticity and autocorrelation up to 1 lag, you should: Estimate the model with OLS, which gives you usual $SE(\beta_1)$, the RMSE $\hat \sigma$, and the residuals $\hat u_1,...,\hat u_T$. Get the ${\hat r_1,...,\hat r_T}$ residuals from the auxiliary OLS regression of $x_t$ on a constant and calculate $\hat a_t = \hat u_t \cdot \hat r_t$ for $t=1,...,T$. If you had more regressors, you would include them as additional covariates. Assuming that the serial correlation lasts up to one period, calculate $$\hat v(1)=\sum_{t=1}^T \hat a_t^2+ \sum_{t=2}^T \hat a_t \cdot \hat a_{t-1}.$$ The first term in $\hat v$ is what gets you the het-consistent standard error. The second term is the autocorrelation part. Assuming the autocorrelation is positive, this is why your standard errors blow up: you have less information. If you autocorrelation lasted longer, you would have additional weighted terms for each each lag. You might want to use a finite sample correction multiplier of $\frac{T}{T-k}$ here, where we count the constant as one of the $k$ covariates. Calculate N-W standard error of $\beta_1$ as $$\left[ \frac{SE(\beta_1)}{\hat \sigma} \right]^2 \cdot \sqrt{ \hat v(1)}.$$ Here's an example with Stata (with the full data shown by the list command in case you want to use other software). This has a slight wrinkle in that Stata uses a default finite sample correction of $\frac{T}{T-k}$ that is not default in other statistics packages and is usually not shown in textbook formulas, though it is a sensible thing to do: . /* N-W Standard Errors With One Regressor and Serial Correlation That Dies Down After 1 Peri > od */ . webuse idle2, clear . tsset time time variable: time, 1 to 30 delta: 1 unit . list time usr idle, clean noobs time usr idle 1 0 100 2 0 100 3 0 97 4 1 98 5 2 94 6 0 98 7 2 90 8 3 85 9 1 68 10 2 91 11 2 94 12 2 89 13 1 88 14 4 92 15 7 74 16 7 76 17 8 71 18 4 78 19 5 75 20 10 74 21 16 65 22 12 63 23 3 83 24 2 60 25 3 85 26 5 87 27 6 83 28 5 84 29 1 98 30 1 98 . /* Step 1 */ . reg usr idle Source | SS df MS Number of obs = 30 -------------+---------------------------------- F(1, 28) = 28.07 Model | 210.35435 1 210.35435 Prob > F = 0.0000 Residual | 209.812316 28 7.49329702 R-squared = 0.5006 -------------+---------------------------------- Adj R-squared = 0.4828 Total | 420.166667 29 14.4885057 Root MSE = 2.7374 ------------------------------------------------------------------------------ usr | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- idle | -.2281501 .0430607 -5.30 0.000 -.3163559 -.1399442 _cons | 23.13483 3.67706 6.29 0.000 15.60271 30.66694 ------------------------------------------------------------------------------ . scalar se_beta1 = _se[idle] . scalar sigmahat = e(rmse) . predict double uhat, resid . /* Step 2 */ . reg idle Source | SS df MS Number of obs = 30 -------------+---------------------------------- F(0, 29) = 0.00 Model | 0 0 . Prob > F = . Residual | 4041.2 29 139.351724 R-squared = 0.0000 -------------+---------------------------------- Adj R-squared = 0.0000 Total | 4041.2 29 139.351724 Root MSE = 11.805 ------------------------------------------------------------------------------ idle | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- _cons | 84.6 2.15524 39.25 0.000 80.19204 89.00796 ------------------------------------------------------------------------------ . predict double rhat, resid . gen double ahat = uhat*rhat . /* Step 3 */ . gen double v = ahat^2 . replace v = v + ahat*L1.ahat in 2/L (29 real changes made) . sum v Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- v | 30 3070.853 8464.421 -256.7766 33901.46 . scalar v1 = r(sum) . scalar v1_fsc = r(sum)*(30/28) // Stata uses a finite sample correction of T/(T-k) . /* Step 4 */ . di "Usual N-W SE = " sqrt(scalar(v1))*[scalar(se_beta1)/scalar(sigmahat)]^2 Usual N-W SE = .07510689 . di "Stata's N-W SE = " sqrt(scalar(v1_fsc))*[scalar(se_beta1)/scalar(sigmahat)]^2 Stata's N-W SE = .07774301 . /* Comapare to newey command */ . newey usr idle, lag(1) Regression with Newey-West standard errors Number of obs = 30 maximum lag: 1 F( 1, 28) = 8.61 Prob > F = 0.0066 ------------------------------------------------------------------------------ | Newey-West usr | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- idle | -.2281501 .077743 -2.93 0.007 -.3873994 -.0689007 _cons | 23.13483 7.119611 3.25 0.003 8.550965 37.71869 ------------------------------------------------------------------------------ . di _se[idle] .07774301 As you can see, with the finite sample correction, newey matches what we did by hand at 0.07774301. I am not sure this example contains a whole lot of intuition, but YMMV. This is based on Wooldridge, Jeffrey M. "A computationally simple heteroskedasticity and serial correlation robust standard error for the linear regression model." Economics Letters 31.3 (1989): 239-243. Stata Code: /* N-W Standard Errors With One Regressor and Serial Correlation That Dies Down After 1 Period */ webuse idle2, clear tsset time list time usr idle, clean noobs /* Step 1 */ reg usr idle scalar se_beta1 = _se[idle] scalar sigmahat = e(rmse) predict double uhat, resid /* Step 2 */ reg idle predict double rhat, resid gen double ahat = uhat*rhat /* Step 3 */ gen double v = ahat^2 replace v = v + ahat*L1.ahat in 2/L sum v scalar v1 = r(sum) scalar v1_fsc = r(sum)*(30/28) // Stata uses a finite sample correction of T/(T-k) /* Step 4 */ di "Usual N-W SE = " sqrt(scalar(v1))*[scalar(se_beta1)/scalar(sigmahat)]^2 di "Stata's N-W SE = " sqrt(scalar(v1_fsc))*[scalar(se_beta1)/scalar(sigmahat)]^2 /* Compare to newey command */ newey usr idle, lag(1) di _se[idle] /* Compare To Smaller Robust Sandwich SE */ sum v scalar v0 = r(sum)*(30/28) di "Stata's Sandwich SE = " sqrt(scalar(v0))*[scalar(se_beta1)/scalar(sigmahat)]^2 reg usr idle, robust di _se[idle]
Formula for Newey West Standard Error
Take your model of $$y_t=\beta_0+\beta_1x_t+u_t,$$ where $t=1,...,T$. We will assume there are no other regressors and that the serial correlation only lasts up to one period (so shocks do not persist
Formula for Newey West Standard Error Take your model of $$y_t=\beta_0+\beta_1x_t+u_t,$$ where $t=1,...,T$. We will assume there are no other regressors and that the serial correlation only lasts up to one period (so shocks do not persist for very long). To get the Newey-West/HAC standard error of $\beta_1$ that is robust to heteroskedasticity and autocorrelation up to 1 lag, you should: Estimate the model with OLS, which gives you usual $SE(\beta_1)$, the RMSE $\hat \sigma$, and the residuals $\hat u_1,...,\hat u_T$. Get the ${\hat r_1,...,\hat r_T}$ residuals from the auxiliary OLS regression of $x_t$ on a constant and calculate $\hat a_t = \hat u_t \cdot \hat r_t$ for $t=1,...,T$. If you had more regressors, you would include them as additional covariates. Assuming that the serial correlation lasts up to one period, calculate $$\hat v(1)=\sum_{t=1}^T \hat a_t^2+ \sum_{t=2}^T \hat a_t \cdot \hat a_{t-1}.$$ The first term in $\hat v$ is what gets you the het-consistent standard error. The second term is the autocorrelation part. Assuming the autocorrelation is positive, this is why your standard errors blow up: you have less information. If you autocorrelation lasted longer, you would have additional weighted terms for each each lag. You might want to use a finite sample correction multiplier of $\frac{T}{T-k}$ here, where we count the constant as one of the $k$ covariates. Calculate N-W standard error of $\beta_1$ as $$\left[ \frac{SE(\beta_1)}{\hat \sigma} \right]^2 \cdot \sqrt{ \hat v(1)}.$$ Here's an example with Stata (with the full data shown by the list command in case you want to use other software). This has a slight wrinkle in that Stata uses a default finite sample correction of $\frac{T}{T-k}$ that is not default in other statistics packages and is usually not shown in textbook formulas, though it is a sensible thing to do: . /* N-W Standard Errors With One Regressor and Serial Correlation That Dies Down After 1 Peri > od */ . webuse idle2, clear . tsset time time variable: time, 1 to 30 delta: 1 unit . list time usr idle, clean noobs time usr idle 1 0 100 2 0 100 3 0 97 4 1 98 5 2 94 6 0 98 7 2 90 8 3 85 9 1 68 10 2 91 11 2 94 12 2 89 13 1 88 14 4 92 15 7 74 16 7 76 17 8 71 18 4 78 19 5 75 20 10 74 21 16 65 22 12 63 23 3 83 24 2 60 25 3 85 26 5 87 27 6 83 28 5 84 29 1 98 30 1 98 . /* Step 1 */ . reg usr idle Source | SS df MS Number of obs = 30 -------------+---------------------------------- F(1, 28) = 28.07 Model | 210.35435 1 210.35435 Prob > F = 0.0000 Residual | 209.812316 28 7.49329702 R-squared = 0.5006 -------------+---------------------------------- Adj R-squared = 0.4828 Total | 420.166667 29 14.4885057 Root MSE = 2.7374 ------------------------------------------------------------------------------ usr | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- idle | -.2281501 .0430607 -5.30 0.000 -.3163559 -.1399442 _cons | 23.13483 3.67706 6.29 0.000 15.60271 30.66694 ------------------------------------------------------------------------------ . scalar se_beta1 = _se[idle] . scalar sigmahat = e(rmse) . predict double uhat, resid . /* Step 2 */ . reg idle Source | SS df MS Number of obs = 30 -------------+---------------------------------- F(0, 29) = 0.00 Model | 0 0 . Prob > F = . Residual | 4041.2 29 139.351724 R-squared = 0.0000 -------------+---------------------------------- Adj R-squared = 0.0000 Total | 4041.2 29 139.351724 Root MSE = 11.805 ------------------------------------------------------------------------------ idle | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- _cons | 84.6 2.15524 39.25 0.000 80.19204 89.00796 ------------------------------------------------------------------------------ . predict double rhat, resid . gen double ahat = uhat*rhat . /* Step 3 */ . gen double v = ahat^2 . replace v = v + ahat*L1.ahat in 2/L (29 real changes made) . sum v Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- v | 30 3070.853 8464.421 -256.7766 33901.46 . scalar v1 = r(sum) . scalar v1_fsc = r(sum)*(30/28) // Stata uses a finite sample correction of T/(T-k) . /* Step 4 */ . di "Usual N-W SE = " sqrt(scalar(v1))*[scalar(se_beta1)/scalar(sigmahat)]^2 Usual N-W SE = .07510689 . di "Stata's N-W SE = " sqrt(scalar(v1_fsc))*[scalar(se_beta1)/scalar(sigmahat)]^2 Stata's N-W SE = .07774301 . /* Comapare to newey command */ . newey usr idle, lag(1) Regression with Newey-West standard errors Number of obs = 30 maximum lag: 1 F( 1, 28) = 8.61 Prob > F = 0.0066 ------------------------------------------------------------------------------ | Newey-West usr | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- idle | -.2281501 .077743 -2.93 0.007 -.3873994 -.0689007 _cons | 23.13483 7.119611 3.25 0.003 8.550965 37.71869 ------------------------------------------------------------------------------ . di _se[idle] .07774301 As you can see, with the finite sample correction, newey matches what we did by hand at 0.07774301. I am not sure this example contains a whole lot of intuition, but YMMV. This is based on Wooldridge, Jeffrey M. "A computationally simple heteroskedasticity and serial correlation robust standard error for the linear regression model." Economics Letters 31.3 (1989): 239-243. Stata Code: /* N-W Standard Errors With One Regressor and Serial Correlation That Dies Down After 1 Period */ webuse idle2, clear tsset time list time usr idle, clean noobs /* Step 1 */ reg usr idle scalar se_beta1 = _se[idle] scalar sigmahat = e(rmse) predict double uhat, resid /* Step 2 */ reg idle predict double rhat, resid gen double ahat = uhat*rhat /* Step 3 */ gen double v = ahat^2 replace v = v + ahat*L1.ahat in 2/L sum v scalar v1 = r(sum) scalar v1_fsc = r(sum)*(30/28) // Stata uses a finite sample correction of T/(T-k) /* Step 4 */ di "Usual N-W SE = " sqrt(scalar(v1))*[scalar(se_beta1)/scalar(sigmahat)]^2 di "Stata's N-W SE = " sqrt(scalar(v1_fsc))*[scalar(se_beta1)/scalar(sigmahat)]^2 /* Compare to newey command */ newey usr idle, lag(1) di _se[idle] /* Compare To Smaller Robust Sandwich SE */ sum v scalar v0 = r(sum)*(30/28) di "Stata's Sandwich SE = " sqrt(scalar(v0))*[scalar(se_beta1)/scalar(sigmahat)]^2 reg usr idle, robust di _se[idle]
Formula for Newey West Standard Error Take your model of $$y_t=\beta_0+\beta_1x_t+u_t,$$ where $t=1,...,T$. We will assume there are no other regressors and that the serial correlation only lasts up to one period (so shocks do not persist
35,692
Probability of people not facing their partner at a round table
Analysis Let's guess and then systematically improve the guess until it's correct. Begin by guessing the answer is $1$. Of course that's wrong. To see how wrong, label one partner in each pair "Red" and the other "Blue". From the perspective of any Red individual, there is a $1/(2n-1)$ chance that their (Blue) partner will sit across from them. Because there are $n$ red individuals, let's subtract $n\times 1/(2n-1)$ from that initial guess. But wait--that's still not quite right, because all pairs of couples have been double-counted. If one couple is seated opposite, there remain $n-1$ couples, $2n-2$ places, and from any Red individual's point of view, the chance that they are part of a second couple is $1/(2n-3)$. Therefore we need to re-add $\binom{n}{2}\times 1/(2n-1)\times 1/(2n-3)$. But now we have undercounted contributions to the result from triples of couples, which we need to correct. And so it goes, until finally we have accommodated all $n$ couples in the formula. (This, of course, is just the Principle of Inclusion-Exclusion in action.) The resulting formula is $$\sum_{i=0}^n (-1)^i \binom{n}{i} \frac{1}{(2n-1)(2n-3)\ldots (2n-2i+1)} = {_1}F_1\left(-n, -n+\frac{1}{2}, -\frac{1}{2}\right).\tag{1}$$ Computation For positive integers $n$, the Kummer confluent hypergeometric function ${_1}F_1\left(-n, -n+\frac{1}{2}, z\right)$ is a polynomial of degree $n$ in $z$. From the Kummer Transformation $${_1}F_1\left(-n, -n+\frac{1}{2}, -\frac{1}{2}\right) = e^{-1/2}\ {_1}F_1\left(\frac{1}{2}, -n+\frac{1}{2}, \frac{1}{2}\right)$$ it is straightforward to deduce that the limiting value of the probability as $n$ grows large is $e^{-1/2} \approx 0.6065306597\ldots$. The convergence is slow: you have to multiply $n$ by $10$ to attain an additional decimal digit. Nevertheless, accurate (double-precision) values can quickly be computed for any $n$ by noting that the terms in the left hand sum of $(1)$ grow more slowly than powers of $-1/2$. Thus, by the time $i$ reaches $52$, the new values will be essentially zero compared to $e^{-1/2}$ (and in fact a closer analysis suggests that stopping the summation by $i=45$ will work). This formula will break down for $n$ greater than 10,000,000 in certain computing environments due to imprecision in the log Gamma function. The problem arises from cancellation in the differences arising when computing terms in the series. An excellent approximation to those differences when $n$ is sufficiently large can be found in terms of $\psi(n-1/4)$, where $\psi$ is the derivative of $\log \Gamma$ (the digamma function). That is implemented in the code below, at a slight cost in computation time. Implementation The following R code computes about 20,000 double-precision values per second. f <- function(n) { h <- function(n) { ifelse(n < 1e6, lfactorial(n) - lfactorial(n-1/2), digamma(n+3/4)/2) } m <- min(n, 46) k <- 0:m x <- exp(h(n) - h(n-k) - lfactorial(k) - k*log(2)) * (-1)^k sum(x) } As an example, let's track how closely log(f(n)) comes to its limiting value of $-1/2$ for large $n$. As claimed above, each factor of $10$ in $n$ adds one decimal place of limiting accuracy. Let's therefore look at the $n^\text{th}$ decimal place in the logarithm of the ratio of $f(n)$ to $e^{-1/2}$, for whole powers of $10$ from $n=10^1$ through $n=10^{14}$: > round(sapply(1:14, function(n) 10^n * (log(f(10^n)) + 1/2)), 3) [1] -0.255 -0.251 -0.250 ... -0.250 -0.249 -0.249 -0.400 (Seven values have been omitted from the middle, all equal to -0.250.) The constant pattern is clear. At the end, with $n=10^{14}$, it starts to break down, indicating loss of precision. Improving on this would likely require high-precision arithmetic.
Probability of people not facing their partner at a round table
Analysis Let's guess and then systematically improve the guess until it's correct. Begin by guessing the answer is $1$. Of course that's wrong. To see how wrong, label one partner in each pair "Red"
Probability of people not facing their partner at a round table Analysis Let's guess and then systematically improve the guess until it's correct. Begin by guessing the answer is $1$. Of course that's wrong. To see how wrong, label one partner in each pair "Red" and the other "Blue". From the perspective of any Red individual, there is a $1/(2n-1)$ chance that their (Blue) partner will sit across from them. Because there are $n$ red individuals, let's subtract $n\times 1/(2n-1)$ from that initial guess. But wait--that's still not quite right, because all pairs of couples have been double-counted. If one couple is seated opposite, there remain $n-1$ couples, $2n-2$ places, and from any Red individual's point of view, the chance that they are part of a second couple is $1/(2n-3)$. Therefore we need to re-add $\binom{n}{2}\times 1/(2n-1)\times 1/(2n-3)$. But now we have undercounted contributions to the result from triples of couples, which we need to correct. And so it goes, until finally we have accommodated all $n$ couples in the formula. (This, of course, is just the Principle of Inclusion-Exclusion in action.) The resulting formula is $$\sum_{i=0}^n (-1)^i \binom{n}{i} \frac{1}{(2n-1)(2n-3)\ldots (2n-2i+1)} = {_1}F_1\left(-n, -n+\frac{1}{2}, -\frac{1}{2}\right).\tag{1}$$ Computation For positive integers $n$, the Kummer confluent hypergeometric function ${_1}F_1\left(-n, -n+\frac{1}{2}, z\right)$ is a polynomial of degree $n$ in $z$. From the Kummer Transformation $${_1}F_1\left(-n, -n+\frac{1}{2}, -\frac{1}{2}\right) = e^{-1/2}\ {_1}F_1\left(\frac{1}{2}, -n+\frac{1}{2}, \frac{1}{2}\right)$$ it is straightforward to deduce that the limiting value of the probability as $n$ grows large is $e^{-1/2} \approx 0.6065306597\ldots$. The convergence is slow: you have to multiply $n$ by $10$ to attain an additional decimal digit. Nevertheless, accurate (double-precision) values can quickly be computed for any $n$ by noting that the terms in the left hand sum of $(1)$ grow more slowly than powers of $-1/2$. Thus, by the time $i$ reaches $52$, the new values will be essentially zero compared to $e^{-1/2}$ (and in fact a closer analysis suggests that stopping the summation by $i=45$ will work). This formula will break down for $n$ greater than 10,000,000 in certain computing environments due to imprecision in the log Gamma function. The problem arises from cancellation in the differences arising when computing terms in the series. An excellent approximation to those differences when $n$ is sufficiently large can be found in terms of $\psi(n-1/4)$, where $\psi$ is the derivative of $\log \Gamma$ (the digamma function). That is implemented in the code below, at a slight cost in computation time. Implementation The following R code computes about 20,000 double-precision values per second. f <- function(n) { h <- function(n) { ifelse(n < 1e6, lfactorial(n) - lfactorial(n-1/2), digamma(n+3/4)/2) } m <- min(n, 46) k <- 0:m x <- exp(h(n) - h(n-k) - lfactorial(k) - k*log(2)) * (-1)^k sum(x) } As an example, let's track how closely log(f(n)) comes to its limiting value of $-1/2$ for large $n$. As claimed above, each factor of $10$ in $n$ adds one decimal place of limiting accuracy. Let's therefore look at the $n^\text{th}$ decimal place in the logarithm of the ratio of $f(n)$ to $e^{-1/2}$, for whole powers of $10$ from $n=10^1$ through $n=10^{14}$: > round(sapply(1:14, function(n) 10^n * (log(f(10^n)) + 1/2)), 3) [1] -0.255 -0.251 -0.250 ... -0.250 -0.249 -0.249 -0.400 (Seven values have been omitted from the middle, all equal to -0.250.) The constant pattern is clear. At the end, with $n=10^{14}$, it starts to break down, indicating loss of precision. Improving on this would likely require high-precision arithmetic.
Probability of people not facing their partner at a round table Analysis Let's guess and then systematically improve the guess until it's correct. Begin by guessing the answer is $1$. Of course that's wrong. To see how wrong, label one partner in each pair "Red"
35,693
Probability of people not facing their partner at a round table
Why would the intuitive method work? Think of the table as a collection of pairs; that is, instead of the traditional North-West-East-South cross of a bridge table, we look at it like a table with two rows: North-South West-East If we condition on North being the senior partner of one couple, then there's a 1/3rd chance that South will be the junior partner of that couple, which then forces West and East to be a couple, and a 2/3rd chance that South will be a member of the other couple, and then the the last set is also definitely not a couple. When we extend from $n=2$ to $n=3$, we just add a row to the table: Northwest-Southeast North-South West-East If we set Northwest as always being the senior partner of the first couple, then there's clearly a $\frac{1}{5}$ chance that there's a paired couple and we can stop, and a $\frac{4}{5}$ chance that there isn't, and we can continue, with a smaller problem. Note that the smaller problem is a different one, though, which is 'coincidentally' the same. Instead of having four people and two couples going into the problem, we must have one couple and two singles, and the chance that the couple is paired up is $\frac{1}{3}$ (for the same reasons as before). This gives us a recursive approach; we can talk about a problem with two parameters, $(n,c)$, where $n$ refers to the number of people and $c$ refers to the number of couples. So $(8,4)$ gives us $\frac{6}{7}(6,2)$ (that is to say, four couples with 8 people gives us a $\frac{1}{7}$ chance of failure when assigning the first pair, and then the chance of failure for 2 couples and 6 people in the case where we survive), and then for $(6,2)$ we need to expand out four cases: Both of the next couple are single: $\frac{2*1}{6*5}(4,2)$ One was single, the other was in a couple: $\frac{4*2*2}{6*5}(4,1)$ Both were in different couples: $\frac{4*2}{6*5}(4,0)$ (Note that $(4,0)=1$, for obvious reasons.) Both were in the same couple: $\frac{4*1}{6*5}$ (This is a loss condition) If you go through and do all the math, I think you end up with $\frac{20}{35}$ for the 8 person case, which is not $\frac{6}{7}\frac{8}{15}$. (It's higher because of the chance that we totally break up the couples early on.) I'm not aware of an immediate trick that allows you to just use a combinatoric formula to get an answer in closed form, but it seems likely that there could be one. [edit: See whuber's answer for the solution.]
Probability of people not facing their partner at a round table
Why would the intuitive method work? Think of the table as a collection of pairs; that is, instead of the traditional North-West-East-South cross of a bridge table, we look at it like a table with two
Probability of people not facing their partner at a round table Why would the intuitive method work? Think of the table as a collection of pairs; that is, instead of the traditional North-West-East-South cross of a bridge table, we look at it like a table with two rows: North-South West-East If we condition on North being the senior partner of one couple, then there's a 1/3rd chance that South will be the junior partner of that couple, which then forces West and East to be a couple, and a 2/3rd chance that South will be a member of the other couple, and then the the last set is also definitely not a couple. When we extend from $n=2$ to $n=3$, we just add a row to the table: Northwest-Southeast North-South West-East If we set Northwest as always being the senior partner of the first couple, then there's clearly a $\frac{1}{5}$ chance that there's a paired couple and we can stop, and a $\frac{4}{5}$ chance that there isn't, and we can continue, with a smaller problem. Note that the smaller problem is a different one, though, which is 'coincidentally' the same. Instead of having four people and two couples going into the problem, we must have one couple and two singles, and the chance that the couple is paired up is $\frac{1}{3}$ (for the same reasons as before). This gives us a recursive approach; we can talk about a problem with two parameters, $(n,c)$, where $n$ refers to the number of people and $c$ refers to the number of couples. So $(8,4)$ gives us $\frac{6}{7}(6,2)$ (that is to say, four couples with 8 people gives us a $\frac{1}{7}$ chance of failure when assigning the first pair, and then the chance of failure for 2 couples and 6 people in the case where we survive), and then for $(6,2)$ we need to expand out four cases: Both of the next couple are single: $\frac{2*1}{6*5}(4,2)$ One was single, the other was in a couple: $\frac{4*2*2}{6*5}(4,1)$ Both were in different couples: $\frac{4*2}{6*5}(4,0)$ (Note that $(4,0)=1$, for obvious reasons.) Both were in the same couple: $\frac{4*1}{6*5}$ (This is a loss condition) If you go through and do all the math, I think you end up with $\frac{20}{35}$ for the 8 person case, which is not $\frac{6}{7}\frac{8}{15}$. (It's higher because of the chance that we totally break up the couples early on.) I'm not aware of an immediate trick that allows you to just use a combinatoric formula to get an answer in closed form, but it seems likely that there could be one. [edit: See whuber's answer for the solution.]
Probability of people not facing their partner at a round table Why would the intuitive method work? Think of the table as a collection of pairs; that is, instead of the traditional North-West-East-South cross of a bridge table, we look at it like a table with two
35,694
Which glm family to use for ordinal DV?
Given you have an ordinal response using the function MASS::polr should be more appropriate; it implements a proportional odds logistic regression routine. A very comprehensive tutorial on the analysis of ordinal response variables can be found here. It is also worth checking this thread on: How to understand output from R's polr function (ordered logistic regression)?. In brief, a proportional odds model instead of modelling the probability of response in a particular category, it models the cumulative probability that the response is not greater than a chosen category. Your understanding that a binomial family would be too restrictive is fine. A Gaussian with an identity link would be quite unnatural though too; you could not easily constrain it to positive and/or integers responses. You might want to consider using a GLM with a Poisson family but that it is a bit hand-wavy as you need to often define arbitrary categories (so something like glm( ..., family = poisson)). I have seen this being used as illustrative example in some case (eg. Faraway's Extending the Linear Model with R, Chapt. 4.5) but I think it is a bit suboptimal when compared to a real proportional odds logistic regression. A free and accessible paper on the matter is: Regression models for ordinal responses: a review of methods and applications. from Ananth & Kleinbaum; it is a bit dated (1997) but it is nicely presented and will bring you up-to-speed it relevant terminology.
Which glm family to use for ordinal DV?
Given you have an ordinal response using the function MASS::polr should be more appropriate; it implements a proportional odds logistic regression routine. A very comprehensive tutorial on the analysi
Which glm family to use for ordinal DV? Given you have an ordinal response using the function MASS::polr should be more appropriate; it implements a proportional odds logistic regression routine. A very comprehensive tutorial on the analysis of ordinal response variables can be found here. It is also worth checking this thread on: How to understand output from R's polr function (ordered logistic regression)?. In brief, a proportional odds model instead of modelling the probability of response in a particular category, it models the cumulative probability that the response is not greater than a chosen category. Your understanding that a binomial family would be too restrictive is fine. A Gaussian with an identity link would be quite unnatural though too; you could not easily constrain it to positive and/or integers responses. You might want to consider using a GLM with a Poisson family but that it is a bit hand-wavy as you need to often define arbitrary categories (so something like glm( ..., family = poisson)). I have seen this being used as illustrative example in some case (eg. Faraway's Extending the Linear Model with R, Chapt. 4.5) but I think it is a bit suboptimal when compared to a real proportional odds logistic regression. A free and accessible paper on the matter is: Regression models for ordinal responses: a review of methods and applications. from Ananth & Kleinbaum; it is a bit dated (1997) but it is nicely presented and will bring you up-to-speed it relevant terminology.
Which glm family to use for ordinal DV? Given you have an ordinal response using the function MASS::polr should be more appropriate; it implements a proportional odds logistic regression routine. A very comprehensive tutorial on the analysi
35,695
Which glm family to use for ordinal DV?
A multinomial distribution with a cumulative logit link function. You could also use a cumulative probit link function, but that's usually less desirable.
Which glm family to use for ordinal DV?
A multinomial distribution with a cumulative logit link function. You could also use a cumulative probit link function, but that's usually less desirable.
Which glm family to use for ordinal DV? A multinomial distribution with a cumulative logit link function. You could also use a cumulative probit link function, but that's usually less desirable.
Which glm family to use for ordinal DV? A multinomial distribution with a cumulative logit link function. You could also use a cumulative probit link function, but that's usually less desirable.
35,696
What is skewness of a distribution?
Skewness is related to the symmetry of a distribution. Note that I do not write that "skewness measures symmetry" or some such. The specific relationship between symmetry and skewness is a bit complicated. A symmetric distribution will have zero skewness, for usual definitions of skewness. (Yes, there are multiple ones.) For instance, in Pearson's moment skewness, the third power in the formula implies that probability masses to the left and the right of the mean cancel out. However, the converse is not true. You can easily create distributions that are not symmetric but whose Pearson's moment skewness is zero - we just need the densities to cancel out. In fact, you can do this for unimodal distributions as well. The same applies to other skewness measures, like Pearson's mode skewness or median skewness. However, for practical purposes zero skewness is usually treated as equivalent to symmetry, and unless you purposely create a pathological example, a zero skew distribution will usually be close enough to symmetry that you will be fine.
What is skewness of a distribution?
Skewness is related to the symmetry of a distribution. Note that I do not write that "skewness measures symmetry" or some such. The specific relationship between symmetry and skewness is a bit compli
What is skewness of a distribution? Skewness is related to the symmetry of a distribution. Note that I do not write that "skewness measures symmetry" or some such. The specific relationship between symmetry and skewness is a bit complicated. A symmetric distribution will have zero skewness, for usual definitions of skewness. (Yes, there are multiple ones.) For instance, in Pearson's moment skewness, the third power in the formula implies that probability masses to the left and the right of the mean cancel out. However, the converse is not true. You can easily create distributions that are not symmetric but whose Pearson's moment skewness is zero - we just need the densities to cancel out. In fact, you can do this for unimodal distributions as well. The same applies to other skewness measures, like Pearson's mode skewness or median skewness. However, for practical purposes zero skewness is usually treated as equivalent to symmetry, and unless you purposely create a pathological example, a zero skew distribution will usually be close enough to symmetry that you will be fine.
What is skewness of a distribution? Skewness is related to the symmetry of a distribution. Note that I do not write that "skewness measures symmetry" or some such. The specific relationship between symmetry and skewness is a bit compli
35,697
Lasso and Ridge tuning parameter scope
Yes, you should taking into account the scale of the output $y$ and should also take into account the scale of the covariates in $X$. Let $X \in \mathbb{R}^{n \times p}$ be the design matrix, whose rows are vectors with each entry being a covariate that together seek to explain the response $y \in \mathbb{R}^n$. Each entry of the response $y_i = f(e_i^T X) + \epsilon_i$ (for $i = 1, \dots, n$) is additively composed of a signal that depends on the covariates and an iid mean zero noise. Choosing to model the signal $f$ as being approximately linear leads us to the LASSO estimate $$\hat \beta_\lambda = \arg\min_\beta \frac{1}{2n} \|y-X\beta\|_2^2 + \lambda \|\beta\|_1,$$ we know, by first order conditions, that $\frac{-1}{n} X^T (y - X \hat \beta_\lambda) = \lambda \hat{z}_\lambda$, where $\hat{z}_\lambda$ is the dual variable satisfying $\hat{z}_{\lambda,j} = sgn(\hat{\beta}_{\lambda, j})$ if $\hat{\beta}_{\lambda, j} \neq 0$ and $\hat{z}_{\lambda, j} \in [-1,1]$ if $\hat{\beta}_{\lambda, j} = 0$. Plugging in $\hat{\beta}_\lambda = 0$ into this equation, we see that $\frac{-1}{n} X^T y = \lambda \hat{z}_\lambda$, making $$\frac{1}{n} \|X^T y \|_\infty = \lambda \|\hat{z}_{\lambda}\|_\infty.$$ If $\|\hat{z}_\lambda\|_\infty \neq 1$, then $\lambda$ could decrease (with $\|\hat{z}_\lambda\|_\infty$ increased to maintain equality) and the LASSO estimate would still be $\hat{\beta}_\lambda = 0$. Therefore, at $\lambda_\mathrm{max}$, the smallest value of $\lambda$ that produces $\hat{\beta}_{\lambda}=0$, we get that $$\frac{1}{n} \|X^T y\|_\infty = \lambda_\mathrm{max} \cdot 1.$$ This tells us that there's no need to consider $\lambda > \lambda_\mathrm{max}$ when tuning the LASSO. Now, in practice, most solvers standardize the columns of $X$ so that won't need to be directly taken into account. (Note that it's reasonable to standardize the covariates since the units of measurement shouldn't affect the estimated coefficient.) The ridge case is discussed well here: Maximum penalty for ridge regression
Lasso and Ridge tuning parameter scope
Yes, you should taking into account the scale of the output $y$ and should also take into account the scale of the covariates in $X$. Let $X \in \mathbb{R}^{n \times p}$ be the design matrix, whose ro
Lasso and Ridge tuning parameter scope Yes, you should taking into account the scale of the output $y$ and should also take into account the scale of the covariates in $X$. Let $X \in \mathbb{R}^{n \times p}$ be the design matrix, whose rows are vectors with each entry being a covariate that together seek to explain the response $y \in \mathbb{R}^n$. Each entry of the response $y_i = f(e_i^T X) + \epsilon_i$ (for $i = 1, \dots, n$) is additively composed of a signal that depends on the covariates and an iid mean zero noise. Choosing to model the signal $f$ as being approximately linear leads us to the LASSO estimate $$\hat \beta_\lambda = \arg\min_\beta \frac{1}{2n} \|y-X\beta\|_2^2 + \lambda \|\beta\|_1,$$ we know, by first order conditions, that $\frac{-1}{n} X^T (y - X \hat \beta_\lambda) = \lambda \hat{z}_\lambda$, where $\hat{z}_\lambda$ is the dual variable satisfying $\hat{z}_{\lambda,j} = sgn(\hat{\beta}_{\lambda, j})$ if $\hat{\beta}_{\lambda, j} \neq 0$ and $\hat{z}_{\lambda, j} \in [-1,1]$ if $\hat{\beta}_{\lambda, j} = 0$. Plugging in $\hat{\beta}_\lambda = 0$ into this equation, we see that $\frac{-1}{n} X^T y = \lambda \hat{z}_\lambda$, making $$\frac{1}{n} \|X^T y \|_\infty = \lambda \|\hat{z}_{\lambda}\|_\infty.$$ If $\|\hat{z}_\lambda\|_\infty \neq 1$, then $\lambda$ could decrease (with $\|\hat{z}_\lambda\|_\infty$ increased to maintain equality) and the LASSO estimate would still be $\hat{\beta}_\lambda = 0$. Therefore, at $\lambda_\mathrm{max}$, the smallest value of $\lambda$ that produces $\hat{\beta}_{\lambda}=0$, we get that $$\frac{1}{n} \|X^T y\|_\infty = \lambda_\mathrm{max} \cdot 1.$$ This tells us that there's no need to consider $\lambda > \lambda_\mathrm{max}$ when tuning the LASSO. Now, in practice, most solvers standardize the columns of $X$ so that won't need to be directly taken into account. (Note that it's reasonable to standardize the covariates since the units of measurement shouldn't affect the estimated coefficient.) The ridge case is discussed well here: Maximum penalty for ridge regression
Lasso and Ridge tuning parameter scope Yes, you should taking into account the scale of the output $y$ and should also take into account the scale of the covariates in $X$. Let $X \in \mathbb{R}^{n \times p}$ be the design matrix, whose ro
35,698
Lasso and Ridge tuning parameter scope
In the R package glmnet, the function cv.glmnet fits a model on the whole data set to select suitable regularization path, and then does cross-validation using that path. This seems to work well in practice.
Lasso and Ridge tuning parameter scope
In the R package glmnet, the function cv.glmnet fits a model on the whole data set to select suitable regularization path, and then does cross-validation using that path. This seems to work well in pr
Lasso and Ridge tuning parameter scope In the R package glmnet, the function cv.glmnet fits a model on the whole data set to select suitable regularization path, and then does cross-validation using that path. This seems to work well in practice.
Lasso and Ridge tuning parameter scope In the R package glmnet, the function cv.glmnet fits a model on the whole data set to select suitable regularization path, and then does cross-validation using that path. This seems to work well in pr
35,699
Difference in partial dependence calculated by R and Python
Scikit-learn center the partial dependence with the mean of the target value, R does not. Here is an example using diabetes dataset. R data(diabetes, package="lars") y <- diabetes$y x <- diabetes$x class(x) <- "matrix" data <- data.frame(y, as.data.frame(x)) model <- gbm::gbm(formula = y ~ . , data = data, distribution = "gaussian", shrinkage = 1, bag.fraction = 1, n.trees = 100, interaction.depth = 2, verbose = T, keep.data = F) partial <- plot.gbm(dgbm, i.var = 1, return.grid = T) plot(partial[, 2] - mean(y), type = "l") Python import numpy as np import sklearn import matplotlib.pyplot as plt import sklearn.datasets import sklearn.ensemble from sklearn.ensemble.partial_dependence import partial_dependence diabetes = sklearn.datasets.load_diabetes() X= diabetes.data y= diabetes.target gbm = sklearn.ensemble.GradientBoostingRegressor(loss='ls', learning_rate=1, max_leaf_nodes=3, min_samples_leaf=10, n_estimators=100, verbose=True) model_gbm = gbm.fit(X, y) partial, axe = partial_dependence(gbrt=model_gbm, X=X, target_variables=(0)) plt.plot(partial.T)
Difference in partial dependence calculated by R and Python
Scikit-learn center the partial dependence with the mean of the target value, R does not. Here is an example using diabetes dataset. R data(diabetes, package="lars") y <- diabetes$y x <
Difference in partial dependence calculated by R and Python Scikit-learn center the partial dependence with the mean of the target value, R does not. Here is an example using diabetes dataset. R data(diabetes, package="lars") y <- diabetes$y x <- diabetes$x class(x) <- "matrix" data <- data.frame(y, as.data.frame(x)) model <- gbm::gbm(formula = y ~ . , data = data, distribution = "gaussian", shrinkage = 1, bag.fraction = 1, n.trees = 100, interaction.depth = 2, verbose = T, keep.data = F) partial <- plot.gbm(dgbm, i.var = 1, return.grid = T) plot(partial[, 2] - mean(y), type = "l") Python import numpy as np import sklearn import matplotlib.pyplot as plt import sklearn.datasets import sklearn.ensemble from sklearn.ensemble.partial_dependence import partial_dependence diabetes = sklearn.datasets.load_diabetes() X= diabetes.data y= diabetes.target gbm = sklearn.ensemble.GradientBoostingRegressor(loss='ls', learning_rate=1, max_leaf_nodes=3, min_samples_leaf=10, n_estimators=100, verbose=True) model_gbm = gbm.fit(X, y) partial, axe = partial_dependence(gbrt=model_gbm, X=X, target_variables=(0)) plt.plot(partial.T)
Difference in partial dependence calculated by R and Python Scikit-learn center the partial dependence with the mean of the target value, R does not. Here is an example using diabetes dataset. R data(diabetes, package="lars") y <- diabetes$y x <
35,700
Can I make a decision using a Bayes factor?
This is an excellent and deep question. While traditional textbooks (like mine) tend to promote Bayes factors as equivalent to posterior probabilities of the null and alternative hypotheses or of two models under comparison, which is formally correct as detailed in the following extract from my Bayesian Choice, I now tend to think that the Bayes factor per se should not be used for decision-making but rather as a measure of relative evidence of one model versus the other. For instance, using $\mathfrak{B}^\pi_{01}(x)=1$ as the dividing line between null and alternative (or between model a and model b) does not strike me as a natural choice. Furthermore, I do not think the 0-1 loss advocated by Neyman and Pearson and later adopted by almost everyone is making much sense and brings any support to the decisional interpretation of the Bayes factor. My current perspective on the Bayes factor is more in a prior or posterior predictive mode where the behaviour of $\mathfrak{B}^\pi_{01}(x)$ is assessed under both models, in order to calibrate the observed value $\mathfrak{B}^\pi_{01}(x)$ against both prior or posterior distributions of $\mathfrak{B}^\pi_{01}(x)$. This gets us away from the decisional perspective. [From The Bayesian Choice, 2007, Section 5.2.2, page 227] From a decision-theoretic point of view the Bayes factor is only a one-to-one transform of the posterior probability, but this notion came out to be considered on its own ground in Bayesian testing. The Bayes factor is the ratio of the posterior probabilities of the null and the alternative hypothesis over the ratio of the prior probabilities of the null and the alternative hypothesis, i.e., $$ \mathfrak{B}^\pi_{01}(x) = {\mathbb{P}(\theta \in \Theta_ 0\mid x) \over \mathbb{P}(\theta \in \Theta_1\mid x)} \bigg/ {\pi(\theta \in \Theta_ 0) \over \pi(\theta \in \Theta_ 1)}. $$ This ratio evaluates the modification of the odds of $\Theta_0$ against $\Theta_1$ due to the observation(s) and can naturally be compared to $1$, although an exact comparison scale can only be based upon a loss function. The Bayes factor is, from a Bayesian decision-theoretic point of view, completely equivalent to the posterior probability of the null hypothesis as $H_0$ is accepted when $$ B^\pi_{01} (x) \ge {a_1\over a_0} \big/ {\rho_0 \over \rho_1} = {a_1\rho_1 \over a_0\rho_0}, $$ where $$ \begin{align*} \rho_0 &= \pi(\theta\in\Theta_0) \quad \hbox{ and } \nonumber\\ \rho_1 &= \pi(\theta\in\Theta_1)\\ &=1-\rho_0. \end{align*} $$ and where $a_0$ and $a_1$ are the penalties for wrongly selecting the alternative and null hypotheses or the models $\mathfrak{M}_0$ and $\mathfrak{M}_1$. respectively, in Neyman-Pearson formulation: $$ \mathfrak{L}(\theta, \varphi) = \begin{cases} 0 &\text{if $\varphi=\mathbb{I}_{\Theta_0}(\theta)$,} \cr a_0 &\text{if $\theta\in\Theta_0$ and $\varphi=0$,} \cr a_1 &\text{if $\theta\not\in\Theta_0$ and $\varphi=1$,}\cr\end{cases} $$
Can I make a decision using a Bayes factor?
This is an excellent and deep question. While traditional textbooks (like mine) tend to promote Bayes factors as equivalent to posterior probabilities of the null and alternative hypotheses or of two
Can I make a decision using a Bayes factor? This is an excellent and deep question. While traditional textbooks (like mine) tend to promote Bayes factors as equivalent to posterior probabilities of the null and alternative hypotheses or of two models under comparison, which is formally correct as detailed in the following extract from my Bayesian Choice, I now tend to think that the Bayes factor per se should not be used for decision-making but rather as a measure of relative evidence of one model versus the other. For instance, using $\mathfrak{B}^\pi_{01}(x)=1$ as the dividing line between null and alternative (or between model a and model b) does not strike me as a natural choice. Furthermore, I do not think the 0-1 loss advocated by Neyman and Pearson and later adopted by almost everyone is making much sense and brings any support to the decisional interpretation of the Bayes factor. My current perspective on the Bayes factor is more in a prior or posterior predictive mode where the behaviour of $\mathfrak{B}^\pi_{01}(x)$ is assessed under both models, in order to calibrate the observed value $\mathfrak{B}^\pi_{01}(x)$ against both prior or posterior distributions of $\mathfrak{B}^\pi_{01}(x)$. This gets us away from the decisional perspective. [From The Bayesian Choice, 2007, Section 5.2.2, page 227] From a decision-theoretic point of view the Bayes factor is only a one-to-one transform of the posterior probability, but this notion came out to be considered on its own ground in Bayesian testing. The Bayes factor is the ratio of the posterior probabilities of the null and the alternative hypothesis over the ratio of the prior probabilities of the null and the alternative hypothesis, i.e., $$ \mathfrak{B}^\pi_{01}(x) = {\mathbb{P}(\theta \in \Theta_ 0\mid x) \over \mathbb{P}(\theta \in \Theta_1\mid x)} \bigg/ {\pi(\theta \in \Theta_ 0) \over \pi(\theta \in \Theta_ 1)}. $$ This ratio evaluates the modification of the odds of $\Theta_0$ against $\Theta_1$ due to the observation(s) and can naturally be compared to $1$, although an exact comparison scale can only be based upon a loss function. The Bayes factor is, from a Bayesian decision-theoretic point of view, completely equivalent to the posterior probability of the null hypothesis as $H_0$ is accepted when $$ B^\pi_{01} (x) \ge {a_1\over a_0} \big/ {\rho_0 \over \rho_1} = {a_1\rho_1 \over a_0\rho_0}, $$ where $$ \begin{align*} \rho_0 &= \pi(\theta\in\Theta_0) \quad \hbox{ and } \nonumber\\ \rho_1 &= \pi(\theta\in\Theta_1)\\ &=1-\rho_0. \end{align*} $$ and where $a_0$ and $a_1$ are the penalties for wrongly selecting the alternative and null hypotheses or the models $\mathfrak{M}_0$ and $\mathfrak{M}_1$. respectively, in Neyman-Pearson formulation: $$ \mathfrak{L}(\theta, \varphi) = \begin{cases} 0 &\text{if $\varphi=\mathbb{I}_{\Theta_0}(\theta)$,} \cr a_0 &\text{if $\theta\in\Theta_0$ and $\varphi=0$,} \cr a_1 &\text{if $\theta\not\in\Theta_0$ and $\varphi=1$,}\cr\end{cases} $$
Can I make a decision using a Bayes factor? This is an excellent and deep question. While traditional textbooks (like mine) tend to promote Bayes factors as equivalent to posterior probabilities of the null and alternative hypotheses or of two