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
40,601
Is this a valid way to construct a confidence interval?
Given $k=0$ successes of $n$ trials, the exact (Clopper–Pearson) confidence interval is $[p_1,p_2]$ such that $$P(K \ge k=0 \vert p=p_1)=\frac{\alpha}{2}$$ and $$P(K \le k=0 \vert p=p_2)=\frac{\alpha}{2},$$ where $K \sim Binomial(n,p)$. You can calculate $[p_1,p_2]$ using the inverse binomial function. However, it is also possible to solve by hand for $p_i$ since the cumulative binomial is very simple in this special case: $(1−p)^n= \alpha$. You can also use a Poisson approximation in the same way to get $e^{-n \cdot p}=\alpha$. Here's a graph of the approximation as a function of sample size:
Is this a valid way to construct a confidence interval?
Given $k=0$ successes of $n$ trials, the exact (Clopper–Pearson) confidence interval is $[p_1,p_2]$ such that $$P(K \ge k=0 \vert p=p_1)=\frac{\alpha}{2}$$ and $$P(K \le k=0 \vert p=p_2)=\frac{\alpha}
Is this a valid way to construct a confidence interval? Given $k=0$ successes of $n$ trials, the exact (Clopper–Pearson) confidence interval is $[p_1,p_2]$ such that $$P(K \ge k=0 \vert p=p_1)=\frac{\alpha}{2}$$ and $$P(K \le k=0 \vert p=p_2)=\frac{\alpha}{2},$$ where $K \sim Binomial(n,p)$. You can calculate $[p_1,p_2]$ using the inverse binomial function. However, it is also possible to solve by hand for $p_i$ since the cumulative binomial is very simple in this special case: $(1−p)^n= \alpha$. You can also use a Poisson approximation in the same way to get $e^{-n \cdot p}=\alpha$. Here's a graph of the approximation as a function of sample size:
Is this a valid way to construct a confidence interval? Given $k=0$ successes of $n$ trials, the exact (Clopper–Pearson) confidence interval is $[p_1,p_2]$ such that $$P(K \ge k=0 \vert p=p_1)=\frac{\alpha}{2}$$ and $$P(K \le k=0 \vert p=p_2)=\frac{\alpha}
40,602
t-SNE dimensions as additional predictor variables
When you computed the tSNE representation of the data, presumably you used all of the data and so the data in your CV hold-out set was actually considered in your training data. It is built into the tSNE components. I do not believe that there is any way to predict the tSNE coordinates of new data points, so this method does not seem to be useful for building a classifier. PCA is another story. You could compute PCA on your training folds and then project new data onto the principal components (from training data only). As long as you do not compute the principal components using all of the data before applying other methods, this should be OK
t-SNE dimensions as additional predictor variables
When you computed the tSNE representation of the data, presumably you used all of the data and so the data in your CV hold-out set was actually considered in your training data. It is built into the t
t-SNE dimensions as additional predictor variables When you computed the tSNE representation of the data, presumably you used all of the data and so the data in your CV hold-out set was actually considered in your training data. It is built into the tSNE components. I do not believe that there is any way to predict the tSNE coordinates of new data points, so this method does not seem to be useful for building a classifier. PCA is another story. You could compute PCA on your training folds and then project new data onto the principal components (from training data only). As long as you do not compute the principal components using all of the data before applying other methods, this should be OK
t-SNE dimensions as additional predictor variables When you computed the tSNE representation of the data, presumably you used all of the data and so the data in your CV hold-out set was actually considered in your training data. It is built into the t
40,603
t-SNE dimensions as additional predictor variables
Not worthy of an answer, but too long for a comment. I am also interested in this question. The theory seems quite difficult as you are layering a non-linear algorithm over top of another one. TL;DR I'm surprised it works very well, I would look into the hyperparameters of your random forest. But since the theory is quite complex there may be something happening that I don't understand. First, an intuitive understanding. t-SNE attempts to map data from a high dimensional space down to a lower dimensional space while keeping the distance between points which are 'close' in high-dimensions but without caring about points which are not close. In effect, it creates clusters of the points which are near one another in predictor space and maps them to two (or three) dimensions. This, along with a classification scheme can provide reasonable accuracy. Consider the example from the original paper of t-SNEs application to the MNIST dataset -- in two dimensions you can easily pick out the digits by eye with ~90% accuracy, a k-means classifier layered on top will do about that or better. A well-specified random forest ought to pick out that structure in the high-dimensional space without the need to first map it down. As you are not adding any information, and you accept some loss in t-SNE you are (in some sense) just placing your data on a 3-dimensional manifold and appending this lossy new dataset to your existing set. As random forests already have a means of regularizing, it is unclear why your result is improved. It makes me skeptical of how well your hyperparameters are set, i.e. it may be the case that your Random Forest is not regularizing very well so that you have t-SNE do it for you your accuracy improves. Setting the hyperparameters correctly in the first place and removing the t-SNE ought to further improve on this performance.
t-SNE dimensions as additional predictor variables
Not worthy of an answer, but too long for a comment. I am also interested in this question. The theory seems quite difficult as you are layering a non-linear algorithm over top of another one. TL;DR I
t-SNE dimensions as additional predictor variables Not worthy of an answer, but too long for a comment. I am also interested in this question. The theory seems quite difficult as you are layering a non-linear algorithm over top of another one. TL;DR I'm surprised it works very well, I would look into the hyperparameters of your random forest. But since the theory is quite complex there may be something happening that I don't understand. First, an intuitive understanding. t-SNE attempts to map data from a high dimensional space down to a lower dimensional space while keeping the distance between points which are 'close' in high-dimensions but without caring about points which are not close. In effect, it creates clusters of the points which are near one another in predictor space and maps them to two (or three) dimensions. This, along with a classification scheme can provide reasonable accuracy. Consider the example from the original paper of t-SNEs application to the MNIST dataset -- in two dimensions you can easily pick out the digits by eye with ~90% accuracy, a k-means classifier layered on top will do about that or better. A well-specified random forest ought to pick out that structure in the high-dimensional space without the need to first map it down. As you are not adding any information, and you accept some loss in t-SNE you are (in some sense) just placing your data on a 3-dimensional manifold and appending this lossy new dataset to your existing set. As random forests already have a means of regularizing, it is unclear why your result is improved. It makes me skeptical of how well your hyperparameters are set, i.e. it may be the case that your Random Forest is not regularizing very well so that you have t-SNE do it for you your accuracy improves. Setting the hyperparameters correctly in the first place and removing the t-SNE ought to further improve on this performance.
t-SNE dimensions as additional predictor variables Not worthy of an answer, but too long for a comment. I am also interested in this question. The theory seems quite difficult as you are layering a non-linear algorithm over top of another one. TL;DR I
40,604
t-SNE dimensions as additional predictor variables
Do not use $t$-SNE as predictor variables (in general). As it has been pointed out in a previous answer in a best-case scenario using all the data to compute the $t$-SNE representation is a bad practice even if one holds out the response variable. In addition using $t$-SNE directly also renders the original modelling procedure useless when presented with new data (as the OP correctly comments too) because we cannot reconstruct a new embedding. As a work-around I think it is worth exploring the option of a deep auto-encoder. This will allow use to readily map new data on our "interesting representation". Deep auto-encoders can learn highly non-linear representations of a dataset. We will train the auto-encoder on our training folds (similar to what we would do with PCA) and then project new data accordingly. amoeba's answer on "Building an autoencoder in Tensorflow to surpass PCA" is an excellent resource to get you started. In specific cases, one might be able to build a deep neural network to replicate the output of $t$-SNE on a new sample. This option will take care of the above issues (data reuse, no generalisation to unseen data). I do not think it is a substantially different approach from using a deep auto-encoder in the first place though and conceptually I find it more convoluted. Plus the auto-encoder literature has many extensions (eg. denoising auto-encoders) that might come handy. Regarding the exact phenomenon of 10%+ performance boost reported: Assuming that the response variable is not accidentally used, I suspect that the data might have an non-linear embedding that the RF classifier cannot easily detect. Random forests (or any other model for that matter) do not guarantee that any non-linear association will be discovered. I would suggest examining the $t$-SNE output itself. Maybe some of the patterns are not so hard to explain and a bit of clever/educated features engineering from your part can give you a decent boost. I hope you see that, somewhat anti-climatically, using $t$-SNE output directly is not very straight-forward. $t$-SNE is a very helpful tool; nevertheless as many great tools, it is easy for us to misuse it as a hammer when we just have screws.
t-SNE dimensions as additional predictor variables
Do not use $t$-SNE as predictor variables (in general). As it has been pointed out in a previous answer in a best-case scenario using all the data to compute the $t$-SNE representation is a bad pract
t-SNE dimensions as additional predictor variables Do not use $t$-SNE as predictor variables (in general). As it has been pointed out in a previous answer in a best-case scenario using all the data to compute the $t$-SNE representation is a bad practice even if one holds out the response variable. In addition using $t$-SNE directly also renders the original modelling procedure useless when presented with new data (as the OP correctly comments too) because we cannot reconstruct a new embedding. As a work-around I think it is worth exploring the option of a deep auto-encoder. This will allow use to readily map new data on our "interesting representation". Deep auto-encoders can learn highly non-linear representations of a dataset. We will train the auto-encoder on our training folds (similar to what we would do with PCA) and then project new data accordingly. amoeba's answer on "Building an autoencoder in Tensorflow to surpass PCA" is an excellent resource to get you started. In specific cases, one might be able to build a deep neural network to replicate the output of $t$-SNE on a new sample. This option will take care of the above issues (data reuse, no generalisation to unseen data). I do not think it is a substantially different approach from using a deep auto-encoder in the first place though and conceptually I find it more convoluted. Plus the auto-encoder literature has many extensions (eg. denoising auto-encoders) that might come handy. Regarding the exact phenomenon of 10%+ performance boost reported: Assuming that the response variable is not accidentally used, I suspect that the data might have an non-linear embedding that the RF classifier cannot easily detect. Random forests (or any other model for that matter) do not guarantee that any non-linear association will be discovered. I would suggest examining the $t$-SNE output itself. Maybe some of the patterns are not so hard to explain and a bit of clever/educated features engineering from your part can give you a decent boost. I hope you see that, somewhat anti-climatically, using $t$-SNE output directly is not very straight-forward. $t$-SNE is a very helpful tool; nevertheless as many great tools, it is easy for us to misuse it as a hammer when we just have screws.
t-SNE dimensions as additional predictor variables Do not use $t$-SNE as predictor variables (in general). As it has been pointed out in a previous answer in a best-case scenario using all the data to compute the $t$-SNE representation is a bad pract
40,605
t-SNE dimensions as additional predictor variables
I'll also assume, as did G5W, that you used all your data in generating your coordinates. Given this, I'm aware of perhaps two mechanisms to use t-SNE as a predictor on a go-forward basis: For all new "live" data, rebuild the model after running t-SNE on your entire dataset. The order would be something like: 1) Get new data and put it alongside your historical data. 2) Run t-SNE on all data (new & old). 3) Properly orient your train/test/live datasets and rebuild the model using new coordinates in 3-dimensional (or N-dimensional) t-SNE space. 4) Score model on the recently generated coordinates of the new 'live' data. This approach would be valid for batch scoring, but may come at a potentially significant time cost. You may also find issues with prediction stability, as previous scores 'float' around, and coordinates/models are re-calculated. Or, using the t-SNE interpretations of your training data, build individual models for your individual coordinate components. This is alluded to by Laurens van der Maaten at the bottom of his t-SNE FAQ. [https://lvdmaaten.github.io/tsne/]. Then, use the component models to estimate the coordinates for the new 'live' data. This, however, will bring new sources of error to be minimized with crossval and tuning of the individual x,y,z model components.
t-SNE dimensions as additional predictor variables
I'll also assume, as did G5W, that you used all your data in generating your coordinates. Given this, I'm aware of perhaps two mechanisms to use t-SNE as a predictor on a go-forward basis: For all n
t-SNE dimensions as additional predictor variables I'll also assume, as did G5W, that you used all your data in generating your coordinates. Given this, I'm aware of perhaps two mechanisms to use t-SNE as a predictor on a go-forward basis: For all new "live" data, rebuild the model after running t-SNE on your entire dataset. The order would be something like: 1) Get new data and put it alongside your historical data. 2) Run t-SNE on all data (new & old). 3) Properly orient your train/test/live datasets and rebuild the model using new coordinates in 3-dimensional (or N-dimensional) t-SNE space. 4) Score model on the recently generated coordinates of the new 'live' data. This approach would be valid for batch scoring, but may come at a potentially significant time cost. You may also find issues with prediction stability, as previous scores 'float' around, and coordinates/models are re-calculated. Or, using the t-SNE interpretations of your training data, build individual models for your individual coordinate components. This is alluded to by Laurens van der Maaten at the bottom of his t-SNE FAQ. [https://lvdmaaten.github.io/tsne/]. Then, use the component models to estimate the coordinates for the new 'live' data. This, however, will bring new sources of error to be minimized with crossval and tuning of the individual x,y,z model components.
t-SNE dimensions as additional predictor variables I'll also assume, as did G5W, that you used all your data in generating your coordinates. Given this, I'm aware of perhaps two mechanisms to use t-SNE as a predictor on a go-forward basis: For all n
40,606
How to use "IDs" as an input variable to a ML model?
ID variables like phone number should not be included as predictors, because you are trying to train a model to understand general patterns. Phone number doesn't offer the model any real insight into what drives fraud vs non-fraud. You'd be better off using a lookup table after the fact to flag transactions linked to that phone number.
How to use "IDs" as an input variable to a ML model?
ID variables like phone number should not be included as predictors, because you are trying to train a model to understand general patterns. Phone number doesn't offer the model any real insight into
How to use "IDs" as an input variable to a ML model? ID variables like phone number should not be included as predictors, because you are trying to train a model to understand general patterns. Phone number doesn't offer the model any real insight into what drives fraud vs non-fraud. You'd be better off using a lookup table after the fact to flag transactions linked to that phone number.
How to use "IDs" as an input variable to a ML model? ID variables like phone number should not be included as predictors, because you are trying to train a model to understand general patterns. Phone number doesn't offer the model any real insight into
40,607
How to use "IDs" as an input variable to a ML model?
With new functionalities implemented in tensorflow such as hashing and embedding, I was able to take advantage of ID variables in my data and use them as predictive variables. You can find the explanation in this post: https://developers.googleblog.com/2017/11/introducing-tensorflow-feature-columns.html
How to use "IDs" as an input variable to a ML model?
With new functionalities implemented in tensorflow such as hashing and embedding, I was able to take advantage of ID variables in my data and use them as predictive variables. You can find the explana
How to use "IDs" as an input variable to a ML model? With new functionalities implemented in tensorflow such as hashing and embedding, I was able to take advantage of ID variables in my data and use them as predictive variables. You can find the explanation in this post: https://developers.googleblog.com/2017/11/introducing-tensorflow-feature-columns.html
How to use "IDs" as an input variable to a ML model? With new functionalities implemented in tensorflow such as hashing and embedding, I was able to take advantage of ID variables in my data and use them as predictive variables. You can find the explana
40,608
How does the ReLU function work for z < 0?
Both back and forward propagation are faster to evaluate for the same reason: relu doesn't need any calculation. The gradient is either 0 on the negative value or 1 for the positive. I wouldn't say that the gradient descent moves faster due to gradient being 1 on the positive values. It's only the calculations are faster.
How does the ReLU function work for z < 0?
Both back and forward propagation are faster to evaluate for the same reason: relu doesn't need any calculation. The gradient is either 0 on the negative value or 1 for the positive. I wouldn't say th
How does the ReLU function work for z < 0? Both back and forward propagation are faster to evaluate for the same reason: relu doesn't need any calculation. The gradient is either 0 on the negative value or 1 for the positive. I wouldn't say that the gradient descent moves faster due to gradient being 1 on the positive values. It's only the calculations are faster.
How does the ReLU function work for z < 0? Both back and forward propagation are faster to evaluate for the same reason: relu doesn't need any calculation. The gradient is either 0 on the negative value or 1 for the positive. I wouldn't say th
40,609
How does the ReLU function work for z < 0?
The gradient is zero, which means nothing gets backpropagated through them; the precise value fed to this neuron doesn't matter when $z<0$. If a RELU unit is always in the left part of the graph, you get the dying/dead RELU problem; this is one of the reasons that people have looked for alternatives to RELUs. Sigmoid activations get a similar problem at both ends; even though they're not exactly flat like a RELU, they're close enough once you get to +/- 5 or so.
How does the ReLU function work for z < 0?
The gradient is zero, which means nothing gets backpropagated through them; the precise value fed to this neuron doesn't matter when $z<0$. If a RELU unit is always in the left part of the graph, yo
How does the ReLU function work for z < 0? The gradient is zero, which means nothing gets backpropagated through them; the precise value fed to this neuron doesn't matter when $z<0$. If a RELU unit is always in the left part of the graph, you get the dying/dead RELU problem; this is one of the reasons that people have looked for alternatives to RELUs. Sigmoid activations get a similar problem at both ends; even though they're not exactly flat like a RELU, they're close enough once you get to +/- 5 or so.
How does the ReLU function work for z < 0? The gradient is zero, which means nothing gets backpropagated through them; the precise value fed to this neuron doesn't matter when $z<0$. If a RELU unit is always in the left part of the graph, yo
40,610
Difference between (factor|group) and (1|factor:group) specifications in lme4
At first sight, there are two main differences: mod1 is a random intercept and random slope model while mod2 is a random intercept model (without random slope): (year|cluster) implicitly includes the intercept and thus expands to (1 + year|cluster). In this case you assume a different baseline for each cluster and allow the clusters to vary with respect to the year effect. mod2 includes an interaction, mod1 doesn't: As mod2 only includes a random intercept for the cluster*year interaction you get the estimates for every unique combination of the factor levels (i.e. AA:year2, AA:year3, ...) Note that mod1 estimates $k$ variances and $k(k-1)/2$ correlations for the $k$ random effects per cluster. If you constrain the cluster-related variances to be equal and all the correlations also to be equal (this is called compound symmetry), you get a model with many fewer (only two) variance/covariance parameters: mod3 <- lmer(y ~ x + year + (1|cluster) + (1|year:cluster)) (note the similarity/difference compared to mod2) which can be useful when there is not enough information in the data to estimate mod1. For more on this see this excellent post by Reinhold Kliegl and also my follow-up question: Equivalence of (0 + factor|group) and (1|group) + (1|group:factor) random effect specifications in case of compound symmetry. So mod3 can be seen as a restricted version of mod1. Your mod2 is restricted even further, but this one-parameter parametrization is arguably less realistic.
Difference between (factor|group) and (1|factor:group) specifications in lme4
At first sight, there are two main differences: mod1 is a random intercept and random slope model while mod2 is a random intercept model (without random slope): (year|cluster) implicitly includes the
Difference between (factor|group) and (1|factor:group) specifications in lme4 At first sight, there are two main differences: mod1 is a random intercept and random slope model while mod2 is a random intercept model (without random slope): (year|cluster) implicitly includes the intercept and thus expands to (1 + year|cluster). In this case you assume a different baseline for each cluster and allow the clusters to vary with respect to the year effect. mod2 includes an interaction, mod1 doesn't: As mod2 only includes a random intercept for the cluster*year interaction you get the estimates for every unique combination of the factor levels (i.e. AA:year2, AA:year3, ...) Note that mod1 estimates $k$ variances and $k(k-1)/2$ correlations for the $k$ random effects per cluster. If you constrain the cluster-related variances to be equal and all the correlations also to be equal (this is called compound symmetry), you get a model with many fewer (only two) variance/covariance parameters: mod3 <- lmer(y ~ x + year + (1|cluster) + (1|year:cluster)) (note the similarity/difference compared to mod2) which can be useful when there is not enough information in the data to estimate mod1. For more on this see this excellent post by Reinhold Kliegl and also my follow-up question: Equivalence of (0 + factor|group) and (1|group) + (1|group:factor) random effect specifications in case of compound symmetry. So mod3 can be seen as a restricted version of mod1. Your mod2 is restricted even further, but this one-parameter parametrization is arguably less realistic.
Difference between (factor|group) and (1|factor:group) specifications in lme4 At first sight, there are two main differences: mod1 is a random intercept and random slope model while mod2 is a random intercept model (without random slope): (year|cluster) implicitly includes the
40,611
Entropy of distribution with uniform sub-distribution
Simply apply the entropy formula: the result drops right out. The idea is that $A$ alone contributes at least $$-|A| \left(\frac{1}{|A|}\right)\log\left(\frac{1}{|A|}\right)=\log|A|$$ to the entropy and any other terms in the entropy formula can only increase it further. Details follow. First, let's be clear about the language: subsets of $\mathcal{X}$ are not usually considered "events." $X$ is a function from a probability space $(\Omega, \mathfrak{F}, \mathbb{P})$ into $\mathcal X$. The inverse images $$X^{-1}(a) = \{\omega\in\Omega\mid X(\omega)=a\}$$ are assumed to be measurable subsets of $\Omega$ and as such are (in the conventional sense) events. For convenience, let $n=|A|$ be its cardinality and let $p$ be the common probability of all the events in question; that is, $$p = \Pr(X^{-1}(a))$$ for any $a\in A$. Decompose $\Omega$ into $X^{-1}(A)$ and its complement, $\bar A = \Omega\setminus X^{-1}(A)$. The Axiom of Total Probability, along with the fact that the probability of $\bar A$ is not negative, imply $$\eqalign{ 1 &= \Pr(\Omega) = \Pr(\bar A_X) + \Pr(X^{-1}(A))\\ &= \Pr(\bar A_X) + \sum_{a\in A} \Pr(X^{-1}(a)) \\ & = \Pr(\bar A_X) + np \ge np. }$$ In case $n$ is infinite, this shows $p$ must be zero and $\log p$ will be undefined. We must therefore assume $n$ is finite. In this case, the preceding calculation shows $$p \le \frac{1}{n}.$$ In the calculation of the entropy of $X$, there will be terms corresponding to $X^{-1}\left(\mathcal{X}\setminus A\right)$ which contribute non-negative values to the entropy. There remain $n$ terms from $A$. Each of these contributes $-p\log p$ to the entropy (by definition). Because $p \le 1/n$ and $\log$ is a monotonically increasing function (i.e., $\log(p) \le \log(1/n)$), their total of $-np\log p$ has a lower bound $$-np\log p \ge -n\frac{1}{n}\log\left(\frac{1}{n}\right) = \log n =\log|A|,$$ QED.
Entropy of distribution with uniform sub-distribution
Simply apply the entropy formula: the result drops right out. The idea is that $A$ alone contributes at least $$-|A| \left(\frac{1}{|A|}\right)\log\left(\frac{1}{|A|}\right)=\log|A|$$ to the entropy
Entropy of distribution with uniform sub-distribution Simply apply the entropy formula: the result drops right out. The idea is that $A$ alone contributes at least $$-|A| \left(\frac{1}{|A|}\right)\log\left(\frac{1}{|A|}\right)=\log|A|$$ to the entropy and any other terms in the entropy formula can only increase it further. Details follow. First, let's be clear about the language: subsets of $\mathcal{X}$ are not usually considered "events." $X$ is a function from a probability space $(\Omega, \mathfrak{F}, \mathbb{P})$ into $\mathcal X$. The inverse images $$X^{-1}(a) = \{\omega\in\Omega\mid X(\omega)=a\}$$ are assumed to be measurable subsets of $\Omega$ and as such are (in the conventional sense) events. For convenience, let $n=|A|$ be its cardinality and let $p$ be the common probability of all the events in question; that is, $$p = \Pr(X^{-1}(a))$$ for any $a\in A$. Decompose $\Omega$ into $X^{-1}(A)$ and its complement, $\bar A = \Omega\setminus X^{-1}(A)$. The Axiom of Total Probability, along with the fact that the probability of $\bar A$ is not negative, imply $$\eqalign{ 1 &= \Pr(\Omega) = \Pr(\bar A_X) + \Pr(X^{-1}(A))\\ &= \Pr(\bar A_X) + \sum_{a\in A} \Pr(X^{-1}(a)) \\ & = \Pr(\bar A_X) + np \ge np. }$$ In case $n$ is infinite, this shows $p$ must be zero and $\log p$ will be undefined. We must therefore assume $n$ is finite. In this case, the preceding calculation shows $$p \le \frac{1}{n}.$$ In the calculation of the entropy of $X$, there will be terms corresponding to $X^{-1}\left(\mathcal{X}\setminus A\right)$ which contribute non-negative values to the entropy. There remain $n$ terms from $A$. Each of these contributes $-p\log p$ to the entropy (by definition). Because $p \le 1/n$ and $\log$ is a monotonically increasing function (i.e., $\log(p) \le \log(1/n)$), their total of $-np\log p$ has a lower bound $$-np\log p \ge -n\frac{1}{n}\log\left(\frac{1}{n}\right) = \log n =\log|A|,$$ QED.
Entropy of distribution with uniform sub-distribution Simply apply the entropy formula: the result drops right out. The idea is that $A$ alone contributes at least $$-|A| \left(\frac{1}{|A|}\right)\log\left(\frac{1}{|A|}\right)=\log|A|$$ to the entropy
40,612
How can I show whether or not two time series are “different” from one another?
Because the variance in a count or proportion tends to be proportional to the count or proportion itself, theory (and much experience) suggest analyzing the square roots of the data. See for yourself by plotting the proportions and overall counts on square-root axes. So that each column has a visual impact directly proportional to the count it represents, the column widths (as well as their heights) are also proportional to the square roots of the counts: this makes the areas of the columns directly proportional to the counts. The columns are only lightly drawn because they are of secondary interest in this visualization of proportions, as the title states. The apparently random variation of points (representing the proportions) around their smooth (shown as the blue line), as well as the approximate symmetry of that variation around the smooth, attest to the appropriateness of the square root scale. They also suggest that a more sophisticated analysis of temporal correlation is unnecessary: you can be confident that the trends you see in this plot are real. They present a subtler picture than suggested in the question: the proportions do increase, but only through the first seven years. Creating such a combined plot can be done in Excel or Stata, but is difficult, fussy, and time-consuming in either program. This example was produced with the ggplot2 package in R (version 3.4.0). To illustrate the process, here is the full R code. library(ggplot2) X <- data.frame(Year=2003:2016, Young=c(17,23,22,35,46,71,80,68,76,84,74,88,62,60), All=c(3007,5200,6000,5900,6740,7070,7120, 7324,7620,8051,8437,9130,8930,9000)*10) scale.dup <- 0.5e6 # Proportional to column heights in the plot ggplot(X, aes(Year, 100 * scale.dup * Young/All)) + geom_col(aes(Year, All, width=2.25*sqrt(All/scale.dup)), fill="#ffffe0", alpha=0.75, color="Gray") + geom_smooth(size=1.25) + geom_point(size=2) + ylab("All") + scale_y_continuous(sec.axis=dup_axis(~. / scale.dup, "Young / All (%)"), trans="sqrt") + ggtitle("Disease Registry Patient Proportions", "2003 - 2016 (square root scales)")
How can I show whether or not two time series are “different” from one another?
Because the variance in a count or proportion tends to be proportional to the count or proportion itself, theory (and much experience) suggest analyzing the square roots of the data. See for yourself
How can I show whether or not two time series are “different” from one another? Because the variance in a count or proportion tends to be proportional to the count or proportion itself, theory (and much experience) suggest analyzing the square roots of the data. See for yourself by plotting the proportions and overall counts on square-root axes. So that each column has a visual impact directly proportional to the count it represents, the column widths (as well as their heights) are also proportional to the square roots of the counts: this makes the areas of the columns directly proportional to the counts. The columns are only lightly drawn because they are of secondary interest in this visualization of proportions, as the title states. The apparently random variation of points (representing the proportions) around their smooth (shown as the blue line), as well as the approximate symmetry of that variation around the smooth, attest to the appropriateness of the square root scale. They also suggest that a more sophisticated analysis of temporal correlation is unnecessary: you can be confident that the trends you see in this plot are real. They present a subtler picture than suggested in the question: the proportions do increase, but only through the first seven years. Creating such a combined plot can be done in Excel or Stata, but is difficult, fussy, and time-consuming in either program. This example was produced with the ggplot2 package in R (version 3.4.0). To illustrate the process, here is the full R code. library(ggplot2) X <- data.frame(Year=2003:2016, Young=c(17,23,22,35,46,71,80,68,76,84,74,88,62,60), All=c(3007,5200,6000,5900,6740,7070,7120, 7324,7620,8051,8437,9130,8930,9000)*10) scale.dup <- 0.5e6 # Proportional to column heights in the plot ggplot(X, aes(Year, 100 * scale.dup * Young/All)) + geom_col(aes(Year, All, width=2.25*sqrt(All/scale.dup)), fill="#ffffe0", alpha=0.75, color="Gray") + geom_smooth(size=1.25) + geom_point(size=2) + ylab("All") + scale_y_continuous(sec.axis=dup_axis(~. / scale.dup, "Young / All (%)"), trans="sqrt") + ggtitle("Disease Registry Patient Proportions", "2003 - 2016 (square root scales)")
How can I show whether or not two time series are “different” from one another? Because the variance in a count or proportion tends to be proportional to the count or proportion itself, theory (and much experience) suggest analyzing the square roots of the data. See for yourself
40,613
Are deep neural networks robust to outliers?
Relative to a standard multiple regression model, I believe an MLP is much more robust to outliers. This is the case for several reasons: 1) the multiple regression has only one single shot at fitting the data. Meanwhile the MLP has so many more opportunities to fit the data by varying the number of nodes and hidden layers to use to fit the data. This more flexible fitting mechanism should allow the MLP to underweight the impact of outliers (relative to either a Y or a X variable); 2) MLPs activation functions typically use a Logit Regression mechanism (Sigmoid) or a Tangent Hyperbolic function (Tanh). The former generates intermediary outputs between 0 and 1 and the latter between -1 and +1. Those activation functions further enhance the capability of MLPs to deal with non-linear events and outliers. 3) MLPs can incorporate regularization mechanisms. The latter should assist in resolving multicollinearity and reducing the impact of outliers. Also, to diagnose the impact of outliers on your MLPs, you can also do cross validation. However, if your main objective is to reduce the impact of outliers there are more transparent ways to deal with that. Tree based models are certainly a good way to do that, as you mentioned. But, there is also a whole family of Robust Regression models. Some of them combine with regularization mechanisms to resolve the multicollinearity issue. And, those models are far easier to explain to a non-specialized audience.
Are deep neural networks robust to outliers?
Relative to a standard multiple regression model, I believe an MLP is much more robust to outliers. This is the case for several reasons: 1) the multiple regression has only one single shot at fittin
Are deep neural networks robust to outliers? Relative to a standard multiple regression model, I believe an MLP is much more robust to outliers. This is the case for several reasons: 1) the multiple regression has only one single shot at fitting the data. Meanwhile the MLP has so many more opportunities to fit the data by varying the number of nodes and hidden layers to use to fit the data. This more flexible fitting mechanism should allow the MLP to underweight the impact of outliers (relative to either a Y or a X variable); 2) MLPs activation functions typically use a Logit Regression mechanism (Sigmoid) or a Tangent Hyperbolic function (Tanh). The former generates intermediary outputs between 0 and 1 and the latter between -1 and +1. Those activation functions further enhance the capability of MLPs to deal with non-linear events and outliers. 3) MLPs can incorporate regularization mechanisms. The latter should assist in resolving multicollinearity and reducing the impact of outliers. Also, to diagnose the impact of outliers on your MLPs, you can also do cross validation. However, if your main objective is to reduce the impact of outliers there are more transparent ways to deal with that. Tree based models are certainly a good way to do that, as you mentioned. But, there is also a whole family of Robust Regression models. Some of them combine with regularization mechanisms to resolve the multicollinearity issue. And, those models are far easier to explain to a non-specialized audience.
Are deep neural networks robust to outliers? Relative to a standard multiple regression model, I believe an MLP is much more robust to outliers. This is the case for several reasons: 1) the multiple regression has only one single shot at fittin
40,614
Are deep neural networks robust to outliers?
Based on this article by Lin and Tegmark (below), I think the answer is "it depends." In other words and as they state, most deep learning algorithms assume a lognormal distribution. As long as your data fits that assumption, then there is no problem. The problem is when the tails of the distribution are more extreme than lognormal, e.g., power lawed or super-exponential. Their Figure 1 and related discussion outline the issues with the lack of tail fit based on lognormality across several different data types and solutions are proposed, specifically in the context of deep learning NNs. Lin and Tegmark, Critical Behavior from Deep Dynamics: A Hidden Dimension in Natural Language arXiv:1606.06737
Are deep neural networks robust to outliers?
Based on this article by Lin and Tegmark (below), I think the answer is "it depends." In other words and as they state, most deep learning algorithms assume a lognormal distribution. As long as your d
Are deep neural networks robust to outliers? Based on this article by Lin and Tegmark (below), I think the answer is "it depends." In other words and as they state, most deep learning algorithms assume a lognormal distribution. As long as your data fits that assumption, then there is no problem. The problem is when the tails of the distribution are more extreme than lognormal, e.g., power lawed or super-exponential. Their Figure 1 and related discussion outline the issues with the lack of tail fit based on lognormality across several different data types and solutions are proposed, specifically in the context of deep learning NNs. Lin and Tegmark, Critical Behavior from Deep Dynamics: A Hidden Dimension in Natural Language arXiv:1606.06737
Are deep neural networks robust to outliers? Based on this article by Lin and Tegmark (below), I think the answer is "it depends." In other words and as they state, most deep learning algorithms assume a lognormal distribution. As long as your d
40,615
Are deep neural networks robust to outliers?
Multilayer Perceptron (MLP) are sensitive to outliers. MLP are universal approximators i.e. they can be used to approximate any target function. With such an expressive hypothesis space, MLP may risk overfitting by learning from noise (outliers). Outliers can also cause slow/no learning to take place because of the vanishing gradient problem. Activations saturate at either tail of 0 or 1, and gradients are near zero in these regions. If a feature has a variance that is orders of magnitude larger than others, it might dominate the objective function (unable to learn from other features). Hence, as a preprocessing step, it is highly recommended to apply standardization on the training data to reduce outliers. References: LeCun, Y. A., Bottou, L., Orr, G. B., & Müller, K. R. (2012). Efficient backprop. In Neural networks: Tricks of the trade (pp. 9-48). Springer, Berlin, Heidelberg. Pang-Ning Tan, Michael Steinbach, Anuj Karpatne, and Vipin Kumar. 2018. Introduction to Data Mining (2nd Edition) (2nd. ed.). Pearson. Chapter 5.4 Artificial Neural Networks
Are deep neural networks robust to outliers?
Multilayer Perceptron (MLP) are sensitive to outliers. MLP are universal approximators i.e. they can be used to approximate any target function. With such an expressive hypothesis space, MLP may risk
Are deep neural networks robust to outliers? Multilayer Perceptron (MLP) are sensitive to outliers. MLP are universal approximators i.e. they can be used to approximate any target function. With such an expressive hypothesis space, MLP may risk overfitting by learning from noise (outliers). Outliers can also cause slow/no learning to take place because of the vanishing gradient problem. Activations saturate at either tail of 0 or 1, and gradients are near zero in these regions. If a feature has a variance that is orders of magnitude larger than others, it might dominate the objective function (unable to learn from other features). Hence, as a preprocessing step, it is highly recommended to apply standardization on the training data to reduce outliers. References: LeCun, Y. A., Bottou, L., Orr, G. B., & Müller, K. R. (2012). Efficient backprop. In Neural networks: Tricks of the trade (pp. 9-48). Springer, Berlin, Heidelberg. Pang-Ning Tan, Michael Steinbach, Anuj Karpatne, and Vipin Kumar. 2018. Introduction to Data Mining (2nd Edition) (2nd. ed.). Pearson. Chapter 5.4 Artificial Neural Networks
Are deep neural networks robust to outliers? Multilayer Perceptron (MLP) are sensitive to outliers. MLP are universal approximators i.e. they can be used to approximate any target function. With such an expressive hypothesis space, MLP may risk
40,616
Computing Bayesian Credible Intervals for Bayesian Regression
Unfortunately, the interval that you are looking for is not uniquely determined. Essentially, what you need is the Posterior Predictive Density (PPD, see https://en.wikipedia.org/wiki/Posterior_predictive_distribution), which is the density function of new/unseen data given the observed data. This PPD depends on the posterior distribution of the parameters, $\theta_1, ..., \theta_n$ in your case. It can be written as $p(y^* | y, x, x^*) = \int p(y^*, \theta | y, x, x^*) d\theta = \int p(y^* | \theta) p (\theta | y, x, x^*)d\theta$ where $y^*$ represents the unseen response data, $y$ represents the known response data, $x$ and $x^*$ represent the predictor values that correspond to $y$ and $y^*$, and $\theta$ represents the parameters. The last factor in the final integral is the posterior distribution of $\theta$ given $y, x, x^*$. As the PPD depends on the posterior distribution of the parameters, this, in turn, depends on the prior distribution of the parameters (and on the chosen data model / likelihood function). This means that for each prior you may choose, your posterior distribution changes (and, as a result, your interval as well). Usually, when choosing completely uninformative (i.e. flat) priors, along with a Normal likelihood for the response values given the predictors, the results of a Bayesian analysis overlap with those of a frequentist analysis. Then again, flat priors are usually a poor choice for such a model. When you know which priors you want to use for your analysis, it may be possible to compute the PPD analytically, but in many cases this is simply impossible. I'd recommend using a tool like Stan (http://mc-stan.org) to draw samples from the posterior distribution and then use those to determine a credible interval for your parameters and your new (simulated) data. Hope this helps!
Computing Bayesian Credible Intervals for Bayesian Regression
Unfortunately, the interval that you are looking for is not uniquely determined. Essentially, what you need is the Posterior Predictive Density (PPD, see https://en.wikipedia.org/wiki/Posterior_predic
Computing Bayesian Credible Intervals for Bayesian Regression Unfortunately, the interval that you are looking for is not uniquely determined. Essentially, what you need is the Posterior Predictive Density (PPD, see https://en.wikipedia.org/wiki/Posterior_predictive_distribution), which is the density function of new/unseen data given the observed data. This PPD depends on the posterior distribution of the parameters, $\theta_1, ..., \theta_n$ in your case. It can be written as $p(y^* | y, x, x^*) = \int p(y^*, \theta | y, x, x^*) d\theta = \int p(y^* | \theta) p (\theta | y, x, x^*)d\theta$ where $y^*$ represents the unseen response data, $y$ represents the known response data, $x$ and $x^*$ represent the predictor values that correspond to $y$ and $y^*$, and $\theta$ represents the parameters. The last factor in the final integral is the posterior distribution of $\theta$ given $y, x, x^*$. As the PPD depends on the posterior distribution of the parameters, this, in turn, depends on the prior distribution of the parameters (and on the chosen data model / likelihood function). This means that for each prior you may choose, your posterior distribution changes (and, as a result, your interval as well). Usually, when choosing completely uninformative (i.e. flat) priors, along with a Normal likelihood for the response values given the predictors, the results of a Bayesian analysis overlap with those of a frequentist analysis. Then again, flat priors are usually a poor choice for such a model. When you know which priors you want to use for your analysis, it may be possible to compute the PPD analytically, but in many cases this is simply impossible. I'd recommend using a tool like Stan (http://mc-stan.org) to draw samples from the posterior distribution and then use those to determine a credible interval for your parameters and your new (simulated) data. Hope this helps!
Computing Bayesian Credible Intervals for Bayesian Regression Unfortunately, the interval that you are looking for is not uniquely determined. Essentially, what you need is the Posterior Predictive Density (PPD, see https://en.wikipedia.org/wiki/Posterior_predic
40,617
How are robust standard errors calculated in the case of logistic regression?
The definition is completely analogous if you use the so-called working residuals and if regressors and residuals are weighted appropriately. The working weights are part of the usual iteratively weighted least squares (IWLS) algorithm employed for generalized linear models (including logistic regression). The main idea is to use derivative of the log-likelihood with respect to the mean or the corresponding linear predictor as a measure of deviation. Alternatively, you can use the so-called scores or estimating functions as a measure of deviation, i.e., the derivative of the log-likelihood with respect to the coefficients of the linear predictor. All these ideas are employed in our sandwich package for R to enable object-oriented implementations of the different sandwich estimators. See Zeileis (2006, Object-Oriented Computation of Sandwich Estimators, doi:10.18637/jss.v016.i09) for the details. A worked illustration in R using a logistic regression for labor market participation is: data("SwissLabor", package = "AER") m <- glm(participation ~ ., data = SwissLabor, family = binomial) The classical Eicker/Huber/White sandwich covariance matrix can be computed using our sandwich package: library("sandwich") vcov_sandwich <- sandwich(m) And by hand you can easily extract the working residuals and regressors, appropriately weighted with the working weights: r <- residuals(m, "working") * sqrt(weights(m, "working")) X <- model.matrix(m) * sqrt(weights(m, "working")) Then, the formula for the covariance matrix is just the same as in the linear regression model vcov_byhand <- solve(t(X) %*% X) %*% t(X) %*% diag(r^2) %*% X %*% solve(t(X) %*% X) all.equal(vcov_sandwich, vcov_byhand) ## [1] TRUE Two caveats: (1) Of course, one shouldn't compute the sandwich like this but more efficient and numerically more stable matrix computations can be employed. (2) For data with independent binary responses, these sandwich covariances are not robust against anything. They are consistent, that's ok, but there is no way to misspecify the likelihood without misspecifying the model equation.
How are robust standard errors calculated in the case of logistic regression?
The definition is completely analogous if you use the so-called working residuals and if regressors and residuals are weighted appropriately. The working weights are part of the usual iteratively weig
How are robust standard errors calculated in the case of logistic regression? The definition is completely analogous if you use the so-called working residuals and if regressors and residuals are weighted appropriately. The working weights are part of the usual iteratively weighted least squares (IWLS) algorithm employed for generalized linear models (including logistic regression). The main idea is to use derivative of the log-likelihood with respect to the mean or the corresponding linear predictor as a measure of deviation. Alternatively, you can use the so-called scores or estimating functions as a measure of deviation, i.e., the derivative of the log-likelihood with respect to the coefficients of the linear predictor. All these ideas are employed in our sandwich package for R to enable object-oriented implementations of the different sandwich estimators. See Zeileis (2006, Object-Oriented Computation of Sandwich Estimators, doi:10.18637/jss.v016.i09) for the details. A worked illustration in R using a logistic regression for labor market participation is: data("SwissLabor", package = "AER") m <- glm(participation ~ ., data = SwissLabor, family = binomial) The classical Eicker/Huber/White sandwich covariance matrix can be computed using our sandwich package: library("sandwich") vcov_sandwich <- sandwich(m) And by hand you can easily extract the working residuals and regressors, appropriately weighted with the working weights: r <- residuals(m, "working") * sqrt(weights(m, "working")) X <- model.matrix(m) * sqrt(weights(m, "working")) Then, the formula for the covariance matrix is just the same as in the linear regression model vcov_byhand <- solve(t(X) %*% X) %*% t(X) %*% diag(r^2) %*% X %*% solve(t(X) %*% X) all.equal(vcov_sandwich, vcov_byhand) ## [1] TRUE Two caveats: (1) Of course, one shouldn't compute the sandwich like this but more efficient and numerically more stable matrix computations can be employed. (2) For data with independent binary responses, these sandwich covariances are not robust against anything. They are consistent, that's ok, but there is no way to misspecify the likelihood without misspecifying the model equation.
How are robust standard errors calculated in the case of logistic regression? The definition is completely analogous if you use the so-called working residuals and if regressors and residuals are weighted appropriately. The working weights are part of the usual iteratively weig
40,618
Multiple polynomial regression versus GAM
The two models you fitted are exactly equivalent (up to implementational details). The advantage of the GAM framework is that you are not limited to global basis expansions of your covariates. Instead you can use a range of penalized spline bases that may better adapt to the data rather than imposing a particular functional form as you did with the polynomial model. I also wouldn't use the gam package. The penalized spline approach of Simon Wood, as implemented in the mgcv package that ships with R is much more useful that Hastie and Tibshirani's original. Here I modify your example to use (thin plate) splines in the GAM via the s() function (for smooth) rather than the poly() function used in the lm(). I restrict the basis dimension for both terms but set them larger than the polynomial for technical reasons (if the true curves are polynomials of degree 2, that is on the edge of the set of functions the spline can represent and smoothness selection may not identify them — I come back to the issue of basis dimension size later). Here the splines use maximum 4 degrees of freedom, from k = 5 but we loose 1 df each due to identifiability constraints to accommodate a model intercept. library("ISLR") # for Wage dataset data(Wage) library("mgcv") lm.wage.poly <- lm(wage ~ poly(age, 2, raw = TRUE) + poly(year, 2, raw = TRUE), data = Wage) lm.wage.gam <- gam(wage ~ s(age, k = 5) + s(year, k = 5), data = Wage) anova(lm.wage.poly, lm.wage.gam) That gives: > anova(lm.wage.poly, lm.wage.gam) Analysis of Variance Table Model 1: wage ~ poly(age, 2, raw = TRUE) + poly(year, 2, raw = TRUE) Model 2: wage ~ s(age, k = 5) + s(year, k = 5) Res.Df RSS Df Sum of Sq F Pr(>F) 1 2995.0 4771710 2 2994.2 4745169 0.84022 26541 19.932 3.083e-05 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 which indicates that the GAM uses slightly more degrees of freedom than the polynomial model, but has improved the fit to a degree. If we look at the model summary > summary(lm.wage.gam) Family: gaussian Link function: identity Formula: wage ~ s(age, k = 5) + s(year, k = 5) Parametric coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 111.7036 0.7268 153.7 <2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Approximate significance of smooth terms: edf Ref.df F p-value s(age) 3.84 3.984 70.97 < 2e-16 *** s(year) 1.00 1.000 13.58 0.000232 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 R-sq.(adj) = 0.0899 Deviance explained = 9.13% GCV = 1587.9 Scale est. = 1584.8 n = 3000 We note that gam() selected a linear function of year (it uses 1 effective degree of freedom == EDF). An ~ 4 EDF term was fitted to age. This is in contrast to the polynomial model, which used 2 DFs per covariate regardless. We should check that the basis dimensions specified (k = 5) were sufficiently large: > gam.check(lm.wage.gam) Method: GCV Optimizer: magic Smoothing parameter selection converged after 9 iterations. The RMS GCV score gradient at convergence was 0.0001096254 . The Hessian was positive definite. Model rank = 9 / 9 Basis dimension (k) checking results. Low p-value (k-index<1) may indicate that k is too low, especially if edf is close to k'. k' edf k-index p-value s(age) 4.00 3.84 0.98 0.09 . s(year) 4.00 1.00 1.01 0.72 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 The test for s(age) is marginal and we would be advised to increase k and refit. Here I increase both terms basis dimension, but year only has a few unique values so we can't go beyond k = 7 for that term. m2 <- gam(wage ~ s(age, k = 10) + s(year, k = 7), data = Wage) Now smoothness selection suggests age should be more strongly non-linear that before: > summary(m2) Family: gaussian Link function: identity Formula: wage ~ s(age, k = 10) + s(year, k = 7) Parametric coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 111.7036 0.7266 153.7 <2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Approximate significance of smooth terms: edf Ref.df F p-value s(age) 5.462 6.568 43.51 < 2e-16 *** s(year) 1.000 1.000 14.18 0.000169 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 R-sq.(adj) = 0.0905 Deviance explained = 9.24% GCV = 1587.7 Scale est. = 1583.7 n = 3000 The fitted smooths are now: The conceptual difference between the polynomial basis expansion and the spline basis expansion used in the GAM is that the former is global; data at age 20 contribute to the fit of the quadratic function of age at age 80. Because of this global nature, the polynomial can be too inflexible for many nonlinear relationships. As the spline basis is local, the fit at a particular age for example is largely dominated by the values of the response around the same age.
Multiple polynomial regression versus GAM
The two models you fitted are exactly equivalent (up to implementational details). The advantage of the GAM framework is that you are not limited to global basis expansions of your covariates. Instead
Multiple polynomial regression versus GAM The two models you fitted are exactly equivalent (up to implementational details). The advantage of the GAM framework is that you are not limited to global basis expansions of your covariates. Instead you can use a range of penalized spline bases that may better adapt to the data rather than imposing a particular functional form as you did with the polynomial model. I also wouldn't use the gam package. The penalized spline approach of Simon Wood, as implemented in the mgcv package that ships with R is much more useful that Hastie and Tibshirani's original. Here I modify your example to use (thin plate) splines in the GAM via the s() function (for smooth) rather than the poly() function used in the lm(). I restrict the basis dimension for both terms but set them larger than the polynomial for technical reasons (if the true curves are polynomials of degree 2, that is on the edge of the set of functions the spline can represent and smoothness selection may not identify them — I come back to the issue of basis dimension size later). Here the splines use maximum 4 degrees of freedom, from k = 5 but we loose 1 df each due to identifiability constraints to accommodate a model intercept. library("ISLR") # for Wage dataset data(Wage) library("mgcv") lm.wage.poly <- lm(wage ~ poly(age, 2, raw = TRUE) + poly(year, 2, raw = TRUE), data = Wage) lm.wage.gam <- gam(wage ~ s(age, k = 5) + s(year, k = 5), data = Wage) anova(lm.wage.poly, lm.wage.gam) That gives: > anova(lm.wage.poly, lm.wage.gam) Analysis of Variance Table Model 1: wage ~ poly(age, 2, raw = TRUE) + poly(year, 2, raw = TRUE) Model 2: wage ~ s(age, k = 5) + s(year, k = 5) Res.Df RSS Df Sum of Sq F Pr(>F) 1 2995.0 4771710 2 2994.2 4745169 0.84022 26541 19.932 3.083e-05 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 which indicates that the GAM uses slightly more degrees of freedom than the polynomial model, but has improved the fit to a degree. If we look at the model summary > summary(lm.wage.gam) Family: gaussian Link function: identity Formula: wage ~ s(age, k = 5) + s(year, k = 5) Parametric coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 111.7036 0.7268 153.7 <2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Approximate significance of smooth terms: edf Ref.df F p-value s(age) 3.84 3.984 70.97 < 2e-16 *** s(year) 1.00 1.000 13.58 0.000232 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 R-sq.(adj) = 0.0899 Deviance explained = 9.13% GCV = 1587.9 Scale est. = 1584.8 n = 3000 We note that gam() selected a linear function of year (it uses 1 effective degree of freedom == EDF). An ~ 4 EDF term was fitted to age. This is in contrast to the polynomial model, which used 2 DFs per covariate regardless. We should check that the basis dimensions specified (k = 5) were sufficiently large: > gam.check(lm.wage.gam) Method: GCV Optimizer: magic Smoothing parameter selection converged after 9 iterations. The RMS GCV score gradient at convergence was 0.0001096254 . The Hessian was positive definite. Model rank = 9 / 9 Basis dimension (k) checking results. Low p-value (k-index<1) may indicate that k is too low, especially if edf is close to k'. k' edf k-index p-value s(age) 4.00 3.84 0.98 0.09 . s(year) 4.00 1.00 1.01 0.72 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 The test for s(age) is marginal and we would be advised to increase k and refit. Here I increase both terms basis dimension, but year only has a few unique values so we can't go beyond k = 7 for that term. m2 <- gam(wage ~ s(age, k = 10) + s(year, k = 7), data = Wage) Now smoothness selection suggests age should be more strongly non-linear that before: > summary(m2) Family: gaussian Link function: identity Formula: wage ~ s(age, k = 10) + s(year, k = 7) Parametric coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 111.7036 0.7266 153.7 <2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Approximate significance of smooth terms: edf Ref.df F p-value s(age) 5.462 6.568 43.51 < 2e-16 *** s(year) 1.000 1.000 14.18 0.000169 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 R-sq.(adj) = 0.0905 Deviance explained = 9.24% GCV = 1587.7 Scale est. = 1583.7 n = 3000 The fitted smooths are now: The conceptual difference between the polynomial basis expansion and the spline basis expansion used in the GAM is that the former is global; data at age 20 contribute to the fit of the quadratic function of age at age 80. Because of this global nature, the polynomial can be too inflexible for many nonlinear relationships. As the spline basis is local, the fit at a particular age for example is largely dominated by the values of the response around the same age.
Multiple polynomial regression versus GAM The two models you fitted are exactly equivalent (up to implementational details). The advantage of the GAM framework is that you are not limited to global basis expansions of your covariates. Instead
40,619
Multiple polynomial regression versus GAM
If we use lo and s basis expansion in gam, we will see the difference. Here is the demo: Using no basis expansion and polynomial, gam and lm are the same. > library(gam) > anova(lm(mpg~wt,data=mtcars),gam(mpg~wt,data=mtcars)) Analysis of Variance Table Model 1: mpg ~ wt Model 2: mpg ~ wt Res.Df RSS Df Sum of Sq F Pr(>F) 1 30 278.32 2 30 278.32 0 5.6843e-14 > anova(lm(mpg~poly(wt,2,raw = T),data=mtcars),gam(mpg~poly(wt,2,raw = T),data=mtcars)) Analysis of Variance Table Model 1: mpg ~ poly(wt, 2, raw = T) Model 2: mpg ~ poly(wt, 2, raw = T) Res.Df RSS Df Sum of Sq F Pr(>F) 1 29 203.75 2 29 203.75 0 0 Using lo and s expansion, gam and lm are different. > anova(lm(mpg~lo(wt),data=mtcars), gam(mpg~lo(wt),data=mtcars)) Analysis of Variance Table Model 1: mpg ~ lo(wt) Model 2: mpg ~ lo(wt) Res.Df RSS Df Sum of Sq F Pr(>F) 1 30.0 278.32 2 26.6 177.47 3.4 100.86 4.4462 0.009422 ** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 > anova(lm(mpg~s(wt),data=mtcars), gam(mpg~s(wt),data=mtcars)) Analysis of Variance Table Model 1: mpg ~ s(wt) Model 2: mpg ~ s(wt) Res.Df RSS Df Sum of Sq F Pr(>F) 1 30 278.32 2 27 190.00 3 88.321 4.1837 0.01483 * --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Multiple polynomial regression versus GAM
If we use lo and s basis expansion in gam, we will see the difference. Here is the demo: Using no basis expansion and polynomial, gam and lm are the same. > library(gam) > anova(lm(mpg~wt,data=mtcars)
Multiple polynomial regression versus GAM If we use lo and s basis expansion in gam, we will see the difference. Here is the demo: Using no basis expansion and polynomial, gam and lm are the same. > library(gam) > anova(lm(mpg~wt,data=mtcars),gam(mpg~wt,data=mtcars)) Analysis of Variance Table Model 1: mpg ~ wt Model 2: mpg ~ wt Res.Df RSS Df Sum of Sq F Pr(>F) 1 30 278.32 2 30 278.32 0 5.6843e-14 > anova(lm(mpg~poly(wt,2,raw = T),data=mtcars),gam(mpg~poly(wt,2,raw = T),data=mtcars)) Analysis of Variance Table Model 1: mpg ~ poly(wt, 2, raw = T) Model 2: mpg ~ poly(wt, 2, raw = T) Res.Df RSS Df Sum of Sq F Pr(>F) 1 29 203.75 2 29 203.75 0 0 Using lo and s expansion, gam and lm are different. > anova(lm(mpg~lo(wt),data=mtcars), gam(mpg~lo(wt),data=mtcars)) Analysis of Variance Table Model 1: mpg ~ lo(wt) Model 2: mpg ~ lo(wt) Res.Df RSS Df Sum of Sq F Pr(>F) 1 30.0 278.32 2 26.6 177.47 3.4 100.86 4.4462 0.009422 ** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 > anova(lm(mpg~s(wt),data=mtcars), gam(mpg~s(wt),data=mtcars)) Analysis of Variance Table Model 1: mpg ~ s(wt) Model 2: mpg ~ s(wt) Res.Df RSS Df Sum of Sq F Pr(>F) 1 30 278.32 2 27 190.00 3 88.321 4.1837 0.01483 * --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Multiple polynomial regression versus GAM If we use lo and s basis expansion in gam, we will see the difference. Here is the demo: Using no basis expansion and polynomial, gam and lm are the same. > library(gam) > anova(lm(mpg~wt,data=mtcars)
40,620
How does a Generator (GAN) create samples similar to the data space from a vector of random numbers?
I am not sure I understand probability distribution and random sampling enough to understand this part. Could someone explain what is going on? In non-math words: the generator $G$ is a network and as such needs some kind of input to produce an image, we call this input $z$ and so the generated images can be seen as $G(z)$, or more explicitly $G(z, \theta_G)$. Does the generator sample from a probability distribution that was assigned in the beginning, or is it simply doing transformations with its weights $W$ on a vector of random numbers generated upon each iteration? In math words, $z$ is drawn from a prior probability distribution $p_z$ and then used to condition on another probability distribution $p_G$ so that samples drawn from it are similar to real images. So, to answer your question: yes and yes. Yes because the probability distribution is chosen from the beginning and never changes, and yes because every time we feed an input to the generator we sample a new vector from that distribution, i.e. we feed a vector of randomly generated number. Now, how do people select the prior distribution probability $p_z$? A common and sensible choice is to draw $z$ from a zero-centered unit-variance Gaussian distribution. This gives some nice properties once the network is trained: The unit variance means that each element in the random vector might end up representing a feature in the generated image uncorrelated to the other features (e.g. $z_2$ might be "the face has glasses" and $z_5$ might be "length of the hairs") The zero-centered Gaussian means that it will be easy to draw samples and even interpolate between two values and see a progressive change in the image. In fact, because the density is all around the center and not scattered, we can pick any point in the latent space and be sure that the generated image will make sense, rather than being a mess of pixels. In other words, there are no "holes" in the prior where the network was not trained enough to generate something meaningful. Hope this helps ;)
How does a Generator (GAN) create samples similar to the data space from a vector of random numbers?
I am not sure I understand probability distribution and random sampling enough to understand this part. Could someone explain what is going on? In non-math words: the generator $G$ is a network and a
How does a Generator (GAN) create samples similar to the data space from a vector of random numbers? I am not sure I understand probability distribution and random sampling enough to understand this part. Could someone explain what is going on? In non-math words: the generator $G$ is a network and as such needs some kind of input to produce an image, we call this input $z$ and so the generated images can be seen as $G(z)$, or more explicitly $G(z, \theta_G)$. Does the generator sample from a probability distribution that was assigned in the beginning, or is it simply doing transformations with its weights $W$ on a vector of random numbers generated upon each iteration? In math words, $z$ is drawn from a prior probability distribution $p_z$ and then used to condition on another probability distribution $p_G$ so that samples drawn from it are similar to real images. So, to answer your question: yes and yes. Yes because the probability distribution is chosen from the beginning and never changes, and yes because every time we feed an input to the generator we sample a new vector from that distribution, i.e. we feed a vector of randomly generated number. Now, how do people select the prior distribution probability $p_z$? A common and sensible choice is to draw $z$ from a zero-centered unit-variance Gaussian distribution. This gives some nice properties once the network is trained: The unit variance means that each element in the random vector might end up representing a feature in the generated image uncorrelated to the other features (e.g. $z_2$ might be "the face has glasses" and $z_5$ might be "length of the hairs") The zero-centered Gaussian means that it will be easy to draw samples and even interpolate between two values and see a progressive change in the image. In fact, because the density is all around the center and not scattered, we can pick any point in the latent space and be sure that the generated image will make sense, rather than being a mess of pixels. In other words, there are no "holes" in the prior where the network was not trained enough to generate something meaningful. Hope this helps ;)
How does a Generator (GAN) create samples similar to the data space from a vector of random numbers? I am not sure I understand probability distribution and random sampling enough to understand this part. Could someone explain what is going on? In non-math words: the generator $G$ is a network and a
40,621
How does a Generator (GAN) create samples similar to the data space from a vector of random numbers?
The following idea from this awesome Stanford lecture about generative models was very helpful to me in understanding the sample generations in GANs: Deep Neural Networks (DNNs) are great in learning mappings from an input X to an output Y but are deterministic, hence cannot generate new samples. To overcome this, we sample random noise from a simple probability distribution and use a DNN to learn a transformation from the simple noise distribution to the complex (training) data distribution.
How does a Generator (GAN) create samples similar to the data space from a vector of random numbers?
The following idea from this awesome Stanford lecture about generative models was very helpful to me in understanding the sample generations in GANs: Deep Neural Networks (DNNs) are great in learning
How does a Generator (GAN) create samples similar to the data space from a vector of random numbers? The following idea from this awesome Stanford lecture about generative models was very helpful to me in understanding the sample generations in GANs: Deep Neural Networks (DNNs) are great in learning mappings from an input X to an output Y but are deterministic, hence cannot generate new samples. To overcome this, we sample random noise from a simple probability distribution and use a DNN to learn a transformation from the simple noise distribution to the complex (training) data distribution.
How does a Generator (GAN) create samples similar to the data space from a vector of random numbers? The following idea from this awesome Stanford lecture about generative models was very helpful to me in understanding the sample generations in GANs: Deep Neural Networks (DNNs) are great in learning
40,622
How to calculate the mean and CI for a percentage
Let me see if I understood your question correctly. You have a sample of n = 20; For each observation in this sample you have computed a percentage reduction as a consequence of some treatment: i.e. \begin{equation}p_i =\frac{x_i,t - x_{i,t-1}}{x_{i,t-1}}\end{equation} where $x_{i,t}$ is the i-th observation in your sample after the treatment and $x_{i,t-1}$ is the i-th observation in your sample before the treatment. These percentage reductions you have taken and averaged: \begin{equation} \hat{p} = \frac{1}{20}\sum_{i=1}^{20} p_i\end{equation} to estimate a parameter $p$ in the population: the percentage reduction in the population on average as a result of the treatment. And what you're interested in is computing a confidence interval for this RATIO (I did not realize that this was a ratio of two random variables that was being estimated when I wrote this). If this is correct, then what I suggest you use is a paired sample t-test: https://en.wikipedia.org/wiki/Student%27s_t-test#Dependent_t-test_for_paired_samples The value of $\hat{p}$ is a random variable as it will differ from sample to sample. If the sample is large enough (usually n > 30), then the distribution of $\hat{p}$ over many simple random samples will be normally distributed according to the Central Limit Theorem. This sample is somewhat small, and you probably don't have a very reliable estimate of the population variance therefore (it's unknown), so for that reason you use the T-distribution which is approximately normal for large samples. The reason for using the paired T-test is that your observations are not independent. The percentage reduction is computed, if I understood you correctly, by comparing the i-th observation before and after a treatment. If there are two groups, however, that you're comparing, then an ordinary T-test will do. Hope that this helps! Edit: what I (stupidly!) forgot here is to mention that you have a ratio estimator. This poses some problems for using a T-test. $\hat{p}$ is the quotient of two random variables. In addition, your estimate will be biased. See here https://en.wikipedia.org/wiki/Ratio_estimator. It's explained there how you can adjust for this.
How to calculate the mean and CI for a percentage
Let me see if I understood your question correctly. You have a sample of n = 20; For each observation in this sample you have computed a percentage reduction as a consequence of some treatment: i.e.
How to calculate the mean and CI for a percentage Let me see if I understood your question correctly. You have a sample of n = 20; For each observation in this sample you have computed a percentage reduction as a consequence of some treatment: i.e. \begin{equation}p_i =\frac{x_i,t - x_{i,t-1}}{x_{i,t-1}}\end{equation} where $x_{i,t}$ is the i-th observation in your sample after the treatment and $x_{i,t-1}$ is the i-th observation in your sample before the treatment. These percentage reductions you have taken and averaged: \begin{equation} \hat{p} = \frac{1}{20}\sum_{i=1}^{20} p_i\end{equation} to estimate a parameter $p$ in the population: the percentage reduction in the population on average as a result of the treatment. And what you're interested in is computing a confidence interval for this RATIO (I did not realize that this was a ratio of two random variables that was being estimated when I wrote this). If this is correct, then what I suggest you use is a paired sample t-test: https://en.wikipedia.org/wiki/Student%27s_t-test#Dependent_t-test_for_paired_samples The value of $\hat{p}$ is a random variable as it will differ from sample to sample. If the sample is large enough (usually n > 30), then the distribution of $\hat{p}$ over many simple random samples will be normally distributed according to the Central Limit Theorem. This sample is somewhat small, and you probably don't have a very reliable estimate of the population variance therefore (it's unknown), so for that reason you use the T-distribution which is approximately normal for large samples. The reason for using the paired T-test is that your observations are not independent. The percentage reduction is computed, if I understood you correctly, by comparing the i-th observation before and after a treatment. If there are two groups, however, that you're comparing, then an ordinary T-test will do. Hope that this helps! Edit: what I (stupidly!) forgot here is to mention that you have a ratio estimator. This poses some problems for using a T-test. $\hat{p}$ is the quotient of two random variables. In addition, your estimate will be biased. See here https://en.wikipedia.org/wiki/Ratio_estimator. It's explained there how you can adjust for this.
How to calculate the mean and CI for a percentage Let me see if I understood your question correctly. You have a sample of n = 20; For each observation in this sample you have computed a percentage reduction as a consequence of some treatment: i.e.
40,623
How to calculate the mean and CI for a percentage
The data size is small, so I recommend bootstrap confidence intervals. Resample 20 observations with replacement from your dataset, compute your percent reduction on that resample, and repeat 1000 times. Your x% confidence interval is simply the $\frac{1 - x}{2}$ quantile of your collection to the $\frac{100 - x}{2}$ quantile. One benefit of this approach is that your CI will "automatically" incorporate the asymmetry inherent in the problem. There will be no statistics in your collection that are e.g. less than zero because the way you calculate your stat makes that impossible. Doing anything based on the well-known standard error of $\hat{p}$ will give you a CI based on a normal distribution, which will have nonzero density for all values of p, even impossible ones like -1.
How to calculate the mean and CI for a percentage
The data size is small, so I recommend bootstrap confidence intervals. Resample 20 observations with replacement from your dataset, compute your percent reduction on that resample, and repeat 1000 tim
How to calculate the mean and CI for a percentage The data size is small, so I recommend bootstrap confidence intervals. Resample 20 observations with replacement from your dataset, compute your percent reduction on that resample, and repeat 1000 times. Your x% confidence interval is simply the $\frac{1 - x}{2}$ quantile of your collection to the $\frac{100 - x}{2}$ quantile. One benefit of this approach is that your CI will "automatically" incorporate the asymmetry inherent in the problem. There will be no statistics in your collection that are e.g. less than zero because the way you calculate your stat makes that impossible. Doing anything based on the well-known standard error of $\hat{p}$ will give you a CI based on a normal distribution, which will have nonzero density for all values of p, even impossible ones like -1.
How to calculate the mean and CI for a percentage The data size is small, so I recommend bootstrap confidence intervals. Resample 20 observations with replacement from your dataset, compute your percent reduction on that resample, and repeat 1000 tim
40,624
How to calculate the mean and CI for a percentage
One very reasonable approach is to log-transform the data (final values and pre-values), perform a linear regression/ANCOVA on the log-transformed data. Then you backtransform (simply exp(x)) to the original scale. The result can be interpreted as the ratio of geometric means compared to the pre-values. I would then tpically interpret something like 0.8 as a 20% reduction. This is typically much better behaved than analyzing calculated percentage change values (in particular the standard deviation does not tend to be constant across different values and various other problems) and also ensures that confidence intervals lie within the possible percentage changes (i.e. values cannot be lowered by more than 100%).
How to calculate the mean and CI for a percentage
One very reasonable approach is to log-transform the data (final values and pre-values), perform a linear regression/ANCOVA on the log-transformed data. Then you backtransform (simply exp(x)) to the o
How to calculate the mean and CI for a percentage One very reasonable approach is to log-transform the data (final values and pre-values), perform a linear regression/ANCOVA on the log-transformed data. Then you backtransform (simply exp(x)) to the original scale. The result can be interpreted as the ratio of geometric means compared to the pre-values. I would then tpically interpret something like 0.8 as a 20% reduction. This is typically much better behaved than analyzing calculated percentage change values (in particular the standard deviation does not tend to be constant across different values and various other problems) and also ensures that confidence intervals lie within the possible percentage changes (i.e. values cannot be lowered by more than 100%).
How to calculate the mean and CI for a percentage One very reasonable approach is to log-transform the data (final values and pre-values), perform a linear regression/ANCOVA on the log-transformed data. Then you backtransform (simply exp(x)) to the o
40,625
How to calculate the mean and CI for a percentage
A common approach to this would to use a risk ratio and create the confidence interval around logged risk ratio. The risk ratio is the ratio of the two proportions and can be computed as $$ RR = \frac{p_1}{p_2} $$ where $p_1$ is the proportion for group 1, and $p_2$ is the proportion for group 2. Working from a 2 by 2 frequency table with the cell frequencies represented by $a$, $b$, $c$, and $d$ (that is, $a$ and $c$ are the number of successes for groups 1 and 2, respectively, and $b$ and $d$ are the number of failures for groups 1 and 2, respectively), we can compute the risk ratio as $$ RR = \frac{a/(a+b)}{c/(c+d)} $$ The standard error of the logged risk ratio is computed as $$ se = \sqrt{\frac{b}{a(a+b)} + \frac{d}{c(c+d)}}$$ Thus, we can compute the 95% confidence interval as $$ln(RR) \pm 1.96(se) $$ Taking the exponent of the upper and lower confidence limits will give you the confidence interval for the risk ratio $$ RR = e^{ln(RR)} $$ You can convert the risk ratio into your original question of percent reduction (assuming the risk ratio is less than 1) with the following $$ \%~reduction = (1-RR) \times 100 $$ You could apply this to the limits of the confidence interval. Note that if the risk ratio is greater than one, you would determine the % increase as $$ \%~increase = (RR-1) \times 100 $$
How to calculate the mean and CI for a percentage
A common approach to this would to use a risk ratio and create the confidence interval around logged risk ratio. The risk ratio is the ratio of the two proportions and can be computed as $$ RR = \frac
How to calculate the mean and CI for a percentage A common approach to this would to use a risk ratio and create the confidence interval around logged risk ratio. The risk ratio is the ratio of the two proportions and can be computed as $$ RR = \frac{p_1}{p_2} $$ where $p_1$ is the proportion for group 1, and $p_2$ is the proportion for group 2. Working from a 2 by 2 frequency table with the cell frequencies represented by $a$, $b$, $c$, and $d$ (that is, $a$ and $c$ are the number of successes for groups 1 and 2, respectively, and $b$ and $d$ are the number of failures for groups 1 and 2, respectively), we can compute the risk ratio as $$ RR = \frac{a/(a+b)}{c/(c+d)} $$ The standard error of the logged risk ratio is computed as $$ se = \sqrt{\frac{b}{a(a+b)} + \frac{d}{c(c+d)}}$$ Thus, we can compute the 95% confidence interval as $$ln(RR) \pm 1.96(se) $$ Taking the exponent of the upper and lower confidence limits will give you the confidence interval for the risk ratio $$ RR = e^{ln(RR)} $$ You can convert the risk ratio into your original question of percent reduction (assuming the risk ratio is less than 1) with the following $$ \%~reduction = (1-RR) \times 100 $$ You could apply this to the limits of the confidence interval. Note that if the risk ratio is greater than one, you would determine the % increase as $$ \%~increase = (RR-1) \times 100 $$
How to calculate the mean and CI for a percentage A common approach to this would to use a risk ratio and create the confidence interval around logged risk ratio. The risk ratio is the ratio of the two proportions and can be computed as $$ RR = \frac
40,626
SVM: Why does the number of support vectors decrease when C is increased?
In short, C is the penalty on the slack variables, which measure the degree to which the margin constraints are violated. A training pattern violates the margin constraint if the kernel expansion (i.e. the output of the SVM) has a value between -1 and +1, and all patterns violating this constraint will be support vectors. If you increase C, a greater penalty is put on violation of the constraint, the solution will change to reduce the size of the violations (and hence the number of violations) so the margin is made narrower, and less patterns will fall inside it, so there are fewer support vectors. The expected error rate depends on both the margin and also on the sum of the slack variables, so in practice generalisation is maximised by a compromise between the two qualities, giving an intermediate value of C.
SVM: Why does the number of support vectors decrease when C is increased?
In short, C is the penalty on the slack variables, which measure the degree to which the margin constraints are violated. A training pattern violates the margin constraint if the kernel expansion (i.
SVM: Why does the number of support vectors decrease when C is increased? In short, C is the penalty on the slack variables, which measure the degree to which the margin constraints are violated. A training pattern violates the margin constraint if the kernel expansion (i.e. the output of the SVM) has a value between -1 and +1, and all patterns violating this constraint will be support vectors. If you increase C, a greater penalty is put on violation of the constraint, the solution will change to reduce the size of the violations (and hence the number of violations) so the margin is made narrower, and less patterns will fall inside it, so there are fewer support vectors. The expected error rate depends on both the margin and also on the sum of the slack variables, so in practice generalisation is maximised by a compromise between the two qualities, giving an intermediate value of C.
SVM: Why does the number of support vectors decrease when C is increased? In short, C is the penalty on the slack variables, which measure the degree to which the margin constraints are violated. A training pattern violates the margin constraint if the kernel expansion (i.
40,627
need intuition: why is there no winning strategy to this game?
It's because the numbers R2 and B2 are fixed. If I have unlimited tokens of either color, then the result might be different. But... imagine you only have blue cards left, by some fluke of chance. By this time, I have a certain number of blue tokens and red tokens left. No matter which order I play them the result will equal the number of blue tokens I have left. Similarly, if you only have red cards left, no matter what order I play my remaining red tokens, the score will equal the number of red tokens I have left at this point. The issue is that, I cannot predict in what order you will play your cards, therefore by the time I know that I should have more red tokens ideally, or more blue tokens ideally, it's too late. Let's do reductio ad absurdum, and let's say there is just 1 token of each color, and 1 card of each color. If I know you will play red then blue, then I should play red then blue. But, at the time I play, e.g., red, I don't know whether you will play red or blue. Perhaps you play red, perhaps you play blue. By the time it gets to my second token, well, I know what you played, but I can no longer control the fact that my second token is now blue ;-) Now, going back to my very first sentence: if I had unlimited tokens, then I can look at what you have left, and play the color you have most of. But since my own tokens are fixed, and I have exactly the same number of tokens that you have cards, then the order I play them makes no difference. Summary is: from where I am, I can control the order that I play my remaining tokens, but I cannot control the proportion of the color of my remaining tokens. If I had unlimited tokens of either color, I could look at your cards, and see you have more blues, then I could play more blue tokens, and win. But I don't. Oh, I see, you mean, imagine during the first third of moves, you play only red, so you have more blue than red, but still have some blue left. Then, I could play red for a bit, until such time as you switch to have more blue than red, and then I play blue for a bit. The problem is, that this means that you have to play more blue in proportion to your remaining red, followed by more red. If I know you're going to do that, then I can play more blue first, and then more red. But since you're playing randomly, for all I know, you're going to play more red first, and then more blue later. Basically: I can see you have proportionally more of one color now, but I can't control what proportion I have now, it's too late I can't guess whether you're now going to play first more red, and then more blue; or first more blue and then more red if you play evenly, same proportion of blue/red, for the rest of the match, it matters not whether I play my reds first, or my blue first if I know you will play blues first, then reds; or reds first then blue; I could change my sequence accordingly but without that prior knowledge, changing my own sequence might increase my score, or it might decrease my score, and I won't know which, until I've already played, by which time it's too late.
need intuition: why is there no winning strategy to this game?
It's because the numbers R2 and B2 are fixed. If I have unlimited tokens of either color, then the result might be different. But... imagine you only have blue cards left, by some fluke of chance. By
need intuition: why is there no winning strategy to this game? It's because the numbers R2 and B2 are fixed. If I have unlimited tokens of either color, then the result might be different. But... imagine you only have blue cards left, by some fluke of chance. By this time, I have a certain number of blue tokens and red tokens left. No matter which order I play them the result will equal the number of blue tokens I have left. Similarly, if you only have red cards left, no matter what order I play my remaining red tokens, the score will equal the number of red tokens I have left at this point. The issue is that, I cannot predict in what order you will play your cards, therefore by the time I know that I should have more red tokens ideally, or more blue tokens ideally, it's too late. Let's do reductio ad absurdum, and let's say there is just 1 token of each color, and 1 card of each color. If I know you will play red then blue, then I should play red then blue. But, at the time I play, e.g., red, I don't know whether you will play red or blue. Perhaps you play red, perhaps you play blue. By the time it gets to my second token, well, I know what you played, but I can no longer control the fact that my second token is now blue ;-) Now, going back to my very first sentence: if I had unlimited tokens, then I can look at what you have left, and play the color you have most of. But since my own tokens are fixed, and I have exactly the same number of tokens that you have cards, then the order I play them makes no difference. Summary is: from where I am, I can control the order that I play my remaining tokens, but I cannot control the proportion of the color of my remaining tokens. If I had unlimited tokens of either color, I could look at your cards, and see you have more blues, then I could play more blue tokens, and win. But I don't. Oh, I see, you mean, imagine during the first third of moves, you play only red, so you have more blue than red, but still have some blue left. Then, I could play red for a bit, until such time as you switch to have more blue than red, and then I play blue for a bit. The problem is, that this means that you have to play more blue in proportion to your remaining red, followed by more red. If I know you're going to do that, then I can play more blue first, and then more red. But since you're playing randomly, for all I know, you're going to play more red first, and then more blue later. Basically: I can see you have proportionally more of one color now, but I can't control what proportion I have now, it's too late I can't guess whether you're now going to play first more red, and then more blue; or first more blue and then more red if you play evenly, same proportion of blue/red, for the rest of the match, it matters not whether I play my reds first, or my blue first if I know you will play blues first, then reds; or reds first then blue; I could change my sequence accordingly but without that prior knowledge, changing my own sequence might increase my score, or it might decrease my score, and I won't know which, until I've already played, by which time it's too late.
need intuition: why is there no winning strategy to this game? It's because the numbers R2 and B2 are fixed. If I have unlimited tokens of either color, then the result might be different. But... imagine you only have blue cards left, by some fluke of chance. By
40,628
What's the difference between regression and analysis of variance?
ANOVA isn't a model --- it is a method within a model The analysis of variance (ANOVA) is a method that occurs within regression models. The technique is based on the law of iterated variance. Suppose you have some regression model: $$Y_i = f(\mathbf{x}_i, \theta) + \varepsilon_i \quad \quad \quad \varepsilon_1,...,\varepsilon_n \sim \text{IID Dist}(0, \sigma^2).$$ Using the law of iterated variance we can write the marginal variance of $Y_i$ as: $$\begin{equation} \begin{aligned} \mathbb{V}(Y_i) &= \mathbb{V}(\mathbb{E}(Y_i|\mathbf{X}_i)) + \mathbb{E}(\mathbb{V}(Y_i|\mathbf{X}_i)) \\[6pt] &= \mathbb{V}(f(\mathbf{X}_i, \theta)) + \mathbb{E}(\varepsilon_i) \\[6pt] &= \mathbb{V}(f(\mathbf{X}_i, \theta)) + \sigma^2. \\[6pt] \end{aligned} \end{equation}$$ Now, if the explanatory vector does not have a relationship with the response variable then the regression function does not depend on the explanatory vector, and so $\mathbb{V}(f(\mathbf{X}_i, \theta)) = 0$, which implies $\mathbb{V}(Y_i) = \sigma^2$. On the other hand, if the explanatory vector does have a relationship with the response variable, then we will generally have $\mathbb{V}(f(\mathbf{X}_i, \theta)) > 0$, which implies $\mathbb{V}(Y_i) > \sigma^2$. Thus, generally speaking, a larger gap between the estimated variance of the response variable, and the estimated variance of the error term, constitutes evidence in favour of the hypothesis that there is a relationship between the explanatory vector and the response variable. This is the basic insight that underlies ANOVA. It is used to construct formal ANOVA tests to determine whether or not there is evidence of a relationship between the explanatory vector and the response variable. By conditioning on parts of the explanatory vector, this basic method can also be used to test for a relationship between particular subsets of explanatory variables and the response variable. In summary, ANOVA is a particular method that is used within the context of regression analysis to test for relationships between variables.
What's the difference between regression and analysis of variance?
ANOVA isn't a model --- it is a method within a model The analysis of variance (ANOVA) is a method that occurs within regression models. The technique is based on the law of iterated variance. Suppo
What's the difference between regression and analysis of variance? ANOVA isn't a model --- it is a method within a model The analysis of variance (ANOVA) is a method that occurs within regression models. The technique is based on the law of iterated variance. Suppose you have some regression model: $$Y_i = f(\mathbf{x}_i, \theta) + \varepsilon_i \quad \quad \quad \varepsilon_1,...,\varepsilon_n \sim \text{IID Dist}(0, \sigma^2).$$ Using the law of iterated variance we can write the marginal variance of $Y_i$ as: $$\begin{equation} \begin{aligned} \mathbb{V}(Y_i) &= \mathbb{V}(\mathbb{E}(Y_i|\mathbf{X}_i)) + \mathbb{E}(\mathbb{V}(Y_i|\mathbf{X}_i)) \\[6pt] &= \mathbb{V}(f(\mathbf{X}_i, \theta)) + \mathbb{E}(\varepsilon_i) \\[6pt] &= \mathbb{V}(f(\mathbf{X}_i, \theta)) + \sigma^2. \\[6pt] \end{aligned} \end{equation}$$ Now, if the explanatory vector does not have a relationship with the response variable then the regression function does not depend on the explanatory vector, and so $\mathbb{V}(f(\mathbf{X}_i, \theta)) = 0$, which implies $\mathbb{V}(Y_i) = \sigma^2$. On the other hand, if the explanatory vector does have a relationship with the response variable, then we will generally have $\mathbb{V}(f(\mathbf{X}_i, \theta)) > 0$, which implies $\mathbb{V}(Y_i) > \sigma^2$. Thus, generally speaking, a larger gap between the estimated variance of the response variable, and the estimated variance of the error term, constitutes evidence in favour of the hypothesis that there is a relationship between the explanatory vector and the response variable. This is the basic insight that underlies ANOVA. It is used to construct formal ANOVA tests to determine whether or not there is evidence of a relationship between the explanatory vector and the response variable. By conditioning on parts of the explanatory vector, this basic method can also be used to test for a relationship between particular subsets of explanatory variables and the response variable. In summary, ANOVA is a particular method that is used within the context of regression analysis to test for relationships between variables.
What's the difference between regression and analysis of variance? ANOVA isn't a model --- it is a method within a model The analysis of variance (ANOVA) is a method that occurs within regression models. The technique is based on the law of iterated variance. Suppo
40,629
What's the difference between regression and analysis of variance?
Yes, they are both OLS linear regression, but: $X_i$ in the first regression is a continuous predictor. You can subtitle whatever your values you have in your data set into the equation. $X_i$ in the second regression is a dummy variable. It's $0$ if the response belongs to group 1 otherwise it's $1$. The look similar but they have different interpretation. $b$ in the first model is rate of change between the predictor and response, and are both assumed to be continuous. $b$ in the second model is the treatment effort of the second group relative to the first group. It is a regression for categorical predictor. The models are not the same. The design matrix for the first and second model is different.
What's the difference between regression and analysis of variance?
Yes, they are both OLS linear regression, but: $X_i$ in the first regression is a continuous predictor. You can subtitle whatever your values you have in your data set into the equation. $X_i$ in the
What's the difference between regression and analysis of variance? Yes, they are both OLS linear regression, but: $X_i$ in the first regression is a continuous predictor. You can subtitle whatever your values you have in your data set into the equation. $X_i$ in the second regression is a dummy variable. It's $0$ if the response belongs to group 1 otherwise it's $1$. The look similar but they have different interpretation. $b$ in the first model is rate of change between the predictor and response, and are both assumed to be continuous. $b$ in the second model is the treatment effort of the second group relative to the first group. It is a regression for categorical predictor. The models are not the same. The design matrix for the first and second model is different.
What's the difference between regression and analysis of variance? Yes, they are both OLS linear regression, but: $X_i$ in the first regression is a continuous predictor. You can subtitle whatever your values you have in your data set into the equation. $X_i$ in the
40,630
Finding location and scale parameters from PDF
Let's talk about what a location parameter is. (The discussion of scale parameters will exactly parallel it and offers little new.) The setting concerns a set $\mathcal{F}$ of probability distributions $F_\theta$ indexed by a parameter $\theta \in \Theta \subset \mathbb{R}^p$. "Indexed by" not only means each $\theta\in\Theta$ denotes a distribution $F_\theta$: it also means that no distribution is identified by more than one such $\theta$. Consider any location-covariant property of $F_\theta$, such as a specific quantile (which will always exist) or its first moment (which might exist for some distribution families). By "property" I mean quite generally some "nice" real-valued function $t$ ("nice" will be explained momentarily) defined on this family of distributions and "location-covariant" means that for any $F$ in the family, $$t(F^{(\mu)}) = t(F) + \mu$$ where the translate $F^{(\mu)}$ is the distribution function given by $$F^{(\mu)}(x) = F(x-\mu).$$ Consider any $\theta_0$ in the interior of $\Theta$. Parameterizations are assumed to have the property that such a $\theta_0$ will have a $p$-dimensional neighborhood $\mathcal{B}$ in which $t$ is differentiable with nonzero derivative throughout (that's what "nice" means). The Implicit Function Theorem then implies there is a coordinate system in this neighborhood in which the first coordinate is $t$ and the remaining $p-1$ coordinates are differentiable functions. Locally, at least, the distributions can be parameterized by $t$ and by the codimension-1 subset of $\mathcal{B}$ whose first coordinate is $t(\theta_0)$. That gives a new set of coordinates $\gamma=(\gamma_1,\ldots, \gamma_p)$ with $\gamma_1=t$. We say that $t$ is a location parameter for the family. It has the property that if we fix the last $p-1$ coordinates in $\mathcal{B}$, then the distribution function can be written in the form $$F_{(t, \gamma_2, \ldots,\gamma_p)}(x) = H_{(\gamma_2,\ldots, \gamma_p)}(x-t)$$ where $H$ (and therefore anything equivalent to it, such as its pdf if it has one) depends only on the last $p-1$ parameters. This is how you recognize a location parameter: the argument of the distribution function shows up in the formula only as the combination $x-t$. Let's work an example. Suppose each $F_\theta$ in the interior of $\Theta = \{(\theta_1,\theta_2)\mid \theta_1 \ge 0\}$ is continuous and is given in terms of its pdf $f_\theta$ as $$f_\theta(x) \propto \exp(-\theta_1 x^2 + \theta_2 x) \propto \exp\left(-\theta_1\left(x - \frac{\theta_2}{2\theta_1}\right)^2\right).\tag{1}$$ Is this a location family? If so, what is its location parameter? In the first formula of $(1)$, there is no obvious location parameter: $f_\theta$ is not explicitly a function of $x-\theta_1$ or $x-\theta_2$. The second formula of $(1)$ shows each pdf is symmetric around the value $$t(\theta) = \frac{\theta_2}{2\theta_1},$$ which therefore must be the median. Since the median is a location-covariant property, we can exploit this observation to construct a location parameter. Consider $\theta_0 = (1,0)$ for instance. I chose this to make $t(\theta_0)=0$ have a simple value. The level set of $t$ passing through $\theta_0$ is given by $$0 = t(1,0) = t(\theta_1, \theta_2) = \frac{\theta_2}{2\theta_1},$$ showing that (locally) it's the set where $\theta_2=0$ and we may parameterize it by $\theta_1$. Let us therefore change the parameterization from $\theta$ to $$\gamma = (\gamma_1, \gamma_2) = (t(\theta_1, \theta_2), \theta_1) = \left( \frac{\theta_2}{2\theta_1}, \theta_1\right).$$ The base point $\theta_0$ corresponds to $\gamma_0 = (0, 1)$. The inverse of this transformation from $\theta$ to $\gamma$ is $$\theta = (\theta_1, \theta_2) = \left(\gamma_2, 2\gamma_1\gamma_2\right).$$ The new parameterization is therefore $$G_\gamma(x) = F_{\left(\gamma_2, 2\gamma_1\gamma_2\right)}(x) \propto \exp\left(-\gamma_2(x - \gamma_1)^2\right).$$ Now it is perfectly obvious that $\gamma_1$ is a location parameter, because its sole effect is to shift $x$ in the formula. By finding a candidate for a location parameter and demonstrating it acts as one, we have verified that this is a location family and we have found a location parameter for it. Incidentally, we have also identified this parameter with a location-covariant property: the median.
Finding location and scale parameters from PDF
Let's talk about what a location parameter is. (The discussion of scale parameters will exactly parallel it and offers little new.) The setting concerns a set $\mathcal{F}$ of probability distributio
Finding location and scale parameters from PDF Let's talk about what a location parameter is. (The discussion of scale parameters will exactly parallel it and offers little new.) The setting concerns a set $\mathcal{F}$ of probability distributions $F_\theta$ indexed by a parameter $\theta \in \Theta \subset \mathbb{R}^p$. "Indexed by" not only means each $\theta\in\Theta$ denotes a distribution $F_\theta$: it also means that no distribution is identified by more than one such $\theta$. Consider any location-covariant property of $F_\theta$, such as a specific quantile (which will always exist) or its first moment (which might exist for some distribution families). By "property" I mean quite generally some "nice" real-valued function $t$ ("nice" will be explained momentarily) defined on this family of distributions and "location-covariant" means that for any $F$ in the family, $$t(F^{(\mu)}) = t(F) + \mu$$ where the translate $F^{(\mu)}$ is the distribution function given by $$F^{(\mu)}(x) = F(x-\mu).$$ Consider any $\theta_0$ in the interior of $\Theta$. Parameterizations are assumed to have the property that such a $\theta_0$ will have a $p$-dimensional neighborhood $\mathcal{B}$ in which $t$ is differentiable with nonzero derivative throughout (that's what "nice" means). The Implicit Function Theorem then implies there is a coordinate system in this neighborhood in which the first coordinate is $t$ and the remaining $p-1$ coordinates are differentiable functions. Locally, at least, the distributions can be parameterized by $t$ and by the codimension-1 subset of $\mathcal{B}$ whose first coordinate is $t(\theta_0)$. That gives a new set of coordinates $\gamma=(\gamma_1,\ldots, \gamma_p)$ with $\gamma_1=t$. We say that $t$ is a location parameter for the family. It has the property that if we fix the last $p-1$ coordinates in $\mathcal{B}$, then the distribution function can be written in the form $$F_{(t, \gamma_2, \ldots,\gamma_p)}(x) = H_{(\gamma_2,\ldots, \gamma_p)}(x-t)$$ where $H$ (and therefore anything equivalent to it, such as its pdf if it has one) depends only on the last $p-1$ parameters. This is how you recognize a location parameter: the argument of the distribution function shows up in the formula only as the combination $x-t$. Let's work an example. Suppose each $F_\theta$ in the interior of $\Theta = \{(\theta_1,\theta_2)\mid \theta_1 \ge 0\}$ is continuous and is given in terms of its pdf $f_\theta$ as $$f_\theta(x) \propto \exp(-\theta_1 x^2 + \theta_2 x) \propto \exp\left(-\theta_1\left(x - \frac{\theta_2}{2\theta_1}\right)^2\right).\tag{1}$$ Is this a location family? If so, what is its location parameter? In the first formula of $(1)$, there is no obvious location parameter: $f_\theta$ is not explicitly a function of $x-\theta_1$ or $x-\theta_2$. The second formula of $(1)$ shows each pdf is symmetric around the value $$t(\theta) = \frac{\theta_2}{2\theta_1},$$ which therefore must be the median. Since the median is a location-covariant property, we can exploit this observation to construct a location parameter. Consider $\theta_0 = (1,0)$ for instance. I chose this to make $t(\theta_0)=0$ have a simple value. The level set of $t$ passing through $\theta_0$ is given by $$0 = t(1,0) = t(\theta_1, \theta_2) = \frac{\theta_2}{2\theta_1},$$ showing that (locally) it's the set where $\theta_2=0$ and we may parameterize it by $\theta_1$. Let us therefore change the parameterization from $\theta$ to $$\gamma = (\gamma_1, \gamma_2) = (t(\theta_1, \theta_2), \theta_1) = \left( \frac{\theta_2}{2\theta_1}, \theta_1\right).$$ The base point $\theta_0$ corresponds to $\gamma_0 = (0, 1)$. The inverse of this transformation from $\theta$ to $\gamma$ is $$\theta = (\theta_1, \theta_2) = \left(\gamma_2, 2\gamma_1\gamma_2\right).$$ The new parameterization is therefore $$G_\gamma(x) = F_{\left(\gamma_2, 2\gamma_1\gamma_2\right)}(x) \propto \exp\left(-\gamma_2(x - \gamma_1)^2\right).$$ Now it is perfectly obvious that $\gamma_1$ is a location parameter, because its sole effect is to shift $x$ in the formula. By finding a candidate for a location parameter and demonstrating it acts as one, we have verified that this is a location family and we have found a location parameter for it. Incidentally, we have also identified this parameter with a location-covariant property: the median.
Finding location and scale parameters from PDF Let's talk about what a location parameter is. (The discussion of scale parameters will exactly parallel it and offers little new.) The setting concerns a set $\mathcal{F}$ of probability distributio
40,631
Finding location and scale parameters from PDF
Consider a random variable $Z$ with any density function $f_Z(z)$. You can define a location–scale family with the transform $X=\phi Z +\theta$, & the new density function is given by $$f_X(x;\theta,\phi) = \frac{1}{\phi}\cdot f_Z\left(\frac{x-\theta}{\phi}\right)$$ So any family of distributions whose density function can be written in this form is a location–scale family. For example the family of uniform distributions on $(a,b)$ is defined by the density function $$f_X(x;a,b) = \frac{1}{b-a}\cdot \boldsymbol{1}_{[a,b]}(x)$$ which can be re-written as $$f_X(x;a,b) = \frac{1}{b-a}\cdot \boldsymbol{1}_{[0,1]}\left(\frac{x-a}{b-a}\right)$$ $$f_X(x;a,b) = \frac{1}{b-a}\cdot f_X\left(\frac{x-a}{b-a};0,1\right)$$ showing that $a$ is a location parameter & $b-a$ is a scale parameter.
Finding location and scale parameters from PDF
Consider a random variable $Z$ with any density function $f_Z(z)$. You can define a location–scale family with the transform $X=\phi Z +\theta$, & the new density function is given by $$f_X(x;\theta,\
Finding location and scale parameters from PDF Consider a random variable $Z$ with any density function $f_Z(z)$. You can define a location–scale family with the transform $X=\phi Z +\theta$, & the new density function is given by $$f_X(x;\theta,\phi) = \frac{1}{\phi}\cdot f_Z\left(\frac{x-\theta}{\phi}\right)$$ So any family of distributions whose density function can be written in this form is a location–scale family. For example the family of uniform distributions on $(a,b)$ is defined by the density function $$f_X(x;a,b) = \frac{1}{b-a}\cdot \boldsymbol{1}_{[a,b]}(x)$$ which can be re-written as $$f_X(x;a,b) = \frac{1}{b-a}\cdot \boldsymbol{1}_{[0,1]}\left(\frac{x-a}{b-a}\right)$$ $$f_X(x;a,b) = \frac{1}{b-a}\cdot f_X\left(\frac{x-a}{b-a};0,1\right)$$ showing that $a$ is a location parameter & $b-a$ is a scale parameter.
Finding location and scale parameters from PDF Consider a random variable $Z$ with any density function $f_Z(z)$. You can define a location–scale family with the transform $X=\phi Z +\theta$, & the new density function is given by $$f_X(x;\theta,\
40,632
Which binomial prediction interval works well for tail probabilities, i.e. $\hat{p}=1/n$ for large $n$
There is a simple nonparametric prediction limit. Recall that a prediction limit is a procedure consisting of two independent samples $\mathcal{X}=x_1,\ldots, x_n$ and $\mathcal{Y}=y_1, \ldots, y_m$, two statistics $t$ and $s$, and a size $1-\alpha$. When the chance that $s(\mathcal{Y})$ is less than $t(\mathcal{X})$ is $\alpha$ or smaller, we say that $t$ is a one-sided lower prediction limit for $s$ of size $1-\alpha$. The PL in question uses the smallest of the $x_i$ for $t(\mathcal{X})$. It is intended that all the $y_j$ should equal or exceed the PL with high probability. Equivalently, $s(\mathcal{Y})$ is the smallest of all the $y_j$. This PL works when the $n$ observations are independent and identically distributed and the $m$ additional observations are also iid and independent of the first $n$ observations. These assumptions imply all $n+m$ observations are exchangeable, which in turn (easily) implies the smallest observation of them all is found among the first $n$ with probability at least $n/(n+m)$. The size is the chance that one (at least) of all the observations tied for smallest lies within the $n$ values of $\mathcal{X}$. This chance is no smaller than $n/(n+m)$. When the common underlying distribution is continuous, it is exactly $n/(n+m)$. For example, the smallest of $n=95$ values is a $95\%$ lower prediction limit for $m=5$ additional values. The smallest of $n=10^6$ values is only a $50\%$ lower prediction limit for $m=10^6$ additional values. Similar considerations (requiring more combinatorial sophistication) are used to compute the coverage of any order statistic qua prediction limit. See section 5.4 of Hahn & Meeker for a synopsis ("Distribution-free prediction intervals to contain at least $k$ of $m$ future observations.") Reference Gerald J. Hahn and William Q. Meeker, Statistical Intervals, A Guide For Practitioners. J. Wiley & Sons, 1991.
Which binomial prediction interval works well for tail probabilities, i.e. $\hat{p}=1/n$ for large $
There is a simple nonparametric prediction limit. Recall that a prediction limit is a procedure consisting of two independent samples $\mathcal{X}=x_1,\ldots, x_n$ and $\mathcal{Y}=y_1, \ldots, y_m$,
Which binomial prediction interval works well for tail probabilities, i.e. $\hat{p}=1/n$ for large $n$ There is a simple nonparametric prediction limit. Recall that a prediction limit is a procedure consisting of two independent samples $\mathcal{X}=x_1,\ldots, x_n$ and $\mathcal{Y}=y_1, \ldots, y_m$, two statistics $t$ and $s$, and a size $1-\alpha$. When the chance that $s(\mathcal{Y})$ is less than $t(\mathcal{X})$ is $\alpha$ or smaller, we say that $t$ is a one-sided lower prediction limit for $s$ of size $1-\alpha$. The PL in question uses the smallest of the $x_i$ for $t(\mathcal{X})$. It is intended that all the $y_j$ should equal or exceed the PL with high probability. Equivalently, $s(\mathcal{Y})$ is the smallest of all the $y_j$. This PL works when the $n$ observations are independent and identically distributed and the $m$ additional observations are also iid and independent of the first $n$ observations. These assumptions imply all $n+m$ observations are exchangeable, which in turn (easily) implies the smallest observation of them all is found among the first $n$ with probability at least $n/(n+m)$. The size is the chance that one (at least) of all the observations tied for smallest lies within the $n$ values of $\mathcal{X}$. This chance is no smaller than $n/(n+m)$. When the common underlying distribution is continuous, it is exactly $n/(n+m)$. For example, the smallest of $n=95$ values is a $95\%$ lower prediction limit for $m=5$ additional values. The smallest of $n=10^6$ values is only a $50\%$ lower prediction limit for $m=10^6$ additional values. Similar considerations (requiring more combinatorial sophistication) are used to compute the coverage of any order statistic qua prediction limit. See section 5.4 of Hahn & Meeker for a synopsis ("Distribution-free prediction intervals to contain at least $k$ of $m$ future observations.") Reference Gerald J. Hahn and William Q. Meeker, Statistical Intervals, A Guide For Practitioners. J. Wiley & Sons, 1991.
Which binomial prediction interval works well for tail probabilities, i.e. $\hat{p}=1/n$ for large $ There is a simple nonparametric prediction limit. Recall that a prediction limit is a procedure consisting of two independent samples $\mathcal{X}=x_1,\ldots, x_n$ and $\mathcal{Y}=y_1, \ldots, y_m$,
40,633
How do I get the Box-Cox log likelihood using the Jacobian?
To ensure that the likelihoods for different values of $\lambda$ are compareable, we need the log likelihood based on the untransformed non-Gaussian data $y_1,\dots,y_n$, that is, $$ l(\lambda,\boldsymbol{\beta},\sigma^2)=\ln f(y_1,\dots,y_n).\tag{1} $$ According to the model, the pdf of the transformed data, say $f_{(\lambda)}$, is Gaussian, such that, $$ \ln f_{(\lambda)}(y_1^{(\lambda)},\dots,y_n^{(\lambda)})= -\frac{n}{2}\log(2\pi\sigma^{2})-\frac{1}{2\sigma^{2}}(\mathbf{y}^{(\lambda)}-\mathbf{X}\boldsymbol{\beta})^{T}(\mathbf{y}^{(\lambda)}-\mathbf{X}\boldsymbol{\beta}). \tag{2} $$ The relationship between the two pdfs is $$ f(y_1,\dots,y_n)=f_{(\lambda)}(y_1^{(\lambda)},\dots,y_n^{(\lambda)})|\mathbf{J}|,\tag{3} $$ where the diagonal elements of the Jacobian are $\partial y_i^{(\lambda)}/\partial y_i = y_i^{\lambda-1}$ and the off-diagonal elements $\partial y_i^{(\lambda)}/\partial y_j$ are all zero. Hence, the determinant $$|\mathbf{J}|=\prod_{i=1}^n y_i^{\lambda-1}.\tag{4} $$ Combining (1) to (4) leads to the log likelihood function $l$ in your question. EDIT: Instead of including the additional term from the Jacobian (3) in the log likelihood (e.g. before maximising this with respect to $\lambda$), an alternative is to fit the model to $y_i'=y_i^{(\lambda)}/\tilde y^{\lambda-1}$ where $\tilde y=(\prod_{i=1}^n y_i)^{1/n}$ (the geometric mean of the original $y_i$'s). This has pdf \begin{align} f'(y_1',\dots,y_n')&=f_{(\lambda)}(y_1^{(\lambda)},\dots,y_n^{(\lambda)})(\tilde y^{\lambda-1})^n \\&=f_{(\lambda)}(y_1^{(\lambda)},\dots,y_n^{(\lambda)})\prod_{i=1}^n y_i^{\lambda-1} \\&=f(y_1,\dots,y_n). \end{align} The likelihood you obtain from fitting the model to this transformation is thus identical to the likelihood (1) that we seek without the inclusion of any extra correction term.
How do I get the Box-Cox log likelihood using the Jacobian?
To ensure that the likelihoods for different values of $\lambda$ are compareable, we need the log likelihood based on the untransformed non-Gaussian data $y_1,\dots,y_n$, that is, $$ l(\lambda,\boldsy
How do I get the Box-Cox log likelihood using the Jacobian? To ensure that the likelihoods for different values of $\lambda$ are compareable, we need the log likelihood based on the untransformed non-Gaussian data $y_1,\dots,y_n$, that is, $$ l(\lambda,\boldsymbol{\beta},\sigma^2)=\ln f(y_1,\dots,y_n).\tag{1} $$ According to the model, the pdf of the transformed data, say $f_{(\lambda)}$, is Gaussian, such that, $$ \ln f_{(\lambda)}(y_1^{(\lambda)},\dots,y_n^{(\lambda)})= -\frac{n}{2}\log(2\pi\sigma^{2})-\frac{1}{2\sigma^{2}}(\mathbf{y}^{(\lambda)}-\mathbf{X}\boldsymbol{\beta})^{T}(\mathbf{y}^{(\lambda)}-\mathbf{X}\boldsymbol{\beta}). \tag{2} $$ The relationship between the two pdfs is $$ f(y_1,\dots,y_n)=f_{(\lambda)}(y_1^{(\lambda)},\dots,y_n^{(\lambda)})|\mathbf{J}|,\tag{3} $$ where the diagonal elements of the Jacobian are $\partial y_i^{(\lambda)}/\partial y_i = y_i^{\lambda-1}$ and the off-diagonal elements $\partial y_i^{(\lambda)}/\partial y_j$ are all zero. Hence, the determinant $$|\mathbf{J}|=\prod_{i=1}^n y_i^{\lambda-1}.\tag{4} $$ Combining (1) to (4) leads to the log likelihood function $l$ in your question. EDIT: Instead of including the additional term from the Jacobian (3) in the log likelihood (e.g. before maximising this with respect to $\lambda$), an alternative is to fit the model to $y_i'=y_i^{(\lambda)}/\tilde y^{\lambda-1}$ where $\tilde y=(\prod_{i=1}^n y_i)^{1/n}$ (the geometric mean of the original $y_i$'s). This has pdf \begin{align} f'(y_1',\dots,y_n')&=f_{(\lambda)}(y_1^{(\lambda)},\dots,y_n^{(\lambda)})(\tilde y^{\lambda-1})^n \\&=f_{(\lambda)}(y_1^{(\lambda)},\dots,y_n^{(\lambda)})\prod_{i=1}^n y_i^{\lambda-1} \\&=f(y_1,\dots,y_n). \end{align} The likelihood you obtain from fitting the model to this transformation is thus identical to the likelihood (1) that we seek without the inclusion of any extra correction term.
How do I get the Box-Cox log likelihood using the Jacobian? To ensure that the likelihoods for different values of $\lambda$ are compareable, we need the log likelihood based on the untransformed non-Gaussian data $y_1,\dots,y_n$, that is, $$ l(\lambda,\boldsy
40,634
Variance of a stationary AR(2) model
Stationarity Considering your AR(2) process with mean zero i.i.d. noise $\epsilon_t$ of variance $\sigma_\epsilon^2$, $$ y_t = \beta_1 y_{t-1} + \beta_2 y_{t-2} + \epsilon_t \,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,(*) $$ we can rewrite it in terms of the lag operator $L$ $$ (1 - \beta_1 L - \beta_2 L^2)y_t = \epsilon_t $$ so that we have a new operator $$ 1 - \beta_1 L - \beta_2 L^2 $$ If the above were a polynomial in $L$, let its roots be $z_1^{-1}, z_2^{-1}$. We call the polynomial the characteristic polynomial, and $z_1, z_2$ its factors. (Note the factors and roots are inverses of each other, and may be complex.) It can be shown that the AR(2) is stationary when $|z_1| < 1$ and $|z_2|<1$. i.e. when all of the following are met: $$ |\beta_2| < 1 \\ \beta_2 + \beta_1 < 1 \\ \beta_2 - \beta_1 < 1 $$ For details, see this answer. Or in terms of the more general ARMA(p,q) process, see Introduction to Time Series and Forecasting. Brockwell and Davis. 2016. p 74. Variance If the process is stationary, we can write the covariance as a function of increment alone, so let the covariance function $\gamma(k) \doteq E[y_t y_{t+k}]$. We can find the variance $\gamma(0)$ by squaring and taking the expectation of both sides of equation $(*)$ with the following result $$ \gamma(0) = \beta_1^2 \gamma(0) + \beta_2^2 \gamma(0) + 2 \beta_1 \beta_2 \gamma(1) + \sigma_\epsilon^2 \,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,(**) $$ Starting again from equation $(*)$, this time multiply both sides by $y_{t-k}$ and again take the expectation $$ \gamma(k) = \beta_1 \gamma(k-1) + \beta_2 \gamma(k-2) $$ Usefully, we now have an expression for covariance, but we just need it to compute $\gamma(1)$. Since $\gamma(-1) = \gamma(1)$ (examine the definition, note that covariance is not a function of $t$), we can let $k=1$ in the above equation and get $$ \gamma(1) = \frac{\beta_1 \gamma(0)}{1-\beta_2} $$ Substituting into $(**)$, we get the variance $$ \text{Var}(y_t) = \gamma(0) = \frac{(1-\beta_2)\sigma_\epsilon^2}{(1+\beta_2)(1 - \beta_1 - \beta_2)(1 + \beta_1 - \beta_2)} $$ As a sanity check, our stationarity conditions on $\beta_1, \beta_2$ described earlier are precisely the conditions which make our expression for $\text{Var}(y_t)$ positive. The above is essentially a summary and rearrangement of some parts of these notes. Strong or Weak Stationarity I have only seen arguments of AR process stationarity in terms of fixed mean and variance, so weak stationarity is implied. However, if the stationary distribution can be characterized completely in terms of those first and second moments, then we also have strong stationarity. See A unified view of linear AR(1) models. G.K. Grunwald. 1996. As an example, if we have an AR(1) process and $\epsilon_t$ is i.i.d. Gaussian, then the process' stationary distribution is also Gaussian. Since the Gaussian is fully specified by its first two moments, we have strong stationarity in that case. I am unsure whether or not this also applies to more general AR(p) Gaussian processes, or to AR(p) processes with other kinds of i.i.d. noise.
Variance of a stationary AR(2) model
Stationarity Considering your AR(2) process with mean zero i.i.d. noise $\epsilon_t$ of variance $\sigma_\epsilon^2$, $$ y_t = \beta_1 y_{t-1} + \beta_2 y_{t-2} + \epsilon_t \,\,\,\,\,\,\,\,\,\,\,\,\
Variance of a stationary AR(2) model Stationarity Considering your AR(2) process with mean zero i.i.d. noise $\epsilon_t$ of variance $\sigma_\epsilon^2$, $$ y_t = \beta_1 y_{t-1} + \beta_2 y_{t-2} + \epsilon_t \,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,(*) $$ we can rewrite it in terms of the lag operator $L$ $$ (1 - \beta_1 L - \beta_2 L^2)y_t = \epsilon_t $$ so that we have a new operator $$ 1 - \beta_1 L - \beta_2 L^2 $$ If the above were a polynomial in $L$, let its roots be $z_1^{-1}, z_2^{-1}$. We call the polynomial the characteristic polynomial, and $z_1, z_2$ its factors. (Note the factors and roots are inverses of each other, and may be complex.) It can be shown that the AR(2) is stationary when $|z_1| < 1$ and $|z_2|<1$. i.e. when all of the following are met: $$ |\beta_2| < 1 \\ \beta_2 + \beta_1 < 1 \\ \beta_2 - \beta_1 < 1 $$ For details, see this answer. Or in terms of the more general ARMA(p,q) process, see Introduction to Time Series and Forecasting. Brockwell and Davis. 2016. p 74. Variance If the process is stationary, we can write the covariance as a function of increment alone, so let the covariance function $\gamma(k) \doteq E[y_t y_{t+k}]$. We can find the variance $\gamma(0)$ by squaring and taking the expectation of both sides of equation $(*)$ with the following result $$ \gamma(0) = \beta_1^2 \gamma(0) + \beta_2^2 \gamma(0) + 2 \beta_1 \beta_2 \gamma(1) + \sigma_\epsilon^2 \,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,(**) $$ Starting again from equation $(*)$, this time multiply both sides by $y_{t-k}$ and again take the expectation $$ \gamma(k) = \beta_1 \gamma(k-1) + \beta_2 \gamma(k-2) $$ Usefully, we now have an expression for covariance, but we just need it to compute $\gamma(1)$. Since $\gamma(-1) = \gamma(1)$ (examine the definition, note that covariance is not a function of $t$), we can let $k=1$ in the above equation and get $$ \gamma(1) = \frac{\beta_1 \gamma(0)}{1-\beta_2} $$ Substituting into $(**)$, we get the variance $$ \text{Var}(y_t) = \gamma(0) = \frac{(1-\beta_2)\sigma_\epsilon^2}{(1+\beta_2)(1 - \beta_1 - \beta_2)(1 + \beta_1 - \beta_2)} $$ As a sanity check, our stationarity conditions on $\beta_1, \beta_2$ described earlier are precisely the conditions which make our expression for $\text{Var}(y_t)$ positive. The above is essentially a summary and rearrangement of some parts of these notes. Strong or Weak Stationarity I have only seen arguments of AR process stationarity in terms of fixed mean and variance, so weak stationarity is implied. However, if the stationary distribution can be characterized completely in terms of those first and second moments, then we also have strong stationarity. See A unified view of linear AR(1) models. G.K. Grunwald. 1996. As an example, if we have an AR(1) process and $\epsilon_t$ is i.i.d. Gaussian, then the process' stationary distribution is also Gaussian. Since the Gaussian is fully specified by its first two moments, we have strong stationarity in that case. I am unsure whether or not this also applies to more general AR(p) Gaussian processes, or to AR(p) processes with other kinds of i.i.d. noise.
Variance of a stationary AR(2) model Stationarity Considering your AR(2) process with mean zero i.i.d. noise $\epsilon_t$ of variance $\sigma_\epsilon^2$, $$ y_t = \beta_1 y_{t-1} + \beta_2 y_{t-2} + \epsilon_t \,\,\,\,\,\,\,\,\,\,\,\,\
40,635
Variance of a stationary AR(2) model
I do not have enough reputation to comment, so I’ll post it as an answer instead: The accepted answer can be simplified to: $$ \sigma = \frac{\sigma_Z^2}{1-\beta_1^2 (\frac{1+\beta_2}{1-\beta_2})-\beta_2^2} $$ See also: Prove the Variance of an AR(2) Model EDIT: So I re-did the math and it seems the answer of the posted link contains a small mistake. I updated the simplified answer accordingly.
Variance of a stationary AR(2) model
I do not have enough reputation to comment, so I’ll post it as an answer instead: The accepted answer can be simplified to: $$ \sigma = \frac{\sigma_Z^2}{1-\beta_1^2 (\frac{1+\beta_2}{1-\beta_2})-\bet
Variance of a stationary AR(2) model I do not have enough reputation to comment, so I’ll post it as an answer instead: The accepted answer can be simplified to: $$ \sigma = \frac{\sigma_Z^2}{1-\beta_1^2 (\frac{1+\beta_2}{1-\beta_2})-\beta_2^2} $$ See also: Prove the Variance of an AR(2) Model EDIT: So I re-did the math and it seems the answer of the posted link contains a small mistake. I updated the simplified answer accordingly.
Variance of a stationary AR(2) model I do not have enough reputation to comment, so I’ll post it as an answer instead: The accepted answer can be simplified to: $$ \sigma = \frac{\sigma_Z^2}{1-\beta_1^2 (\frac{1+\beta_2}{1-\beta_2})-\bet
40,636
Variance of a stationary AR(2) model
Stack it, i.e. write as VAR(1) for the vector x(t) = [y(t),y(t-1)]', x(t) = [beta1,beta2;1,0] x(t-1) + [epsilon(t),0]'. Vectorize the resulting matrix equation and exploit vec(ABC)=(C' kron A) vec(B)
Variance of a stationary AR(2) model
Stack it, i.e. write as VAR(1) for the vector x(t) = [y(t),y(t-1)]', x(t) = [beta1,beta2;1,0] x(t-1) + [epsilon(t),0]'. Vectorize the resulting matrix equation and exploit vec(ABC)=(C' kron A) vec(B)
Variance of a stationary AR(2) model Stack it, i.e. write as VAR(1) for the vector x(t) = [y(t),y(t-1)]', x(t) = [beta1,beta2;1,0] x(t-1) + [epsilon(t),0]'. Vectorize the resulting matrix equation and exploit vec(ABC)=(C' kron A) vec(B)
Variance of a stationary AR(2) model Stack it, i.e. write as VAR(1) for the vector x(t) = [y(t),y(t-1)]', x(t) = [beta1,beta2;1,0] x(t-1) + [epsilon(t),0]'. Vectorize the resulting matrix equation and exploit vec(ABC)=(C' kron A) vec(B)
40,637
Variance of a stationary AR(2) model
From $X_t = \phi_1 X_{t-1} + \phi_2 X_{t-2} $, \begin{eqnarray*} E[ X_t X_{t-k}] &=& \phi_1 E[X_{t-1} X_{t-k}] + \phi_2 E[X_{t-2} X_{t-k}] + E[X_t X_{t-1}] \\ \gamma_k &=& \phi_1 \gamma_{k-1} + \phi_2 \gamma_{k-2} + E[Z_t X_{t-k}] \quad (*) \end{eqnarray*} Now, \begin{eqnarray} E[Z_t X_{t-k}] = \left \{ \begin{array}{cc} \sigma_Z^2 & \text{if } k = 0 \\ 0 & \text{if } k=1,2, \cdots \end{array} \right . (**) \end{eqnarray} Then combining (*) with (**) and using the symmetry property of the autocorrelation function. That is, $\gamma_t = \gamma_{-t}$ \begin{eqnarray} \sigma^2 = \gamma_0 &=& \phi_1 \gamma_{1} + \phi_2 \gamma_{2} + \sigma_Z^2 \quad , \quad (****) \\ \gamma_k &=& \phi_1 \gamma_{k-1} + \phi_2 \gamma_{k-2} \quad , \quad k=1,2, \cdots. \quad , \quad (***) \end{eqnarray} We need to find $\gamma_1$ and $\gamma_2$. From () \begin{eqnarray} \gamma_1 = \phi_1 \gamma_0 + \phi_2 \gamma_{-1} = \phi_1 \gamma_0 + \phi_2 \gamma_1 \\ \gamma_1 = \frac{\phi_1 \gamma_0}{1 - \phi_2} = \frac{\phi_1 \sigma^2}{1 - \phi_2} \end{eqnarray} From () with $k=2$ we find that \begin{eqnarray} \gamma_2 = \phi_1 \gamma_1 + \phi_2 \gamma_0 = \phi_1 \frac{\phi_1 \sigma^2}{1-\phi_2} + \phi_2 \sigma^2 = \sigma^2 \left ( \frac{\phi_1^2 + \phi_2(1 - \phi_2) }{1 - \phi_2}\right ) \quad , \quad (*****) \end{eqnarray} Then by pluggin this in (****) $$ \sigma^2 = \phi_1 \left ( \frac{\phi_1 \sigma^2}{1 - \phi_2} \right ) + \phi_2 \sigma^2 \left ( \frac{\phi_1^2 + \phi_2(1 - \phi_2) }{1 - \phi_2}\right ) + \sigma_Z^2$$ That is, \begin{eqnarray} \sigma^2 \left [1 - \left ( \frac{\phi_1^2}{1 - \phi_2} \right ) -\phi_2 \left ( \frac{\phi_1^2 + \phi_2(1 - \phi_2) }{1 - \phi_2}\right ) \right ] = \sigma_Z^2 \end{eqnarray} We simplify the quantity in brackets. That is: \begin{eqnarray} 1 - \left ( \frac{\phi_1^2}{1 - \phi_2} \right ) -\phi_2 \left ( \frac{\phi_1^2 + \phi_2(1 - \phi_2) }{1 - \phi_2}\right ) &=&\frac{1 -\phi_2 - \phi_1^2 - \phi_2 \phi_1^2 - \phi_2^2 + \phi_2^3}{1 - \phi_2} \\ &=& \frac{(1 - \phi_2^2) - \phi_1^2(1 + \phi_2) + \phi_2(\phi_2^2 -1)}{1 - \phi_2} \\ &=& \frac{(1-\phi_2)(1 + \phi_2) - \phi_1^2(1 + \phi_2) - \phi_2(1 -\phi_2)(1 + \phi_2) }{1-\phi_2} \\ &=& \frac{(1 + \phi_2) (1 - \phi_2 - \phi_1^2 - \phi_2(1 - \phi_2))}{1 - \phi_2} \\ &=& \frac{(1 + \phi_2) (1 - 2 \phi_2 + \phi_2^2 - \phi_1^2)}{1 - \phi_2} \\ &=& \frac{(1 + \phi_2)[( 1 - \phi_2)^2 - \phi_1^2]}{1 - \phi_2} \\ &=& \frac{(1+ \phi_2)( 1 - \phi_2 - \phi_1)(1 - \phi_2 + \phi_1)}{1 - \phi_2} \end{eqnarray} We find then that \begin{eqnarray} \sigma^2 = \frac{(1 - \phi_2) \sigma_Z^2}{(1+ \phi_2)( 1 - \phi_2 - \phi_1) (1 - \phi_2 + \phi_1)} \end{eqnarray}
Variance of a stationary AR(2) model
From $X_t = \phi_1 X_{t-1} + \phi_2 X_{t-2} $, \begin{eqnarray*} E[ X_t X_{t-k}] &=& \phi_1 E[X_{t-1} X_{t-k}] + \phi_2 E[X_{t-2} X_{t-k}] + E[X_t X_{t-1}] \\ \gamma_k &=& \phi_1 \gamma_{k-1} +
Variance of a stationary AR(2) model From $X_t = \phi_1 X_{t-1} + \phi_2 X_{t-2} $, \begin{eqnarray*} E[ X_t X_{t-k}] &=& \phi_1 E[X_{t-1} X_{t-k}] + \phi_2 E[X_{t-2} X_{t-k}] + E[X_t X_{t-1}] \\ \gamma_k &=& \phi_1 \gamma_{k-1} + \phi_2 \gamma_{k-2} + E[Z_t X_{t-k}] \quad (*) \end{eqnarray*} Now, \begin{eqnarray} E[Z_t X_{t-k}] = \left \{ \begin{array}{cc} \sigma_Z^2 & \text{if } k = 0 \\ 0 & \text{if } k=1,2, \cdots \end{array} \right . (**) \end{eqnarray} Then combining (*) with (**) and using the symmetry property of the autocorrelation function. That is, $\gamma_t = \gamma_{-t}$ \begin{eqnarray} \sigma^2 = \gamma_0 &=& \phi_1 \gamma_{1} + \phi_2 \gamma_{2} + \sigma_Z^2 \quad , \quad (****) \\ \gamma_k &=& \phi_1 \gamma_{k-1} + \phi_2 \gamma_{k-2} \quad , \quad k=1,2, \cdots. \quad , \quad (***) \end{eqnarray} We need to find $\gamma_1$ and $\gamma_2$. From () \begin{eqnarray} \gamma_1 = \phi_1 \gamma_0 + \phi_2 \gamma_{-1} = \phi_1 \gamma_0 + \phi_2 \gamma_1 \\ \gamma_1 = \frac{\phi_1 \gamma_0}{1 - \phi_2} = \frac{\phi_1 \sigma^2}{1 - \phi_2} \end{eqnarray} From () with $k=2$ we find that \begin{eqnarray} \gamma_2 = \phi_1 \gamma_1 + \phi_2 \gamma_0 = \phi_1 \frac{\phi_1 \sigma^2}{1-\phi_2} + \phi_2 \sigma^2 = \sigma^2 \left ( \frac{\phi_1^2 + \phi_2(1 - \phi_2) }{1 - \phi_2}\right ) \quad , \quad (*****) \end{eqnarray} Then by pluggin this in (****) $$ \sigma^2 = \phi_1 \left ( \frac{\phi_1 \sigma^2}{1 - \phi_2} \right ) + \phi_2 \sigma^2 \left ( \frac{\phi_1^2 + \phi_2(1 - \phi_2) }{1 - \phi_2}\right ) + \sigma_Z^2$$ That is, \begin{eqnarray} \sigma^2 \left [1 - \left ( \frac{\phi_1^2}{1 - \phi_2} \right ) -\phi_2 \left ( \frac{\phi_1^2 + \phi_2(1 - \phi_2) }{1 - \phi_2}\right ) \right ] = \sigma_Z^2 \end{eqnarray} We simplify the quantity in brackets. That is: \begin{eqnarray} 1 - \left ( \frac{\phi_1^2}{1 - \phi_2} \right ) -\phi_2 \left ( \frac{\phi_1^2 + \phi_2(1 - \phi_2) }{1 - \phi_2}\right ) &=&\frac{1 -\phi_2 - \phi_1^2 - \phi_2 \phi_1^2 - \phi_2^2 + \phi_2^3}{1 - \phi_2} \\ &=& \frac{(1 - \phi_2^2) - \phi_1^2(1 + \phi_2) + \phi_2(\phi_2^2 -1)}{1 - \phi_2} \\ &=& \frac{(1-\phi_2)(1 + \phi_2) - \phi_1^2(1 + \phi_2) - \phi_2(1 -\phi_2)(1 + \phi_2) }{1-\phi_2} \\ &=& \frac{(1 + \phi_2) (1 - \phi_2 - \phi_1^2 - \phi_2(1 - \phi_2))}{1 - \phi_2} \\ &=& \frac{(1 + \phi_2) (1 - 2 \phi_2 + \phi_2^2 - \phi_1^2)}{1 - \phi_2} \\ &=& \frac{(1 + \phi_2)[( 1 - \phi_2)^2 - \phi_1^2]}{1 - \phi_2} \\ &=& \frac{(1+ \phi_2)( 1 - \phi_2 - \phi_1)(1 - \phi_2 + \phi_1)}{1 - \phi_2} \end{eqnarray} We find then that \begin{eqnarray} \sigma^2 = \frac{(1 - \phi_2) \sigma_Z^2}{(1+ \phi_2)( 1 - \phi_2 - \phi_1) (1 - \phi_2 + \phi_1)} \end{eqnarray}
Variance of a stationary AR(2) model From $X_t = \phi_1 X_{t-1} + \phi_2 X_{t-2} $, \begin{eqnarray*} E[ X_t X_{t-k}] &=& \phi_1 E[X_{t-1} X_{t-k}] + \phi_2 E[X_{t-2} X_{t-k}] + E[X_t X_{t-1}] \\ \gamma_k &=& \phi_1 \gamma_{k-1} +
40,638
Forecasting time series using ARMA-GARCH in R
Obtaining accurate point forecasts for financial time series is notoriously hard. That has to do with the nature of the financial markets; actors look for opportunities to exploit any predictability, and they remove it while they are doing it (change in expected profitability of an asset $\rightarrow$ change in supply/demand $\rightarrow$ change in asset price). This happens very quickly in active markets, so that the predictability does not persist long enough for models to capture it. Thus financial time series often behave like random walks with some heteroskedasticity. Meanwhile, volatility of financial time series is easier to predict as apparently there is no market mechanism to remove the predictability. That is why your GARCH forecasts of volatility seem to work rather well. But you should note that graphs of fitted volatility vs. realized squared returns can be somewhat misleading. Leaving aside the fact that squared returns are only a noisy proxy of realized volatility, there is another thing: our eyes are easily tricked by graphs like the first one in your post. When it comes to goodness of fit, our eyes pay attention not only to to the vertical distance between fitted and realized values, which is what matters, but also to horizontal distance. So instead of graphing fitted. vs. realized values (two lines), it is helpful to graph just the difference between the two (one line). You might be surprised to discover that differences which appear small from the first type of graph are not that small when depicted in the second type of graph. This is because the fitted volatility from GARCH typically lags the realized volatility by one period. If a time series has many data points, this lag (the horizontal difference) is visually small and can hardly be noticed, so the fit looks better than it actually is.
Forecasting time series using ARMA-GARCH in R
Obtaining accurate point forecasts for financial time series is notoriously hard. That has to do with the nature of the financial markets; actors look for opportunities to exploit any predictability,
Forecasting time series using ARMA-GARCH in R Obtaining accurate point forecasts for financial time series is notoriously hard. That has to do with the nature of the financial markets; actors look for opportunities to exploit any predictability, and they remove it while they are doing it (change in expected profitability of an asset $\rightarrow$ change in supply/demand $\rightarrow$ change in asset price). This happens very quickly in active markets, so that the predictability does not persist long enough for models to capture it. Thus financial time series often behave like random walks with some heteroskedasticity. Meanwhile, volatility of financial time series is easier to predict as apparently there is no market mechanism to remove the predictability. That is why your GARCH forecasts of volatility seem to work rather well. But you should note that graphs of fitted volatility vs. realized squared returns can be somewhat misleading. Leaving aside the fact that squared returns are only a noisy proxy of realized volatility, there is another thing: our eyes are easily tricked by graphs like the first one in your post. When it comes to goodness of fit, our eyes pay attention not only to to the vertical distance between fitted and realized values, which is what matters, but also to horizontal distance. So instead of graphing fitted. vs. realized values (two lines), it is helpful to graph just the difference between the two (one line). You might be surprised to discover that differences which appear small from the first type of graph are not that small when depicted in the second type of graph. This is because the fitted volatility from GARCH typically lags the realized volatility by one period. If a time series has many data points, this lag (the horizontal difference) is visually small and can hardly be noticed, so the fit looks better than it actually is.
Forecasting time series using ARMA-GARCH in R Obtaining accurate point forecasts for financial time series is notoriously hard. That has to do with the nature of the financial markets; actors look for opportunities to exploit any predictability,
40,639
Time series data with seasonality using VAR?
VAR models are routinely used with seasonal data, e.g. in macroeconomics where most of the time series (such as GDP or unemployment) are seasonal. Seasonality is handled either (1) outside of the model (by seasonally adjusting the series before fitting a VAR model) or (2) within the model (by including seasonal dummy variables, for example). For (1), seasonal decomposition can be performed by function stl, decompose (as mentioned in another answer by @GD_N) or by fitting a univariate SARIMA model or an ARIMA model with seasonal dummies or Fourier terms - but there are other options, too. For (2), seasonal dummies can be included as exogenous regressors or via the optional argument season in the vars::VAR function in R (scroll down in the package manual for details).
Time series data with seasonality using VAR?
VAR models are routinely used with seasonal data, e.g. in macroeconomics where most of the time series (such as GDP or unemployment) are seasonal. Seasonality is handled either (1) outside of the mode
Time series data with seasonality using VAR? VAR models are routinely used with seasonal data, e.g. in macroeconomics where most of the time series (such as GDP or unemployment) are seasonal. Seasonality is handled either (1) outside of the model (by seasonally adjusting the series before fitting a VAR model) or (2) within the model (by including seasonal dummy variables, for example). For (1), seasonal decomposition can be performed by function stl, decompose (as mentioned in another answer by @GD_N) or by fitting a univariate SARIMA model or an ARIMA model with seasonal dummies or Fourier terms - but there are other options, too. For (2), seasonal dummies can be included as exogenous regressors or via the optional argument season in the vars::VAR function in R (scroll down in the package manual for details).
Time series data with seasonality using VAR? VAR models are routinely used with seasonal data, e.g. in macroeconomics where most of the time series (such as GDP or unemployment) are seasonal. Seasonality is handled either (1) outside of the mode
40,640
Time series data with seasonality using VAR?
Let me explain you in steps on removing seasonality: Detect the trend: first find if the time series is additive or multiplicative Detrend the time series: this will expose seasonality. Average seasonality: from the detrend time series, it’s easy to compute the average seasonality. We add the seasonality together and divide by the number of seasonality. If you are using R, there are two functions, decompose and stl, which help you do the above said. Often, the decomposition is used to removes the seasonal effect from a time series. It provided a cleaner way to understand the trend. Note 1: you can use the autocorrelation function to identify the seasonality (weekly, monthly, quarterly, half-yearly or yearly) Note 2: SARMA handles seasonality, read on it too.
Time series data with seasonality using VAR?
Let me explain you in steps on removing seasonality: Detect the trend: first find if the time series is additive or multiplicative Detrend the time series: this will expose seasonality. Average seaso
Time series data with seasonality using VAR? Let me explain you in steps on removing seasonality: Detect the trend: first find if the time series is additive or multiplicative Detrend the time series: this will expose seasonality. Average seasonality: from the detrend time series, it’s easy to compute the average seasonality. We add the seasonality together and divide by the number of seasonality. If you are using R, there are two functions, decompose and stl, which help you do the above said. Often, the decomposition is used to removes the seasonal effect from a time series. It provided a cleaner way to understand the trend. Note 1: you can use the autocorrelation function to identify the seasonality (weekly, monthly, quarterly, half-yearly or yearly) Note 2: SARMA handles seasonality, read on it too.
Time series data with seasonality using VAR? Let me explain you in steps on removing seasonality: Detect the trend: first find if the time series is additive or multiplicative Detrend the time series: this will expose seasonality. Average seaso
40,641
Multiple Regression - Testing for multicollinearity
I don't think it matters much. Checking it later will save you unnecessary work and agitation at needless transformations that might prove pointless if the variables won't be in the final model. That being said, checking vif(model) is not time consuming, and you can always wait with the application of solutions to potential multicollinearity until later. The problem of multicollinearity is that it can distort the affected coefficients, change their signs and their significance. The 'good' thing (should say convenient) about multicollinearity it is that it affects only the collinear variables - yet does not affect he rest of the variables. This means that if collinear it's only exists on control variables, it often OK to disregard it. You can check, see if it's on controls. If it is, optimize and leave it. If on main explanatory variables, deal now before optimizing (a common way is centering - which can be done using scale(var_to_scale, scale = FALSE) Edit: the answer by @user3640761 rises a valid suggestion, that you check for high correlations in your data before doing anything else. It's easy, fast, and can give a good indication.
Multiple Regression - Testing for multicollinearity
I don't think it matters much. Checking it later will save you unnecessary work and agitation at needless transformations that might prove pointless if the variables won't be in the final model. That
Multiple Regression - Testing for multicollinearity I don't think it matters much. Checking it later will save you unnecessary work and agitation at needless transformations that might prove pointless if the variables won't be in the final model. That being said, checking vif(model) is not time consuming, and you can always wait with the application of solutions to potential multicollinearity until later. The problem of multicollinearity is that it can distort the affected coefficients, change their signs and their significance. The 'good' thing (should say convenient) about multicollinearity it is that it affects only the collinear variables - yet does not affect he rest of the variables. This means that if collinear it's only exists on control variables, it often OK to disregard it. You can check, see if it's on controls. If it is, optimize and leave it. If on main explanatory variables, deal now before optimizing (a common way is centering - which can be done using scale(var_to_scale, scale = FALSE) Edit: the answer by @user3640761 rises a valid suggestion, that you check for high correlations in your data before doing anything else. It's easy, fast, and can give a good indication.
Multiple Regression - Testing for multicollinearity I don't think it matters much. Checking it later will save you unnecessary work and agitation at needless transformations that might prove pointless if the variables won't be in the final model. That
40,642
Multiple Regression - Testing for multicollinearity
I'm perhaps the last person to answer this question, but what would be the disadvantage of running a correlation analysis before the regression just to get an insight to the data and then think if the multicollinearity affect the model prediction?
Multiple Regression - Testing for multicollinearity
I'm perhaps the last person to answer this question, but what would be the disadvantage of running a correlation analysis before the regression just to get an insight to the data and then think if the
Multiple Regression - Testing for multicollinearity I'm perhaps the last person to answer this question, but what would be the disadvantage of running a correlation analysis before the regression just to get an insight to the data and then think if the multicollinearity affect the model prediction?
Multiple Regression - Testing for multicollinearity I'm perhaps the last person to answer this question, but what would be the disadvantage of running a correlation analysis before the regression just to get an insight to the data and then think if the
40,643
Multiple Regression - Testing for multicollinearity
The question is about "testing" for multicollinearity. I'd argue it's not possible because multicollinearity is a characteristic of the sample not the population. Reference: http://davegiles.blogspot.com.au/2013/06/can-you-actually-test-for.html The answers given by @Yuval and @user3640761 give useful diagnostics, but they are not statistical tests. That's my answer: You may use VIF or pairwise correlation (e.g. scatterplot matrix) to check multicollinearity, but you can't test it.
Multiple Regression - Testing for multicollinearity
The question is about "testing" for multicollinearity. I'd argue it's not possible because multicollinearity is a characteristic of the sample not the population. Reference: http://davegiles.blogspot
Multiple Regression - Testing for multicollinearity The question is about "testing" for multicollinearity. I'd argue it's not possible because multicollinearity is a characteristic of the sample not the population. Reference: http://davegiles.blogspot.com.au/2013/06/can-you-actually-test-for.html The answers given by @Yuval and @user3640761 give useful diagnostics, but they are not statistical tests. That's my answer: You may use VIF or pairwise correlation (e.g. scatterplot matrix) to check multicollinearity, but you can't test it.
Multiple Regression - Testing for multicollinearity The question is about "testing" for multicollinearity. I'd argue it's not possible because multicollinearity is a characteristic of the sample not the population. Reference: http://davegiles.blogspot
40,644
Bayesian recurrent neural network with keras and pymc3/edward
From a pure implementation perspective, it should be straightforward: take your model code, replace every trainable Variable creation with ed.Normal(...) or sth similar, establish variational posteriors as well, zip them in a dict, feed it to some inference object from edward et voila. The problem is that variational training of RNNs, since based on sampling, is quite hard. The sampling noise will be of no fun as soon as it is amplified by the recurrent net's dynamics. To my knowledge, there is currently no "gold standard" on how to do this in general. The starting point is probably Alex Graves's paper [1]; some recent work has been done by Yarin Gal [2], where dropout is interpreted as variational inference. It will give you a predictive distribution by integrating out the dropout noise. The latter one will probably be the easiest to get to work, but I have no practical experience myself. [1] Graves, Alex. "Practical variational inference for neural networks." Advances in Neural Information Processing Systems. 2011. [2] Gal, Yarin. "A theoretically grounded application of dropout in recurrent neural networks." arXiv preprint arXiv:1512.05287 (2015).
Bayesian recurrent neural network with keras and pymc3/edward
From a pure implementation perspective, it should be straightforward: take your model code, replace every trainable Variable creation with ed.Normal(...) or sth similar, establish variational posterio
Bayesian recurrent neural network with keras and pymc3/edward From a pure implementation perspective, it should be straightforward: take your model code, replace every trainable Variable creation with ed.Normal(...) or sth similar, establish variational posteriors as well, zip them in a dict, feed it to some inference object from edward et voila. The problem is that variational training of RNNs, since based on sampling, is quite hard. The sampling noise will be of no fun as soon as it is amplified by the recurrent net's dynamics. To my knowledge, there is currently no "gold standard" on how to do this in general. The starting point is probably Alex Graves's paper [1]; some recent work has been done by Yarin Gal [2], where dropout is interpreted as variational inference. It will give you a predictive distribution by integrating out the dropout noise. The latter one will probably be the easiest to get to work, but I have no practical experience myself. [1] Graves, Alex. "Practical variational inference for neural networks." Advances in Neural Information Processing Systems. 2011. [2] Gal, Yarin. "A theoretically grounded application of dropout in recurrent neural networks." arXiv preprint arXiv:1512.05287 (2015).
Bayesian recurrent neural network with keras and pymc3/edward From a pure implementation perspective, it should be straightforward: take your model code, replace every trainable Variable creation with ed.Normal(...) or sth similar, establish variational posterio
40,645
Bayesian recurrent neural network with keras and pymc3/edward
Meanwhile, other papers related to Bayesian RNNs have been published. For example, Bayesian Recurrent Neural Networks and Bayesian Recurrent Neural Network Models for Forecasting and Quantifying Uncertainty in Spatial-Temporal Data.
Bayesian recurrent neural network with keras and pymc3/edward
Meanwhile, other papers related to Bayesian RNNs have been published. For example, Bayesian Recurrent Neural Networks and Bayesian Recurrent Neural Network Models for Forecasting and Quantifying Uncer
Bayesian recurrent neural network with keras and pymc3/edward Meanwhile, other papers related to Bayesian RNNs have been published. For example, Bayesian Recurrent Neural Networks and Bayesian Recurrent Neural Network Models for Forecasting and Quantifying Uncertainty in Spatial-Temporal Data.
Bayesian recurrent neural network with keras and pymc3/edward Meanwhile, other papers related to Bayesian RNNs have been published. For example, Bayesian Recurrent Neural Networks and Bayesian Recurrent Neural Network Models for Forecasting and Quantifying Uncer
40,646
Use BIC or AIC as approximation for Bayesian Model Averaging [duplicate]
I don't understand the first sentence very well, but if your asking whether you should use BIC or AIC to approximate BMA than the answer is fairly straightforward. You would use BIC rather than AIC to approximate posterior model probabilities which can then be used as weights in BMA. Given a set of models $M_1,M_2,…,M_n$ and respective BIC scores $B_1,B_2,…,B_n$, the posterior probability for model $j \in \{1,2,...,n\}$ can be approximated as; $$ Pr(M_j|D) \approx \frac{\exp\bigg(\frac{\mathrm{B_j}}{-2}\bigg)}{\sum_{i=1}^n \exp\bigg(\frac{\mathrm{B_i}}{-2}\bigg)} $$ Where $D$ is "the data". I briefly touch on why this is the case here. You can also see a good reference here, or take a look at the original paper where BIC is derived (Schwarz, 1978) which inevitably leads to this result. The posterior probabilities $Pr(M_j|D)$ are used as weights in BMA, and it should be obvious that $\sum_{j=1}^n Pr(M_j|D) = 1$. If you plan to do this in real life, I would advise using Bayes factors to avoid computational difficulties (overflow/underflow). In this case you would choose one BIC value, say the lowest one, which we will denote as $B_{*}$ then letting $\Delta_i=B_i-B_{*}$ calculate; $$ Pr(M_j|D) \approx \frac{\exp\bigg(\frac{\Delta_j}{-2}\bigg)}{\sum_{i=1}^n \exp\bigg(\frac{\Delta_i}{-2}\bigg)} $$ This helps avoid issues of getting extremely large/small positive numbers when exponentiating the BIC values. Schwarz, G. (1978). Estimating the dimension of a model. The annals of statistics, 6(2), 461-464.
Use BIC or AIC as approximation for Bayesian Model Averaging [duplicate]
I don't understand the first sentence very well, but if your asking whether you should use BIC or AIC to approximate BMA than the answer is fairly straightforward. You would use BIC rather than AIC to
Use BIC or AIC as approximation for Bayesian Model Averaging [duplicate] I don't understand the first sentence very well, but if your asking whether you should use BIC or AIC to approximate BMA than the answer is fairly straightforward. You would use BIC rather than AIC to approximate posterior model probabilities which can then be used as weights in BMA. Given a set of models $M_1,M_2,…,M_n$ and respective BIC scores $B_1,B_2,…,B_n$, the posterior probability for model $j \in \{1,2,...,n\}$ can be approximated as; $$ Pr(M_j|D) \approx \frac{\exp\bigg(\frac{\mathrm{B_j}}{-2}\bigg)}{\sum_{i=1}^n \exp\bigg(\frac{\mathrm{B_i}}{-2}\bigg)} $$ Where $D$ is "the data". I briefly touch on why this is the case here. You can also see a good reference here, or take a look at the original paper where BIC is derived (Schwarz, 1978) which inevitably leads to this result. The posterior probabilities $Pr(M_j|D)$ are used as weights in BMA, and it should be obvious that $\sum_{j=1}^n Pr(M_j|D) = 1$. If you plan to do this in real life, I would advise using Bayes factors to avoid computational difficulties (overflow/underflow). In this case you would choose one BIC value, say the lowest one, which we will denote as $B_{*}$ then letting $\Delta_i=B_i-B_{*}$ calculate; $$ Pr(M_j|D) \approx \frac{\exp\bigg(\frac{\Delta_j}{-2}\bigg)}{\sum_{i=1}^n \exp\bigg(\frac{\Delta_i}{-2}\bigg)} $$ This helps avoid issues of getting extremely large/small positive numbers when exponentiating the BIC values. Schwarz, G. (1978). Estimating the dimension of a model. The annals of statistics, 6(2), 461-464.
Use BIC or AIC as approximation for Bayesian Model Averaging [duplicate] I don't understand the first sentence very well, but if your asking whether you should use BIC or AIC to approximate BMA than the answer is fairly straightforward. You would use BIC rather than AIC to
40,647
How can endogeneity arise in OLS estimation?
from my point of view this problem stems from the fact that OLS models a linear projection $L(Y|X)=X\beta$ that is defined such that we always have $(Y-L(Y|X))⊥X$ but it does not hold in general that $L(Y|X)=X\beta=E[Y|X]$. As a example assume that $Y=X+X^2+e$ and $E[Y|X]=X+X^2$, if we now do not account for the squared term, i.e. estimate a linear projection $L(Y|X)=X\beta$ we effectively say $Y=X+\epsilon$ and $\epsilon=X^2+e$. Or in other words, we put the $X^2$ in the error term. By the basic calculation rules of random variables (and assuming that $e\sim iid(0,\sigma)$) it holds that $$Cov(\epsilon,X)=Cov(X^2+e,X)=Cov(X^2,X)=0$$ but clearly $$E[\epsilon|X]=E[X^2|X]\neq 0$$ Therefore, your suspicion of non-linear effects is quite right, but the more deep reason is that modelling via OLS is not necessarily the same as modelling the conditional expectation. But more broadly speacking, enogeneity in general can have three reasons (as shown in standard textbooks like Wooldridges "Econometric analysis of cross section and panel data"). Classical is the omitted variable problem that stems from the confusion of the error term of the OLS estimator and the error term of the "real" model. Second is the measurement error problem where we control for all relevant covariates but some of the error in the measurement of them goes into the error term and third is the problem of Simulateneity. Therefore, I would say that your remarki that "endogeneity [can] be thought of as another manifestation of omitted variable problem" is correct. However, endogeneity must not necessarily stem from a omitted variable but can also have other sources. I would clearly refer to the book of Wooldridge, especially Chap. 2 for the concepts of the conditional expectation (what we want to estimate) and linear projection (what we have at hand if we use OLS) and Chap. 4 for the problem of endogeneity and its sources.
How can endogeneity arise in OLS estimation?
from my point of view this problem stems from the fact that OLS models a linear projection $L(Y|X)=X\beta$ that is defined such that we always have $(Y-L(Y|X))⊥X$ but it does not hold in general that
How can endogeneity arise in OLS estimation? from my point of view this problem stems from the fact that OLS models a linear projection $L(Y|X)=X\beta$ that is defined such that we always have $(Y-L(Y|X))⊥X$ but it does not hold in general that $L(Y|X)=X\beta=E[Y|X]$. As a example assume that $Y=X+X^2+e$ and $E[Y|X]=X+X^2$, if we now do not account for the squared term, i.e. estimate a linear projection $L(Y|X)=X\beta$ we effectively say $Y=X+\epsilon$ and $\epsilon=X^2+e$. Or in other words, we put the $X^2$ in the error term. By the basic calculation rules of random variables (and assuming that $e\sim iid(0,\sigma)$) it holds that $$Cov(\epsilon,X)=Cov(X^2+e,X)=Cov(X^2,X)=0$$ but clearly $$E[\epsilon|X]=E[X^2|X]\neq 0$$ Therefore, your suspicion of non-linear effects is quite right, but the more deep reason is that modelling via OLS is not necessarily the same as modelling the conditional expectation. But more broadly speacking, enogeneity in general can have three reasons (as shown in standard textbooks like Wooldridges "Econometric analysis of cross section and panel data"). Classical is the omitted variable problem that stems from the confusion of the error term of the OLS estimator and the error term of the "real" model. Second is the measurement error problem where we control for all relevant covariates but some of the error in the measurement of them goes into the error term and third is the problem of Simulateneity. Therefore, I would say that your remarki that "endogeneity [can] be thought of as another manifestation of omitted variable problem" is correct. However, endogeneity must not necessarily stem from a omitted variable but can also have other sources. I would clearly refer to the book of Wooldridge, especially Chap. 2 for the concepts of the conditional expectation (what we want to estimate) and linear projection (what we have at hand if we use OLS) and Chap. 4 for the problem of endogeneity and its sources.
How can endogeneity arise in OLS estimation? from my point of view this problem stems from the fact that OLS models a linear projection $L(Y|X)=X\beta$ that is defined such that we always have $(Y-L(Y|X))⊥X$ but it does not hold in general that
40,648
Practical description of LOESS and smoothing splines?
[In the later discussion of LOESS here I attempt to describe LOWESS and its implementation in the R function lowess as well as outline some of the modifications made for the function loess (though some details that don't seem to be directly relevant to your questions are omitted).] In particular: with smoothing splines, how do we choose the number and location of breakpoints You don't; there's one at every data point; the smoothing parameter is the source of all the regularization. If you want fewer knots, you're talking about penalized splines. as well as the polynomial degree of the spline? With smooth.spline it's always cubic, it says so right in the help. If you mean the degree of local fit in LOESS (which is not a spline) first see Cleveland [1] (which describes LOWESS, on which LOESS is based) -- it pretty much suggests that 0 isn't flexible enough ("*in the practical situation, an assumption of local linearity serves better than local constancy") and 2 is harder to compute, relative to a smaller gain in flexibility, and it suggests choosing the degree to be 1 as the best compromise in practice. The suggestions in Cleveland [1] (more details about choosing the various parameters are given in the paper) are the defaults in the R function lowess (such as degree 1 and span 2/3). The help on 'loess' says it uses different defaults (degree is 2 and span is 3/4). And what do the bandwidth arguments control in the function? As it is described by Bill Cleveland[1], LOESS applies a tricube weight function ($W(x)=((1-|x|^3)_+)^3$) to locally weight the points. $W$ is scaled so that the $r$-th nearest neighbor is the first to get zero weight, where $r = \text{round}(fn)$ and $f$ is the span argument. If there are multiple predictors this is modified (see the help on loess). The loess function allows you to specify a target number-of-parameters equivalent instead of the span. Also how does LOESS select outliers for removal? Again, as described by in Cleveland[1], LOWESS downweights observations with large residuals rather than specifically select and remove them. However, some observations may get zero weight, which means some are effectively removed. Specifically, after an initial fit LOWESS introduces robustness weights based on the residuals from the initial fit. The robustness weights use a biweight function ($B(x)=((1-x^2)_+)^2$); any observation with an absolute residual more than six times the median absolute residual will have zero weight, but points closer than that will still have reduced weight; for example, a point with absolute residual 3.25 times the median absolute residual will have about half weight. This downweighting process is iterated (that is, residuals are recalculated from a fit using these weights, and the robustness weights recalculated in turn, until convergence). Note that both $W$ and $B$ can downweight a given observation. The help for the implementation of loess refers to redescending M-estimation using a biweight function, but that is presumably just being used as a brief way of describing the above scheme rather than doing anything different. [1] Cleveland, William S. (1979). "Robust Locally Weighted Regression and Smoothing Scatterplots". Journal of the American Statistical Association. 74 (368): 829–836.
Practical description of LOESS and smoothing splines?
[In the later discussion of LOESS here I attempt to describe LOWESS and its implementation in the R function lowess as well as outline some of the modifications made for the function loess (though som
Practical description of LOESS and smoothing splines? [In the later discussion of LOESS here I attempt to describe LOWESS and its implementation in the R function lowess as well as outline some of the modifications made for the function loess (though some details that don't seem to be directly relevant to your questions are omitted).] In particular: with smoothing splines, how do we choose the number and location of breakpoints You don't; there's one at every data point; the smoothing parameter is the source of all the regularization. If you want fewer knots, you're talking about penalized splines. as well as the polynomial degree of the spline? With smooth.spline it's always cubic, it says so right in the help. If you mean the degree of local fit in LOESS (which is not a spline) first see Cleveland [1] (which describes LOWESS, on which LOESS is based) -- it pretty much suggests that 0 isn't flexible enough ("*in the practical situation, an assumption of local linearity serves better than local constancy") and 2 is harder to compute, relative to a smaller gain in flexibility, and it suggests choosing the degree to be 1 as the best compromise in practice. The suggestions in Cleveland [1] (more details about choosing the various parameters are given in the paper) are the defaults in the R function lowess (such as degree 1 and span 2/3). The help on 'loess' says it uses different defaults (degree is 2 and span is 3/4). And what do the bandwidth arguments control in the function? As it is described by Bill Cleveland[1], LOESS applies a tricube weight function ($W(x)=((1-|x|^3)_+)^3$) to locally weight the points. $W$ is scaled so that the $r$-th nearest neighbor is the first to get zero weight, where $r = \text{round}(fn)$ and $f$ is the span argument. If there are multiple predictors this is modified (see the help on loess). The loess function allows you to specify a target number-of-parameters equivalent instead of the span. Also how does LOESS select outliers for removal? Again, as described by in Cleveland[1], LOWESS downweights observations with large residuals rather than specifically select and remove them. However, some observations may get zero weight, which means some are effectively removed. Specifically, after an initial fit LOWESS introduces robustness weights based on the residuals from the initial fit. The robustness weights use a biweight function ($B(x)=((1-x^2)_+)^2$); any observation with an absolute residual more than six times the median absolute residual will have zero weight, but points closer than that will still have reduced weight; for example, a point with absolute residual 3.25 times the median absolute residual will have about half weight. This downweighting process is iterated (that is, residuals are recalculated from a fit using these weights, and the robustness weights recalculated in turn, until convergence). Note that both $W$ and $B$ can downweight a given observation. The help for the implementation of loess refers to redescending M-estimation using a biweight function, but that is presumably just being used as a brief way of describing the above scheme rather than doing anything different. [1] Cleveland, William S. (1979). "Robust Locally Weighted Regression and Smoothing Scatterplots". Journal of the American Statistical Association. 74 (368): 829–836.
Practical description of LOESS and smoothing splines? [In the later discussion of LOESS here I attempt to describe LOWESS and its implementation in the R function lowess as well as outline some of the modifications made for the function loess (though som
40,649
How to threshold multiclass probability prediction to get confusion matrix?
According to @cangrejo's answer: https://stats.stackexchange.com/a/310956/194535, suppose the original output probability of your model is the vector $v$, and then you can define the prior distribution: $\pi=(\frac{1}{\theta_1}, \frac{1}{\theta_2},..., \frac{1}{\theta_N})$, for $\theta_i \in (0,1)$ and $\sum_i\theta_i = 1$, where $N$ is the total number of labeled classes, $i$ is the class index. Take $v' = v \odot \pi$ as the new output probability of your model, where $\odot$ denotes an element-wise product. Now, your question can be reformulate to this: Finding the $\pi$ which optimize the metrics you have specified (eg. roc_auc_score) from the new output probability model. Once you find it, the $\theta s (\theta_1, \theta_2, ..., \theta_N)$ is your optimal threshold for each classes. The Code part: Create a proxyModel class which takes your original model object as an argument and return a proxyModel object. When you called predict_proba() through the proxyModel object, it will calculate new probability automatically based on the threshold you specified: class proxyModel(): def __init__(self, origin_model): self.origin_model = origin_model def predict_proba(self, x, threshold_list=None): # get origin probability ori_proba = self.origin_model.predict_proba(x) # set default threshold if threshold_list is None: threshold_list = np.full(ori_proba[0].shape, 1) # get the output shape of threshold_list output_shape = np.array(threshold_list).shape # element-wise divide by the threshold of each classes new_proba = np.divide(ori_proba, threshold_list) # calculate the norm (sum of new probability of each classes) norm = np.linalg.norm(new_proba, ord=1, axis=1) # reshape the norm norm = np.broadcast_to(np.array([norm]).T, (norm.shape[0],output_shape[0])) # renormalize the new probability new_proba = np.divide(new_proba, norm) return new_proba def predict(self, x, threshold_list=None): return np.argmax(self.predict_proba(x, threshold_list), axis=1) Implement a score function: def scoreFunc(model, X, y_true, threshold_list): y_pred = model.predict(X, threshold_list=threshold_list) y_pred_proba = model.predict_proba(X, threshold_list=threshold_list) ###### metrics ###### from sklearn.metrics import accuracy_score from sklearn.metrics import roc_auc_score from sklearn.metrics import average_precision_score from sklearn.metrics import f1_score accuracy = accuracy_score(y_true, y_pred) roc_auc = roc_auc_score(y_true, y_pred_proba, average='macro') pr_auc = average_precision_score(y_true, y_pred_proba, average='macro') f1_value = f1_score(y_true, y_pred, average='macro') return accuracy, roc_auc, pr_auc, f1_value Define weighted_score_with_threshold() function, which takes the threshold as input and return weighted score: def weighted_score_with_threshold(threshold, model, X_test, Y_test, metrics='accuracy', delta=5e-5): # if the sum of thresholds were not between 1+delta and 1-delta, # return infinity (just for reduce the search space of the minimizaiton algorithm, # because the sum of thresholds should be as close to 1 as possible). threshold_sum = np.sum(threshold) if threshold_sum > 1+delta: return np.inf if threshold_sum < 1-delta: return np.inf # to avoid objective function jump into nan solution if np.isnan(threshold_sum): print("threshold_sum is nan") return np.inf # renormalize: the sum of threshold should be 1 normalized_threshold = threshold/threshold_sum # calculate scores based on thresholds # suppose it'll return 4 scores in a tuple: (accuracy, roc_auc, pr_auc, f1) scores = scoreFunc(model, X_test, Y_test, threshold_list=normalized_threshold) scores = np.array(scores) weight = np.array([1,1,1,1]) # Give the metric you want to maximize a bigger weight: if metrics == 'accuracy': weight = np.array([10,1,1,1]) elif metrics == 'roc_auc': weight = np.array([1,10,1,1]) elif metrics == 'pr_auc': weight = np.array([1,1,10,1]) elif metrics == 'f1': weight = np.array([1,1,1,10]) elif 'all': weight = np.array([1,1,1,1]) # return negatitive weighted sum (because you want to maximize the sum, # it's equivalent to minimize the negative sum) return -np.dot(weight, scores) Use optimize algorithm differential_evolution() (better then fmin) to find the optimal threshold: from scipy import optimize output_class_num = Y_test.shape[1] bounds = optimize.Bounds([1e-5]*output_class_num,[1]*output_class_num) pmodel = proxyModel(model) result = optimize.differential_evolution(weighted_score_with_threshold, bounds, args=(pmodel, X_test, Y_test, 'accuracy')) # calculate threshold threshold = result.x/np.sum(result.x) # print the optimized score print(scoreFunc(model, X_test, Y_test, threshold_list=threshold))
How to threshold multiclass probability prediction to get confusion matrix?
According to @cangrejo's answer: https://stats.stackexchange.com/a/310956/194535, suppose the original output probability of your model is the vector $v$, and then you can define the prior distributio
How to threshold multiclass probability prediction to get confusion matrix? According to @cangrejo's answer: https://stats.stackexchange.com/a/310956/194535, suppose the original output probability of your model is the vector $v$, and then you can define the prior distribution: $\pi=(\frac{1}{\theta_1}, \frac{1}{\theta_2},..., \frac{1}{\theta_N})$, for $\theta_i \in (0,1)$ and $\sum_i\theta_i = 1$, where $N$ is the total number of labeled classes, $i$ is the class index. Take $v' = v \odot \pi$ as the new output probability of your model, where $\odot$ denotes an element-wise product. Now, your question can be reformulate to this: Finding the $\pi$ which optimize the metrics you have specified (eg. roc_auc_score) from the new output probability model. Once you find it, the $\theta s (\theta_1, \theta_2, ..., \theta_N)$ is your optimal threshold for each classes. The Code part: Create a proxyModel class which takes your original model object as an argument and return a proxyModel object. When you called predict_proba() through the proxyModel object, it will calculate new probability automatically based on the threshold you specified: class proxyModel(): def __init__(self, origin_model): self.origin_model = origin_model def predict_proba(self, x, threshold_list=None): # get origin probability ori_proba = self.origin_model.predict_proba(x) # set default threshold if threshold_list is None: threshold_list = np.full(ori_proba[0].shape, 1) # get the output shape of threshold_list output_shape = np.array(threshold_list).shape # element-wise divide by the threshold of each classes new_proba = np.divide(ori_proba, threshold_list) # calculate the norm (sum of new probability of each classes) norm = np.linalg.norm(new_proba, ord=1, axis=1) # reshape the norm norm = np.broadcast_to(np.array([norm]).T, (norm.shape[0],output_shape[0])) # renormalize the new probability new_proba = np.divide(new_proba, norm) return new_proba def predict(self, x, threshold_list=None): return np.argmax(self.predict_proba(x, threshold_list), axis=1) Implement a score function: def scoreFunc(model, X, y_true, threshold_list): y_pred = model.predict(X, threshold_list=threshold_list) y_pred_proba = model.predict_proba(X, threshold_list=threshold_list) ###### metrics ###### from sklearn.metrics import accuracy_score from sklearn.metrics import roc_auc_score from sklearn.metrics import average_precision_score from sklearn.metrics import f1_score accuracy = accuracy_score(y_true, y_pred) roc_auc = roc_auc_score(y_true, y_pred_proba, average='macro') pr_auc = average_precision_score(y_true, y_pred_proba, average='macro') f1_value = f1_score(y_true, y_pred, average='macro') return accuracy, roc_auc, pr_auc, f1_value Define weighted_score_with_threshold() function, which takes the threshold as input and return weighted score: def weighted_score_with_threshold(threshold, model, X_test, Y_test, metrics='accuracy', delta=5e-5): # if the sum of thresholds were not between 1+delta and 1-delta, # return infinity (just for reduce the search space of the minimizaiton algorithm, # because the sum of thresholds should be as close to 1 as possible). threshold_sum = np.sum(threshold) if threshold_sum > 1+delta: return np.inf if threshold_sum < 1-delta: return np.inf # to avoid objective function jump into nan solution if np.isnan(threshold_sum): print("threshold_sum is nan") return np.inf # renormalize: the sum of threshold should be 1 normalized_threshold = threshold/threshold_sum # calculate scores based on thresholds # suppose it'll return 4 scores in a tuple: (accuracy, roc_auc, pr_auc, f1) scores = scoreFunc(model, X_test, Y_test, threshold_list=normalized_threshold) scores = np.array(scores) weight = np.array([1,1,1,1]) # Give the metric you want to maximize a bigger weight: if metrics == 'accuracy': weight = np.array([10,1,1,1]) elif metrics == 'roc_auc': weight = np.array([1,10,1,1]) elif metrics == 'pr_auc': weight = np.array([1,1,10,1]) elif metrics == 'f1': weight = np.array([1,1,1,10]) elif 'all': weight = np.array([1,1,1,1]) # return negatitive weighted sum (because you want to maximize the sum, # it's equivalent to minimize the negative sum) return -np.dot(weight, scores) Use optimize algorithm differential_evolution() (better then fmin) to find the optimal threshold: from scipy import optimize output_class_num = Y_test.shape[1] bounds = optimize.Bounds([1e-5]*output_class_num,[1]*output_class_num) pmodel = proxyModel(model) result = optimize.differential_evolution(weighted_score_with_threshold, bounds, args=(pmodel, X_test, Y_test, 'accuracy')) # calculate threshold threshold = result.x/np.sum(result.x) # print the optimized score print(scoreFunc(model, X_test, Y_test, threshold_list=threshold))
How to threshold multiclass probability prediction to get confusion matrix? According to @cangrejo's answer: https://stats.stackexchange.com/a/310956/194535, suppose the original output probability of your model is the vector $v$, and then you can define the prior distributio
40,650
How to threshold multiclass probability prediction to get confusion matrix?
This was helpful, thanks! But it is not applicable during model training. When it comes to using this method after training the model (after finding the hyperparameters relevant to the model), it's valid; only that there has to be some way of standardizing this to avoid loss of generality and for it to be applicable on test data.
How to threshold multiclass probability prediction to get confusion matrix?
This was helpful, thanks! But it is not applicable during model training. When it comes to using this method after training the model (after finding the hyperparameters relevant to the model), it's va
How to threshold multiclass probability prediction to get confusion matrix? This was helpful, thanks! But it is not applicable during model training. When it comes to using this method after training the model (after finding the hyperparameters relevant to the model), it's valid; only that there has to be some way of standardizing this to avoid loss of generality and for it to be applicable on test data.
How to threshold multiclass probability prediction to get confusion matrix? This was helpful, thanks! But it is not applicable during model training. When it comes to using this method after training the model (after finding the hyperparameters relevant to the model), it's va
40,651
Is the Shapiro-Wilk test only applicable to smaller sample sizes?
The Shapiro Wilk test applies at any sample size above $n=2$ (it can't work at $n=1$ or $n=2$). However, implementations of the test will generally not cover the very largest sample sizes (such as $n>5000$ -- though if you're using tables rather than a computer to do the test the tables might only go up to say $n=50$ or something like that). Such upper limits are for a technical reason to do with the implementation of the test -- specifically the need to obtain a list of constants for each sample size that increases in size with $n$, not because the test itself is in any way unsuitable at very large sample sizes. In principle you could implement it for n=100 million if you wanted to be able to do that. There is no particular distinction between $n>30$ and $n\leq 30$ (any more than there is at any other intermediate sample size). At very large sample sizes, sometimes people who would like to do a Shapiro-Wilk test will substitute the closely related Shapiro-Francia test for the Shapiro-Wilk (which corresponds to looking at the squared correlation in a Q-Q plot of normality), though at very large sample sizes there's rarely any point in goodness of fit tests anyway (testing random number generators is a plausible application, but outside of that it seems likely to be an unproductive activity).
Is the Shapiro-Wilk test only applicable to smaller sample sizes?
The Shapiro Wilk test applies at any sample size above $n=2$ (it can't work at $n=1$ or $n=2$). However, implementations of the test will generally not cover the very largest sample sizes (such as $n
Is the Shapiro-Wilk test only applicable to smaller sample sizes? The Shapiro Wilk test applies at any sample size above $n=2$ (it can't work at $n=1$ or $n=2$). However, implementations of the test will generally not cover the very largest sample sizes (such as $n>5000$ -- though if you're using tables rather than a computer to do the test the tables might only go up to say $n=50$ or something like that). Such upper limits are for a technical reason to do with the implementation of the test -- specifically the need to obtain a list of constants for each sample size that increases in size with $n$, not because the test itself is in any way unsuitable at very large sample sizes. In principle you could implement it for n=100 million if you wanted to be able to do that. There is no particular distinction between $n>30$ and $n\leq 30$ (any more than there is at any other intermediate sample size). At very large sample sizes, sometimes people who would like to do a Shapiro-Wilk test will substitute the closely related Shapiro-Francia test for the Shapiro-Wilk (which corresponds to looking at the squared correlation in a Q-Q plot of normality), though at very large sample sizes there's rarely any point in goodness of fit tests anyway (testing random number generators is a plausible application, but outside of that it seems likely to be an unproductive activity).
Is the Shapiro-Wilk test only applicable to smaller sample sizes? The Shapiro Wilk test applies at any sample size above $n=2$ (it can't work at $n=1$ or $n=2$). However, implementations of the test will generally not cover the very largest sample sizes (such as $n
40,652
Choose probability distribution to maximize evaluation function (for CDC flu forecasting contest)
Cool problem! As Xi'an's derivation shows, it is related to minimizing the KL-divergence from Q to P. Cliff provides some important context as well. The problem can be solved trivially using optimization software, but I don't see a way to write a closed-form formula for the general solution. If $q_i \geq 0 $ never binds, then there is an intuitive formula. Almost certainly optimal $\mathbf{q} \neq \mathbf{p}$ (though see my example graphs at the end, it might be close). And $\max \mathrm{E}[x]$ is not the same problem as $\max \mathrm{E}[\log(x)]$. Observe $x + y$ is not an equivalent objective as $\log(x) + \log(y)$. It's not a monotonic transformation. Expectation is a sum and the log goes inside the sum, so it's not a monotonic transformation of the objective function. KKT conditions (i.e. necessary and sufficient conditions) for a solution: Define $q_0 = 0$ and $q_{n+1} = 0$. The problem is: \begin{equation} \begin{array}{*2{>{\displaystyle}r}} \mbox{maximize (over $q_i$)} & \sum_{i=1}^n p_i \log \left( q_{i-1} + q_i + q_{i+1} \right) \\ \mbox{subject to} & q_i \geq 0 \\ & \sum_{i=1}^n q_i = 1 \end{array} \end{equation} Lagrangian: $$ \mathcal{L} = \sum_i p_i \log \left( q_{i-1} + q_i + q_{i+1} \right) + \sum_i \mu_i q_i -\lambda \left( \sum_i q_i - 1\right) $$ This is a convex optimization problem where Slater's condition holds therefore the KKT conditions are necessary and sufficient conditions for an optimum. First order condition: $$ \frac{p_{i-1}}{q_{i-2} + q_{i-1} + q_{i}} + \frac{p_i}{q_{i-1} + q_i + q_{i+1}} + \frac{p_{i+1}}{q_{i} + q_{i+1} + q_{i+2}} = \lambda - \mu_i $$ Complementary slackness: $$\mu_i q_i = 0 $$ And of course $\mu_i \geq 0$. (It appears from my testing that $\lambda = 1$ but I don't immediately see why.) $\mu_i$ and $\lambda$ are Lagrange multipliers. Solution if $q_i \geq 0$ never binds. Then consider solution $$ p_i = \frac{q_{i-1} + q_i + q_{i+1}}{3} \quad \quad \mu_i = 0 \quad \quad \lambda = 1$$ Plugging into the first order condition, we get $\frac{1}{3} + \frac{1}{3} + \frac{1}{3} = 1$. So it works (as long as $\sum_i q_i = 1$ and $q_i \geq 0$ are also satisfied). How to write the problem with matrices: Let $\mathbf{p}$ and $\mathbf{q}$ be vectors. Let $A$ be a tri-band diagonal matrix of ones. Eg. for $n = 5$ $$A = \left[\begin{array}{ccccc} 1 & 1 & 0 & 0 & 0 \\ 1 & 1 & 1 & 0& 0 \\ 0 & 1 & 1 & 1 & 0 \\0 &0 & 1 & 1&1\\ 0 &0 &0 & 1 & 1 \end{array} \right] $$ Problem can be written with more matrix notation: \begin{equation} \begin{array}{*2{>{\displaystyle}r}} \mbox{maximize (over $\mathbf{q}$)} & \mathbf{p}'\log\left(A \mathbf{q} \right) \\ \mbox{subject to} & q_i \geq 0 \\ & \sum_i q_i = 1 \end{array} \end{equation} This can be solved fast numerically but I don't see a way to a clean closed form solution? Solution is characterized by: $$A\mathbf{y} = \lambda - \mathbf{u} \quad \quad \mathbf{x} = A \mathbf{q} \quad \quad y_i = \frac{p_i}{x_i} $$ but I don't see how that's terribly helpful beyond checking your optimization software. Code to solve it using CVX and MATLAB A = eye(n) + diag(ones(n-1,1),1) + diag(ones(n-1,1),-1); cvx_begin variable q(n) dual variable u; dual variable l; maximize(p'*log(A*q)) subject to: u: q >= 0; l: sum(q) <= 1; cvx_end Eg. inputs: p = 0.0724 0.0383 0.0968 0.1040 0.1384 0.1657 0.0279 0.0856 0.2614 0.0095 has solution: q = 0.0000 0.1929 0.0000 0.0341 0.3886 0.0000 0.0000 0.2865 0.0979 0.0000 Solution I get (blue) when I have a ton of bins basically following normal pdf (red): Another more arbitrary problem: Very loosely, for $p_{i-1} \approx p_i \approx p_{i+1}$ you get $q_i \approx p_i$, but if $p_i$ moves around a ton, you get some tricky stuff going on where the optimization tries to put the mass on $q_i$'s in the neighborhood of $p_i$ mass, strategically placing it between $p_i$'s with mass. Another conceptual point is that uncertainty in your forecast will effectively smooth your estimate of $p$, and a smoother $p$ will have a solution $q$ that's closer to $p$. (I think that's right.)
Choose probability distribution to maximize evaluation function (for CDC flu forecasting contest)
Cool problem! As Xi'an's derivation shows, it is related to minimizing the KL-divergence from Q to P. Cliff provides some important context as well. The problem can be solved trivially using optimizat
Choose probability distribution to maximize evaluation function (for CDC flu forecasting contest) Cool problem! As Xi'an's derivation shows, it is related to minimizing the KL-divergence from Q to P. Cliff provides some important context as well. The problem can be solved trivially using optimization software, but I don't see a way to write a closed-form formula for the general solution. If $q_i \geq 0 $ never binds, then there is an intuitive formula. Almost certainly optimal $\mathbf{q} \neq \mathbf{p}$ (though see my example graphs at the end, it might be close). And $\max \mathrm{E}[x]$ is not the same problem as $\max \mathrm{E}[\log(x)]$. Observe $x + y$ is not an equivalent objective as $\log(x) + \log(y)$. It's not a monotonic transformation. Expectation is a sum and the log goes inside the sum, so it's not a monotonic transformation of the objective function. KKT conditions (i.e. necessary and sufficient conditions) for a solution: Define $q_0 = 0$ and $q_{n+1} = 0$. The problem is: \begin{equation} \begin{array}{*2{>{\displaystyle}r}} \mbox{maximize (over $q_i$)} & \sum_{i=1}^n p_i \log \left( q_{i-1} + q_i + q_{i+1} \right) \\ \mbox{subject to} & q_i \geq 0 \\ & \sum_{i=1}^n q_i = 1 \end{array} \end{equation} Lagrangian: $$ \mathcal{L} = \sum_i p_i \log \left( q_{i-1} + q_i + q_{i+1} \right) + \sum_i \mu_i q_i -\lambda \left( \sum_i q_i - 1\right) $$ This is a convex optimization problem where Slater's condition holds therefore the KKT conditions are necessary and sufficient conditions for an optimum. First order condition: $$ \frac{p_{i-1}}{q_{i-2} + q_{i-1} + q_{i}} + \frac{p_i}{q_{i-1} + q_i + q_{i+1}} + \frac{p_{i+1}}{q_{i} + q_{i+1} + q_{i+2}} = \lambda - \mu_i $$ Complementary slackness: $$\mu_i q_i = 0 $$ And of course $\mu_i \geq 0$. (It appears from my testing that $\lambda = 1$ but I don't immediately see why.) $\mu_i$ and $\lambda$ are Lagrange multipliers. Solution if $q_i \geq 0$ never binds. Then consider solution $$ p_i = \frac{q_{i-1} + q_i + q_{i+1}}{3} \quad \quad \mu_i = 0 \quad \quad \lambda = 1$$ Plugging into the first order condition, we get $\frac{1}{3} + \frac{1}{3} + \frac{1}{3} = 1$. So it works (as long as $\sum_i q_i = 1$ and $q_i \geq 0$ are also satisfied). How to write the problem with matrices: Let $\mathbf{p}$ and $\mathbf{q}$ be vectors. Let $A$ be a tri-band diagonal matrix of ones. Eg. for $n = 5$ $$A = \left[\begin{array}{ccccc} 1 & 1 & 0 & 0 & 0 \\ 1 & 1 & 1 & 0& 0 \\ 0 & 1 & 1 & 1 & 0 \\0 &0 & 1 & 1&1\\ 0 &0 &0 & 1 & 1 \end{array} \right] $$ Problem can be written with more matrix notation: \begin{equation} \begin{array}{*2{>{\displaystyle}r}} \mbox{maximize (over $\mathbf{q}$)} & \mathbf{p}'\log\left(A \mathbf{q} \right) \\ \mbox{subject to} & q_i \geq 0 \\ & \sum_i q_i = 1 \end{array} \end{equation} This can be solved fast numerically but I don't see a way to a clean closed form solution? Solution is characterized by: $$A\mathbf{y} = \lambda - \mathbf{u} \quad \quad \mathbf{x} = A \mathbf{q} \quad \quad y_i = \frac{p_i}{x_i} $$ but I don't see how that's terribly helpful beyond checking your optimization software. Code to solve it using CVX and MATLAB A = eye(n) + diag(ones(n-1,1),1) + diag(ones(n-1,1),-1); cvx_begin variable q(n) dual variable u; dual variable l; maximize(p'*log(A*q)) subject to: u: q >= 0; l: sum(q) <= 1; cvx_end Eg. inputs: p = 0.0724 0.0383 0.0968 0.1040 0.1384 0.1657 0.0279 0.0856 0.2614 0.0095 has solution: q = 0.0000 0.1929 0.0000 0.0341 0.3886 0.0000 0.0000 0.2865 0.0979 0.0000 Solution I get (blue) when I have a ton of bins basically following normal pdf (red): Another more arbitrary problem: Very loosely, for $p_{i-1} \approx p_i \approx p_{i+1}$ you get $q_i \approx p_i$, but if $p_i$ moves around a ton, you get some tricky stuff going on where the optimization tries to put the mass on $q_i$'s in the neighborhood of $p_i$ mass, strategically placing it between $p_i$'s with mass. Another conceptual point is that uncertainty in your forecast will effectively smooth your estimate of $p$, and a smoother $p$ will have a solution $q$ that's closer to $p$. (I think that's right.)
Choose probability distribution to maximize evaluation function (for CDC flu forecasting contest) Cool problem! As Xi'an's derivation shows, it is related to minimizing the KL-divergence from Q to P. Cliff provides some important context as well. The problem can be solved trivially using optimizat
40,653
Choose probability distribution to maximize evaluation function (for CDC flu forecasting contest)
Since $\mathbf{q}=\mathbf{p}$ solves$$\arg\min_\mathbf{q} \sum p_i\log\{ p_i\big/q_i\}$$ what about just solving $$q_{i-1}+q_i+q_{i+1}=3p_i\qquad i=1,\ldots,n-1$$ to find the solution to $$\arg\max_\mathbf{q} \sum p_i\log\{ p_i\big/(q_{i-1}+q_i+q_{i+1})\}$$ If the solution to this system of equations does not belong to the $\mathbb{R}^{n+1}$ simplex then the argument will be found on a face of the simplex.
Choose probability distribution to maximize evaluation function (for CDC flu forecasting contest)
Since $\mathbf{q}=\mathbf{p}$ solves$$\arg\min_\mathbf{q} \sum p_i\log\{ p_i\big/q_i\}$$ what about just solving $$q_{i-1}+q_i+q_{i+1}=3p_i\qquad i=1,\ldots,n-1$$ to find the solution to $$\arg\max_\m
Choose probability distribution to maximize evaluation function (for CDC flu forecasting contest) Since $\mathbf{q}=\mathbf{p}$ solves$$\arg\min_\mathbf{q} \sum p_i\log\{ p_i\big/q_i\}$$ what about just solving $$q_{i-1}+q_i+q_{i+1}=3p_i\qquad i=1,\ldots,n-1$$ to find the solution to $$\arg\max_\mathbf{q} \sum p_i\log\{ p_i\big/(q_{i-1}+q_i+q_{i+1})\}$$ If the solution to this system of equations does not belong to the $\mathbb{R}^{n+1}$ simplex then the argument will be found on a face of the simplex.
Choose probability distribution to maximize evaluation function (for CDC flu forecasting contest) Since $\mathbf{q}=\mathbf{p}$ solves$$\arg\min_\mathbf{q} \sum p_i\log\{ p_i\big/q_i\}$$ what about just solving $$q_{i-1}+q_i+q_{i+1}=3p_i\qquad i=1,\ldots,n-1$$ to find the solution to $$\arg\max_\m
40,654
Choose probability distribution to maximize evaluation function (for CDC flu forecasting contest)
If I understand this correctly, I do not think this will have a closed form solution. Or moreover, it's at least a specialization of a problem that is not in closed form. The reason I say this is that it is exactly the likelihood that appears in the NPMLE for interval censored data, the specialization being that all the intervals are of the form $[X-1, X+1]$. In general, the NPMLE is the maximizer of the function $ \sum_{i = 1}^n \log(P(t_i \in [L_i, R_i]) )$ where $t_i$ is the event time for subject $i$, where all that is known is that the event occurred within the interval $[L_i, R_i]$. This equates to exactly your problem, with $L_i = X_i-1$ and $R_i = X_i + 1$. In general, this is not in closed form. However, at least one special case is; that of current status data, or when all the intervals are of the form $[0, c_i]$ or $[c_i, \infty)$. That being said, there are plenty of algorithms for solving the NPMLE! You can fit that using R's icenReg package with the ic_np function (note: I'm the author). Make sure set the option B = c(1,1), declaring that the intervals are closed. Note that it is not the case that the function $q$ that maximizes $E[q(X-1)+ ...]$ also maximizes $E[\log(q(X-1) + ...]$. As a trivial example, suppose $X_1 = 1, X_2 = 1, X_3 = 10$. Then $q(1) = 1$ and 0 otherwise maximizes $E[q(X-1)+ ...]$ but is undefined for $E[\log(q(X-1) + ...]$.
Choose probability distribution to maximize evaluation function (for CDC flu forecasting contest)
If I understand this correctly, I do not think this will have a closed form solution. Or moreover, it's at least a specialization of a problem that is not in closed form. The reason I say this is tha
Choose probability distribution to maximize evaluation function (for CDC flu forecasting contest) If I understand this correctly, I do not think this will have a closed form solution. Or moreover, it's at least a specialization of a problem that is not in closed form. The reason I say this is that it is exactly the likelihood that appears in the NPMLE for interval censored data, the specialization being that all the intervals are of the form $[X-1, X+1]$. In general, the NPMLE is the maximizer of the function $ \sum_{i = 1}^n \log(P(t_i \in [L_i, R_i]) )$ where $t_i$ is the event time for subject $i$, where all that is known is that the event occurred within the interval $[L_i, R_i]$. This equates to exactly your problem, with $L_i = X_i-1$ and $R_i = X_i + 1$. In general, this is not in closed form. However, at least one special case is; that of current status data, or when all the intervals are of the form $[0, c_i]$ or $[c_i, \infty)$. That being said, there are plenty of algorithms for solving the NPMLE! You can fit that using R's icenReg package with the ic_np function (note: I'm the author). Make sure set the option B = c(1,1), declaring that the intervals are closed. Note that it is not the case that the function $q$ that maximizes $E[q(X-1)+ ...]$ also maximizes $E[\log(q(X-1) + ...]$. As a trivial example, suppose $X_1 = 1, X_2 = 1, X_3 = 10$. Then $q(1) = 1$ and 0 otherwise maximizes $E[q(X-1)+ ...]$ but is undefined for $E[\log(q(X-1) + ...]$.
Choose probability distribution to maximize evaluation function (for CDC flu forecasting contest) If I understand this correctly, I do not think this will have a closed form solution. Or moreover, it's at least a specialization of a problem that is not in closed form. The reason I say this is tha
40,655
What is low rank intuitively for an adjacency matrix?
I'm not sure if your question is easy to answer, but I will try to provide an intuition. I am not an expert in non-negative matrix factorisation so I can't explain the connections there. Let's restrict out attention to simple, undirected graphs $G$ with $n$ vertices. I will assume by low-rank you mean, low-rank of the adjacency matrix. These properties are derived from here Here's are a characterisation low-rank graphs: the graph with no vertices is the only graph with rank 0 a complete bipartite graph is the only connected graph with rank 2 a complete tripartite graph is the only connected graph with rank 3 Rank is known to be preserved between subgraphs as follows: if H is an induced subgraph of G, then $rank(H) \leq rank(G) $. Let $G = G1 \cup G2 \cup··· \cup G_n$, where $G_1, G_2,...,G_n$ are connected components of G, then $rank(G) = \sum_i^n rank(G_i)$ Since the complete graph has rank $n$, it follow from this that $largest \_clique(G) \leq rank(G)$. What is the rank of an average graph? Consider this simple model of a random graph $G$: for every pair of vertices flip a fair coin to determine whether there is an edge between them. It has been shown that with very high probability $G$ has rank $n$. This suggests to me that low rank graphs are locally sparse or have a densely connected component but have lots of isolated vertices. A graph picked at random is likely to be full rank, however.
What is low rank intuitively for an adjacency matrix?
I'm not sure if your question is easy to answer, but I will try to provide an intuition. I am not an expert in non-negative matrix factorisation so I can't explain the connections there. Let's restri
What is low rank intuitively for an adjacency matrix? I'm not sure if your question is easy to answer, but I will try to provide an intuition. I am not an expert in non-negative matrix factorisation so I can't explain the connections there. Let's restrict out attention to simple, undirected graphs $G$ with $n$ vertices. I will assume by low-rank you mean, low-rank of the adjacency matrix. These properties are derived from here Here's are a characterisation low-rank graphs: the graph with no vertices is the only graph with rank 0 a complete bipartite graph is the only connected graph with rank 2 a complete tripartite graph is the only connected graph with rank 3 Rank is known to be preserved between subgraphs as follows: if H is an induced subgraph of G, then $rank(H) \leq rank(G) $. Let $G = G1 \cup G2 \cup··· \cup G_n$, where $G_1, G_2,...,G_n$ are connected components of G, then $rank(G) = \sum_i^n rank(G_i)$ Since the complete graph has rank $n$, it follow from this that $largest \_clique(G) \leq rank(G)$. What is the rank of an average graph? Consider this simple model of a random graph $G$: for every pair of vertices flip a fair coin to determine whether there is an edge between them. It has been shown that with very high probability $G$ has rank $n$. This suggests to me that low rank graphs are locally sparse or have a densely connected component but have lots of isolated vertices. A graph picked at random is likely to be full rank, however.
What is low rank intuitively for an adjacency matrix? I'm not sure if your question is easy to answer, but I will try to provide an intuition. I am not an expert in non-negative matrix factorisation so I can't explain the connections there. Let's restri
40,656
Positive Poisson regression: what is the effect on the model of shifting vs truncating?
Although you are modeling counts, your data cannot be Poisson. The easy way to see this is because it cannot be $0$, which is a possible value for the Poisson distribution. But this isn't really a shifted or truncated Poisson, either. Nor could the number of resits be Poisson. What you are calling "the number of resits" could equally well be called "the number of failures until $r$ successes". That is the definition of a negative binomial. In your case, $r=1$. In short, I would model "the number of resits" using a regression model with a negative binomial distribution. Typically with a regression model, the predicted values should be the expected value at each point in the covariate space. Note that the expected value of a negative binomial is: $$ E[Y] = \frac{(1-p)r}{p} $$ where $p$ is the probability of success. Since $r=1$ for you, the predicted values are the odds of failing a test. You could convert that to the probability of passing a test via $1-(\hat y / (1+\hat y))$. It's actually a little more complicated than that in practice, unfortunately. First, as you probably know, models that use something other than the normal distribution for the response (e.g., the negative binomial), need to use a link function. So to get to what I'm calling $\hat y$, you will need to exponentiate the values computed from the model equation. Next, 'using a negative binomial distribution' sounds like you need negative binomial regression. Actually, that is a slightly different animal from what we have here. Negative binomial regression estimates not only the regression coefficients but also a dispersion parameter. We know the appropriate parameter value for your case a-priori. What you need is called the geometric model. Note also that there are different ways of specifying and parameterizing these things, so you need to read the documentation very carefully. I can walk through a simple example using R. Let's compare people who did not take a prep class, x = 0, to those who did, x = 1. We will imagine that those who didn't take a prep class have only a 30% chance of passing, but those who did have a 70% chance. library(MASS) # you need this library for the negative.binomial() function below set.seed(1082) # this makes the example exactly reproducible y = c(rnbinom(1000, size=1, prob=.3), # number of resits for those who didn't rnbinom(1000, size=1, prob=.7) ) # or did take prep class x = rep(c(0,1), each=1000) # prep class indicator m = glm(y~x, family=negative.binomial(theta=1)) summary(m) # Call: # glm(formula = y ~ x, family = negative.binomial(theta = 1)) # # Deviance Residuals: # Min 1Q Median 3Q Max # -1.5805 -0.8358 -0.6336 0.4447 3.3044 # # Coefficients: # Estimate Std. Error t value Pr(>|t|) # (Intercept) 0.91108 0.03883 23.46 <2e-16 *** # x -1.78335 0.07180 -24.84 <2e-16 *** # --- # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 # # (Dispersion parameter for Negative Binomial(1) family taken to be 1.075368) # # Null deviance: 2646 on 1999 degrees of freedom # Residual deviance: 1913 on 1998 degrees of freedom # AIC: 5902.8 # # Number of Fisher Scoring iterations: 4 cm = c(coef(m)[1], sum(coef(m)) ) 1 - ( exp(cm)/(1 + exp(cm)) ) # the model's estimated probabilities of passing the test # (Intercept) # 0.2867795 0.7052186
Positive Poisson regression: what is the effect on the model of shifting vs truncating?
Although you are modeling counts, your data cannot be Poisson. The easy way to see this is because it cannot be $0$, which is a possible value for the Poisson distribution. But this isn't really a s
Positive Poisson regression: what is the effect on the model of shifting vs truncating? Although you are modeling counts, your data cannot be Poisson. The easy way to see this is because it cannot be $0$, which is a possible value for the Poisson distribution. But this isn't really a shifted or truncated Poisson, either. Nor could the number of resits be Poisson. What you are calling "the number of resits" could equally well be called "the number of failures until $r$ successes". That is the definition of a negative binomial. In your case, $r=1$. In short, I would model "the number of resits" using a regression model with a negative binomial distribution. Typically with a regression model, the predicted values should be the expected value at each point in the covariate space. Note that the expected value of a negative binomial is: $$ E[Y] = \frac{(1-p)r}{p} $$ where $p$ is the probability of success. Since $r=1$ for you, the predicted values are the odds of failing a test. You could convert that to the probability of passing a test via $1-(\hat y / (1+\hat y))$. It's actually a little more complicated than that in practice, unfortunately. First, as you probably know, models that use something other than the normal distribution for the response (e.g., the negative binomial), need to use a link function. So to get to what I'm calling $\hat y$, you will need to exponentiate the values computed from the model equation. Next, 'using a negative binomial distribution' sounds like you need negative binomial regression. Actually, that is a slightly different animal from what we have here. Negative binomial regression estimates not only the regression coefficients but also a dispersion parameter. We know the appropriate parameter value for your case a-priori. What you need is called the geometric model. Note also that there are different ways of specifying and parameterizing these things, so you need to read the documentation very carefully. I can walk through a simple example using R. Let's compare people who did not take a prep class, x = 0, to those who did, x = 1. We will imagine that those who didn't take a prep class have only a 30% chance of passing, but those who did have a 70% chance. library(MASS) # you need this library for the negative.binomial() function below set.seed(1082) # this makes the example exactly reproducible y = c(rnbinom(1000, size=1, prob=.3), # number of resits for those who didn't rnbinom(1000, size=1, prob=.7) ) # or did take prep class x = rep(c(0,1), each=1000) # prep class indicator m = glm(y~x, family=negative.binomial(theta=1)) summary(m) # Call: # glm(formula = y ~ x, family = negative.binomial(theta = 1)) # # Deviance Residuals: # Min 1Q Median 3Q Max # -1.5805 -0.8358 -0.6336 0.4447 3.3044 # # Coefficients: # Estimate Std. Error t value Pr(>|t|) # (Intercept) 0.91108 0.03883 23.46 <2e-16 *** # x -1.78335 0.07180 -24.84 <2e-16 *** # --- # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 # # (Dispersion parameter for Negative Binomial(1) family taken to be 1.075368) # # Null deviance: 2646 on 1999 degrees of freedom # Residual deviance: 1913 on 1998 degrees of freedom # AIC: 5902.8 # # Number of Fisher Scoring iterations: 4 cm = c(coef(m)[1], sum(coef(m)) ) 1 - ( exp(cm)/(1 + exp(cm)) ) # the model's estimated probabilities of passing the test # (Intercept) # 0.2867795 0.7052186
Positive Poisson regression: what is the effect on the model of shifting vs truncating? Although you are modeling counts, your data cannot be Poisson. The easy way to see this is because it cannot be $0$, which is a possible value for the Poisson distribution. But this isn't really a s
40,657
Positive Poisson regression: what is the effect on the model of shifting vs truncating?
You have to use the distribution that explains the phenomenon. Sometime a simple rewording can do the trick of thinking outside the box. For instance, instead of framing the question as "how many attempts to pass?" you frame it as "How many re-takes?". You see, in your case it's impossible to have an observations of a "number of attempts" variable less that 1. Hence, Poisson is simply not a good fit at all. However, if you frame the question the way I did, you observations of "number of retakes" variable include 0, and Poisson could be reasonable distribution to consider. You're not truncating anything or shifting, you are answering a different question about a different variable, namely, a "number of re-takes" not attempts like in the original question.
Positive Poisson regression: what is the effect on the model of shifting vs truncating?
You have to use the distribution that explains the phenomenon. Sometime a simple rewording can do the trick of thinking outside the box. For instance, instead of framing the question as "how many atte
Positive Poisson regression: what is the effect on the model of shifting vs truncating? You have to use the distribution that explains the phenomenon. Sometime a simple rewording can do the trick of thinking outside the box. For instance, instead of framing the question as "how many attempts to pass?" you frame it as "How many re-takes?". You see, in your case it's impossible to have an observations of a "number of attempts" variable less that 1. Hence, Poisson is simply not a good fit at all. However, if you frame the question the way I did, you observations of "number of retakes" variable include 0, and Poisson could be reasonable distribution to consider. You're not truncating anything or shifting, you are answering a different question about a different variable, namely, a "number of re-takes" not attempts like in the original question.
Positive Poisson regression: what is the effect on the model of shifting vs truncating? You have to use the distribution that explains the phenomenon. Sometime a simple rewording can do the trick of thinking outside the box. For instance, instead of framing the question as "how many atte
40,658
Were professors Samuel S. Wilks and Daniel S. Wilks related?
I am Daniel Wilks. No relation to Samuel S, but I get this question a lot.
Were professors Samuel S. Wilks and Daniel S. Wilks related?
I am Daniel Wilks. No relation to Samuel S, but I get this question a lot.
Were professors Samuel S. Wilks and Daniel S. Wilks related? I am Daniel Wilks. No relation to Samuel S, but I get this question a lot.
Were professors Samuel S. Wilks and Daniel S. Wilks related? I am Daniel Wilks. No relation to Samuel S, but I get this question a lot.
40,659
Were professors Samuel S. Wilks and Daniel S. Wilks related?
I cannot currently say that they were not related, but we can at least say that Daniel is not Samuel's son. This biography of Samuel S Wilks says [1]: On 1 September 1931 Wilks married Hattie Eugenia Orr (1906-2000), known as Gena. They had one child, a son named Stanley Neal Wilks born in 1932. However, the elder Wilks would be of the right age to perhaps be a grandfather or great uncle to the younger one (or even some other, more distant relation, of course -- ultimately we're all related) [1] J J O'Connor and E F Robertson (2014) Samuel Stanley Wilks, Biographies MacTutor History of Mathematics archive School of Mathematics and Statistics University of St Andrews, Scotland http://www-history.mcs.st-and.ac.uk/Biographies/Wilks.html
Were professors Samuel S. Wilks and Daniel S. Wilks related?
I cannot currently say that they were not related, but we can at least say that Daniel is not Samuel's son. This biography of Samuel S Wilks says [1]: On 1 September 1931 Wilks married Hattie Eugenia
Were professors Samuel S. Wilks and Daniel S. Wilks related? I cannot currently say that they were not related, but we can at least say that Daniel is not Samuel's son. This biography of Samuel S Wilks says [1]: On 1 September 1931 Wilks married Hattie Eugenia Orr (1906-2000), known as Gena. They had one child, a son named Stanley Neal Wilks born in 1932. However, the elder Wilks would be of the right age to perhaps be a grandfather or great uncle to the younger one (or even some other, more distant relation, of course -- ultimately we're all related) [1] J J O'Connor and E F Robertson (2014) Samuel Stanley Wilks, Biographies MacTutor History of Mathematics archive School of Mathematics and Statistics University of St Andrews, Scotland http://www-history.mcs.st-and.ac.uk/Biographies/Wilks.html
Were professors Samuel S. Wilks and Daniel S. Wilks related? I cannot currently say that they were not related, but we can at least say that Daniel is not Samuel's son. This biography of Samuel S Wilks says [1]: On 1 September 1931 Wilks married Hattie Eugenia
40,660
Monte Carlo method cannot be used
Edit: I strongly recommend getting a new book to study from because this book is garbage by the looks of it. First off, there is a gross typo: the integral to estimate should be $\int_{-\infty}^\infty xf(x)dx$ as can plainly be seen in the explanation presented. Second, the expectation is NOT infinite, it simply doesn't exist, just like in the case of a Cauchy random variable. In its most basic form, MC integration draws random samples $x_i$ such that: $$\frac{(b-a)}{N}[g(x_1)+\cdots+g(x_N)]\approx \int_{a}^{b} g(x)dx.$$ Here $x_i$ are drawn in $[a,b]$, for example as a uniform distribution. When the interval is infinite, we can truncate it to a finite interval and rely on the tail integrals being small. The last sentence translates to $\int_{-\infty}^ag(x)dx+\int_b^\infty g(x)dx<\infty$. Notice that the above expression is precisely $(b-a)E[g(X)]$ where $X$ is drawn from $[a,b]$. Thus you need the expectation to be finite. When the expectation exists, but the variance doesn't, there is no good way of putting error bars on the MC estimate of the integral. So in your case, $g(x)=xf(x)$, and the above methodology fails as the tail integrals of $xf(x)$ are NOT finite.
Monte Carlo method cannot be used
Edit: I strongly recommend getting a new book to study from because this book is garbage by the looks of it. First off, there is a gross typo: the integral to estimate should be $\int_{-\infty}^\infty
Monte Carlo method cannot be used Edit: I strongly recommend getting a new book to study from because this book is garbage by the looks of it. First off, there is a gross typo: the integral to estimate should be $\int_{-\infty}^\infty xf(x)dx$ as can plainly be seen in the explanation presented. Second, the expectation is NOT infinite, it simply doesn't exist, just like in the case of a Cauchy random variable. In its most basic form, MC integration draws random samples $x_i$ such that: $$\frac{(b-a)}{N}[g(x_1)+\cdots+g(x_N)]\approx \int_{a}^{b} g(x)dx.$$ Here $x_i$ are drawn in $[a,b]$, for example as a uniform distribution. When the interval is infinite, we can truncate it to a finite interval and rely on the tail integrals being small. The last sentence translates to $\int_{-\infty}^ag(x)dx+\int_b^\infty g(x)dx<\infty$. Notice that the above expression is precisely $(b-a)E[g(X)]$ where $X$ is drawn from $[a,b]$. Thus you need the expectation to be finite. When the expectation exists, but the variance doesn't, there is no good way of putting error bars on the MC estimate of the integral. So in your case, $g(x)=xf(x)$, and the above methodology fails as the tail integrals of $xf(x)$ are NOT finite.
Monte Carlo method cannot be used Edit: I strongly recommend getting a new book to study from because this book is garbage by the looks of it. First off, there is a gross typo: the integral to estimate should be $\int_{-\infty}^\infty
40,661
Monte Carlo method cannot be used
There might be the need for a caveat for the question, in term of what is it that you call Monte Carlo integration. You want to use Monte Carlo to estimate $\int_{-\infty}^{\infty} f(x) dx$, a quantity we know to be 1. One way to to do this is to find a pdf $g(x)$ such that you can sample from $g$, and then $$\int_{-\infty}^{\infty} f(x) = \int_{-\infty}^{\infty} \dfrac{f(x)}{g(x)}g(x)dx = E_g \left[\dfrac{f(x)}{g(x)} \right].$$ So you can get $N$ numbers from $g$, $x_1, \dots, x_N$, and calculate $$\dfrac{1}{N}\sum_{i=1}^{N}\dfrac{f(x_i)}{g(x_i)} \approx \int_{-\infty}^{\infty} f(x) .$$ Thus, your choice of $g$ will lead to different estimators. @Alex R. in their answer used the uniform distribution pdf $$g(x) = \dfrac{1}{b-a} I_{a < x<b}. $$ However, in that case you are sampling from a Uniform distribution from the whole real line, and such a distribution does not exist, thus $g$ cannot be the pdf of a uniform distribution. I believe there might a typo in the notes, since the following R code seems to suggest that a Monte Carlo estimate of $\int_{-\infty}^{\infty} f(x)$ can be obtained. Here I use $g$ to be the pdf of a $N(0,100)$, where $100$ is the variance. set.seed(1) N <- 1e4 f <- function(x) { y <- ifelse(abs(x) > 4, 1/x^2, 1/16) return(y) } # Draws from g prop <- rnorm(N, 0, 10) #Evaluate g(x) g_prop <- dnorm(prop, 0, 10) #Evaluate f(x) f_prop <- f(prop) mc_est <- sum(f_prop/g_prop)/N mc_est [1] 0.9502994 I can probably use a better $g$ to get a better estimate, but it looks like Monte Carlo integration is possible. Maybe the question wanted to say "... estimate the value of $\int_{-\infty}^{\infty} x f(x) dx$". In which case Monte Carlo is not possible since the quantity you want to estimate does not exist.
Monte Carlo method cannot be used
There might be the need for a caveat for the question, in term of what is it that you call Monte Carlo integration. You want to use Monte Carlo to estimate $\int_{-\infty}^{\infty} f(x) dx$, a quantit
Monte Carlo method cannot be used There might be the need for a caveat for the question, in term of what is it that you call Monte Carlo integration. You want to use Monte Carlo to estimate $\int_{-\infty}^{\infty} f(x) dx$, a quantity we know to be 1. One way to to do this is to find a pdf $g(x)$ such that you can sample from $g$, and then $$\int_{-\infty}^{\infty} f(x) = \int_{-\infty}^{\infty} \dfrac{f(x)}{g(x)}g(x)dx = E_g \left[\dfrac{f(x)}{g(x)} \right].$$ So you can get $N$ numbers from $g$, $x_1, \dots, x_N$, and calculate $$\dfrac{1}{N}\sum_{i=1}^{N}\dfrac{f(x_i)}{g(x_i)} \approx \int_{-\infty}^{\infty} f(x) .$$ Thus, your choice of $g$ will lead to different estimators. @Alex R. in their answer used the uniform distribution pdf $$g(x) = \dfrac{1}{b-a} I_{a < x<b}. $$ However, in that case you are sampling from a Uniform distribution from the whole real line, and such a distribution does not exist, thus $g$ cannot be the pdf of a uniform distribution. I believe there might a typo in the notes, since the following R code seems to suggest that a Monte Carlo estimate of $\int_{-\infty}^{\infty} f(x)$ can be obtained. Here I use $g$ to be the pdf of a $N(0,100)$, where $100$ is the variance. set.seed(1) N <- 1e4 f <- function(x) { y <- ifelse(abs(x) > 4, 1/x^2, 1/16) return(y) } # Draws from g prop <- rnorm(N, 0, 10) #Evaluate g(x) g_prop <- dnorm(prop, 0, 10) #Evaluate f(x) f_prop <- f(prop) mc_est <- sum(f_prop/g_prop)/N mc_est [1] 0.9502994 I can probably use a better $g$ to get a better estimate, but it looks like Monte Carlo integration is possible. Maybe the question wanted to say "... estimate the value of $\int_{-\infty}^{\infty} x f(x) dx$". In which case Monte Carlo is not possible since the quantity you want to estimate does not exist.
Monte Carlo method cannot be used There might be the need for a caveat for the question, in term of what is it that you call Monte Carlo integration. You want to use Monte Carlo to estimate $\int_{-\infty}^{\infty} f(x) dx$, a quantit
40,662
Why do we need to model RNA-seq data using Poisson, negative binomial,
The data is count data because it's the number of counts aligned to a gene. It's not continuous and therefore can't be modelled as say a normal distribution. Poisson distribution is designed for modelling count data. However, the Poisson distribution assumes the first and second moments (mean and variance) are equal. This is not true for RNA-Seq. Lowly expressed genes have much higher variance than highly expressed genes. To account for the variability, we use the negative-binomial model which is really an extension of Poisson. The NB model has an extra parameter to model for the variance. It can be proven as the variance approach to the mean, the NB model becomes the Poisson model. EDIT To answer your comments: Normalization is usually necessary to model the different sequencing depth between libraries. However, you don't need to do it yourself if you use DESeq2 or edgeR. They have their own normalization algorithm (Trim-mean-valued and upper-quartiles). Those packages do the normalization for you. Fit your data to a NB model, estimate the dispersion (ie: variance). Once they have a model, they can use whatever statistical method required (I think it's the Wald test for DESeq2) to check for differential expressed genes. The results depend on how much they express and also how much variance they have.
Why do we need to model RNA-seq data using Poisson, negative binomial,
The data is count data because it's the number of counts aligned to a gene. It's not continuous and therefore can't be modelled as say a normal distribution. Poisson distribution is designed for model
Why do we need to model RNA-seq data using Poisson, negative binomial, The data is count data because it's the number of counts aligned to a gene. It's not continuous and therefore can't be modelled as say a normal distribution. Poisson distribution is designed for modelling count data. However, the Poisson distribution assumes the first and second moments (mean and variance) are equal. This is not true for RNA-Seq. Lowly expressed genes have much higher variance than highly expressed genes. To account for the variability, we use the negative-binomial model which is really an extension of Poisson. The NB model has an extra parameter to model for the variance. It can be proven as the variance approach to the mean, the NB model becomes the Poisson model. EDIT To answer your comments: Normalization is usually necessary to model the different sequencing depth between libraries. However, you don't need to do it yourself if you use DESeq2 or edgeR. They have their own normalization algorithm (Trim-mean-valued and upper-quartiles). Those packages do the normalization for you. Fit your data to a NB model, estimate the dispersion (ie: variance). Once they have a model, they can use whatever statistical method required (I think it's the Wald test for DESeq2) to check for differential expressed genes. The results depend on how much they express and also how much variance they have.
Why do we need to model RNA-seq data using Poisson, negative binomial, The data is count data because it's the number of counts aligned to a gene. It's not continuous and therefore can't be modelled as say a normal distribution. Poisson distribution is designed for model
40,663
Why do we need to model RNA-seq data using Poisson, negative binomial,
It is usual to model counts taking into account that: 1 - they only take on integer values 2 - they are always non-negative 3 - (most importantly) their variability increases with their mean The negative binomial is used when the dispersion of the counts is greater than would be expected from the Poisson. In both cases it is usual to model using a log link.
Why do we need to model RNA-seq data using Poisson, negative binomial,
It is usual to model counts taking into account that: 1 - they only take on integer values 2 - they are always non-negative 3 - (most importantly) their variability increases with their mean The negat
Why do we need to model RNA-seq data using Poisson, negative binomial, It is usual to model counts taking into account that: 1 - they only take on integer values 2 - they are always non-negative 3 - (most importantly) their variability increases with their mean The negative binomial is used when the dispersion of the counts is greater than would be expected from the Poisson. In both cases it is usual to model using a log link.
Why do we need to model RNA-seq data using Poisson, negative binomial, It is usual to model counts taking into account that: 1 - they only take on integer values 2 - they are always non-negative 3 - (most importantly) their variability increases with their mean The negat
40,664
SUTVA vs. independence
I think SUTVA violations come in two flavors, which are not always distinct: "spillovers/interferences" that arise from contact across individuals in social, commodity, or physical space (independence flavor) dilution/concentration of treatment effects that stem from changes in the prevalence of treatment (what economists call general equilibrium effects or failure of the ceteris paribus assumption flavor) Consider a job training program that teaches a handful of people how to knit and sell their output on Etsy (a small program in a large market). If you have treated trainees that teach control group people how to crochet, or more knitting takes place when you treat groups of friends (knitting is often a social activity), you have an example of (1). Two real world examples of this are patients in early AIDS drug trials sharing their medication or irrigation/rain causing fertilizer runoff from treated to control plots. If you a have a mandatory job training program that teaches knitting and selling at a local farmer's market (large program in a small market), you might expect the prices of scarves and socks to plummet, with the pecuniary benefit of the knitting knowledge declining with the number of people treated. A real world example is the effect of charter schools on academic achievement, which might change if you had a large influx of public school students into the other sector, or a program that teaches farmers to all grow a particular type of crop. You can think of this dilution as either a dosage change or as a kind of treatment effect change. I think it is frequently hard to make these two fully distinct, and (2) often operates through (1)-type channel: the inrush of public school students is only problematic because of rival resource constraints or peer effects. However, (2) is more subtle than spillover/interference, so I think it does go "beyond independence" in some sense. I think (1) is often more harmful, since it undermines internal validity of an estimate, though we can sometimes redefine the unit of analysis to be the community within which individuals interact rather than the individuals themselves. I think of (2) as circumscribing the external validity, since when trials are small, we can think of the estimated partial equilibrium effects as a kind of bound on the general equilibrium effects that would be seen if the program was scaled up and prices and inputs or "dosage" change. This limits what you can claim, but if the costs of the small trial program already exceed the benefits, and we anticipate the benefits to decline if the program is scaled up, that is still useful information. Alternatively, SUTVA may only hold for some part of our data, and the analysis can proceed once the rest is discarded. This makes (2) less pernicious. Here's a slightly more rigorous way to think about this. We can write the treatment effect for person $i$ as a function of the $(N-1) \times 1$ indicator vector $\mathbf{t}$ that gives you treatment assignments in the remaining population: $$\Delta_i(\mathbf{t})=y^1_i(\mathbf{t})-y^0_i(\mathbf{t})$$ We can think about how $\Delta_i$ varies as we change $\mathbf{t}$ in particular ways. Let $T=\vert \mathbf{t} \vert$, the $L_1$ norm of the treatment assignment vector. This tells you how many people got treated in a particular treatment configuration. If $\Delta_i$ depends on where the ones are in $\mathbf{t}$, holding $T$ fixed, you have SUTVA violation of type (1). This means it matters whether people "connected" to person $i$ are treated or not, a kind of dependence. If $\Delta_i$ only changes with $T$, but is the same for all pairs $\mathbf{t}'$ and $\mathbf{t}$ where $\vert \mathbf{t'} \vert= \vert \mathbf{t} \vert,$ you have a type 2 violation. If $\Delta_i(\mathbf{t})=y^1_i-y^0_i,$ SUTVA is fully satisfied since the potential outcomes do not depend on how the treatment is rolled out. To summarize all this, there are two types of SUTVA violations which are not fully conceptually distinct, but have differing implications, which makes it useful to emphasize their differences.
SUTVA vs. independence
I think SUTVA violations come in two flavors, which are not always distinct: "spillovers/interferences" that arise from contact across individuals in social, commodity, or physical space (independenc
SUTVA vs. independence I think SUTVA violations come in two flavors, which are not always distinct: "spillovers/interferences" that arise from contact across individuals in social, commodity, or physical space (independence flavor) dilution/concentration of treatment effects that stem from changes in the prevalence of treatment (what economists call general equilibrium effects or failure of the ceteris paribus assumption flavor) Consider a job training program that teaches a handful of people how to knit and sell their output on Etsy (a small program in a large market). If you have treated trainees that teach control group people how to crochet, or more knitting takes place when you treat groups of friends (knitting is often a social activity), you have an example of (1). Two real world examples of this are patients in early AIDS drug trials sharing their medication or irrigation/rain causing fertilizer runoff from treated to control plots. If you a have a mandatory job training program that teaches knitting and selling at a local farmer's market (large program in a small market), you might expect the prices of scarves and socks to plummet, with the pecuniary benefit of the knitting knowledge declining with the number of people treated. A real world example is the effect of charter schools on academic achievement, which might change if you had a large influx of public school students into the other sector, or a program that teaches farmers to all grow a particular type of crop. You can think of this dilution as either a dosage change or as a kind of treatment effect change. I think it is frequently hard to make these two fully distinct, and (2) often operates through (1)-type channel: the inrush of public school students is only problematic because of rival resource constraints or peer effects. However, (2) is more subtle than spillover/interference, so I think it does go "beyond independence" in some sense. I think (1) is often more harmful, since it undermines internal validity of an estimate, though we can sometimes redefine the unit of analysis to be the community within which individuals interact rather than the individuals themselves. I think of (2) as circumscribing the external validity, since when trials are small, we can think of the estimated partial equilibrium effects as a kind of bound on the general equilibrium effects that would be seen if the program was scaled up and prices and inputs or "dosage" change. This limits what you can claim, but if the costs of the small trial program already exceed the benefits, and we anticipate the benefits to decline if the program is scaled up, that is still useful information. Alternatively, SUTVA may only hold for some part of our data, and the analysis can proceed once the rest is discarded. This makes (2) less pernicious. Here's a slightly more rigorous way to think about this. We can write the treatment effect for person $i$ as a function of the $(N-1) \times 1$ indicator vector $\mathbf{t}$ that gives you treatment assignments in the remaining population: $$\Delta_i(\mathbf{t})=y^1_i(\mathbf{t})-y^0_i(\mathbf{t})$$ We can think about how $\Delta_i$ varies as we change $\mathbf{t}$ in particular ways. Let $T=\vert \mathbf{t} \vert$, the $L_1$ norm of the treatment assignment vector. This tells you how many people got treated in a particular treatment configuration. If $\Delta_i$ depends on where the ones are in $\mathbf{t}$, holding $T$ fixed, you have SUTVA violation of type (1). This means it matters whether people "connected" to person $i$ are treated or not, a kind of dependence. If $\Delta_i$ only changes with $T$, but is the same for all pairs $\mathbf{t}'$ and $\mathbf{t}$ where $\vert \mathbf{t'} \vert= \vert \mathbf{t} \vert,$ you have a type 2 violation. If $\Delta_i(\mathbf{t})=y^1_i-y^0_i,$ SUTVA is fully satisfied since the potential outcomes do not depend on how the treatment is rolled out. To summarize all this, there are two types of SUTVA violations which are not fully conceptually distinct, but have differing implications, which makes it useful to emphasize their differences.
SUTVA vs. independence I think SUTVA violations come in two flavors, which are not always distinct: "spillovers/interferences" that arise from contact across individuals in social, commodity, or physical space (independenc
40,665
Why would one ever use z-score over a t-score?
The image you used is wrong. If you know the population standard deviation then your statistic follows a normal distribution. When you do not know it, and you estimate from the sample than your statistic follows a t distribution and that is all. In your image and the text that follows the image you reverted yes with no. Other than that when you know the exact distribution that there is no meaning of using an approximation. The fact that t distribution goes toward a normal distribution when the degrees of freedom is large is an approximation. Most probably this custom of using the normal approximation instead of t distribution when you have a large sample and estimate variance from the sample is an historical artifact. From the times when critical values were stored in printed tables, and computed values for t distribution for all degrees of freedom was hard if not impossible to find. But now we have computers.
Why would one ever use z-score over a t-score?
The image you used is wrong. If you know the population standard deviation then your statistic follows a normal distribution. When you do not know it, and you estimate from the sample than your statis
Why would one ever use z-score over a t-score? The image you used is wrong. If you know the population standard deviation then your statistic follows a normal distribution. When you do not know it, and you estimate from the sample than your statistic follows a t distribution and that is all. In your image and the text that follows the image you reverted yes with no. Other than that when you know the exact distribution that there is no meaning of using an approximation. The fact that t distribution goes toward a normal distribution when the degrees of freedom is large is an approximation. Most probably this custom of using the normal approximation instead of t distribution when you have a large sample and estimate variance from the sample is an historical artifact. From the times when critical values were stored in printed tables, and computed values for t distribution for all degrees of freedom was hard if not impossible to find. But now we have computers.
Why would one ever use z-score over a t-score? The image you used is wrong. If you know the population standard deviation then your statistic follows a normal distribution. When you do not know it, and you estimate from the sample than your statis
40,666
Why is the mean of a Chi Square distribution equal to the degree of freedom?
You don't define the mean to be the degrees of freedom (d.f.) -- it follows from the definition of the pdf and the definition of expectation of a random variable. The pdf of a chi-squared random variable with $k$ d.f. is: ${\frac {1}{2^{\frac {k}{2}}\Gamma \left({\frac {k}{2}}\right)}}\;x^{{\frac {k}{2}}-1}e^{-{\frac {x}{2}}}\; x>0, k>0$ (and $0$ elsewhere) The expectation of a continuous random variable is: $\operatorname {E} [X]=\int _{-\infty }^{\infty }xf(x)\,\mathrm {d} x.$ So the mean of a chi-square random variable is: $\operatorname {E} [X]=\int _{0}^{\infty }x{\frac {1}{2^{\frac {k}{2}}\Gamma \left({\frac {k}{2}}\right)}}\;x^{{\frac {k}{2}}-1}e^{-{\frac {x}{2}}}\,\mathrm {d} x $ Pulling the constants out and combining the $x$ powers ${\frac {1}{2^{\frac {k}{2}}\Gamma \left({\frac {k}{2}}\right)}}\; \int _{0}^{\infty }x^{{\frac {k+2}{2}}-1}e^{-{\frac {x}{2}}}\,\mathrm {d} x $ the term in the integral can be recognized as another chi-square (missing the normalizing constant). If you multiply and divide by the relevant normalizing constant so that the integral is 1, you're left with a ratio of normalizing constants out the front (for different d.f.) ... which you should be able to simplify. However, if your question is really "why choose that pdf to be called a chi-square?", whuber's comment is relevant -- the sum of squares of independent standard normals is a random variable that fairly naturally arises in a number of contexts*, and that is something we would therefore like to have a name for. The degrees of freedom relates to the number of independent normals involved and each of those squared components has mean 1. * So for example, Helmert identified it as related to the distribution of sample variance for iid samples from a normal distribution (though the use of the symbol $\chi^2$ and hence the name "chi-squared" don't come until Pearson's work about a generation later).
Why is the mean of a Chi Square distribution equal to the degree of freedom?
You don't define the mean to be the degrees of freedom (d.f.) -- it follows from the definition of the pdf and the definition of expectation of a random variable. The pdf of a chi-squared random vari
Why is the mean of a Chi Square distribution equal to the degree of freedom? You don't define the mean to be the degrees of freedom (d.f.) -- it follows from the definition of the pdf and the definition of expectation of a random variable. The pdf of a chi-squared random variable with $k$ d.f. is: ${\frac {1}{2^{\frac {k}{2}}\Gamma \left({\frac {k}{2}}\right)}}\;x^{{\frac {k}{2}}-1}e^{-{\frac {x}{2}}}\; x>0, k>0$ (and $0$ elsewhere) The expectation of a continuous random variable is: $\operatorname {E} [X]=\int _{-\infty }^{\infty }xf(x)\,\mathrm {d} x.$ So the mean of a chi-square random variable is: $\operatorname {E} [X]=\int _{0}^{\infty }x{\frac {1}{2^{\frac {k}{2}}\Gamma \left({\frac {k}{2}}\right)}}\;x^{{\frac {k}{2}}-1}e^{-{\frac {x}{2}}}\,\mathrm {d} x $ Pulling the constants out and combining the $x$ powers ${\frac {1}{2^{\frac {k}{2}}\Gamma \left({\frac {k}{2}}\right)}}\; \int _{0}^{\infty }x^{{\frac {k+2}{2}}-1}e^{-{\frac {x}{2}}}\,\mathrm {d} x $ the term in the integral can be recognized as another chi-square (missing the normalizing constant). If you multiply and divide by the relevant normalizing constant so that the integral is 1, you're left with a ratio of normalizing constants out the front (for different d.f.) ... which you should be able to simplify. However, if your question is really "why choose that pdf to be called a chi-square?", whuber's comment is relevant -- the sum of squares of independent standard normals is a random variable that fairly naturally arises in a number of contexts*, and that is something we would therefore like to have a name for. The degrees of freedom relates to the number of independent normals involved and each of those squared components has mean 1. * So for example, Helmert identified it as related to the distribution of sample variance for iid samples from a normal distribution (though the use of the symbol $\chi^2$ and hence the name "chi-squared" don't come until Pearson's work about a generation later).
Why is the mean of a Chi Square distribution equal to the degree of freedom? You don't define the mean to be the degrees of freedom (d.f.) -- it follows from the definition of the pdf and the definition of expectation of a random variable. The pdf of a chi-squared random vari
40,667
Why is the mean of a Chi Square distribution equal to the degree of freedom?
Chi squared distribution is Gamma distribution with parameters $(\lambda, \alpha) = (\frac12, \frac{n}2)$. And we know that expected value of Gamma is $\frac{\alpha}{\lambda}$ . Hence the expected value of a chi squared r.v. is $ \frac{n/2}{1/2} = n$.
Why is the mean of a Chi Square distribution equal to the degree of freedom?
Chi squared distribution is Gamma distribution with parameters $(\lambda, \alpha) = (\frac12, \frac{n}2)$. And we know that expected value of Gamma is $\frac{\alpha}{\lambda}$ . Hence the expected val
Why is the mean of a Chi Square distribution equal to the degree of freedom? Chi squared distribution is Gamma distribution with parameters $(\lambda, \alpha) = (\frac12, \frac{n}2)$. And we know that expected value of Gamma is $\frac{\alpha}{\lambda}$ . Hence the expected value of a chi squared r.v. is $ \frac{n/2}{1/2} = n$.
Why is the mean of a Chi Square distribution equal to the degree of freedom? Chi squared distribution is Gamma distribution with parameters $(\lambda, \alpha) = (\frac12, \frac{n}2)$. And we know that expected value of Gamma is $\frac{\alpha}{\lambda}$ . Hence the expected val
40,668
Match Quality Graph
It seems to me it is worth noting that these are, in essence, agreement data. We should use a plot designed for displaying and assessing such data. The plot I'm most familiar with for this purpose is Bangdawala's agreement chart. You can find it discussed here: Bangdiwala, SI, & Shankar, V (2013). The agreement chart. BMC Medical Research Methodology, 13:97. (See also Bangdiwala's B.) In R, you can create one with ?agreementplot in the vcd package. (I know it can be done in SAS using the AGREE option in PROC FREQ, and I'm sure there are Stata macros for it as well.) library(vcd) d = read.table(text="cq sa pct ... 4 4 11.4", header=T) tab = xtabs(pct~cq+sa, d) windows() agreementplot(tab) ## you can also get the Bangdiwala B agreement statistics: print(agreementplot(tab)) # $Bangdiwala # [,1] # [1,] 0.1352742 # # $Bangdiwala_Weighted # [,1] # [1,] 0.5426176 # # $weights # [1] 1.0000000 0.8888889 Some things to note from this plot are: The rectangles lie along the red diagonal. This means that neither measure is systematically higher or lower than the other. (That is, neither is a biased measure of the other.) The heavy black rectangles are a fairly small proportion of the area of the outer rectangles, indicating that the matching of students to schools is far from perfect. (The gray rectangles represent partial—'off by 1'—agreement.)
Match Quality Graph
It seems to me it is worth noting that these are, in essence, agreement data. We should use a plot designed for displaying and assessing such data. The plot I'm most familiar with for this purpose i
Match Quality Graph It seems to me it is worth noting that these are, in essence, agreement data. We should use a plot designed for displaying and assessing such data. The plot I'm most familiar with for this purpose is Bangdawala's agreement chart. You can find it discussed here: Bangdiwala, SI, & Shankar, V (2013). The agreement chart. BMC Medical Research Methodology, 13:97. (See also Bangdiwala's B.) In R, you can create one with ?agreementplot in the vcd package. (I know it can be done in SAS using the AGREE option in PROC FREQ, and I'm sure there are Stata macros for it as well.) library(vcd) d = read.table(text="cq sa pct ... 4 4 11.4", header=T) tab = xtabs(pct~cq+sa, d) windows() agreementplot(tab) ## you can also get the Bangdiwala B agreement statistics: print(agreementplot(tab)) # $Bangdiwala # [,1] # [1,] 0.1352742 # # $Bangdiwala_Weighted # [,1] # [1,] 0.5426176 # # $weights # [1] 1.0000000 0.8888889 Some things to note from this plot are: The rectangles lie along the red diagonal. This means that neither measure is systematically higher or lower than the other. (That is, neither is a biased measure of the other.) The heavy black rectangles are a fairly small proportion of the area of the outer rectangles, indicating that the matching of students to schools is far from perfect. (The gray rectangles represent partial—'off by 1'—agreement.)
Match Quality Graph It seems to me it is worth noting that these are, in essence, agreement data. We should use a plot designed for displaying and assessing such data. The plot I'm most familiar with for this purpose i
40,669
Match Quality Graph
I think the biggest weakness of the original is that the color intensity dominates our perception even though it is practically meaningless in that it duplicates information already represented by the positions. I imagine that leading to your dissatisfaction and search for alternatives. Here is a version using color intensity for counts instead of using size for counts. It does a decent job of showing the counts falling off from the diagonal and that quartiles 2 and 3 are not that different. Neither color not area is very easy to perceive accurately, but I switched from area to color for percents because it's more "glance-able" for pattern recognition. I used discrete colors instead of continuous colors to mask what I judged to be meaningless variations. Looking at marginals, I'm finding it easier to see patterns in separate bar charts than in overlaid lines -- not sure why. With some effort, it may work to append the bars charts to two edges of the heat map for a true "marginal" effect. Lines do make it easier to think in terms of what happens when the X variable changes from over value to the next. The data seems too coarse to go very far with a visualization.
Match Quality Graph
I think the biggest weakness of the original is that the color intensity dominates our perception even though it is practically meaningless in that it duplicates information already represented by the
Match Quality Graph I think the biggest weakness of the original is that the color intensity dominates our perception even though it is practically meaningless in that it duplicates information already represented by the positions. I imagine that leading to your dissatisfaction and search for alternatives. Here is a version using color intensity for counts instead of using size for counts. It does a decent job of showing the counts falling off from the diagonal and that quartiles 2 and 3 are not that different. Neither color not area is very easy to perceive accurately, but I switched from area to color for percents because it's more "glance-able" for pattern recognition. I used discrete colors instead of continuous colors to mask what I judged to be meaningless variations. Looking at marginals, I'm finding it easier to see patterns in separate bar charts than in overlaid lines -- not sure why. With some effort, it may work to append the bars charts to two edges of the heat map for a true "marginal" effect. Lines do make it easier to think in terms of what happens when the X variable changes from over value to the next. The data seems too coarse to go very far with a visualization.
Match Quality Graph I think the biggest weakness of the original is that the color intensity dominates our perception even though it is practically meaningless in that it duplicates information already represented by the
40,670
Match Quality Graph
I think the current charts show the data pretty well. The stacked bar chart has such nice progressions it is easier to follow along than most stacked bar charts. The original bubble chart shows that there is a reasonable correlation between the two (I calculated it at 0.36). One alternative is a dot plot/line chart. One thing I like about this is the ability to de-trend, and then plot the same lines. (So you can see deviations from expected, as oppossed to simply the bivariate percentages.) I'm not sure what a reasonable model is though. A default model are the residuals from the cross-tab table, in this case it just replicates the original chart though. It strikes me (both from the original bubble plot and this dot chart) that there is more binning at the extremes, but I'm not sure of a way off-hand to quantify that. There are always more fancy things you could do (like a network graph that has the two quartile sets as nodes and shows weighted lines). But I think these examples are basically all you need.
Match Quality Graph
I think the current charts show the data pretty well. The stacked bar chart has such nice progressions it is easier to follow along than most stacked bar charts. The original bubble chart shows that t
Match Quality Graph I think the current charts show the data pretty well. The stacked bar chart has such nice progressions it is easier to follow along than most stacked bar charts. The original bubble chart shows that there is a reasonable correlation between the two (I calculated it at 0.36). One alternative is a dot plot/line chart. One thing I like about this is the ability to de-trend, and then plot the same lines. (So you can see deviations from expected, as oppossed to simply the bivariate percentages.) I'm not sure what a reasonable model is though. A default model are the residuals from the cross-tab table, in this case it just replicates the original chart though. It strikes me (both from the original bubble plot and this dot chart) that there is more binning at the extremes, but I'm not sure of a way off-hand to quantify that. There are always more fancy things you could do (like a network graph that has the two quartile sets as nodes and shows weighted lines). But I think these examples are basically all you need.
Match Quality Graph I think the current charts show the data pretty well. The stacked bar chart has such nice progressions it is easier to follow along than most stacked bar charts. The original bubble chart shows that t
40,671
Equivalent of a flipped lognormal distribution
A reversed Lognormal ... I will use the notation here that is common in defining the Johnson family, since the latter commonly provides a 3 or 4 parameter version of the Lognormal that captures that which you seek. If $Z \sim N(0,1)$, and $Y=\exp\big({\frac{Z-\gamma}{\delta }}\big)$, then $Y$ has a Lognormal distribution with pdf say $f(y)$: $$f(y) = \frac{\delta}{y \sqrt{2 \pi }} {\exp\big[{-\frac{1}{2} \big(\gamma +\delta \log (y)\big)^2}\big]} \quad \quad \text{ for } y > 0$$ Applying a second transform $X=\xi -Y$ yields the reversed Lognormal that you seek, with pdf say $g(x)$: $$g(x) = \frac{\delta}{(\xi -x) \sqrt{2 \pi }} {\exp\big[{-\frac{1}{2} \big(\gamma +\delta \log (\xi -x)\big)^2}\big]} \quad \quad \text{ for } x< \xi$$ Example The following diagram represents grouped data from Table 1 in Pretorius (1930, p.148). Here, $X$ denotes barometric height (grouped data), while the vertical axis denotes observed frequency. The blue square curve represents the grouped data The red curve is a fitted reverse Lognormal using the automated JohnsonSL function from the mathStatica package for Mathematica. References Pretorius, S. J. (1930), Skew bivariate frequency surfaces, examined in the light of numerical illustrations, Biometrika, 22, 109-223.
Equivalent of a flipped lognormal distribution
A reversed Lognormal ... I will use the notation here that is common in defining the Johnson family, since the latter commonly provides a 3 or 4 parameter version of the Lognormal that captures that
Equivalent of a flipped lognormal distribution A reversed Lognormal ... I will use the notation here that is common in defining the Johnson family, since the latter commonly provides a 3 or 4 parameter version of the Lognormal that captures that which you seek. If $Z \sim N(0,1)$, and $Y=\exp\big({\frac{Z-\gamma}{\delta }}\big)$, then $Y$ has a Lognormal distribution with pdf say $f(y)$: $$f(y) = \frac{\delta}{y \sqrt{2 \pi }} {\exp\big[{-\frac{1}{2} \big(\gamma +\delta \log (y)\big)^2}\big]} \quad \quad \text{ for } y > 0$$ Applying a second transform $X=\xi -Y$ yields the reversed Lognormal that you seek, with pdf say $g(x)$: $$g(x) = \frac{\delta}{(\xi -x) \sqrt{2 \pi }} {\exp\big[{-\frac{1}{2} \big(\gamma +\delta \log (\xi -x)\big)^2}\big]} \quad \quad \text{ for } x< \xi$$ Example The following diagram represents grouped data from Table 1 in Pretorius (1930, p.148). Here, $X$ denotes barometric height (grouped data), while the vertical axis denotes observed frequency. The blue square curve represents the grouped data The red curve is a fitted reverse Lognormal using the automated JohnsonSL function from the mathStatica package for Mathematica. References Pretorius, S. J. (1930), Skew bivariate frequency surfaces, examined in the light of numerical illustrations, Biometrika, 22, 109-223.
Equivalent of a flipped lognormal distribution A reversed Lognormal ... I will use the notation here that is common in defining the Johnson family, since the latter commonly provides a 3 or 4 parameter version of the Lognormal that captures that
40,672
Equivalent of a flipped lognormal distribution
Independent of scale (min,max of x-values), a beta distribution can have a left tail, and so can a power function distribution. However, if your data did result in a left tail on a histogram, you could probably fit it very well using the stable distribution, which has four parameters. The stable is used in QF (quantitative finance) to fit log-returns of asset prices, and can take on mixtures of distributions like Cauchy, Laplace, non-central Student's t, beta, logistic, normal, etc. Don't look for it in software packages, since it's not that popular of a distribution in statistics.
Equivalent of a flipped lognormal distribution
Independent of scale (min,max of x-values), a beta distribution can have a left tail, and so can a power function distribution. However, if your data did result in a left tail on a histogram, you cou
Equivalent of a flipped lognormal distribution Independent of scale (min,max of x-values), a beta distribution can have a left tail, and so can a power function distribution. However, if your data did result in a left tail on a histogram, you could probably fit it very well using the stable distribution, which has four parameters. The stable is used in QF (quantitative finance) to fit log-returns of asset prices, and can take on mixtures of distributions like Cauchy, Laplace, non-central Student's t, beta, logistic, normal, etc. Don't look for it in software packages, since it's not that popular of a distribution in statistics.
Equivalent of a flipped lognormal distribution Independent of scale (min,max of x-values), a beta distribution can have a left tail, and so can a power function distribution. However, if your data did result in a left tail on a histogram, you cou
40,673
How to find a maximum likelihood estimator for a discrete parameter?
This problem is simpler than it might look: although it might get confusing when one tries to apply routine Calculus methods, it is easy when worked from general principles. By definition, the likelihood $\mathcal L$ is the probability of the data. Since the data are (implicitly) assumed independent, this is the product of the individual probability densities, each equal to $(n+1/2)(x_i^2)^n$. Consequently, as shown in the question, $$\mathcal{L}(n) = \prod_{i=1}^m \left((n+1/2)x_i^{2n}\right) = (n+1/2)^m \left(\prod_{i=1}^m x_i^2\right)^n.$$ The only part depending on the data is that product on the right. Since it is almost surely positive for any of the $n$ under consideration, we may write it in terms of its logarithm. A convenient multiple of that is the mean log of the squared data, $$q=\frac{1}{m}\log\prod_{i=1}^m x_i^2.$$ Note that $q$ depends on the data, but not on the unknown parameter $n$: it will be the test statistic on which the Maximum Likelihood estimate is based. Indeed, let's take logs of both sides, obtaining $$\log\mathcal{L}(n) = m\log(n+1/2) + mnq.$$ Observe that since $|x_i| \lt 1$ for all $i$, $q \lt 0$. To maximize $\mathcal{L}$ we merely have to select the largest of the four values with $n=1,2,3,4$: namely, $$\eqalign{\log \mathcal{L}(1) &= m\log(3/2) + mq,\\ \log \mathcal{L}(2) &= m\log(5/2) + 2mq,\\ \log \mathcal{L}(3) &= m\log(7/2) + 3mq,\\ \log \mathcal{L}(4) &= m\log(9/2) + 4mq.}$$ From row to row the $m\log(n+1/2)$ terms increase, but they do so more and more slowly; yet the $nmq$ terms decrease the value of $\log\mathcal L(n)$ at a constant rate of $m|q|$. Thus, the largest value of $(1/m)\log\mathcal L$--which corresponds to the largest value of $\mathcal L$ itself--is attained at the point where, in scanning these four values, $|q|$ first exceeds $$\log((n+1)+1/2) - \log(n+1/2) = \log\left(\frac{2n+3}{2n+1}\right).$$ This leads to an extremely simple procedure that can be specified even before collecting the data. Namely, The increasing sequence $\log(5/3) \gt \log(7/5) \gt \log(9/7)$ partitions the real numbers into four intervals $$I_1=(-\infty, \log\frac{9}{7}],\ I_2=[\log\frac{9}{7}, \log\frac{7}{5}],\ I_3=[\log\frac{7}{5}, \log\frac{5}{3}],\ I_4=[\log\frac{5}{3},\infty).$$ If $|q|\in I_j$, pick $\hat n=j$ as the maximum likelihood estimator. If $|q|$ lies at the common boundary of two intervals, they give two MLEs for $n$. For each $n=1,2,3,4$, this procedure was applied to $1000$ independent samples of size $10$, then $1000$ more independent samples of size $500$. The tabulation of the estimates shows decent correspondence between $n$ and $\hat n$ for the small samples--which is as much as one might hope--and near perfect correspondence for the large samples--which is where the Maximum Likelihood method ought to perform well. Here are the results (which can be reproduced with the following R code): $`m = 10` MLE=1 MLE=2 MLE=3 MLE=4 n=1 753 169 15 1 n=2 213 488 241 77 n=3 27 222 340 283 n=4 7 121 404 639 $`m = 500` MLE=1 MLE=2 MLE=3 MLE=4 n=1 1000 0 0 0 n=2 0 999 0 0 n=3 0 1 998 2 n=4 0 0 2 998 For instance, when the true parameter was $n=2$ and the sample size was only $m=10$, the top table shows the MLE was correct $488$ out of $1000$ times and was off by one (that is, estimating $n$ as either $1$ or $3$) $213+241$ other times. On the whole, the MLE appears a little biased towards the middle values for small $m$ and extremely accurate for large $m$. # # Generate random values. # rpow <- function(n, p) { q <- runif(n) i <- sample.int(2, n, replace=TRUE) ifelse(i==1, -1, +1) * q^(1/(2*p+1)) } # # Confirm `rpow` works as intended by matching histograms to the PDFs. # par(mfrow=c(1,4)) for (n in 1:4) { hist(rpow(1e4, n), main=paste("n =", n), freq=FALSE) curve(x^(2*n)*(n+1/2), add=TRUE, col="Red", lwd=2) } # # Test the MLE. # MLE.pow <- function(x, breaks=log(c(5/3, 7/5, 9/7))) { # Given data `x`, return the MLE in {1,2,3,4}. m <- length(x) q <- sum(log(x^2)) / m sum(abs(q) <= breaks) + 1 } m <- c(10,500) # Specify sample sizes to test set.seed(17) # Create a reproducible starting point sim <- lapply(m, function(m) { x <- replicate(1e3, sapply(1:4, function(n) MLE.pow(rpow(m, n)))) results <- apply(x, 1, tabulate, nbins=4) # Tabulate the MLEs rownames(results) <- paste0("n=", 1:4) colnames(results) <- paste0("MLE=", 1:4) results }) names(sim) <- paste("m =", m) print(sim)
How to find a maximum likelihood estimator for a discrete parameter?
This problem is simpler than it might look: although it might get confusing when one tries to apply routine Calculus methods, it is easy when worked from general principles. By definition, the likeli
How to find a maximum likelihood estimator for a discrete parameter? This problem is simpler than it might look: although it might get confusing when one tries to apply routine Calculus methods, it is easy when worked from general principles. By definition, the likelihood $\mathcal L$ is the probability of the data. Since the data are (implicitly) assumed independent, this is the product of the individual probability densities, each equal to $(n+1/2)(x_i^2)^n$. Consequently, as shown in the question, $$\mathcal{L}(n) = \prod_{i=1}^m \left((n+1/2)x_i^{2n}\right) = (n+1/2)^m \left(\prod_{i=1}^m x_i^2\right)^n.$$ The only part depending on the data is that product on the right. Since it is almost surely positive for any of the $n$ under consideration, we may write it in terms of its logarithm. A convenient multiple of that is the mean log of the squared data, $$q=\frac{1}{m}\log\prod_{i=1}^m x_i^2.$$ Note that $q$ depends on the data, but not on the unknown parameter $n$: it will be the test statistic on which the Maximum Likelihood estimate is based. Indeed, let's take logs of both sides, obtaining $$\log\mathcal{L}(n) = m\log(n+1/2) + mnq.$$ Observe that since $|x_i| \lt 1$ for all $i$, $q \lt 0$. To maximize $\mathcal{L}$ we merely have to select the largest of the four values with $n=1,2,3,4$: namely, $$\eqalign{\log \mathcal{L}(1) &= m\log(3/2) + mq,\\ \log \mathcal{L}(2) &= m\log(5/2) + 2mq,\\ \log \mathcal{L}(3) &= m\log(7/2) + 3mq,\\ \log \mathcal{L}(4) &= m\log(9/2) + 4mq.}$$ From row to row the $m\log(n+1/2)$ terms increase, but they do so more and more slowly; yet the $nmq$ terms decrease the value of $\log\mathcal L(n)$ at a constant rate of $m|q|$. Thus, the largest value of $(1/m)\log\mathcal L$--which corresponds to the largest value of $\mathcal L$ itself--is attained at the point where, in scanning these four values, $|q|$ first exceeds $$\log((n+1)+1/2) - \log(n+1/2) = \log\left(\frac{2n+3}{2n+1}\right).$$ This leads to an extremely simple procedure that can be specified even before collecting the data. Namely, The increasing sequence $\log(5/3) \gt \log(7/5) \gt \log(9/7)$ partitions the real numbers into four intervals $$I_1=(-\infty, \log\frac{9}{7}],\ I_2=[\log\frac{9}{7}, \log\frac{7}{5}],\ I_3=[\log\frac{7}{5}, \log\frac{5}{3}],\ I_4=[\log\frac{5}{3},\infty).$$ If $|q|\in I_j$, pick $\hat n=j$ as the maximum likelihood estimator. If $|q|$ lies at the common boundary of two intervals, they give two MLEs for $n$. For each $n=1,2,3,4$, this procedure was applied to $1000$ independent samples of size $10$, then $1000$ more independent samples of size $500$. The tabulation of the estimates shows decent correspondence between $n$ and $\hat n$ for the small samples--which is as much as one might hope--and near perfect correspondence for the large samples--which is where the Maximum Likelihood method ought to perform well. Here are the results (which can be reproduced with the following R code): $`m = 10` MLE=1 MLE=2 MLE=3 MLE=4 n=1 753 169 15 1 n=2 213 488 241 77 n=3 27 222 340 283 n=4 7 121 404 639 $`m = 500` MLE=1 MLE=2 MLE=3 MLE=4 n=1 1000 0 0 0 n=2 0 999 0 0 n=3 0 1 998 2 n=4 0 0 2 998 For instance, when the true parameter was $n=2$ and the sample size was only $m=10$, the top table shows the MLE was correct $488$ out of $1000$ times and was off by one (that is, estimating $n$ as either $1$ or $3$) $213+241$ other times. On the whole, the MLE appears a little biased towards the middle values for small $m$ and extremely accurate for large $m$. # # Generate random values. # rpow <- function(n, p) { q <- runif(n) i <- sample.int(2, n, replace=TRUE) ifelse(i==1, -1, +1) * q^(1/(2*p+1)) } # # Confirm `rpow` works as intended by matching histograms to the PDFs. # par(mfrow=c(1,4)) for (n in 1:4) { hist(rpow(1e4, n), main=paste("n =", n), freq=FALSE) curve(x^(2*n)*(n+1/2), add=TRUE, col="Red", lwd=2) } # # Test the MLE. # MLE.pow <- function(x, breaks=log(c(5/3, 7/5, 9/7))) { # Given data `x`, return the MLE in {1,2,3,4}. m <- length(x) q <- sum(log(x^2)) / m sum(abs(q) <= breaks) + 1 } m <- c(10,500) # Specify sample sizes to test set.seed(17) # Create a reproducible starting point sim <- lapply(m, function(m) { x <- replicate(1e3, sapply(1:4, function(n) MLE.pow(rpow(m, n)))) results <- apply(x, 1, tabulate, nbins=4) # Tabulate the MLEs rownames(results) <- paste0("n=", 1:4) colnames(results) <- paste0("MLE=", 1:4) results }) names(sim) <- paste("m =", m) print(sim)
How to find a maximum likelihood estimator for a discrete parameter? This problem is simpler than it might look: although it might get confusing when one tries to apply routine Calculus methods, it is easy when worked from general principles. By definition, the likeli
40,674
How to find a maximum likelihood estimator for a discrete parameter?
This has a few tricky points, so let's work it out. First, we note that $2n$ is an even number, so the function that wants to be a density will be non-negative from that respect, as it should, even though the variable $X$ may take negative values. Second we need to determine the value of $c$ so that we have a proper density. We require $$\int_{-1}^1 cx^{2n}dx =1 \implies \frac{c}{2n+1}x^{2n+1} \Big|^1_{-1} =1$$ and since $2n+1$ is an odd number, we get $$\frac{c}{2n+1}[1-(-1)] =1 \implies c= n+1/2$$ ...as already noted in the comments. Therefore $$ f_X(x) = (n+1/2)x^{2n}, \;\;\; -1<x<1$$ and the likelihood function from an i.i.d. sample is ($I\{\}$ being the indicator function) $$L = I_{\{-1<x<1\}}\cdot (n+1/2)^m\prod_{i=1}^mx_i^{2n} $$ We usually consider the log-likelihood for various beneficial reasons, but here, if we take logarithms we will be looking at $\ln x_i$ which is not defined if $x_i\leq 0$. But if one attempted to maximize the likelihood directly to avoid taking logs it would again hit on the same problem -the logarithm of the $x$-values would again appear if we considered the derivative with respect to $n$. But since $x_i^{2n}$ is non-negative, we can write $$L = I_{\{-1<x<1\}}\cdot (n+1/2)^m\prod_{i=1}^m|x_i|^{2n} $$ $$\implies\ln L = \ln \left(I_{\{-1<x<1\}}\right) + m\ln(n+1/2)+2n\sum_{i=1}^m\ln|x_i|$$ ..which leaves us only with the problem of obtaining a realized value $x_i=0$ exactly. Well, from a theoretic point of view we invoke the zero-probability of a continuous r.v. taking a specific value, while from an applied point of view, if our sample contains an exact zero value, we can just discard it. While this log-likelihood is strictly concave in $n$ and has a straightforward f.o.c $$\frac{\partial \ln L}{\partial n} = \frac {m}{n+1/2} + 2\sum_{i=1}^m\ln|x_i|$$ $$\implies \hat n = \frac {m}{-2\sum_{i=1}^m\ln|x_i|} - \frac 12$$ ...we have just ignored the restrictions on the values of $n$. This is a discrete-optimization problem. Nothing guarantees that the above expression will give an integer, or that it will fall in between $1$ and $4$. After a little thinking, instead of considering derivatives etc as usual and dance around $\hat n$, it would be simpler to evaluate the log-likelihood at the four possible values of $n$ and see for which it attains the highest value.
How to find a maximum likelihood estimator for a discrete parameter?
This has a few tricky points, so let's work it out. First, we note that $2n$ is an even number, so the function that wants to be a density will be non-negative from that respect, as it should, even
How to find a maximum likelihood estimator for a discrete parameter? This has a few tricky points, so let's work it out. First, we note that $2n$ is an even number, so the function that wants to be a density will be non-negative from that respect, as it should, even though the variable $X$ may take negative values. Second we need to determine the value of $c$ so that we have a proper density. We require $$\int_{-1}^1 cx^{2n}dx =1 \implies \frac{c}{2n+1}x^{2n+1} \Big|^1_{-1} =1$$ and since $2n+1$ is an odd number, we get $$\frac{c}{2n+1}[1-(-1)] =1 \implies c= n+1/2$$ ...as already noted in the comments. Therefore $$ f_X(x) = (n+1/2)x^{2n}, \;\;\; -1<x<1$$ and the likelihood function from an i.i.d. sample is ($I\{\}$ being the indicator function) $$L = I_{\{-1<x<1\}}\cdot (n+1/2)^m\prod_{i=1}^mx_i^{2n} $$ We usually consider the log-likelihood for various beneficial reasons, but here, if we take logarithms we will be looking at $\ln x_i$ which is not defined if $x_i\leq 0$. But if one attempted to maximize the likelihood directly to avoid taking logs it would again hit on the same problem -the logarithm of the $x$-values would again appear if we considered the derivative with respect to $n$. But since $x_i^{2n}$ is non-negative, we can write $$L = I_{\{-1<x<1\}}\cdot (n+1/2)^m\prod_{i=1}^m|x_i|^{2n} $$ $$\implies\ln L = \ln \left(I_{\{-1<x<1\}}\right) + m\ln(n+1/2)+2n\sum_{i=1}^m\ln|x_i|$$ ..which leaves us only with the problem of obtaining a realized value $x_i=0$ exactly. Well, from a theoretic point of view we invoke the zero-probability of a continuous r.v. taking a specific value, while from an applied point of view, if our sample contains an exact zero value, we can just discard it. While this log-likelihood is strictly concave in $n$ and has a straightforward f.o.c $$\frac{\partial \ln L}{\partial n} = \frac {m}{n+1/2} + 2\sum_{i=1}^m\ln|x_i|$$ $$\implies \hat n = \frac {m}{-2\sum_{i=1}^m\ln|x_i|} - \frac 12$$ ...we have just ignored the restrictions on the values of $n$. This is a discrete-optimization problem. Nothing guarantees that the above expression will give an integer, or that it will fall in between $1$ and $4$. After a little thinking, instead of considering derivatives etc as usual and dance around $\hat n$, it would be simpler to evaluate the log-likelihood at the four possible values of $n$ and see for which it attains the highest value.
How to find a maximum likelihood estimator for a discrete parameter? This has a few tricky points, so let's work it out. First, we note that $2n$ is an even number, so the function that wants to be a density will be non-negative from that respect, as it should, even
40,675
distance measure of two discrete probability histograms (distance between two vectors)
Jensen-Shannon distance is the 1st thing I'd consider. If you don't insist on having a "distance function", you can directly use Jensen–Shannon divergence, from which this distance is derived. JS divergence is widely used to measure the difference between two probability distributions. It fits your case, as the inputs are two probability vectors. JS divergence is a straightforward modification of the well-known Kullback–Leibler divergence. Generally, KL and JS divergence require the input vectors have nonzero entries. In case of zeros in the input, many people simply choose to throw out those values. Check https://mathoverflow.net/a/72672 for more details on this issue.
distance measure of two discrete probability histograms (distance between two vectors)
Jensen-Shannon distance is the 1st thing I'd consider. If you don't insist on having a "distance function", you can directly use Jensen–Shannon divergence, from which this distance is derived. JS dive
distance measure of two discrete probability histograms (distance between two vectors) Jensen-Shannon distance is the 1st thing I'd consider. If you don't insist on having a "distance function", you can directly use Jensen–Shannon divergence, from which this distance is derived. JS divergence is widely used to measure the difference between two probability distributions. It fits your case, as the inputs are two probability vectors. JS divergence is a straightforward modification of the well-known Kullback–Leibler divergence. Generally, KL and JS divergence require the input vectors have nonzero entries. In case of zeros in the input, many people simply choose to throw out those values. Check https://mathoverflow.net/a/72672 for more details on this issue.
distance measure of two discrete probability histograms (distance between two vectors) Jensen-Shannon distance is the 1st thing I'd consider. If you don't insist on having a "distance function", you can directly use Jensen–Shannon divergence, from which this distance is derived. JS dive
40,676
distance measure of two discrete probability histograms (distance between two vectors)
There is also the Wasserstein metric, which has become more popular in the Bayesian inference literature. In your case, the 'wasserstein1d' function from package 'transport' should do the trick: x <- rnorm(200) y <- rnorm(150,2) wasserstein1d(x,y)
distance measure of two discrete probability histograms (distance between two vectors)
There is also the Wasserstein metric, which has become more popular in the Bayesian inference literature. In your case, the 'wasserstein1d' function from package 'transport' should do the trick: x <
distance measure of two discrete probability histograms (distance between two vectors) There is also the Wasserstein metric, which has become more popular in the Bayesian inference literature. In your case, the 'wasserstein1d' function from package 'transport' should do the trick: x <- rnorm(200) y <- rnorm(150,2) wasserstein1d(x,y)
distance measure of two discrete probability histograms (distance between two vectors) There is also the Wasserstein metric, which has become more popular in the Bayesian inference literature. In your case, the 'wasserstein1d' function from package 'transport' should do the trick: x <
40,677
To select variables or not in logistic regression
Approaches that naively select model terms based on some p-values or some AIC cut-offs (either in a multivariate model via some kind of stepwise or other selection or by looking at lots of univariate models) lead to extremely problematic fits that may fit the particular dataset well, but will otherwise not be useful. Models constructed in such a fashion tend to wrongly identify variables as relevant that are not (while not identifying truly relevant variables - if we assume the used model is some reasonable approximation to nature, in which some variables are relevant and some are not) and have poor predictive properties on new datasets. Nevertheless such approaches are still often used and one can even occasionally get such work published in some well-respected journals, but are quite thoroughly discredited in the statistical community. There are a lot of more appropriate approaches, e.g. bootstrapping naive model building approaches, cross-validation, random forests, model averaging, variable selection priors etc. that should be used instead.
To select variables or not in logistic regression
Approaches that naively select model terms based on some p-values or some AIC cut-offs (either in a multivariate model via some kind of stepwise or other selection or by looking at lots of univariate
To select variables or not in logistic regression Approaches that naively select model terms based on some p-values or some AIC cut-offs (either in a multivariate model via some kind of stepwise or other selection or by looking at lots of univariate models) lead to extremely problematic fits that may fit the particular dataset well, but will otherwise not be useful. Models constructed in such a fashion tend to wrongly identify variables as relevant that are not (while not identifying truly relevant variables - if we assume the used model is some reasonable approximation to nature, in which some variables are relevant and some are not) and have poor predictive properties on new datasets. Nevertheless such approaches are still often used and one can even occasionally get such work published in some well-respected journals, but are quite thoroughly discredited in the statistical community. There are a lot of more appropriate approaches, e.g. bootstrapping naive model building approaches, cross-validation, random forests, model averaging, variable selection priors etc. that should be used instead.
To select variables or not in logistic regression Approaches that naively select model terms based on some p-values or some AIC cut-offs (either in a multivariate model via some kind of stepwise or other selection or by looking at lots of univariate
40,678
What's wrong with data-guided modeling in regression?
First, there is no way to "guarantee" any model other than perhaps in physics. As discussed in detail in my book and Course Notes there is a safe strategy for assigning d.f. to predictors based on a properly masked analysis of "predictive potential" when subject matter knowledge is lacking. For categorical variables, in the absence of any subject matter knowledge, this may involve combining the least frequent categories so that the total number of categories analyzed equals one more than the d.f. you wish to devote to that predictor. There is a perfect analogy to help understand the harm done by data-guided modeling. Suppose you have $k$ groups and wanted to bring evidence for differences in population means between two or more of the groups. ANOVA with $k-1$ numerator d.f. provides a perfect multiplicity adjustment and yields perfect control of type I error if model assumptions are close to being true. A data-guided change from this approach would be to decide which of the groups should be pooled before doing a comparison involving fewer than $k-1$ d.f., by combining means that were observed to be "close". The resulting test would not come close to preserving type I error. This is exactly the problem with stepwise variable selection or with using the data to tell you how many knots to use for a continuous predictor. The latter case was studied in detail (using a quadratic fit instead of splines) by Grambsch & O'Brien, whose excellent paper is summarized in my notes.
What's wrong with data-guided modeling in regression?
First, there is no way to "guarantee" any model other than perhaps in physics. As discussed in detail in my book and Course Notes there is a safe strategy for assigning d.f. to predictors based on a
What's wrong with data-guided modeling in regression? First, there is no way to "guarantee" any model other than perhaps in physics. As discussed in detail in my book and Course Notes there is a safe strategy for assigning d.f. to predictors based on a properly masked analysis of "predictive potential" when subject matter knowledge is lacking. For categorical variables, in the absence of any subject matter knowledge, this may involve combining the least frequent categories so that the total number of categories analyzed equals one more than the d.f. you wish to devote to that predictor. There is a perfect analogy to help understand the harm done by data-guided modeling. Suppose you have $k$ groups and wanted to bring evidence for differences in population means between two or more of the groups. ANOVA with $k-1$ numerator d.f. provides a perfect multiplicity adjustment and yields perfect control of type I error if model assumptions are close to being true. A data-guided change from this approach would be to decide which of the groups should be pooled before doing a comparison involving fewer than $k-1$ d.f., by combining means that were observed to be "close". The resulting test would not come close to preserving type I error. This is exactly the problem with stepwise variable selection or with using the data to tell you how many knots to use for a continuous predictor. The latter case was studied in detail (using a quadratic fit instead of splines) by Grambsch & O'Brien, whose excellent paper is summarized in my notes.
What's wrong with data-guided modeling in regression? First, there is no way to "guarantee" any model other than perhaps in physics. As discussed in detail in my book and Course Notes there is a safe strategy for assigning d.f. to predictors based on a
40,679
What's wrong with data-guided modeling in regression?
a) hopefully it is clear that standard statistical measures are dealing with the chance of getting a result at random and do not include the possibilities of you eyeballing the data and using your own particular experience and perception. b) Prof Harrell doesn't say you couldnt use bootstrap, just that its too much work... you would have to run multiple bootstraps, then for each bootrap data sample manually eyeball the data decide on your fitting transformation and then run a regression. Bootstrap is only practical when you have a fully automated process.
What's wrong with data-guided modeling in regression?
a) hopefully it is clear that standard statistical measures are dealing with the chance of getting a result at random and do not include the possibilities of you eyeballing the data and using your ow
What's wrong with data-guided modeling in regression? a) hopefully it is clear that standard statistical measures are dealing with the chance of getting a result at random and do not include the possibilities of you eyeballing the data and using your own particular experience and perception. b) Prof Harrell doesn't say you couldnt use bootstrap, just that its too much work... you would have to run multiple bootstraps, then for each bootrap data sample manually eyeball the data decide on your fitting transformation and then run a regression. Bootstrap is only practical when you have a fully automated process.
What's wrong with data-guided modeling in regression? a) hopefully it is clear that standard statistical measures are dealing with the chance of getting a result at random and do not include the possibilities of you eyeballing the data and using your ow
40,680
Different results using Brier score and Logarithmic scoring rule
Without getting into the Bayesian vs. frequentist part of your question, the two proper accuracy scores are rewarding different things and it's not surprising they behave differently. The logarithmic score rewards more extreme predictions that are in the right direction. This score can be ruined by a single prediction of probability of 0 or 1 that is in the wrong direction, due to taking the log of zero. The logarithmic rule is a rescaling of the gold standard optimization criteria (in the absence of other knowledge that Bayesians would use in the prior distribution) the log likelihood so in a sense it is the best accuracy score to use for binary $Y$.
Different results using Brier score and Logarithmic scoring rule
Without getting into the Bayesian vs. frequentist part of your question, the two proper accuracy scores are rewarding different things and it's not surprising they behave differently. The logarithmic
Different results using Brier score and Logarithmic scoring rule Without getting into the Bayesian vs. frequentist part of your question, the two proper accuracy scores are rewarding different things and it's not surprising they behave differently. The logarithmic score rewards more extreme predictions that are in the right direction. This score can be ruined by a single prediction of probability of 0 or 1 that is in the wrong direction, due to taking the log of zero. The logarithmic rule is a rescaling of the gold standard optimization criteria (in the absence of other knowledge that Bayesians would use in the prior distribution) the log likelihood so in a sense it is the best accuracy score to use for binary $Y$.
Different results using Brier score and Logarithmic scoring rule Without getting into the Bayesian vs. frequentist part of your question, the two proper accuracy scores are rewarding different things and it's not surprising they behave differently. The logarithmic
40,681
Combining Binomial Random Variables
[I've put some material on how to sum geometric progressions and expectation of geometric random variables at the end; this answer relies on such results but they're fairly well known so I figured I wouldn't start with them. If any readers are not, then skip to the end to see one way to get them out. It's worth doing some of those yourself (without peeking) so you fix the idea in your mind.] If you assume player 1 must win then you need to work out conditional probabilities. When you condition on player 1 winning your calculations are incorrect. $P(A|B) = \frac{P(AB)}{P(B)}$ $P(\text{at toss }k\text{ player 1 wins}|\text{player 1 wins})= \frac{P(\text{player 1 wins on toss }k)}{P(\text{player 1 wins})}$ $=\frac{p_1(1-p_1)^{k-1}(1-p_2)^{k-1}}{\sum_{j=1}^\infty p_1(1-p_1)^{j-1}(1-p_2)^{j-1}}$ Now let's save ourselves some effort: Let $1-p^*=(1-p_1)(1-p_2)$ $=\frac{p_1(1-p^*)^{k-1}}{p_1\sum_{j=1}^\infty (1-p^*)^{j-1}}$ $=\frac{p^*(1-p^*)^{k-1}}{p^*\sum_{j=1}^\infty (1-p^*)^{j-1}}$ Now the numerator is the pmf of a geometric random variable and the denominator is the sum of that geometric pmf (which sums to 1): $={p^*(1-p^*)^{k-1}}$ (with some thought you can arrive at the same answer directly, without any algebraic manipulation) Now the conditional expectation comes out immediately to be $E(\text{number of tosses until player 1 wins}|\text{player 1 wins}))=\frac{1}{p^*}$ Summing a geometric series: $\qquad\qquad\quad\: S_0\:=\:p+p(1-p)+p(1-p)^2+p(1-p)^3+...$ $\qquad\:(1-p)S_0\:=\:\:\:\quad p(1-p)+p(1-p)^2+p(1-p)^3+...$ $(1-(1-p)) S_0=\:p+\quad\, 0\quad\:\: +\quad\: 0\qquad +\quad\: 0\qquad +...$ So $pS_0=p$, or $S_0=1$. If you need to see how to get the expectation of a geometric($p$) random variable, we can use the same trick as above - write out the terms in $S_1=\sum_{k=1}^\infty kp(1-p)^{k-1}$ one by one, and then under it write out the terms in $(1-p)S_1$, but shifted so that the second set of terms are all moved one to the right. Then take differences term by term and this time you're left with a geometric series (rather than a single value and totally cancelled terms), but we already know how to sum geometric series, we did it with $S_0$ above.
Combining Binomial Random Variables
[I've put some material on how to sum geometric progressions and expectation of geometric random variables at the end; this answer relies on such results but they're fairly well known so I figured I w
Combining Binomial Random Variables [I've put some material on how to sum geometric progressions and expectation of geometric random variables at the end; this answer relies on such results but they're fairly well known so I figured I wouldn't start with them. If any readers are not, then skip to the end to see one way to get them out. It's worth doing some of those yourself (without peeking) so you fix the idea in your mind.] If you assume player 1 must win then you need to work out conditional probabilities. When you condition on player 1 winning your calculations are incorrect. $P(A|B) = \frac{P(AB)}{P(B)}$ $P(\text{at toss }k\text{ player 1 wins}|\text{player 1 wins})= \frac{P(\text{player 1 wins on toss }k)}{P(\text{player 1 wins})}$ $=\frac{p_1(1-p_1)^{k-1}(1-p_2)^{k-1}}{\sum_{j=1}^\infty p_1(1-p_1)^{j-1}(1-p_2)^{j-1}}$ Now let's save ourselves some effort: Let $1-p^*=(1-p_1)(1-p_2)$ $=\frac{p_1(1-p^*)^{k-1}}{p_1\sum_{j=1}^\infty (1-p^*)^{j-1}}$ $=\frac{p^*(1-p^*)^{k-1}}{p^*\sum_{j=1}^\infty (1-p^*)^{j-1}}$ Now the numerator is the pmf of a geometric random variable and the denominator is the sum of that geometric pmf (which sums to 1): $={p^*(1-p^*)^{k-1}}$ (with some thought you can arrive at the same answer directly, without any algebraic manipulation) Now the conditional expectation comes out immediately to be $E(\text{number of tosses until player 1 wins}|\text{player 1 wins}))=\frac{1}{p^*}$ Summing a geometric series: $\qquad\qquad\quad\: S_0\:=\:p+p(1-p)+p(1-p)^2+p(1-p)^3+...$ $\qquad\:(1-p)S_0\:=\:\:\:\quad p(1-p)+p(1-p)^2+p(1-p)^3+...$ $(1-(1-p)) S_0=\:p+\quad\, 0\quad\:\: +\quad\: 0\qquad +\quad\: 0\qquad +...$ So $pS_0=p$, or $S_0=1$. If you need to see how to get the expectation of a geometric($p$) random variable, we can use the same trick as above - write out the terms in $S_1=\sum_{k=1}^\infty kp(1-p)^{k-1}$ one by one, and then under it write out the terms in $(1-p)S_1$, but shifted so that the second set of terms are all moved one to the right. Then take differences term by term and this time you're left with a geometric series (rather than a single value and totally cancelled terms), but we already know how to sum geometric series, we did it with $S_0$ above.
Combining Binomial Random Variables [I've put some material on how to sum geometric progressions and expectation of geometric random variables at the end; this answer relies on such results but they're fairly well known so I figured I w
40,682
Combining Binomial Random Variables
Let us define a round of tosses as two tosses; the first toss by A who tosses a coin with $P(\text{Heads}) = p_1$ and the second toss by B who tosses a coin with $P(\text{Heads}) = p_2$. The outcomes of a round and the corresponding probabilities are $$\begin{matrix} HH & &p_1p_2\\ HT & &p_1(1-p_2)\\ TH & &(1-p_1)p_2\\ TT & &(1-p_1)(1-p_2) \end{matrix}$$ where, if either of the first two outcomes occurs, A wins (with probability $p_1$); in fact, it does not matter in the least whether B tosses a coin at all once A has tossed a Head. Call this event $\mathcal A$ If the third outcome $TH$ occurs, B wins (with probability $(1-p_1)p_2 = p_2 - p_1p_2$; we call this $\mathcal B$. If the fourth outcome $TT$ occurs, nobody wins, and a new round is initiated. This is event $\mathcal C$. Thus, one of the three (disjoint) events $\mathcal{A, B, C}$ can occur on a round. The game ends on a round with probability $p^* = p_1 + p_2 - p_1p_2$ and continues for the next round with probability $1-p^*$. A wins the game if the outcomes of the rounds are any of the following disjoint sequences of events: \begin{align} &\mathcal{A}\\&\mathcal{CA}\\&\mathcal{CCA}\\&\mathcal{CCCA}\\ &\quad\vdots\\&\mathcal{C}^{k-1}\mathcal{A}\\&\quad\vdots \end{align} Thus, $$P(\mathcal A) = p_1 + (1-p^*)p_1 + (1-p^*)^2p_1 + \cdots = \frac{p_1}{p^*}$$ and similarly, \begin{align}P(\mathcal B) &= (1-p_1)p_2 + (1-p^*)(1-p_1)p_2 + (1-p^*)^2(1-p_1)p_2 + \cdots \\ &= \frac{(1-p_1)p_2}{p^*} \\ &= \frac{p^*-p_1}{p^*}\\ &= 1-P(\mathcal A).\end{align} Note that conditioned on the event that the game ended on the round under consideration, the probabilities of the players winning are $$P(\text{A wins}) = \frac{p_1}{p_1 + p_2 - p_1p_2} = \frac{p_1}{p^*}, \quad P(\text{B wins}) = \frac{p_2 - p_1p_2}{p_1 + p_2 - p_1p_2} = \frac{p^*-p_1}{p^*}.$$ These are the same as the unconditional probabilities of $\mathcal A$ and $\mathcal B$ Let $X$ denote the number of rounds till the game ends. $X$ also denotes the number of times that the winner of the game tosses the coin. Then, $X$ is a geometric random variable with parameter $p^* = p_1 + p_2 - p_1p_2$. But, the previous paragraph shows that conditioned on the occurrence of the event $\{X = k\}$, the conditional probability of $\mathcal A$ is the same as the unconditional probability, that is, _for each $k, k =1,2,3,\ldots$, the event $\{X = k\}$ and the event $\mathcal A$ are mutually independent events. Indeed, the random variable $X$ is independent of the event $\mathcal A$. Now, the expected value of $X$ is \begin{align} E[X] &= 1\cdot p^* + 2\cdot (1-p^*)p^* + 3\cdot (1-p^*)^2p^* + \cdots\\ &= p^*\left[1 + 2\cdot (1-p^*) + 3\cdot (1-p^*)^2 + \cdots \right]\\ &= p^* \cdot \frac{1}{(1-(1-p^*))^2}\\ &= p^* \cdot \frac{1}{(p^*)^2}\\ &= \frac{1}{p^*} = \frac{1}{p_1 + p_2 - p_1p_2} \end{align} and this expected value is supremely indifferent to the occurrence or the non-occurrence of $\mathcal A$. In short, the expected number of tosses when A wins the game is $\frac{1}{p^*}$ which is the same as the expected number of tosses when B wins the game.
Combining Binomial Random Variables
Let us define a round of tosses as two tosses; the first toss by A who tosses a coin with $P(\text{Heads}) = p_1$ and the second toss by B who tosses a coin with $P(\text{Heads}) = p_2$. The outcomes
Combining Binomial Random Variables Let us define a round of tosses as two tosses; the first toss by A who tosses a coin with $P(\text{Heads}) = p_1$ and the second toss by B who tosses a coin with $P(\text{Heads}) = p_2$. The outcomes of a round and the corresponding probabilities are $$\begin{matrix} HH & &p_1p_2\\ HT & &p_1(1-p_2)\\ TH & &(1-p_1)p_2\\ TT & &(1-p_1)(1-p_2) \end{matrix}$$ where, if either of the first two outcomes occurs, A wins (with probability $p_1$); in fact, it does not matter in the least whether B tosses a coin at all once A has tossed a Head. Call this event $\mathcal A$ If the third outcome $TH$ occurs, B wins (with probability $(1-p_1)p_2 = p_2 - p_1p_2$; we call this $\mathcal B$. If the fourth outcome $TT$ occurs, nobody wins, and a new round is initiated. This is event $\mathcal C$. Thus, one of the three (disjoint) events $\mathcal{A, B, C}$ can occur on a round. The game ends on a round with probability $p^* = p_1 + p_2 - p_1p_2$ and continues for the next round with probability $1-p^*$. A wins the game if the outcomes of the rounds are any of the following disjoint sequences of events: \begin{align} &\mathcal{A}\\&\mathcal{CA}\\&\mathcal{CCA}\\&\mathcal{CCCA}\\ &\quad\vdots\\&\mathcal{C}^{k-1}\mathcal{A}\\&\quad\vdots \end{align} Thus, $$P(\mathcal A) = p_1 + (1-p^*)p_1 + (1-p^*)^2p_1 + \cdots = \frac{p_1}{p^*}$$ and similarly, \begin{align}P(\mathcal B) &= (1-p_1)p_2 + (1-p^*)(1-p_1)p_2 + (1-p^*)^2(1-p_1)p_2 + \cdots \\ &= \frac{(1-p_1)p_2}{p^*} \\ &= \frac{p^*-p_1}{p^*}\\ &= 1-P(\mathcal A).\end{align} Note that conditioned on the event that the game ended on the round under consideration, the probabilities of the players winning are $$P(\text{A wins}) = \frac{p_1}{p_1 + p_2 - p_1p_2} = \frac{p_1}{p^*}, \quad P(\text{B wins}) = \frac{p_2 - p_1p_2}{p_1 + p_2 - p_1p_2} = \frac{p^*-p_1}{p^*}.$$ These are the same as the unconditional probabilities of $\mathcal A$ and $\mathcal B$ Let $X$ denote the number of rounds till the game ends. $X$ also denotes the number of times that the winner of the game tosses the coin. Then, $X$ is a geometric random variable with parameter $p^* = p_1 + p_2 - p_1p_2$. But, the previous paragraph shows that conditioned on the occurrence of the event $\{X = k\}$, the conditional probability of $\mathcal A$ is the same as the unconditional probability, that is, _for each $k, k =1,2,3,\ldots$, the event $\{X = k\}$ and the event $\mathcal A$ are mutually independent events. Indeed, the random variable $X$ is independent of the event $\mathcal A$. Now, the expected value of $X$ is \begin{align} E[X] &= 1\cdot p^* + 2\cdot (1-p^*)p^* + 3\cdot (1-p^*)^2p^* + \cdots\\ &= p^*\left[1 + 2\cdot (1-p^*) + 3\cdot (1-p^*)^2 + \cdots \right]\\ &= p^* \cdot \frac{1}{(1-(1-p^*))^2}\\ &= p^* \cdot \frac{1}{(p^*)^2}\\ &= \frac{1}{p^*} = \frac{1}{p_1 + p_2 - p_1p_2} \end{align} and this expected value is supremely indifferent to the occurrence or the non-occurrence of $\mathcal A$. In short, the expected number of tosses when A wins the game is $\frac{1}{p^*}$ which is the same as the expected number of tosses when B wins the game.
Combining Binomial Random Variables Let us define a round of tosses as two tosses; the first toss by A who tosses a coin with $P(\text{Heads}) = p_1$ and the second toss by B who tosses a coin with $P(\text{Heads}) = p_2$. The outcomes
40,683
What is the two alternative forced choice paradigm
Two-alternative forced choice is a psychophysical method ("paradigm") used to solicit behavioral or perceptual responses from subjects. The name comes from two aspects of the method. It is called two-alternative because the subjects are shown two alternative stimuli (A or B), and forced choice because they are "forced" to choose one, based on some previously-instructed criteria (e.g., brightness, moving rightward, etc). It is "forced" in the sense that the subject isn't offered a way to avoid answering or choose "none of the above"; it's not actually coercive. The term is sometimes used more loosely to indicate a task where the subject views a single stimulus and must make one of two responses. However, this isn't strictly correct. Macmillin and Creelman (2005) (pg 166) write: "In using the traditional name for this design, we continue an unfortunate historical precedent. The choices made by observer in two-alternative forced choice (2AFC) studies are no more constrained than in other correspondence experiments. As in the one-interval design, the possible stimuli come from one of two categories (Old or New, Loud or Soft) and the experimenter is interested in the correspondence between the correct response and the observer's 'forced choice.' The new feature of the 2AFC design is that both alternatives are presented on every trial in random spatial or temporal order. The observer reports not which stimulus occurred--both did--but in which order." Most other sources seem to agree with this definition: Hautus, 2015; Schneider and Parker, 2013. This distinction is important because a "classic" 2AFC task is much easier than a detection task, and signal detection theory results about performance on one do not always apply for the other. Consider Jeff's lexical decision task, below. In a detection paradigm, you might be shown the string "goke" and asked to decide whether it is a word (no). In the corresponding 2AFC experiment, you might instead be shown "goke" and "joke" and asked to decide which is a word (joke). Macmillin and Creelman present this a bit oddly, but you could also reply by indicating the relative order ("The word came 2nd"). The detection paradigm relies only on your knowledge of the string "goke", while the 2AFC task lets you weigh the (un)familiarity of "goke" against the familiarity of "joke", which provides the observer with extra information. In fact, it can be shown mathematically that an optimal strategy does a factor of $\sqrt{2}$ better on the 2AFC task. As Jeff notes, some fields are less rigorous about this than others. Still, it costs almost nothing (two extra characters!) to describe a task in a way that everyone will unambiguously find "correct" (2AFC vs. yes/no), so I would encourage you to do so.
What is the two alternative forced choice paradigm
Two-alternative forced choice is a psychophysical method ("paradigm") used to solicit behavioral or perceptual responses from subjects. The name comes from two aspects of the method. It is called two-
What is the two alternative forced choice paradigm Two-alternative forced choice is a psychophysical method ("paradigm") used to solicit behavioral or perceptual responses from subjects. The name comes from two aspects of the method. It is called two-alternative because the subjects are shown two alternative stimuli (A or B), and forced choice because they are "forced" to choose one, based on some previously-instructed criteria (e.g., brightness, moving rightward, etc). It is "forced" in the sense that the subject isn't offered a way to avoid answering or choose "none of the above"; it's not actually coercive. The term is sometimes used more loosely to indicate a task where the subject views a single stimulus and must make one of two responses. However, this isn't strictly correct. Macmillin and Creelman (2005) (pg 166) write: "In using the traditional name for this design, we continue an unfortunate historical precedent. The choices made by observer in two-alternative forced choice (2AFC) studies are no more constrained than in other correspondence experiments. As in the one-interval design, the possible stimuli come from one of two categories (Old or New, Loud or Soft) and the experimenter is interested in the correspondence between the correct response and the observer's 'forced choice.' The new feature of the 2AFC design is that both alternatives are presented on every trial in random spatial or temporal order. The observer reports not which stimulus occurred--both did--but in which order." Most other sources seem to agree with this definition: Hautus, 2015; Schneider and Parker, 2013. This distinction is important because a "classic" 2AFC task is much easier than a detection task, and signal detection theory results about performance on one do not always apply for the other. Consider Jeff's lexical decision task, below. In a detection paradigm, you might be shown the string "goke" and asked to decide whether it is a word (no). In the corresponding 2AFC experiment, you might instead be shown "goke" and "joke" and asked to decide which is a word (joke). Macmillin and Creelman present this a bit oddly, but you could also reply by indicating the relative order ("The word came 2nd"). The detection paradigm relies only on your knowledge of the string "goke", while the 2AFC task lets you weigh the (un)familiarity of "goke" against the familiarity of "joke", which provides the observer with extra information. In fact, it can be shown mathematically that an optimal strategy does a factor of $\sqrt{2}$ better on the 2AFC task. As Jeff notes, some fields are less rigorous about this than others. Still, it costs almost nothing (two extra characters!) to describe a task in a way that everyone will unambiguously find "correct" (2AFC vs. yes/no), so I would encourage you to do so.
What is the two alternative forced choice paradigm Two-alternative forced choice is a psychophysical method ("paradigm") used to solicit behavioral or perceptual responses from subjects. The name comes from two aspects of the method. It is called two-
40,684
What is the two alternative forced choice paradigm
Two-alternative forced choice (2AFC) refers to the methodology used to solicit responses from participants. It is used in many different paradigms across different domains. As the name implies, participants are presented only two choices, and they must make a response (indifference is not allowed). For example, the lexical decision task is a 2AFC task. Participants are presented a sequence of letters such as BOKE and must quickly indicate whether the sequence of letters forms a word or a non-word. Another example from psychophysics might ask participants to judge whether a test stimulus is brighter than a target stimulus. Participants must response either yes or no.
What is the two alternative forced choice paradigm
Two-alternative forced choice (2AFC) refers to the methodology used to solicit responses from participants. It is used in many different paradigms across different domains. As the name implies, partic
What is the two alternative forced choice paradigm Two-alternative forced choice (2AFC) refers to the methodology used to solicit responses from participants. It is used in many different paradigms across different domains. As the name implies, participants are presented only two choices, and they must make a response (indifference is not allowed). For example, the lexical decision task is a 2AFC task. Participants are presented a sequence of letters such as BOKE and must quickly indicate whether the sequence of letters forms a word or a non-word. Another example from psychophysics might ask participants to judge whether a test stimulus is brighter than a target stimulus. Participants must response either yes or no.
What is the two alternative forced choice paradigm Two-alternative forced choice (2AFC) refers to the methodology used to solicit responses from participants. It is used in many different paradigms across different domains. As the name implies, partic
40,685
What is the two alternative forced choice paradigm
Having read the other two answers, I think we are still missing an important point. As @Jeff notes, many tasks involve two alternatives, e.g., a detection task. In a detection task, or indeed, in any task with a single stimulus and a decision that must be made about that stimulus, the subject must set a criterion level for their decision. This criterion level may vary from person to person, or may vary in the same person from day to day or even from trial to trial. In contrast, a task with two stimuli eliminates the possibility of different criterion levels. With fewer degrees of freedom to the subjects behavior, the experiment is more controlled. (There may be bias in the 2 stimulus task - you might be biased to pick the stimulus on the left, or the stimulus presented first. This bias is orthogonal to the task, however, whereas criterion level directly affects task performance.)
What is the two alternative forced choice paradigm
Having read the other two answers, I think we are still missing an important point. As @Jeff notes, many tasks involve two alternatives, e.g., a detection task. In a detection task, or indeed, in any
What is the two alternative forced choice paradigm Having read the other two answers, I think we are still missing an important point. As @Jeff notes, many tasks involve two alternatives, e.g., a detection task. In a detection task, or indeed, in any task with a single stimulus and a decision that must be made about that stimulus, the subject must set a criterion level for their decision. This criterion level may vary from person to person, or may vary in the same person from day to day or even from trial to trial. In contrast, a task with two stimuli eliminates the possibility of different criterion levels. With fewer degrees of freedom to the subjects behavior, the experiment is more controlled. (There may be bias in the 2 stimulus task - you might be biased to pick the stimulus on the left, or the stimulus presented first. This bias is orthogonal to the task, however, whereas criterion level directly affects task performance.)
What is the two alternative forced choice paradigm Having read the other two answers, I think we are still missing an important point. As @Jeff notes, many tasks involve two alternatives, e.g., a detection task. In a detection task, or indeed, in any
40,686
Why is ROC curve always increasing (or non-decreasing)?
(WLOG) Because no case which is classified as a positive will ever be classified as a negative for any lower threshold.
Why is ROC curve always increasing (or non-decreasing)?
(WLOG) Because no case which is classified as a positive will ever be classified as a negative for any lower threshold.
Why is ROC curve always increasing (or non-decreasing)? (WLOG) Because no case which is classified as a positive will ever be classified as a negative for any lower threshold.
Why is ROC curve always increasing (or non-decreasing)? (WLOG) Because no case which is classified as a positive will ever be classified as a negative for any lower threshold.
40,687
Appropriate way to calculate cross-validated R square
That is incorrect because it allows for recalibration of predictions with a new overall slope and intercept. Use this formula after freezing all coefficients: 1 - (sum of squared errors) / (sum of squares total). The denominator is $(n-1)\times$ the observed variance of $Y$ in the holdout sample. When you do it correctly you can get negative $R^2$ in some holdout samples when the real $R^2$ is low.
Appropriate way to calculate cross-validated R square
That is incorrect because it allows for recalibration of predictions with a new overall slope and intercept. Use this formula after freezing all coefficients: 1 - (sum of squared errors) / (sum of sq
Appropriate way to calculate cross-validated R square That is incorrect because it allows for recalibration of predictions with a new overall slope and intercept. Use this formula after freezing all coefficients: 1 - (sum of squared errors) / (sum of squares total). The denominator is $(n-1)\times$ the observed variance of $Y$ in the holdout sample. When you do it correctly you can get negative $R^2$ in some holdout samples when the real $R^2$ is low.
Appropriate way to calculate cross-validated R square That is incorrect because it allows for recalibration of predictions with a new overall slope and intercept. Use this formula after freezing all coefficients: 1 - (sum of squared errors) / (sum of sq
40,688
Relationship between logistic regression and hyperplane
The picture below will probably answer your question. A logistic regression model with 2 features creates a wave based on the logit link function. Applying the decision rule (for example above 50%) transforms the wave to a separating hyperplane like that, but not similar to, one found in SVM. This is illustrated in the picture below. Note that this separating hyperplane is in feature space. These pictures come from http://blog.data-miners.com/2014/03/lines-and-circles-and-logistic.html You can find an expose on om the subject.
Relationship between logistic regression and hyperplane
The picture below will probably answer your question. A logistic regression model with 2 features creates a wave based on the logit link function. Applying the decision rule (for example above 50%)
Relationship between logistic regression and hyperplane The picture below will probably answer your question. A logistic regression model with 2 features creates a wave based on the logit link function. Applying the decision rule (for example above 50%) transforms the wave to a separating hyperplane like that, but not similar to, one found in SVM. This is illustrated in the picture below. Note that this separating hyperplane is in feature space. These pictures come from http://blog.data-miners.com/2014/03/lines-and-circles-and-logistic.html You can find an expose on om the subject.
Relationship between logistic regression and hyperplane The picture below will probably answer your question. A logistic regression model with 2 features creates a wave based on the logit link function. Applying the decision rule (for example above 50%)
40,689
Feature scaling (normalization) in multiple regression analysis with normal equation method?
Well, in the second article there is a sentence: Note that before conducting linear regression, you should normalize the data. One way is $\frac{x_i−mean(x)}{Range(x)}$, and some use $sd(x)$ as the denominator. Both work. But is not said that it applies specifically to normal equations. And in gradient descent section there is nothing said about normalization. So I suppose it was a small mistake to include that sentence in Normal Equation section instead of Gradient Descent. Anyway Andrew Ng is pretty authoritative on machine learning topic, so you can rely on his words: Using this formula does not require any feature scaling, and you will get an exact solution in one calculation: there is no 'loop until convergence' like in gradient descent.
Feature scaling (normalization) in multiple regression analysis with normal equation method?
Well, in the second article there is a sentence: Note that before conducting linear regression, you should normalize the data. One way is $\frac{x_i−mean(x)}{Range(x)}$, and some use $sd(x)$ as
Feature scaling (normalization) in multiple regression analysis with normal equation method? Well, in the second article there is a sentence: Note that before conducting linear regression, you should normalize the data. One way is $\frac{x_i−mean(x)}{Range(x)}$, and some use $sd(x)$ as the denominator. Both work. But is not said that it applies specifically to normal equations. And in gradient descent section there is nothing said about normalization. So I suppose it was a small mistake to include that sentence in Normal Equation section instead of Gradient Descent. Anyway Andrew Ng is pretty authoritative on machine learning topic, so you can rely on his words: Using this formula does not require any feature scaling, and you will get an exact solution in one calculation: there is no 'loop until convergence' like in gradient descent.
Feature scaling (normalization) in multiple regression analysis with normal equation method? Well, in the second article there is a sentence: Note that before conducting linear regression, you should normalize the data. One way is $\frac{x_i−mean(x)}{Range(x)}$, and some use $sd(x)$ as
40,690
What math background do I need to read ESL effectively?
In terms of Mathematics one does not need a heavy background for a first comprehensive read of ESL. What a first year CS/Engineering undergraduate would know is adequate. For example, in terms of Linear Algebra the levels of G. Strang's Introduction to Linear Algebra and in terms of Multivariate Calculus J. Stewart's Calculus will get you through most of ESL without any issues. Refreshing your basic conditional probabilities will not go to waste either. Some topics like the ones based on reproducing Hilbert kernel spaces, wavelets and importance sampling will not be fully accessible and one would probably need to read about them separately in order to fully grasp them. Nevertheless the book tries to explain them in a relative straightforward manner so the reader can obtain enough working knowledge to get the gist of the text. Check the thread Can you recommend a book to read before Elements of Statistical Learning? too. It is not really concerned with Mathematical preliminaries but rather with "conceptual ones" mostly. As a somewhat smoother and more mathematically self-contained alternative to ESL you might want to consider K. Murphy's Machine Learning: a Probabilistic Perspective.
What math background do I need to read ESL effectively?
In terms of Mathematics one does not need a heavy background for a first comprehensive read of ESL. What a first year CS/Engineering undergraduate would know is adequate. For example, in terms of Line
What math background do I need to read ESL effectively? In terms of Mathematics one does not need a heavy background for a first comprehensive read of ESL. What a first year CS/Engineering undergraduate would know is adequate. For example, in terms of Linear Algebra the levels of G. Strang's Introduction to Linear Algebra and in terms of Multivariate Calculus J. Stewart's Calculus will get you through most of ESL without any issues. Refreshing your basic conditional probabilities will not go to waste either. Some topics like the ones based on reproducing Hilbert kernel spaces, wavelets and importance sampling will not be fully accessible and one would probably need to read about them separately in order to fully grasp them. Nevertheless the book tries to explain them in a relative straightforward manner so the reader can obtain enough working knowledge to get the gist of the text. Check the thread Can you recommend a book to read before Elements of Statistical Learning? too. It is not really concerned with Mathematical preliminaries but rather with "conceptual ones" mostly. As a somewhat smoother and more mathematically self-contained alternative to ESL you might want to consider K. Murphy's Machine Learning: a Probabilistic Perspective.
What math background do I need to read ESL effectively? In terms of Mathematics one does not need a heavy background for a first comprehensive read of ESL. What a first year CS/Engineering undergraduate would know is adequate. For example, in terms of Line
40,691
What's wrong if I fit the auto-regression with OLS?
To answer the title question, fitting an AR($p$) model using OLS will yield biased estimates. The reason is that for unbiasedness, the model errors should be uncorrelated with past, current and future values of regressors, which is not the case in autoregressive models. For example, in case of AR(1) $$ y_t=\varphi y_{t-1}+\varepsilon_t $$ (assuming zero mean for simplicity). Lag this by 1 to obtain $$ y_{t-1}=\varphi y_{t-2}+\varepsilon_{t-1}. $$ Note that $\varepsilon_{t-1}$ enters the model of $y_{t-1}$; hence, the regressor $y_{t-1}$ will be correlated with lagged error $\varepsilon_{t-1}$. The argument is given (without proof) e.g. in this lecture note, p. 5-6. On a positive note, OLS gives consistent estimators for an autoregressive model (see the same lecture note, p. 4-5) Also, in my experience OLS is quite popular for fitting AR models, and is pretty standard for fitting multivariate AR, i.e. VAR, models.
What's wrong if I fit the auto-regression with OLS?
To answer the title question, fitting an AR($p$) model using OLS will yield biased estimates. The reason is that for unbiasedness, the model errors should be uncorrelated with past, current and future
What's wrong if I fit the auto-regression with OLS? To answer the title question, fitting an AR($p$) model using OLS will yield biased estimates. The reason is that for unbiasedness, the model errors should be uncorrelated with past, current and future values of regressors, which is not the case in autoregressive models. For example, in case of AR(1) $$ y_t=\varphi y_{t-1}+\varepsilon_t $$ (assuming zero mean for simplicity). Lag this by 1 to obtain $$ y_{t-1}=\varphi y_{t-2}+\varepsilon_{t-1}. $$ Note that $\varepsilon_{t-1}$ enters the model of $y_{t-1}$; hence, the regressor $y_{t-1}$ will be correlated with lagged error $\varepsilon_{t-1}$. The argument is given (without proof) e.g. in this lecture note, p. 5-6. On a positive note, OLS gives consistent estimators for an autoregressive model (see the same lecture note, p. 4-5) Also, in my experience OLS is quite popular for fitting AR models, and is pretty standard for fitting multivariate AR, i.e. VAR, models.
What's wrong if I fit the auto-regression with OLS? To answer the title question, fitting an AR($p$) model using OLS will yield biased estimates. The reason is that for unbiasedness, the model errors should be uncorrelated with past, current and future
40,692
What's wrong if I fit the auto-regression with OLS?
If you fit by regressing $\mathbf{y}_{p+1:n}=(y_{p+1},...,y_n)^\top$ on its lags $X=[\mathbf{y}_{p:n-1},\mathbf{y}_{p-1:n-2},...,\mathbf{y}_{1:n-p}]$ the lags of that on you're going to be conditioning on the first $p$ values (for an AR(p)). If you fit by say maximum likelihood you're able to incorporate the likelihood for the first $p$ values. If $n$ is not very large relative to $p$ is can sometimes make a substantial difference.
What's wrong if I fit the auto-regression with OLS?
If you fit by regressing $\mathbf{y}_{p+1:n}=(y_{p+1},...,y_n)^\top$ on its lags $X=[\mathbf{y}_{p:n-1},\mathbf{y}_{p-1:n-2},...,\mathbf{y}_{1:n-p}]$ the lags of that on you're going to be conditionin
What's wrong if I fit the auto-regression with OLS? If you fit by regressing $\mathbf{y}_{p+1:n}=(y_{p+1},...,y_n)^\top$ on its lags $X=[\mathbf{y}_{p:n-1},\mathbf{y}_{p-1:n-2},...,\mathbf{y}_{1:n-p}]$ the lags of that on you're going to be conditioning on the first $p$ values (for an AR(p)). If you fit by say maximum likelihood you're able to incorporate the likelihood for the first $p$ values. If $n$ is not very large relative to $p$ is can sometimes make a substantial difference.
What's wrong if I fit the auto-regression with OLS? If you fit by regressing $\mathbf{y}_{p+1:n}=(y_{p+1},...,y_n)^\top$ on its lags $X=[\mathbf{y}_{p:n-1},\mathbf{y}_{p-1:n-2},...,\mathbf{y}_{1:n-p}]$ the lags of that on you're going to be conditionin
40,693
why does R rlm {MASS} return different coefficients almost each time it is called?
Because of the algorithm you choose to compute the initial values (init) (from which the second stage of the algorithm, i.e. the MM steps, start). Setting init=lts uses the coefficients fitted by the FastLTS algorithm as starting points of the MM iterations. The FastLTS algorithm in turn uses many random starting points so is itself random. Unless you fix the seed argument, you will get different solutions (which is as it should be!). library(MASS) model1 <- rlm(stack.loss ~ ., data = stackloss,maxit = 1000000, init = "lts",seed=1, method = "MM", psi=psi.huber, acc=0.00001, scale.est="proposal 2", cor = T) model2 <- rlm(stack.loss ~ ., data = stackloss,maxit = 1000000, init = "lts",seed=1, method = "MM", psi=psi.huber, acc=0.00001, scale.est="proposal 2", cor = T) model1$coef-model2$coef Setting method = "MM" without setting init uses the coefficient fitted by the FastS algorithm as starting points of the MM iterations (source). The FastS algorithm in turn uses many random starting points so is itself random. Unless you fix the seed argument, you will get different solutions (which is as it should be!). library(MASS) model1 <- rlm(stack.loss ~ ., data = stackloss,maxit = 1000000, seed=1, method = "MM", psi=psi.huber, acc=0.00001, scale.est="proposal 2", cor = T) model2 <- rlm(stack.loss ~ ., data = stackloss,maxit = 1000000, seed=1, method = "MM", psi=psi.huber, acc=0.00001, scale.est="proposal 2", cor = T) model1$coef-model2$coef
why does R rlm {MASS} return different coefficients almost each time it is called?
Because of the algorithm you choose to compute the initial values (init) (from which the second stage of the algorithm, i.e. the MM steps, start). Setting init=lts uses the coefficients fitted by the
why does R rlm {MASS} return different coefficients almost each time it is called? Because of the algorithm you choose to compute the initial values (init) (from which the second stage of the algorithm, i.e. the MM steps, start). Setting init=lts uses the coefficients fitted by the FastLTS algorithm as starting points of the MM iterations. The FastLTS algorithm in turn uses many random starting points so is itself random. Unless you fix the seed argument, you will get different solutions (which is as it should be!). library(MASS) model1 <- rlm(stack.loss ~ ., data = stackloss,maxit = 1000000, init = "lts",seed=1, method = "MM", psi=psi.huber, acc=0.00001, scale.est="proposal 2", cor = T) model2 <- rlm(stack.loss ~ ., data = stackloss,maxit = 1000000, init = "lts",seed=1, method = "MM", psi=psi.huber, acc=0.00001, scale.est="proposal 2", cor = T) model1$coef-model2$coef Setting method = "MM" without setting init uses the coefficient fitted by the FastS algorithm as starting points of the MM iterations (source). The FastS algorithm in turn uses many random starting points so is itself random. Unless you fix the seed argument, you will get different solutions (which is as it should be!). library(MASS) model1 <- rlm(stack.loss ~ ., data = stackloss,maxit = 1000000, seed=1, method = "MM", psi=psi.huber, acc=0.00001, scale.est="proposal 2", cor = T) model2 <- rlm(stack.loss ~ ., data = stackloss,maxit = 1000000, seed=1, method = "MM", psi=psi.huber, acc=0.00001, scale.est="proposal 2", cor = T) model1$coef-model2$coef
why does R rlm {MASS} return different coefficients almost each time it is called? Because of the algorithm you choose to compute the initial values (init) (from which the second stage of the algorithm, i.e. the MM steps, start). Setting init=lts uses the coefficients fitted by the
40,694
Proof of the Derivation of the marginal and conditional Gaussian
Let's write the RV $X$, $Y$ as $$ X = \mu + \varepsilon _x \\ Y = AX + b + \varepsilon _y $$ with $ \varepsilon _x \sim \mathcal N (0, \Lambda ^{-1})$, $ \varepsilon _y \sim \mathcal N (0, L ^{-1})$. Now pluging in X in the second equation above gives $$ Y = A\mu + b + A\varepsilon _x + \varepsilon _y. $$ This is a linear combination of normal distributed random variables and as such itself normal distributed with expectation $A\mu +b$ and covariance matrix $A\Lambda ^{-1}A^T + L^{-1}$ ($var(AX)=Avar(X)A^T$). From this you get $p(y)$. The second fact is a bit more complicated and involves some tedious calculation. From Bayes Theorem it follows that $$ p(x|y) \propto p(y|x)p(x) \\ \propto \exp ((y-Ax-b)^TL(y-Ax-b) + (x-\mu)^T\Lambda(x-\mu)). $$ If you multiply everything out and then factor out $x$ you get to something proportional to $$ \exp( (x-(\Lambda + A^TLA)^{-1}A^TL(y-b))^T(\Lambda + A^TLA)(x-(\Lambda + A^TLA)^{-1}AL(y-b))) $$ which is proportional to your given normal.
Proof of the Derivation of the marginal and conditional Gaussian
Let's write the RV $X$, $Y$ as $$ X = \mu + \varepsilon _x \\ Y = AX + b + \varepsilon _y $$ with $ \varepsilon _x \sim \mathcal N (0, \Lambda ^{-1})$, $ \varepsilon _y \sim \mathcal N (0, L ^{-1})$.
Proof of the Derivation of the marginal and conditional Gaussian Let's write the RV $X$, $Y$ as $$ X = \mu + \varepsilon _x \\ Y = AX + b + \varepsilon _y $$ with $ \varepsilon _x \sim \mathcal N (0, \Lambda ^{-1})$, $ \varepsilon _y \sim \mathcal N (0, L ^{-1})$. Now pluging in X in the second equation above gives $$ Y = A\mu + b + A\varepsilon _x + \varepsilon _y. $$ This is a linear combination of normal distributed random variables and as such itself normal distributed with expectation $A\mu +b$ and covariance matrix $A\Lambda ^{-1}A^T + L^{-1}$ ($var(AX)=Avar(X)A^T$). From this you get $p(y)$. The second fact is a bit more complicated and involves some tedious calculation. From Bayes Theorem it follows that $$ p(x|y) \propto p(y|x)p(x) \\ \propto \exp ((y-Ax-b)^TL(y-Ax-b) + (x-\mu)^T\Lambda(x-\mu)). $$ If you multiply everything out and then factor out $x$ you get to something proportional to $$ \exp( (x-(\Lambda + A^TLA)^{-1}A^TL(y-b))^T(\Lambda + A^TLA)(x-(\Lambda + A^TLA)^{-1}AL(y-b))) $$ which is proportional to your given normal.
Proof of the Derivation of the marginal and conditional Gaussian Let's write the RV $X$, $Y$ as $$ X = \mu + \varepsilon _x \\ Y = AX + b + \varepsilon _y $$ with $ \varepsilon _x \sim \mathcal N (0, \Lambda ^{-1})$, $ \varepsilon _y \sim \mathcal N (0, L ^{-1})$.
40,695
Proof of the Derivation of the marginal and conditional Gaussian
I would like to also give a algebraic response to this question showing that by multiplying the Gaussians together and integrating you can get this result. I did this using the covariance matrix defined as $L, \Lambda$ instead of $L^{-1}$ and $\Lambda^{-1}$ because that is my preference. \begin{align} y|x \sim & N(Ax + b, L) \\ x \sim & N(\mu, \Lambda) \end{align} \begin{multline} y^T L^{-1} y - 2y^T L^{-1}(Ax + b) + (Ax+b)^T L^{-1} (Ax + b) + \\ x^T\Lambda^{-1} x - 2x^T\Lambda^{-1} \mu + \mu^T \Lambda^{-1} \mu = \\ y^T L^{-1} y- 2y^T L^{-1} Ax - 2y^T L^{-1} b + x^T A^T L^{-1} A x + 2x^T A^T L^{-1} b + b^T L^{-1} b \\ x^T\Lambda^{-1} x - 2x^T\Lambda^{-1} \mu + \mu^T \Lambda^{-1} \mu \end{multline} As before make quadratic forms out of the $ x $ terms to integrate them out: \begin{align} x^T ( \Lambda^{-1} + A^T L^{-1} A) x - 2x^T ( \Lambda^{-1} \mu + A^T L^{-1} y - A^T L^{-1} b) + \mu^T \Lambda^{-1} \mu + b^T L^{-1} b \end{align} \begin{align} V &= [A^TL^{-1} A + \Lambda^{-1} ]^{-1} \\ u &= [ \Lambda^{-1} \mu + A^T L^{-1} y - A^T L^{-1} b]\\ h & = Vu \\ h^TV^{-1}h &= u^T V u \\ c & = \mu^T \Lambda^{-1} \mu + b^T L^{-1} b \\ \end{align} $ x $ is Gaussian and integrates to its normalizing constant. The term $ c- K $, $ K = u^TVu $ factors into the $ y $ exponential giving, \begin{align} y^T L^{-1} y -2y^TL^{-1} b + c - K \end{align} And, \begin{multline} u^T V u = \\ [ \Lambda^{-1} \mu + A^T L^{-1} y - A^T L^{-1} b]^T V [ \Lambda^{-1} \mu + A^T L^{-1} y - A^T L^{-1} b] = \\ \mu^T \Lambda^{-1} V \Lambda^{-1} \mu + y^T L^{-1} A V A^T L^{-1} y + b^T L^{-1} AV A^T L^{-1} b \\ + 2y^T L^{-1} A V \Lambda^{-1} \mu - 2\mu^T \Lambda^{-1} V A^T L^{-1} b - 2y^T L^{-1} A V A^T L^{-1} b \end{multline} Together this becomes: \begin{multline} y^T [ L^{-1} - L^{-1} A V A^T L^{-1} ] y - 2y^T [L^{-1} b + L^{-1} A V \Lambda^{-1} \mu - L^{-1} A V A^T L^{-1} b] + \\ \mu^T[ \Lambda^{-1} - \Lambda^{-1} V \Lambda^{-1} ]\mu + b^T[L^{-1} - L^{-1} A V A^T L^{-1}] b - 2 b^T L^{-1} A V \Lambda^{-1} \mu \end{multline} Which simplifies slightly, \begin{equation} y^T R^{-1} y - 2y^T g + b^T R^{-1} b + \mu^T[ \Lambda^{-1} - \Lambda^{-1} V\Lambda^{-1}]\mu - 2 b^T L^{-1} A V \Lambda^{-1} \mu \end{equation} \begin{align} R^{-1} = L^{-1} - L^{-1} A V A^T L^{-1} = [L + A \Lambda A^T]^{-1} \\ g = [L^{-1} b + L^{-1} A V \Lambda^{-1} \mu - L^{-1} A V A^T L^{-1} b] \end{align} Furthermore, $ Rg = A\mu +b $: \begin{align} R g &= R [L^{-1} b + L^{-1} A V \Lambda^{-1} \mu - L^{-1} A V A^T L^{-1} b] \\ &= R[ (L^{-1} - L^{-1} A VA^T L^{-1}) b + L^{-1} A V \Lambda^{-1} \mu ] \label{amu1} \\ & = b + R L^{-1} A V \Lambda^{-1} \mu \label{amu2} \end{align} After canceling out the $ b $ term on both sides I get I solve for the other term, equating coefficients: \begin{align} R L^{-1} A V \Lambda \mu = & [L + A \Lambda A^T] L^{-1} A V \Lambda^{-1} \mu = A \mu \label{amu3} \\ = & A + A\Lambda A^T L^{-1} A = A [\Lambda^{-1} + A^T L^{-1} A] \Lambda \label{amu4} \\ & \text{(using the definition of $ V $)} \notag \\ \end{align} \begin{align} I + \Lambda A^T L^{-1} A = & I + A^T L^{-1} A \Lambda \label{amu5}\\ \Lambda A^T L^{-1} A = & \Lambda A^T L^{-1} A \label{amu6} \end{align} And therefore $ Rg = A\mu + b $ and $ R^{-1} A \mu = L^{-1} AV \Lambda^{-1} \mu. $ Simplifying equation the equation for $y$ I get, \begin{equation} y^T R^{-1} y - 2y^TR^{-1} (A\mu + b)+ b^TR^{-1} b + \mu^T[ \Lambda^{-1} - \Lambda^{-1} V \Lambda^{-1} ]\mu - 2 b^T L^{-1} A V \Lambda^{-1} \mu. \end{equation} Notice, $$ \Lambda - \Lambda^{-1} V \Lambda^{-1} = A^T R^{-1} A $$ To show this: \begin{align} A^T R^{-1} A & = \Lambda^{-1} - \Lambda^{-1} V \Lambda^{-1} \\ & = \Lambda^{-1} - \Lambda^{-1} I ( I \Lambda I + F^{-1}) I \Lambda^{-1} \end{align} $ F^{-1} = A^TL^{-1} A $, \begin{align} \Lambda^{-1} - \Lambda^{-1} I ( I \Lambda^{-1} I + F^{-1}) I \Lambda^{-1} & = [\Lambda + F] ^{-1} \end{align} By the Woodbury identity. \begin{align} A^T R^{-1} A & = [\Lambda + F] ^{-1}\\ A^{-1} R A^{-1} & = \Lambda + F \\ R & = A \Lambda A^T + L \end{align} Since both sides are equal, the `sandwich' term is equal to $ A^T R^{-1} A $ I get the following: \begin{equation} y^T R^{-1} y - 2y^TR^{-1} (A\mu + b)+ b^TR^{-1} b + \mu^T A^T R^{-1} A \mu - 2 b^T R^{-1} A\mu. \end{equation} Which gives the results that $ y $ is distributed normally. $$ y \sim \mathcal{N} (A\mu + b, R) $$ The other part is much easier, and the algebra is not very tedious. The first the long equation given for $ y $ can be simplified when conditioning on $x$ since everything not involving $x$ can be subsumed into the constant of proportionality. This leaves only, \begin{equation} -2x^T A^T L^{-1} y + x^T A^T L^{-1} x + 2 x^T A^T L^{-1} b + X^T \Lambda^{-1} x - 2x^T \Lambda ^{-1} \mu \end{equation} Then refactoring this term, \begin{equation} x^T [ A^T L^{-1} A + \Lambda^{-1} ] x - 2x^T [A^T L^{-1} (y - b) + \Lambda^{-1} \mu] + K \end{equation} Where $ K $ is some constant. Call $[ A^T L^{-1} A + \Lambda^{-1} ] = \Sigma^{-1}$. Therefore, \begin{equation} x \sim \mathcal{N} ( \Sigma [ A^T L^{-1}(y - b) + \Lambda^{-1} \mu], \Sigma) \end{equation} Remember I defined my covariance matrix to the inverse of what was given in the question.
Proof of the Derivation of the marginal and conditional Gaussian
I would like to also give a algebraic response to this question showing that by multiplying the Gaussians together and integrating you can get this result. I did this using the covariance matrix defin
Proof of the Derivation of the marginal and conditional Gaussian I would like to also give a algebraic response to this question showing that by multiplying the Gaussians together and integrating you can get this result. I did this using the covariance matrix defined as $L, \Lambda$ instead of $L^{-1}$ and $\Lambda^{-1}$ because that is my preference. \begin{align} y|x \sim & N(Ax + b, L) \\ x \sim & N(\mu, \Lambda) \end{align} \begin{multline} y^T L^{-1} y - 2y^T L^{-1}(Ax + b) + (Ax+b)^T L^{-1} (Ax + b) + \\ x^T\Lambda^{-1} x - 2x^T\Lambda^{-1} \mu + \mu^T \Lambda^{-1} \mu = \\ y^T L^{-1} y- 2y^T L^{-1} Ax - 2y^T L^{-1} b + x^T A^T L^{-1} A x + 2x^T A^T L^{-1} b + b^T L^{-1} b \\ x^T\Lambda^{-1} x - 2x^T\Lambda^{-1} \mu + \mu^T \Lambda^{-1} \mu \end{multline} As before make quadratic forms out of the $ x $ terms to integrate them out: \begin{align} x^T ( \Lambda^{-1} + A^T L^{-1} A) x - 2x^T ( \Lambda^{-1} \mu + A^T L^{-1} y - A^T L^{-1} b) + \mu^T \Lambda^{-1} \mu + b^T L^{-1} b \end{align} \begin{align} V &= [A^TL^{-1} A + \Lambda^{-1} ]^{-1} \\ u &= [ \Lambda^{-1} \mu + A^T L^{-1} y - A^T L^{-1} b]\\ h & = Vu \\ h^TV^{-1}h &= u^T V u \\ c & = \mu^T \Lambda^{-1} \mu + b^T L^{-1} b \\ \end{align} $ x $ is Gaussian and integrates to its normalizing constant. The term $ c- K $, $ K = u^TVu $ factors into the $ y $ exponential giving, \begin{align} y^T L^{-1} y -2y^TL^{-1} b + c - K \end{align} And, \begin{multline} u^T V u = \\ [ \Lambda^{-1} \mu + A^T L^{-1} y - A^T L^{-1} b]^T V [ \Lambda^{-1} \mu + A^T L^{-1} y - A^T L^{-1} b] = \\ \mu^T \Lambda^{-1} V \Lambda^{-1} \mu + y^T L^{-1} A V A^T L^{-1} y + b^T L^{-1} AV A^T L^{-1} b \\ + 2y^T L^{-1} A V \Lambda^{-1} \mu - 2\mu^T \Lambda^{-1} V A^T L^{-1} b - 2y^T L^{-1} A V A^T L^{-1} b \end{multline} Together this becomes: \begin{multline} y^T [ L^{-1} - L^{-1} A V A^T L^{-1} ] y - 2y^T [L^{-1} b + L^{-1} A V \Lambda^{-1} \mu - L^{-1} A V A^T L^{-1} b] + \\ \mu^T[ \Lambda^{-1} - \Lambda^{-1} V \Lambda^{-1} ]\mu + b^T[L^{-1} - L^{-1} A V A^T L^{-1}] b - 2 b^T L^{-1} A V \Lambda^{-1} \mu \end{multline} Which simplifies slightly, \begin{equation} y^T R^{-1} y - 2y^T g + b^T R^{-1} b + \mu^T[ \Lambda^{-1} - \Lambda^{-1} V\Lambda^{-1}]\mu - 2 b^T L^{-1} A V \Lambda^{-1} \mu \end{equation} \begin{align} R^{-1} = L^{-1} - L^{-1} A V A^T L^{-1} = [L + A \Lambda A^T]^{-1} \\ g = [L^{-1} b + L^{-1} A V \Lambda^{-1} \mu - L^{-1} A V A^T L^{-1} b] \end{align} Furthermore, $ Rg = A\mu +b $: \begin{align} R g &= R [L^{-1} b + L^{-1} A V \Lambda^{-1} \mu - L^{-1} A V A^T L^{-1} b] \\ &= R[ (L^{-1} - L^{-1} A VA^T L^{-1}) b + L^{-1} A V \Lambda^{-1} \mu ] \label{amu1} \\ & = b + R L^{-1} A V \Lambda^{-1} \mu \label{amu2} \end{align} After canceling out the $ b $ term on both sides I get I solve for the other term, equating coefficients: \begin{align} R L^{-1} A V \Lambda \mu = & [L + A \Lambda A^T] L^{-1} A V \Lambda^{-1} \mu = A \mu \label{amu3} \\ = & A + A\Lambda A^T L^{-1} A = A [\Lambda^{-1} + A^T L^{-1} A] \Lambda \label{amu4} \\ & \text{(using the definition of $ V $)} \notag \\ \end{align} \begin{align} I + \Lambda A^T L^{-1} A = & I + A^T L^{-1} A \Lambda \label{amu5}\\ \Lambda A^T L^{-1} A = & \Lambda A^T L^{-1} A \label{amu6} \end{align} And therefore $ Rg = A\mu + b $ and $ R^{-1} A \mu = L^{-1} AV \Lambda^{-1} \mu. $ Simplifying equation the equation for $y$ I get, \begin{equation} y^T R^{-1} y - 2y^TR^{-1} (A\mu + b)+ b^TR^{-1} b + \mu^T[ \Lambda^{-1} - \Lambda^{-1} V \Lambda^{-1} ]\mu - 2 b^T L^{-1} A V \Lambda^{-1} \mu. \end{equation} Notice, $$ \Lambda - \Lambda^{-1} V \Lambda^{-1} = A^T R^{-1} A $$ To show this: \begin{align} A^T R^{-1} A & = \Lambda^{-1} - \Lambda^{-1} V \Lambda^{-1} \\ & = \Lambda^{-1} - \Lambda^{-1} I ( I \Lambda I + F^{-1}) I \Lambda^{-1} \end{align} $ F^{-1} = A^TL^{-1} A $, \begin{align} \Lambda^{-1} - \Lambda^{-1} I ( I \Lambda^{-1} I + F^{-1}) I \Lambda^{-1} & = [\Lambda + F] ^{-1} \end{align} By the Woodbury identity. \begin{align} A^T R^{-1} A & = [\Lambda + F] ^{-1}\\ A^{-1} R A^{-1} & = \Lambda + F \\ R & = A \Lambda A^T + L \end{align} Since both sides are equal, the `sandwich' term is equal to $ A^T R^{-1} A $ I get the following: \begin{equation} y^T R^{-1} y - 2y^TR^{-1} (A\mu + b)+ b^TR^{-1} b + \mu^T A^T R^{-1} A \mu - 2 b^T R^{-1} A\mu. \end{equation} Which gives the results that $ y $ is distributed normally. $$ y \sim \mathcal{N} (A\mu + b, R) $$ The other part is much easier, and the algebra is not very tedious. The first the long equation given for $ y $ can be simplified when conditioning on $x$ since everything not involving $x$ can be subsumed into the constant of proportionality. This leaves only, \begin{equation} -2x^T A^T L^{-1} y + x^T A^T L^{-1} x + 2 x^T A^T L^{-1} b + X^T \Lambda^{-1} x - 2x^T \Lambda ^{-1} \mu \end{equation} Then refactoring this term, \begin{equation} x^T [ A^T L^{-1} A + \Lambda^{-1} ] x - 2x^T [A^T L^{-1} (y - b) + \Lambda^{-1} \mu] + K \end{equation} Where $ K $ is some constant. Call $[ A^T L^{-1} A + \Lambda^{-1} ] = \Sigma^{-1}$. Therefore, \begin{equation} x \sim \mathcal{N} ( \Sigma [ A^T L^{-1}(y - b) + \Lambda^{-1} \mu], \Sigma) \end{equation} Remember I defined my covariance matrix to the inverse of what was given in the question.
Proof of the Derivation of the marginal and conditional Gaussian I would like to also give a algebraic response to this question showing that by multiplying the Gaussians together and integrating you can get this result. I did this using the covariance matrix defin
40,696
Why do autoencoders come under unsupervised learning?
An autoencoder is unsupervised since it's not using labeled data. The goal is to minimize reconstruction error based on a loss function, such as the mean squared error: $\mathcal{L}(\mathbf{x},\mathbf{x'})=\|\mathbf{x}-\mathbf{x'}\|^2=\|\mathbf{x}-f(\mathbf{W'}(f(\mathbf{Wx}+\mathbf{b}))+\mathbf{b'})\|^2$ All algorithms that do not use labeled data (targets) are unsupervised. Clustering algorithms are unsupervised. They generate natural groupings of data. Autoencoders are typically used for dimensionality reduction. You can think of them as non-linear PCA. Autoencoders consist of an encoder and a decoder. They kind of fit a zip and unzip functions for compression, learned from the dataset. In the image below there is just one hidden layer. The output $x'$ is the corrupted version of $x$ (some noise is added -- this makes the compression more robust). After the training is performed and the lower dimensional representation is learned, you can get rid of the decoder. Now, with your encoding function you can transform your data set into a lower dimensionality one. With the new dataset now you can repeat the process with an even lower dimensionality. This is the basic idea of stacked autoencoders.
Why do autoencoders come under unsupervised learning?
An autoencoder is unsupervised since it's not using labeled data. The goal is to minimize reconstruction error based on a loss function, such as the mean squared error: $\mathcal{L}(\mathbf{x},\mathbf
Why do autoencoders come under unsupervised learning? An autoencoder is unsupervised since it's not using labeled data. The goal is to minimize reconstruction error based on a loss function, such as the mean squared error: $\mathcal{L}(\mathbf{x},\mathbf{x'})=\|\mathbf{x}-\mathbf{x'}\|^2=\|\mathbf{x}-f(\mathbf{W'}(f(\mathbf{Wx}+\mathbf{b}))+\mathbf{b'})\|^2$ All algorithms that do not use labeled data (targets) are unsupervised. Clustering algorithms are unsupervised. They generate natural groupings of data. Autoencoders are typically used for dimensionality reduction. You can think of them as non-linear PCA. Autoencoders consist of an encoder and a decoder. They kind of fit a zip and unzip functions for compression, learned from the dataset. In the image below there is just one hidden layer. The output $x'$ is the corrupted version of $x$ (some noise is added -- this makes the compression more robust). After the training is performed and the lower dimensional representation is learned, you can get rid of the decoder. Now, with your encoding function you can transform your data set into a lower dimensionality one. With the new dataset now you can repeat the process with an even lower dimensionality. This is the basic idea of stacked autoencoders.
Why do autoencoders come under unsupervised learning? An autoencoder is unsupervised since it's not using labeled data. The goal is to minimize reconstruction error based on a loss function, such as the mean squared error: $\mathcal{L}(\mathbf{x},\mathbf
40,697
Why do autoencoders come under unsupervised learning?
Before answering the question, I quote from (Artificial Intelligence: A Modern Approach): In unsupervised learning the agent learns pattern in the input even though no explicit feedback is supplied. The most common unsupervised learning task is clustering. ... In supervised learning the agent observe some example input output pairs and learns functions that maps from input to output. In unsupervised learning, you provide a function and you aim at minimizing or maximizing that function. However, in supervised learning, you do not know the function, and you hope by providing some examples, the learning algorithm will figure out the function that maps the inputs to the desired outputs with least error. You cannot optimize autoencoders without a feedback from an example. Once you provide the same input in order to correct the performance, you supervise it. This is why. If you're still unconvinced, try to train it without providing the input to the loss function. How are you going to correct the parameters? Sometimes, autoencoders are not used to reconstruct the exact input, but rather with modified version. For example you can provide a set of brain images as inputs, and for the output you provide the same images with tumors highlightedas. In this case, you train the autoencoders to not only reconstruct the input, but also to find these anomalies.
Why do autoencoders come under unsupervised learning?
Before answering the question, I quote from (Artificial Intelligence: A Modern Approach): In unsupervised learning the agent learns pattern in the input even though no explicit feedback is supplied.
Why do autoencoders come under unsupervised learning? Before answering the question, I quote from (Artificial Intelligence: A Modern Approach): In unsupervised learning the agent learns pattern in the input even though no explicit feedback is supplied. The most common unsupervised learning task is clustering. ... In supervised learning the agent observe some example input output pairs and learns functions that maps from input to output. In unsupervised learning, you provide a function and you aim at minimizing or maximizing that function. However, in supervised learning, you do not know the function, and you hope by providing some examples, the learning algorithm will figure out the function that maps the inputs to the desired outputs with least error. You cannot optimize autoencoders without a feedback from an example. Once you provide the same input in order to correct the performance, you supervise it. This is why. If you're still unconvinced, try to train it without providing the input to the loss function. How are you going to correct the parameters? Sometimes, autoencoders are not used to reconstruct the exact input, but rather with modified version. For example you can provide a set of brain images as inputs, and for the output you provide the same images with tumors highlightedas. In this case, you train the autoencoders to not only reconstruct the input, but also to find these anomalies.
Why do autoencoders come under unsupervised learning? Before answering the question, I quote from (Artificial Intelligence: A Modern Approach): In unsupervised learning the agent learns pattern in the input even though no explicit feedback is supplied.
40,698
Why do autoencoders come under unsupervised learning?
This is pretty heuristic explanation :( Autoencoders with sparsity enforcement seek to arrive at a more efficient representation of the data. Because we effectively restricting the number of how many neurons we allow to "fire" at a given layer, we are actually imposing sort-of bound on dimensionality of data which makes it to the next layer. This forces the algorithm to compress information. This compression is achieved, as usual, by similar treatment of simliar cases. For example, if we were to train an autoencoder with n-dimensional input and output, one hidden layer with strict sparsity parameter with linear activation functions of all neurons and we would succeed in training it "near-perfectly", we would arrive at a result very similiar to PCA. That is, the hidden layer would try to capture information which explains most variance. In this sense, grouping observations which have similar output from the hidden layer allow us to get dimensionality-reduction effect while preserving a lot of information. This grouping or dimensionality reduction is essence of unsupervised learning.
Why do autoencoders come under unsupervised learning?
This is pretty heuristic explanation :( Autoencoders with sparsity enforcement seek to arrive at a more efficient representation of the data. Because we effectively restricting the number of how many
Why do autoencoders come under unsupervised learning? This is pretty heuristic explanation :( Autoencoders with sparsity enforcement seek to arrive at a more efficient representation of the data. Because we effectively restricting the number of how many neurons we allow to "fire" at a given layer, we are actually imposing sort-of bound on dimensionality of data which makes it to the next layer. This forces the algorithm to compress information. This compression is achieved, as usual, by similar treatment of simliar cases. For example, if we were to train an autoencoder with n-dimensional input and output, one hidden layer with strict sparsity parameter with linear activation functions of all neurons and we would succeed in training it "near-perfectly", we would arrive at a result very similiar to PCA. That is, the hidden layer would try to capture information which explains most variance. In this sense, grouping observations which have similar output from the hidden layer allow us to get dimensionality-reduction effect while preserving a lot of information. This grouping or dimensionality reduction is essence of unsupervised learning.
Why do autoencoders come under unsupervised learning? This is pretty heuristic explanation :( Autoencoders with sparsity enforcement seek to arrive at a more efficient representation of the data. Because we effectively restricting the number of how many
40,699
Why do autoencoders come under unsupervised learning?
Since terminology is so confusing someone invented the term "self-supervised" to describe autoencoders learning mode: I now call it “self-supervised learning”, because “unsupervised” is both a loaded and confusing term. … Self-supervised learning uses way more supervisory signals than supervised learning, and enormously more than reinforcement learning. That’s why calling it “unsupervised” is totally misleading. by Yann LeCun (2019. 04. 30) AI602: Recent Advances in Deep Learning: Lecture 07 Essentially, "unsupervised" means "learns from data not curated by humans" which is not what "not supervised" in the colloquial sense of the word "supervision" actually means. Self-supervised better describes how an autoencoder really works.
Why do autoencoders come under unsupervised learning?
Since terminology is so confusing someone invented the term "self-supervised" to describe autoencoders learning mode: I now call it “self-supervised learning”, because “unsupervised” is both a loaded
Why do autoencoders come under unsupervised learning? Since terminology is so confusing someone invented the term "self-supervised" to describe autoencoders learning mode: I now call it “self-supervised learning”, because “unsupervised” is both a loaded and confusing term. … Self-supervised learning uses way more supervisory signals than supervised learning, and enormously more than reinforcement learning. That’s why calling it “unsupervised” is totally misleading. by Yann LeCun (2019. 04. 30) AI602: Recent Advances in Deep Learning: Lecture 07 Essentially, "unsupervised" means "learns from data not curated by humans" which is not what "not supervised" in the colloquial sense of the word "supervision" actually means. Self-supervised better describes how an autoencoder really works.
Why do autoencoders come under unsupervised learning? Since terminology is so confusing someone invented the term "self-supervised" to describe autoencoders learning mode: I now call it “self-supervised learning”, because “unsupervised” is both a loaded
40,700
Relationship between least-squares regression and information theory
The entropy of the random variable $Y$, $H(Y$) is sometimes called a measure of your "uncertainty" about $Y$. What if you know about this other variable, $X$? Your uncertainty about $Y$ given $X$ will go down. This reduction is called mutual information and is written $I(Y;X) = H(Y) - H(Y|X)$. From an information point of view, I think this is what you want to know: how is the information that $X$ gives me about $Y$ reflected in the regression coefficient? I'll show how to estimate the mutual information in terms of the regression coefficient, under some assumptions. One way to approach this problem is to assume that the variables are normally distributed. Suppose $X$ is a random variable drawn from a Gaussian with mean $\mu_x$ and standard deviation $\sigma_x$. If $y = \beta_{y,x} x + \epsilon$ and epsilon is Gaussian noise (uncorrelated with $x$) with standard deviation $\sigma_x$, then the Pearson correlation coefficient, $\rho^2 = \beta_{y,x}^2 / (\beta_{y,x}^2 + \sigma_\epsilon^2/\sigma_x^2)$. Under these assumptions, the correlation coefficient is related to the mutual information: $$I(Y;X) = -1/2 \log(1-\rho^2) = 1/2 \log\left(1 + \beta_{y,x}^2 / (\sigma_\epsilon^2/\sigma_x^2)\right) $$ (using the definition of entropy for normal distributions). Actually, this is even true under some slightly weaker assumptions. If you really just want the entropy of $Y$, you can write it as a function of this expression as $H(Y) = I(X;Y) + H(Y|X)$. This type of analysis comes up in analyzing the capacity of the additive white Gaussian noise channel. Just a few qualitative comments about this solution. This mutual information is always non-negative and zero if $\beta=0$. I guess you can interpret $\sigma_x/\sigma_\epsilon$ as a signal-to-noise ratio (SNR). If the SNR is small then it washes out any informative value that $x$ has about $y$. Generally, the regression coefficient has no relationship to mutual information. I.e., you can find distributions with fixed $\beta$ where MI can be anything. Heuristically, though, it makes sense to think of the equation above as a lower bound. For another connection between regression and information theory, I can also suggest this paper showing the relationship between linear regression and transfer entropy.
Relationship between least-squares regression and information theory
The entropy of the random variable $Y$, $H(Y$) is sometimes called a measure of your "uncertainty" about $Y$. What if you know about this other variable, $X$? Your uncertainty about $Y$ given $X$ will
Relationship between least-squares regression and information theory The entropy of the random variable $Y$, $H(Y$) is sometimes called a measure of your "uncertainty" about $Y$. What if you know about this other variable, $X$? Your uncertainty about $Y$ given $X$ will go down. This reduction is called mutual information and is written $I(Y;X) = H(Y) - H(Y|X)$. From an information point of view, I think this is what you want to know: how is the information that $X$ gives me about $Y$ reflected in the regression coefficient? I'll show how to estimate the mutual information in terms of the regression coefficient, under some assumptions. One way to approach this problem is to assume that the variables are normally distributed. Suppose $X$ is a random variable drawn from a Gaussian with mean $\mu_x$ and standard deviation $\sigma_x$. If $y = \beta_{y,x} x + \epsilon$ and epsilon is Gaussian noise (uncorrelated with $x$) with standard deviation $\sigma_x$, then the Pearson correlation coefficient, $\rho^2 = \beta_{y,x}^2 / (\beta_{y,x}^2 + \sigma_\epsilon^2/\sigma_x^2)$. Under these assumptions, the correlation coefficient is related to the mutual information: $$I(Y;X) = -1/2 \log(1-\rho^2) = 1/2 \log\left(1 + \beta_{y,x}^2 / (\sigma_\epsilon^2/\sigma_x^2)\right) $$ (using the definition of entropy for normal distributions). Actually, this is even true under some slightly weaker assumptions. If you really just want the entropy of $Y$, you can write it as a function of this expression as $H(Y) = I(X;Y) + H(Y|X)$. This type of analysis comes up in analyzing the capacity of the additive white Gaussian noise channel. Just a few qualitative comments about this solution. This mutual information is always non-negative and zero if $\beta=0$. I guess you can interpret $\sigma_x/\sigma_\epsilon$ as a signal-to-noise ratio (SNR). If the SNR is small then it washes out any informative value that $x$ has about $y$. Generally, the regression coefficient has no relationship to mutual information. I.e., you can find distributions with fixed $\beta$ where MI can be anything. Heuristically, though, it makes sense to think of the equation above as a lower bound. For another connection between regression and information theory, I can also suggest this paper showing the relationship between linear regression and transfer entropy.
Relationship between least-squares regression and information theory The entropy of the random variable $Y$, $H(Y$) is sometimes called a measure of your "uncertainty" about $Y$. What if you know about this other variable, $X$? Your uncertainty about $Y$ given $X$ will