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
|
|---|---|---|---|---|---|---|
15,801
|
How to perform residual analysis for binary/dichotomous independent predictors in linear regression?
|
It's true that conventional residual plots are harder work in this case: it can be (much) more difficult to see whether the distributions are about the same. But there are easy alternatives here. You are just comparing two distributions, and there are many good ways to do that. Some possibilities are side-by-side or superimposed quantile plots, histograms or box plots. My own prejudice is that box plots unadorned are often over-used here: they usually will suppress the detail we should want to look at, even if we can often dismiss it as unimportant. But you can eat your cake and have it.
You use R, but nothing statistical in your question is R-specific. Here I used Stata for a regression on a single binary predictor and then fired up quantile box plots comparing the residuals for the two levels of the predictor. The practical conclusion in this example is that the distributions are about the same.
More detail if the plot looks cryptic: For each distribution, we have a quantile plot, i.e. the ordered values are plotted versus their (fractional) rank. A box showing median and quartiles is superimposed. Hence each box is defined vertically in the usual way and horizontally because it is bounded by lines for fractional ranks $1/4$ and $3/4$.
Note: See also How to present box plot with an extreme outlier? including @Glen_b's example of similar plots using R. Such plots should be easy in any decent software; if not, your software is not decent.
|
How to perform residual analysis for binary/dichotomous independent predictors in linear regression?
|
It's true that conventional residual plots are harder work in this case: it can be (much) more difficult to see whether the distributions are about the same. But there are easy alternatives here. You
|
How to perform residual analysis for binary/dichotomous independent predictors in linear regression?
It's true that conventional residual plots are harder work in this case: it can be (much) more difficult to see whether the distributions are about the same. But there are easy alternatives here. You are just comparing two distributions, and there are many good ways to do that. Some possibilities are side-by-side or superimposed quantile plots, histograms or box plots. My own prejudice is that box plots unadorned are often over-used here: they usually will suppress the detail we should want to look at, even if we can often dismiss it as unimportant. But you can eat your cake and have it.
You use R, but nothing statistical in your question is R-specific. Here I used Stata for a regression on a single binary predictor and then fired up quantile box plots comparing the residuals for the two levels of the predictor. The practical conclusion in this example is that the distributions are about the same.
More detail if the plot looks cryptic: For each distribution, we have a quantile plot, i.e. the ordered values are plotted versus their (fractional) rank. A box showing median and quartiles is superimposed. Hence each box is defined vertically in the usual way and horizontally because it is bounded by lines for fractional ranks $1/4$ and $3/4$.
Note: See also How to present box plot with an extreme outlier? including @Glen_b's example of similar plots using R. Such plots should be easy in any decent software; if not, your software is not decent.
|
How to perform residual analysis for binary/dichotomous independent predictors in linear regression?
It's true that conventional residual plots are harder work in this case: it can be (much) more difficult to see whether the distributions are about the same. But there are easy alternatives here. You
|
15,802
|
How to uniformly project a hash to a fixed number of buckets
|
NB: putting in form the answer that emerged from discussion in comments so that it's easier to read for interested people
(updated version)
Suppose we have a source generating independent events that we want to distribute uniformly into $B$ buckets.
The key steps are:
hash each event $e$ to an integer $i$ of size $2^N$
project onto $\mathcal{R} \times [0, 1[$ as $p = \frac{i}{2^N}$
find matching bucket $b_i$ so that $\frac{b_i}{B} \le p \lt \frac{b_{i+1}}{B}$
For 1. a popular solution is to use MurmurHash to generate a 64 or 128 bits integer.
For 3. a simple solution is to iterate on $j = 1..B$ and check that $p$ is in $[\frac{b_j}{B}, \frac{b_{j+1}}{B}[$
In (python) pseudo-code the overall procedure could be:
def hash_to_bucket(e, B):
i = murmurhash3.to_long128(str(e))
p = i / float(2**128)
for j in range(0, B):
if j/float(B) <= p and (j+1)/float(B) > p:
return j+1
return B
(previous version, really not optimal)
The first observation is that the n-th letter of the hash should be uniformly distributed with respect to the alphabet (which is here 16 letters long - thanks to @leonbloy for pointing that out).
Then, to project it to a [0,100[ range, the trick is to take 2 letters from the hash (e.g. 1st and 2nd positions) and generate an integer with that:
int_value = int(hash[0])+16*int(hash[1])
This value lives in the range [0,16+(16-1)*16[, hence we just have to modulo it to 100 to generate a bucket in the [0, 100[ range:
As pointed out in the comments, doing so impact the uniformity of the distribution since the first letter is more influential than the second.
bucket = int_value % 100
In theory you can convert the whole hash into a (very big) integer by interpreting it as a number: i = h[0] + 16*h[1]+16*16*h[2] ... + 16^31*h[31] (each letter represents an hexadecimal number). Then you could modulo this big number to project it to the bucket space. One can then note that taking the modulo of i can be decomposed into a distributive and additive operation:
\begin{align}
i \mod N = (&\\
&(h_0 \mod N) \\
&+ (16 \mod N \times h_1 \mod N) \\
&+ ... \\
&+ (16^{31} \mod N \times h_{31} \mod N)\\
&) \mod N
\end{align}
|
How to uniformly project a hash to a fixed number of buckets
|
NB: putting in form the answer that emerged from discussion in comments so that it's easier to read for interested people
(updated version)
Suppose we have a source generating independent events that
|
How to uniformly project a hash to a fixed number of buckets
NB: putting in form the answer that emerged from discussion in comments so that it's easier to read for interested people
(updated version)
Suppose we have a source generating independent events that we want to distribute uniformly into $B$ buckets.
The key steps are:
hash each event $e$ to an integer $i$ of size $2^N$
project onto $\mathcal{R} \times [0, 1[$ as $p = \frac{i}{2^N}$
find matching bucket $b_i$ so that $\frac{b_i}{B} \le p \lt \frac{b_{i+1}}{B}$
For 1. a popular solution is to use MurmurHash to generate a 64 or 128 bits integer.
For 3. a simple solution is to iterate on $j = 1..B$ and check that $p$ is in $[\frac{b_j}{B}, \frac{b_{j+1}}{B}[$
In (python) pseudo-code the overall procedure could be:
def hash_to_bucket(e, B):
i = murmurhash3.to_long128(str(e))
p = i / float(2**128)
for j in range(0, B):
if j/float(B) <= p and (j+1)/float(B) > p:
return j+1
return B
(previous version, really not optimal)
The first observation is that the n-th letter of the hash should be uniformly distributed with respect to the alphabet (which is here 16 letters long - thanks to @leonbloy for pointing that out).
Then, to project it to a [0,100[ range, the trick is to take 2 letters from the hash (e.g. 1st and 2nd positions) and generate an integer with that:
int_value = int(hash[0])+16*int(hash[1])
This value lives in the range [0,16+(16-1)*16[, hence we just have to modulo it to 100 to generate a bucket in the [0, 100[ range:
As pointed out in the comments, doing so impact the uniformity of the distribution since the first letter is more influential than the second.
bucket = int_value % 100
In theory you can convert the whole hash into a (very big) integer by interpreting it as a number: i = h[0] + 16*h[1]+16*16*h[2] ... + 16^31*h[31] (each letter represents an hexadecimal number). Then you could modulo this big number to project it to the bucket space. One can then note that taking the modulo of i can be decomposed into a distributive and additive operation:
\begin{align}
i \mod N = (&\\
&(h_0 \mod N) \\
&+ (16 \mod N \times h_1 \mod N) \\
&+ ... \\
&+ (16^{31} \mod N \times h_{31} \mod N)\\
&) \mod N
\end{align}
|
How to uniformly project a hash to a fixed number of buckets
NB: putting in form the answer that emerged from discussion in comments so that it's easier to read for interested people
(updated version)
Suppose we have a source generating independent events that
|
15,803
|
How to uniformly project a hash to a fixed number of buckets
|
I had a similar problem and came up with a different solution which may be faster and more easily implemented in any language.
My first thought was to dispatch items quickly and uniformly in a fixed number of buckets, and also to be scalable, I should mimic randomness.
So I coded this little function returning a float number in [0, 1[ given a string (or any kind of data in fact).
Here in Python:
import math
def pseudo_random_checksum(s, precision=10000):
x = sum([ord(c) * math.sin(i + 1) for i,c in enumerate(s)]) * precision
return x - math.floor(x)
Off course it's not random, in fact it's not even pseudo random, the same data will always return the same checksum. But it acts like random and it's pretty fast.
You can easily dispatch and later retrieve items in N buckets by simply assigning each item to bucket number math.floor(N * pseudo_random_checksum(item)).
|
How to uniformly project a hash to a fixed number of buckets
|
I had a similar problem and came up with a different solution which may be faster and more easily implemented in any language.
My first thought was to dispatch items quickly and uniformly in a fixed n
|
How to uniformly project a hash to a fixed number of buckets
I had a similar problem and came up with a different solution which may be faster and more easily implemented in any language.
My first thought was to dispatch items quickly and uniformly in a fixed number of buckets, and also to be scalable, I should mimic randomness.
So I coded this little function returning a float number in [0, 1[ given a string (or any kind of data in fact).
Here in Python:
import math
def pseudo_random_checksum(s, precision=10000):
x = sum([ord(c) * math.sin(i + 1) for i,c in enumerate(s)]) * precision
return x - math.floor(x)
Off course it's not random, in fact it's not even pseudo random, the same data will always return the same checksum. But it acts like random and it's pretty fast.
You can easily dispatch and later retrieve items in N buckets by simply assigning each item to bucket number math.floor(N * pseudo_random_checksum(item)).
|
How to uniformly project a hash to a fixed number of buckets
I had a similar problem and came up with a different solution which may be faster and more easily implemented in any language.
My first thought was to dispatch items quickly and uniformly in a fixed n
|
15,804
|
How to uniformly project a hash to a fixed number of buckets
|
Here you can find a a branchless uniform bucket distribution that works with with bitwise operations.
|
How to uniformly project a hash to a fixed number of buckets
|
Here you can find a a branchless uniform bucket distribution that works with with bitwise operations.
|
How to uniformly project a hash to a fixed number of buckets
Here you can find a a branchless uniform bucket distribution that works with with bitwise operations.
|
How to uniformly project a hash to a fixed number of buckets
Here you can find a a branchless uniform bucket distribution that works with with bitwise operations.
|
15,805
|
Is there any difference between the terms "paired t-test" and "pairwise t-test"?
|
Roughly, paired t-test is a t-test in which each subject is compared with itself or, in other words, determines whether they differ from each other in a significant way under the assumptions that the paired differences are independent and identically normally distributed.
Pairwise t-test, on the other hand is a function in R which performs all possible pairwise comparisons. See this discussion for more information
|
Is there any difference between the terms "paired t-test" and "pairwise t-test"?
|
Roughly, paired t-test is a t-test in which each subject is compared with itself or, in other words, determines whether they differ from each other in a significant way under the assumptions that the
|
Is there any difference between the terms "paired t-test" and "pairwise t-test"?
Roughly, paired t-test is a t-test in which each subject is compared with itself or, in other words, determines whether they differ from each other in a significant way under the assumptions that the paired differences are independent and identically normally distributed.
Pairwise t-test, on the other hand is a function in R which performs all possible pairwise comparisons. See this discussion for more information
|
Is there any difference between the terms "paired t-test" and "pairwise t-test"?
Roughly, paired t-test is a t-test in which each subject is compared with itself or, in other words, determines whether they differ from each other in a significant way under the assumptions that the
|
15,806
|
Modelling a Poisson distribution with overdispersion
|
for overdispersed poisson, use the negative binomial, which allows you to parameterize the variance as a function of the mean precisely. rnbinom(), etc. in R.
|
Modelling a Poisson distribution with overdispersion
|
for overdispersed poisson, use the negative binomial, which allows you to parameterize the variance as a function of the mean precisely. rnbinom(), etc. in R.
|
Modelling a Poisson distribution with overdispersion
for overdispersed poisson, use the negative binomial, which allows you to parameterize the variance as a function of the mean precisely. rnbinom(), etc. in R.
|
Modelling a Poisson distribution with overdispersion
for overdispersed poisson, use the negative binomial, which allows you to parameterize the variance as a function of the mean precisely. rnbinom(), etc. in R.
|
15,807
|
Modelling a Poisson distribution with overdispersion
|
If your mean value for the Poisson is 1500, then you're very close to a normal distribution; you might try using that as an approximation and then modelling the mean and variance separately.
|
Modelling a Poisson distribution with overdispersion
|
If your mean value for the Poisson is 1500, then you're very close to a normal distribution; you might try using that as an approximation and then modelling the mean and variance separately.
|
Modelling a Poisson distribution with overdispersion
If your mean value for the Poisson is 1500, then you're very close to a normal distribution; you might try using that as an approximation and then modelling the mean and variance separately.
|
Modelling a Poisson distribution with overdispersion
If your mean value for the Poisson is 1500, then you're very close to a normal distribution; you might try using that as an approximation and then modelling the mean and variance separately.
|
15,808
|
What is energy minimization in machine learning?
|
Energy-based models are a unified framework for representing many machine learning algorithms. They interpret inference as minimizing an energy function and learning as minimizing a loss functional.
The energy function is a function of the configuration of latent variables, and the configuration of inputs provided in an example. Inference typically means finding a low energy configuration, or sampling from the possible configuration so that the probability of choosing a given configuration is a Gibbs distribution.
The loss functional is a function of the model parameters given many examples. E.g., in a supervised learning problem, your loss is the total error at the targets. It's sometimes called a "functional" because it's a function of the (parametrized) function that constitutes the model.
Major paper:
Y. LeCun, S. Chopra, R. Hadsell, M. Ranzato, and F. J. Huang, “A tutorial on energy-based learning,” in Predicting Structured Data, MIT Press, 2006.
Also see:
LeCun, Y., & Huang, F. J. (2005). Loss Functions for Discriminative Training of Energy-Based Models. In Proceedings of the 10th International Workshop on Artificial Intelligence and Statistics (AIStats’05). Retrieved from http://yann.lecun.com/exdb/publis/pdf/lecun-huang-05.pdf
Ranzato, M., Boureau, Y.-L., Chopra, S., & LeCun, Y. (2007). A Unified Energy-Based Framework for Unsupervised Learning. Proc. Conference on AI and Statistics (AI-Stats). Retrieved from http://dblp.uni-trier.de/db/journals/jmlr/jmlrp2.html#RanzatoBCL07
|
What is energy minimization in machine learning?
|
Energy-based models are a unified framework for representing many machine learning algorithms. They interpret inference as minimizing an energy function and learning as minimizing a loss functional.
|
What is energy minimization in machine learning?
Energy-based models are a unified framework for representing many machine learning algorithms. They interpret inference as minimizing an energy function and learning as minimizing a loss functional.
The energy function is a function of the configuration of latent variables, and the configuration of inputs provided in an example. Inference typically means finding a low energy configuration, or sampling from the possible configuration so that the probability of choosing a given configuration is a Gibbs distribution.
The loss functional is a function of the model parameters given many examples. E.g., in a supervised learning problem, your loss is the total error at the targets. It's sometimes called a "functional" because it's a function of the (parametrized) function that constitutes the model.
Major paper:
Y. LeCun, S. Chopra, R. Hadsell, M. Ranzato, and F. J. Huang, “A tutorial on energy-based learning,” in Predicting Structured Data, MIT Press, 2006.
Also see:
LeCun, Y., & Huang, F. J. (2005). Loss Functions for Discriminative Training of Energy-Based Models. In Proceedings of the 10th International Workshop on Artificial Intelligence and Statistics (AIStats’05). Retrieved from http://yann.lecun.com/exdb/publis/pdf/lecun-huang-05.pdf
Ranzato, M., Boureau, Y.-L., Chopra, S., & LeCun, Y. (2007). A Unified Energy-Based Framework for Unsupervised Learning. Proc. Conference on AI and Statistics (AI-Stats). Retrieved from http://dblp.uni-trier.de/db/journals/jmlr/jmlrp2.html#RanzatoBCL07
|
What is energy minimization in machine learning?
Energy-based models are a unified framework for representing many machine learning algorithms. They interpret inference as minimizing an energy function and learning as minimizing a loss functional.
|
15,809
|
What is energy minimization in machine learning?
|
In signal detection literature, the energy of a signal $x_t$ is defined as
$$
E = \Sigma x_t^2
$$
When predicting some response y from some features x, a very common and simple way to proceed is to minimise the sum of the squared errors
$$
SSE= \Sigma (y-\hat{y})^2
$$
where $\hat{y}$ is the fitted response. Notice the similarity? The SSE is energy. This energy is minimised by the fitted parameters.
|
What is energy minimization in machine learning?
|
In signal detection literature, the energy of a signal $x_t$ is defined as
$$
E = \Sigma x_t^2
$$
When predicting some response y from some features x, a very common and simple way to proceed is to mi
|
What is energy minimization in machine learning?
In signal detection literature, the energy of a signal $x_t$ is defined as
$$
E = \Sigma x_t^2
$$
When predicting some response y from some features x, a very common and simple way to proceed is to minimise the sum of the squared errors
$$
SSE= \Sigma (y-\hat{y})^2
$$
where $\hat{y}$ is the fitted response. Notice the similarity? The SSE is energy. This energy is minimised by the fitted parameters.
|
What is energy minimization in machine learning?
In signal detection literature, the energy of a signal $x_t$ is defined as
$$
E = \Sigma x_t^2
$$
When predicting some response y from some features x, a very common and simple way to proceed is to mi
|
15,810
|
Do we really perform multivariate regression analysis with *million* coefficients/independent variables?
|
Does this really happen or is it a theoretical issue?
It happens, see any popular deeplearning model for computer vision. Say, alexnet has a dense connection between 2048 and 2048 units, that's 4 million coefficients.
What's the point of analyzing a million IVs? Does it really give us that much increase in value of information gained as opposed to ignoring them?
If you're analyzing highly categorical data (say, internet advertisement data), your model has to keep some meaningful 'descriptions' for each category (e.g. city, page id, sitename, advertisement id, user id, etc.), the actual size of 'description' depends on the selected ML model.
Even simple logistic regression will have dozens of thousands of parameters to be fitted (one per category). More advanced models like factorization machines are going to have times more.
Or is it because, initially we have no idea what is useful, so we just run the damn regression to see what is useful and go from there and possibly prune the set of IVs?
Actually, most of fitted parameters in these models can be dropped, but you can not know that beforehand, so you leave the problem of defining which parameters are important to machine learning, and impose some regularizations to put 'soft limit' to the effective number of parameters to stay.
... and I think you'll find such examples later in your ML course.
|
Do we really perform multivariate regression analysis with *million* coefficients/independent variab
|
Does this really happen or is it a theoretical issue?
It happens, see any popular deeplearning model for computer vision. Say, alexnet has a dense connection between 2048 and 2048 units, that's 4 mil
|
Do we really perform multivariate regression analysis with *million* coefficients/independent variables?
Does this really happen or is it a theoretical issue?
It happens, see any popular deeplearning model for computer vision. Say, alexnet has a dense connection between 2048 and 2048 units, that's 4 million coefficients.
What's the point of analyzing a million IVs? Does it really give us that much increase in value of information gained as opposed to ignoring them?
If you're analyzing highly categorical data (say, internet advertisement data), your model has to keep some meaningful 'descriptions' for each category (e.g. city, page id, sitename, advertisement id, user id, etc.), the actual size of 'description' depends on the selected ML model.
Even simple logistic regression will have dozens of thousands of parameters to be fitted (one per category). More advanced models like factorization machines are going to have times more.
Or is it because, initially we have no idea what is useful, so we just run the damn regression to see what is useful and go from there and possibly prune the set of IVs?
Actually, most of fitted parameters in these models can be dropped, but you can not know that beforehand, so you leave the problem of defining which parameters are important to machine learning, and impose some regularizations to put 'soft limit' to the effective number of parameters to stay.
... and I think you'll find such examples later in your ML course.
|
Do we really perform multivariate regression analysis with *million* coefficients/independent variab
Does this really happen or is it a theoretical issue?
It happens, see any popular deeplearning model for computer vision. Say, alexnet has a dense connection between 2048 and 2048 units, that's 4 mil
|
15,811
|
Is up- or down-sampling imbalanced data actually that effective? Why?
|
The short answer appears to be Yes: there is some evidence that upsampling of the minority class and/or downsampling of the majority class in a training set can somewhat improve out-of-sample AUC (area under the ROC curve, a threshold-independent metric) even on the unaltered, unbalanced data distribution.
With that said, in most or all of the examples I've seen, the increases in AUC are very modest -- a typical "best case" (i.e., best over all the models and sampling methods examined by an author) would be, say, AUC = .91 without up/downsampling vs. AUC = .93 with up/downsampling. I haven't seen any example where applying up/downsampling could turn a bad AUC into a good AUC in any circumstance. I'm also not aware of evidence that upsampling/downsampling can improve generalization under a strictly proper scoring rule like the Brier score (see this great answer for more info about that).
Some evidence
The most direct evidence I've seen, and the only one that includes some theoretical analysis, is from this paper Why Does Rebalancing Class-Unbalanced
Data Improve AUC for Linear Discriminant
Analysis?. The authors show that when using LDA on two Gaussian classes with unequal covariance matrices (contrary to an assumption of LDA), both simple upsampling and simple downsampling (nothing fancier like SMOTE) to achieve 50:50 class balance can improve generalization for the unbalanced data distribution. Here's a key figure:
In this paper Handling class imbalance in customer churn prediction, the authors examine both simple downsampling ("under-sampling") and an "advanced under-sampling method" called CUBE, for logistic regression and random forest. They conclude that downsampling helps, but CUBE does not seem to improve over simple downsampling to any meaningful extent. In this key figure, the leftmost point on each curve is for the unaltered dataset with no downsampling:
In this example from the docs for the imbalanced-learn Python package, the authors examine the AUC performance of a K nearest neighbors classifier under three sophisticated up/downsampling methods as well as baseline (no up/downsampling). Here is the key figure showing the ROC curves:
I found this R notebook that looks at logistic regression, comparing cross-validated AUC for baseline (no up/downsamping) vs. simple downsampling vs. a more sophisticated upsampling method called ROSE. The author concludes that simple downsampling doesn't help much overall, but that ROSE leads to a somewhat better ROC curve overall. In the key figure below,
green curve = ROSE (AUC = .639)
black curve = baseline (AUC = .587)
red curve = simple downsampling (AUC = .575)
|
Is up- or down-sampling imbalanced data actually that effective? Why?
|
The short answer appears to be Yes: there is some evidence that upsampling of the minority class and/or downsampling of the majority class in a training set can somewhat improve out-of-sample AUC (are
|
Is up- or down-sampling imbalanced data actually that effective? Why?
The short answer appears to be Yes: there is some evidence that upsampling of the minority class and/or downsampling of the majority class in a training set can somewhat improve out-of-sample AUC (area under the ROC curve, a threshold-independent metric) even on the unaltered, unbalanced data distribution.
With that said, in most or all of the examples I've seen, the increases in AUC are very modest -- a typical "best case" (i.e., best over all the models and sampling methods examined by an author) would be, say, AUC = .91 without up/downsampling vs. AUC = .93 with up/downsampling. I haven't seen any example where applying up/downsampling could turn a bad AUC into a good AUC in any circumstance. I'm also not aware of evidence that upsampling/downsampling can improve generalization under a strictly proper scoring rule like the Brier score (see this great answer for more info about that).
Some evidence
The most direct evidence I've seen, and the only one that includes some theoretical analysis, is from this paper Why Does Rebalancing Class-Unbalanced
Data Improve AUC for Linear Discriminant
Analysis?. The authors show that when using LDA on two Gaussian classes with unequal covariance matrices (contrary to an assumption of LDA), both simple upsampling and simple downsampling (nothing fancier like SMOTE) to achieve 50:50 class balance can improve generalization for the unbalanced data distribution. Here's a key figure:
In this paper Handling class imbalance in customer churn prediction, the authors examine both simple downsampling ("under-sampling") and an "advanced under-sampling method" called CUBE, for logistic regression and random forest. They conclude that downsampling helps, but CUBE does not seem to improve over simple downsampling to any meaningful extent. In this key figure, the leftmost point on each curve is for the unaltered dataset with no downsampling:
In this example from the docs for the imbalanced-learn Python package, the authors examine the AUC performance of a K nearest neighbors classifier under three sophisticated up/downsampling methods as well as baseline (no up/downsampling). Here is the key figure showing the ROC curves:
I found this R notebook that looks at logistic regression, comparing cross-validated AUC for baseline (no up/downsamping) vs. simple downsampling vs. a more sophisticated upsampling method called ROSE. The author concludes that simple downsampling doesn't help much overall, but that ROSE leads to a somewhat better ROC curve overall. In the key figure below,
green curve = ROSE (AUC = .639)
black curve = baseline (AUC = .587)
red curve = simple downsampling (AUC = .575)
|
Is up- or down-sampling imbalanced data actually that effective? Why?
The short answer appears to be Yes: there is some evidence that upsampling of the minority class and/or downsampling of the majority class in a training set can somewhat improve out-of-sample AUC (are
|
15,812
|
Is up- or down-sampling imbalanced data actually that effective? Why?
|
If you want to first to collect sample to do classification based on these results, then undersampling might be necessary even from the cost perpective.
But in this case your estimation methods typically do not return population level probabilities, they are conditional on the sampling scheme which was used.
Here is example:
https://stats.stackexchange.com/questions/127476/inference-possibilities-for-matched-case-control-study
|
Is up- or down-sampling imbalanced data actually that effective? Why?
|
If you want to first to collect sample to do classification based on these results, then undersampling might be necessary even from the cost perpective.
But in this case your estimation methods typic
|
Is up- or down-sampling imbalanced data actually that effective? Why?
If you want to first to collect sample to do classification based on these results, then undersampling might be necessary even from the cost perpective.
But in this case your estimation methods typically do not return population level probabilities, they are conditional on the sampling scheme which was used.
Here is example:
https://stats.stackexchange.com/questions/127476/inference-possibilities-for-matched-case-control-study
|
Is up- or down-sampling imbalanced data actually that effective? Why?
If you want to first to collect sample to do classification based on these results, then undersampling might be necessary even from the cost perpective.
But in this case your estimation methods typic
|
15,813
|
Meaning of a convergence warning in glmer
|
Before going in to the code, allow me to give you a quick primer on trust region methods. Let $f(x)$ be your objective function and $x_k$ be your current iterate. Iteration $k$ of a generic trust region method looks something like this:
Pick a maximum step size, $\Delta_k$
Build an model of $f(x)$ at $x = x_k$; call it $Q(x)$.
Find the step, $s_k$, that minimizes $Q_k(x_k + s_k)$ subject to the constraint $||s_k|| \leq \Delta_k$
If $s_k$ is "good enough", let $x_{k+1} = x_k + s_k$
Otherwise, refine your model and try again
One of the the ways you determine if $s_k$ is "good enough" is by comparing the decrease predicted by the model to the actual decrease in the objective function. This is what the portion of the code after 430 does. However, before that, there's a quick sanity check to see if the model predicts a decrease AT ALL. And that's what's happening at 430.
To understand the value of VQUAD, we first have to understand a few other variables. Fortunately, there are good comments right below the declaration of SUBROUTINE BOBYQB. The salient variables are:
GOPT, the gradient of the model
HQ, the Hessian of the model
D, the trial step (I called this $s_k$ above)
Beginning a few lines above 410, you'll see DO 410 J=1,N. This begins a for-loop (and a nested for-loop) that evaluates the change predicted by the model using trial step D. It accumulates the predicted change in VQUAD. The first part of the for-loop evaluates the first-order terms and the nested for-loop evaluates the second-order terms. It would probably be easier to read if the loops were indented, like this:
DO 410 J=1,N
VQUAD=VQUAD+D(J)*GOPT(J)
DO 410 I=1,J
IH=IH+1
TEMP=D(I)*D(J)
IF (I .EQ. J) TEMP=HALF*TEMP
410 VQUAD=VQUAD+HQ(IH)*TEMP
There's another for-loop after this to incorporate other parameters in to the model. I have to admit, I don't fully understand this - my best guess is that it's particular to how they build the model.
At the end of all this, VQUAD holds the change in objective function predicted by the model. So if VQUAD is non-negative, that's bad. Now this particular solver can use an alternative step computation (probably a line search), which is where NTRITS comes in to play. So the logic at 430 is saying, "If the last iteration used the alternative step computation AND the model does not predict a decrease AND IPRINT > 0, print the warning message." Note that the solver is going to terminate regardless of the value of IPRINT.
Speaking of IPRINT, that value is passed to BOBYQA by the calling function. In this case, your R routine is the calling function. There's a verbose parameter to glmer - I would be dimes to dollars that same value is passed to BOBYQA. Try setting verbose to 0 and you probably won't see the warning. But it won't change what's going on under the hood, of course.
|
Meaning of a convergence warning in glmer
|
Before going in to the code, allow me to give you a quick primer on trust region methods. Let $f(x)$ be your objective function and $x_k$ be your current iterate. Iteration $k$ of a generic trust re
|
Meaning of a convergence warning in glmer
Before going in to the code, allow me to give you a quick primer on trust region methods. Let $f(x)$ be your objective function and $x_k$ be your current iterate. Iteration $k$ of a generic trust region method looks something like this:
Pick a maximum step size, $\Delta_k$
Build an model of $f(x)$ at $x = x_k$; call it $Q(x)$.
Find the step, $s_k$, that minimizes $Q_k(x_k + s_k)$ subject to the constraint $||s_k|| \leq \Delta_k$
If $s_k$ is "good enough", let $x_{k+1} = x_k + s_k$
Otherwise, refine your model and try again
One of the the ways you determine if $s_k$ is "good enough" is by comparing the decrease predicted by the model to the actual decrease in the objective function. This is what the portion of the code after 430 does. However, before that, there's a quick sanity check to see if the model predicts a decrease AT ALL. And that's what's happening at 430.
To understand the value of VQUAD, we first have to understand a few other variables. Fortunately, there are good comments right below the declaration of SUBROUTINE BOBYQB. The salient variables are:
GOPT, the gradient of the model
HQ, the Hessian of the model
D, the trial step (I called this $s_k$ above)
Beginning a few lines above 410, you'll see DO 410 J=1,N. This begins a for-loop (and a nested for-loop) that evaluates the change predicted by the model using trial step D. It accumulates the predicted change in VQUAD. The first part of the for-loop evaluates the first-order terms and the nested for-loop evaluates the second-order terms. It would probably be easier to read if the loops were indented, like this:
DO 410 J=1,N
VQUAD=VQUAD+D(J)*GOPT(J)
DO 410 I=1,J
IH=IH+1
TEMP=D(I)*D(J)
IF (I .EQ. J) TEMP=HALF*TEMP
410 VQUAD=VQUAD+HQ(IH)*TEMP
There's another for-loop after this to incorporate other parameters in to the model. I have to admit, I don't fully understand this - my best guess is that it's particular to how they build the model.
At the end of all this, VQUAD holds the change in objective function predicted by the model. So if VQUAD is non-negative, that's bad. Now this particular solver can use an alternative step computation (probably a line search), which is where NTRITS comes in to play. So the logic at 430 is saying, "If the last iteration used the alternative step computation AND the model does not predict a decrease AND IPRINT > 0, print the warning message." Note that the solver is going to terminate regardless of the value of IPRINT.
Speaking of IPRINT, that value is passed to BOBYQA by the calling function. In this case, your R routine is the calling function. There's a verbose parameter to glmer - I would be dimes to dollars that same value is passed to BOBYQA. Try setting verbose to 0 and you probably won't see the warning. But it won't change what's going on under the hood, of course.
|
Meaning of a convergence warning in glmer
Before going in to the code, allow me to give you a quick primer on trust region methods. Let $f(x)$ be your objective function and $x_k$ be your current iterate. Iteration $k$ of a generic trust re
|
15,814
|
What's the deal with autocorrelation?
|
I think the author is probably talking about the residuals of the model. I argue this because of his statement about adding more fourier coefficients; if, as I believe, he is fitting a fourier model, then adding more coefficients will reduce the autocorrelation of the residuals at the expense of a higher CV.
If you have trouble visualizing this, think of the following example: suppose you have the following 100 points data set, which comes from a two-coefficient fourier model with addeded white gaussian noise:
The following graph shows two fits: one done with 2 fourier coefficients, and one done with 200 fourier coefficients:
As you can see, the 200 fourier coefficients fits the DATAPOINTS better, while the 2 coefficient fit (the 'real' model) fits the MODEL better. This implies that the autocorrelation of the residuals of the model with 200 coefficients will almost surely be closer to zero at all lags than the residuals of the 2 coefficient model, because the model with 200 coefficients fits exactly almost all datapoints (i.e., the residuals will be almost all zeros). However, what would you think will happen if you leave, say, 10 datapoints out of the sample and fit the same models? The 2-coefficient model will predict better the datapoints you leaved out of the sample! Thus, it will produce a lower CV error as opossed to the 200-coefficient model; this is called overfitting. The reason behind this 'magic' is because what CV actually tries to measure is prediction error, i.e., how well your model predicts datapoints not in your dataset.
In this context, autocorrelation on the residuals is 'bad', because
it means you are not modeling the correlation between datapoints
well enough. The main reason why people don't difference the series is because they actually want to model the underlying process as it is. One differences the time series usually to get rid of periodicities or trends, but if that periodicity or trend is actually what you are trying to model, then differencing them might seem like a last resort option (or an option in order to model the residuals with a more complex stochastic process).
This really depends on the area you are working on. It could be a problem with the deterministic model also. However, depending on the form of the autocorrelation, it can be easily seen when the autocorrelation arises due to, e.g., flicker noise, ARMA-like noise or if it is a residual underlying periodic source (in which case you would maybe want to increase the number of fourier coefficients).
|
What's the deal with autocorrelation?
|
I think the author is probably talking about the residuals of the model. I argue this because of his statement about adding more fourier coefficients; if, as I believe, he is fitting a fourier model,
|
What's the deal with autocorrelation?
I think the author is probably talking about the residuals of the model. I argue this because of his statement about adding more fourier coefficients; if, as I believe, he is fitting a fourier model, then adding more coefficients will reduce the autocorrelation of the residuals at the expense of a higher CV.
If you have trouble visualizing this, think of the following example: suppose you have the following 100 points data set, which comes from a two-coefficient fourier model with addeded white gaussian noise:
The following graph shows two fits: one done with 2 fourier coefficients, and one done with 200 fourier coefficients:
As you can see, the 200 fourier coefficients fits the DATAPOINTS better, while the 2 coefficient fit (the 'real' model) fits the MODEL better. This implies that the autocorrelation of the residuals of the model with 200 coefficients will almost surely be closer to zero at all lags than the residuals of the 2 coefficient model, because the model with 200 coefficients fits exactly almost all datapoints (i.e., the residuals will be almost all zeros). However, what would you think will happen if you leave, say, 10 datapoints out of the sample and fit the same models? The 2-coefficient model will predict better the datapoints you leaved out of the sample! Thus, it will produce a lower CV error as opossed to the 200-coefficient model; this is called overfitting. The reason behind this 'magic' is because what CV actually tries to measure is prediction error, i.e., how well your model predicts datapoints not in your dataset.
In this context, autocorrelation on the residuals is 'bad', because
it means you are not modeling the correlation between datapoints
well enough. The main reason why people don't difference the series is because they actually want to model the underlying process as it is. One differences the time series usually to get rid of periodicities or trends, but if that periodicity or trend is actually what you are trying to model, then differencing them might seem like a last resort option (or an option in order to model the residuals with a more complex stochastic process).
This really depends on the area you are working on. It could be a problem with the deterministic model also. However, depending on the form of the autocorrelation, it can be easily seen when the autocorrelation arises due to, e.g., flicker noise, ARMA-like noise or if it is a residual underlying periodic source (in which case you would maybe want to increase the number of fourier coefficients).
|
What's the deal with autocorrelation?
I think the author is probably talking about the residuals of the model. I argue this because of his statement about adding more fourier coefficients; if, as I believe, he is fitting a fourier model,
|
15,815
|
What's the deal with autocorrelation?
|
I found this paper 'Spurious Regressions in Econometrics' helpful when trying to get my head around why eliminating trends is necessary. Essentially if two variables are trending then they'll co-vary, which is a recipe for trouble.
|
What's the deal with autocorrelation?
|
I found this paper 'Spurious Regressions in Econometrics' helpful when trying to get my head around why eliminating trends is necessary. Essentially if two variables are trending then they'll co-vary,
|
What's the deal with autocorrelation?
I found this paper 'Spurious Regressions in Econometrics' helpful when trying to get my head around why eliminating trends is necessary. Essentially if two variables are trending then they'll co-vary, which is a recipe for trouble.
|
What's the deal with autocorrelation?
I found this paper 'Spurious Regressions in Econometrics' helpful when trying to get my head around why eliminating trends is necessary. Essentially if two variables are trending then they'll co-vary,
|
15,816
|
Learning statistical concepts through data analysis exercises
|
As I have to explain variable selection methods quite often, not in a teaching context, but for non-statisticians requesting aid with their research, I love this extremely simple example that illustrates why single variable selection is not necessarily a good idea.
If you have this dataset:
y X1 x2
1 1 1
1 0 0
0 1 0
0 0 1
It doesn't take long to realize that both X1 and X2 individually are completely noninformative for y (when they are the same, y is 'certain' to be 1 - I'm ignoring sample size issues here, just assume these four observations to be the whole universe). However, the combination of the two variables is completely informative. As such, it is more easy for people to understand why it is not a good idea to (e.g.) only check the p-value for models with each individual variable as a regressor.
In my experience, this really gets the message through.
|
Learning statistical concepts through data analysis exercises
|
As I have to explain variable selection methods quite often, not in a teaching context, but for non-statisticians requesting aid with their research, I love this extremely simple example that illustra
|
Learning statistical concepts through data analysis exercises
As I have to explain variable selection methods quite often, not in a teaching context, but for non-statisticians requesting aid with their research, I love this extremely simple example that illustrates why single variable selection is not necessarily a good idea.
If you have this dataset:
y X1 x2
1 1 1
1 0 0
0 1 0
0 0 1
It doesn't take long to realize that both X1 and X2 individually are completely noninformative for y (when they are the same, y is 'certain' to be 1 - I'm ignoring sample size issues here, just assume these four observations to be the whole universe). However, the combination of the two variables is completely informative. As such, it is more easy for people to understand why it is not a good idea to (e.g.) only check the p-value for models with each individual variable as a regressor.
In my experience, this really gets the message through.
|
Learning statistical concepts through data analysis exercises
As I have to explain variable selection methods quite often, not in a teaching context, but for non-statisticians requesting aid with their research, I love this extremely simple example that illustra
|
15,817
|
Learning statistical concepts through data analysis exercises
|
Multiple Regression Coefficients and the Expected Sign Fallacy
One of my favorite illustrations of a statistical concept through a data analysis exercise is the deconstruction of a multiple regression into multiple bivariate regressions.
Objectives
To clarify the meaning of regression
coefficients in the presence of
multiple predictors.
To illustrate why it is incorrect to
“expect” a multiple regression
coefficient to have a particular sign
based on its bivariate relationship
with Y when the predictors are
correlated.
Concept
The regression coefficients in a multiple regression model represent the relationship between a) the part of a given predictor variable (x1) that is not related to all of the other predictor variables (x2...xN) in the model; and 2) the part of the response variable (Y) that is not related to all of the other predictor variables (x2...xN) in the model. When there is correlation among the predictors, the signs associated with the predictor coefficients represent the relationships among those residuals.
Exercise
Generate some random data for two
predictors (x1, x2) and a response
(y).
Regress y on x2 and store the
residuals.
Regress x1 on x2 and store the
residuals.
Regress the residuals of step 2 (r1)
on the residuals of step 3 (r2).
The coefficient for step 4 for r2 will be the coefficient of x1 for the multiple regression model with x1 and x2. You could do the same for x2 by partialing out x1 for both y and x2.
Here's some R code for this exercise.
set.seed(3338)
x1 <- rnorm(100)
x2 <- rnorm(100)
y <- 0 + 2*x1 + 5*x2 + rnorm(100)
lm(y ~ x1 + x2) # Multiple regression Model
ry1 <- residuals( lm( y ~ x2) ) # The part of y not related to x2
rx1 <- residuals( lm(x1 ~ x2) ) # The part of x1 not related to x2
lm( ry1 ~ rx1)
ry2 <- residuals( lm( y ~ x1) ) # The part of y not related to x1
rx2 <- residuals( lm(x2 ~ x1) ) # The part of x2 not related to x1
lm( ry2 ~ rx2)
Here are the relevant outputs and results.
Call:
lm(formula = y ~ x1 + x2)
Coefficients:
(Intercept) ***x1*** ***x2***
-0.02410 ***1.89527*** ***5.07549***
Call:
lm(formula = ry1 ~ rx1)
Coefficients:
(Intercept) ***rx1***
-2.854e-17 ***1.895e+00***
Call:
lm(formula = ry2 ~ rx2)
Coefficients:
(Intercept) ***rx2***
3.406e-17 ***5.075e+00***
|
Learning statistical concepts through data analysis exercises
|
Multiple Regression Coefficients and the Expected Sign Fallacy
One of my favorite illustrations of a statistical concept through a data analysis exercise is the deconstruction of a multiple regression
|
Learning statistical concepts through data analysis exercises
Multiple Regression Coefficients and the Expected Sign Fallacy
One of my favorite illustrations of a statistical concept through a data analysis exercise is the deconstruction of a multiple regression into multiple bivariate regressions.
Objectives
To clarify the meaning of regression
coefficients in the presence of
multiple predictors.
To illustrate why it is incorrect to
“expect” a multiple regression
coefficient to have a particular sign
based on its bivariate relationship
with Y when the predictors are
correlated.
Concept
The regression coefficients in a multiple regression model represent the relationship between a) the part of a given predictor variable (x1) that is not related to all of the other predictor variables (x2...xN) in the model; and 2) the part of the response variable (Y) that is not related to all of the other predictor variables (x2...xN) in the model. When there is correlation among the predictors, the signs associated with the predictor coefficients represent the relationships among those residuals.
Exercise
Generate some random data for two
predictors (x1, x2) and a response
(y).
Regress y on x2 and store the
residuals.
Regress x1 on x2 and store the
residuals.
Regress the residuals of step 2 (r1)
on the residuals of step 3 (r2).
The coefficient for step 4 for r2 will be the coefficient of x1 for the multiple regression model with x1 and x2. You could do the same for x2 by partialing out x1 for both y and x2.
Here's some R code for this exercise.
set.seed(3338)
x1 <- rnorm(100)
x2 <- rnorm(100)
y <- 0 + 2*x1 + 5*x2 + rnorm(100)
lm(y ~ x1 + x2) # Multiple regression Model
ry1 <- residuals( lm( y ~ x2) ) # The part of y not related to x2
rx1 <- residuals( lm(x1 ~ x2) ) # The part of x1 not related to x2
lm( ry1 ~ rx1)
ry2 <- residuals( lm( y ~ x1) ) # The part of y not related to x1
rx2 <- residuals( lm(x2 ~ x1) ) # The part of x2 not related to x1
lm( ry2 ~ rx2)
Here are the relevant outputs and results.
Call:
lm(formula = y ~ x1 + x2)
Coefficients:
(Intercept) ***x1*** ***x2***
-0.02410 ***1.89527*** ***5.07549***
Call:
lm(formula = ry1 ~ rx1)
Coefficients:
(Intercept) ***rx1***
-2.854e-17 ***1.895e+00***
Call:
lm(formula = ry2 ~ rx2)
Coefficients:
(Intercept) ***rx2***
3.406e-17 ***5.075e+00***
|
Learning statistical concepts through data analysis exercises
Multiple Regression Coefficients and the Expected Sign Fallacy
One of my favorite illustrations of a statistical concept through a data analysis exercise is the deconstruction of a multiple regression
|
15,818
|
How meaningful is the connection between MLE and cross entropy in deep learning?
|
Neural nets don't necessarily give probabilities as outputs, but they can be designed to do this. To be interpreted as probabilities, a set of values must be nonnegative and sum to one. Designing a network to output probabilities typically amounts to choosing an output layer that imposes these constraints. For example, in a classification problem with $k$ classes, a common choice is a softmax output layer with $k$ units. The softmax function forces the outputs to be nonnegative and sum to one. The $j$th output unit gives the probability that the class is $j$. For binary classification problems, another popular choice is to use a single output unit with logistic activation function. The output of the logistic function is between zero and one, and gives the probability that the class is 1. The probability that the class is 0 is implicitly one minus this value. If the network contains no hidden layers, then these two examples are equivalent to multinomial logistic regression and logistic regression, respectively.
Cross entropy $H(p, q)$ measures the difference between two probability distributions $p$ and $q$. When cross entropy is used as a loss function for discriminative classifiers, $p$ and $q$ are distributions over class labels, given the input (i.e. a particular data point). $p$ is the 'true' distribution and $q$ is the distribution predicted by the model. In typical classification problems, each input in the dataset is associated with an integer label representing the true class. In this case, we use the empirical distribution for $p$. This simply assigns probability 1 to the true class of a data point, and probability 0 to all other classes. $q$ is the distribution of class probabilities predicted by the network (e.g. as described above).
Say the data are i.i.d., $p_i$ is the empirical distribution, and $q_i$ is the predicted distribution (for the $i$th data point). Then, minimizing the cross entropy loss (i.e. $H(p_i, q_i)$ averaged over data points) is equivalent to maximizing the likelihood of the data. The proof is relatively straightforward. The basic idea is to show that the cross entropy loss is proportional to a sum of negative log predicted probabilities of the data points. This falls out neatly because of the form of the empirical distribution.
Cross entropy loss can also be applied more generally. For example, in 'soft classification' problems, we're given distributions over class labels rather than hard class labels (so we don't use the empirical distribution). I describe how to use cross entropy loss in that case here.
To address some other specifics in your question:
Different training and prediction probabilities
It looks like you're finding the output unit with maximum activation and comparing this to the class label. This isn't done for training using the cross entropy loss. Instead, the probabilities output by the model are compared to the 'true' probabilities (typically taken to be the empirical distribution).
Shanon entropy applies to a specific kind of encoding, which is not the one being used in training the network.
Cross entropy $H(p,q)$ can be interpreted as the number of bits per message needed (on average) to encode events drawn from true distribution $p$, if using an optimal code for distribution $q$. Cross entropy takes a minimum value of $H(p)$ (the Shannon entropy of $p$) when $q = p$. The better the match between $q$ and $p$, the shorter the message length. Training a model to minimize the cross entropy can be seen as training it to better approximate the true distribution. In supervised learning problems like we've been discussing, the model gives a probability distribution over possible outputs, given the input. Explicitly finding optimal codes for the distribution isn't part of the process.
|
How meaningful is the connection between MLE and cross entropy in deep learning?
|
Neural nets don't necessarily give probabilities as outputs, but they can be designed to do this. To be interpreted as probabilities, a set of values must be nonnegative and sum to one. Designing a ne
|
How meaningful is the connection between MLE and cross entropy in deep learning?
Neural nets don't necessarily give probabilities as outputs, but they can be designed to do this. To be interpreted as probabilities, a set of values must be nonnegative and sum to one. Designing a network to output probabilities typically amounts to choosing an output layer that imposes these constraints. For example, in a classification problem with $k$ classes, a common choice is a softmax output layer with $k$ units. The softmax function forces the outputs to be nonnegative and sum to one. The $j$th output unit gives the probability that the class is $j$. For binary classification problems, another popular choice is to use a single output unit with logistic activation function. The output of the logistic function is between zero and one, and gives the probability that the class is 1. The probability that the class is 0 is implicitly one minus this value. If the network contains no hidden layers, then these two examples are equivalent to multinomial logistic regression and logistic regression, respectively.
Cross entropy $H(p, q)$ measures the difference between two probability distributions $p$ and $q$. When cross entropy is used as a loss function for discriminative classifiers, $p$ and $q$ are distributions over class labels, given the input (i.e. a particular data point). $p$ is the 'true' distribution and $q$ is the distribution predicted by the model. In typical classification problems, each input in the dataset is associated with an integer label representing the true class. In this case, we use the empirical distribution for $p$. This simply assigns probability 1 to the true class of a data point, and probability 0 to all other classes. $q$ is the distribution of class probabilities predicted by the network (e.g. as described above).
Say the data are i.i.d., $p_i$ is the empirical distribution, and $q_i$ is the predicted distribution (for the $i$th data point). Then, minimizing the cross entropy loss (i.e. $H(p_i, q_i)$ averaged over data points) is equivalent to maximizing the likelihood of the data. The proof is relatively straightforward. The basic idea is to show that the cross entropy loss is proportional to a sum of negative log predicted probabilities of the data points. This falls out neatly because of the form of the empirical distribution.
Cross entropy loss can also be applied more generally. For example, in 'soft classification' problems, we're given distributions over class labels rather than hard class labels (so we don't use the empirical distribution). I describe how to use cross entropy loss in that case here.
To address some other specifics in your question:
Different training and prediction probabilities
It looks like you're finding the output unit with maximum activation and comparing this to the class label. This isn't done for training using the cross entropy loss. Instead, the probabilities output by the model are compared to the 'true' probabilities (typically taken to be the empirical distribution).
Shanon entropy applies to a specific kind of encoding, which is not the one being used in training the network.
Cross entropy $H(p,q)$ can be interpreted as the number of bits per message needed (on average) to encode events drawn from true distribution $p$, if using an optimal code for distribution $q$. Cross entropy takes a minimum value of $H(p)$ (the Shannon entropy of $p$) when $q = p$. The better the match between $q$ and $p$, the shorter the message length. Training a model to minimize the cross entropy can be seen as training it to better approximate the true distribution. In supervised learning problems like we've been discussing, the model gives a probability distribution over possible outputs, given the input. Explicitly finding optimal codes for the distribution isn't part of the process.
|
How meaningful is the connection between MLE and cross entropy in deep learning?
Neural nets don't necessarily give probabilities as outputs, but they can be designed to do this. To be interpreted as probabilities, a set of values must be nonnegative and sum to one. Designing a ne
|
15,819
|
How meaningful is the connection between MLE and cross entropy in deep learning?
|
I'll answer from a slightly more general perspective, concerning the nature of how, when, and why we can consider NN outputs to be probability distributions.
In the sense that the softmax enforces the outputs to sum to 1 and also be non-negative, the output of the network is a discrete probability distribution over the classes, or at least can be interpreted as such. Hence it is perfectly reasonable to talk about cross-entropies and maximum likelihoods.
However, what I think you are seeing (and it is correct), is that the output "probabilities" may have nothing to do with the actual probability of correctness. This is a well-known problem in ML, called calibration.
For instance, if your classifier $f_\theta$ of dogs $D$ and cats $C$ says $f_\theta(x_i,C) = P(x_i = C|\theta) = 0.7$, then you would expect that if you took a set of examples $S=\{x_j\}$ all of which had $P(x_j = C|\theta) = 0.7$, then roughly 30% of the inputs would be misclassified (since it was only 70% confident).
However, it turns out that modern training methods do not enforce this at all! See Guo et al, On the Calibration of Modern Neural Networks to see some discussion of this.
In other words, the "probability" of the output from the softmax may well have nothing to do with the actual model confidence. And this is no surprise: we merely want to maximize our accuracy, and every input example has a probability of 1 of being its target class. There is little incentivizing the model to get this right. If it doesn't need to estimate uncertainty then why should it? Cross-entropy does not rectify this issue; indeed, you are telling it to go to a delta function every time!
Lots of recent work on Bayesian neural networks strive to rectify this issue. Such models employ a distribution over parameters given the data $P(\theta|X) = P(X|\theta)P(\theta)/P(X)$, which can be integrated to get an actual probability distribution $P(y_i|x_i,X)=\int P(y_i|\theta,x_i) P(\theta|X) \,d\theta$.
This helps guarantee useful uncertainty measurements and better calibration. However, it is more problematic computationally.
Hopefully I didn't misunderstand your question!
|
How meaningful is the connection between MLE and cross entropy in deep learning?
|
I'll answer from a slightly more general perspective, concerning the nature of how, when, and why we can consider NN outputs to be probability distributions.
In the sense that the softmax enforces the
|
How meaningful is the connection between MLE and cross entropy in deep learning?
I'll answer from a slightly more general perspective, concerning the nature of how, when, and why we can consider NN outputs to be probability distributions.
In the sense that the softmax enforces the outputs to sum to 1 and also be non-negative, the output of the network is a discrete probability distribution over the classes, or at least can be interpreted as such. Hence it is perfectly reasonable to talk about cross-entropies and maximum likelihoods.
However, what I think you are seeing (and it is correct), is that the output "probabilities" may have nothing to do with the actual probability of correctness. This is a well-known problem in ML, called calibration.
For instance, if your classifier $f_\theta$ of dogs $D$ and cats $C$ says $f_\theta(x_i,C) = P(x_i = C|\theta) = 0.7$, then you would expect that if you took a set of examples $S=\{x_j\}$ all of which had $P(x_j = C|\theta) = 0.7$, then roughly 30% of the inputs would be misclassified (since it was only 70% confident).
However, it turns out that modern training methods do not enforce this at all! See Guo et al, On the Calibration of Modern Neural Networks to see some discussion of this.
In other words, the "probability" of the output from the softmax may well have nothing to do with the actual model confidence. And this is no surprise: we merely want to maximize our accuracy, and every input example has a probability of 1 of being its target class. There is little incentivizing the model to get this right. If it doesn't need to estimate uncertainty then why should it? Cross-entropy does not rectify this issue; indeed, you are telling it to go to a delta function every time!
Lots of recent work on Bayesian neural networks strive to rectify this issue. Such models employ a distribution over parameters given the data $P(\theta|X) = P(X|\theta)P(\theta)/P(X)$, which can be integrated to get an actual probability distribution $P(y_i|x_i,X)=\int P(y_i|\theta,x_i) P(\theta|X) \,d\theta$.
This helps guarantee useful uncertainty measurements and better calibration. However, it is more problematic computationally.
Hopefully I didn't misunderstand your question!
|
How meaningful is the connection between MLE and cross entropy in deep learning?
I'll answer from a slightly more general perspective, concerning the nature of how, when, and why we can consider NN outputs to be probability distributions.
In the sense that the softmax enforces the
|
15,820
|
How meaningful is the connection between MLE and cross entropy in deep learning?
|
Feed-forward neural networks approximate the true class probabilities when trained properly.
In 1991, Richard & Lippmann proved that feed-forward neural networks approach posterior class probabilities, when trained with {0,1} class-indicator target patterns [Richard M. D., & Lippmann R. P. (1991). Neural network classifiers estimate bayesian a posteriori probabilities. Neural Computation, 3, 461–
483.]. In their line of proof, they use one-hidden layer feed-forward neural networks.
In the mathematical annotation of Duda & Hart [Duda R.O. & Hart P.E. (1973) Pattern Classification and Scene Analysis, Wiley], define the feature distributions provided as input vector to the feed-forward neural network as $P({\bf{\it x}}\,\mid\,\omega_i)$, where for example the data vector equals ${\bf{\it x}}=(0.2,10.2,0,2)$, for a classification task with 4 feature-variables. The index $i$ indicates the possible $n$ classes, $i \in \{1,\ldots,n\}$.
The feed-forward neural network classifier learns the posterior probabilities, ${\hat P}(\omega_i\,\mid\,{\bf{\it x}})$, when trained by gradient descent. The desired output pattern needs for example to be ${\bf {\it o}}=(0,1)$, for a two-class classification problem. The feed-forward neural network has one output node per class. The vector $(0,1)$ indicates that the observed feature-vector belongs to the 2'nd class.
|
How meaningful is the connection between MLE and cross entropy in deep learning?
|
Feed-forward neural networks approximate the true class probabilities when trained properly.
In 1991, Richard & Lippmann proved that feed-forward neural networks approach posterior class probabilitie
|
How meaningful is the connection between MLE and cross entropy in deep learning?
Feed-forward neural networks approximate the true class probabilities when trained properly.
In 1991, Richard & Lippmann proved that feed-forward neural networks approach posterior class probabilities, when trained with {0,1} class-indicator target patterns [Richard M. D., & Lippmann R. P. (1991). Neural network classifiers estimate bayesian a posteriori probabilities. Neural Computation, 3, 461–
483.]. In their line of proof, they use one-hidden layer feed-forward neural networks.
In the mathematical annotation of Duda & Hart [Duda R.O. & Hart P.E. (1973) Pattern Classification and Scene Analysis, Wiley], define the feature distributions provided as input vector to the feed-forward neural network as $P({\bf{\it x}}\,\mid\,\omega_i)$, where for example the data vector equals ${\bf{\it x}}=(0.2,10.2,0,2)$, for a classification task with 4 feature-variables. The index $i$ indicates the possible $n$ classes, $i \in \{1,\ldots,n\}$.
The feed-forward neural network classifier learns the posterior probabilities, ${\hat P}(\omega_i\,\mid\,{\bf{\it x}})$, when trained by gradient descent. The desired output pattern needs for example to be ${\bf {\it o}}=(0,1)$, for a two-class classification problem. The feed-forward neural network has one output node per class. The vector $(0,1)$ indicates that the observed feature-vector belongs to the 2'nd class.
|
How meaningful is the connection between MLE and cross entropy in deep learning?
Feed-forward neural networks approximate the true class probabilities when trained properly.
In 1991, Richard & Lippmann proved that feed-forward neural networks approach posterior class probabilitie
|
15,821
|
How meaningful is the connection between MLE and cross entropy in deep learning?
|
The log-likelihood is not directly linked to the entropy in the context of your question. The similarity is superficial: both have the sums of logarithms of probability-like quantities.
The logarithm in log-likelihood (MLE) is done purely for numerical calculation reasons. The product of probabilities can be a very small number, especially if your sample is large. Then the range of likelihoods goes from 1 to disappearingly small value of a product. When you get the log, the product becomes a sum, and the log function compresses the range of values to a smaller more manageable domain. Logarithm is a monotonous function, so the max (min) of log-likelihood will produce the same answer of the likelihood itself. Hence, the presence of the log in MLE expression is not important in mathematical sense, and is simply a matter of convenience.
The presence of a logarithm function in the entropy is more substantial, and has its roots in statistical mechanics, a branch of physics. It's linked to Boltzmann distribution, which is used in theory of gases. You could derive the air pressure as a function of the altitude using it, for instance.
|
How meaningful is the connection between MLE and cross entropy in deep learning?
|
The log-likelihood is not directly linked to the entropy in the context of your question. The similarity is superficial: both have the sums of logarithms of probability-like quantities.
The logarithm
|
How meaningful is the connection between MLE and cross entropy in deep learning?
The log-likelihood is not directly linked to the entropy in the context of your question. The similarity is superficial: both have the sums of logarithms of probability-like quantities.
The logarithm in log-likelihood (MLE) is done purely for numerical calculation reasons. The product of probabilities can be a very small number, especially if your sample is large. Then the range of likelihoods goes from 1 to disappearingly small value of a product. When you get the log, the product becomes a sum, and the log function compresses the range of values to a smaller more manageable domain. Logarithm is a monotonous function, so the max (min) of log-likelihood will produce the same answer of the likelihood itself. Hence, the presence of the log in MLE expression is not important in mathematical sense, and is simply a matter of convenience.
The presence of a logarithm function in the entropy is more substantial, and has its roots in statistical mechanics, a branch of physics. It's linked to Boltzmann distribution, which is used in theory of gases. You could derive the air pressure as a function of the altitude using it, for instance.
|
How meaningful is the connection between MLE and cross entropy in deep learning?
The log-likelihood is not directly linked to the entropy in the context of your question. The similarity is superficial: both have the sums of logarithms of probability-like quantities.
The logarithm
|
15,822
|
What are the difference between Dice, Jaccard, and overlap coefficients? [closed]
|
From the wikipedia page:
$$J=\frac{D}{2-D} \;\; \text{and}\;\; D=\frac{2J}{J+1}$$
where $D$ is the Dice Coefficient and $J$ is the Jacard Index.
In my opinion, the Dice Coefficient is more intuitive because it can be seen as the percentage of overlap between the two sets, that is a number between 0 and 1.
As for the Overlap it represents the percentage of overlap as it relates only to the smallest volume:
$$overlap = \frac{|X\cap Y|}{min(|X|, |Y|)}$$
The relation between it and the other two measures is not direct, but one can be get from one the others and vice-versa with information of the area/volume of $X$ and $Y$
|
What are the difference between Dice, Jaccard, and overlap coefficients? [closed]
|
From the wikipedia page:
$$J=\frac{D}{2-D} \;\; \text{and}\;\; D=\frac{2J}{J+1}$$
where $D$ is the Dice Coefficient and $J$ is the Jacard Index.
In my opinion, the Dice Coefficient is more intuitive b
|
What are the difference between Dice, Jaccard, and overlap coefficients? [closed]
From the wikipedia page:
$$J=\frac{D}{2-D} \;\; \text{and}\;\; D=\frac{2J}{J+1}$$
where $D$ is the Dice Coefficient and $J$ is the Jacard Index.
In my opinion, the Dice Coefficient is more intuitive because it can be seen as the percentage of overlap between the two sets, that is a number between 0 and 1.
As for the Overlap it represents the percentage of overlap as it relates only to the smallest volume:
$$overlap = \frac{|X\cap Y|}{min(|X|, |Y|)}$$
The relation between it and the other two measures is not direct, but one can be get from one the others and vice-versa with information of the area/volume of $X$ and $Y$
|
What are the difference between Dice, Jaccard, and overlap coefficients? [closed]
From the wikipedia page:
$$J=\frac{D}{2-D} \;\; \text{and}\;\; D=\frac{2J}{J+1}$$
where $D$ is the Dice Coefficient and $J$ is the Jacard Index.
In my opinion, the Dice Coefficient is more intuitive b
|
15,823
|
Why is it called the "standard" deviation?
|
Pearson made up this term in 1894 paper "On the dissection of asymmetrical frequency-curves", here's the pdf. Also, he wrote it with a hyphen, "standard-deviation".
He didn't bother to explain us why he chose the term. Gauss and Airy called it mean error (mittlerer Fehler) and error of mean square. In physics it's usually called "dispersion", btw.
My guess is that Pearson used the Gaussian (normal) distribution to motivate the usage, so he probably thought that it's "standard" in that sense.
|
Why is it called the "standard" deviation?
|
Pearson made up this term in 1894 paper "On the dissection of asymmetrical frequency-curves", here's the pdf. Also, he wrote it with a hyphen, "standard-deviation".
He didn't bother to explain us why
|
Why is it called the "standard" deviation?
Pearson made up this term in 1894 paper "On the dissection of asymmetrical frequency-curves", here's the pdf. Also, he wrote it with a hyphen, "standard-deviation".
He didn't bother to explain us why he chose the term. Gauss and Airy called it mean error (mittlerer Fehler) and error of mean square. In physics it's usually called "dispersion", btw.
My guess is that Pearson used the Gaussian (normal) distribution to motivate the usage, so he probably thought that it's "standard" in that sense.
|
Why is it called the "standard" deviation?
Pearson made up this term in 1894 paper "On the dissection of asymmetrical frequency-curves", here's the pdf. Also, he wrote it with a hyphen, "standard-deviation".
He didn't bother to explain us why
|
15,824
|
Why is it called the "standard" deviation?
|
I guess that we can have an idea of why a standard deviation is called "standard" by looking at the synonyms of this word (see here). Some of them, like "typical" or "average", make clear the fact that a standard deviation is conceptually a typical or an average deviation to the mean, even if technically speaking you have to take the square root of the averaged squared deviations to the mean of your dataset. In French, we use "écart-type" to refer to standard deviation, "écart" meaning deviation and "type" meaning typical, which probably makes this clearer. I found this a very useful way to provide a conceptual definition of standard deviation to students.
|
Why is it called the "standard" deviation?
|
I guess that we can have an idea of why a standard deviation is called "standard" by looking at the synonyms of this word (see here). Some of them, like "typical" or "average", make clear the fact tha
|
Why is it called the "standard" deviation?
I guess that we can have an idea of why a standard deviation is called "standard" by looking at the synonyms of this word (see here). Some of them, like "typical" or "average", make clear the fact that a standard deviation is conceptually a typical or an average deviation to the mean, even if technically speaking you have to take the square root of the averaged squared deviations to the mean of your dataset. In French, we use "écart-type" to refer to standard deviation, "écart" meaning deviation and "type" meaning typical, which probably makes this clearer. I found this a very useful way to provide a conceptual definition of standard deviation to students.
|
Why is it called the "standard" deviation?
I guess that we can have an idea of why a standard deviation is called "standard" by looking at the synonyms of this word (see here). Some of them, like "typical" or "average", make clear the fact tha
|
15,825
|
Arima time series forecast (auto.arima) with multiple exogeneous variables in R
|
If your external regressors are causal for $y$, but not the other way around and do not cause each other, then ARIMA is definitely appropriate. VAR makes sense if your different time series all depend on each other.
For auto.arima() to work with external regressors, collect your regressors into a matrix X, which you feed into the xreg parameter of auto.arima(). (Of course, X must have the same number of rows as the time series y you are modeling.)
For forecasting, you will need the future values of your regressors, which you then again feed into the xreg parameter of forecast.
The help pages are ?auto.arima and ?forecast.Arima (note the capital A - this is not a typo. Don't ask me...).
|
Arima time series forecast (auto.arima) with multiple exogeneous variables in R
|
If your external regressors are causal for $y$, but not the other way around and do not cause each other, then ARIMA is definitely appropriate. VAR makes sense if your different time series all depend
|
Arima time series forecast (auto.arima) with multiple exogeneous variables in R
If your external regressors are causal for $y$, but not the other way around and do not cause each other, then ARIMA is definitely appropriate. VAR makes sense if your different time series all depend on each other.
For auto.arima() to work with external regressors, collect your regressors into a matrix X, which you feed into the xreg parameter of auto.arima(). (Of course, X must have the same number of rows as the time series y you are modeling.)
For forecasting, you will need the future values of your regressors, which you then again feed into the xreg parameter of forecast.
The help pages are ?auto.arima and ?forecast.Arima (note the capital A - this is not a typo. Don't ask me...).
|
Arima time series forecast (auto.arima) with multiple exogeneous variables in R
If your external regressors are causal for $y$, but not the other way around and do not cause each other, then ARIMA is definitely appropriate. VAR makes sense if your different time series all depend
|
15,826
|
Propensity score matching with panel data
|
You basically have to create a wide format dataset with the all the characteristics that are relevant for the matching procedure, perform the matching on this cross-sectional dataset, and then use the ID to identify the matched pair in the panel dataset. Here are some more details:
Use reshape to create a wide format dataset. Format the pre-treatment variables in the way you want to use them in the matching procedure. You can just take the average of your variables if you have multiple observations for one individual but you can also come up with other ways (you can also keep multiple observations of the same variables such as health1, health2 and use all of them in the matching). The goal is to have a dataset with one observation per individual.
Using this dataset, perform the matching procedure with psmatch2.
Merge the information about the matched cases with the original dataset. Drop cases that are not matched etc. I am not sure about the details here because I don't really know stata and psmatch2 but I think you get the idea.
Using these steps, you can match cases based on all pre-treatment information and you only have one match per treatment unit.
|
Propensity score matching with panel data
|
You basically have to create a wide format dataset with the all the characteristics that are relevant for the matching procedure, perform the matching on this cross-sectional dataset, and then use the
|
Propensity score matching with panel data
You basically have to create a wide format dataset with the all the characteristics that are relevant for the matching procedure, perform the matching on this cross-sectional dataset, and then use the ID to identify the matched pair in the panel dataset. Here are some more details:
Use reshape to create a wide format dataset. Format the pre-treatment variables in the way you want to use them in the matching procedure. You can just take the average of your variables if you have multiple observations for one individual but you can also come up with other ways (you can also keep multiple observations of the same variables such as health1, health2 and use all of them in the matching). The goal is to have a dataset with one observation per individual.
Using this dataset, perform the matching procedure with psmatch2.
Merge the information about the matched cases with the original dataset. Drop cases that are not matched etc. I am not sure about the details here because I don't really know stata and psmatch2 but I think you get the idea.
Using these steps, you can match cases based on all pre-treatment information and you only have one match per treatment unit.
|
Propensity score matching with panel data
You basically have to create a wide format dataset with the all the characteristics that are relevant for the matching procedure, perform the matching on this cross-sectional dataset, and then use the
|
15,827
|
Propensity score matching with panel data
|
There's no way to do that in Stata or any other software that I am aware of.
If you're trying to patch up a biased matching estimator with panel data techniques, here's one approach that may work. If you can assume that matching takes care of some, but not all of the selection bias, but that the bias largely remains constant over time, you can remove the time-invariant portion of the bias by constructing separate matching estimates in each period and taking the difference.
Let $t$ be the pre-treatment period and $t'$ be the post. If the untreated state outcome $Y_0$ satisfies
\begin{equation}
E[Y_{0t} \vert X, D=1]-E[Y_{0t} \vert X, D=0]=E[Y_{0t'} \vert X, D=1]-E[Y_{0t'} \vert X, D=0]=Bias,
\end{equation}
then if $\Delta^{M}_{t'}=\Delta^{TT}+Bias$ and $\Delta^{M}_{t}=Bias$,
you can get $\Delta^{M}_{t'}-\Delta^{M}_{t}=\Delta^{TT}$
Heckman, Ichimura, Smith and Todd 1998 Econometrica and Eichler and
Lechner 2002 Labour Economics papers are examples of this approach. On the other hand, 150 treated observations may not be enough for this approach to work.
|
Propensity score matching with panel data
|
There's no way to do that in Stata or any other software that I am aware of.
If you're trying to patch up a biased matching estimator with panel data techniques, here's one approach that may work. If
|
Propensity score matching with panel data
There's no way to do that in Stata or any other software that I am aware of.
If you're trying to patch up a biased matching estimator with panel data techniques, here's one approach that may work. If you can assume that matching takes care of some, but not all of the selection bias, but that the bias largely remains constant over time, you can remove the time-invariant portion of the bias by constructing separate matching estimates in each period and taking the difference.
Let $t$ be the pre-treatment period and $t'$ be the post. If the untreated state outcome $Y_0$ satisfies
\begin{equation}
E[Y_{0t} \vert X, D=1]-E[Y_{0t} \vert X, D=0]=E[Y_{0t'} \vert X, D=1]-E[Y_{0t'} \vert X, D=0]=Bias,
\end{equation}
then if $\Delta^{M}_{t'}=\Delta^{TT}+Bias$ and $\Delta^{M}_{t}=Bias$,
you can get $\Delta^{M}_{t'}-\Delta^{M}_{t}=\Delta^{TT}$
Heckman, Ichimura, Smith and Todd 1998 Econometrica and Eichler and
Lechner 2002 Labour Economics papers are examples of this approach. On the other hand, 150 treated observations may not be enough for this approach to work.
|
Propensity score matching with panel data
There's no way to do that in Stata or any other software that I am aware of.
If you're trying to patch up a biased matching estimator with panel data techniques, here's one approach that may work. If
|
15,828
|
Propensity score matching with panel data
|
Steps:
As it has been mentioned in detail by Greg, you can use a cross-sectional dataset, either on pre-treatment means or on a sepecific pre-treatment period to generate the matching.
Using the whole panel you assign indicator variables for
a. treatedIndividual
b. treatedPeriod, the latter is equal to zero as soon as the treatment occurs for the treatedIndividual.
Since the point in time where treatedPeriod changes from 0 to 1 varies across individuals and never turns to 1 for untreated you must assign the same starting point from the treated match to the untreated match. This is intuitive but I would still like to see a good reference that justifies this approach which I have not found so far.
The regression set-up would be:
depvar = treatedIndvidual + treatedPeriod + treatedIndvidual*treatedPeriod + controls
where the interaction term gives you the treatment effect.
|
Propensity score matching with panel data
|
Steps:
As it has been mentioned in detail by Greg, you can use a cross-sectional dataset, either on pre-treatment means or on a sepecific pre-treatment period to generate the matching.
Using the wh
|
Propensity score matching with panel data
Steps:
As it has been mentioned in detail by Greg, you can use a cross-sectional dataset, either on pre-treatment means or on a sepecific pre-treatment period to generate the matching.
Using the whole panel you assign indicator variables for
a. treatedIndividual
b. treatedPeriod, the latter is equal to zero as soon as the treatment occurs for the treatedIndividual.
Since the point in time where treatedPeriod changes from 0 to 1 varies across individuals and never turns to 1 for untreated you must assign the same starting point from the treated match to the untreated match. This is intuitive but I would still like to see a good reference that justifies this approach which I have not found so far.
The regression set-up would be:
depvar = treatedIndvidual + treatedPeriod + treatedIndvidual*treatedPeriod + controls
where the interaction term gives you the treatment effect.
|
Propensity score matching with panel data
Steps:
As it has been mentioned in detail by Greg, you can use a cross-sectional dataset, either on pre-treatment means or on a sepecific pre-treatment period to generate the matching.
Using the wh
|
15,829
|
Propensity score matching with panel data
|
Did you consider to use the nnmatch command?
I use this command and it is a pretty comprehensive one.
It does take into account different matching algorithms and also cases, in which the propensity score is the same for some control group individuals. Of course, the treatment of this case depends on the matching algorithm, if you take k-nearest-neighbour or kernel or whatever.
|
Propensity score matching with panel data
|
Did you consider to use the nnmatch command?
I use this command and it is a pretty comprehensive one.
It does take into account different matching algorithms and also cases, in which the propensity sc
|
Propensity score matching with panel data
Did you consider to use the nnmatch command?
I use this command and it is a pretty comprehensive one.
It does take into account different matching algorithms and also cases, in which the propensity score is the same for some control group individuals. Of course, the treatment of this case depends on the matching algorithm, if you take k-nearest-neighbour or kernel or whatever.
|
Propensity score matching with panel data
Did you consider to use the nnmatch command?
I use this command and it is a pretty comprehensive one.
It does take into account different matching algorithms and also cases, in which the propensity sc
|
15,830
|
Conditional expectation of R-squared
|
Any linear model can be written $\boxed{Y=\mu+\sigma G}$ where $G$ has the standard normal distribution on $\mathbb{R}^n$ and $\mu$ is assumed to belong to a linear subspace $W$ of $\mathbb{R}^n$. In your case $W=\text{Im}(X)$.
Let $[1] \subset W$ be the one-dimensional linear subspace generated by the vector $(1,1,\ldots,1)$. Taking $U=[1]$ below, the $R^2$ is highly related to the classical Fisher statistic
$$
F = \frac{{\Vert P_Z Y\Vert}^2/(m-\ell)}{{\Vert P_W^\perp Y\Vert}^2/(n-m)},
$$
for the hypothesis test of $H_0\colon\{\mu \in U\}$ where $U\subset W$ is a linear subspace, and denoting by $Z=U^\perp \cap W$ the orthogonal complement of $U$ in $W$, and denoting $m=\dim(W)$ and $\ell=\dim(U)$ (then $m=p$ and $\ell=1$ in your situation).
Indeed,
$$
\dfrac{{\Vert P_Z Y\Vert}^2}{{\Vert P_W^\perp Y\Vert}^2}
= \frac{R^2}{1-R^2}
$$
because the definition of $R^2$ is
$$R^2 = \frac{{\Vert P_Z Y\Vert}^2}{{\Vert P_U^\perp Y\Vert}^2}=1 - \frac{{\Vert P^\perp_W Y\Vert}^2}{{\Vert P_U^\perp Y\Vert}^2}.$$
Obviously $\boxed{P_Z Y = P_Z \mu + \sigma P_Z G}$ and
$\boxed{P_W^\perp Y = \sigma P_W^\perp G}$.
When $H_0\colon\{\mu \in U\}$ is true then $P_Z \mu = 0$ and therefore
$$
F = \frac{{\Vert P_Z G\Vert}^2/(m-\ell)}{{\Vert P_W^\perp G\Vert}^2/(n-m)} \sim F_{m-\ell,n-m}
$$
has the Fisher $F_{m-\ell,n-m}$ distribution. Consequently, from the classical relation between the Fisher distribution and the Beta distribution, $R^2 \sim {\cal B}(m-\ell, n-m)$.
In the general situation we have to deal with $P_Z Y = P_Z \mu + \sigma P_Z G$ when $P_Z\mu \neq 0$. In this general case one has ${\Vert P_Z Y\Vert}^2 \sim \sigma^2\chi^2_{m-\ell}(\lambda)$, the noncentral $\chi^2$ distribution with $m-\ell$ degrees of freedom and noncentrality parameter $\boxed{\lambda=\frac{{\Vert P_Z \mu\Vert}^2}{\sigma^2}}$, and then
$\boxed{F \sim F_{m-\ell,n-m}(\lambda)}$ (noncentral Fisher distribution). This is the classical result used to compute power of $F$-tests.
The classical relation between the Fisher distribution and the Beta distribution hold in the noncentral situation too. Finally $R^2$ has the noncentral beta distribution with "shape parameters" $m-\ell$ and $n-m$ and noncentrality parameter $\lambda$. I think the moments are available in the literature but they possibly are highly complicated.
Finally let us write down $P_Z\mu$. Note that $P_Z = P_W - P_U$. One has $P_U \mu = \bar\mu 1$ when $U=[1]$, and $P_W \mu = \mu$. Hence $P_Z \mu =\mu - \bar\mu 1$ where here $\mu=X\beta$ for the unknown parameters vector $\beta$.
|
Conditional expectation of R-squared
|
Any linear model can be written $\boxed{Y=\mu+\sigma G}$ where $G$ has the standard normal distribution on $\mathbb{R}^n$ and $\mu$ is assumed to belong to a linear subspace $W$ of $\mathbb{R}^n$. In
|
Conditional expectation of R-squared
Any linear model can be written $\boxed{Y=\mu+\sigma G}$ where $G$ has the standard normal distribution on $\mathbb{R}^n$ and $\mu$ is assumed to belong to a linear subspace $W$ of $\mathbb{R}^n$. In your case $W=\text{Im}(X)$.
Let $[1] \subset W$ be the one-dimensional linear subspace generated by the vector $(1,1,\ldots,1)$. Taking $U=[1]$ below, the $R^2$ is highly related to the classical Fisher statistic
$$
F = \frac{{\Vert P_Z Y\Vert}^2/(m-\ell)}{{\Vert P_W^\perp Y\Vert}^2/(n-m)},
$$
for the hypothesis test of $H_0\colon\{\mu \in U\}$ where $U\subset W$ is a linear subspace, and denoting by $Z=U^\perp \cap W$ the orthogonal complement of $U$ in $W$, and denoting $m=\dim(W)$ and $\ell=\dim(U)$ (then $m=p$ and $\ell=1$ in your situation).
Indeed,
$$
\dfrac{{\Vert P_Z Y\Vert}^2}{{\Vert P_W^\perp Y\Vert}^2}
= \frac{R^2}{1-R^2}
$$
because the definition of $R^2$ is
$$R^2 = \frac{{\Vert P_Z Y\Vert}^2}{{\Vert P_U^\perp Y\Vert}^2}=1 - \frac{{\Vert P^\perp_W Y\Vert}^2}{{\Vert P_U^\perp Y\Vert}^2}.$$
Obviously $\boxed{P_Z Y = P_Z \mu + \sigma P_Z G}$ and
$\boxed{P_W^\perp Y = \sigma P_W^\perp G}$.
When $H_0\colon\{\mu \in U\}$ is true then $P_Z \mu = 0$ and therefore
$$
F = \frac{{\Vert P_Z G\Vert}^2/(m-\ell)}{{\Vert P_W^\perp G\Vert}^2/(n-m)} \sim F_{m-\ell,n-m}
$$
has the Fisher $F_{m-\ell,n-m}$ distribution. Consequently, from the classical relation between the Fisher distribution and the Beta distribution, $R^2 \sim {\cal B}(m-\ell, n-m)$.
In the general situation we have to deal with $P_Z Y = P_Z \mu + \sigma P_Z G$ when $P_Z\mu \neq 0$. In this general case one has ${\Vert P_Z Y\Vert}^2 \sim \sigma^2\chi^2_{m-\ell}(\lambda)$, the noncentral $\chi^2$ distribution with $m-\ell$ degrees of freedom and noncentrality parameter $\boxed{\lambda=\frac{{\Vert P_Z \mu\Vert}^2}{\sigma^2}}$, and then
$\boxed{F \sim F_{m-\ell,n-m}(\lambda)}$ (noncentral Fisher distribution). This is the classical result used to compute power of $F$-tests.
The classical relation between the Fisher distribution and the Beta distribution hold in the noncentral situation too. Finally $R^2$ has the noncentral beta distribution with "shape parameters" $m-\ell$ and $n-m$ and noncentrality parameter $\lambda$. I think the moments are available in the literature but they possibly are highly complicated.
Finally let us write down $P_Z\mu$. Note that $P_Z = P_W - P_U$. One has $P_U \mu = \bar\mu 1$ when $U=[1]$, and $P_W \mu = \mu$. Hence $P_Z \mu =\mu - \bar\mu 1$ where here $\mu=X\beta$ for the unknown parameters vector $\beta$.
|
Conditional expectation of R-squared
Any linear model can be written $\boxed{Y=\mu+\sigma G}$ where $G$ has the standard normal distribution on $\mathbb{R}^n$ and $\mu$ is assumed to belong to a linear subspace $W$ of $\mathbb{R}^n$. In
|
15,831
|
Frequentism and priors
|
With respect to Robby McKilliam's comment: I think the difficulty a frequentist would have with this lies in the definition of "prior knowledge", not so much with the ability to incorporate prior knowledge in a model. For example, consider estimating the probability that a given coin will come up heads. Let us assume my prior knowledge was, essentially, an experiment in which that coin had been flipped 10 times and came up with 5 heads, or perhaps of the form "the factory made 1 million coins, and the dist'n of $p$, as determined by huge experiments, is $\beta(a,b)$". Everyone uses Bayes' Rule when you really do have prior information of this type (Bayes' Rule just defines conditional probability, it's not a Bayesian-only thing) so in real life the frequentist and the Bayesian would use the same approach, and incorporate the information into the model via Bayes' Rule. (Caveat: unless your sample size is large enough that you are pretty sure the prior information's not going to have an effect on the results.) However, the interpretation of the results is, of course, different.
Difficulty arises, especially from a philosophical point of view, as the knowledge becomes less objective / experimental and more subjective. As this happens, the frequentist will likely become less inclined to incorporate this information into the model at all, whereas the Bayesian still has some more-or-less formal mechanisms for doing so, difficulties of eliciting a subjective prior notwithstanding.
With respect to regularization: Consider a likelihood $l(\theta;x)$ and a prior $p(\theta)$. There is nothing to prevent, at least not technically, a frequentist from using maximum likelihood estimation "regularized" by $\log p(\theta)$, as in:
$\tilde{\theta} = \max_{\theta} \{\log l(\theta;x) + \log p(\theta) \}$
For $p(\theta)$ Gaussian, this amounts to a quadratic penalty shrinking $\theta$ towards the mean of the Gaussian, and so forth for other distributions. $\tilde{\theta}$ is equal to the maximum a posteriori (MAP) point estimate of a Bayesian using the same likelihood function and prior. Of course, again, the interpretation of the frequentist and Bayesian estimates will differ. The Bayesian is also not constrained to use a MAP point estimate, having access to a full posterior distribution - but then, the frequentist doesn't have to maximize a regularized log likelihood either, being able to use various robust estimates, or method-of-moments, etc., if available.
Again, difficulty arises from a philosophical point of view. Why choose one regularization function over another? A Bayesian can do so - shifting to a prior - based view - by assessing the prior information. A frequentist would have a harder time (be unable to?) justifying a choice on those grounds, but instead would likely do so largely based on the properties of the regularization function as applied to his/her type of problem, as learned from the joint work / experience of many statisticians. OTOH, (pragmatic) Bayesians do that with priors too - if I had $100 for every paper on priors for variances I've read...
Other "thoughts": I've skipped the entire issue of selecting a likelihood function by assuming that it is unaffected by the frequentist / Bayesian viewpoint. I'm sure in most cases it is, but I can imagine that in unusual situations it would be, e.g., for computational reasons.
Summary: I suspect frequentists can, except perhaps for some corner cases, incorporate pretty much any prior information into their models that a Bayesian can, from a strictly mathematical and computational viewpoint. Interpretation of results will of course be different. I don't, however, believe the frequentist would regard it as philosophically correct to do so in all cases, e.g., the regularization function above where the person down the hall who actually knows something about $\theta$ says "I think $\theta$ should be around 1.5". And incorporating close-to-ignorance via, say, a Jeffrey's prior, is right out.
|
Frequentism and priors
|
With respect to Robby McKilliam's comment: I think the difficulty a frequentist would have with this lies in the definition of "prior knowledge", not so much with the ability to incorporate prior kno
|
Frequentism and priors
With respect to Robby McKilliam's comment: I think the difficulty a frequentist would have with this lies in the definition of "prior knowledge", not so much with the ability to incorporate prior knowledge in a model. For example, consider estimating the probability that a given coin will come up heads. Let us assume my prior knowledge was, essentially, an experiment in which that coin had been flipped 10 times and came up with 5 heads, or perhaps of the form "the factory made 1 million coins, and the dist'n of $p$, as determined by huge experiments, is $\beta(a,b)$". Everyone uses Bayes' Rule when you really do have prior information of this type (Bayes' Rule just defines conditional probability, it's not a Bayesian-only thing) so in real life the frequentist and the Bayesian would use the same approach, and incorporate the information into the model via Bayes' Rule. (Caveat: unless your sample size is large enough that you are pretty sure the prior information's not going to have an effect on the results.) However, the interpretation of the results is, of course, different.
Difficulty arises, especially from a philosophical point of view, as the knowledge becomes less objective / experimental and more subjective. As this happens, the frequentist will likely become less inclined to incorporate this information into the model at all, whereas the Bayesian still has some more-or-less formal mechanisms for doing so, difficulties of eliciting a subjective prior notwithstanding.
With respect to regularization: Consider a likelihood $l(\theta;x)$ and a prior $p(\theta)$. There is nothing to prevent, at least not technically, a frequentist from using maximum likelihood estimation "regularized" by $\log p(\theta)$, as in:
$\tilde{\theta} = \max_{\theta} \{\log l(\theta;x) + \log p(\theta) \}$
For $p(\theta)$ Gaussian, this amounts to a quadratic penalty shrinking $\theta$ towards the mean of the Gaussian, and so forth for other distributions. $\tilde{\theta}$ is equal to the maximum a posteriori (MAP) point estimate of a Bayesian using the same likelihood function and prior. Of course, again, the interpretation of the frequentist and Bayesian estimates will differ. The Bayesian is also not constrained to use a MAP point estimate, having access to a full posterior distribution - but then, the frequentist doesn't have to maximize a regularized log likelihood either, being able to use various robust estimates, or method-of-moments, etc., if available.
Again, difficulty arises from a philosophical point of view. Why choose one regularization function over another? A Bayesian can do so - shifting to a prior - based view - by assessing the prior information. A frequentist would have a harder time (be unable to?) justifying a choice on those grounds, but instead would likely do so largely based on the properties of the regularization function as applied to his/her type of problem, as learned from the joint work / experience of many statisticians. OTOH, (pragmatic) Bayesians do that with priors too - if I had $100 for every paper on priors for variances I've read...
Other "thoughts": I've skipped the entire issue of selecting a likelihood function by assuming that it is unaffected by the frequentist / Bayesian viewpoint. I'm sure in most cases it is, but I can imagine that in unusual situations it would be, e.g., for computational reasons.
Summary: I suspect frequentists can, except perhaps for some corner cases, incorporate pretty much any prior information into their models that a Bayesian can, from a strictly mathematical and computational viewpoint. Interpretation of results will of course be different. I don't, however, believe the frequentist would regard it as philosophically correct to do so in all cases, e.g., the regularization function above where the person down the hall who actually knows something about $\theta$ says "I think $\theta$ should be around 1.5". And incorporating close-to-ignorance via, say, a Jeffrey's prior, is right out.
|
Frequentism and priors
With respect to Robby McKilliam's comment: I think the difficulty a frequentist would have with this lies in the definition of "prior knowledge", not so much with the ability to incorporate prior kno
|
15,832
|
Frequentism and priors
|
For the purpose of answering this question it's useful to define frequentism as "interest the properties of the sampling distribution of functions of the data." Such functions could be point estimators, p-values of test statistics, confidence intervals, Neyman-Pearson test outcomes, or basically anything else you can think of. Frequentism doesn't specify how to construct estimators, p-values, etc., in full generality, although some guidelines exist, e.g., use sufficient statistics if they're available, use pivotal statistics if they're available, etc. From this perspective, prior information isn't incorporated into the model per se, but rather into the function mapping data to the output of the function.
The "interest" referred to above is in properties considered important for inference, such as lack of bias, asymptotic consistency, variance, mean squared error, mean absolute error, confidence coverage (especially nominal versus actual), Type I error control, and anything else with obvious or intuitive importance for learning from data. These properties can be assessed (by simulation, if nothing else) whether or not the function incorporates prior information.
Particular interest centers on properties that can be known to hold no matter the actual parameter values underlying the data generation process. For example, in the normal i.i.d. model with known variance the data mean is unbiased and asymptotically consistent for the distribution mean no matter what that is. In contrast, a shrinkage estimator (a weighted average of the data mean and a prior guess for the distribution mean) has a lower mean squared error if the distribution mean is close to the prior guess but a higher mean squared error otherwise, although it "inherits" asymptotic consistency from the data mean.
So I would say that one can put prior information into the inference method, but it doesn't go into the model. A really nice illustration of the notions I've outlined in the context of confidence intervals for physical properties that are necessarily non-negative is Feldman and Cousins, A Unified Approach to the Classical Statistical Analysis of Small Signals.
|
Frequentism and priors
|
For the purpose of answering this question it's useful to define frequentism as "interest the properties of the sampling distribution of functions of the data." Such functions could be point estimator
|
Frequentism and priors
For the purpose of answering this question it's useful to define frequentism as "interest the properties of the sampling distribution of functions of the data." Such functions could be point estimators, p-values of test statistics, confidence intervals, Neyman-Pearson test outcomes, or basically anything else you can think of. Frequentism doesn't specify how to construct estimators, p-values, etc., in full generality, although some guidelines exist, e.g., use sufficient statistics if they're available, use pivotal statistics if they're available, etc. From this perspective, prior information isn't incorporated into the model per se, but rather into the function mapping data to the output of the function.
The "interest" referred to above is in properties considered important for inference, such as lack of bias, asymptotic consistency, variance, mean squared error, mean absolute error, confidence coverage (especially nominal versus actual), Type I error control, and anything else with obvious or intuitive importance for learning from data. These properties can be assessed (by simulation, if nothing else) whether or not the function incorporates prior information.
Particular interest centers on properties that can be known to hold no matter the actual parameter values underlying the data generation process. For example, in the normal i.i.d. model with known variance the data mean is unbiased and asymptotically consistent for the distribution mean no matter what that is. In contrast, a shrinkage estimator (a weighted average of the data mean and a prior guess for the distribution mean) has a lower mean squared error if the distribution mean is close to the prior guess but a higher mean squared error otherwise, although it "inherits" asymptotic consistency from the data mean.
So I would say that one can put prior information into the inference method, but it doesn't go into the model. A really nice illustration of the notions I've outlined in the context of confidence intervals for physical properties that are necessarily non-negative is Feldman and Cousins, A Unified Approach to the Classical Statistical Analysis of Small Signals.
|
Frequentism and priors
For the purpose of answering this question it's useful to define frequentism as "interest the properties of the sampling distribution of functions of the data." Such functions could be point estimator
|
15,833
|
War stories where wrong decisions were made based on statistical information?
|
This isn't exactly what you're asking for, but I think you'd like David Freedman's work. He calls BS on misapplication of statistical tests, etc... See here: http://www.stat.berkeley.edu/~freedman/. One of my favorites is “What is the probability of an earthquake?”.
|
War stories where wrong decisions were made based on statistical information?
|
This isn't exactly what you're asking for, but I think you'd like David Freedman's work. He calls BS on misapplication of statistical tests, etc... See here: http://www.stat.berkeley.edu/~freedman/. O
|
War stories where wrong decisions were made based on statistical information?
This isn't exactly what you're asking for, but I think you'd like David Freedman's work. He calls BS on misapplication of statistical tests, etc... See here: http://www.stat.berkeley.edu/~freedman/. One of my favorites is “What is the probability of an earthquake?”.
|
War stories where wrong decisions were made based on statistical information?
This isn't exactly what you're asking for, but I think you'd like David Freedman's work. He calls BS on misapplication of statistical tests, etc... See here: http://www.stat.berkeley.edu/~freedman/. O
|
15,834
|
War stories where wrong decisions were made based on statistical information?
|
You might check out a recent presentation on SSRN by Bernard Black, "Bloopers: How (Mostly) Smart People Get Causal Inference Wrong."
http://papers.ssrn.com/sol3/papers.cfm?abstract_id=1663404
I will say that I also admire David Freedman and appreciate his work. Though I was a UC Berkeley grad student while he was here, he passed away before I had a chance to take his course. You might have a look at his collected works edited by a few other Berkeley professors: "Statistical Models and Causal Inference: A Dialogue with the Social Sciences."
|
War stories where wrong decisions were made based on statistical information?
|
You might check out a recent presentation on SSRN by Bernard Black, "Bloopers: How (Mostly) Smart People Get Causal Inference Wrong."
http://papers.ssrn.com/sol3/papers.cfm?abstract_id=1663404
I will
|
War stories where wrong decisions were made based on statistical information?
You might check out a recent presentation on SSRN by Bernard Black, "Bloopers: How (Mostly) Smart People Get Causal Inference Wrong."
http://papers.ssrn.com/sol3/papers.cfm?abstract_id=1663404
I will say that I also admire David Freedman and appreciate his work. Though I was a UC Berkeley grad student while he was here, he passed away before I had a chance to take his course. You might have a look at his collected works edited by a few other Berkeley professors: "Statistical Models and Causal Inference: A Dialogue with the Social Sciences."
|
War stories where wrong decisions were made based on statistical information?
You might check out a recent presentation on SSRN by Bernard Black, "Bloopers: How (Mostly) Smart People Get Causal Inference Wrong."
http://papers.ssrn.com/sol3/papers.cfm?abstract_id=1663404
I will
|
15,835
|
War stories where wrong decisions were made based on statistical information?
|
This thread is now ancient but it may still be worth posting the results of a recent study titled, A bot crawled thousands of studies looking for simple math errors. The results are concerning. It's not exactly a war story but it does illustrate the rampant errors inherent in published, peer reviewed papers. http://www.vox.com/science-and-health/2016/9/30/13077658/statcheck-psychology-replication
|
War stories where wrong decisions were made based on statistical information?
|
This thread is now ancient but it may still be worth posting the results of a recent study titled, A bot crawled thousands of studies looking for simple math errors. The results are concerning. It's n
|
War stories where wrong decisions were made based on statistical information?
This thread is now ancient but it may still be worth posting the results of a recent study titled, A bot crawled thousands of studies looking for simple math errors. The results are concerning. It's not exactly a war story but it does illustrate the rampant errors inherent in published, peer reviewed papers. http://www.vox.com/science-and-health/2016/9/30/13077658/statcheck-psychology-replication
|
War stories where wrong decisions were made based on statistical information?
This thread is now ancient but it may still be worth posting the results of a recent study titled, A bot crawled thousands of studies looking for simple math errors. The results are concerning. It's n
|
15,836
|
War stories where wrong decisions were made based on statistical information?
|
The sad case of Sally Clark springs to mind.
In 1999, she was wrongfully convicted of murdering her two sons after it was erroneously concluded by Professor Sir Roy Meadow that the chances of both of her sons dying from sudden infant death syndrome (SIDS) were 1 in 73 million, and his now discredited eponymous law:
One is a tragedy, two is suspicious and three is murder unless there
is proof to the contrary.
The Royal Statistical Society criticised the statistical evidence on two counts:
The incorrect assumption of independence between SIDS in siblings. This made the calculation used by Meadow - squaring the probability for a single SIDS incident - invalid.
A misrepresentation of the statistics giving rise to the prosecutor's fallacy.
Furthermore, there were concerns raised by Ray Hill about the quality of the underlying data used to compute the chance of a single SIDS event.
After two appeals, Clark was eventually acquitted, but the experience of losing both sons, and the miscarriage of justice left her psychologically scarred and she died of alcohol poisoning in 2007.
|
War stories where wrong decisions were made based on statistical information?
|
The sad case of Sally Clark springs to mind.
In 1999, she was wrongfully convicted of murdering her two sons after it was erroneously concluded by Professor Sir Roy Meadow that the chances of both of
|
War stories where wrong decisions were made based on statistical information?
The sad case of Sally Clark springs to mind.
In 1999, she was wrongfully convicted of murdering her two sons after it was erroneously concluded by Professor Sir Roy Meadow that the chances of both of her sons dying from sudden infant death syndrome (SIDS) were 1 in 73 million, and his now discredited eponymous law:
One is a tragedy, two is suspicious and three is murder unless there
is proof to the contrary.
The Royal Statistical Society criticised the statistical evidence on two counts:
The incorrect assumption of independence between SIDS in siblings. This made the calculation used by Meadow - squaring the probability for a single SIDS incident - invalid.
A misrepresentation of the statistics giving rise to the prosecutor's fallacy.
Furthermore, there were concerns raised by Ray Hill about the quality of the underlying data used to compute the chance of a single SIDS event.
After two appeals, Clark was eventually acquitted, but the experience of losing both sons, and the miscarriage of justice left her psychologically scarred and she died of alcohol poisoning in 2007.
|
War stories where wrong decisions were made based on statistical information?
The sad case of Sally Clark springs to mind.
In 1999, she was wrongfully convicted of murdering her two sons after it was erroneously concluded by Professor Sir Roy Meadow that the chances of both of
|
15,837
|
Testing for coefficients significance in Lasso logistic regression
|
The problem with using the usual significance tests is that they assume the null that is that there are random variables, with no relationship with the outcome variables. However what you have with lasso, is a bunch of random variables, from which you select the best ones with the lasso, also the betas are shrunk. So you cannot use it, the results will be biased.
As far as I know, the bootstrap is not used to get the variance estimation, but to get the probabilities of a variable is selected. And those are your p-values. Check Hassie's free book, Statistical Learning with Sparsity, chapter 6 is talking about the same thing. Statistical Learning with Sparsity:
The Lasso and Generalizations
Also check this paper for some other ways to get p-values from lasso:
High-Dimensional Inference: Confidence
Intervals, p-Values and R-Software hdi.There are probably more.
|
Testing for coefficients significance in Lasso logistic regression
|
The problem with using the usual significance tests is that they assume the null that is that there are random variables, with no relationship with the outcome variables. However what you have with la
|
Testing for coefficients significance in Lasso logistic regression
The problem with using the usual significance tests is that they assume the null that is that there are random variables, with no relationship with the outcome variables. However what you have with lasso, is a bunch of random variables, from which you select the best ones with the lasso, also the betas are shrunk. So you cannot use it, the results will be biased.
As far as I know, the bootstrap is not used to get the variance estimation, but to get the probabilities of a variable is selected. And those are your p-values. Check Hassie's free book, Statistical Learning with Sparsity, chapter 6 is talking about the same thing. Statistical Learning with Sparsity:
The Lasso and Generalizations
Also check this paper for some other ways to get p-values from lasso:
High-Dimensional Inference: Confidence
Intervals, p-Values and R-Software hdi.There are probably more.
|
Testing for coefficients significance in Lasso logistic regression
The problem with using the usual significance tests is that they assume the null that is that there are random variables, with no relationship with the outcome variables. However what you have with la
|
15,838
|
Testing for coefficients significance in Lasso logistic regression
|
The issue with performing inference after model selection is that you are selecting the most predictive variables and then performing inference as if they were selected independently of the data. It is possible to show that refitting the regression model after doing model selection with the lasso (or any other model selection method!) may lead to $\sqrt{n}$-biased estimates (which is one reason why a simple Gaussian approximation will often fail for confidence intervals)
Fortunately, there has been much progress in recent years in developing inference methods that account for post-selection. Some relevant references for your case are:
Exact post-selection inference, with application to the lasso
and,
Post-selection inference for l1-penalized likelihood models by Jonathan Taylor and Robert Tibshirani,
Stanford University. The techniques discussed in these references are implemented in the R package selectiveInference- selectiveInference: Tools for Post-Selection Inference | CRAN
. The selectiveInference package should produce the valid confidence intervals you need.
|
Testing for coefficients significance in Lasso logistic regression
|
The issue with performing inference after model selection is that you are selecting the most predictive variables and then performing inference as if they were selected independently of the data. It i
|
Testing for coefficients significance in Lasso logistic regression
The issue with performing inference after model selection is that you are selecting the most predictive variables and then performing inference as if they were selected independently of the data. It is possible to show that refitting the regression model after doing model selection with the lasso (or any other model selection method!) may lead to $\sqrt{n}$-biased estimates (which is one reason why a simple Gaussian approximation will often fail for confidence intervals)
Fortunately, there has been much progress in recent years in developing inference methods that account for post-selection. Some relevant references for your case are:
Exact post-selection inference, with application to the lasso
and,
Post-selection inference for l1-penalized likelihood models by Jonathan Taylor and Robert Tibshirani,
Stanford University. The techniques discussed in these references are implemented in the R package selectiveInference- selectiveInference: Tools for Post-Selection Inference | CRAN
. The selectiveInference package should produce the valid confidence intervals you need.
|
Testing for coefficients significance in Lasso logistic regression
The issue with performing inference after model selection is that you are selecting the most predictive variables and then performing inference as if they were selected independently of the data. It i
|
15,839
|
Residual standard error difference between optim and glm
|
The issues is that the standard errors comes from
$$\hat\sigma^2 (X^\top X)^{-1}$$
where $\hat\sigma^2$ is the unbiased estimator and not the MLE. See summary.lm
summary.lm
#R function (object, correlation = FALSE, symbolic.cor = FALSE,
#R ...)
#R {
#R z <- object
#R p <- z$rank
#R rdf <- z$df.residual
#R ...
#R Qr <- qr.lm(object)
#R ...
#R r <- z$residuals
#R f <- z$fitted.values
#R w <- z$weights
#R if (is.null(w)) {
#R mss <- if (attr(z$terms, "intercept"))
#R sum((f - mean(f))^2)
#R else sum(f^2)
#R rss <- sum(r^2)
#R }
#R ...
#R resvar <- rss/rdf
#R ...
#R R <- chol2inv(Qr$qr[p1, p1, drop = FALSE])
#R se <- sqrt(diag(R) * resvar)
#R ...
This is the inverse observed Fisher information for $(\beta_0, \beta_1)$ conditional on $\hat\sigma^2$. Now the inverse observed Fisher information you compute is for the triplet $(\beta_0, \beta_1, \sigma)$. I.e., you use the MLE of $\sigma$ and not the unbiased estimator. Thus, I gather the standard errors should differ by factor $\sqrt{n/(n-3 + 1)}$ or something similar. This is the case
set.seed(1)
n = 4 # very small sample size !
b0 <- 5
b1 <- 2
sigma <- 5
x <- runif(n, 1, 100)
y = b0 + b1*x + rnorm(n, 0, sigma)
negLL <- function(beta, y, x) {
b0 <- beta[1]
b1 <- beta[2]
sigma <- beta[3]
yhat <- b0 + b1*x
return(-sum(dnorm(y, yhat, sigma, log = TRUE)))
}
res <- optim(c(0, 0, 1), negLL, y = y, x = x, hessian=TRUE)
estimates <- res$par # Parameters estimates
(se <- sqrt(diag(solve(res$hessian))))
#R [1] 5.690 0.097 1.653
k <- 3
se * sqrt(n / (n-k+1))
#R [1] 8.047 0.137 2.338
To elaborate more as usεr11852 requests, the log-likelihood is
$$l(\vec{\beta},\sigma) =
-\frac{n}{2}\log(2\pi) - n\log{\sigma}
- \frac{1}{2\sigma^2}(\vec{y}-X\vec\beta)^\top(\vec{y}-X\vec\beta)$$
where $X$ is the design matrix and $n$ is the number of observation. Consequently, the observed information matrix is
$$-\nabla_{\vec{\beta}}\nabla_{\vec{\beta}}^\top
l(\vec{\beta},\sigma) = \frac{1}{\sigma^2}X^\top X$$
Now we can either plug in the MLE or the unbaised estimator of $\sigma$ as the following show
m <- lm(y ~ x)
X <- cbind(1, x)
sqrt(sum(resid(m)^2)/n * diag(solve(crossprod(X))))
#R x
#R 5.71058285 0.09732149
k <- 3
sqrt(sum(resid(m)^2)/(n-k+1) * diag(solve(crossprod(X))))
#R x
#R 8.0759837 0.1376334
We can do the same with a QR decomposition as lm does
obj <- qr(X)
sqrt(sum(resid(m)^2)/(n-k+1) * diag(chol2inv(obj$qr)))
#R [1] 8.0759837 0.1376334
So to answer
I understand from my readings on the web that optimization is not a simple task but I was wondering if it would be possible to reproduce in a simple way the standard error estimates from glm while using optim.
then you need to scale up the standard errors in the Gaussian example you use.
|
Residual standard error difference between optim and glm
|
The issues is that the standard errors comes from
$$\hat\sigma^2 (X^\top X)^{-1}$$
where $\hat\sigma^2$ is the unbiased estimator and not the MLE. See summary.lm
summary.lm
#R function (object, corre
|
Residual standard error difference between optim and glm
The issues is that the standard errors comes from
$$\hat\sigma^2 (X^\top X)^{-1}$$
where $\hat\sigma^2$ is the unbiased estimator and not the MLE. See summary.lm
summary.lm
#R function (object, correlation = FALSE, symbolic.cor = FALSE,
#R ...)
#R {
#R z <- object
#R p <- z$rank
#R rdf <- z$df.residual
#R ...
#R Qr <- qr.lm(object)
#R ...
#R r <- z$residuals
#R f <- z$fitted.values
#R w <- z$weights
#R if (is.null(w)) {
#R mss <- if (attr(z$terms, "intercept"))
#R sum((f - mean(f))^2)
#R else sum(f^2)
#R rss <- sum(r^2)
#R }
#R ...
#R resvar <- rss/rdf
#R ...
#R R <- chol2inv(Qr$qr[p1, p1, drop = FALSE])
#R se <- sqrt(diag(R) * resvar)
#R ...
This is the inverse observed Fisher information for $(\beta_0, \beta_1)$ conditional on $\hat\sigma^2$. Now the inverse observed Fisher information you compute is for the triplet $(\beta_0, \beta_1, \sigma)$. I.e., you use the MLE of $\sigma$ and not the unbiased estimator. Thus, I gather the standard errors should differ by factor $\sqrt{n/(n-3 + 1)}$ or something similar. This is the case
set.seed(1)
n = 4 # very small sample size !
b0 <- 5
b1 <- 2
sigma <- 5
x <- runif(n, 1, 100)
y = b0 + b1*x + rnorm(n, 0, sigma)
negLL <- function(beta, y, x) {
b0 <- beta[1]
b1 <- beta[2]
sigma <- beta[3]
yhat <- b0 + b1*x
return(-sum(dnorm(y, yhat, sigma, log = TRUE)))
}
res <- optim(c(0, 0, 1), negLL, y = y, x = x, hessian=TRUE)
estimates <- res$par # Parameters estimates
(se <- sqrt(diag(solve(res$hessian))))
#R [1] 5.690 0.097 1.653
k <- 3
se * sqrt(n / (n-k+1))
#R [1] 8.047 0.137 2.338
To elaborate more as usεr11852 requests, the log-likelihood is
$$l(\vec{\beta},\sigma) =
-\frac{n}{2}\log(2\pi) - n\log{\sigma}
- \frac{1}{2\sigma^2}(\vec{y}-X\vec\beta)^\top(\vec{y}-X\vec\beta)$$
where $X$ is the design matrix and $n$ is the number of observation. Consequently, the observed information matrix is
$$-\nabla_{\vec{\beta}}\nabla_{\vec{\beta}}^\top
l(\vec{\beta},\sigma) = \frac{1}{\sigma^2}X^\top X$$
Now we can either plug in the MLE or the unbaised estimator of $\sigma$ as the following show
m <- lm(y ~ x)
X <- cbind(1, x)
sqrt(sum(resid(m)^2)/n * diag(solve(crossprod(X))))
#R x
#R 5.71058285 0.09732149
k <- 3
sqrt(sum(resid(m)^2)/(n-k+1) * diag(solve(crossprod(X))))
#R x
#R 8.0759837 0.1376334
We can do the same with a QR decomposition as lm does
obj <- qr(X)
sqrt(sum(resid(m)^2)/(n-k+1) * diag(chol2inv(obj$qr)))
#R [1] 8.0759837 0.1376334
So to answer
I understand from my readings on the web that optimization is not a simple task but I was wondering if it would be possible to reproduce in a simple way the standard error estimates from glm while using optim.
then you need to scale up the standard errors in the Gaussian example you use.
|
Residual standard error difference between optim and glm
The issues is that the standard errors comes from
$$\hat\sigma^2 (X^\top X)^{-1}$$
where $\hat\sigma^2$ is the unbiased estimator and not the MLE. See summary.lm
summary.lm
#R function (object, corre
|
15,840
|
Residual standard error difference between optim and glm
|
If i understood well, the solution is simple: optim maximizes the likelihood, by dividing the sum of squared residuals by $n$. What you want is to divide the sum of squares by $n-k+1$. So undo the division by $n$ and divide by $n-k+1$: sqrt(4.717216^2*4/2) = 6.671151
|
Residual standard error difference between optim and glm
|
If i understood well, the solution is simple: optim maximizes the likelihood, by dividing the sum of squared residuals by $n$. What you want is to divide the sum of squares by $n-k+1$. So undo the div
|
Residual standard error difference between optim and glm
If i understood well, the solution is simple: optim maximizes the likelihood, by dividing the sum of squared residuals by $n$. What you want is to divide the sum of squares by $n-k+1$. So undo the division by $n$ and divide by $n-k+1$: sqrt(4.717216^2*4/2) = 6.671151
|
Residual standard error difference between optim and glm
If i understood well, the solution is simple: optim maximizes the likelihood, by dividing the sum of squared residuals by $n$. What you want is to divide the sum of squares by $n-k+1$. So undo the div
|
15,841
|
The difference between logistic regression and support vector machines?
|
You are right if you are talking about hard SVM and the two classes are linearly separable. LR finds any solution that separates the two classes. Hard SVM finds "the" solution among all possible ones that has the maximum margin.
In case of soft SVM and the classes not being linearly separable, you are still right with a slight modification. The error cannot become zero. LR finds a hyperplane that corresponds to the minimization of some error. Soft SVM tries to minimize the error (another error) and at the same time trades off that error with the margin via a regularization parameter.
One difference between the two: SVM is a hard classifier but LR is a probabilistic one. SVM is sparse. It chooses the support vectors (from the training samples) that has the most discriminatory power between the two classes. Since it does not keep other training points beyond that at the test time, we do not have any idea about about the distribution of any of the two classes.
I have explained how LR solution (using IRLS) breaks in case of linearly separability of the two classes and why it stops being a probabilistic classifier in such a case: https://stats.stackexchange.com/a/133292/66491
|
The difference between logistic regression and support vector machines?
|
You are right if you are talking about hard SVM and the two classes are linearly separable. LR finds any solution that separates the two classes. Hard SVM finds "the" solution among all possible one
|
The difference between logistic regression and support vector machines?
You are right if you are talking about hard SVM and the two classes are linearly separable. LR finds any solution that separates the two classes. Hard SVM finds "the" solution among all possible ones that has the maximum margin.
In case of soft SVM and the classes not being linearly separable, you are still right with a slight modification. The error cannot become zero. LR finds a hyperplane that corresponds to the minimization of some error. Soft SVM tries to minimize the error (another error) and at the same time trades off that error with the margin via a regularization parameter.
One difference between the two: SVM is a hard classifier but LR is a probabilistic one. SVM is sparse. It chooses the support vectors (from the training samples) that has the most discriminatory power between the two classes. Since it does not keep other training points beyond that at the test time, we do not have any idea about about the distribution of any of the two classes.
I have explained how LR solution (using IRLS) breaks in case of linearly separability of the two classes and why it stops being a probabilistic classifier in such a case: https://stats.stackexchange.com/a/133292/66491
|
The difference between logistic regression and support vector machines?
You are right if you are talking about hard SVM and the two classes are linearly separable. LR finds any solution that separates the two classes. Hard SVM finds "the" solution among all possible one
|
15,842
|
Confused with MCMC Metropolis-Hastings variations: Random-Walk, Non-Random-Walk, Independent, Metropolis
|
Here you go - three examples. I've made the code much less efficient than it would be in a real application in order to make the logic clearer (I hope.)
# We'll assume estimation of a Poisson mean as a function of x
x <- runif(100)
y <- rpois(100,5*x) # beta = 5 where mean(y[i]) = beta*x[i]
# Prior distribution on log(beta): t(5) with mean 2
# (Very spread out on original scale; median = 7.4, roughly)
log_prior <- function(log_beta) dt(log_beta-2, 5, log=TRUE)
# Log likelihood
log_lik <- function(log_beta, y, x) sum(dpois(y, exp(log_beta)*x, log=TRUE))
# Random Walk Metropolis-Hastings
# Proposal is centered at the current value of the parameter
rw_proposal <- function(current) rnorm(1, current, 0.25)
rw_p_proposal_given_current <- function(proposal, current) dnorm(proposal, current, 0.25, log=TRUE)
rw_p_current_given_proposal <- function(current, proposal) dnorm(current, proposal, 0.25, log=TRUE)
rw_alpha <- function(proposal, current) {
# Due to the structure of the rw proposal distribution, the rw_p_proposal_given_current and
# rw_p_current_given_proposal terms cancel out, so we don't need to include them - although
# logically they are still there: p(prop|curr) = p(curr|prop) for all curr, prop
exp(log_lik(proposal, y, x) + log_prior(proposal) - log_lik(current, y, x) - log_prior(current))
}
# Independent Metropolis-Hastings
# Note: the proposal is independent of the current value (hence the name), but I maintain the
# parameterization of the functions anyway. The proposal is not ignorable any more
# when calculation the acceptance probability, as p(curr|prop) != p(prop|curr) in general.
ind_proposal <- function(current) rnorm(1, 2, 1)
ind_p_proposal_given_current <- function(proposal, current) dnorm(proposal, 2, 1, log=TRUE)
ind_p_current_given_proposal <- function(current, proposal) dnorm(current, 2, 1, log=TRUE)
ind_alpha <- function(proposal, current) {
exp(log_lik(proposal, y, x) + log_prior(proposal) + ind_p_current_given_proposal(current, proposal)
- log_lik(current, y, x) - log_prior(current) - ind_p_proposal_given_current(proposal, current))
}
# Vanilla Metropolis-Hastings - the independence sampler would do here, but I'll add something
# else for the proposal distribution; a Normal(current, 0.1+abs(current)/5) - symmetric but with a different
# scale depending upon location, so can't ignore the proposal distribution when calculating alpha as
# p(prop|curr) != p(curr|prop) in general
van_proposal <- function(current) rnorm(1, current, 0.1+abs(current)/5)
van_p_proposal_given_current <- function(proposal, current) dnorm(proposal, current, 0.1+abs(current)/5, log=TRUE)
van_p_current_given_proposal <- function(current, proposal) dnorm(current, proposal, 0.1+abs(proposal)/5, log=TRUE)
van_alpha <- function(proposal, current) {
exp(log_lik(proposal, y, x) + log_prior(proposal) + ind_p_current_given_proposal(current, proposal)
- log_lik(current, y, x) - log_prior(current) - ind_p_proposal_given_current(proposal, current))
}
# Generate the chain
values <- rep(0, 10000)
u <- runif(length(values))
naccept <- 0
current <- 1 # Initial value
propfunc <- van_proposal # Substitute ind_proposal or rw_proposal here
alphafunc <- van_alpha # Substitute ind_alpha or rw_alpha here
for (i in 1:length(values)) {
proposal <- propfunc(current)
alpha <- alphafunc(proposal, current)
if (u[i] < alpha) {
values[i] <- exp(proposal)
current <- proposal
naccept <- naccept + 1
} else {
values[i] <- exp(current)
}
}
naccept / length(values)
summary(values)
For the vanilla sampler, we get:
> naccept / length(values)
[1] 0.1737
> summary(values)
Min. 1st Qu. Median Mean 3rd Qu. Max.
2.843 5.153 5.388 5.378 5.594 6.628
which is a low acceptance probability, but still... tuning the proposal would help here, or adopting a different one. Here's the random walk proposal results:
> naccept / length(values)
[1] 0.2902
> summary(values)
Min. 1st Qu. Median Mean 3rd Qu. Max.
2.718 5.147 5.369 5.370 5.584 6.781
Similar results, as one would hope, and a better acceptance probability (aiming for ~50% with one parameter.)
And, for completeness, the independence sampler:
> naccept / length(values)
[1] 0.0684
> summary(values)
Min. 1st Qu. Median Mean 3rd Qu. Max.
3.990 5.162 5.391 5.380 5.577 8.802
Because it doesn't "adapt" to the shape of the posterior, it tends to have the poorest acceptance probability and is hardest to tune well for this problem.
Note that generally speaking we'd prefer proposals with fatter tails, but that's a whole other topic.
|
Confused with MCMC Metropolis-Hastings variations: Random-Walk, Non-Random-Walk, Independent, Metrop
|
Here you go - three examples. I've made the code much less efficient than it would be in a real application in order to make the logic clearer (I hope.)
# We'll assume estimation of a Poisson mean as
|
Confused with MCMC Metropolis-Hastings variations: Random-Walk, Non-Random-Walk, Independent, Metropolis
Here you go - three examples. I've made the code much less efficient than it would be in a real application in order to make the logic clearer (I hope.)
# We'll assume estimation of a Poisson mean as a function of x
x <- runif(100)
y <- rpois(100,5*x) # beta = 5 where mean(y[i]) = beta*x[i]
# Prior distribution on log(beta): t(5) with mean 2
# (Very spread out on original scale; median = 7.4, roughly)
log_prior <- function(log_beta) dt(log_beta-2, 5, log=TRUE)
# Log likelihood
log_lik <- function(log_beta, y, x) sum(dpois(y, exp(log_beta)*x, log=TRUE))
# Random Walk Metropolis-Hastings
# Proposal is centered at the current value of the parameter
rw_proposal <- function(current) rnorm(1, current, 0.25)
rw_p_proposal_given_current <- function(proposal, current) dnorm(proposal, current, 0.25, log=TRUE)
rw_p_current_given_proposal <- function(current, proposal) dnorm(current, proposal, 0.25, log=TRUE)
rw_alpha <- function(proposal, current) {
# Due to the structure of the rw proposal distribution, the rw_p_proposal_given_current and
# rw_p_current_given_proposal terms cancel out, so we don't need to include them - although
# logically they are still there: p(prop|curr) = p(curr|prop) for all curr, prop
exp(log_lik(proposal, y, x) + log_prior(proposal) - log_lik(current, y, x) - log_prior(current))
}
# Independent Metropolis-Hastings
# Note: the proposal is independent of the current value (hence the name), but I maintain the
# parameterization of the functions anyway. The proposal is not ignorable any more
# when calculation the acceptance probability, as p(curr|prop) != p(prop|curr) in general.
ind_proposal <- function(current) rnorm(1, 2, 1)
ind_p_proposal_given_current <- function(proposal, current) dnorm(proposal, 2, 1, log=TRUE)
ind_p_current_given_proposal <- function(current, proposal) dnorm(current, 2, 1, log=TRUE)
ind_alpha <- function(proposal, current) {
exp(log_lik(proposal, y, x) + log_prior(proposal) + ind_p_current_given_proposal(current, proposal)
- log_lik(current, y, x) - log_prior(current) - ind_p_proposal_given_current(proposal, current))
}
# Vanilla Metropolis-Hastings - the independence sampler would do here, but I'll add something
# else for the proposal distribution; a Normal(current, 0.1+abs(current)/5) - symmetric but with a different
# scale depending upon location, so can't ignore the proposal distribution when calculating alpha as
# p(prop|curr) != p(curr|prop) in general
van_proposal <- function(current) rnorm(1, current, 0.1+abs(current)/5)
van_p_proposal_given_current <- function(proposal, current) dnorm(proposal, current, 0.1+abs(current)/5, log=TRUE)
van_p_current_given_proposal <- function(current, proposal) dnorm(current, proposal, 0.1+abs(proposal)/5, log=TRUE)
van_alpha <- function(proposal, current) {
exp(log_lik(proposal, y, x) + log_prior(proposal) + ind_p_current_given_proposal(current, proposal)
- log_lik(current, y, x) - log_prior(current) - ind_p_proposal_given_current(proposal, current))
}
# Generate the chain
values <- rep(0, 10000)
u <- runif(length(values))
naccept <- 0
current <- 1 # Initial value
propfunc <- van_proposal # Substitute ind_proposal or rw_proposal here
alphafunc <- van_alpha # Substitute ind_alpha or rw_alpha here
for (i in 1:length(values)) {
proposal <- propfunc(current)
alpha <- alphafunc(proposal, current)
if (u[i] < alpha) {
values[i] <- exp(proposal)
current <- proposal
naccept <- naccept + 1
} else {
values[i] <- exp(current)
}
}
naccept / length(values)
summary(values)
For the vanilla sampler, we get:
> naccept / length(values)
[1] 0.1737
> summary(values)
Min. 1st Qu. Median Mean 3rd Qu. Max.
2.843 5.153 5.388 5.378 5.594 6.628
which is a low acceptance probability, but still... tuning the proposal would help here, or adopting a different one. Here's the random walk proposal results:
> naccept / length(values)
[1] 0.2902
> summary(values)
Min. 1st Qu. Median Mean 3rd Qu. Max.
2.718 5.147 5.369 5.370 5.584 6.781
Similar results, as one would hope, and a better acceptance probability (aiming for ~50% with one parameter.)
And, for completeness, the independence sampler:
> naccept / length(values)
[1] 0.0684
> summary(values)
Min. 1st Qu. Median Mean 3rd Qu. Max.
3.990 5.162 5.391 5.380 5.577 8.802
Because it doesn't "adapt" to the shape of the posterior, it tends to have the poorest acceptance probability and is hardest to tune well for this problem.
Note that generally speaking we'd prefer proposals with fatter tails, but that's a whole other topic.
|
Confused with MCMC Metropolis-Hastings variations: Random-Walk, Non-Random-Walk, Independent, Metrop
Here you go - three examples. I've made the code much less efficient than it would be in a real application in order to make the logic clearer (I hope.)
# We'll assume estimation of a Poisson mean as
|
15,843
|
Confused with MCMC Metropolis-Hastings variations: Random-Walk, Non-Random-Walk, Independent, Metropolis
|
See:
By construction, the algorithm does not depend on the normalization constant, since what matters is the ratio of the pdf's. The variation of the algorithm in which the proposal pdf $q()$ is not symmetric is due to Hasting (1970) and for this reason the algorithm is often also called Metropolis-Hasting. Moreover, what has been described here is the global Metropolis algorithm, in contrast to the local one, in which a cycle affects only one component of ${\bf x}$.
The Wikipedia article is a good complementary read. As you can see, the Metropolis also has a "correction ratio" but, as mentioned above, Hastings introduced a modification that allows for non-symmetric proposal distributions.
The Metropolis algorithm is implemented in the R package mcmc under the command metrop().
Other code examples:
http://www.mas.ncl.ac.uk/~ndjw1/teaching/sim/metrop/
http://pcl.missouri.edu/jeff/node/322
http://darrenjw.wordpress.com/2010/08/15/metropolis-hastings-mcmc-algorithms/
|
Confused with MCMC Metropolis-Hastings variations: Random-Walk, Non-Random-Walk, Independent, Metrop
|
See:
By construction, the algorithm does not depend on the normalization constant, since what matters is the ratio of the pdf's. The variation of the algorithm in which the proposal pdf $q()$ is not
|
Confused with MCMC Metropolis-Hastings variations: Random-Walk, Non-Random-Walk, Independent, Metropolis
See:
By construction, the algorithm does not depend on the normalization constant, since what matters is the ratio of the pdf's. The variation of the algorithm in which the proposal pdf $q()$ is not symmetric is due to Hasting (1970) and for this reason the algorithm is often also called Metropolis-Hasting. Moreover, what has been described here is the global Metropolis algorithm, in contrast to the local one, in which a cycle affects only one component of ${\bf x}$.
The Wikipedia article is a good complementary read. As you can see, the Metropolis also has a "correction ratio" but, as mentioned above, Hastings introduced a modification that allows for non-symmetric proposal distributions.
The Metropolis algorithm is implemented in the R package mcmc under the command metrop().
Other code examples:
http://www.mas.ncl.ac.uk/~ndjw1/teaching/sim/metrop/
http://pcl.missouri.edu/jeff/node/322
http://darrenjw.wordpress.com/2010/08/15/metropolis-hastings-mcmc-algorithms/
|
Confused with MCMC Metropolis-Hastings variations: Random-Walk, Non-Random-Walk, Independent, Metrop
See:
By construction, the algorithm does not depend on the normalization constant, since what matters is the ratio of the pdf's. The variation of the algorithm in which the proposal pdf $q()$ is not
|
15,844
|
E-M, is there an intuitive explanation?
|
Just to save some typing, call the observed data $X$, the missing data $Z$ (e.g. the hidden states of the HMM), and the parameter vector we're trying to find $Q$ (e.g. transition/emission probabilities).
The intuitive explanation is that we basically cheat, pretend for a moment we know $Q$ so we can find a conditional distribution of Z that in turn lets us find the MLE for $Q$ (ignoring for the moment the fact that we're basically making a circular argument), then admit that we cheated, put in our new, better value for $Q$, and do it all over again until we don't have to cheat anymore.
Slightly more technically, by pretending that we know the real value $Q$, we can pretend we know something about the conditional distribution of $Z|\{X,Q\}$, which lets us improve our estimate for $Q$, which we now pretend is the real value for $Q$ so we can pretend we know something about the conditional distribution of $Z|\{X,Q\}$, which lets us improve our estimate for $Q$, which... and so on.
Even more technically, if we knew $Z$, we could maximize $\log(f(Q|X,Z))$ and have the right answer. The problem is that we don't know $Z$, and any estimate for $Q$ must depend on it. But if we want to find the best estimate (or distribution) for $Z$, then we need to know $X$ and $Q$. We're stuck in a chicken-and-egg situation if we want the unique maximizer analytically.
Our 'out' is that -- for any estimate of $Q$ (call it $Q_n$) -- we can find the distribution of $Z|\{Q_n,X\}$, and so we can maximize our expected joint log-likelihood of $Q|\{X,Z\}$, with respect to the conditional distribution of $Z|\{Q_n,X\}$. This conditional distribution basically tells us how $Z$ depends on the current value of $Q$ given $X$, and lets us know how to change $Q$ to increase our likelihood for both $Q$ and $Z$ at the same time for a particular value of $Q$ (that we've called $Q_n$). Once we've picked out a new $Q_{n+1}$, we have a different conditional distribution for $Z|\{Q_{n+1}, X\}$ and so have to re-calculate the expectation.
|
E-M, is there an intuitive explanation?
|
Just to save some typing, call the observed data $X$, the missing data $Z$ (e.g. the hidden states of the HMM), and the parameter vector we're trying to find $Q$ (e.g. transition/emission probabilitie
|
E-M, is there an intuitive explanation?
Just to save some typing, call the observed data $X$, the missing data $Z$ (e.g. the hidden states of the HMM), and the parameter vector we're trying to find $Q$ (e.g. transition/emission probabilities).
The intuitive explanation is that we basically cheat, pretend for a moment we know $Q$ so we can find a conditional distribution of Z that in turn lets us find the MLE for $Q$ (ignoring for the moment the fact that we're basically making a circular argument), then admit that we cheated, put in our new, better value for $Q$, and do it all over again until we don't have to cheat anymore.
Slightly more technically, by pretending that we know the real value $Q$, we can pretend we know something about the conditional distribution of $Z|\{X,Q\}$, which lets us improve our estimate for $Q$, which we now pretend is the real value for $Q$ so we can pretend we know something about the conditional distribution of $Z|\{X,Q\}$, which lets us improve our estimate for $Q$, which... and so on.
Even more technically, if we knew $Z$, we could maximize $\log(f(Q|X,Z))$ and have the right answer. The problem is that we don't know $Z$, and any estimate for $Q$ must depend on it. But if we want to find the best estimate (or distribution) for $Z$, then we need to know $X$ and $Q$. We're stuck in a chicken-and-egg situation if we want the unique maximizer analytically.
Our 'out' is that -- for any estimate of $Q$ (call it $Q_n$) -- we can find the distribution of $Z|\{Q_n,X\}$, and so we can maximize our expected joint log-likelihood of $Q|\{X,Z\}$, with respect to the conditional distribution of $Z|\{Q_n,X\}$. This conditional distribution basically tells us how $Z$ depends on the current value of $Q$ given $X$, and lets us know how to change $Q$ to increase our likelihood for both $Q$ and $Z$ at the same time for a particular value of $Q$ (that we've called $Q_n$). Once we've picked out a new $Q_{n+1}$, we have a different conditional distribution for $Z|\{Q_{n+1}, X\}$ and so have to re-calculate the expectation.
|
E-M, is there an intuitive explanation?
Just to save some typing, call the observed data $X$, the missing data $Z$ (e.g. the hidden states of the HMM), and the parameter vector we're trying to find $Q$ (e.g. transition/emission probabilitie
|
15,845
|
Literature review on non-linear regression
|
The book "Nonlinear Regression Analysis and Its Applications" (2007) by Bates & Watts springs to mind as an immediate suggestion. It is co-authored by one of the masters of regression algorithm design (D. Bates). Note that is is not exactly fresh; the edition I link is published on 2007 but most of the material is from the 1989 edition. That being said, it is definitely authoritative and has aged very well. I used it as a reference book at times and it was very good. Especially when it came to computational aspects it was indispensable. It couples well with the "Mixed-Effects Models in S and S-PLUS" (2000) by Pinheiro & Bates, which is closer to a panel data paradigm of the problem.
Secondary suggestions: Ruppert et al. "Semiparametric Regression" (2003) has less computational focus that B&W but I think it has a broader scope too. Depending on how we define non-linear regression, looking at Generalised Additive Models can be very insightful and to that extent Wood's "Generalized Additive Models: An Introduction with R" (2017; 2nd Ed.) is probably the most up-to-date reference out there, it is a great read. Similarly, if we care more for Local Regression Models, checking Fan & Gijbels "Local Polynomial Modelling and Its Applications" (1996) is definitely a classic too. (I appreciate that these secondary suggestions are moving even further away from the panel data paradigm but I need them to make my next point.)
Comment: One could note that there are fewer non-parametric regression books coming out recently; that's not entirely a coincidence: Machine Learning happened. Putting aside best-in-class general books like: "Elements of Statistical Learning" (2009) by Hastie et al. and "Machine Learning: a Probabilistic Perspective" (2013) by Murphy, looking into Devroye et al. "A Probabilistic Theory of Pattern Recognition" (1997) covers consistency results, bounds, error rates, convergence, etc. in great detail. Therefore there are some review articles on the intersection of Machine Learning and Econometrics like: "Machine Learning: An Applied Econometric Approach" (2017) by Mullainathan & Spiess or "Big Data: New Tricks for Econometrics" (2014) by Varian. They give an OK overview but they do not offer a rigorous mathematical treatment of the matter, they should though offer a reasonable list of references.
|
Literature review on non-linear regression
|
The book "Nonlinear Regression Analysis and Its Applications" (2007) by Bates & Watts springs to mind as an immediate suggestion. It is co-authored by one of the masters of regression algorithm design
|
Literature review on non-linear regression
The book "Nonlinear Regression Analysis and Its Applications" (2007) by Bates & Watts springs to mind as an immediate suggestion. It is co-authored by one of the masters of regression algorithm design (D. Bates). Note that is is not exactly fresh; the edition I link is published on 2007 but most of the material is from the 1989 edition. That being said, it is definitely authoritative and has aged very well. I used it as a reference book at times and it was very good. Especially when it came to computational aspects it was indispensable. It couples well with the "Mixed-Effects Models in S and S-PLUS" (2000) by Pinheiro & Bates, which is closer to a panel data paradigm of the problem.
Secondary suggestions: Ruppert et al. "Semiparametric Regression" (2003) has less computational focus that B&W but I think it has a broader scope too. Depending on how we define non-linear regression, looking at Generalised Additive Models can be very insightful and to that extent Wood's "Generalized Additive Models: An Introduction with R" (2017; 2nd Ed.) is probably the most up-to-date reference out there, it is a great read. Similarly, if we care more for Local Regression Models, checking Fan & Gijbels "Local Polynomial Modelling and Its Applications" (1996) is definitely a classic too. (I appreciate that these secondary suggestions are moving even further away from the panel data paradigm but I need them to make my next point.)
Comment: One could note that there are fewer non-parametric regression books coming out recently; that's not entirely a coincidence: Machine Learning happened. Putting aside best-in-class general books like: "Elements of Statistical Learning" (2009) by Hastie et al. and "Machine Learning: a Probabilistic Perspective" (2013) by Murphy, looking into Devroye et al. "A Probabilistic Theory of Pattern Recognition" (1997) covers consistency results, bounds, error rates, convergence, etc. in great detail. Therefore there are some review articles on the intersection of Machine Learning and Econometrics like: "Machine Learning: An Applied Econometric Approach" (2017) by Mullainathan & Spiess or "Big Data: New Tricks for Econometrics" (2014) by Varian. They give an OK overview but they do not offer a rigorous mathematical treatment of the matter, they should though offer a reasonable list of references.
|
Literature review on non-linear regression
The book "Nonlinear Regression Analysis and Its Applications" (2007) by Bates & Watts springs to mind as an immediate suggestion. It is co-authored by one of the masters of regression algorithm design
|
15,846
|
Literature review on non-linear regression
|
Non-linear regression is a mature and broad topic, that's why I doubt that there are many recent review papers. The only papers that I can think of are:
Motulsky HJ, Ransnas LA: "Fitting Curves to Data Using Nonlinear Regression: A Practical and Nonmathematical Review." The FASEB Journal, 1(5), 365-374 <- As the name says, a nonmathematical review so not a good place to look for stuff about consistency and asymptotics.
A. R. Gallant: "Nonlinear Regression" The American Statistician Vol. 29, No. 2 (May, 1975), pp. 73-81 <- Older than the paper you mentioned in the question.
You might find a good overview in some statistics handbooks. For instance in "Handbook of regression methods" by Young or in "Modern regression methods" by Ryan you can find a good chapter about nonlinear regression.
About consistency and asymptotics I can recommend chapter 2 of the book "Statistical tools for nonlinear regression" by Huet et al.
Last but not least, the two classics in the English speaking literature are Bates & Watts as mentioned above and "Nonlinear Regression" from Seber and Wild. Another very good bok is "Nonlinear Statistical Models" by Gallant
|
Literature review on non-linear regression
|
Non-linear regression is a mature and broad topic, that's why I doubt that there are many recent review papers. The only papers that I can think of are:
Motulsky HJ, Ransnas LA: "Fitting Curves to Dat
|
Literature review on non-linear regression
Non-linear regression is a mature and broad topic, that's why I doubt that there are many recent review papers. The only papers that I can think of are:
Motulsky HJ, Ransnas LA: "Fitting Curves to Data Using Nonlinear Regression: A Practical and Nonmathematical Review." The FASEB Journal, 1(5), 365-374 <- As the name says, a nonmathematical review so not a good place to look for stuff about consistency and asymptotics.
A. R. Gallant: "Nonlinear Regression" The American Statistician Vol. 29, No. 2 (May, 1975), pp. 73-81 <- Older than the paper you mentioned in the question.
You might find a good overview in some statistics handbooks. For instance in "Handbook of regression methods" by Young or in "Modern regression methods" by Ryan you can find a good chapter about nonlinear regression.
About consistency and asymptotics I can recommend chapter 2 of the book "Statistical tools for nonlinear regression" by Huet et al.
Last but not least, the two classics in the English speaking literature are Bates & Watts as mentioned above and "Nonlinear Regression" from Seber and Wild. Another very good bok is "Nonlinear Statistical Models" by Gallant
|
Literature review on non-linear regression
Non-linear regression is a mature and broad topic, that's why I doubt that there are many recent review papers. The only papers that I can think of are:
Motulsky HJ, Ransnas LA: "Fitting Curves to Dat
|
15,847
|
lmer with multiply imputed data
|
You can do this somewhat by hand if by taking advantage of the lapply functionality in R and the list-structure returned by the Amelia multiple imputation package. Here's a quick example script.
library(Amelia)
library(lme4)
library(merTools)
library(plyr) # for collapsing estimates
Amelia is similar to mice so you can just substitute your variables in from the mice call here -- this example is from a project I was working on.
a.out <- amelia(dat[sub1, varIndex], idvars = "SCH_ID",
noms = varIndex[!varIndex %in% c("SCH_ID", "math12")],
m = 10)
a.out is the imputation object, now we need to run the model on each imputed dataset. To do this, we use the lapply function in R to repeat a function over list elements. This function applies the function -- which is the model specification -- to each dataset (d) in the list and returns the results in a list of models.
mods <- lapply(a.out$imputations,
function(d) lmer((log(wage) ~ gender + age + age_sqr +
occupation + degree + private_sector + overtime +
(1+gender|faculty), data = d)
Now we create a data.frame from that list, by simulating the values the fixed and random effects using the functions FEsim and REsim from the merTools package
imputeFEs <- ldply(mods, FEsim, nsims = 1000)
imputeREs <- ldply(mods, REsim, nsims = 1000)
The data.frames above include separate estimates for each dataset, now we need to combine them using a collapse like argument collapse
imputeREs <- ddply(imputeREs, .(X1, X2), summarize, mean = mean(mean),
median = mean(median), sd = mean(sd),
level = level[1])
imputeFEs <- ddply(imputeFEs, .(var), summarize, meanEff = mean(meanEff),
medEff = mean(medEff), sdEff = mean(sdEff))
Now we can also extract some statistics on the variance/covariance for the random effects across the imputed values. Here I have written two simple extractor functions to do this.
REsdExtract <- function(model){
out <- unlist(lapply(VarCorr(model), attr, "stddev"))
return(out)
}
REcorrExtract <- function(model){
out <- unlist(lapply(VarCorr(model), attr, "corre"))
return(min(unique(out)))
}
And now we can apply them to the models and store them as a vector:
modStats <- cbind(ldply(mods, REsdExtract), ldply(mods, REcorrExtract))
Update
The functions below will get you much closer to the output provided by arm::display by operating on the list of lmer or glmer objects. Hopefully this will be incorporated into the merTools package in the near future:
# Functions to extract standard deviation of random effects from model
REsdExtract <- function(model){
out <- unlist(lapply(VarCorr(model), attr, "stddev"))
return(out)
}
#slope intercept correlation from model
REcorrExtract <- function(model){
out <- unlist(lapply(VarCorr(model), attr, "corre"))
return(min(unique(out)))
}
modelRandEffStats <- function(modList){
SDs <- ldply(modList, REsdExtract)
corrs <- ldply(modList, REcorrExtract)
tmp <- cbind(SDs, corrs)
names(tmp) <- c("Imp", "Int", "Slope", "id", "Corr")
out <- data.frame(IntSD_mean = mean(tmp$Int),
SlopeSD_mean = mean(tmp$Slope),
Corr_mean = mean(tmp$Corr),
IntSD_sd = sd(tmp$Int),
SlopeSD_sd = sd(tmp$Slope),
Corr_sd = sd(tmp$Corr))
return(out)
}
modelFixedEff <- function(modList){
require(broom)
fixEst <- ldply(modList, tidy, effects = "fixed")
# Collapse
out <- ddply(fixEst, .(term), summarize,
estimate = mean(estimate),
std.error = mean(std.error))
out$statistic <- out$estimate / out$std.error
return(out)
}
print.merModList <- function(modList, digits = 3){
len <- length(modList)
form <- modList[[1]]@call
print(form)
cat("\nFixed Effects:\n")
fedat <- modelFixedEff(modList)
dimnames(fedat)[[1]] <- fedat$term
pfround(fedat[-1, -1], digits)
cat("\nError Terms Random Effect Std. Devs\n")
cat("and covariances:\n")
cat("\n")
ngrps <- length(VarCorr(modmathG[[1]]))
errorList <- vector(mode = 'list', length = ngrps)
corrList <- vector(mode = 'list', length = ngrps)
for(i in 1:ngrps){
subList <- lapply(modList, function(x) VarCorr(x)[[i]])
subList <- apply(simplify2array(subList), 1:2, mean)
errorList[[i]] <- subList
subList <- lapply(modList, function(x) attr(VarCorr(x)[[i]], "corre"))
subList <- min(unique(apply(simplify2array(subList), 1:2, function(x) mean(x))))
corrList[[i]] <- subList
}
errorList <- lapply(errorList, function(x) {
diag(x) <- sqrt(diag(x))
return(x)
})
lapply(errorList, pfround, digits)
cat("\nError Term Correlations:\n")
lapply(corrList, pfround, digits)
residError <- mean(unlist(lapply(modList, function(x) attr(VarCorr(x), "sc"))))
cat("\nResidual Error =", fround(residError,
digits), "\n")
cat("\n---Groups\n")
ngrps <- lapply(modList[[1]]@flist, function(x) length(levels(x)))
modn <- getME(modList[[1]], "devcomp")$dims["n"]
cat(sprintf("number of obs: %d, groups: ", modn))
cat(paste(paste(names(ngrps), ngrps, sep = ", "),
collapse = "; "))
cat("\n")
cat("\nModel Fit Stats")
mAIC <- mean(unlist(lapply(modList, AIC)))
cat(sprintf("\nAIC = %g", round(mAIC, 1)))
moDsigma.hat <- mean(unlist(lapply(modmathG, sigma)))
cat("\nOverdispersion parameter =", fround(moDsigma.hat,
digits), "\n")
}
|
lmer with multiply imputed data
|
You can do this somewhat by hand if by taking advantage of the lapply functionality in R and the list-structure returned by the Amelia multiple imputation package. Here's a quick example script.
libr
|
lmer with multiply imputed data
You can do this somewhat by hand if by taking advantage of the lapply functionality in R and the list-structure returned by the Amelia multiple imputation package. Here's a quick example script.
library(Amelia)
library(lme4)
library(merTools)
library(plyr) # for collapsing estimates
Amelia is similar to mice so you can just substitute your variables in from the mice call here -- this example is from a project I was working on.
a.out <- amelia(dat[sub1, varIndex], idvars = "SCH_ID",
noms = varIndex[!varIndex %in% c("SCH_ID", "math12")],
m = 10)
a.out is the imputation object, now we need to run the model on each imputed dataset. To do this, we use the lapply function in R to repeat a function over list elements. This function applies the function -- which is the model specification -- to each dataset (d) in the list and returns the results in a list of models.
mods <- lapply(a.out$imputations,
function(d) lmer((log(wage) ~ gender + age + age_sqr +
occupation + degree + private_sector + overtime +
(1+gender|faculty), data = d)
Now we create a data.frame from that list, by simulating the values the fixed and random effects using the functions FEsim and REsim from the merTools package
imputeFEs <- ldply(mods, FEsim, nsims = 1000)
imputeREs <- ldply(mods, REsim, nsims = 1000)
The data.frames above include separate estimates for each dataset, now we need to combine them using a collapse like argument collapse
imputeREs <- ddply(imputeREs, .(X1, X2), summarize, mean = mean(mean),
median = mean(median), sd = mean(sd),
level = level[1])
imputeFEs <- ddply(imputeFEs, .(var), summarize, meanEff = mean(meanEff),
medEff = mean(medEff), sdEff = mean(sdEff))
Now we can also extract some statistics on the variance/covariance for the random effects across the imputed values. Here I have written two simple extractor functions to do this.
REsdExtract <- function(model){
out <- unlist(lapply(VarCorr(model), attr, "stddev"))
return(out)
}
REcorrExtract <- function(model){
out <- unlist(lapply(VarCorr(model), attr, "corre"))
return(min(unique(out)))
}
And now we can apply them to the models and store them as a vector:
modStats <- cbind(ldply(mods, REsdExtract), ldply(mods, REcorrExtract))
Update
The functions below will get you much closer to the output provided by arm::display by operating on the list of lmer or glmer objects. Hopefully this will be incorporated into the merTools package in the near future:
# Functions to extract standard deviation of random effects from model
REsdExtract <- function(model){
out <- unlist(lapply(VarCorr(model), attr, "stddev"))
return(out)
}
#slope intercept correlation from model
REcorrExtract <- function(model){
out <- unlist(lapply(VarCorr(model), attr, "corre"))
return(min(unique(out)))
}
modelRandEffStats <- function(modList){
SDs <- ldply(modList, REsdExtract)
corrs <- ldply(modList, REcorrExtract)
tmp <- cbind(SDs, corrs)
names(tmp) <- c("Imp", "Int", "Slope", "id", "Corr")
out <- data.frame(IntSD_mean = mean(tmp$Int),
SlopeSD_mean = mean(tmp$Slope),
Corr_mean = mean(tmp$Corr),
IntSD_sd = sd(tmp$Int),
SlopeSD_sd = sd(tmp$Slope),
Corr_sd = sd(tmp$Corr))
return(out)
}
modelFixedEff <- function(modList){
require(broom)
fixEst <- ldply(modList, tidy, effects = "fixed")
# Collapse
out <- ddply(fixEst, .(term), summarize,
estimate = mean(estimate),
std.error = mean(std.error))
out$statistic <- out$estimate / out$std.error
return(out)
}
print.merModList <- function(modList, digits = 3){
len <- length(modList)
form <- modList[[1]]@call
print(form)
cat("\nFixed Effects:\n")
fedat <- modelFixedEff(modList)
dimnames(fedat)[[1]] <- fedat$term
pfround(fedat[-1, -1], digits)
cat("\nError Terms Random Effect Std. Devs\n")
cat("and covariances:\n")
cat("\n")
ngrps <- length(VarCorr(modmathG[[1]]))
errorList <- vector(mode = 'list', length = ngrps)
corrList <- vector(mode = 'list', length = ngrps)
for(i in 1:ngrps){
subList <- lapply(modList, function(x) VarCorr(x)[[i]])
subList <- apply(simplify2array(subList), 1:2, mean)
errorList[[i]] <- subList
subList <- lapply(modList, function(x) attr(VarCorr(x)[[i]], "corre"))
subList <- min(unique(apply(simplify2array(subList), 1:2, function(x) mean(x))))
corrList[[i]] <- subList
}
errorList <- lapply(errorList, function(x) {
diag(x) <- sqrt(diag(x))
return(x)
})
lapply(errorList, pfround, digits)
cat("\nError Term Correlations:\n")
lapply(corrList, pfround, digits)
residError <- mean(unlist(lapply(modList, function(x) attr(VarCorr(x), "sc"))))
cat("\nResidual Error =", fround(residError,
digits), "\n")
cat("\n---Groups\n")
ngrps <- lapply(modList[[1]]@flist, function(x) length(levels(x)))
modn <- getME(modList[[1]], "devcomp")$dims["n"]
cat(sprintf("number of obs: %d, groups: ", modn))
cat(paste(paste(names(ngrps), ngrps, sep = ", "),
collapse = "; "))
cat("\n")
cat("\nModel Fit Stats")
mAIC <- mean(unlist(lapply(modList, AIC)))
cat(sprintf("\nAIC = %g", round(mAIC, 1)))
moDsigma.hat <- mean(unlist(lapply(modmathG, sigma)))
cat("\nOverdispersion parameter =", fround(moDsigma.hat,
digits), "\n")
}
|
lmer with multiply imputed data
You can do this somewhat by hand if by taking advantage of the lapply functionality in R and the list-structure returned by the Amelia multiple imputation package. Here's a quick example script.
libr
|
15,848
|
lmer with multiply imputed data
|
You can also use the testEstimates function after imputation using mice with the following code: testEstimates(as.mitml.result(fm1), var.comp = T)$var.comp
|
lmer with multiply imputed data
|
You can also use the testEstimates function after imputation using mice with the following code: testEstimates(as.mitml.result(fm1), var.comp = T)$var.comp
|
lmer with multiply imputed data
You can also use the testEstimates function after imputation using mice with the following code: testEstimates(as.mitml.result(fm1), var.comp = T)$var.comp
|
lmer with multiply imputed data
You can also use the testEstimates function after imputation using mice with the following code: testEstimates(as.mitml.result(fm1), var.comp = T)$var.comp
|
15,849
|
What is the intuition behind exchangeable samples under the null hypothesis?
|
First, the non-figurative description: Exchangability means that the joint distribution is invariant to permutations of the values of each variable in the joint distribution (i.e, $f_{XYZ}(x = 1, y=3, z=2)=f_{XYZ}(x=3,y=2,z=1)$, etc). If this is not the case then counting permutations is not a valid way of testing the null hypothesis, as each permutation will have a different weight (probability/density). Permutation tests depend on each assignment of a given set of numerical values to your variables having the same density/probability.
A concrete example where exchangeability is absent: You have N jars, each filled with 100 numbered tickets. The first M jars have tickets with only odd numbers from 1-200 (1 ticket per number), the remaining N-M have tickets for only even numbers between 1 - 200. If you select a ticket from each jar at random, you get a joint distribution on sample results. In this case, $f(X_1=1,X_2=2,X_3=3...X_N=N)\neq f(X_1=N,X_2=N-1,X_3=N-2...X_N=1)$
so you cannot just count permutations of the values 1 through N. In general, exchangeability fails when your sample can be stratified into sub-groups (as I have done with the jars). Exchangeabilty would be restored if, instead of taking 1 sample from N jars, you took N samples from 1 jar. Then, the joint distribution would be invariant to permutations.
|
What is the intuition behind exchangeable samples under the null hypothesis?
|
First, the non-figurative description: Exchangability means that the joint distribution is invariant to permutations of the values of each variable in the joint distribution (i.e, $f_{XYZ}(x = 1, y=3,
|
What is the intuition behind exchangeable samples under the null hypothesis?
First, the non-figurative description: Exchangability means that the joint distribution is invariant to permutations of the values of each variable in the joint distribution (i.e, $f_{XYZ}(x = 1, y=3, z=2)=f_{XYZ}(x=3,y=2,z=1)$, etc). If this is not the case then counting permutations is not a valid way of testing the null hypothesis, as each permutation will have a different weight (probability/density). Permutation tests depend on each assignment of a given set of numerical values to your variables having the same density/probability.
A concrete example where exchangeability is absent: You have N jars, each filled with 100 numbered tickets. The first M jars have tickets with only odd numbers from 1-200 (1 ticket per number), the remaining N-M have tickets for only even numbers between 1 - 200. If you select a ticket from each jar at random, you get a joint distribution on sample results. In this case, $f(X_1=1,X_2=2,X_3=3...X_N=N)\neq f(X_1=N,X_2=N-1,X_3=N-2...X_N=1)$
so you cannot just count permutations of the values 1 through N. In general, exchangeability fails when your sample can be stratified into sub-groups (as I have done with the jars). Exchangeabilty would be restored if, instead of taking 1 sample from N jars, you took N samples from 1 jar. Then, the joint distribution would be invariant to permutations.
|
What is the intuition behind exchangeable samples under the null hypothesis?
First, the non-figurative description: Exchangability means that the joint distribution is invariant to permutations of the values of each variable in the joint distribution (i.e, $f_{XYZ}(x = 1, y=3,
|
15,850
|
Is the sum of two decision trees equivalent to a single decision tree?
|
Yes, the weighted sum of a regression trees is equivalent to a single (deeper) regression tree.
Universal function approximator
A regression tree is a universal function approximator (see e.g. cstheory). Most research on universal function approximations is done on artifical neural networks with one hidden layer (read this great blog). However, most machine learning algorithms are universal function approximations.
Being a universal function approximator means that any arbitrary function can be approximately represented. Thus, no matter how complex the function gets, a universal function approximation can represent it with any desired precision. In case of a regression tree you can imagine an infinitely deep one. This infinitely deep tree can assign any value to any point in space.
Since a weighted sum of a regression tree is another arbitrary function, there exists another regression tree that represents that function.
An algorithm to create such a tree
Knowing that such a tree exist is great. But we also want a recipe to create them. Such and algorithm would combine two given trees $T_1$ and $T_2$ and create a new one. A solution is copy-pasting $T_2$ at every leaf node of $T1$. The output value of the leaf nodes of the new tree is then the weighted sum of the leaf node of $T1$ (somewhere in the middle of the tree) and the leaf node of $T2$.
The example below shows two simple trees that are added with weight 0.5. Note that one node will never be reached, because there does not exist a number that is smaller than 3 and larger than 5. This indicates that these trees can be improved, but it does not make them invalid.
Why use more complex algorithms
An interesting additional question was raised by @usεr11852 in the comments: why would we use boosting algorithms (or in fact any complex machine learning algorithm) if every function can be modelled with a simple regression tree?
Regression trees can indeed represent any function but that is only one criteria for a machine learning algorithm. One important other property is how well they generalise. Deep regression trees are prone to overfitting, i.e. they do not generalise well. A random forest averages lots of deep trees to prevent this.
|
Is the sum of two decision trees equivalent to a single decision tree?
|
Yes, the weighted sum of a regression trees is equivalent to a single (deeper) regression tree.
Universal function approximator
A regression tree is a universal function approximator (see e.g. cstheo
|
Is the sum of two decision trees equivalent to a single decision tree?
Yes, the weighted sum of a regression trees is equivalent to a single (deeper) regression tree.
Universal function approximator
A regression tree is a universal function approximator (see e.g. cstheory). Most research on universal function approximations is done on artifical neural networks with one hidden layer (read this great blog). However, most machine learning algorithms are universal function approximations.
Being a universal function approximator means that any arbitrary function can be approximately represented. Thus, no matter how complex the function gets, a universal function approximation can represent it with any desired precision. In case of a regression tree you can imagine an infinitely deep one. This infinitely deep tree can assign any value to any point in space.
Since a weighted sum of a regression tree is another arbitrary function, there exists another regression tree that represents that function.
An algorithm to create such a tree
Knowing that such a tree exist is great. But we also want a recipe to create them. Such and algorithm would combine two given trees $T_1$ and $T_2$ and create a new one. A solution is copy-pasting $T_2$ at every leaf node of $T1$. The output value of the leaf nodes of the new tree is then the weighted sum of the leaf node of $T1$ (somewhere in the middle of the tree) and the leaf node of $T2$.
The example below shows two simple trees that are added with weight 0.5. Note that one node will never be reached, because there does not exist a number that is smaller than 3 and larger than 5. This indicates that these trees can be improved, but it does not make them invalid.
Why use more complex algorithms
An interesting additional question was raised by @usεr11852 in the comments: why would we use boosting algorithms (or in fact any complex machine learning algorithm) if every function can be modelled with a simple regression tree?
Regression trees can indeed represent any function but that is only one criteria for a machine learning algorithm. One important other property is how well they generalise. Deep regression trees are prone to overfitting, i.e. they do not generalise well. A random forest averages lots of deep trees to prevent this.
|
Is the sum of two decision trees equivalent to a single decision tree?
Yes, the weighted sum of a regression trees is equivalent to a single (deeper) regression tree.
Universal function approximator
A regression tree is a universal function approximator (see e.g. cstheo
|
15,851
|
Intuition about parameter estimation in mixed models (variance parameters vs. conditional modes)
|
Consider a simple linear mixed model, e.g. a random intercept model where we estimate the dependency of $y$ on $x$ in different subjects, and assume that each subject has their own random intercept:$$y = a + bx + c_i + \epsilon.$$ Here intercepts $c_i$ are modeled as coming from a Gaussian distribution $$c_i\sim \mathcal N(0, \tau^2)$$ and random noise is also Gaussian $$\epsilon \sim \mathcal N(0, \sigma^2).$$ In the lme4 syntax this model would be written as y ~ x + (1|subject).
It is instructive to rewrite the above as follows:
\begin{gather}
y \mid c \sim \mathcal N(a + bx + c, \sigma^2) \\
c \sim \mathcal N(0, \tau^2)
\end{gather}
This is a more formal way to specify the same probabilistic model. From this formulation we can directly see that the random effects $c_i$ are not "parameters": they are unobserved random variables. So how can we estimate the variance parameters without knowing the values of $c$?
Note that the first equation above describes the conditional distribution of $y$ given $c$. If we know the distribution of $c$ and of $y\mid c$, then we can work out the unconditional distribution of $y$ by integrating over $c$. You might know it as the Law of total probability. If both distributions are Gaussian, then the resulting unconditional distribution is also Gaussian.
In this case the unconditional distribution is simply $\mathcal N(a + bx, \sigma^2+\tau^2)$, but our observations are not i.i.d. samples from it because there are multiple measurements per subject. In order to proceed, we need to consider the distribution of the whole $n$-dimensional vector $\mathbf y$ of all observations: $$\mathbf y \sim \mathcal N(a+b\mathbf x, \boldsymbol\Sigma)$$ where $\boldsymbol\Sigma=\sigma^2 \mathbf I_n + \tau^2 \mathbf I_N \otimes \mathbf 1_M$ is a block-diagonal matrix composed of $\sigma^2$ and $\tau^2$. You asked for intuition so I want to avoid the math. The important point is that this equation does not have $c$ anymore! This is what one actually fits to the observed data, and that is why one says that $c_i$ are not the parameters of the model.
When the parameters $a$, $b$, $\tau^2$, and $\sigma^2$ are fit, one can work out the conditional distribution of $c_i$ for each $i$. What you see in the mixed model output are the modes of these distributions, aka the conditional modes.
|
Intuition about parameter estimation in mixed models (variance parameters vs. conditional modes)
|
Consider a simple linear mixed model, e.g. a random intercept model where we estimate the dependency of $y$ on $x$ in different subjects, and assume that each subject has their own random intercept:$$
|
Intuition about parameter estimation in mixed models (variance parameters vs. conditional modes)
Consider a simple linear mixed model, e.g. a random intercept model where we estimate the dependency of $y$ on $x$ in different subjects, and assume that each subject has their own random intercept:$$y = a + bx + c_i + \epsilon.$$ Here intercepts $c_i$ are modeled as coming from a Gaussian distribution $$c_i\sim \mathcal N(0, \tau^2)$$ and random noise is also Gaussian $$\epsilon \sim \mathcal N(0, \sigma^2).$$ In the lme4 syntax this model would be written as y ~ x + (1|subject).
It is instructive to rewrite the above as follows:
\begin{gather}
y \mid c \sim \mathcal N(a + bx + c, \sigma^2) \\
c \sim \mathcal N(0, \tau^2)
\end{gather}
This is a more formal way to specify the same probabilistic model. From this formulation we can directly see that the random effects $c_i$ are not "parameters": they are unobserved random variables. So how can we estimate the variance parameters without knowing the values of $c$?
Note that the first equation above describes the conditional distribution of $y$ given $c$. If we know the distribution of $c$ and of $y\mid c$, then we can work out the unconditional distribution of $y$ by integrating over $c$. You might know it as the Law of total probability. If both distributions are Gaussian, then the resulting unconditional distribution is also Gaussian.
In this case the unconditional distribution is simply $\mathcal N(a + bx, \sigma^2+\tau^2)$, but our observations are not i.i.d. samples from it because there are multiple measurements per subject. In order to proceed, we need to consider the distribution of the whole $n$-dimensional vector $\mathbf y$ of all observations: $$\mathbf y \sim \mathcal N(a+b\mathbf x, \boldsymbol\Sigma)$$ where $\boldsymbol\Sigma=\sigma^2 \mathbf I_n + \tau^2 \mathbf I_N \otimes \mathbf 1_M$ is a block-diagonal matrix composed of $\sigma^2$ and $\tau^2$. You asked for intuition so I want to avoid the math. The important point is that this equation does not have $c$ anymore! This is what one actually fits to the observed data, and that is why one says that $c_i$ are not the parameters of the model.
When the parameters $a$, $b$, $\tau^2$, and $\sigma^2$ are fit, one can work out the conditional distribution of $c_i$ for each $i$. What you see in the mixed model output are the modes of these distributions, aka the conditional modes.
|
Intuition about parameter estimation in mixed models (variance parameters vs. conditional modes)
Consider a simple linear mixed model, e.g. a random intercept model where we estimate the dependency of $y$ on $x$ in different subjects, and assume that each subject has their own random intercept:$$
|
15,852
|
Intuition about parameter estimation in mixed models (variance parameters vs. conditional modes)
|
You can easily estimate variance and covariance parameters without relying on random-effects by using fixed-effects (see here for a discussion fixed-effects vs. random-effects; be aware of the fact that there are different definitions of these terms).
Fixed-effects can be easily derived by adding a (binary) indicator variable for each group (or each time period or whatever you are thinking to use as random-effects; this is equivalent to the within transformation). This allows you easily to estimate the fixed-effects (which can be viewed as a parameter).
Fixed-effects assumption does not require you to make an assumption of the distribution of the fixed-effects, you can easily estimate the variance of the fixed-effects (although this extremely noise if the number of observation within each group is small; they minimize the bias for the expense of much larger variance compared to the random-effects because you lose one degree of freedom for each group through adding these indicator variables). You can also estimate covariances between different sets of fixed-effects, or between fixed-effects and other covariates. We have done that for example in a paper called Competitive Balance and Assortative Matching in the German Bundesliga to estimate whether better football players increasingly play for better teams.
Random-effects need a prior assumption about the covariance. In classical random-effects models, you assume that the random-effects are like an error and they are independent of the other covariates (so that you can ignore them and use OLS and get still consistent albeit inefficient estimates for the other parameter if the assumptions of the random-effects model hold true).
Further more technical information is available here. Andrew Gelman has also a lot of more intuitive work about this in his nice book Data analysis using regression and multilevel/hierarchical models
|
Intuition about parameter estimation in mixed models (variance parameters vs. conditional modes)
|
You can easily estimate variance and covariance parameters without relying on random-effects by using fixed-effects (see here for a discussion fixed-effects vs. random-effects; be aware of the fact th
|
Intuition about parameter estimation in mixed models (variance parameters vs. conditional modes)
You can easily estimate variance and covariance parameters without relying on random-effects by using fixed-effects (see here for a discussion fixed-effects vs. random-effects; be aware of the fact that there are different definitions of these terms).
Fixed-effects can be easily derived by adding a (binary) indicator variable for each group (or each time period or whatever you are thinking to use as random-effects; this is equivalent to the within transformation). This allows you easily to estimate the fixed-effects (which can be viewed as a parameter).
Fixed-effects assumption does not require you to make an assumption of the distribution of the fixed-effects, you can easily estimate the variance of the fixed-effects (although this extremely noise if the number of observation within each group is small; they minimize the bias for the expense of much larger variance compared to the random-effects because you lose one degree of freedom for each group through adding these indicator variables). You can also estimate covariances between different sets of fixed-effects, or between fixed-effects and other covariates. We have done that for example in a paper called Competitive Balance and Assortative Matching in the German Bundesliga to estimate whether better football players increasingly play for better teams.
Random-effects need a prior assumption about the covariance. In classical random-effects models, you assume that the random-effects are like an error and they are independent of the other covariates (so that you can ignore them and use OLS and get still consistent albeit inefficient estimates for the other parameter if the assumptions of the random-effects model hold true).
Further more technical information is available here. Andrew Gelman has also a lot of more intuitive work about this in his nice book Data analysis using regression and multilevel/hierarchical models
|
Intuition about parameter estimation in mixed models (variance parameters vs. conditional modes)
You can easily estimate variance and covariance parameters without relying on random-effects by using fixed-effects (see here for a discussion fixed-effects vs. random-effects; be aware of the fact th
|
15,853
|
Neural Network: Why can't I overfit?
|
The reason to try to overfit a data set is in order to understand the model capacity needed in order to represent your dataset.
If our model capacity is too low, you won't be able to represent your data set. When you increase the model capacity until you can fully represent your data set, you know you found the minimal capacity.
The overfitting is not the goal here, it is a by product. Your model probably represent the data set and not necessarily the concept. If you will try this model on a test set, the performance will be probably be lower indicating the overfit.
However, model capacity is not the only reason that a model cannot represent a concept. It is possible that the concept doesn't belong to the family of functions represented by your model - as when your NN is linear and the concept is not. It is possible that the input is not enough to differ between the samples or that your optimization algorithm simply failed to find the proper solution.
In your case, you have only two predictors. If they were binary it was quite likely you couldn't represent two much with them.
Assuming that they are bounded and smooth, you can try to bin them.
If you get high entropy in bins (e.g., a bin with 50%-50% distribution), no logic relaying only on these features will be able to differ them.
|
Neural Network: Why can't I overfit?
|
The reason to try to overfit a data set is in order to understand the model capacity needed in order to represent your dataset.
If our model capacity is too low, you won't be able to represent your da
|
Neural Network: Why can't I overfit?
The reason to try to overfit a data set is in order to understand the model capacity needed in order to represent your dataset.
If our model capacity is too low, you won't be able to represent your data set. When you increase the model capacity until you can fully represent your data set, you know you found the minimal capacity.
The overfitting is not the goal here, it is a by product. Your model probably represent the data set and not necessarily the concept. If you will try this model on a test set, the performance will be probably be lower indicating the overfit.
However, model capacity is not the only reason that a model cannot represent a concept. It is possible that the concept doesn't belong to the family of functions represented by your model - as when your NN is linear and the concept is not. It is possible that the input is not enough to differ between the samples or that your optimization algorithm simply failed to find the proper solution.
In your case, you have only two predictors. If they were binary it was quite likely you couldn't represent two much with them.
Assuming that they are bounded and smooth, you can try to bin them.
If you get high entropy in bins (e.g., a bin with 50%-50% distribution), no logic relaying only on these features will be able to differ them.
|
Neural Network: Why can't I overfit?
The reason to try to overfit a data set is in order to understand the model capacity needed in order to represent your dataset.
If our model capacity is too low, you won't be able to represent your da
|
15,854
|
Neural Network: Why can't I overfit?
|
I had the same problem, i kept zero regularisation and optimal learning rate. but the learning rate decay was set to zero. Once I set the learning rate decay to some value like 0.95 it worked and increase the number of epochs
|
Neural Network: Why can't I overfit?
|
I had the same problem, i kept zero regularisation and optimal learning rate. but the learning rate decay was set to zero. Once I set the learning rate decay to some value like 0.95 it worked and incr
|
Neural Network: Why can't I overfit?
I had the same problem, i kept zero regularisation and optimal learning rate. but the learning rate decay was set to zero. Once I set the learning rate decay to some value like 0.95 it worked and increase the number of epochs
|
Neural Network: Why can't I overfit?
I had the same problem, i kept zero regularisation and optimal learning rate. but the learning rate decay was set to zero. Once I set the learning rate decay to some value like 0.95 it worked and incr
|
15,855
|
How is the confidence interval calculated for the ACF function?
|
In Chatfield's Analysis of Time Series (1980), he gives a number of methods of estimating the autocovariance function, including the jack-knife method. He also notes that it can be shown that the variance of the autocorrelation coefficient at lag k, $r_k$, is normally distributed at the limit, and that $\operatorname{Var}(r_k) \sim 1/N$ (where $N$ is the number of observations). These two observations are pretty much the core of the issue. He doesn't give a derivation for the first observation, but references Kendall & Stuart, The Advanced Theory of Statistics (1966).
Now, we want $\alpha/2$ in both tails, for the two tail test, so we want the $1−\alpha/2$
quantile. Then see that
$(1+1−\alpha)/2=1−\alpha/2 $
and multiply through by the standard deviation (i.e. square root of the variance as found above).
|
How is the confidence interval calculated for the ACF function?
|
In Chatfield's Analysis of Time Series (1980), he gives a number of methods of estimating the autocovariance function, including the jack-knife method. He also notes that it can be shown that the vari
|
How is the confidence interval calculated for the ACF function?
In Chatfield's Analysis of Time Series (1980), he gives a number of methods of estimating the autocovariance function, including the jack-knife method. He also notes that it can be shown that the variance of the autocorrelation coefficient at lag k, $r_k$, is normally distributed at the limit, and that $\operatorname{Var}(r_k) \sim 1/N$ (where $N$ is the number of observations). These two observations are pretty much the core of the issue. He doesn't give a derivation for the first observation, but references Kendall & Stuart, The Advanced Theory of Statistics (1966).
Now, we want $\alpha/2$ in both tails, for the two tail test, so we want the $1−\alpha/2$
quantile. Then see that
$(1+1−\alpha)/2=1−\alpha/2 $
and multiply through by the standard deviation (i.e. square root of the variance as found above).
|
How is the confidence interval calculated for the ACF function?
In Chatfield's Analysis of Time Series (1980), he gives a number of methods of estimating the autocovariance function, including the jack-knife method. He also notes that it can be shown that the vari
|
15,856
|
understanding of p-value in multiple linear regression
|
This is incorrect for a couple reasons:
The model "without" X4 will not necessarily have the same coefficient estimates for the other values. Fit the reduced model and see for yourself.
The statistical test for the coefficient does not concern the "mean" values of Y obtained from 2 predictions. The predicted $Y$ will always have the same grand mean, thus have a p-value from the t-test equal to 0.5. The same holds for the residuals. Your t-test had the wrong value per the point above.
The statistical test which is conducted for the statistical significance of the coefficient is a one sample t-test. This is confusing since we do not have a "sample" of multiple coefficients for X4, but we have an estimate of the distributional properties of such a sample using the central limit theorem. The mean and standard error describe the location and shape of such a limiting distribution. If you take the column "Est" and divide by "SE" and compare to a standard normal distribution, this gives you the p-values in the 4th column.
A fourth point: a criticism of minitab's help page. Such a help file could not, in a paragraph, summarize years of statistical training, so I need not contend with the whole thing. But, to say that a "predictor" is "an important contribution" is vague and probably incorrect. The rationale for choosing which variables to include in a multivariate model is subtle and relies on scientific reasoning and not statistical inference.
|
understanding of p-value in multiple linear regression
|
This is incorrect for a couple reasons:
The model "without" X4 will not necessarily have the same coefficient estimates for the other values. Fit the reduced model and see for yourself.
The statistic
|
understanding of p-value in multiple linear regression
This is incorrect for a couple reasons:
The model "without" X4 will not necessarily have the same coefficient estimates for the other values. Fit the reduced model and see for yourself.
The statistical test for the coefficient does not concern the "mean" values of Y obtained from 2 predictions. The predicted $Y$ will always have the same grand mean, thus have a p-value from the t-test equal to 0.5. The same holds for the residuals. Your t-test had the wrong value per the point above.
The statistical test which is conducted for the statistical significance of the coefficient is a one sample t-test. This is confusing since we do not have a "sample" of multiple coefficients for X4, but we have an estimate of the distributional properties of such a sample using the central limit theorem. The mean and standard error describe the location and shape of such a limiting distribution. If you take the column "Est" and divide by "SE" and compare to a standard normal distribution, this gives you the p-values in the 4th column.
A fourth point: a criticism of minitab's help page. Such a help file could not, in a paragraph, summarize years of statistical training, so I need not contend with the whole thing. But, to say that a "predictor" is "an important contribution" is vague and probably incorrect. The rationale for choosing which variables to include in a multivariate model is subtle and relies on scientific reasoning and not statistical inference.
|
understanding of p-value in multiple linear regression
This is incorrect for a couple reasons:
The model "without" X4 will not necessarily have the same coefficient estimates for the other values. Fit the reduced model and see for yourself.
The statistic
|
15,857
|
understanding of p-value in multiple linear regression
|
Your initial interpretation of p-values appears correct, which is that only the intercept has a coefficient that's significantly different from 0. You'll notice that the estimate of the coefficient for x4 is still quite high, but there's enough error that it's not significantly different from 0.
Your paired t test of y1 and y2 suggests that the models are different from one another. That's to be expected, in one model you included a large but imprecise coefficient that's contributing quite a bit to your model. There's no reason to think that the p-value of these models being different from one another should be the same as the p-value of the coefficient of x4 being different from 0.
|
understanding of p-value in multiple linear regression
|
Your initial interpretation of p-values appears correct, which is that only the intercept has a coefficient that's significantly different from 0. You'll notice that the estimate of the coefficient fo
|
understanding of p-value in multiple linear regression
Your initial interpretation of p-values appears correct, which is that only the intercept has a coefficient that's significantly different from 0. You'll notice that the estimate of the coefficient for x4 is still quite high, but there's enough error that it's not significantly different from 0.
Your paired t test of y1 and y2 suggests that the models are different from one another. That's to be expected, in one model you included a large but imprecise coefficient that's contributing quite a bit to your model. There's no reason to think that the p-value of these models being different from one another should be the same as the p-value of the coefficient of x4 being different from 0.
|
understanding of p-value in multiple linear regression
Your initial interpretation of p-values appears correct, which is that only the intercept has a coefficient that's significantly different from 0. You'll notice that the estimate of the coefficient fo
|
15,858
|
Bayesian estimation of $N$ of a binomial distribution
|
Well, since you got your code to work, it looks like this answer is a bit too late. But I've already written the code, so...
For what it's worth, this is the same* model fit with rstan. It is estimated in 11 seconds on my consumer laptop, achieving a higher effective sample size for our parameters of interest $(N, \theta)$ in fewer iterations.
raftery.model <- "
data{
int I;
int y[I];
}
parameters{
real<lower=max(y)> N;
simplex[2] theta;
}
transformed parameters{
}
model{
vector[I] Pr_y;
for(i in 1:I){
Pr_y[i] <- binomial_coefficient_log(N, y[i])
+multiply_log(y[i], theta[1])
+multiply_log((N-y[i]), theta[2]);
}
increment_log_prob(sum(Pr_y));
increment_log_prob(-log(N));
}
"
raft.data <- list(y=c(53,57,66,67,72), I=5)
system.time(fit.test <- stan(model_code=raftery.model, data=raft.data,iter=10))
system.time(fit <- stan(fit=fit.test, data=raft.data,iter=10000,chains=5))
Note that I cast theta as a 2-simplex. This is just for numerical stability. The quantity of interest is theta[1]; obviously theta[2] is superfluous information.
*As you can see, the posterior summary is virtually identical, and promoting $N$ to a real quantity does not appear to have a substantive impact on our inferences.
The 97.5% quantile for $N$ is 50% larger for my model, but I think that's because stan's sampler is better at exploring the full range of the posterior than a simple random walk, so it can more easily make it into the tails. I may be wrong, though.
mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat
N 1078.75 256.72 15159.79 94.44 148.28 230.61 461.63 4575.49 3487 1
theta[1] 0.29 0.00 0.19 0.01 0.14 0.27 0.42 0.67 2519 1
theta[2] 0.71 0.00 0.19 0.33 0.58 0.73 0.86 0.99 2519 1
lp__ -19.88 0.02 1.11 -22.89 -20.31 -19.54 -19.09 -18.82 3339 1
Taking the values of $N, \theta$ generated from stan, I use these to draw posterior predictive values $\tilde{y}$. We should not be surprised that mean of the posterior predictions $\tilde{y}$ is very near the mean of the sample data!
N.samples <- round(extract(fit, "N")[[1]])
theta.samples <- extract(fit, "theta")[[1]]
y_pred <- rbinom(50000, size=N.samples, prob=theta.samples[,1])
mean(y_pred)
Min. 1st Qu. Median Mean 3rd Qu. Max.
32.00 58.00 63.00 63.04 68.00 102.00
To check whether the rstan sampler is a problem or not, I computed the posterior over a grid. We can see that the posterior is banana-shaped; this kind of posterior can be problematic for euclidian metric HMC. But let's check the numerical results. (The severity of the banana shape is actually suppressed here since $N$ is on the log scale.) If you think about the banana shape for a minute, you'll realize that it must lie on the line $\bar{y}=\theta N$.
The code below may confirm that our results from stan make sense.
theta <- seq(0+1e-10,1-1e-10, len=1e2)
N <- round(seq(72, 5e5, len=1e5)); N[2]-N[1]
grid <- expand.grid(N,theta)
y <- c(53,57,66,67,72)
raftery.prob <- function(x, z=y){
N <- x[1]
theta <- x[2]
exp(sum(dbinom(z, size=N, prob=theta, log=T)))/N
}
post <- matrix(apply(grid, 1, raftery.prob), nrow=length(N), ncol=length(theta),byrow=F)
approx(y=N, x=cumsum(rowSums(post))/sum(rowSums(post)), xout=0.975)
$x
[1] 0.975
$y
[1] 3236.665
Hm. This is not quite what I would have expected. Grid evaluation for the 97.5% quantile is closer to the JAGS results than to the rstan results. At the same time, I don't believe that the grid results should be taken as gospel because grid evaluation is making several rather coarse simplifications: grid resolution isn't too fine on the one hand, while on the other, we are (falsely) asserting that total probability in the grid must be 1, since we must draw a boundary (and finite grid points) for the problem to be computable (I'm still waiting on infinite RAM). In truth, our model has positive probability over $(0,1)\times\left\{N|N\in\mathbb{Z}\land N\ge72)\right\}$. But perhaps something more subtle is at play here.
|
Bayesian estimation of $N$ of a binomial distribution
|
Well, since you got your code to work, it looks like this answer is a bit too late. But I've already written the code, so...
For what it's worth, this is the same* model fit with rstan. It is estimate
|
Bayesian estimation of $N$ of a binomial distribution
Well, since you got your code to work, it looks like this answer is a bit too late. But I've already written the code, so...
For what it's worth, this is the same* model fit with rstan. It is estimated in 11 seconds on my consumer laptop, achieving a higher effective sample size for our parameters of interest $(N, \theta)$ in fewer iterations.
raftery.model <- "
data{
int I;
int y[I];
}
parameters{
real<lower=max(y)> N;
simplex[2] theta;
}
transformed parameters{
}
model{
vector[I] Pr_y;
for(i in 1:I){
Pr_y[i] <- binomial_coefficient_log(N, y[i])
+multiply_log(y[i], theta[1])
+multiply_log((N-y[i]), theta[2]);
}
increment_log_prob(sum(Pr_y));
increment_log_prob(-log(N));
}
"
raft.data <- list(y=c(53,57,66,67,72), I=5)
system.time(fit.test <- stan(model_code=raftery.model, data=raft.data,iter=10))
system.time(fit <- stan(fit=fit.test, data=raft.data,iter=10000,chains=5))
Note that I cast theta as a 2-simplex. This is just for numerical stability. The quantity of interest is theta[1]; obviously theta[2] is superfluous information.
*As you can see, the posterior summary is virtually identical, and promoting $N$ to a real quantity does not appear to have a substantive impact on our inferences.
The 97.5% quantile for $N$ is 50% larger for my model, but I think that's because stan's sampler is better at exploring the full range of the posterior than a simple random walk, so it can more easily make it into the tails. I may be wrong, though.
mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat
N 1078.75 256.72 15159.79 94.44 148.28 230.61 461.63 4575.49 3487 1
theta[1] 0.29 0.00 0.19 0.01 0.14 0.27 0.42 0.67 2519 1
theta[2] 0.71 0.00 0.19 0.33 0.58 0.73 0.86 0.99 2519 1
lp__ -19.88 0.02 1.11 -22.89 -20.31 -19.54 -19.09 -18.82 3339 1
Taking the values of $N, \theta$ generated from stan, I use these to draw posterior predictive values $\tilde{y}$. We should not be surprised that mean of the posterior predictions $\tilde{y}$ is very near the mean of the sample data!
N.samples <- round(extract(fit, "N")[[1]])
theta.samples <- extract(fit, "theta")[[1]]
y_pred <- rbinom(50000, size=N.samples, prob=theta.samples[,1])
mean(y_pred)
Min. 1st Qu. Median Mean 3rd Qu. Max.
32.00 58.00 63.00 63.04 68.00 102.00
To check whether the rstan sampler is a problem or not, I computed the posterior over a grid. We can see that the posterior is banana-shaped; this kind of posterior can be problematic for euclidian metric HMC. But let's check the numerical results. (The severity of the banana shape is actually suppressed here since $N$ is on the log scale.) If you think about the banana shape for a minute, you'll realize that it must lie on the line $\bar{y}=\theta N$.
The code below may confirm that our results from stan make sense.
theta <- seq(0+1e-10,1-1e-10, len=1e2)
N <- round(seq(72, 5e5, len=1e5)); N[2]-N[1]
grid <- expand.grid(N,theta)
y <- c(53,57,66,67,72)
raftery.prob <- function(x, z=y){
N <- x[1]
theta <- x[2]
exp(sum(dbinom(z, size=N, prob=theta, log=T)))/N
}
post <- matrix(apply(grid, 1, raftery.prob), nrow=length(N), ncol=length(theta),byrow=F)
approx(y=N, x=cumsum(rowSums(post))/sum(rowSums(post)), xout=0.975)
$x
[1] 0.975
$y
[1] 3236.665
Hm. This is not quite what I would have expected. Grid evaluation for the 97.5% quantile is closer to the JAGS results than to the rstan results. At the same time, I don't believe that the grid results should be taken as gospel because grid evaluation is making several rather coarse simplifications: grid resolution isn't too fine on the one hand, while on the other, we are (falsely) asserting that total probability in the grid must be 1, since we must draw a boundary (and finite grid points) for the problem to be computable (I'm still waiting on infinite RAM). In truth, our model has positive probability over $(0,1)\times\left\{N|N\in\mathbb{Z}\land N\ge72)\right\}$. But perhaps something more subtle is at play here.
|
Bayesian estimation of $N$ of a binomial distribution
Well, since you got your code to work, it looks like this answer is a bit too late. But I've already written the code, so...
For what it's worth, this is the same* model fit with rstan. It is estimate
|
15,859
|
Bayesian estimation of $N$ of a binomial distribution
|
Thanks again to @StéphaneLaurent and @user777 for their valuable input in the comments. After some tweaking of the prior for $\lambda$ I can now replicate the results from the paper of Raftery (1988).
Here is my analysis script and results using JAGS and R:
#===============================================================================================================
# Load packages
#===============================================================================================================
sapply(c("ggplot2"
, "rjags"
, "R2jags"
, "hdrcde"
, "runjags"
, "mcmcplots"
, "KernSmooth"), library, character.only = TRUE)
#===============================================================================================================
# Model file
#===============================================================================================================
cat("
model {
# Likelihood
for (i in 1:N) {
x[i] ~ dbin(theta, n)
}
# Prior
n ~ dpois(mu)
lambda ~ dgamma(0.005, 0.005)
# lambda ~ dunif(0, 1000)
mu <- lambda/theta
theta ~ dunif(0, 1)
}
", file="jags_model_binomial.txt")
#===============================================================================================================
# Data
#===============================================================================================================
data.list <- list(x = c(53, 57, 66, 67, 72, NA), N = 6) # Waterbuck example from Raftery (1988)
#===============================================================================================================
# Inits
#===============================================================================================================
jags.inits <- function() {
list(
n = sample(max(data.list$x, na.rm = TRUE):1000, size = 1)
, theta = runif(1, 0, 1)
, lambda = runif(1, 1, 10)
# , cauchy = runif(1, 1, 1000)
# , mu = runif(1, 0, 5)
)
}
#===============================================================================================================
# Run the chains
#===============================================================================================================
# Parameters to store
params <- c("n"
, "theta"
, "lambda"
, "mu"
, paste("x[", which(is.na(data.list[["x"]])), "]", sep = "")
)
# MCMC settings
niter <- 500000 # number of iterations
nburn <- 20000 # number of iterations to discard (the burn-in-period)
nchains <- 5 # number of chains
# Run JAGS
out <- jags(
data = data.list
, parameters.to.save = params
, model.file = "jags_model_binomial.txt"
, n.chains = nchains
, n.iter = niter
, n.burnin = nburn
, n.thin = 50
, inits = jags.inits
, progress.bar = "text")
Computation took around 98 seconds on my desktop pc.
#===============================================================================================================
# Inspect results
#===============================================================================================================
print(out
, digits = 2
, intervals = c(0.025, 0.1, 0.25, 0.5, 0.75, 0.9, 0.975))
The results are:
Inference for Bugs model at "jags_model_binomial.txt", fit using jags,
5 chains, each with 5e+05 iterations (first 20000 discarded), n.thin = 50
n.sims = 48000 iterations saved
mu.vect sd.vect 2.5% 10% 25% 50% 75% 90% 97.5% Rhat n.eff
lambda 62.90 5.18 53.09 56.47 59.45 62.74 66.19 69.49 73.49 1 48000
mu 521.28 968.41 92.31 113.02 148.00 232.87 467.10 1058.17 3014.82 1 1600
n 521.73 968.54 95.00 114.00 148.00 233.00 467.00 1060.10 3028.00 1 1600
theta 0.29 0.18 0.02 0.06 0.13 0.27 0.42 0.55 0.66 1 1600
x[6] 63.03 7.33 49.00 54.00 58.00 63.00 68.00 72.00 78.00 1 36000
deviance 34.88 1.53 33.63 33.70 33.85 34.34 35.34 36.81 39.07 1 48000
The posterior mean of $N$ is $522$ and the posterior median is $233$. I calculated the posterior mode of $N$ on the log-scale and back-transformed the estimate:
jagsfit.mcmc <- as.mcmc(out)
jagsfit.mcmc <- combine.mcmc(jagsfit.mcmc)
hpd.80 <- hdr.den(log(as.vector(jagsfit.mcmc[, "n"])), prob = c(80), den = bkde(log(as.vector(jagsfit.mcmc[, "n"])), gridsize = 10000))
exp(hpd.80$mode)
[1] 149.8161
And the 80%-HPD of $N$ is:
(hpd.ints <- HPDinterval(jagsfit.mcmc, prob = c(0.8)))
lower upper
deviance 33.61011007 35.677810
lambda 56.08842502 69.089507
mu 72.42307587 580.027182
n 78.00000000 578.000000
theta 0.01026193 0.465714
x[6] 53.00000000 71.000000
The posterior mode for $N$ is $150$ and the 80%-HPD is $(78; 578)$ which is very close to the limits given in the paper which are $(80; 598)$.
|
Bayesian estimation of $N$ of a binomial distribution
|
Thanks again to @StéphaneLaurent and @user777 for their valuable input in the comments. After some tweaking of the prior for $\lambda$ I can now replicate the results from the paper of Raftery (1988).
|
Bayesian estimation of $N$ of a binomial distribution
Thanks again to @StéphaneLaurent and @user777 for their valuable input in the comments. After some tweaking of the prior for $\lambda$ I can now replicate the results from the paper of Raftery (1988).
Here is my analysis script and results using JAGS and R:
#===============================================================================================================
# Load packages
#===============================================================================================================
sapply(c("ggplot2"
, "rjags"
, "R2jags"
, "hdrcde"
, "runjags"
, "mcmcplots"
, "KernSmooth"), library, character.only = TRUE)
#===============================================================================================================
# Model file
#===============================================================================================================
cat("
model {
# Likelihood
for (i in 1:N) {
x[i] ~ dbin(theta, n)
}
# Prior
n ~ dpois(mu)
lambda ~ dgamma(0.005, 0.005)
# lambda ~ dunif(0, 1000)
mu <- lambda/theta
theta ~ dunif(0, 1)
}
", file="jags_model_binomial.txt")
#===============================================================================================================
# Data
#===============================================================================================================
data.list <- list(x = c(53, 57, 66, 67, 72, NA), N = 6) # Waterbuck example from Raftery (1988)
#===============================================================================================================
# Inits
#===============================================================================================================
jags.inits <- function() {
list(
n = sample(max(data.list$x, na.rm = TRUE):1000, size = 1)
, theta = runif(1, 0, 1)
, lambda = runif(1, 1, 10)
# , cauchy = runif(1, 1, 1000)
# , mu = runif(1, 0, 5)
)
}
#===============================================================================================================
# Run the chains
#===============================================================================================================
# Parameters to store
params <- c("n"
, "theta"
, "lambda"
, "mu"
, paste("x[", which(is.na(data.list[["x"]])), "]", sep = "")
)
# MCMC settings
niter <- 500000 # number of iterations
nburn <- 20000 # number of iterations to discard (the burn-in-period)
nchains <- 5 # number of chains
# Run JAGS
out <- jags(
data = data.list
, parameters.to.save = params
, model.file = "jags_model_binomial.txt"
, n.chains = nchains
, n.iter = niter
, n.burnin = nburn
, n.thin = 50
, inits = jags.inits
, progress.bar = "text")
Computation took around 98 seconds on my desktop pc.
#===============================================================================================================
# Inspect results
#===============================================================================================================
print(out
, digits = 2
, intervals = c(0.025, 0.1, 0.25, 0.5, 0.75, 0.9, 0.975))
The results are:
Inference for Bugs model at "jags_model_binomial.txt", fit using jags,
5 chains, each with 5e+05 iterations (first 20000 discarded), n.thin = 50
n.sims = 48000 iterations saved
mu.vect sd.vect 2.5% 10% 25% 50% 75% 90% 97.5% Rhat n.eff
lambda 62.90 5.18 53.09 56.47 59.45 62.74 66.19 69.49 73.49 1 48000
mu 521.28 968.41 92.31 113.02 148.00 232.87 467.10 1058.17 3014.82 1 1600
n 521.73 968.54 95.00 114.00 148.00 233.00 467.00 1060.10 3028.00 1 1600
theta 0.29 0.18 0.02 0.06 0.13 0.27 0.42 0.55 0.66 1 1600
x[6] 63.03 7.33 49.00 54.00 58.00 63.00 68.00 72.00 78.00 1 36000
deviance 34.88 1.53 33.63 33.70 33.85 34.34 35.34 36.81 39.07 1 48000
The posterior mean of $N$ is $522$ and the posterior median is $233$. I calculated the posterior mode of $N$ on the log-scale and back-transformed the estimate:
jagsfit.mcmc <- as.mcmc(out)
jagsfit.mcmc <- combine.mcmc(jagsfit.mcmc)
hpd.80 <- hdr.den(log(as.vector(jagsfit.mcmc[, "n"])), prob = c(80), den = bkde(log(as.vector(jagsfit.mcmc[, "n"])), gridsize = 10000))
exp(hpd.80$mode)
[1] 149.8161
And the 80%-HPD of $N$ is:
(hpd.ints <- HPDinterval(jagsfit.mcmc, prob = c(0.8)))
lower upper
deviance 33.61011007 35.677810
lambda 56.08842502 69.089507
mu 72.42307587 580.027182
n 78.00000000 578.000000
theta 0.01026193 0.465714
x[6] 53.00000000 71.000000
The posterior mode for $N$ is $150$ and the 80%-HPD is $(78; 578)$ which is very close to the limits given in the paper which are $(80; 598)$.
|
Bayesian estimation of $N$ of a binomial distribution
Thanks again to @StéphaneLaurent and @user777 for their valuable input in the comments. After some tweaking of the prior for $\lambda$ I can now replicate the results from the paper of Raftery (1988).
|
15,860
|
What do you do when there's no elbow point for kmeans clustering
|
Wrong method?
Maybe you are using the wrong algorithm for your problem.
Wrong preprocessing?
K-means is highly sensitive to preprocessing. If one attribute is on a much larger scale than the others, it will dominate the output. Your output will then be effectively 1-dimensional
Visualize results
Whatever you do, you need to validate your results by something other than starting at a number such as SSQ. Instead, consider visualization.
Visualization may also tell you that maybe there is only a single cluster in your data.
|
What do you do when there's no elbow point for kmeans clustering
|
Wrong method?
Maybe you are using the wrong algorithm for your problem.
Wrong preprocessing?
K-means is highly sensitive to preprocessing. If one attribute is on a much larger scale than the others, i
|
What do you do when there's no elbow point for kmeans clustering
Wrong method?
Maybe you are using the wrong algorithm for your problem.
Wrong preprocessing?
K-means is highly sensitive to preprocessing. If one attribute is on a much larger scale than the others, it will dominate the output. Your output will then be effectively 1-dimensional
Visualize results
Whatever you do, you need to validate your results by something other than starting at a number such as SSQ. Instead, consider visualization.
Visualization may also tell you that maybe there is only a single cluster in your data.
|
What do you do when there's no elbow point for kmeans clustering
Wrong method?
Maybe you are using the wrong algorithm for your problem.
Wrong preprocessing?
K-means is highly sensitive to preprocessing. If one attribute is on a much larger scale than the others, i
|
15,861
|
What do you do when there's no elbow point for kmeans clustering
|
One way is to manually inspect the members in your clusters for a specific k to see if the groupings make sense (are they distinguishable?). This can be done via contingency tables and conditional means. Do this for a variety of k's and you can determine what value is appropriate.
A less subjective way is to use the Silhouette Value:
https://stackoverflow.com/questions/18285434/how-do-i-choose-k-when-using-k-means-clustering-with-silhouette-function
This can be computed with your favorite software package. From the link:
This method just compares the intra-group similarity to closest group similarity. If any data member average distance to other members of the same cluster is higher than average distance to some other cluster members, then this value is negative and clustering is not successful. On the other hand, silhuette values close to 1 indicates a successful clustering operation. 0.5 is not an exact measure for clustering.
|
What do you do when there's no elbow point for kmeans clustering
|
One way is to manually inspect the members in your clusters for a specific k to see if the groupings make sense (are they distinguishable?). This can be done via contingency tables and conditional me
|
What do you do when there's no elbow point for kmeans clustering
One way is to manually inspect the members in your clusters for a specific k to see if the groupings make sense (are they distinguishable?). This can be done via contingency tables and conditional means. Do this for a variety of k's and you can determine what value is appropriate.
A less subjective way is to use the Silhouette Value:
https://stackoverflow.com/questions/18285434/how-do-i-choose-k-when-using-k-means-clustering-with-silhouette-function
This can be computed with your favorite software package. From the link:
This method just compares the intra-group similarity to closest group similarity. If any data member average distance to other members of the same cluster is higher than average distance to some other cluster members, then this value is negative and clustering is not successful. On the other hand, silhuette values close to 1 indicates a successful clustering operation. 0.5 is not an exact measure for clustering.
|
What do you do when there's no elbow point for kmeans clustering
One way is to manually inspect the members in your clusters for a specific k to see if the groupings make sense (are they distinguishable?). This can be done via contingency tables and conditional me
|
15,862
|
What do you do when there's no elbow point for kmeans clustering
|
No elbow in for K-means does not mean that there are no clusters in the data;
No elbow means that the algorithm used cannot separate clusters;
(think about K-means for concentric circles, vs DBSCAN)
Generally, you may consider:
tune your algorithm;
use another algorithm;
do data preprocessing.
|
What do you do when there's no elbow point for kmeans clustering
|
No elbow in for K-means does not mean that there are no clusters in the data;
No elbow means that the algorithm used cannot separate clusters;
(think about K-means for concentric circles, vs DBSCAN)
|
What do you do when there's no elbow point for kmeans clustering
No elbow in for K-means does not mean that there are no clusters in the data;
No elbow means that the algorithm used cannot separate clusters;
(think about K-means for concentric circles, vs DBSCAN)
Generally, you may consider:
tune your algorithm;
use another algorithm;
do data preprocessing.
|
What do you do when there's no elbow point for kmeans clustering
No elbow in for K-means does not mean that there are no clusters in the data;
No elbow means that the algorithm used cannot separate clusters;
(think about K-means for concentric circles, vs DBSCAN)
|
15,863
|
What do you do when there's no elbow point for kmeans clustering
|
We can use the NbClust package to find the most optimal value of k.
It provides 30 indices for determining the number of clusters and proposes the best result.
NbClust(data=df, distance ="euclidean", min.nc=2, max.nc=15, method ="kmeans", index="all")
|
What do you do when there's no elbow point for kmeans clustering
|
We can use the NbClust package to find the most optimal value of k.
It provides 30 indices for determining the number of clusters and proposes the best result.
NbClust(data=df, distance ="euclidean",
|
What do you do when there's no elbow point for kmeans clustering
We can use the NbClust package to find the most optimal value of k.
It provides 30 indices for determining the number of clusters and proposes the best result.
NbClust(data=df, distance ="euclidean", min.nc=2, max.nc=15, method ="kmeans", index="all")
|
What do you do when there's no elbow point for kmeans clustering
We can use the NbClust package to find the most optimal value of k.
It provides 30 indices for determining the number of clusters and proposes the best result.
NbClust(data=df, distance ="euclidean",
|
15,864
|
Is there a style guide for statistical graphs intended for presentations?
|
On color
Generally, use dark background in a dark room; light background in a well-lit room or room with plenty of natural light. Once you’ve picked dark background, then use light color for fonts and graphical components; vice versa for light background.
I found it useful to actually project a color wheel onto the screen and check if there is any segment that is not distinguishable. I personally found yellow-red-brown spectrum usually fails, and I tried to avoid using them to show gradient data.
If a graph can do the job with just black and white, then keep it black and white. Blue themes are deemed the most color-blind-friendly, while red-green combination is a usual culprit to avoid. Brewer has made a website for choosing map colors. There you can also pick themes that are colorblind safe and, more importantly, photocopy-able. Color charts are doomed if they lose information after photocopying.
Line/shape and font
Whenever I have a chance, I’ll go to the room that I’ll be presenting and use the beamer there to project some reference slides (see the attached image). You can make one for fonts, one for lines with different thickness, etc. My general impression is that sans serif works better when the on-screen resolution is low.
Format
I use .png for simpler graph and illustration and .tif for maps. I have not encountered any problem so far. I like that these two formats can tolerate a good degree of manual enlargement. In case if the audience really wants to see the picture up close, I can still do that without it turning pixelated.
Print
For very complicated graphs, I also brought print outs. A trend that I have been seeing in lectures is that more and more attendees are loading up my presentation on their computer while listening to me. The benefits are that they can see the graphs up close, and they can also take notes directly on their computer. So, I would also recommend at the beginning and the end, provide a link to the crowd in case if they'd like to download your work.
References
Since the question isn't about how to make good graphs, I'll save all those Clevenland and Tufte materials. Although, I have to say that Tufte's principles on data-ink ratio have been very helpful, as long as you know when to stop following his advices.
For online presentation, I'd recommend books and website by Garr Reynolds. His book Presentation Zen is pretty useful.
|
Is there a style guide for statistical graphs intended for presentations?
|
On color
Generally, use dark background in a dark room; light background in a well-lit room or room with plenty of natural light. Once you’ve picked dark background, then use light color for fonts and
|
Is there a style guide for statistical graphs intended for presentations?
On color
Generally, use dark background in a dark room; light background in a well-lit room or room with plenty of natural light. Once you’ve picked dark background, then use light color for fonts and graphical components; vice versa for light background.
I found it useful to actually project a color wheel onto the screen and check if there is any segment that is not distinguishable. I personally found yellow-red-brown spectrum usually fails, and I tried to avoid using them to show gradient data.
If a graph can do the job with just black and white, then keep it black and white. Blue themes are deemed the most color-blind-friendly, while red-green combination is a usual culprit to avoid. Brewer has made a website for choosing map colors. There you can also pick themes that are colorblind safe and, more importantly, photocopy-able. Color charts are doomed if they lose information after photocopying.
Line/shape and font
Whenever I have a chance, I’ll go to the room that I’ll be presenting and use the beamer there to project some reference slides (see the attached image). You can make one for fonts, one for lines with different thickness, etc. My general impression is that sans serif works better when the on-screen resolution is low.
Format
I use .png for simpler graph and illustration and .tif for maps. I have not encountered any problem so far. I like that these two formats can tolerate a good degree of manual enlargement. In case if the audience really wants to see the picture up close, I can still do that without it turning pixelated.
Print
For very complicated graphs, I also brought print outs. A trend that I have been seeing in lectures is that more and more attendees are loading up my presentation on their computer while listening to me. The benefits are that they can see the graphs up close, and they can also take notes directly on their computer. So, I would also recommend at the beginning and the end, provide a link to the crowd in case if they'd like to download your work.
References
Since the question isn't about how to make good graphs, I'll save all those Clevenland and Tufte materials. Although, I have to say that Tufte's principles on data-ink ratio have been very helpful, as long as you know when to stop following his advices.
For online presentation, I'd recommend books and website by Garr Reynolds. His book Presentation Zen is pretty useful.
|
Is there a style guide for statistical graphs intended for presentations?
On color
Generally, use dark background in a dark room; light background in a well-lit room or room with plenty of natural light. Once you’ve picked dark background, then use light color for fonts and
|
15,865
|
Is there a style guide for statistical graphs intended for presentations?
|
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
A couple more guides
Sunlight labs - http://design.sunlightlabs.com/projects/Sunlight-StyleGuide-DataViz.pdf
NPR - https://github.com/propublica/guides/blob/master/news-apps.md
And one more
UK Government Digital Service - https://www.gov.uk/service-manual/user-centred-design/data-visualisation.html
|
Is there a style guide for statistical graphs intended for presentations?
|
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
|
Is there a style guide for statistical graphs intended for presentations?
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
A couple more guides
Sunlight labs - http://design.sunlightlabs.com/projects/Sunlight-StyleGuide-DataViz.pdf
NPR - https://github.com/propublica/guides/blob/master/news-apps.md
And one more
UK Government Digital Service - https://www.gov.uk/service-manual/user-centred-design/data-visualisation.html
|
Is there a style guide for statistical graphs intended for presentations?
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
|
15,866
|
Expected value of the log-determinant of a Wishart matrix
|
As I was getting ready to post this, I was able to answer my own question. In accordance with general StackExchange etiquette I've decided to post it anyways in hopes that someone else who runs into this problem might find this in the future, possibly after running into the same issues with sources that I did. I've decided to answer it immediately so that no one wastes time on it since the solution isn't interesting.
$(\dagger)$ is wrong, because the paper linked to in the discussion was using a different parametrization of the Wishart; this wasn't noticed by the discussants. What we should actually have is
$$
\frac{|\Lambda|}{|\Psi|} \sim \chi^2_\nu \chi^2_{\nu - 1} \cdots\chi^2_{\nu - D + 1}. \qquad (\dagger\dagger)
$$
After this correction, the two formulas lead to the same answer.
At any rate, I think think $(\dagger\dagger)$ is an interesting relationship.
EDIT:
Following probabilisticlogic's advice we can write $\Lambda \stackrel d = \Psi^{1/2} L L^T \Psi^{1/2}$ where lower triangular $L$ has $N(0, 1)$ elements off the diagonal and $\sqrt{\chi^2_{\nu - i + 1}}, (i = 1, ..., D)$ elements on the diagonal. Taking the determinent of both sides gives $(\dagger\dagger)$ immediately.
|
Expected value of the log-determinant of a Wishart matrix
|
As I was getting ready to post this, I was able to answer my own question. In accordance with general StackExchange etiquette I've decided to post it anyways in hopes that someone else who runs into t
|
Expected value of the log-determinant of a Wishart matrix
As I was getting ready to post this, I was able to answer my own question. In accordance with general StackExchange etiquette I've decided to post it anyways in hopes that someone else who runs into this problem might find this in the future, possibly after running into the same issues with sources that I did. I've decided to answer it immediately so that no one wastes time on it since the solution isn't interesting.
$(\dagger)$ is wrong, because the paper linked to in the discussion was using a different parametrization of the Wishart; this wasn't noticed by the discussants. What we should actually have is
$$
\frac{|\Lambda|}{|\Psi|} \sim \chi^2_\nu \chi^2_{\nu - 1} \cdots\chi^2_{\nu - D + 1}. \qquad (\dagger\dagger)
$$
After this correction, the two formulas lead to the same answer.
At any rate, I think think $(\dagger\dagger)$ is an interesting relationship.
EDIT:
Following probabilisticlogic's advice we can write $\Lambda \stackrel d = \Psi^{1/2} L L^T \Psi^{1/2}$ where lower triangular $L$ has $N(0, 1)$ elements off the diagonal and $\sqrt{\chi^2_{\nu - i + 1}}, (i = 1, ..., D)$ elements on the diagonal. Taking the determinent of both sides gives $(\dagger\dagger)$ immediately.
|
Expected value of the log-determinant of a Wishart matrix
As I was getting ready to post this, I was able to answer my own question. In accordance with general StackExchange etiquette I've decided to post it anyways in hopes that someone else who runs into t
|
15,867
|
How to detect a significant change in time series data due to a "policy" change?
|
The Box-Tiao paper referred to by Jason was based on a known law change. The question here
is how to detect the point in time. The answer is to use the Tsay procedure to detect Interventions be they Pulses, level Shifts , Seasonal Pulses and/or local time trends.
|
How to detect a significant change in time series data due to a "policy" change?
|
The Box-Tiao paper referred to by Jason was based on a known law change. The question here
is how to detect the point in time. The answer is to use the Tsay procedure to detect Interventions be they
|
How to detect a significant change in time series data due to a "policy" change?
The Box-Tiao paper referred to by Jason was based on a known law change. The question here
is how to detect the point in time. The answer is to use the Tsay procedure to detect Interventions be they Pulses, level Shifts , Seasonal Pulses and/or local time trends.
|
How to detect a significant change in time series data due to a "policy" change?
The Box-Tiao paper referred to by Jason was based on a known law change. The question here
is how to detect the point in time. The answer is to use the Tsay procedure to detect Interventions be they
|
15,868
|
How to detect a significant change in time series data due to a "policy" change?
|
Josh said:
josh: From the OP "What is the appropriate test to determine if the
time series has increase or decreased based on the data? ". This I
believe asks for a determination if the mean of the residuals has
shifted not the parameters of some ARIMA Model. In my opinion you are
recommending the wrong software/solution procedure but that's just my
opinion. – IrishStat Oct 28 '11 at 19:08
Suppose one starts with an AR(1) Model:
$$Y_t = \gamma + \phi*Y_{t-1} + E_t$$
Where ${E_t}$ is, say, a Gaussian Noise (mean zero and variance $\sigma^2$
The mean of this series.
The mean of the series is $\frac{\gamma}{1-phi}$
So, if for some time the parameters $\gamma$ and $\phi$ does not change, then so does the overall mean of the series. However, it any of these changes, necessarily the mean of the series will change. So, under piecewise stationarity, we are looking for changes of these parameters!
If structural models are assumed, Auto-PARM is the procedure to use.
|
How to detect a significant change in time series data due to a "policy" change?
|
Josh said:
josh: From the OP "What is the appropriate test to determine if the
time series has increase or decreased based on the data? ". This I
believe asks for a determination if the mean of
|
How to detect a significant change in time series data due to a "policy" change?
Josh said:
josh: From the OP "What is the appropriate test to determine if the
time series has increase or decreased based on the data? ". This I
believe asks for a determination if the mean of the residuals has
shifted not the parameters of some ARIMA Model. In my opinion you are
recommending the wrong software/solution procedure but that's just my
opinion. – IrishStat Oct 28 '11 at 19:08
Suppose one starts with an AR(1) Model:
$$Y_t = \gamma + \phi*Y_{t-1} + E_t$$
Where ${E_t}$ is, say, a Gaussian Noise (mean zero and variance $\sigma^2$
The mean of this series.
The mean of the series is $\frac{\gamma}{1-phi}$
So, if for some time the parameters $\gamma$ and $\phi$ does not change, then so does the overall mean of the series. However, it any of these changes, necessarily the mean of the series will change. So, under piecewise stationarity, we are looking for changes of these parameters!
If structural models are assumed, Auto-PARM is the procedure to use.
|
How to detect a significant change in time series data due to a "policy" change?
Josh said:
josh: From the OP "What is the appropriate test to determine if the
time series has increase or decreased based on the data? ". This I
believe asks for a determination if the mean of
|
15,869
|
How to detect a significant change in time series data due to a "policy" change?
|
Looking through some old notes on structural breaks, I have these two cites:
Enders, "Applied Econometric Time Series", 2nd edition, ch. 5.
Enders discusses interventions, pulse functions, gradual change functions, transfer functions, etc. This article may also be helpful:
Box, G.E.P. and G. C. Tiao. 1975. “Intervention Analysis with Applications to Economic and Environmental Problems.” Journal of the American Statistical Association 70: 70-79.
|
How to detect a significant change in time series data due to a "policy" change?
|
Looking through some old notes on structural breaks, I have these two cites:
Enders, "Applied Econometric Time Series", 2nd edition, ch. 5.
Enders discusses interventions, pulse functions, gradual c
|
How to detect a significant change in time series data due to a "policy" change?
Looking through some old notes on structural breaks, I have these two cites:
Enders, "Applied Econometric Time Series", 2nd edition, ch. 5.
Enders discusses interventions, pulse functions, gradual change functions, transfer functions, etc. This article may also be helpful:
Box, G.E.P. and G. C. Tiao. 1975. “Intervention Analysis with Applications to Economic and Environmental Problems.” Journal of the American Statistical Association 70: 70-79.
|
How to detect a significant change in time series data due to a "policy" change?
Looking through some old notes on structural breaks, I have these two cites:
Enders, "Applied Econometric Time Series", 2nd edition, ch. 5.
Enders discusses interventions, pulse functions, gradual c
|
15,870
|
How to detect a significant change in time series data due to a "policy" change?
|
Couldn't you just use a change point model, and then try to identify the change point using an MCMC algorithm such as Gibbs Sampling?
This should be relatively simple to implement, provided you have some prior distributions for your data or the full conditional distirbution (for Gibbs).
You can find a quick overview here
|
How to detect a significant change in time series data due to a "policy" change?
|
Couldn't you just use a change point model, and then try to identify the change point using an MCMC algorithm such as Gibbs Sampling?
This should be relatively simple to implement, provided you have
|
How to detect a significant change in time series data due to a "policy" change?
Couldn't you just use a change point model, and then try to identify the change point using an MCMC algorithm such as Gibbs Sampling?
This should be relatively simple to implement, provided you have some prior distributions for your data or the full conditional distirbution (for Gibbs).
You can find a quick overview here
|
How to detect a significant change in time series data due to a "policy" change?
Couldn't you just use a change point model, and then try to identify the change point using an MCMC algorithm such as Gibbs Sampling?
This should be relatively simple to implement, provided you have
|
15,871
|
How to detect a significant change in time series data due to a "policy" change?
|
If you were considering all time points as candidate change points (a.k.a. break points, a.k.a. structural change) then the strucchange package is a very good option.
It seem that in your particular scenario, there is only one candidate time point. In this case, several quick options come to mind:
T-test: a t-test on the hours of concentration per day on the "before quitting" vs. "after quitting" periods. If you are concerned with day-to-day correlation, you could give up some observations so that you have long enough intervals to believe the days are no longer correlated. With this approach,you will be trading off power with simplicity.
AR: Fit an AR model with one dummy: "after quitting". If the predictor is significant, then you have a change. Using an AR, will capture the (possible) dependence between days.
|
How to detect a significant change in time series data due to a "policy" change?
|
If you were considering all time points as candidate change points (a.k.a. break points, a.k.a. structural change) then the strucchange package is a very good option.
It seem that in your particular s
|
How to detect a significant change in time series data due to a "policy" change?
If you were considering all time points as candidate change points (a.k.a. break points, a.k.a. structural change) then the strucchange package is a very good option.
It seem that in your particular scenario, there is only one candidate time point. In this case, several quick options come to mind:
T-test: a t-test on the hours of concentration per day on the "before quitting" vs. "after quitting" periods. If you are concerned with day-to-day correlation, you could give up some observations so that you have long enough intervals to believe the days are no longer correlated. With this approach,you will be trading off power with simplicity.
AR: Fit an AR model with one dummy: "after quitting". If the predictor is significant, then you have a change. Using an AR, will capture the (possible) dependence between days.
|
How to detect a significant change in time series data due to a "policy" change?
If you were considering all time points as candidate change points (a.k.a. break points, a.k.a. structural change) then the strucchange package is a very good option.
It seem that in your particular s
|
15,872
|
How to detect a significant change in time series data due to a "policy" change?
|
A few years ago I heard a talk by a grad student, Stacey Hancock, during a local ASA chapter meeting and it was on "structural break estimation" of time series. The talk was really interesting and I spoke with her afterwards and she was working with Richard Davis (of Brockwell-Davis), then at Colorado State University, now at Columbia. The talk was an extension of Davis et al. work in a 2006 JASA paper called Strutural Break Estimation for Nonstationary Time Series Models, which is freely available here.
Davis has a software implementation of the method that he calls Auto-PARM, which he made into a Windows executable. If you contact him you may be able to get a copy. I have a copy, and here is example output on a 1,200 observation time series:
============== RESULTS ===============
ISLAND 1
SC= 1910.58314770669
Breaking point/AR order
1 1
351 1
612 3
======================================
Total time: 5.812500
So the series is AR(1) in the beginning, at observation 351 the AR(1) process changes to another AR(1) process (you can get the parameters), and then at observation 612 the process changes to AR(3).
One interesting setting I tried Auto-PARM on was looking at weekly ATM withdrawal data that was part of the NN5 competition. I recall the algorithm finding structural breaks in late November of a given year, e.g. the beginning of the US holiday shopping season.
So, how to use this algorithm via existing implementations? Well, again, you could reach out to Davis and see if you can get the Windows executable. When I was at Rogue Wave Software I worked with Davis to get Auto-PARM into the IMSL Numerical Libraries. The first language it was ported to was Fortran, where it is called Auto_PARM, and I suspect Rogue Wave will release a C port soon, with Python, C# and Java ports to follow.
|
How to detect a significant change in time series data due to a "policy" change?
|
A few years ago I heard a talk by a grad student, Stacey Hancock, during a local ASA chapter meeting and it was on "structural break estimation" of time series. The talk was really interesting and I s
|
How to detect a significant change in time series data due to a "policy" change?
A few years ago I heard a talk by a grad student, Stacey Hancock, during a local ASA chapter meeting and it was on "structural break estimation" of time series. The talk was really interesting and I spoke with her afterwards and she was working with Richard Davis (of Brockwell-Davis), then at Colorado State University, now at Columbia. The talk was an extension of Davis et al. work in a 2006 JASA paper called Strutural Break Estimation for Nonstationary Time Series Models, which is freely available here.
Davis has a software implementation of the method that he calls Auto-PARM, which he made into a Windows executable. If you contact him you may be able to get a copy. I have a copy, and here is example output on a 1,200 observation time series:
============== RESULTS ===============
ISLAND 1
SC= 1910.58314770669
Breaking point/AR order
1 1
351 1
612 3
======================================
Total time: 5.812500
So the series is AR(1) in the beginning, at observation 351 the AR(1) process changes to another AR(1) process (you can get the parameters), and then at observation 612 the process changes to AR(3).
One interesting setting I tried Auto-PARM on was looking at weekly ATM withdrawal data that was part of the NN5 competition. I recall the algorithm finding structural breaks in late November of a given year, e.g. the beginning of the US holiday shopping season.
So, how to use this algorithm via existing implementations? Well, again, you could reach out to Davis and see if you can get the Windows executable. When I was at Rogue Wave Software I worked with Davis to get Auto-PARM into the IMSL Numerical Libraries. The first language it was ported to was Fortran, where it is called Auto_PARM, and I suspect Rogue Wave will release a C port soon, with Python, C# and Java ports to follow.
|
How to detect a significant change in time series data due to a "policy" change?
A few years ago I heard a talk by a grad student, Stacey Hancock, during a local ASA chapter meeting and it was on "structural break estimation" of time series. The talk was really interesting and I s
|
15,873
|
What is ordinary, in ordinary least squares?
|
Least squares in $y$ is often called ordinary least squares (OLS) because it was the first ever statistical procedure to be developed circa 1800, see history. It is equivalent to minimizing the $L_2$ norm, $||Y-f(X)||_2$. Subsequently, weighted least squares, minimization of other norms (e.g., $L_1$), generalized least squares, M Estimation, bivariate minimization (e.g., Deming regression), non-parametric regression, maximum likelihood regression, regularization (e.g., Tikhonov, ridge) and other inverse problem techniques and multiple other tools were developed. There is still controversy over who first applied it, Gauss or Legendre (see link). The term "ordinary" (implying in $y$) was obviously added to "least squares" only after so many alternative methods arose that the (still most) popular OLS needed to be differentiated from the plethora of other minimizations that became available. The word ordinary is often used in mathematical jargon as a synonym of simple. For example, consider the phrase ordinary differential equations. When exactly adding ordinary$+$least squares occurred would be hard to track down since that occurred when it became natural or obvious to do so. EDIT (for @alexis): Early 20th century I would presume, @GeoMatt22 says 1921 in comments below, but the mathematical meaning of ordinary (sive, vanilla) predates that and certain differential equations were called ordinary in the late 18th century as per The History of Differential Equations, 1670--1950.
|
What is ordinary, in ordinary least squares?
|
Least squares in $y$ is often called ordinary least squares (OLS) because it was the first ever statistical procedure to be developed circa 1800, see history. It is equivalent to minimizing the $L_2$
|
What is ordinary, in ordinary least squares?
Least squares in $y$ is often called ordinary least squares (OLS) because it was the first ever statistical procedure to be developed circa 1800, see history. It is equivalent to minimizing the $L_2$ norm, $||Y-f(X)||_2$. Subsequently, weighted least squares, minimization of other norms (e.g., $L_1$), generalized least squares, M Estimation, bivariate minimization (e.g., Deming regression), non-parametric regression, maximum likelihood regression, regularization (e.g., Tikhonov, ridge) and other inverse problem techniques and multiple other tools were developed. There is still controversy over who first applied it, Gauss or Legendre (see link). The term "ordinary" (implying in $y$) was obviously added to "least squares" only after so many alternative methods arose that the (still most) popular OLS needed to be differentiated from the plethora of other minimizations that became available. The word ordinary is often used in mathematical jargon as a synonym of simple. For example, consider the phrase ordinary differential equations. When exactly adding ordinary$+$least squares occurred would be hard to track down since that occurred when it became natural or obvious to do so. EDIT (for @alexis): Early 20th century I would presume, @GeoMatt22 says 1921 in comments below, but the mathematical meaning of ordinary (sive, vanilla) predates that and certain differential equations were called ordinary in the late 18th century as per The History of Differential Equations, 1670--1950.
|
What is ordinary, in ordinary least squares?
Least squares in $y$ is often called ordinary least squares (OLS) because it was the first ever statistical procedure to be developed circa 1800, see history. It is equivalent to minimizing the $L_2$
|
15,874
|
What is the relation behind Jeffreys Priors and a variance stabilizing transformation?
|
The Jeffreys prior is invariant under reparametrization. For that reason, many Bayesians consider it to be a “non-informative prior”. (Hartigan showed that there is a whole space of such priors $J^\alpha H^\beta$ for $\alpha + \beta=1$ where $J$ is Jeffreys' prior and $H$ is Hartigan's asymptotically locally invariant prior. — Invariant Prior Distributions)
It is an often-repeated falsehood that the uniform prior is non-informative, but after an arbitrary transformation of your parameters, and a uniform prior on the new parameters means something completely different. If an arbitrary change of parametrization affects your prior, then your prior is clearly informative.
Using the Jeffreys is, by definition, equivalent to using a flat prior after applying the variance-stabilizing transformation.
From a mathematical standpoint, using the Jeffreys prior, and using a flat prior after applying the variance-stabilizing transformation are equivalent. From a human standpoint, the latter is probably nicer because the parameter space becomes "homogeneous" in the sense that differences are all the same in every direction no matter where you are in the parameter space.
Consider your Bernoulli example. Isn't a little bit weird that scoring 99% on a test is the same distance to 90% as 59% is to 50%? After your variance-stabilizing transformation the former pair are more separated, as they should be. It matches our intuition about actual distances in the space. (Mathematically, the variance-stabilizing transformation is making the curvature of the log-loss equal to the identity matrix.)
|
What is the relation behind Jeffreys Priors and a variance stabilizing transformation?
|
The Jeffreys prior is invariant under reparametrization. For that reason, many Bayesians consider it to be a “non-informative prior”. (Hartigan showed that there is a whole space of such priors $J^\
|
What is the relation behind Jeffreys Priors and a variance stabilizing transformation?
The Jeffreys prior is invariant under reparametrization. For that reason, many Bayesians consider it to be a “non-informative prior”. (Hartigan showed that there is a whole space of such priors $J^\alpha H^\beta$ for $\alpha + \beta=1$ where $J$ is Jeffreys' prior and $H$ is Hartigan's asymptotically locally invariant prior. — Invariant Prior Distributions)
It is an often-repeated falsehood that the uniform prior is non-informative, but after an arbitrary transformation of your parameters, and a uniform prior on the new parameters means something completely different. If an arbitrary change of parametrization affects your prior, then your prior is clearly informative.
Using the Jeffreys is, by definition, equivalent to using a flat prior after applying the variance-stabilizing transformation.
From a mathematical standpoint, using the Jeffreys prior, and using a flat prior after applying the variance-stabilizing transformation are equivalent. From a human standpoint, the latter is probably nicer because the parameter space becomes "homogeneous" in the sense that differences are all the same in every direction no matter where you are in the parameter space.
Consider your Bernoulli example. Isn't a little bit weird that scoring 99% on a test is the same distance to 90% as 59% is to 50%? After your variance-stabilizing transformation the former pair are more separated, as they should be. It matches our intuition about actual distances in the space. (Mathematically, the variance-stabilizing transformation is making the curvature of the log-loss equal to the identity matrix.)
|
What is the relation behind Jeffreys Priors and a variance stabilizing transformation?
The Jeffreys prior is invariant under reparametrization. For that reason, many Bayesians consider it to be a “non-informative prior”. (Hartigan showed that there is a whole space of such priors $J^\
|
15,875
|
What is the relation behind Jeffreys Priors and a variance stabilizing transformation?
|
The Wikipedia page that you provided does not really use the term "variance-stabilizing transformation". The term "variance-stabilizing transformation" is generally used to indicate transformations that make the variance of the random variable a constant. Although in the Bernoulli case, this is what is happening with the transformation, that is not exactly what the goal is. The goal is to get a uniform distribution, and not just a variance stabilizing one.
Recall that one of the main purposes of using Jeffreys prior is that it is invariant under transformation. This means that if you re-parameterize the variable, the prior will not change.
1.
The Jeffreys prior in this Bernoulli case, as you pointed out, is a Beta$(1/2, 1/2)$.
$$p_{\gamma}(\gamma) \propto \dfrac{1}{\sqrt{\gamma(1-\gamma)}}.$$
Reparametrizing with $\gamma = \sin^2(\theta)$, we can find the distribution of $\theta$. First lets see that $\theta = \arcsin(\sqrt{\gamma})$, and since $0 < \gamma < 1$, $0 < \theta < \pi/2$. Recall that $\sin^2(x) + \cos^2(x) = 1$.
\begin{align*}
F_{\theta}(x) & = P(\theta < x)\\
& = P(\sin^2(\theta) < \sin^2(x))\\
& = P(\gamma < \sin^2(x))\\
& = F_{\gamma}(\sin^2(x))\\
f_{\theta}(x) & = \dfrac{d F_{\gamma}(\sin^2(x)}{d x}\\
& = 2\sin(x)\cos(x)\,p_{\gamma}(\sin^2(x))\\
& \propto \sin(x)\cos(x) \dfrac{1}{\sqrt{\sin^2(x)(1 - \sin^2(x))}}\\
& =1.
\end{align*}
Thus $\theta$ is the uniform distribution on $(0, \pi/2)$. This is why the $\sin^2(\theta)$ transformation is used, so that the re-parametrization leads to a uniform distribution. The uniform distribution is now the Jeffreys prior on $\theta$ (since Jeffreys prior is invariant under transformation). This answers your first question.
2.
Often in Bayesian analysis one wants a uniform prior when there is not enough information or prior knowledge about the distribution of the parameter. Such a prior is also called a "diffuse prior" or "default prior". The idea is to not commit to any value in the parameter space more than other values. In such a case the posterior is then completely dependent on the data likelihood. Since,
$$q(\theta|x) \propto f(x|\theta) f(\theta) \propto f(x|\theta).$$
If the transformation is such that the transformed space is bounded, (like $(0, \pi/2)$ in this example), then the uniform distribution will be proper. If the transformed space is unbounded, then the uniform prior will be improper, but often the resulting posterior will be proper. Although, one should always verify that this is the case.
|
What is the relation behind Jeffreys Priors and a variance stabilizing transformation?
|
The Wikipedia page that you provided does not really use the term "variance-stabilizing transformation". The term "variance-stabilizing transformation" is generally used to indicate transformations th
|
What is the relation behind Jeffreys Priors and a variance stabilizing transformation?
The Wikipedia page that you provided does not really use the term "variance-stabilizing transformation". The term "variance-stabilizing transformation" is generally used to indicate transformations that make the variance of the random variable a constant. Although in the Bernoulli case, this is what is happening with the transformation, that is not exactly what the goal is. The goal is to get a uniform distribution, and not just a variance stabilizing one.
Recall that one of the main purposes of using Jeffreys prior is that it is invariant under transformation. This means that if you re-parameterize the variable, the prior will not change.
1.
The Jeffreys prior in this Bernoulli case, as you pointed out, is a Beta$(1/2, 1/2)$.
$$p_{\gamma}(\gamma) \propto \dfrac{1}{\sqrt{\gamma(1-\gamma)}}.$$
Reparametrizing with $\gamma = \sin^2(\theta)$, we can find the distribution of $\theta$. First lets see that $\theta = \arcsin(\sqrt{\gamma})$, and since $0 < \gamma < 1$, $0 < \theta < \pi/2$. Recall that $\sin^2(x) + \cos^2(x) = 1$.
\begin{align*}
F_{\theta}(x) & = P(\theta < x)\\
& = P(\sin^2(\theta) < \sin^2(x))\\
& = P(\gamma < \sin^2(x))\\
& = F_{\gamma}(\sin^2(x))\\
f_{\theta}(x) & = \dfrac{d F_{\gamma}(\sin^2(x)}{d x}\\
& = 2\sin(x)\cos(x)\,p_{\gamma}(\sin^2(x))\\
& \propto \sin(x)\cos(x) \dfrac{1}{\sqrt{\sin^2(x)(1 - \sin^2(x))}}\\
& =1.
\end{align*}
Thus $\theta$ is the uniform distribution on $(0, \pi/2)$. This is why the $\sin^2(\theta)$ transformation is used, so that the re-parametrization leads to a uniform distribution. The uniform distribution is now the Jeffreys prior on $\theta$ (since Jeffreys prior is invariant under transformation). This answers your first question.
2.
Often in Bayesian analysis one wants a uniform prior when there is not enough information or prior knowledge about the distribution of the parameter. Such a prior is also called a "diffuse prior" or "default prior". The idea is to not commit to any value in the parameter space more than other values. In such a case the posterior is then completely dependent on the data likelihood. Since,
$$q(\theta|x) \propto f(x|\theta) f(\theta) \propto f(x|\theta).$$
If the transformation is such that the transformed space is bounded, (like $(0, \pi/2)$ in this example), then the uniform distribution will be proper. If the transformed space is unbounded, then the uniform prior will be improper, but often the resulting posterior will be proper. Although, one should always verify that this is the case.
|
What is the relation behind Jeffreys Priors and a variance stabilizing transformation?
The Wikipedia page that you provided does not really use the term "variance-stabilizing transformation". The term "variance-stabilizing transformation" is generally used to indicate transformations th
|
15,876
|
Does using count data as independent variable violate any of GLM assumptions?
|
There are some nuances at play here, and they may be creating some confusion.
You state that you understand the assumptions of a logistic regression include "iid residuals... ". I would argue that this is not quite correct. We generally do say that about the General Linear Model (i.e., regression), but in that case it means that the residuals are independent of each other, with the same distribution (typically normal) having the same mean (0), and variance (i.e., constant variance: homogeneity of variance / homoscedasticity). Note however that for the Bernoulli distribution and the Binomial distribution, the variance is a function of the mean. Thus, the variance couldn't be constant, unless the covariate were perfectly unrelated to the response. That would be an assumption so restrictive as to render logistic regression worthless. I note that in the abstract of the pdf you cite, it lists the assumptions starting with "the statistical independence of the observations", which we might call i-but-not-id (without meaning to be too cute about it).
Next, as @kjetilbhalvorsen notes in the comment above, covariate values (i.e., your independent variables) are assumed to be fixed in the Generalized Linear Model. That is, no particular distributional assumptions are made. Thus, it does not matter if they are counts or not, nor if they range from 0 to 10, from 1 to 10000, or from -3.1415927 to -2.718281828.
One thing to consider, however, as @whuber notes, if you have a small number of data that are very extreme on one of the covariate dimensions, those points could have a great deal of influence over the results of your analysis. That is, you might get a certain result only because of those points. One way to think about this is to do a kind of sensitivity analysis by fitting your model both with and without those data included. You may believe it is safer or more appropriate to drop those observations, use some form of robust statistical analysis, or to transform those covariates so as to minimize the extreme leverage those points would have. I would not characterize these considerations as "assumptions", but they are certainly important considerations in developing an appropriate model.
|
Does using count data as independent variable violate any of GLM assumptions?
|
There are some nuances at play here, and they may be creating some confusion.
You state that you understand the assumptions of a logistic regression include "iid residuals... ". I would argue that
|
Does using count data as independent variable violate any of GLM assumptions?
There are some nuances at play here, and they may be creating some confusion.
You state that you understand the assumptions of a logistic regression include "iid residuals... ". I would argue that this is not quite correct. We generally do say that about the General Linear Model (i.e., regression), but in that case it means that the residuals are independent of each other, with the same distribution (typically normal) having the same mean (0), and variance (i.e., constant variance: homogeneity of variance / homoscedasticity). Note however that for the Bernoulli distribution and the Binomial distribution, the variance is a function of the mean. Thus, the variance couldn't be constant, unless the covariate were perfectly unrelated to the response. That would be an assumption so restrictive as to render logistic regression worthless. I note that in the abstract of the pdf you cite, it lists the assumptions starting with "the statistical independence of the observations", which we might call i-but-not-id (without meaning to be too cute about it).
Next, as @kjetilbhalvorsen notes in the comment above, covariate values (i.e., your independent variables) are assumed to be fixed in the Generalized Linear Model. That is, no particular distributional assumptions are made. Thus, it does not matter if they are counts or not, nor if they range from 0 to 10, from 1 to 10000, or from -3.1415927 to -2.718281828.
One thing to consider, however, as @whuber notes, if you have a small number of data that are very extreme on one of the covariate dimensions, those points could have a great deal of influence over the results of your analysis. That is, you might get a certain result only because of those points. One way to think about this is to do a kind of sensitivity analysis by fitting your model both with and without those data included. You may believe it is safer or more appropriate to drop those observations, use some form of robust statistical analysis, or to transform those covariates so as to minimize the extreme leverage those points would have. I would not characterize these considerations as "assumptions", but they are certainly important considerations in developing an appropriate model.
|
Does using count data as independent variable violate any of GLM assumptions?
There are some nuances at play here, and they may be creating some confusion.
You state that you understand the assumptions of a logistic regression include "iid residuals... ". I would argue that
|
15,877
|
Does using count data as independent variable violate any of GLM assumptions?
|
One thing I would definitely check is the distributional properties of your independent variables. Very often with count data, you'll see some moderate to severe right-skew. In that case, you will likely want to transform your data, as you'll lose the log-linear relationship. But no, using a logistic (or other GLM) model is fine.
|
Does using count data as independent variable violate any of GLM assumptions?
|
One thing I would definitely check is the distributional properties of your independent variables. Very often with count data, you'll see some moderate to severe right-skew. In that case, you will lik
|
Does using count data as independent variable violate any of GLM assumptions?
One thing I would definitely check is the distributional properties of your independent variables. Very often with count data, you'll see some moderate to severe right-skew. In that case, you will likely want to transform your data, as you'll lose the log-linear relationship. But no, using a logistic (or other GLM) model is fine.
|
Does using count data as independent variable violate any of GLM assumptions?
One thing I would definitely check is the distributional properties of your independent variables. Very often with count data, you'll see some moderate to severe right-skew. In that case, you will lik
|
15,878
|
Does GBM classification suffer from imbalanced class sizes?
|
In my experience, GBM does indeed suffer from imbalanced class sizes. I have had good success using SMOTE sampling, which creates synthetic data while oversampling the minority class. You can find it in the DMwR package.
|
Does GBM classification suffer from imbalanced class sizes?
|
In my experience, GBM does indeed suffer from imbalanced class sizes. I have had good success using SMOTE sampling, which creates synthetic data while oversampling the minority class. You can find it
|
Does GBM classification suffer from imbalanced class sizes?
In my experience, GBM does indeed suffer from imbalanced class sizes. I have had good success using SMOTE sampling, which creates synthetic data while oversampling the minority class. You can find it in the DMwR package.
|
Does GBM classification suffer from imbalanced class sizes?
In my experience, GBM does indeed suffer from imbalanced class sizes. I have had good success using SMOTE sampling, which creates synthetic data while oversampling the minority class. You can find it
|
15,879
|
Does GBM classification suffer from imbalanced class sizes?
|
I think your data is similar to Secom data on which I have worked in past and faced lot of difficulties. Following is what I have tried:
Different sampling techniques
Different classifiers like Random Forest, ANN, GBM, Ensemble methods, etc.
I've also tried 1-Class SVM which has given better results as compared to others like adaboost, Random Forest. You can try that as well.
And I can see you've asked this question 1 year back so if you've found the best way then kindly post it here so that I can get help from it to get better accuracy.
|
Does GBM classification suffer from imbalanced class sizes?
|
I think your data is similar to Secom data on which I have worked in past and faced lot of difficulties. Following is what I have tried:
Different sampling techniques
Different classifiers like Rand
|
Does GBM classification suffer from imbalanced class sizes?
I think your data is similar to Secom data on which I have worked in past and faced lot of difficulties. Following is what I have tried:
Different sampling techniques
Different classifiers like Random Forest, ANN, GBM, Ensemble methods, etc.
I've also tried 1-Class SVM which has given better results as compared to others like adaboost, Random Forest. You can try that as well.
And I can see you've asked this question 1 year back so if you've found the best way then kindly post it here so that I can get help from it to get better accuracy.
|
Does GBM classification suffer from imbalanced class sizes?
I think your data is similar to Secom data on which I have worked in past and faced lot of difficulties. Following is what I have tried:
Different sampling techniques
Different classifiers like Rand
|
15,880
|
Why does shrinkage really work, what's so special about 0?
|
1) Why the damage done by introducing bias is less compared with the gain in variance?
It doesn't have to, it just usually is. Whether the tradeoff is worth it depends on the loss function. But the things we care about in real life are often similar to the squared error (e.g. we care more about one big error than about two errors half the size).
As a counterexample - imagine that for college admissions we shrink people's SAT scores a bit towards the mean SAT for their demographic (however defined). If done properly, this will reduce variance and mean squared error of estimates of (some sort of) ability of the person while introducing bias. Most people would IMHO argue that such a tradeoff is unacceptable.
2) Why does it always work?
3) What's so interesting about 0 (the origin)? Clearly we can shrink anywhere we like (i.e. Stein estimator), but is it going to work as good as the origin?
I think this is because we usually shrink coefficients or effect estimates. There are reasons to believe most effects are not large (see e.g. Andrew Gelman's take). One way to put it is that a world where everything influences everything with a strong effect is a violent unpredictable world. Since our world is predictable enough to let us live long lives and build semi-stable civilizations, it follows that most effects are not large.
Since most effects are not large it is useful to wrongfully shrink the few really big ones while also correctly shrinking the loads of negligible effects.
I believe this is just a property of our world and you probably could construct self-consistent worlds where shrinkage isn't practical (most likely by making mean-squared error an impractical loss function). It just doesn't happen to be the world we live in.
On the other hand, when we think of shrinkage as a prior distribution in Bayesian analysis, there are cases where shrinkage to 0 is actively harmful in practice.
One example is the length scale in Gaussian Processes (where 0 is problematic) the recommendation in Stan's manual is to use a prior that puts negligible weight close to zero i.e. effectively "shrinking" small values away from zero. Similarly, recommended priors for dispersion in negative binomial distribution effectively shrink away from zero. Last but not least, whenever the normal distribution is parametrized with precision (as in INLA), it is useful to use inverse-gamma or other prior distributions that shrink away from zero.
4) Why various universal coding schemes prefer lower number of bits around the origin? Are these hypotheses simply more probable?
Now this is way out of my depth, but Wikipedia says that in universal coding scheme we expect (by definition) $P(i) ≥ P(i + 1)$ for all positive $i$ so this property seems to be a simple consequence of the definition and not related to shrinkage (or am I missing something?)
|
Why does shrinkage really work, what's so special about 0?
|
1) Why the damage done by introducing bias is less compared with the gain in variance?
It doesn't have to, it just usually is. Whether the tradeoff is worth it depends on the loss function. But the t
|
Why does shrinkage really work, what's so special about 0?
1) Why the damage done by introducing bias is less compared with the gain in variance?
It doesn't have to, it just usually is. Whether the tradeoff is worth it depends on the loss function. But the things we care about in real life are often similar to the squared error (e.g. we care more about one big error than about two errors half the size).
As a counterexample - imagine that for college admissions we shrink people's SAT scores a bit towards the mean SAT for their demographic (however defined). If done properly, this will reduce variance and mean squared error of estimates of (some sort of) ability of the person while introducing bias. Most people would IMHO argue that such a tradeoff is unacceptable.
2) Why does it always work?
3) What's so interesting about 0 (the origin)? Clearly we can shrink anywhere we like (i.e. Stein estimator), but is it going to work as good as the origin?
I think this is because we usually shrink coefficients or effect estimates. There are reasons to believe most effects are not large (see e.g. Andrew Gelman's take). One way to put it is that a world where everything influences everything with a strong effect is a violent unpredictable world. Since our world is predictable enough to let us live long lives and build semi-stable civilizations, it follows that most effects are not large.
Since most effects are not large it is useful to wrongfully shrink the few really big ones while also correctly shrinking the loads of negligible effects.
I believe this is just a property of our world and you probably could construct self-consistent worlds where shrinkage isn't practical (most likely by making mean-squared error an impractical loss function). It just doesn't happen to be the world we live in.
On the other hand, when we think of shrinkage as a prior distribution in Bayesian analysis, there are cases where shrinkage to 0 is actively harmful in practice.
One example is the length scale in Gaussian Processes (where 0 is problematic) the recommendation in Stan's manual is to use a prior that puts negligible weight close to zero i.e. effectively "shrinking" small values away from zero. Similarly, recommended priors for dispersion in negative binomial distribution effectively shrink away from zero. Last but not least, whenever the normal distribution is parametrized with precision (as in INLA), it is useful to use inverse-gamma or other prior distributions that shrink away from zero.
4) Why various universal coding schemes prefer lower number of bits around the origin? Are these hypotheses simply more probable?
Now this is way out of my depth, but Wikipedia says that in universal coding scheme we expect (by definition) $P(i) ≥ P(i + 1)$ for all positive $i$ so this property seems to be a simple consequence of the definition and not related to shrinkage (or am I missing something?)
|
Why does shrinkage really work, what's so special about 0?
1) Why the damage done by introducing bias is less compared with the gain in variance?
It doesn't have to, it just usually is. Whether the tradeoff is worth it depends on the loss function. But the t
|
15,881
|
Why does shrinkage really work, what's so special about 0?
|
Ridge, lasso and elastic net are similar to Bayesian methods with priors centered on zero -- see, for example, Statistical Learning with Sparsity by Hastie, Tibshirani and Wainwright, section 2.9 Lq Penalties and Bayes Estimates: "There is also a Bayesian view of these estimators. ... This means that the lasso estimate is the Bayesian MAP (maximum aposteriori) estimator using a Laplacian prior."
One way to answer your question (what's so special about zero?) is that the effects we are estimating are zero on average, and they tend to be small (i.e our priors should be centered around zero). Shrinking estimates towards zero is then optimal in a Bayesian sense, and lasso and ridge and elastic nets can be thought of through that lens.
|
Why does shrinkage really work, what's so special about 0?
|
Ridge, lasso and elastic net are similar to Bayesian methods with priors centered on zero -- see, for example, Statistical Learning with Sparsity by Hastie, Tibshirani and Wainwright, section 2.9 Lq
|
Why does shrinkage really work, what's so special about 0?
Ridge, lasso and elastic net are similar to Bayesian methods with priors centered on zero -- see, for example, Statistical Learning with Sparsity by Hastie, Tibshirani and Wainwright, section 2.9 Lq Penalties and Bayes Estimates: "There is also a Bayesian view of these estimators. ... This means that the lasso estimate is the Bayesian MAP (maximum aposteriori) estimator using a Laplacian prior."
One way to answer your question (what's so special about zero?) is that the effects we are estimating are zero on average, and they tend to be small (i.e our priors should be centered around zero). Shrinking estimates towards zero is then optimal in a Bayesian sense, and lasso and ridge and elastic nets can be thought of through that lens.
|
Why does shrinkage really work, what's so special about 0?
Ridge, lasso and elastic net are similar to Bayesian methods with priors centered on zero -- see, for example, Statistical Learning with Sparsity by Hastie, Tibshirani and Wainwright, section 2.9 Lq
|
15,882
|
When was the word "bias" coined to mean $\mathbb{E}[\hat{\theta}-\theta]$?
|
Apparently, the concept of mean bias was coined by:
Neyman, J., & Pearson, E. S. (1936). Contributions to the theory of testing statistical hypotheses. Statistical Research Memoirs, 1, 1-37.
acccording to:
Lehmann, E. L. "A General Concept of Unbiasedness" The Annals of Mathematical Statistics, vol. 22, no. 4 (Dec., 1951), pp. 587–592.
which contains a more extensive discussion on the history of this concept.
It is worth noticing that mean bias is just a type of bias, and there also exists the concept of median bias (which cannot be straightforwardly extended to the multivariate case, which may explain why it is not that popular).
|
When was the word "bias" coined to mean $\mathbb{E}[\hat{\theta}-\theta]$?
|
Apparently, the concept of mean bias was coined by:
Neyman, J., & Pearson, E. S. (1936). Contributions to the theory of testing statistical hypotheses. Statistical Research Memoirs, 1, 1-37.
acccord
|
When was the word "bias" coined to mean $\mathbb{E}[\hat{\theta}-\theta]$?
Apparently, the concept of mean bias was coined by:
Neyman, J., & Pearson, E. S. (1936). Contributions to the theory of testing statistical hypotheses. Statistical Research Memoirs, 1, 1-37.
acccording to:
Lehmann, E. L. "A General Concept of Unbiasedness" The Annals of Mathematical Statistics, vol. 22, no. 4 (Dec., 1951), pp. 587–592.
which contains a more extensive discussion on the history of this concept.
It is worth noticing that mean bias is just a type of bias, and there also exists the concept of median bias (which cannot be straightforwardly extended to the multivariate case, which may explain why it is not that popular).
|
When was the word "bias" coined to mean $\mathbb{E}[\hat{\theta}-\theta]$?
Apparently, the concept of mean bias was coined by:
Neyman, J., & Pearson, E. S. (1936). Contributions to the theory of testing statistical hypotheses. Statistical Research Memoirs, 1, 1-37.
acccord
|
15,883
|
Hyperparameter tuning in Gaussian Process Regression
|
You are right that you need a new covariance matrix computation on every iteration of gradient ascent. So if the matrix computation is not feasible for your setting, then, I think, you cannot use gradient-based marginal likelihood optimization.
My suggestion is to use gradient-free methods for hyperparameter tuning, such as grid search, random search, or Bayesian optimization-based search. These methods are widely used for optimization hyperparameters of other machine learning algorithms e.g. SVMs.
I suggest the grid search for your first try. You basically form a table (grid) of possible hyperparameters, try every one, and look for the best validation performance (or best marginal likelihood).
Grid search would yield a suboptimal set of hyperparameters, and you have to specify grid by yourself.(tip: make grid in a log scale) but far less computation is needed. (and you don't need gradient!)
If you are not familiar with grid search, you can look up Wikipedia:Hyperparameter Optimization - Grid Search
|
Hyperparameter tuning in Gaussian Process Regression
|
You are right that you need a new covariance matrix computation on every iteration of gradient ascent. So if the matrix computation is not feasible for your setting, then, I think, you cannot use grad
|
Hyperparameter tuning in Gaussian Process Regression
You are right that you need a new covariance matrix computation on every iteration of gradient ascent. So if the matrix computation is not feasible for your setting, then, I think, you cannot use gradient-based marginal likelihood optimization.
My suggestion is to use gradient-free methods for hyperparameter tuning, such as grid search, random search, or Bayesian optimization-based search. These methods are widely used for optimization hyperparameters of other machine learning algorithms e.g. SVMs.
I suggest the grid search for your first try. You basically form a table (grid) of possible hyperparameters, try every one, and look for the best validation performance (or best marginal likelihood).
Grid search would yield a suboptimal set of hyperparameters, and you have to specify grid by yourself.(tip: make grid in a log scale) but far less computation is needed. (and you don't need gradient!)
If you are not familiar with grid search, you can look up Wikipedia:Hyperparameter Optimization - Grid Search
|
Hyperparameter tuning in Gaussian Process Regression
You are right that you need a new covariance matrix computation on every iteration of gradient ascent. So if the matrix computation is not feasible for your setting, then, I think, you cannot use grad
|
15,884
|
Hyperparameter tuning in Gaussian Process Regression
|
If solving the linear problem $K\pmb{\alpha} = \textbf{y}$ is too expensive for you at each step of your optimisation, you could resort to approximation techniques such as the Nystr$\ddot{o}$m method (e.g., Williams and Seeger 2001), such that if $K \in \mathbb{R}^{n \times n}$, the Nystr$\ddot{o}$m method computes a rank $m$ approximation of $K$, where $m < n$. Standard inference in the GP setting has run time complexity $\mathcal{O}(n^3)$, while in the Nystr$\ddot{o}$m approach it is $\mathcal{O}(nm^2)$.
In a bit of detail:
First, select $m$ random samples from your inputs, $X_{mm}$, which are then referred to as the active set. Next, compute the relevant (noise free) submatrix $K_{mm} = k(X_{mm},X_{mm})$. The eigenvectors and eigenvalues of $K_{mm}$, denoted $\textbf{u}$ and $\lambda$ respectively, can then be extended to all $n$ data points by the following:
$\tilde{\lambda} = \dfrac{n}{m}\lambda \\
\tilde{\textbf{u}} = \sqrt{\dfrac{m}{n}}\lambda^{-1}K_{nm}\textbf{u}$
where $K_{nm} = k(X,X_{mm})$.
Notice now how the reduced-rank approximation of $K$ is given by:
$\tilde{K} = (\tilde{\lambda}\tilde{\textbf{u}})\tilde{\textbf{u}}^\text{T}$
where in the case $m = n$, $\tilde{K} = K$.
Now, computing the inverse of $\tilde{K} + \pmb{V}$, where $\pmb{V} = a\pmb{I}$, simply requires use of the Woodbury identity:
$(\pmb{V} + (\tilde{\lambda}\tilde{\textbf{u}})\tilde{\textbf{u}}^\text{T})^{-1} = \pmb{V}^{-1} - \pmb{V}^{-1}\tilde{\textbf{u}}\big(diag(\tilde{\lambda}^{-1}) + \tilde{\textbf{u}}^\text{T}\pmb{V}^{-1}\tilde{\textbf{u}}\big)^{-1}\tilde{\textbf{u}}^\text{T}\pmb{V}^{-1}$
which is now much cheaper, because $\big(diag(\tilde{\lambda}^{-1}) + \tilde{\textbf{u}}^\text{T}\pmb{V}^{-1}\tilde{\textbf{u}}\big)^{-1}$ is of size $m \times m$.
Finally, the evaluation of $det(\tilde{K} + \pmb{I}a)$ (required for computing the log marginal likelihood), can also be derived cheaply. First let us define $\tilde{L} = \sqrt{\tilde{\lambda}}\tilde{\textbf{u}}$, such that $\tilde{L}\tilde{L}^\text{T} = \tilde{K}$. Now, we can use Sylvester's determinant theorem, which states that
$det(\pmb{I}_na + \tilde{L}\tilde{L}^\text{T}) = det(\pmb{I}_ma + \tilde{L}^\text{T}\tilde{L})$
The LHS of the above definition has complexity $\mathcal{O}(n^3)$, while on the RHS it is $\mathcal{O}(m^3)$.
|
Hyperparameter tuning in Gaussian Process Regression
|
If solving the linear problem $K\pmb{\alpha} = \textbf{y}$ is too expensive for you at each step of your optimisation, you could resort to approximation techniques such as the Nystr$\ddot{o}$m method
|
Hyperparameter tuning in Gaussian Process Regression
If solving the linear problem $K\pmb{\alpha} = \textbf{y}$ is too expensive for you at each step of your optimisation, you could resort to approximation techniques such as the Nystr$\ddot{o}$m method (e.g., Williams and Seeger 2001), such that if $K \in \mathbb{R}^{n \times n}$, the Nystr$\ddot{o}$m method computes a rank $m$ approximation of $K$, where $m < n$. Standard inference in the GP setting has run time complexity $\mathcal{O}(n^3)$, while in the Nystr$\ddot{o}$m approach it is $\mathcal{O}(nm^2)$.
In a bit of detail:
First, select $m$ random samples from your inputs, $X_{mm}$, which are then referred to as the active set. Next, compute the relevant (noise free) submatrix $K_{mm} = k(X_{mm},X_{mm})$. The eigenvectors and eigenvalues of $K_{mm}$, denoted $\textbf{u}$ and $\lambda$ respectively, can then be extended to all $n$ data points by the following:
$\tilde{\lambda} = \dfrac{n}{m}\lambda \\
\tilde{\textbf{u}} = \sqrt{\dfrac{m}{n}}\lambda^{-1}K_{nm}\textbf{u}$
where $K_{nm} = k(X,X_{mm})$.
Notice now how the reduced-rank approximation of $K$ is given by:
$\tilde{K} = (\tilde{\lambda}\tilde{\textbf{u}})\tilde{\textbf{u}}^\text{T}$
where in the case $m = n$, $\tilde{K} = K$.
Now, computing the inverse of $\tilde{K} + \pmb{V}$, where $\pmb{V} = a\pmb{I}$, simply requires use of the Woodbury identity:
$(\pmb{V} + (\tilde{\lambda}\tilde{\textbf{u}})\tilde{\textbf{u}}^\text{T})^{-1} = \pmb{V}^{-1} - \pmb{V}^{-1}\tilde{\textbf{u}}\big(diag(\tilde{\lambda}^{-1}) + \tilde{\textbf{u}}^\text{T}\pmb{V}^{-1}\tilde{\textbf{u}}\big)^{-1}\tilde{\textbf{u}}^\text{T}\pmb{V}^{-1}$
which is now much cheaper, because $\big(diag(\tilde{\lambda}^{-1}) + \tilde{\textbf{u}}^\text{T}\pmb{V}^{-1}\tilde{\textbf{u}}\big)^{-1}$ is of size $m \times m$.
Finally, the evaluation of $det(\tilde{K} + \pmb{I}a)$ (required for computing the log marginal likelihood), can also be derived cheaply. First let us define $\tilde{L} = \sqrt{\tilde{\lambda}}\tilde{\textbf{u}}$, such that $\tilde{L}\tilde{L}^\text{T} = \tilde{K}$. Now, we can use Sylvester's determinant theorem, which states that
$det(\pmb{I}_na + \tilde{L}\tilde{L}^\text{T}) = det(\pmb{I}_ma + \tilde{L}^\text{T}\tilde{L})$
The LHS of the above definition has complexity $\mathcal{O}(n^3)$, while on the RHS it is $\mathcal{O}(m^3)$.
|
Hyperparameter tuning in Gaussian Process Regression
If solving the linear problem $K\pmb{\alpha} = \textbf{y}$ is too expensive for you at each step of your optimisation, you could resort to approximation techniques such as the Nystr$\ddot{o}$m method
|
15,885
|
How to correctly assess the correlation between ordinal and a continuous variable?
|
You could use Spearman's, which is based on ranks and therefore OK for ordinal data. You would then have six results.
If you want to take a different approach, you could get complex and look at a multilevel model, with subject being repeated. It sounds like "accuracy" would depend on "preference". So, a mixed model could look at that and account for the non-independence of the data. But, as noted, that's a much more complex model to implement.
|
How to correctly assess the correlation between ordinal and a continuous variable?
|
You could use Spearman's, which is based on ranks and therefore OK for ordinal data. You would then have six results.
If you want to take a different approach, you could get complex and look at a mult
|
How to correctly assess the correlation between ordinal and a continuous variable?
You could use Spearman's, which is based on ranks and therefore OK for ordinal data. You would then have six results.
If you want to take a different approach, you could get complex and look at a multilevel model, with subject being repeated. It sounds like "accuracy" would depend on "preference". So, a mixed model could look at that and account for the non-independence of the data. But, as noted, that's a much more complex model to implement.
|
How to correctly assess the correlation between ordinal and a continuous variable?
You could use Spearman's, which is based on ranks and therefore OK for ordinal data. You would then have six results.
If you want to take a different approach, you could get complex and look at a mult
|
15,886
|
How to correctly assess the correlation between ordinal and a continuous variable?
|
According to this paper* "Measures of Association: How to Choose?" (doi:10.1177/8756479308317006), you should consider kendall's tau-b if the number of items in your ordinal variable is low (<5 or <6 ... this is a bit arbitrary).
If you have a large number of items in your ordinal variable, Spearman correlation would work well.
*the paper may be behind a paywall. But I tried to summarize the essence in my post.
|
How to correctly assess the correlation between ordinal and a continuous variable?
|
According to this paper* "Measures of Association: How to Choose?" (doi:10.1177/8756479308317006), you should consider kendall's tau-b if the number of items in your ordinal variable is low (<5 or <6
|
How to correctly assess the correlation between ordinal and a continuous variable?
According to this paper* "Measures of Association: How to Choose?" (doi:10.1177/8756479308317006), you should consider kendall's tau-b if the number of items in your ordinal variable is low (<5 or <6 ... this is a bit arbitrary).
If you have a large number of items in your ordinal variable, Spearman correlation would work well.
*the paper may be behind a paywall. But I tried to summarize the essence in my post.
|
How to correctly assess the correlation between ordinal and a continuous variable?
According to this paper* "Measures of Association: How to Choose?" (doi:10.1177/8756479308317006), you should consider kendall's tau-b if the number of items in your ordinal variable is low (<5 or <6
|
15,887
|
How to: Prediction intervals for linear regression via bootstrapping
|
Confidence intervals take account of the estimation uncertainty. Prediction intervals add to this the fundamental uncertainty. R's predict.lm will give you the prediction interval for a linear model. From there, all you have to do is run it repeatedly on bootstrapped samples.
n <- 100
n.bs <- 30
dat <- data.frame( x<-runif(n), y=x+runif(n) )
plot(y~x,data=dat)
regressAndPredict <- function( dat ) {
model <- lm( y~x, data=dat )
predict( model, interval="prediction" )
}
regressAndPredict(dat)
replicate( n.bs, regressAndPredict(dat[ sample(seq(n),replace=TRUE) ,]) )
The result of replicate is a 3-dimensional array (n x 3 x n.bs). The length 3 dimension consists of the fitted value for each data element, and the lower/upper bounds of the 95% prediction interval.
Gary King method
Depending on what you want, there's a cool method by King, Tomz, and Wittenberg. It's relatively easy to implement, and avoids the problems of bootstrapping for certain estimates (e.g. max(Y)).
I'll quote from his definition of fundamental uncertainty here, since it's reasonably nice:
A second form of variability, the fundamental un- certainty
represented by the stochastic component (the distribution f ) in
Equation 1, results from innumerable chance events such as weather or
illness that may influ- ence Y but are not included in X. Even if we
knew the ex- act values of the parameters (thereby eliminating esti-
mation uncertainty), fundamental uncertainty would prevent us from
predicting Y without error.
|
How to: Prediction intervals for linear regression via bootstrapping
|
Confidence intervals take account of the estimation uncertainty. Prediction intervals add to this the fundamental uncertainty. R's predict.lm will give you the prediction interval for a linear model
|
How to: Prediction intervals for linear regression via bootstrapping
Confidence intervals take account of the estimation uncertainty. Prediction intervals add to this the fundamental uncertainty. R's predict.lm will give you the prediction interval for a linear model. From there, all you have to do is run it repeatedly on bootstrapped samples.
n <- 100
n.bs <- 30
dat <- data.frame( x<-runif(n), y=x+runif(n) )
plot(y~x,data=dat)
regressAndPredict <- function( dat ) {
model <- lm( y~x, data=dat )
predict( model, interval="prediction" )
}
regressAndPredict(dat)
replicate( n.bs, regressAndPredict(dat[ sample(seq(n),replace=TRUE) ,]) )
The result of replicate is a 3-dimensional array (n x 3 x n.bs). The length 3 dimension consists of the fitted value for each data element, and the lower/upper bounds of the 95% prediction interval.
Gary King method
Depending on what you want, there's a cool method by King, Tomz, and Wittenberg. It's relatively easy to implement, and avoids the problems of bootstrapping for certain estimates (e.g. max(Y)).
I'll quote from his definition of fundamental uncertainty here, since it's reasonably nice:
A second form of variability, the fundamental un- certainty
represented by the stochastic component (the distribution f ) in
Equation 1, results from innumerable chance events such as weather or
illness that may influ- ence Y but are not included in X. Even if we
knew the ex- act values of the parameters (thereby eliminating esti-
mation uncertainty), fundamental uncertainty would prevent us from
predicting Y without error.
|
How to: Prediction intervals for linear regression via bootstrapping
Confidence intervals take account of the estimation uncertainty. Prediction intervals add to this the fundamental uncertainty. R's predict.lm will give you the prediction interval for a linear model
|
15,888
|
How to: Prediction intervals for linear regression via bootstrapping
|
Bootstrapping does not assumed any knowledge of the form of the underlying parent distribution from which the sample arose. Traditional classical statistical parameter estimates are based on the normality assumption. Bootstrap deals with non-normality and is more accurate in practice than the classical methods.
Bootstrapping substitutes computers’ raw computing power for rigorous theoretical analysis. It is an estimate for the sampling distribution of a data set error term. Bootstrapping includes: re-sampling the data set a specified number of times, calculating the mean from each sample and finding the standard error of the mean.
The following “R” code demonstrates the concept:
This practical example demonstrates the usefulness of bootstrapping and estimates the standard error. The standard error is required to calculate confidence interval.
Let us assume you have a skewed data set "a":
a<-rexp(395, rate=0.1) # Create skewed data
visualization of the skewed data set
plot(a,type="l") # Scatter plot of the skewed data
boxplot(a,type="l") # Box plot of the skewed data
hist(a) # Histogram plot of the skewed data
Perform the bootstrapping procedure:
n <- length(a) # the number of bootstrap samples should equal the original data set
xbarstar <- c() # Declare the empty set “xbarstar” variable which will be holding the mean of every bootstrap iteration
for (i in 1:1000) { # Perform 1000 bootstrap iteration
boot.samp <- sample(a, n, replace=TRUE) #”Sample” generates the same number of elements as the original data set
xbarstar[i] <- mean(boot.samp)} # “xbarstar” variable collects 1000 averages of the original data set
##
plot(xbarstar) # Scatter plot of the bootstrapped data
boxplot(xbarstar) # Box plot of the bootstrapped data
hist(xbarstar) # Histogram plot of the bootstrapped data
meanOfMeans <- mean(xbarstar)
standardError <- sd(xbarstar) # the standard error is the standard deviation of the mean of means
confidenceIntervalAboveTheMean <- meanOfMeans + 1.96 * standardError # for 2 standard deviation above the mean
confidenceIntervalBelowTheMean <- meanOfMeans - 1.96 * standardError # for 2 standard deviation above the mean
confidenceInterval <- confidenceIntervalAboveTheMean + confidenceIntervalBelowTheMean
confidenceInterval
|
How to: Prediction intervals for linear regression via bootstrapping
|
Bootstrapping does not assumed any knowledge of the form of the underlying parent distribution from which the sample arose. Traditional classical statistical parameter estimates are based on the norma
|
How to: Prediction intervals for linear regression via bootstrapping
Bootstrapping does not assumed any knowledge of the form of the underlying parent distribution from which the sample arose. Traditional classical statistical parameter estimates are based on the normality assumption. Bootstrap deals with non-normality and is more accurate in practice than the classical methods.
Bootstrapping substitutes computers’ raw computing power for rigorous theoretical analysis. It is an estimate for the sampling distribution of a data set error term. Bootstrapping includes: re-sampling the data set a specified number of times, calculating the mean from each sample and finding the standard error of the mean.
The following “R” code demonstrates the concept:
This practical example demonstrates the usefulness of bootstrapping and estimates the standard error. The standard error is required to calculate confidence interval.
Let us assume you have a skewed data set "a":
a<-rexp(395, rate=0.1) # Create skewed data
visualization of the skewed data set
plot(a,type="l") # Scatter plot of the skewed data
boxplot(a,type="l") # Box plot of the skewed data
hist(a) # Histogram plot of the skewed data
Perform the bootstrapping procedure:
n <- length(a) # the number of bootstrap samples should equal the original data set
xbarstar <- c() # Declare the empty set “xbarstar” variable which will be holding the mean of every bootstrap iteration
for (i in 1:1000) { # Perform 1000 bootstrap iteration
boot.samp <- sample(a, n, replace=TRUE) #”Sample” generates the same number of elements as the original data set
xbarstar[i] <- mean(boot.samp)} # “xbarstar” variable collects 1000 averages of the original data set
##
plot(xbarstar) # Scatter plot of the bootstrapped data
boxplot(xbarstar) # Box plot of the bootstrapped data
hist(xbarstar) # Histogram plot of the bootstrapped data
meanOfMeans <- mean(xbarstar)
standardError <- sd(xbarstar) # the standard error is the standard deviation of the mean of means
confidenceIntervalAboveTheMean <- meanOfMeans + 1.96 * standardError # for 2 standard deviation above the mean
confidenceIntervalBelowTheMean <- meanOfMeans - 1.96 * standardError # for 2 standard deviation above the mean
confidenceInterval <- confidenceIntervalAboveTheMean + confidenceIntervalBelowTheMean
confidenceInterval
|
How to: Prediction intervals for linear regression via bootstrapping
Bootstrapping does not assumed any knowledge of the form of the underlying parent distribution from which the sample arose. Traditional classical statistical parameter estimates are based on the norma
|
15,889
|
When will a Kalman filter give better results than a simple moving average?
|
The estimate given by a moving average will lag behind the true state.
Say you want to measure the altitude of a plane rising at a constant velocity and you have noisy (Gaussian) altitude measurements. An average over a time interval of noisy altitude measurements is likely to give you a good estimate of where the plane was in the middle of that time interval.
If you use a larger time interval for your moving average, the average will be more accurate but it will estimate the plane's altitude at an earlier time. If you use a smaller time interval for your moving average, the average will be less accurate but it will estimate the plane's altitude at a more recent time.
That said, the lag of a moving average may not pose a problem in some applications.
edit: this post asks the same question and has more responses and resources
|
When will a Kalman filter give better results than a simple moving average?
|
The estimate given by a moving average will lag behind the true state.
Say you want to measure the altitude of a plane rising at a constant velocity and you have noisy (Gaussian) altitude measurements
|
When will a Kalman filter give better results than a simple moving average?
The estimate given by a moving average will lag behind the true state.
Say you want to measure the altitude of a plane rising at a constant velocity and you have noisy (Gaussian) altitude measurements. An average over a time interval of noisy altitude measurements is likely to give you a good estimate of where the plane was in the middle of that time interval.
If you use a larger time interval for your moving average, the average will be more accurate but it will estimate the plane's altitude at an earlier time. If you use a smaller time interval for your moving average, the average will be less accurate but it will estimate the plane's altitude at a more recent time.
That said, the lag of a moving average may not pose a problem in some applications.
edit: this post asks the same question and has more responses and resources
|
When will a Kalman filter give better results than a simple moving average?
The estimate given by a moving average will lag behind the true state.
Say you want to measure the altitude of a plane rising at a constant velocity and you have noisy (Gaussian) altitude measurements
|
15,890
|
When will a Kalman filter give better results than a simple moving average?
|
I found that using the original parameters that I used to setup the problem, the moving average was performing better, but when I started playing with the parameters that defined my dynamic model I found the Kalman Filter was performing much better. Now that I have something setup to see the effects the parameters play I think I will gain a better intuition on what exactly is happening. Thank you to those who replied and sorry if my question was/is vague.
|
When will a Kalman filter give better results than a simple moving average?
|
I found that using the original parameters that I used to setup the problem, the moving average was performing better, but when I started playing with the parameters that defined my dynamic model I fo
|
When will a Kalman filter give better results than a simple moving average?
I found that using the original parameters that I used to setup the problem, the moving average was performing better, but when I started playing with the parameters that defined my dynamic model I found the Kalman Filter was performing much better. Now that I have something setup to see the effects the parameters play I think I will gain a better intuition on what exactly is happening. Thank you to those who replied and sorry if my question was/is vague.
|
When will a Kalman filter give better results than a simple moving average?
I found that using the original parameters that I used to setup the problem, the moving average was performing better, but when I started playing with the parameters that defined my dynamic model I fo
|
15,891
|
What are some distributions over the probability simplex?
|
This is studied in compositional data analysis, there is a book by Aitchison: The Statistical Analysis Of Compositional Data.
Define the simplex by
$$
S^n =\{(x_1, \dots,x_{n+1}) \in {\mathbb R}^{n+1} \colon x_1>0,\dots, x_{n+1}>0, \sum_{i=1}^{n+1} x_i=1\}.
$$
Note that we use the index $n$ to indicate dimension! Define the geometric mean of an element of the simplex, $x$ as $\tilde{x}$. Then we can define the logratio transformation (introduced by Aitchison) as $x=(x_1, \dots, x_{n+1}) \mapsto (\log(x_1/\tilde{x}), \dots, \log(x_n/\tilde{x})$. This transformation is onto ${\mathbb R}^n$, so have an inverse which I leave to you to calculate (There are also other versions of this transformation that can be used, which has maybe better mathematical properties, more about that later).
Now you can take a normal (or whatever) distribution defined on ${\mathbb R}^n$ and use this inverse transformation to define a distribution on the simplex. The possibilities are limitless, for each and every multivariate distribution on ${\mathbb R}^n$ we get a distribution on the simplex.
I will augment this post later with some examples, and more details on log-ratio transforms.
|
What are some distributions over the probability simplex?
|
This is studied in compositional data analysis, there is a book by Aitchison: The Statistical Analysis Of Compositional Data.
Define the simplex by
$$
S^n =\{(x_1, \dots,x_{n+1}) \in {\mathbb
|
What are some distributions over the probability simplex?
This is studied in compositional data analysis, there is a book by Aitchison: The Statistical Analysis Of Compositional Data.
Define the simplex by
$$
S^n =\{(x_1, \dots,x_{n+1}) \in {\mathbb R}^{n+1} \colon x_1>0,\dots, x_{n+1}>0, \sum_{i=1}^{n+1} x_i=1\}.
$$
Note that we use the index $n$ to indicate dimension! Define the geometric mean of an element of the simplex, $x$ as $\tilde{x}$. Then we can define the logratio transformation (introduced by Aitchison) as $x=(x_1, \dots, x_{n+1}) \mapsto (\log(x_1/\tilde{x}), \dots, \log(x_n/\tilde{x})$. This transformation is onto ${\mathbb R}^n$, so have an inverse which I leave to you to calculate (There are also other versions of this transformation that can be used, which has maybe better mathematical properties, more about that later).
Now you can take a normal (or whatever) distribution defined on ${\mathbb R}^n$ and use this inverse transformation to define a distribution on the simplex. The possibilities are limitless, for each and every multivariate distribution on ${\mathbb R}^n$ we get a distribution on the simplex.
I will augment this post later with some examples, and more details on log-ratio transforms.
|
What are some distributions over the probability simplex?
This is studied in compositional data analysis, there is a book by Aitchison: The Statistical Analysis Of Compositional Data.
Define the simplex by
$$
S^n =\{(x_1, \dots,x_{n+1}) \in {\mathbb
|
15,892
|
Random walk with momentum
|
To jump to the conclusion immediately, the "momentum" does not change the fact that the normal distribution is an asymptotic approximation of the distribution of the random walk, but the variance changes from $4np(1-p)$ to $np/(1-p)$. This can be derived by relatively elementary considerations in this special case. It is not awfully difficult to generalize the arguments below to a CLT for finite state space Markov chains, say, but the biggest problem is actually the computation of the variance. For the particular problem it can be computed, and hopefully the arguments below can convince the reader that it is the correct variance.
Using the insight that Cardinal provides in a comment, the random walk is given as
$$S_n = \sum_{k=1}^n X_k$$
where $X_k \in \{-1, 1\}$ and the $X_k$'s form a Markov chain with transition probability matrix
$$
\left(\begin{array}{cc}
p & 1-p \\
1-p & p
\end{array}\right).
$$
For asymptotic considerations when $n \to \infty$ the initial distribution of $X_1$ plays no role, so lets fix $X_1 = 1$ for the sake of the following argument, and assume also that $0 < p < 1$. A slick technique is to decompose the Markov chain into independent cycles. Let $\sigma_1$ denote the first time, after time 1, that the Markov chain returns to 1. That is, if $X_2 = 1$ then $\sigma_1 = 2$, and if $X_2 = X_3 = -1$ and $X_4 = 1$ then $\sigma_1 = 4$. In general, let $\sigma_i$ denote the $i$'th return time to 1 and let $\tau_i = \sigma_i - \sigma_{i-1}$ denote the inter-return times (with $\sigma_0 = 1$). With these definitions, we have
With $U_i = \sum_{k = \sigma_{i-1}+1}^{\sigma_i} X_k$ then
$$S_{\sigma_n} = X_1 + \sum_{i=1}^n U_i.$$
Since $X_k$ takes the value $-1$ for $k = \sigma_{i-1}+1, \ldots, \sigma_{i}-1$ and $X_{\sigma_i} = 1$ it holds that
$$U_i = 2 - \tau_i.$$
The inter-return times, $\tau_i$, for a Markov chain are i.i.d. (formally due to the strong Markov property) and in this case with mean $E(\tau_i) = 2$ and variance $V(\tau_i) = 2\frac{p}{1-p}$. It is indicated how to compute the mean and variance below.
The ordinary CLT for i.i.d. variables yields that
$$S_{\sigma_n} \overset{\text{asymp}}{\sim} N\left(0, \frac{2np}{1-p}\right).$$
The final thing to note, which requires a small leap of faith, because I leave out the details, is that $\sigma_n = 1 + \sum_{i=1}^n \tau_i \sim 2n$, which yields that
$$S_{n} \overset{\text{asymp}}{\sim} N\left(0, \frac{np}{1-p}\right).$$
To compute the moments of $\tau_1$ one may note that $P(\tau_1 = 1) = p$ and for $m \geq 2$, $P(\tau_1 = m) = (1-p)^2p^{m-2}$. Then techniques similar to those used when computing moments for the geometric distribution may be applied. Alternatively, if $X$ is geometric with success probability $1-p$ and $Z = 1(\tau_1 = 1)$ then $1 + X(1-Z)$ has the same distribution as $\tau_1$, and it is easy to compute the mean and variance for this latter representation.
|
Random walk with momentum
|
To jump to the conclusion immediately, the "momentum" does not change the fact that the normal distribution is an asymptotic approximation of the distribution of the random walk, but the variance chan
|
Random walk with momentum
To jump to the conclusion immediately, the "momentum" does not change the fact that the normal distribution is an asymptotic approximation of the distribution of the random walk, but the variance changes from $4np(1-p)$ to $np/(1-p)$. This can be derived by relatively elementary considerations in this special case. It is not awfully difficult to generalize the arguments below to a CLT for finite state space Markov chains, say, but the biggest problem is actually the computation of the variance. For the particular problem it can be computed, and hopefully the arguments below can convince the reader that it is the correct variance.
Using the insight that Cardinal provides in a comment, the random walk is given as
$$S_n = \sum_{k=1}^n X_k$$
where $X_k \in \{-1, 1\}$ and the $X_k$'s form a Markov chain with transition probability matrix
$$
\left(\begin{array}{cc}
p & 1-p \\
1-p & p
\end{array}\right).
$$
For asymptotic considerations when $n \to \infty$ the initial distribution of $X_1$ plays no role, so lets fix $X_1 = 1$ for the sake of the following argument, and assume also that $0 < p < 1$. A slick technique is to decompose the Markov chain into independent cycles. Let $\sigma_1$ denote the first time, after time 1, that the Markov chain returns to 1. That is, if $X_2 = 1$ then $\sigma_1 = 2$, and if $X_2 = X_3 = -1$ and $X_4 = 1$ then $\sigma_1 = 4$. In general, let $\sigma_i$ denote the $i$'th return time to 1 and let $\tau_i = \sigma_i - \sigma_{i-1}$ denote the inter-return times (with $\sigma_0 = 1$). With these definitions, we have
With $U_i = \sum_{k = \sigma_{i-1}+1}^{\sigma_i} X_k$ then
$$S_{\sigma_n} = X_1 + \sum_{i=1}^n U_i.$$
Since $X_k$ takes the value $-1$ for $k = \sigma_{i-1}+1, \ldots, \sigma_{i}-1$ and $X_{\sigma_i} = 1$ it holds that
$$U_i = 2 - \tau_i.$$
The inter-return times, $\tau_i$, for a Markov chain are i.i.d. (formally due to the strong Markov property) and in this case with mean $E(\tau_i) = 2$ and variance $V(\tau_i) = 2\frac{p}{1-p}$. It is indicated how to compute the mean and variance below.
The ordinary CLT for i.i.d. variables yields that
$$S_{\sigma_n} \overset{\text{asymp}}{\sim} N\left(0, \frac{2np}{1-p}\right).$$
The final thing to note, which requires a small leap of faith, because I leave out the details, is that $\sigma_n = 1 + \sum_{i=1}^n \tau_i \sim 2n$, which yields that
$$S_{n} \overset{\text{asymp}}{\sim} N\left(0, \frac{np}{1-p}\right).$$
To compute the moments of $\tau_1$ one may note that $P(\tau_1 = 1) = p$ and for $m \geq 2$, $P(\tau_1 = m) = (1-p)^2p^{m-2}$. Then techniques similar to those used when computing moments for the geometric distribution may be applied. Alternatively, if $X$ is geometric with success probability $1-p$ and $Z = 1(\tau_1 = 1)$ then $1 + X(1-Z)$ has the same distribution as $\tau_1$, and it is easy to compute the mean and variance for this latter representation.
|
Random walk with momentum
To jump to the conclusion immediately, the "momentum" does not change the fact that the normal distribution is an asymptotic approximation of the distribution of the random walk, but the variance chan
|
15,893
|
Random walk with momentum
|
Van Belle's 'Rule of Thumb' 8.7 (from the second edition of his book) includes an approximation for the standard error of the mean when innovations have autocorrelation $\rho$. Translating this using $\rho = 2p - 1$ gives
$$\mbox{True standard error of }\bar{x} \approx \sqrt{\frac{p}{1-p}}\frac{s}{\sqrt{n}},$$
where $n \bar{x}$ is the position of the random walk after $n$ steps, and $s$ is the sample standard deviation (which will be, asymptotically in $n$, $\sqrt{1 - \bar{x}^2}$. The upshot is that I expect, as a rough approximation, that the standard deviation of $n \bar{x}$ should be around $\sqrt{n p/(1-p)}$.
edit: I had the wrong autocorrelation (or rather $p$ should have been interpreted differently); is now consistent (I hope!)
|
Random walk with momentum
|
Van Belle's 'Rule of Thumb' 8.7 (from the second edition of his book) includes an approximation for the standard error of the mean when innovations have autocorrelation $\rho$. Translating this using
|
Random walk with momentum
Van Belle's 'Rule of Thumb' 8.7 (from the second edition of his book) includes an approximation for the standard error of the mean when innovations have autocorrelation $\rho$. Translating this using $\rho = 2p - 1$ gives
$$\mbox{True standard error of }\bar{x} \approx \sqrt{\frac{p}{1-p}}\frac{s}{\sqrt{n}},$$
where $n \bar{x}$ is the position of the random walk after $n$ steps, and $s$ is the sample standard deviation (which will be, asymptotically in $n$, $\sqrt{1 - \bar{x}^2}$. The upshot is that I expect, as a rough approximation, that the standard deviation of $n \bar{x}$ should be around $\sqrt{n p/(1-p)}$.
edit: I had the wrong autocorrelation (or rather $p$ should have been interpreted differently); is now consistent (I hope!)
|
Random walk with momentum
Van Belle's 'Rule of Thumb' 8.7 (from the second edition of his book) includes an approximation for the standard error of the mean when innovations have autocorrelation $\rho$. Translating this using
|
15,894
|
For classification with Random Forests in R, how should one adjust for imbalanced class sizes?
|
If you don't like those options, have you considered using a boosting method instead? Given an appropriate loss function, boosting automatically recalibrates the weights as it goes along. If the stochastic nature of random forests appeals to you, stochastic gradient boosting builds that in as well.
|
For classification with Random Forests in R, how should one adjust for imbalanced class sizes?
|
If you don't like those options, have you considered using a boosting method instead? Given an appropriate loss function, boosting automatically recalibrates the weights as it goes along. If the stoch
|
For classification with Random Forests in R, how should one adjust for imbalanced class sizes?
If you don't like those options, have you considered using a boosting method instead? Given an appropriate loss function, boosting automatically recalibrates the weights as it goes along. If the stochastic nature of random forests appeals to you, stochastic gradient boosting builds that in as well.
|
For classification with Random Forests in R, how should one adjust for imbalanced class sizes?
If you don't like those options, have you considered using a boosting method instead? Given an appropriate loss function, boosting automatically recalibrates the weights as it goes along. If the stoch
|
15,895
|
For classification with Random Forests in R, how should one adjust for imbalanced class sizes?
|
I think that weighting objects is somehow equivalent to duplicating them. Maybe you should try modifying the bootstrap step by sampling appropriately your different classes.
Another thought is that class imbalance may shift your decision threshold to another value than $0.5$ (if it's a binary classification problem). Try considering ROC curves and AUC to evaluate how bad the imbalance is causing poor performances on your models.
|
For classification with Random Forests in R, how should one adjust for imbalanced class sizes?
|
I think that weighting objects is somehow equivalent to duplicating them. Maybe you should try modifying the bootstrap step by sampling appropriately your different classes.
Another thought is that cl
|
For classification with Random Forests in R, how should one adjust for imbalanced class sizes?
I think that weighting objects is somehow equivalent to duplicating them. Maybe you should try modifying the bootstrap step by sampling appropriately your different classes.
Another thought is that class imbalance may shift your decision threshold to another value than $0.5$ (if it's a binary classification problem). Try considering ROC curves and AUC to evaluate how bad the imbalance is causing poor performances on your models.
|
For classification with Random Forests in R, how should one adjust for imbalanced class sizes?
I think that weighting objects is somehow equivalent to duplicating them. Maybe you should try modifying the bootstrap step by sampling appropriately your different classes.
Another thought is that cl
|
15,896
|
For classification with Random Forests in R, how should one adjust for imbalanced class sizes?
|
The synthetic minority over-sampling (SMOTE) generates new observations of the minority class as random convex combinations of neighboring observations. The paper is here: https://bmcbioinformatics.biomedcentral.com/articles/10.1186/1471-2105-14-106
|
For classification with Random Forests in R, how should one adjust for imbalanced class sizes?
|
The synthetic minority over-sampling (SMOTE) generates new observations of the minority class as random convex combinations of neighboring observations. The paper is here: https://bmcbioinformatics.bi
|
For classification with Random Forests in R, how should one adjust for imbalanced class sizes?
The synthetic minority over-sampling (SMOTE) generates new observations of the minority class as random convex combinations of neighboring observations. The paper is here: https://bmcbioinformatics.biomedcentral.com/articles/10.1186/1471-2105-14-106
|
For classification with Random Forests in R, how should one adjust for imbalanced class sizes?
The synthetic minority over-sampling (SMOTE) generates new observations of the minority class as random convex combinations of neighboring observations. The paper is here: https://bmcbioinformatics.bi
|
15,897
|
For classification with Random Forests in R, how should one adjust for imbalanced class sizes?
|
Instead of sampling large classes you can expand small classes ! If large classes have many times more observation then small, then biase will be small. I do hope you can handle that supersized dataset.
You may also identify subsets of observations which handle the most information about large classes, there are many possible procedures, the simplest I think is based on nearest neighbors method - observation sampling conditioned on neighborhood graph structure guarantee that sample will have probability density more similar to original one.
randomForest is written in Fortran and c, source code is available (http://cran.r-project.org/src/contrib/randomForest_4.6-2.tar.gz) but I cant spot the place where enthropy is computed,
ps. ups that randomforest use Gini instead of enthropy
|
For classification with Random Forests in R, how should one adjust for imbalanced class sizes?
|
Instead of sampling large classes you can expand small classes ! If large classes have many times more observation then small, then biase will be small. I do hope you can handle that supersized datase
|
For classification with Random Forests in R, how should one adjust for imbalanced class sizes?
Instead of sampling large classes you can expand small classes ! If large classes have many times more observation then small, then biase will be small. I do hope you can handle that supersized dataset.
You may also identify subsets of observations which handle the most information about large classes, there are many possible procedures, the simplest I think is based on nearest neighbors method - observation sampling conditioned on neighborhood graph structure guarantee that sample will have probability density more similar to original one.
randomForest is written in Fortran and c, source code is available (http://cran.r-project.org/src/contrib/randomForest_4.6-2.tar.gz) but I cant spot the place where enthropy is computed,
ps. ups that randomforest use Gini instead of enthropy
|
For classification with Random Forests in R, how should one adjust for imbalanced class sizes?
Instead of sampling large classes you can expand small classes ! If large classes have many times more observation then small, then biase will be small. I do hope you can handle that supersized datase
|
15,898
|
For classification with Random Forests in R, how should one adjust for imbalanced class sizes?
|
(1) You're right the weighting function doesn't work and not sure if it has ever been fixed.
(2) Most use option 2 with balanced data. The key to not loosing too much data is stratified sampling. You randomly sample a unique balanced set for each tree.
|
For classification with Random Forests in R, how should one adjust for imbalanced class sizes?
|
(1) You're right the weighting function doesn't work and not sure if it has ever been fixed.
(2) Most use option 2 with balanced data. The key to not loosing too much data is stratified sampling. You
|
For classification with Random Forests in R, how should one adjust for imbalanced class sizes?
(1) You're right the weighting function doesn't work and not sure if it has ever been fixed.
(2) Most use option 2 with balanced data. The key to not loosing too much data is stratified sampling. You randomly sample a unique balanced set for each tree.
|
For classification with Random Forests in R, how should one adjust for imbalanced class sizes?
(1) You're right the weighting function doesn't work and not sure if it has ever been fixed.
(2) Most use option 2 with balanced data. The key to not loosing too much data is stratified sampling. You
|
15,899
|
Why a sufficient statistic contains all the information needed to compute any estimate of the parameter?
|
Following the comments of @whuber and @Kamster, I probably got a better understanding. When we say that a sufficient statistic contains all the information needed to compute any estimate of the parameter, what we actually mean is that it is enough to compute the maximum likelihood estimator (which is a function of all sufficient statistics).
Given that I am answering my own question, and so I am not 100% sure of the answer, I will not mark it as correct until I get some feedback. Please add any comment and down-vote if you think I am being wrong/imprecise/etc...
(Let me know if this is not compatible with SE etiquette, being this my first question I beg your clemency if I am violating any rule)
|
Why a sufficient statistic contains all the information needed to compute any estimate of the parame
|
Following the comments of @whuber and @Kamster, I probably got a better understanding. When we say that a sufficient statistic contains all the information needed to compute any estimate of the parame
|
Why a sufficient statistic contains all the information needed to compute any estimate of the parameter?
Following the comments of @whuber and @Kamster, I probably got a better understanding. When we say that a sufficient statistic contains all the information needed to compute any estimate of the parameter, what we actually mean is that it is enough to compute the maximum likelihood estimator (which is a function of all sufficient statistics).
Given that I am answering my own question, and so I am not 100% sure of the answer, I will not mark it as correct until I get some feedback. Please add any comment and down-vote if you think I am being wrong/imprecise/etc...
(Let me know if this is not compatible with SE etiquette, being this my first question I beg your clemency if I am violating any rule)
|
Why a sufficient statistic contains all the information needed to compute any estimate of the parame
Following the comments of @whuber and @Kamster, I probably got a better understanding. When we say that a sufficient statistic contains all the information needed to compute any estimate of the parame
|
15,900
|
Why a sufficient statistic contains all the information needed to compute any estimate of the parameter?
|
As I was studying about sufficiency I came across your question because I also wanted to understand the intuition about From what I've gathered this is what I come up with (let me know what you think, if I made any mistakes, etc).
Let $X_1,\ldots,X_n$ be a random sample from a Poisson distribution with mean $\theta>0$.
We know that $T({\bf{X}})=\sum_{i=1}^{n} X_i$ is a sufficient statistic for $\theta$, since the conditional distribution of $X_1,\ldots,X_n$ given $T({\bf{X}})$ is free of $\theta$, in other words, does not depend on $\theta$.
Now, statistician $A$ knows that $X_1,\ldots,X_n \overset{i.i.d}{\sim} Poisson(4)$ and creates $n=400$ random values from this distribution:
n <- 400
theta <- 4
set.seed(1234)
x <- rpois(n, theta)
y=sum(x)
freq.x <- table(x) # We will use this latter on
rel.freq.x <- freq.x/sum(freq.x)
For the values statistician $A$ has created, he takes the sum of it and asks statistician $B$ the following:
"I have these sample values $x_1,\ldots,x_n$ taken from a Poisson distribution. Knowing that $\sum_{i=1}^{n} x_i = y = 4068$, what can you tell me about this distribution?"
So, knowing only that $\sum_{i=1}^{n} x_i = y = 4068$ (and the fact that the sample arose from a Poisson distribution) is sufficient for statistician $B$ to say anything about $\theta$? Since we know that this is a sufficient statistic we know that the answer is "yes".
To gain some intuition about the meaning of this, let's do the following (taken from Hogg & Mckean & Craig's "Introduction to Mathematical Statistics", 7th edition, exercise 7.1.9):
"$B$ decides to create some fake observations, which he calls $z_1,z_2,\ldots,z_n$ (as he knows they will probably not be equal the original $x$-values) as follows. He notes that the conditional probability of independent Poisson random variables $Z_1,Z_2\ldots,Z_n$ being equal to $z_1,z_2,\ldots,z_n$, given $\sum z_i = y$, is
$$\cfrac{\frac{\theta^{z_1}e^{-\theta}}{z_1!} \frac{\theta^{z_2}e^{-\theta}}{z_2!} \cdots \frac{\theta^{z_n}e^{-\theta}}{z_n!}}{\frac{n \theta^{y}e^{-n\theta}}{y!}}=\frac{y!}{z_1!z_2! \cdots z_n!} \left(\frac{1}{n}\right)^{z_1} \left(\frac{1}{n}\right)^{z_2} \cdots \left(\frac{1}{n}\right)^{z_n}$$
since $Y=\sum Z_i$ has a Poisson distribution with mean $n \theta$. The latter distribution is multinomial with $y$ independent trials, each terminating in one of $n$ mutually exclusive and exhaustive ways, each of which has the same probability $1/n$. Accordingly, $B$ runs such a multinomial experiment $y$ independent trials and obtains $z_1,\ldots,z_n$."
This is what the exercise states. So, let's do exactly that:
# Fake observations from multinomial experiment
prob <- rep(1/n, n)
set.seed(1234)
z <- as.numeric(t(rmultinom(y, n=c(1:n), prob)))
y.fake <- sum(z) # y and y.fake must be equal
freq.z <- table(z)
rel.freq.z <- freq.z/sum(freq.z)
And let's see what $Z$ looks like (I'm also plotting the real density of Poisson(4) for $k=0,1,\ldots,13$ - anything above 13 is pratically zero -, for comparison):
# Verifying distributions
k <- 13
plot(x=c(0:k), y=dpois(c(0:k), lambda=theta,
log = FALSE),t="o",ylab="Probability",xlab="k",
xlim=c(0,k), ylim=c(0, max(c(rel.freq.x, rel.freq.z))))
lines(rel.freq.z, t="o", col="green", pch=4)
legend(8,0.2, legend=c("Real Poisson", "Random Z given y"),
col = c("black", "green"), pch=c(1,4))
So, knowing nothing about $\theta$ and knowing only the sufficient statistic $Y=\sum X_i$ we were able to recreate a "distribution" that looks a lot like a Poisson(4) distribution (as $n$ increases, the two curves become more similar).
Now, comparing $X$ and $Z|y$:
plot(rel.freq.x, t="o", pch=16, col="red",
ylab="Relative Frequency", xlab="k",
ylim=c(0, max(c(rel.freq.x, rel.freq.z))))
lines(rel.freq.z, t="o", col="green", pch=4)
legend(7, 0.2, legend=c("Random X", "Random Z given y"),
col = c("red", "green"), pch=c(16,4))
We see that they are pretty similar, as well (as expected)
So, "for the purpose of making a statistical decision, we can ignore the individual random variables $X_i$ and base the decision entirely on the $Y=X_1+X_2+\cdots+X_n$" (Ash, R. "Statistical Inference: A concise course", page 59).
|
Why a sufficient statistic contains all the information needed to compute any estimate of the parame
|
As I was studying about sufficiency I came across your question because I also wanted to understand the intuition about From what I've gathered this is what I come up with (let me know what you think,
|
Why a sufficient statistic contains all the information needed to compute any estimate of the parameter?
As I was studying about sufficiency I came across your question because I also wanted to understand the intuition about From what I've gathered this is what I come up with (let me know what you think, if I made any mistakes, etc).
Let $X_1,\ldots,X_n$ be a random sample from a Poisson distribution with mean $\theta>0$.
We know that $T({\bf{X}})=\sum_{i=1}^{n} X_i$ is a sufficient statistic for $\theta$, since the conditional distribution of $X_1,\ldots,X_n$ given $T({\bf{X}})$ is free of $\theta$, in other words, does not depend on $\theta$.
Now, statistician $A$ knows that $X_1,\ldots,X_n \overset{i.i.d}{\sim} Poisson(4)$ and creates $n=400$ random values from this distribution:
n <- 400
theta <- 4
set.seed(1234)
x <- rpois(n, theta)
y=sum(x)
freq.x <- table(x) # We will use this latter on
rel.freq.x <- freq.x/sum(freq.x)
For the values statistician $A$ has created, he takes the sum of it and asks statistician $B$ the following:
"I have these sample values $x_1,\ldots,x_n$ taken from a Poisson distribution. Knowing that $\sum_{i=1}^{n} x_i = y = 4068$, what can you tell me about this distribution?"
So, knowing only that $\sum_{i=1}^{n} x_i = y = 4068$ (and the fact that the sample arose from a Poisson distribution) is sufficient for statistician $B$ to say anything about $\theta$? Since we know that this is a sufficient statistic we know that the answer is "yes".
To gain some intuition about the meaning of this, let's do the following (taken from Hogg & Mckean & Craig's "Introduction to Mathematical Statistics", 7th edition, exercise 7.1.9):
"$B$ decides to create some fake observations, which he calls $z_1,z_2,\ldots,z_n$ (as he knows they will probably not be equal the original $x$-values) as follows. He notes that the conditional probability of independent Poisson random variables $Z_1,Z_2\ldots,Z_n$ being equal to $z_1,z_2,\ldots,z_n$, given $\sum z_i = y$, is
$$\cfrac{\frac{\theta^{z_1}e^{-\theta}}{z_1!} \frac{\theta^{z_2}e^{-\theta}}{z_2!} \cdots \frac{\theta^{z_n}e^{-\theta}}{z_n!}}{\frac{n \theta^{y}e^{-n\theta}}{y!}}=\frac{y!}{z_1!z_2! \cdots z_n!} \left(\frac{1}{n}\right)^{z_1} \left(\frac{1}{n}\right)^{z_2} \cdots \left(\frac{1}{n}\right)^{z_n}$$
since $Y=\sum Z_i$ has a Poisson distribution with mean $n \theta$. The latter distribution is multinomial with $y$ independent trials, each terminating in one of $n$ mutually exclusive and exhaustive ways, each of which has the same probability $1/n$. Accordingly, $B$ runs such a multinomial experiment $y$ independent trials and obtains $z_1,\ldots,z_n$."
This is what the exercise states. So, let's do exactly that:
# Fake observations from multinomial experiment
prob <- rep(1/n, n)
set.seed(1234)
z <- as.numeric(t(rmultinom(y, n=c(1:n), prob)))
y.fake <- sum(z) # y and y.fake must be equal
freq.z <- table(z)
rel.freq.z <- freq.z/sum(freq.z)
And let's see what $Z$ looks like (I'm also plotting the real density of Poisson(4) for $k=0,1,\ldots,13$ - anything above 13 is pratically zero -, for comparison):
# Verifying distributions
k <- 13
plot(x=c(0:k), y=dpois(c(0:k), lambda=theta,
log = FALSE),t="o",ylab="Probability",xlab="k",
xlim=c(0,k), ylim=c(0, max(c(rel.freq.x, rel.freq.z))))
lines(rel.freq.z, t="o", col="green", pch=4)
legend(8,0.2, legend=c("Real Poisson", "Random Z given y"),
col = c("black", "green"), pch=c(1,4))
So, knowing nothing about $\theta$ and knowing only the sufficient statistic $Y=\sum X_i$ we were able to recreate a "distribution" that looks a lot like a Poisson(4) distribution (as $n$ increases, the two curves become more similar).
Now, comparing $X$ and $Z|y$:
plot(rel.freq.x, t="o", pch=16, col="red",
ylab="Relative Frequency", xlab="k",
ylim=c(0, max(c(rel.freq.x, rel.freq.z))))
lines(rel.freq.z, t="o", col="green", pch=4)
legend(7, 0.2, legend=c("Random X", "Random Z given y"),
col = c("red", "green"), pch=c(16,4))
We see that they are pretty similar, as well (as expected)
So, "for the purpose of making a statistical decision, we can ignore the individual random variables $X_i$ and base the decision entirely on the $Y=X_1+X_2+\cdots+X_n$" (Ash, R. "Statistical Inference: A concise course", page 59).
|
Why a sufficient statistic contains all the information needed to compute any estimate of the parame
As I was studying about sufficiency I came across your question because I also wanted to understand the intuition about From what I've gathered this is what I come up with (let me know what you think,
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.