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
|
|---|---|---|---|---|---|---|
47,301
|
Algorithm and R code for dealing with ties in Wilcoxon rank-sum test
|
The Streitberg-Röhmel shift algorithm is described in two manuscripts:
Streitberg B, Röhmel J (1986). "Exact Distributions for Permutation and Rank Tests: An Introduction to Some Recently Published Algorithms." Statistical Software Newsletter, 12(1), 10-17. ISSN 1609-3631.
Streitberg B, Röhmel J (1987). "Exakte Verteilungen für Rang- und Randomisierungstests im allgemeinen c-Stichprobenfall." EDV in Medizin und Biologie, 18(1), 12-19.
Both are not exactly mainstream journals and one manuscript is in German...which explains why this algorithm is less well-known than the network algorithm by Mehta & Patel underlying their proprietary StatXact software.
The Streitberg-Röhmel shift algorithm (and Van de Wiel's split-up algorithm) are implemented in the R package coin for conditional inference. See:
Hothorn T, Hornik K, Van de Wiel MA, Zeileis A (2006). "A Lego System for Conditional Inference". The American Statistician, 60(3), 257-263.
Hothorn T, Hornik K, Van de Wiel MA, Zeileis A (2008). "Implementing a Class of Permutation Tests: The coin Package." Journal of Statistical Software, 28(8), 1-23.
The R code for the Streitberg-Röhmel algorithm is contained in the file coin/R/ExactDistributions.R in the coin source package, available from CRAN.
|
Algorithm and R code for dealing with ties in Wilcoxon rank-sum test
|
The Streitberg-Röhmel shift algorithm is described in two manuscripts:
Streitberg B, Röhmel J (1986). "Exact Distributions for Permutation and Rank Tests: An Introduction to Some Recently Published A
|
Algorithm and R code for dealing with ties in Wilcoxon rank-sum test
The Streitberg-Röhmel shift algorithm is described in two manuscripts:
Streitberg B, Röhmel J (1986). "Exact Distributions for Permutation and Rank Tests: An Introduction to Some Recently Published Algorithms." Statistical Software Newsletter, 12(1), 10-17. ISSN 1609-3631.
Streitberg B, Röhmel J (1987). "Exakte Verteilungen für Rang- und Randomisierungstests im allgemeinen c-Stichprobenfall." EDV in Medizin und Biologie, 18(1), 12-19.
Both are not exactly mainstream journals and one manuscript is in German...which explains why this algorithm is less well-known than the network algorithm by Mehta & Patel underlying their proprietary StatXact software.
The Streitberg-Röhmel shift algorithm (and Van de Wiel's split-up algorithm) are implemented in the R package coin for conditional inference. See:
Hothorn T, Hornik K, Van de Wiel MA, Zeileis A (2006). "A Lego System for Conditional Inference". The American Statistician, 60(3), 257-263.
Hothorn T, Hornik K, Van de Wiel MA, Zeileis A (2008). "Implementing a Class of Permutation Tests: The coin Package." Journal of Statistical Software, 28(8), 1-23.
The R code for the Streitberg-Röhmel algorithm is contained in the file coin/R/ExactDistributions.R in the coin source package, available from CRAN.
|
Algorithm and R code for dealing with ties in Wilcoxon rank-sum test
The Streitberg-Röhmel shift algorithm is described in two manuscripts:
Streitberg B, Röhmel J (1986). "Exact Distributions for Permutation and Rank Tests: An Introduction to Some Recently Published A
|
47,302
|
Algorithm and R code for dealing with ties in Wilcoxon rank-sum test
|
Actually, on this website you can find an implemented version of the Wilcoxon Rank-Sum test which provides the exact solution for data that involves ties and also for data without ties. In addition, quite big sample sizes can be solved (at the moment $A, B \le 200$).
(The reference is Marx, A.; Backes, C.; Meese, E.; Lenhof, H. P.; and Keller, A.; EDISON-WMW: Exact Dynamic Programming Solution of the Wilcoxon-Mann-Whitney Test. Genomics Proteomics Bioinformatics, 14(1): 55--61. Feb 2016.)
The algorithm behind the code uses dynamic programming to do a complete search and enumerate efficiently all subproblems to be able to calculate the exact p-value without any approximations or corrections.
|
Algorithm and R code for dealing with ties in Wilcoxon rank-sum test
|
Actually, on this website you can find an implemented version of the Wilcoxon Rank-Sum test which provides the exact solution for data that involves ties and also for data without ties. In addition, q
|
Algorithm and R code for dealing with ties in Wilcoxon rank-sum test
Actually, on this website you can find an implemented version of the Wilcoxon Rank-Sum test which provides the exact solution for data that involves ties and also for data without ties. In addition, quite big sample sizes can be solved (at the moment $A, B \le 200$).
(The reference is Marx, A.; Backes, C.; Meese, E.; Lenhof, H. P.; and Keller, A.; EDISON-WMW: Exact Dynamic Programming Solution of the Wilcoxon-Mann-Whitney Test. Genomics Proteomics Bioinformatics, 14(1): 55--61. Feb 2016.)
The algorithm behind the code uses dynamic programming to do a complete search and enumerate efficiently all subproblems to be able to calculate the exact p-value without any approximations or corrections.
|
Algorithm and R code for dealing with ties in Wilcoxon rank-sum test
Actually, on this website you can find an implemented version of the Wilcoxon Rank-Sum test which provides the exact solution for data that involves ties and also for data without ties. In addition, q
|
47,303
|
software library to compute KL divergence?
|
I ended up coding KL divergences and derivatives myself in Julia. I've released it as part of an existing open source project. Future readers may find the code at this page of the Celeste.jl project.
|
software library to compute KL divergence?
|
I ended up coding KL divergences and derivatives myself in Julia. I've released it as part of an existing open source project. Future readers may find the code at this page of the Celeste.jl project.
|
software library to compute KL divergence?
I ended up coding KL divergences and derivatives myself in Julia. I've released it as part of an existing open source project. Future readers may find the code at this page of the Celeste.jl project.
|
software library to compute KL divergence?
I ended up coding KL divergences and derivatives myself in Julia. I've released it as part of an existing open source project. Future readers may find the code at this page of the Celeste.jl project.
|
47,304
|
software library to compute KL divergence?
|
It's great that you came up with the solution (+1). I meant to post an answer to this question much earlier, but was busy traveling to my dissertation defense (which was successful :-). You are likely to be happy with your solution, but, in addition to possibility to compute KL divergences for certain distributions in R, for example, via function KLdiv from flexmix package (http://www.inside-r.org/packages/cran/flexmix/docs/KLdiv), I ran across another and, in my opinion, much better option, which might be of your interest.
It is a very comprehensive piece of autonomous open source software, relevant to the topic, called Information Theoretical Estimators (ITE) Toolbox. It is written in MATLAB/Octave and supports various information theoretic measures. So, sending thanks and kudos to the author of this software, I'm excited to share it here and hope that it will useful to you and the community.
|
software library to compute KL divergence?
|
It's great that you came up with the solution (+1). I meant to post an answer to this question much earlier, but was busy traveling to my dissertation defense (which was successful :-). You are likely
|
software library to compute KL divergence?
It's great that you came up with the solution (+1). I meant to post an answer to this question much earlier, but was busy traveling to my dissertation defense (which was successful :-). You are likely to be happy with your solution, but, in addition to possibility to compute KL divergences for certain distributions in R, for example, via function KLdiv from flexmix package (http://www.inside-r.org/packages/cran/flexmix/docs/KLdiv), I ran across another and, in my opinion, much better option, which might be of your interest.
It is a very comprehensive piece of autonomous open source software, relevant to the topic, called Information Theoretical Estimators (ITE) Toolbox. It is written in MATLAB/Octave and supports various information theoretic measures. So, sending thanks and kudos to the author of this software, I'm excited to share it here and hope that it will useful to you and the community.
|
software library to compute KL divergence?
It's great that you came up with the solution (+1). I meant to post an answer to this question much earlier, but was busy traveling to my dissertation defense (which was successful :-). You are likely
|
47,305
|
Is dimensionality reduction almost always useful for classification?
|
I think there are two ways to look at the question whether SVD/PCA helps in general.
Is it better to use PCA reduced data instead of the raw data?
Often yes, but there are situations where PCA is not needed.
I'd in addition consider how well the bilinear concept behind PCA fits with the data generation process. I work with linear spectroscopy, which is governed by physical laws that mean that my observed spectra $\mathbf X$ are linear combinations of the spectra $\mathbf S$ of the chemical species I have, weighted by their respective concentrations $c$: $\mathbf X = \mathbf C \mathbf S$.This fits very well with the PCA model of scores $\mathbf T$ and loadings $\mathbf P$: $\mathbf X = \mathbf T \mathbf P$
I don't know of any example where PCA has hurt a model (except gross errors in setting up a combined PCA-whaterver model)
Even if the underlying relationship in your data doesn't suit that well to the bilinear approach of PCA, PCA in the first place is only a rotation of your data which would usually not hurt. Discarding higher PCs leads to the dimension reduction, but due to set up of the PCA, they carry only small amounts of variance - so again, chances are that even if it is not all that suitable, it won't hurt that much, neither.
This is also part of the bias-variance trade-off in the context of PCA as regularization technique (see @usεr11852's anwer).
Is it better to use PCA instead of some other dimension reduction technique?
The answer on this will be application specific. But if your application suggests some other way of feature generation, these features may be far more powerful than some PCs, so this is worth considering.
Again, my data and applications happen to be of a nature where PCA is a rather natural fit, so I use it and I cannot contribute a counter-example.
But: having a PCA hammer does not imply that all problems are nails...
Looking for counterexamples, I'd start maybe image analyses where objects in question can appear anywhere in the picture. The people I know who deal with such tasks usually develop specialized features.
The only task I routinely have that comes close to this is detecting cosmic ray spikes in my camera signals (sharp peaks somewhere caused by cosmic rays hitting the CCD). I also use specialized filters to detect them, although they are easy to find after PCA as well. However, we describe that rather as PCA not being robust against spikes and find it disturbing.
|
Is dimensionality reduction almost always useful for classification?
|
I think there are two ways to look at the question whether SVD/PCA helps in general.
Is it better to use PCA reduced data instead of the raw data?
Often yes, but there are situations where PCA is not
|
Is dimensionality reduction almost always useful for classification?
I think there are two ways to look at the question whether SVD/PCA helps in general.
Is it better to use PCA reduced data instead of the raw data?
Often yes, but there are situations where PCA is not needed.
I'd in addition consider how well the bilinear concept behind PCA fits with the data generation process. I work with linear spectroscopy, which is governed by physical laws that mean that my observed spectra $\mathbf X$ are linear combinations of the spectra $\mathbf S$ of the chemical species I have, weighted by their respective concentrations $c$: $\mathbf X = \mathbf C \mathbf S$.This fits very well with the PCA model of scores $\mathbf T$ and loadings $\mathbf P$: $\mathbf X = \mathbf T \mathbf P$
I don't know of any example where PCA has hurt a model (except gross errors in setting up a combined PCA-whaterver model)
Even if the underlying relationship in your data doesn't suit that well to the bilinear approach of PCA, PCA in the first place is only a rotation of your data which would usually not hurt. Discarding higher PCs leads to the dimension reduction, but due to set up of the PCA, they carry only small amounts of variance - so again, chances are that even if it is not all that suitable, it won't hurt that much, neither.
This is also part of the bias-variance trade-off in the context of PCA as regularization technique (see @usεr11852's anwer).
Is it better to use PCA instead of some other dimension reduction technique?
The answer on this will be application specific. But if your application suggests some other way of feature generation, these features may be far more powerful than some PCs, so this is worth considering.
Again, my data and applications happen to be of a nature where PCA is a rather natural fit, so I use it and I cannot contribute a counter-example.
But: having a PCA hammer does not imply that all problems are nails...
Looking for counterexamples, I'd start maybe image analyses where objects in question can appear anywhere in the picture. The people I know who deal with such tasks usually develop specialized features.
The only task I routinely have that comes close to this is detecting cosmic ray spikes in my camera signals (sharp peaks somewhere caused by cosmic rays hitting the CCD). I also use specialized filters to detect them, although they are easy to find after PCA as well. However, we describe that rather as PCA not being robust against spikes and find it disturbing.
|
Is dimensionality reduction almost always useful for classification?
I think there are two ways to look at the question whether SVD/PCA helps in general.
Is it better to use PCA reduced data instead of the raw data?
Often yes, but there are situations where PCA is not
|
47,306
|
Is dimensionality reduction almost always useful for classification?
|
Your intuition is correct. Performing a singular value decomposition in order to use the derived scores in a classifier has a positive influence in a classifier's overall performance in most cases. That is because through SVD one will effectively regularise and/or filter out modes of irrelevant variation (aka. noise). Nevertheless there is no theoretical guarantee that a mode of variation that almost perfectly classifies the data you examine, is not excluded if you decide to choose a particular number of $k$ eigenvectors.
For your example in particular taking around 300 modes of orthogonal variation is most probably enough. Note though that especially if you work in situations where the number of features $p$ is massively larger than the number of available samples $n$ taking an arbitrary number $k$ might give you a false sense of security. There are particular methods (eg. LASSO, SCAD, etc.) that deal with data in that regime. As @ttnphns mentioned @amoeba's answer on How can top k principal components retain the predictive power on a dependent variable? is very good. Do not be driven away by the fact that it focuses on regression. Regression is ultimately an infinite dimensional classification (or in bins of machine precision width if you like :) ).
As for real datasets: I haven't not seen any but I suspect that semantic corpora (Latent Semantic Analysis $\approx$ SVD for texts) might exhibit this behaviour. There might be a relatively invariant small word that in TF-IDF terms scores pretty low - like the word US. Such a term could be probably filtered out in favour of other more dominant terms.
Finally, as mentioned if you want to draw some further conclusions from your classifier using principal modes of variations scores might be detrimental to your model's interpretability. You will be dealing with axes that correspond to normalized linear combinations of your original variables. It might not be trivial to associate them with something tangible in your original sample space.
|
Is dimensionality reduction almost always useful for classification?
|
Your intuition is correct. Performing a singular value decomposition in order to use the derived scores in a classifier has a positive influence in a classifier's overall performance in most cases. Th
|
Is dimensionality reduction almost always useful for classification?
Your intuition is correct. Performing a singular value decomposition in order to use the derived scores in a classifier has a positive influence in a classifier's overall performance in most cases. That is because through SVD one will effectively regularise and/or filter out modes of irrelevant variation (aka. noise). Nevertheless there is no theoretical guarantee that a mode of variation that almost perfectly classifies the data you examine, is not excluded if you decide to choose a particular number of $k$ eigenvectors.
For your example in particular taking around 300 modes of orthogonal variation is most probably enough. Note though that especially if you work in situations where the number of features $p$ is massively larger than the number of available samples $n$ taking an arbitrary number $k$ might give you a false sense of security. There are particular methods (eg. LASSO, SCAD, etc.) that deal with data in that regime. As @ttnphns mentioned @amoeba's answer on How can top k principal components retain the predictive power on a dependent variable? is very good. Do not be driven away by the fact that it focuses on regression. Regression is ultimately an infinite dimensional classification (or in bins of machine precision width if you like :) ).
As for real datasets: I haven't not seen any but I suspect that semantic corpora (Latent Semantic Analysis $\approx$ SVD for texts) might exhibit this behaviour. There might be a relatively invariant small word that in TF-IDF terms scores pretty low - like the word US. Such a term could be probably filtered out in favour of other more dominant terms.
Finally, as mentioned if you want to draw some further conclusions from your classifier using principal modes of variations scores might be detrimental to your model's interpretability. You will be dealing with axes that correspond to normalized linear combinations of your original variables. It might not be trivial to associate them with something tangible in your original sample space.
|
Is dimensionality reduction almost always useful for classification?
Your intuition is correct. Performing a singular value decomposition in order to use the derived scores in a classifier has a positive influence in a classifier's overall performance in most cases. Th
|
47,307
|
A continuous generalization of the binary bandit
|
Disclosure: I know almost nothing about bandits. Still, my suggestion seems like a natuaral generalization of the case you presented. It does not consider the experimental design step in detail (since I don't know what people ususally consider as a loss function in this scenario), so might fail in this respect.
Let me ignore the fact that we have two web pages. You have a web page and your prior for "profit per call" (denoted $\theta$) is (say) Gaussian- $p(\theta) = (2\pi)^{-\frac{1}{2}} \exp( -\frac{\theta^2}{2})$. Lets also say that you believe that if you know the average profit per view, your gains are distributed according to another normal $X \sim \mathcal{N}(\theta, 1)$. Then you have a valid (and very simple) bayesian model.
Now, use the same model for both web pages. After observing $n$ (potential) clients' reactions, you have the distributions for the posterior of $A$ and $B$ which are both Gaussian. Based on whatever target you choose for the experimental design step, you can choose which web page to present next. Calculating and differentiating the target should not be too hard, since we know how to integrate Gaussians.
|
A continuous generalization of the binary bandit
|
Disclosure: I know almost nothing about bandits. Still, my suggestion seems like a natuaral generalization of the case you presented. It does not consider the experimental design step in detail (since
|
A continuous generalization of the binary bandit
Disclosure: I know almost nothing about bandits. Still, my suggestion seems like a natuaral generalization of the case you presented. It does not consider the experimental design step in detail (since I don't know what people ususally consider as a loss function in this scenario), so might fail in this respect.
Let me ignore the fact that we have two web pages. You have a web page and your prior for "profit per call" (denoted $\theta$) is (say) Gaussian- $p(\theta) = (2\pi)^{-\frac{1}{2}} \exp( -\frac{\theta^2}{2})$. Lets also say that you believe that if you know the average profit per view, your gains are distributed according to another normal $X \sim \mathcal{N}(\theta, 1)$. Then you have a valid (and very simple) bayesian model.
Now, use the same model for both web pages. After observing $n$ (potential) clients' reactions, you have the distributions for the posterior of $A$ and $B$ which are both Gaussian. Based on whatever target you choose for the experimental design step, you can choose which web page to present next. Calculating and differentiating the target should not be too hard, since we know how to integrate Gaussians.
|
A continuous generalization of the binary bandit
Disclosure: I know almost nothing about bandits. Still, my suggestion seems like a natuaral generalization of the case you presented. It does not consider the experimental design step in detail (since
|
47,308
|
A continuous generalization of the binary bandit
|
This problem is tackled by the Dearden paper on Bayesian Q-Learning. He considers a normal model for "returns" (future rewards) like @yair's solution. He also considers another term called the "value of information": "the expected improvement in future decision quality that might arise from the information acquired by exploration."
Also, FYI Beta(0, 0) is not "uninformative". The Jeffreys prior is Beta(0.5, 0.5).
Dearden, Richard, Nir Friedman, and Stuart Russell. "Bayesian Q-learning." AAAI/IAAI. 1998.
|
A continuous generalization of the binary bandit
|
This problem is tackled by the Dearden paper on Bayesian Q-Learning. He considers a normal model for "returns" (future rewards) like @yair's solution. He also considers another term called the "valu
|
A continuous generalization of the binary bandit
This problem is tackled by the Dearden paper on Bayesian Q-Learning. He considers a normal model for "returns" (future rewards) like @yair's solution. He also considers another term called the "value of information": "the expected improvement in future decision quality that might arise from the information acquired by exploration."
Also, FYI Beta(0, 0) is not "uninformative". The Jeffreys prior is Beta(0.5, 0.5).
Dearden, Richard, Nir Friedman, and Stuart Russell. "Bayesian Q-learning." AAAI/IAAI. 1998.
|
A continuous generalization of the binary bandit
This problem is tackled by the Dearden paper on Bayesian Q-Learning. He considers a normal model for "returns" (future rewards) like @yair's solution. He also considers another term called the "valu
|
47,309
|
Nonlinear total least squares / Deming regression in R
|
There is a technique called "Orthogonal Distance Regression" that does this. An implementation in R was recently released:
http://www.r-bloggers.com/introducing-orthogonal-nonlinear-least-squares-regression-in-r/
|
Nonlinear total least squares / Deming regression in R
|
There is a technique called "Orthogonal Distance Regression" that does this. An implementation in R was recently released:
http://www.r-bloggers.com/introducing-orthogonal-nonlinear-least-squares-re
|
Nonlinear total least squares / Deming regression in R
There is a technique called "Orthogonal Distance Regression" that does this. An implementation in R was recently released:
http://www.r-bloggers.com/introducing-orthogonal-nonlinear-least-squares-regression-in-r/
|
Nonlinear total least squares / Deming regression in R
There is a technique called "Orthogonal Distance Regression" that does this. An implementation in R was recently released:
http://www.r-bloggers.com/introducing-orthogonal-nonlinear-least-squares-re
|
47,310
|
Are different p-values for chi-squared and z test expected for testing difference in proportions?
|
Very simple: both the z test and the contingency table $\chi^{2}$ test are two tailed tests, but you have got the one-sided $p$-value for your z test statistic. That is for $H_{0}: p_{1} - p_{2} = 0$, the $p$-value = $P(|Z| \ge |z|)$, but your reported $p$-value is only $P(Z \le z)$.
Notice that $0.4013 \times 2 \approx 0.8025$. Easy!
|
Are different p-values for chi-squared and z test expected for testing difference in proportions?
|
Very simple: both the z test and the contingency table $\chi^{2}$ test are two tailed tests, but you have got the one-sided $p$-value for your z test statistic. That is for $H_{0}: p_{1} - p_{2} = 0$,
|
Are different p-values for chi-squared and z test expected for testing difference in proportions?
Very simple: both the z test and the contingency table $\chi^{2}$ test are two tailed tests, but you have got the one-sided $p$-value for your z test statistic. That is for $H_{0}: p_{1} - p_{2} = 0$, the $p$-value = $P(|Z| \ge |z|)$, but your reported $p$-value is only $P(Z \le z)$.
Notice that $0.4013 \times 2 \approx 0.8025$. Easy!
|
Are different p-values for chi-squared and z test expected for testing difference in proportions?
Very simple: both the z test and the contingency table $\chi^{2}$ test are two tailed tests, but you have got the one-sided $p$-value for your z test statistic. That is for $H_{0}: p_{1} - p_{2} = 0$,
|
47,311
|
Can I use Kolmogorov Smirnov test to check if my data are uniformly distributed?
|
The Kolmogorov-Smirnov test can be used to test with a null of any fully specified continuous distribution.
Since the statistic is only a function of the largest difference in cdf, if you use a probability integral transform on the data, that won't change the test statistic but turns it into a test against uniformity.
The top plot shows the situation in a test for normality, the bottom plot shows a test for standard uniform on transformed data. The distance, (D, marked in blue) is the same given any monotonic transformation of the x-axis.
So every KS test will be exactly the same as if you were doing a test of uniformity -- i.e. it's distribution-free -- as long as the distribution is continuous and fully specified (no parameters to estimate), it doesn't matter what the distribution is, the test works exactly the same.
So uniform, normal, gamma, beta, Cauchy, logistic, Student t, or whatever else you like.
(If the distribution is not fully specified - i.e. if you don't know one or more parameters, then it's not actually a Kolmogorov-Smirnov test, but a Lilliefors test*, and no longer distribution free, though in the case of uniformity there's a neat trick which could be used to take it back to a fully specified distribution.)
* Lilliefors himself did the normal and exponential cases
--
In respect of your title, there's nothing that will tell you your data are from a uniformly distributed population -- but a goodness of fit test may tell you that they aren't.
|
Can I use Kolmogorov Smirnov test to check if my data are uniformly distributed?
|
The Kolmogorov-Smirnov test can be used to test with a null of any fully specified continuous distribution.
Since the statistic is only a function of the largest difference in cdf, if you use a probab
|
Can I use Kolmogorov Smirnov test to check if my data are uniformly distributed?
The Kolmogorov-Smirnov test can be used to test with a null of any fully specified continuous distribution.
Since the statistic is only a function of the largest difference in cdf, if you use a probability integral transform on the data, that won't change the test statistic but turns it into a test against uniformity.
The top plot shows the situation in a test for normality, the bottom plot shows a test for standard uniform on transformed data. The distance, (D, marked in blue) is the same given any monotonic transformation of the x-axis.
So every KS test will be exactly the same as if you were doing a test of uniformity -- i.e. it's distribution-free -- as long as the distribution is continuous and fully specified (no parameters to estimate), it doesn't matter what the distribution is, the test works exactly the same.
So uniform, normal, gamma, beta, Cauchy, logistic, Student t, or whatever else you like.
(If the distribution is not fully specified - i.e. if you don't know one or more parameters, then it's not actually a Kolmogorov-Smirnov test, but a Lilliefors test*, and no longer distribution free, though in the case of uniformity there's a neat trick which could be used to take it back to a fully specified distribution.)
* Lilliefors himself did the normal and exponential cases
--
In respect of your title, there's nothing that will tell you your data are from a uniformly distributed population -- but a goodness of fit test may tell you that they aren't.
|
Can I use Kolmogorov Smirnov test to check if my data are uniformly distributed?
The Kolmogorov-Smirnov test can be used to test with a null of any fully specified continuous distribution.
Since the statistic is only a function of the largest difference in cdf, if you use a probab
|
47,312
|
Comparing two means using permutation test and bootstrapping with the boot() function in R
|
While permutations tests, randomization tests and bootstrapping all fall under the class of resampling procedures, they differ in some important ways.
In particular, a permutation test differs in several respects from bootstrapping; you seem to think they're the same thing.
Some of these differences will make it essentially impossible to use bootstrapping to do a permutation test.
a "full" permutation test doesn't actually sample at all. Every data point reappears in every possible sample re-arrangement of the group labels, and it uses every one of the sample combinations that the randomization test samples from; the complete permutation distribution of the test statistc is computed. In practice that's only possible with fairly small samples - or with use of clever algorithms, often to middling sort of sample sizes (dozens of observations, even more in some cases).
You could sample the permutation distribution (which some authors call a randomization test, though other authors use that term to mean something a little different). This involves a form of sampling the data without replacement, in the sense that every observation appears (in possibly some modified form) in each resample. However, these (re)arrangements of the original sample themselves are sampled with replacement from the collection of possible arrangements of the group labels that the complete permutation test uses (as described below)
bootstrapping involves sampling the data with replacement. Some observations in a typical bootstrap sample will occur more than once, others will not be present. On average about 62% recur in a given sample.
Bootstrapping has different assumptions and properties from this approach to randomization testing.
Here's how you'd do a full permutation test of the situation you describe:
a. for every possible allocation of 25 "beer" labels and 18 "water" labels to the 43 observations of the response variable, compute the beer-mean minus the water mean.
b. find the proportion of such allocations (out of the $6.08\times 10^{11}$ combinations just calculated) that have the absolute value of the mean at least as far from 0 as your sample data. That's your exact p-value for the permutation test
Here's how you'd do a resampled permutation test (/randomization test) of it:
a. for some large number of replications, choose allocations at random from the set of possible label-rearrangements discussed in 1 and compute the difference in means (sampling with replacement).
b. add your sample into the set. Find the proportion of sampled allocations that have the absolute value of the mean at least as far from 0 as your sample data. That's your simulated p-value for the randomization test. As you sample more, the uncertainty in the p-value goes down. You can estimate the standard error of the p-value estimate since it's a binomial proportion.
Here's one way you could do a bootstrap test of that (glossing over some of the details in the interest of brevity):
a. Repeat many times: sample with replacement from the "beer" group to get a 'beer' pseudosample. Sample with replacement from the "water" group to get a 'water' pseudosample.
b. use the distribution of the difference in pseudosample means to construct a confidence interval for the difference in means (several methods are discussed in chapter 5 of Davison & Hinkley). If that CI doesn't include 0, conclude that the difference in means is different from 0.
Here's another simple way:
a. resample both groups as in 3a and take the difference. Subtract the difference in the original sample means. (repeated many times; this produces a resampled distribution of differences that has the "shape" as that which results from treating the ecdf like a population distribution but where the mean population difference matches the case under the null)
b. Find where the sample difference in means occurs in this distribution (computing the relevant p value accordingly).
(Davison & Hinkley describe better but more complicated one sample bootstrap test than this - e.g. the studentized bootstrap in Section 4.4.1 of their book. They mention several other possible bootstrap tests for this situation, including one very like a resampled permutation test, but where sampling is with replacement.)
The easy way to do a resampled permutation test (/randomization) test in R isn't to use the boot function at all, but to use the sample function, since that draws without replacement.
Short of reading Davison and Hinkley, you might try these resources on bootstrapping and R:
Ajay Shah's introduction
Quick R on the bootstrap
John Fox's appendix chapter on the bootstrap
Canty's discussion of the boot package
Davison and Kuonen on bootstrap applications in R
|
Comparing two means using permutation test and bootstrapping with the boot() function in R
|
While permutations tests, randomization tests and bootstrapping all fall under the class of resampling procedures, they differ in some important ways.
In particular, a permutation test differs in seve
|
Comparing two means using permutation test and bootstrapping with the boot() function in R
While permutations tests, randomization tests and bootstrapping all fall under the class of resampling procedures, they differ in some important ways.
In particular, a permutation test differs in several respects from bootstrapping; you seem to think they're the same thing.
Some of these differences will make it essentially impossible to use bootstrapping to do a permutation test.
a "full" permutation test doesn't actually sample at all. Every data point reappears in every possible sample re-arrangement of the group labels, and it uses every one of the sample combinations that the randomization test samples from; the complete permutation distribution of the test statistc is computed. In practice that's only possible with fairly small samples - or with use of clever algorithms, often to middling sort of sample sizes (dozens of observations, even more in some cases).
You could sample the permutation distribution (which some authors call a randomization test, though other authors use that term to mean something a little different). This involves a form of sampling the data without replacement, in the sense that every observation appears (in possibly some modified form) in each resample. However, these (re)arrangements of the original sample themselves are sampled with replacement from the collection of possible arrangements of the group labels that the complete permutation test uses (as described below)
bootstrapping involves sampling the data with replacement. Some observations in a typical bootstrap sample will occur more than once, others will not be present. On average about 62% recur in a given sample.
Bootstrapping has different assumptions and properties from this approach to randomization testing.
Here's how you'd do a full permutation test of the situation you describe:
a. for every possible allocation of 25 "beer" labels and 18 "water" labels to the 43 observations of the response variable, compute the beer-mean minus the water mean.
b. find the proportion of such allocations (out of the $6.08\times 10^{11}$ combinations just calculated) that have the absolute value of the mean at least as far from 0 as your sample data. That's your exact p-value for the permutation test
Here's how you'd do a resampled permutation test (/randomization test) of it:
a. for some large number of replications, choose allocations at random from the set of possible label-rearrangements discussed in 1 and compute the difference in means (sampling with replacement).
b. add your sample into the set. Find the proportion of sampled allocations that have the absolute value of the mean at least as far from 0 as your sample data. That's your simulated p-value for the randomization test. As you sample more, the uncertainty in the p-value goes down. You can estimate the standard error of the p-value estimate since it's a binomial proportion.
Here's one way you could do a bootstrap test of that (glossing over some of the details in the interest of brevity):
a. Repeat many times: sample with replacement from the "beer" group to get a 'beer' pseudosample. Sample with replacement from the "water" group to get a 'water' pseudosample.
b. use the distribution of the difference in pseudosample means to construct a confidence interval for the difference in means (several methods are discussed in chapter 5 of Davison & Hinkley). If that CI doesn't include 0, conclude that the difference in means is different from 0.
Here's another simple way:
a. resample both groups as in 3a and take the difference. Subtract the difference in the original sample means. (repeated many times; this produces a resampled distribution of differences that has the "shape" as that which results from treating the ecdf like a population distribution but where the mean population difference matches the case under the null)
b. Find where the sample difference in means occurs in this distribution (computing the relevant p value accordingly).
(Davison & Hinkley describe better but more complicated one sample bootstrap test than this - e.g. the studentized bootstrap in Section 4.4.1 of their book. They mention several other possible bootstrap tests for this situation, including one very like a resampled permutation test, but where sampling is with replacement.)
The easy way to do a resampled permutation test (/randomization) test in R isn't to use the boot function at all, but to use the sample function, since that draws without replacement.
Short of reading Davison and Hinkley, you might try these resources on bootstrapping and R:
Ajay Shah's introduction
Quick R on the bootstrap
John Fox's appendix chapter on the bootstrap
Canty's discussion of the boot package
Davison and Kuonen on bootstrap applications in R
|
Comparing two means using permutation test and bootstrapping with the boot() function in R
While permutations tests, randomization tests and bootstrapping all fall under the class of resampling procedures, they differ in some important ways.
In particular, a permutation test differs in seve
|
47,313
|
Why are inf and sup used in the definition of minimax estimators?
|
It is possible that the set of values $R(\theta,\hat{\delta})$ is an open set. Therefore, supremum/infimum is more general than maximum/minimum. Suppose, $ \{R(\theta,\hat{\delta}): \theta \in \Theta\}=\{x: 0<x<1\}$ where $\Theta$ is the parameter space. This has no maximum, but it has a supremum of 1.
|
Why are inf and sup used in the definition of minimax estimators?
|
It is possible that the set of values $R(\theta,\hat{\delta})$ is an open set. Therefore, supremum/infimum is more general than maximum/minimum. Suppose, $ \{R(\theta,\hat{\delta}): \theta \in \Theta\
|
Why are inf and sup used in the definition of minimax estimators?
It is possible that the set of values $R(\theta,\hat{\delta})$ is an open set. Therefore, supremum/infimum is more general than maximum/minimum. Suppose, $ \{R(\theta,\hat{\delta}): \theta \in \Theta\}=\{x: 0<x<1\}$ where $\Theta$ is the parameter space. This has no maximum, but it has a supremum of 1.
|
Why are inf and sup used in the definition of minimax estimators?
It is possible that the set of values $R(\theta,\hat{\delta})$ is an open set. Therefore, supremum/infimum is more general than maximum/minimum. Suppose, $ \{R(\theta,\hat{\delta}): \theta \in \Theta\
|
47,314
|
How to convert sport odds into percentage?
|
The odds you have are in decimal format, which the bookmaker calculates as:
$$
d_E = \frac{1}{p_E + o_E}
$$
where $d_E$ is the decimal odds for event $E$, $p_E$ is the bookmakers estimated probability of event $E$, and $o_E$ is the over-round which the bookmaker adds to the decimal odds for event $E$. The over-round effectively reduces the odds, making them unfair for the bettor.
In your example, with events $H$ (home win), $D$ (draw), and $A$ (away win), you have:
$$
\frac{1}{d_H} + \frac{1}{d_D} + \frac{1}{d_A} = (p_H + p_D + p_A) + (o_H + o_D + o_A) = 1.04
$$
of course, $p_H + p_D + p_A = 1$. One option is assuming $o_H = o_D = o_A = o$ so you have $1 + 3o = 1.04$ and so $o = 0.04/3$, which you can use to uncover the bookmaker's underlying probabilities, $p_H$, $p_D$, and $p_A$. In practice however, there is no way of knowing how the bookmaker adds over-round onto betting events, it is likely they add more over-round to events which are more likely to be bet, for example a UK bookmaker's odds on England to win the World Cup.
|
How to convert sport odds into percentage?
|
The odds you have are in decimal format, which the bookmaker calculates as:
$$
d_E = \frac{1}{p_E + o_E}
$$
where $d_E$ is the decimal odds for event $E$, $p_E$ is the bookmakers estimated probability
|
How to convert sport odds into percentage?
The odds you have are in decimal format, which the bookmaker calculates as:
$$
d_E = \frac{1}{p_E + o_E}
$$
where $d_E$ is the decimal odds for event $E$, $p_E$ is the bookmakers estimated probability of event $E$, and $o_E$ is the over-round which the bookmaker adds to the decimal odds for event $E$. The over-round effectively reduces the odds, making them unfair for the bettor.
In your example, with events $H$ (home win), $D$ (draw), and $A$ (away win), you have:
$$
\frac{1}{d_H} + \frac{1}{d_D} + \frac{1}{d_A} = (p_H + p_D + p_A) + (o_H + o_D + o_A) = 1.04
$$
of course, $p_H + p_D + p_A = 1$. One option is assuming $o_H = o_D = o_A = o$ so you have $1 + 3o = 1.04$ and so $o = 0.04/3$, which you can use to uncover the bookmaker's underlying probabilities, $p_H$, $p_D$, and $p_A$. In practice however, there is no way of knowing how the bookmaker adds over-round onto betting events, it is likely they add more over-round to events which are more likely to be bet, for example a UK bookmaker's odds on England to win the World Cup.
|
How to convert sport odds into percentage?
The odds you have are in decimal format, which the bookmaker calculates as:
$$
d_E = \frac{1}{p_E + o_E}
$$
where $d_E$ is the decimal odds for event $E$, $p_E$ is the bookmakers estimated probability
|
47,315
|
How to convert sport odds into percentage?
|
If the odds describe real events, you most likely got them from some betting site.
You are searching for overround. If your implied probabilities do not add up to 1 but are greater 1, then the bookmaker makes a sure profit of all above 1.
A simple way to work is to re-normalize, i.e. divide every inverse odd again by the sum, 1.04 in your example.
|
How to convert sport odds into percentage?
|
If the odds describe real events, you most likely got them from some betting site.
You are searching for overround. If your implied probabilities do not add up to 1 but are greater 1, then the bookmak
|
How to convert sport odds into percentage?
If the odds describe real events, you most likely got them from some betting site.
You are searching for overround. If your implied probabilities do not add up to 1 but are greater 1, then the bookmaker makes a sure profit of all above 1.
A simple way to work is to re-normalize, i.e. divide every inverse odd again by the sum, 1.04 in your example.
|
How to convert sport odds into percentage?
If the odds describe real events, you most likely got them from some betting site.
You are searching for overround. If your implied probabilities do not add up to 1 but are greater 1, then the bookmak
|
47,316
|
How to convert sport odds into percentage?
|
If you just want to estimate the probabilities, it seems indeed reasonable to just devide each percentage by 1.04.
However, if you want to find out more about the true percentages that the bookkeeper uses, you can do something more.
Let's assume that the bookkeeper does not want to accept a negative expected value for any of his bets
Now we can conclude the following:
40, 31 and 33 are upper bounds for the underlying true percentages.
40-4, 31-4 and 33-4 are lower bounds for the underlying true percentages (otherwise one of the other two odds would give him a negative expected value)
40+31-4, 31+33-4 and 40+33-4 are lower bounds for the underlying true percentages of a pair of possible outcomes (otherwise the other odd would give him a negative expected value)
Sidenote: I expect a bookkeeper to especially pad bets with a high risk factor, so if it would be 60% vs 40% vs 4%, it would be safe to say that the 4% contains relatively much padding.
|
How to convert sport odds into percentage?
|
If you just want to estimate the probabilities, it seems indeed reasonable to just devide each percentage by 1.04.
However, if you want to find out more about the true percentages that the bookkeeper
|
How to convert sport odds into percentage?
If you just want to estimate the probabilities, it seems indeed reasonable to just devide each percentage by 1.04.
However, if you want to find out more about the true percentages that the bookkeeper uses, you can do something more.
Let's assume that the bookkeeper does not want to accept a negative expected value for any of his bets
Now we can conclude the following:
40, 31 and 33 are upper bounds for the underlying true percentages.
40-4, 31-4 and 33-4 are lower bounds for the underlying true percentages (otherwise one of the other two odds would give him a negative expected value)
40+31-4, 31+33-4 and 40+33-4 are lower bounds for the underlying true percentages of a pair of possible outcomes (otherwise the other odd would give him a negative expected value)
Sidenote: I expect a bookkeeper to especially pad bets with a high risk factor, so if it would be 60% vs 40% vs 4%, it would be safe to say that the 4% contains relatively much padding.
|
How to convert sport odds into percentage?
If you just want to estimate the probabilities, it seems indeed reasonable to just devide each percentage by 1.04.
However, if you want to find out more about the true percentages that the bookkeeper
|
47,317
|
How to convert sport odds into percentage?
|
I think they are odds against. i.e.
2.5 = (Prob(away team wins) + Prob(draw)) / Prob (Home team wins)
You can compute P(Away team wins) + Prob(draw) by taking 1/(2.5+1).
If you do that for all 3, you can P(W) = 0.285, P(D) = 0.235, P(L) = 0.25.
They do not sum up to 1, probably because the odds are rigged. But you can easily normalise them
i.e. P*(W) = P(W) / P(W) + P(D) + P(L) = 0.37
|
How to convert sport odds into percentage?
|
I think they are odds against. i.e.
2.5 = (Prob(away team wins) + Prob(draw)) / Prob (Home team wins)
You can compute P(Away team wins) + Prob(draw) by taking 1/(2.5+1).
If you do that for all 3, you
|
How to convert sport odds into percentage?
I think they are odds against. i.e.
2.5 = (Prob(away team wins) + Prob(draw)) / Prob (Home team wins)
You can compute P(Away team wins) + Prob(draw) by taking 1/(2.5+1).
If you do that for all 3, you can P(W) = 0.285, P(D) = 0.235, P(L) = 0.25.
They do not sum up to 1, probably because the odds are rigged. But you can easily normalise them
i.e. P*(W) = P(W) / P(W) + P(D) + P(L) = 0.37
|
How to convert sport odds into percentage?
I think they are odds against. i.e.
2.5 = (Prob(away team wins) + Prob(draw)) / Prob (Home team wins)
You can compute P(Away team wins) + Prob(draw) by taking 1/(2.5+1).
If you do that for all 3, you
|
47,318
|
How to convert sport odds into percentage?
|
There is a major issue with the odds that are offered in this scenario. Where did they come from?
Suppose I bet \$1 on the home team. With odds of 2.5, I would win \$2.50 and get my \$1 back, for a collection of \$3.50. So, let's look at the chart below:
Winner - Odds - Payback on $1
Home - 2.5 - $3.5
Draw - 3.25 - $4.25
Away - 3.00 - $3.00
Therefore, I can bet \$3 (\$1 on each), and have a positive return. Therefore, there is no way this is odds from a bookmaker, which is why I wonder where the odds come from?
|
How to convert sport odds into percentage?
|
There is a major issue with the odds that are offered in this scenario. Where did they come from?
Suppose I bet \$1 on the home team. With odds of 2.5, I would win \$2.50 and get my \$1 back, for a
|
How to convert sport odds into percentage?
There is a major issue with the odds that are offered in this scenario. Where did they come from?
Suppose I bet \$1 on the home team. With odds of 2.5, I would win \$2.50 and get my \$1 back, for a collection of \$3.50. So, let's look at the chart below:
Winner - Odds - Payback on $1
Home - 2.5 - $3.5
Draw - 3.25 - $4.25
Away - 3.00 - $3.00
Therefore, I can bet \$3 (\$1 on each), and have a positive return. Therefore, there is no way this is odds from a bookmaker, which is why I wonder where the odds come from?
|
How to convert sport odds into percentage?
There is a major issue with the odds that are offered in this scenario. Where did they come from?
Suppose I bet \$1 on the home team. With odds of 2.5, I would win \$2.50 and get my \$1 back, for a
|
47,319
|
Derivative of $x^T A^Ty$ with respect to $\Sigma$ where $A$ is (an upper triangle matrix and ) Cholesky decomposition of $\Sigma$
|
By the chain rule,
$\frac{\partial x^{T}A^{T}y}{\partial \Sigma_{i,j}}=
\mbox{tr} \left( \left( \frac{\partial x^{T}A^{T}y}{\partial A^{T}} \right)^{T} \frac{\partial A^{T}}{\partial \Sigma_{i,j} } \right) $.
This chain rule formulation is described in many references on matrix calculus, such as The Matrix Cookbook of Petersen and Pedersen.
The first partial derivative is easy:
$ \frac{\partial x^{T}A^{T}y}{\partial A^{T}}=xy^{T}$.
You can find a useful formula for the derivative of the Cholesky factor with respect to elements of $\Sigma$ on page 211 of Bayesian Filter and Smoothing by Simo Sarkka
(Note that the book uses $P=AA^{T}$ rather than $\Sigma=A^{T}A$, so the notation is complicated. I've transposed everything in the book to match the notation used in your statement of the problem.) After the change of notation, this formula gives:
$\frac{\partial A^{T}}{\partial \Sigma_{i,j}}=A^{T} \Phi \left(A^{-T} E_{i,j} A^{-1} \right) $
where $\Phi_{k,l}(M)=M_{k,l}$ if $k>l$, $\Phi_{k,l}(M)=M_{k,l}/2$ if $k=l$, and $\Phi_{k,l}(M)=0$ if $k<l$. This is basically the lower triangle of the matrix but with the diagonal divided by 2. $E_{i,j}$ is the zero matrix with one's in the $(i,j)$ and $(j,i)$ positions.
I can't see any particular way to simplify this further.
I have tested this in MATLAB by comparing the formula against a finite difference approximation and the results match up.
|
Derivative of $x^T A^Ty$ with respect to $\Sigma$ where $A$ is (an upper triangle matrix and ) Chole
|
By the chain rule,
$\frac{\partial x^{T}A^{T}y}{\partial \Sigma_{i,j}}=
\mbox{tr} \left( \left( \frac{\partial x^{T}A^{T}y}{\partial A^{T}} \right)^{T} \frac{\partial A^{T}}{\partial \Sigma_{i,j} } \
|
Derivative of $x^T A^Ty$ with respect to $\Sigma$ where $A$ is (an upper triangle matrix and ) Cholesky decomposition of $\Sigma$
By the chain rule,
$\frac{\partial x^{T}A^{T}y}{\partial \Sigma_{i,j}}=
\mbox{tr} \left( \left( \frac{\partial x^{T}A^{T}y}{\partial A^{T}} \right)^{T} \frac{\partial A^{T}}{\partial \Sigma_{i,j} } \right) $.
This chain rule formulation is described in many references on matrix calculus, such as The Matrix Cookbook of Petersen and Pedersen.
The first partial derivative is easy:
$ \frac{\partial x^{T}A^{T}y}{\partial A^{T}}=xy^{T}$.
You can find a useful formula for the derivative of the Cholesky factor with respect to elements of $\Sigma$ on page 211 of Bayesian Filter and Smoothing by Simo Sarkka
(Note that the book uses $P=AA^{T}$ rather than $\Sigma=A^{T}A$, so the notation is complicated. I've transposed everything in the book to match the notation used in your statement of the problem.) After the change of notation, this formula gives:
$\frac{\partial A^{T}}{\partial \Sigma_{i,j}}=A^{T} \Phi \left(A^{-T} E_{i,j} A^{-1} \right) $
where $\Phi_{k,l}(M)=M_{k,l}$ if $k>l$, $\Phi_{k,l}(M)=M_{k,l}/2$ if $k=l$, and $\Phi_{k,l}(M)=0$ if $k<l$. This is basically the lower triangle of the matrix but with the diagonal divided by 2. $E_{i,j}$ is the zero matrix with one's in the $(i,j)$ and $(j,i)$ positions.
I can't see any particular way to simplify this further.
I have tested this in MATLAB by comparing the formula against a finite difference approximation and the results match up.
|
Derivative of $x^T A^Ty$ with respect to $\Sigma$ where $A$ is (an upper triangle matrix and ) Chole
By the chain rule,
$\frac{\partial x^{T}A^{T}y}{\partial \Sigma_{i,j}}=
\mbox{tr} \left( \left( \frac{\partial x^{T}A^{T}y}{\partial A^{T}} \right)^{T} \frac{\partial A^{T}}{\partial \Sigma_{i,j} } \
|
47,320
|
Why doesn't a non-linear kernel improve accuracy in high dimensions compared to a linear kernel?
|
The motivation to use kernel functions is to map the data onto a (typically higher dimensional) feature space in which it is easier to separate the data linearly. If the input space is high dimensional, the data is typically already (nearly) separable, so there is no need to map to an even higher dimensional feature space.
In theory, the best possible model you can obtain with an RBF kernel is at least as good as the best possible linear model. In practice, the improvement offered by nonlinear kernels is often not worth the extra computational effort.
|
Why doesn't a non-linear kernel improve accuracy in high dimensions compared to a linear kernel?
|
The motivation to use kernel functions is to map the data onto a (typically higher dimensional) feature space in which it is easier to separate the data linearly. If the input space is high dimensiona
|
Why doesn't a non-linear kernel improve accuracy in high dimensions compared to a linear kernel?
The motivation to use kernel functions is to map the data onto a (typically higher dimensional) feature space in which it is easier to separate the data linearly. If the input space is high dimensional, the data is typically already (nearly) separable, so there is no need to map to an even higher dimensional feature space.
In theory, the best possible model you can obtain with an RBF kernel is at least as good as the best possible linear model. In practice, the improvement offered by nonlinear kernels is often not worth the extra computational effort.
|
Why doesn't a non-linear kernel improve accuracy in high dimensions compared to a linear kernel?
The motivation to use kernel functions is to map the data onto a (typically higher dimensional) feature space in which it is easier to separate the data linearly. If the input space is high dimensiona
|
47,321
|
Why does Slice sampler use the log of the density?
|
The slice sampler does not "sample from the log-density". It can, however, use the log density in the calculations to obtain a dependent sequence of observations from the density.
The basic idea of a slice sampler is in terms of the density itself, but for various reasons (computational accuracy, primarily) it's usually more convenient to work with the log-density.
As long as you use do everything in such a way as to be completely consistent with doing it in terms of the density, there's no problem whatever working with the log density.
The description for the univariate case in wikipedia here says:
Given a sample $x$ we choose $y$ uniformly at random from the interval $[0, f(x)]$;
given $y$ we choose $x$ uniformly at random from the set $f^{-1}[y, +\infty)$.
The sample of $x$ is obtained by ignoring the $y$ values.
That first step can for example be replaced by sampling from a negative exponential distribution in $-\log y$ where the lower bound of the exponential is at $-\log(f(x))$; the rest of the algorithm (with the obvious change to accommodate the fact that we have a log scale $y$) proceeds much as before. The result is exactly as if we had accurately sampled according to the original algorithm, which is cast in terms of sampling uniformly under the density itself at $x$ ... but in practice the calculation on the log-scale does that job "better"- with less accuracy loss.
Neal explains the motivation for this quite clearly in the Annals paper you included a reference for (p712):
In practice, it is often safer to compute
$g(x)=\log(f(x))$ rather than $f(x)$ itself, in order to avoid possible problems with floating-point underflow. One can
then use the auxiliary variable
$z=\log(y)=g(x_0)−e$, where
$e$ is exponentially distributed with mean one, and define the slice by $S={x:z<g(x)}$.
|
Why does Slice sampler use the log of the density?
|
The slice sampler does not "sample from the log-density". It can, however, use the log density in the calculations to obtain a dependent sequence of observations from the density.
The basic idea of a
|
Why does Slice sampler use the log of the density?
The slice sampler does not "sample from the log-density". It can, however, use the log density in the calculations to obtain a dependent sequence of observations from the density.
The basic idea of a slice sampler is in terms of the density itself, but for various reasons (computational accuracy, primarily) it's usually more convenient to work with the log-density.
As long as you use do everything in such a way as to be completely consistent with doing it in terms of the density, there's no problem whatever working with the log density.
The description for the univariate case in wikipedia here says:
Given a sample $x$ we choose $y$ uniformly at random from the interval $[0, f(x)]$;
given $y$ we choose $x$ uniformly at random from the set $f^{-1}[y, +\infty)$.
The sample of $x$ is obtained by ignoring the $y$ values.
That first step can for example be replaced by sampling from a negative exponential distribution in $-\log y$ where the lower bound of the exponential is at $-\log(f(x))$; the rest of the algorithm (with the obvious change to accommodate the fact that we have a log scale $y$) proceeds much as before. The result is exactly as if we had accurately sampled according to the original algorithm, which is cast in terms of sampling uniformly under the density itself at $x$ ... but in practice the calculation on the log-scale does that job "better"- with less accuracy loss.
Neal explains the motivation for this quite clearly in the Annals paper you included a reference for (p712):
In practice, it is often safer to compute
$g(x)=\log(f(x))$ rather than $f(x)$ itself, in order to avoid possible problems with floating-point underflow. One can
then use the auxiliary variable
$z=\log(y)=g(x_0)−e$, where
$e$ is exponentially distributed with mean one, and define the slice by $S={x:z<g(x)}$.
|
Why does Slice sampler use the log of the density?
The slice sampler does not "sample from the log-density". It can, however, use the log density in the calculations to obtain a dependent sequence of observations from the density.
The basic idea of a
|
47,322
|
The order of Data Centering and Data Transformation
|
If logarithms of predictors, generically $x$, are helpful, and centring variables on their mean is helpful, would it help to centre before transforming?
Once you have subtracted the mean from a variable, then necessarily at least one value is now negative and logarithms can't (usefully) be calculated (setting aside complex analysis).
Even if you discard the specific suggestion of $\log(x−$ mean of $x)$ on those grounds, the more general idea of transforming $(x−$ mean of $x)$ still
requires a transformation that will work with positive, zero and negative values; there are some (cube root, asinh, ...) but they won't usually help you in any situation in which logarithms are being contemplated seriously
implies that the mean of untransformed data is in some sense a natural or even a convenient origin for the transformed scale, which I think is usually not the case. So it's no go generally for your [1] in my view.
By all means, centre variables, transformed or not, in presenting regression results; it's the same regression and it's a matter of convenience how you explain it. So on your [2] I don't think it changes model interpretation at all; it's just convenience whether you write about centred results.
By the way, there is no "of course" about using $\log(x+1)$ even if $x \ge 0$. That's an ad hoc fudge that some people use, especially it seems in some branches of biology. But there is no standard or accepted logic to it.
|
The order of Data Centering and Data Transformation
|
If logarithms of predictors, generically $x$, are helpful, and centring variables on their mean is helpful, would it help to centre before transforming?
Once you have subtracted the mean from a varia
|
The order of Data Centering and Data Transformation
If logarithms of predictors, generically $x$, are helpful, and centring variables on their mean is helpful, would it help to centre before transforming?
Once you have subtracted the mean from a variable, then necessarily at least one value is now negative and logarithms can't (usefully) be calculated (setting aside complex analysis).
Even if you discard the specific suggestion of $\log(x−$ mean of $x)$ on those grounds, the more general idea of transforming $(x−$ mean of $x)$ still
requires a transformation that will work with positive, zero and negative values; there are some (cube root, asinh, ...) but they won't usually help you in any situation in which logarithms are being contemplated seriously
implies that the mean of untransformed data is in some sense a natural or even a convenient origin for the transformed scale, which I think is usually not the case. So it's no go generally for your [1] in my view.
By all means, centre variables, transformed or not, in presenting regression results; it's the same regression and it's a matter of convenience how you explain it. So on your [2] I don't think it changes model interpretation at all; it's just convenience whether you write about centred results.
By the way, there is no "of course" about using $\log(x+1)$ even if $x \ge 0$. That's an ad hoc fudge that some people use, especially it seems in some branches of biology. But there is no standard or accepted logic to it.
|
The order of Data Centering and Data Transformation
If logarithms of predictors, generically $x$, are helpful, and centring variables on their mean is helpful, would it help to centre before transforming?
Once you have subtracted the mean from a varia
|
47,323
|
The order of Data Centering and Data Transformation
|
This is not a question with a straightforward answer. There are deep issues involved.
If logarithm of a variable, say X, is improving the model, then X is an important variable itself as a "level". For example, stock prices are not important as levels (of course this is debatable), because they are recalculated after stock splits, whereas market capitalization of a company, or price of oil may be a level. That's why researchers are mostly using the price differences, or %changes (returns), of stock prices.
Another way of looking at it is to see whether the data generating process is stationary or not. If it is not, then mean centering is something very dubious as you expect the mean to be different for future unseen data points.
When level is not important and the variable is stationary, then you can mean center your variables. But I still personally don't like it. The reason is that when you are calculating the mean for each variable you are in fact estimating the mean. When you are estimating something it means there is an error (big or small). There are situations where the total error from estimating the means of several variables separately can be higher than when estimated together.
Then there is the concept of cointegration. Several variables may not be stationary individually but when combined in a certain way may yield a stationary signal. I don't know your data domain, but it seems to me your variable that you would like to log transform is important as a level, but the fact that you would like to mean center it tells me that there are other variables with a relative meaning to this variable. Maybe you have cointegrating variables.
|
The order of Data Centering and Data Transformation
|
This is not a question with a straightforward answer. There are deep issues involved.
If logarithm of a variable, say X, is improving the model, then X is an important variable itself as a "level". F
|
The order of Data Centering and Data Transformation
This is not a question with a straightforward answer. There are deep issues involved.
If logarithm of a variable, say X, is improving the model, then X is an important variable itself as a "level". For example, stock prices are not important as levels (of course this is debatable), because they are recalculated after stock splits, whereas market capitalization of a company, or price of oil may be a level. That's why researchers are mostly using the price differences, or %changes (returns), of stock prices.
Another way of looking at it is to see whether the data generating process is stationary or not. If it is not, then mean centering is something very dubious as you expect the mean to be different for future unseen data points.
When level is not important and the variable is stationary, then you can mean center your variables. But I still personally don't like it. The reason is that when you are calculating the mean for each variable you are in fact estimating the mean. When you are estimating something it means there is an error (big or small). There are situations where the total error from estimating the means of several variables separately can be higher than when estimated together.
Then there is the concept of cointegration. Several variables may not be stationary individually but when combined in a certain way may yield a stationary signal. I don't know your data domain, but it seems to me your variable that you would like to log transform is important as a level, but the fact that you would like to mean center it tells me that there are other variables with a relative meaning to this variable. Maybe you have cointegrating variables.
|
The order of Data Centering and Data Transformation
This is not a question with a straightforward answer. There are deep issues involved.
If logarithm of a variable, say X, is improving the model, then X is an important variable itself as a "level". F
|
47,324
|
Odds vs. Probabilities (Confusion)
|
A probability lies between 0 and 1; I presume you're familiar enough with it that we don't need to define probability, but please clarify if you do require a basic definition. [So if I say something like "The probability of at least two heads in three tosses of a coin is 1/2" or "the probability that I miss the bus tomorrow is 1/10" I presume the sense of what that means is already clear.]
Odds are the ratio of a probability (p) to its complement (1-p) ($\text{odds}=\frac{p}{1-p}$. In this case the odds for missing the bus would be $\frac{1/10}{9/10}=1/9$.
[In elementary situations where probability is "number of cases where the event holds"/"total cases", odds are "number of cases where the event holds"/"number of cases where it doesn't".]
[In gambling, odds are usually expression not as a fraction but as a literal ratio ("1:9 for" rather than $\frac{_1}{^9}$), and most usually in terms of odds against (the reciprocal of the ratio, "9:1 against"), unless the odds against fall below 1:1, in which case they're again written the first way around, as odds for and referred to as "odds on"); this keeps the larger number expressed first. If there's no adjective (on, for, against), as in "the odds are 20:1", you would normally assume odds against in gambling situations. You'd flip those around and write as a fraction -- $\frac{1}{20}$ to get odds as a statistician writes them. In some situations you will see odds defined differently to this though.]
To convert odds back to probability, divide the odds by (1+odds). So if the odds are 1/9, the probability is $\frac{1/9}{1+1/9}=\frac{1}{10}$
|
Odds vs. Probabilities (Confusion)
|
A probability lies between 0 and 1; I presume you're familiar enough with it that we don't need to define probability, but please clarify if you do require a basic definition. [So if I say something l
|
Odds vs. Probabilities (Confusion)
A probability lies between 0 and 1; I presume you're familiar enough with it that we don't need to define probability, but please clarify if you do require a basic definition. [So if I say something like "The probability of at least two heads in three tosses of a coin is 1/2" or "the probability that I miss the bus tomorrow is 1/10" I presume the sense of what that means is already clear.]
Odds are the ratio of a probability (p) to its complement (1-p) ($\text{odds}=\frac{p}{1-p}$. In this case the odds for missing the bus would be $\frac{1/10}{9/10}=1/9$.
[In elementary situations where probability is "number of cases where the event holds"/"total cases", odds are "number of cases where the event holds"/"number of cases where it doesn't".]
[In gambling, odds are usually expression not as a fraction but as a literal ratio ("1:9 for" rather than $\frac{_1}{^9}$), and most usually in terms of odds against (the reciprocal of the ratio, "9:1 against"), unless the odds against fall below 1:1, in which case they're again written the first way around, as odds for and referred to as "odds on"); this keeps the larger number expressed first. If there's no adjective (on, for, against), as in "the odds are 20:1", you would normally assume odds against in gambling situations. You'd flip those around and write as a fraction -- $\frac{1}{20}$ to get odds as a statistician writes them. In some situations you will see odds defined differently to this though.]
To convert odds back to probability, divide the odds by (1+odds). So if the odds are 1/9, the probability is $\frac{1/9}{1+1/9}=\frac{1}{10}$
|
Odds vs. Probabilities (Confusion)
A probability lies between 0 and 1; I presume you're familiar enough with it that we don't need to define probability, but please clarify if you do require a basic definition. [So if I say something l
|
47,325
|
Odds vs. Probabilities (Confusion)
|
Odds ratio is best understood in the gambling context. If you are throwing a dice, and the winning side is 6, then they say you have 5/1 chance to win, i.e. for every one winning chance there are 5 chances to lose. If the wining sides are 2 and 3, then your odds ratio is 2/1.
Now, you can see how the odds ratio is related to the probabilities: $r=\frac{1-p}{p}$. You can plug probability of losing, instead of winning $\pi=1-p$, then $r=\frac{\pi}{1-\pi}$, basically the same thing.
|
Odds vs. Probabilities (Confusion)
|
Odds ratio is best understood in the gambling context. If you are throwing a dice, and the winning side is 6, then they say you have 5/1 chance to win, i.e. for every one winning chance there are 5 ch
|
Odds vs. Probabilities (Confusion)
Odds ratio is best understood in the gambling context. If you are throwing a dice, and the winning side is 6, then they say you have 5/1 chance to win, i.e. for every one winning chance there are 5 chances to lose. If the wining sides are 2 and 3, then your odds ratio is 2/1.
Now, you can see how the odds ratio is related to the probabilities: $r=\frac{1-p}{p}$. You can plug probability of losing, instead of winning $\pi=1-p$, then $r=\frac{\pi}{1-\pi}$, basically the same thing.
|
Odds vs. Probabilities (Confusion)
Odds ratio is best understood in the gambling context. If you are throwing a dice, and the winning side is 6, then they say you have 5/1 chance to win, i.e. for every one winning chance there are 5 ch
|
47,326
|
Is it possible to compare the parsimony of models with the same number of parameters and explanatory variables?
|
The number of parameters often turns out not to be a good measure of the complexity of a function or model. There are a number of ways of measuring complexity in different scenarios - one of the simplest is Vapnik–Chervonenkis dimension. The basic idea is to imagine a bunch of points distributed in the xy plane, some labeled + and some labeled -. Can a curve from a particular model class be chosen such that all the + points are above the line, and all the - points are below? The number of points for which you can do this defines how "wiggly" the model class is, and thus how complex it is.
For example, say that you have two models $f_1(x) = a*x^2$ and $f_2(x)=1-cos(a*x)$, each of which have one tunable parameter $a$. For how many points (say placed between -0.5 and 0.5) can we produce any +/- labeling, for each model? $f_1(x)$ is very poor by this measure, since it can't even produce all labels for two points (if $y_1/x_1^2>y_2/x_2^2$, then you can never get point 1 below the line and point 2 above). $f_2(x)$, however, actually has infinite VC-dimension, since it can produce any labeling for any number of points (see solution B2b here). So if both $f_1$ and $f_2$ both provide good fits to some data (e.g. we can find an $a$ for each that gives a good fit), we would strongly prefer $f_1$ since it comes from a simpler model class and therefore is more likely to generalize well.
Note that we're talking about complexity of function classes here, not specific functions as you implied in your question - typically "parameters" refers not to the input $x$ of a function, but the coefficients of parts of the model ($a$ in my example).
|
Is it possible to compare the parsimony of models with the same number of parameters and explanatory
|
The number of parameters often turns out not to be a good measure of the complexity of a function or model. There are a number of ways of measuring complexity in different scenarios - one of the simpl
|
Is it possible to compare the parsimony of models with the same number of parameters and explanatory variables?
The number of parameters often turns out not to be a good measure of the complexity of a function or model. There are a number of ways of measuring complexity in different scenarios - one of the simplest is Vapnik–Chervonenkis dimension. The basic idea is to imagine a bunch of points distributed in the xy plane, some labeled + and some labeled -. Can a curve from a particular model class be chosen such that all the + points are above the line, and all the - points are below? The number of points for which you can do this defines how "wiggly" the model class is, and thus how complex it is.
For example, say that you have two models $f_1(x) = a*x^2$ and $f_2(x)=1-cos(a*x)$, each of which have one tunable parameter $a$. For how many points (say placed between -0.5 and 0.5) can we produce any +/- labeling, for each model? $f_1(x)$ is very poor by this measure, since it can't even produce all labels for two points (if $y_1/x_1^2>y_2/x_2^2$, then you can never get point 1 below the line and point 2 above). $f_2(x)$, however, actually has infinite VC-dimension, since it can produce any labeling for any number of points (see solution B2b here). So if both $f_1$ and $f_2$ both provide good fits to some data (e.g. we can find an $a$ for each that gives a good fit), we would strongly prefer $f_1$ since it comes from a simpler model class and therefore is more likely to generalize well.
Note that we're talking about complexity of function classes here, not specific functions as you implied in your question - typically "parameters" refers not to the input $x$ of a function, but the coefficients of parts of the model ($a$ in my example).
|
Is it possible to compare the parsimony of models with the same number of parameters and explanatory
The number of parameters often turns out not to be a good measure of the complexity of a function or model. There are a number of ways of measuring complexity in different scenarios - one of the simpl
|
47,327
|
Is it possible to compare the parsimony of models with the same number of parameters and explanatory variables?
|
When statisticians say that they prefer parsimonious models they are really cautioning against over-fitting. There really is no other statistical reason to prefer a parsimonious model other than ease of interpretability and, generally speaking, that's a silly reason for a statistician. I think Gelman does a good job articulating this here. Of course, there are conceivable reasons why we'd sacrifice statistical accuracy for interpretability but these are not statistical reasons.
I realize this doesn't really answer the spirit of your question so I'll attempt to do that as well. The "complexity" of a function is an objective thing. I think many people would agree that a function that is very "curvy" is more complex than a less-curvy function. One way to assess the curvy-ness of a function is to look at the derivative and the following is a way to assess the curvy-ness of a function across it's domain,
$$\int f''(x)^2 dx $$
|
Is it possible to compare the parsimony of models with the same number of parameters and explanatory
|
When statisticians say that they prefer parsimonious models they are really cautioning against over-fitting. There really is no other statistical reason to prefer a parsimonious model other than ease
|
Is it possible to compare the parsimony of models with the same number of parameters and explanatory variables?
When statisticians say that they prefer parsimonious models they are really cautioning against over-fitting. There really is no other statistical reason to prefer a parsimonious model other than ease of interpretability and, generally speaking, that's a silly reason for a statistician. I think Gelman does a good job articulating this here. Of course, there are conceivable reasons why we'd sacrifice statistical accuracy for interpretability but these are not statistical reasons.
I realize this doesn't really answer the spirit of your question so I'll attempt to do that as well. The "complexity" of a function is an objective thing. I think many people would agree that a function that is very "curvy" is more complex than a less-curvy function. One way to assess the curvy-ness of a function is to look at the derivative and the following is a way to assess the curvy-ness of a function across it's domain,
$$\int f''(x)^2 dx $$
|
Is it possible to compare the parsimony of models with the same number of parameters and explanatory
When statisticians say that they prefer parsimonious models they are really cautioning against over-fitting. There really is no other statistical reason to prefer a parsimonious model other than ease
|
47,328
|
Linear combination of discrete variables $T_i$ with $P(T_i=1)=P(T_i=-1)=1/2$
|
Yes.
Let's begin by simplifying the question. The event
$$T_1\sum_{i=1}^n T_i w_i \geq 0$$
is the union of the disjoint events (determined by $T_1=\pm 1$)
$$w_1 + \sum_{i=2}^n T_i w_i \geq 0,\ -w_1 + \sum_{i=2}^n T_i w_i \geq 0.$$
After simple algebraic manipulation, and using the fact that each $T_i$ has the same distribution as $-T_i$ (it is "symmetric"), these events are both equivalent to those of the form
$$\sum_{i=2}^n T_i w_i \leq w$$
for $w=\pm w_1$. Again exploiting the symmetries of the $T_i$ (to make all the $w_i$ non-negative) and re-ordering them, this can be written
$$\sum_{i=2}^n T_i |w_i| \leq w$$
where $|w_2| \ge |w_3| \ge \cdots \ge |w_n|$.
We need to compute the chances of two such events and wish to do so efficiently. I will assume that the chance needs to be computed to high accuracy, so that approximations would be unacceptable. (For many configurations of the $|w_i|$, Normal approximations to the distributions might otherwise work well. Deeper analysis can be carried out using the characteristic function $\phi$ of $\sum_{i=2}^n T_i |w_i|$, which by definition is $$\phi(t) = \prod_{i=2}^n\left(\frac{\exp(-j |w_i|t)}{2} + \frac{\exp(j |w_i|t)}{2}\right)=\prod_{i=2}^n\cos(w_it);$$ $j = \sqrt{-1}$.)
From now on, reduce $n$ by $1$, start the indexing with $i=1$, and assume all the $w_i$ are positive. (Obviously, any zero values can be ignored.) Let $1 \le k \lt n$. Consider the distribution of $X = \sum_{i=1}^n T_i w_i$ conditional on the first $k$ values of $T_i$:
$$\Pr(X \le w\,|\, T_1, \ldots, T_k) = {\Pr}_{(T_{k+1},\ldots,T_n)}\left(\sum_{i=k+1}^n T_i w_i \le w - \sum_{i=1}^k T_i w_i = w_0\right).$$
Since $|T_i| \le 1$, the left hand sum is bounded:
$$-u_{k+1} = -(w_{k+1} + \cdots + w_n) \le \sum_{i=k+1}^n T_i w_i \le w_{k+1} + \cdots + w_n = u_{k+1}.$$
Let $u_{k+1}$ be the right hand side: it is a cumulative sum of the $w_i$, accumulated from the rightmost (lowest) values. Obviously now if $u_{k+1} \le w_0$ then $X \le w$ is certain; and if $-u_{k+1} \gt w_0$, then $X \le w$ has zero probability. This leads to a simple branch and bound algorithm, because we needn't search any further to assess the distribution. Whereas exhaustive enumeration would have had to examine $2^{n-k}$ possible cases, we have made a determination of their contribution to the distribution in $O(1)$ time.
There is not much hope that this improvement will lead to a worst-case algorithm that is better than $O(2^n)$ in performance (although I think it can be reduced to $O(2^{n/2})$ which--although much better--is still non-polynomial). However, the improvement is good enough to be worth considering, especially for moderate values of $n$ where exhaustive enumeration starts becoming impracticable (somewhere above $20$ and certainly above $40$). Let us therefore turn to benchmarking the algorithm. How efficient is it?
The worst case is when most of the $w_i$ have comparable sizes, for then the branch-and-bound heuristic rarely accomplishes anything. Fortunately, this is exactly the situation where the Central Limit Theorem can supply excellent approximations! It will therefore be perhaps even more interesting to explore situations where the sizes of the $w_i$ are highly spread out.
To this end, I created four datasets with $n=15$ from four distributions with radically different shapes: Beta$(1/5,1/5)$ (sharply bimodal), Exponential (high mode near zero), Uniform, and Gamma$(20)$ (nearly Normal, with values closely arranged near $20$). Each dataset was normalized to a maximum of $1$. Using the branch-and-bound method, $\Pr(X \le w)$ was computed for $19$ values of $w$ ranging from $0$ up to $2\sqrt{n}$. (Negative values of $w$ need not be shown because the distributions of $X$ are nearly symmetric.) The figure displays the results, graphing the probabilities (the empirical cumulative distribution function of $X$) in the top row and the efficiencies (on log-linear scales) in the bottom row. The "efficiency" is the ratio of the number of configurations needed for exhaustive enumeration ($2^n$) to the number of configurations considered by the branch-and-bound algorithm.
For the Beta distribution, whose strong bimodality essentially limits the calculations to the higher half of the data, efficiencies are greatest. As expected, they are least for the Gamma distribution, whose values are all comparable. Nevertheless, even in this difficult case, the efficiencies all exceed $3$.
The smallest efficiencies are usually for $w=0$. Eventually efficiency will increase as $|w|$ increases. Collectively these results are strong evidence that the approach described here not only is computationally more efficient than exhaustive enumeration, it tends to be much more efficient.
The implementation of the algorithm is straightforward and simple. R code follows. It includes a section that tests the algorithm (by comparing its output to an exhaustive enumeration) and another section to reproduce the figure.
#
# The algorithm.
#
f <- function(w0, w) {
w <- sort(abs(w), decreasing=TRUE)
w.sum <- c(rev(cumsum(rev(w)))[-1], 0)
count <- 0 # Counts calls to f()
f <- function(u, u.sum, w0) {
count <<- count + 1
y <- sapply(w0 + c(-1,1)*u[1], function(w1) {
if (w1 < -u.sum[1]) return(0)
if (w1 >= u.sum[1]) return(1)
return(f(u[-1], u.sum[-1], w1))
})
return(mean(y)) # (This could easily be changed to accommodate
# other probabilities for the T[i].)
}
list(Value=f(w, w.sum, w0), Count=count)
}
#
# Test with complete enumeration. The plot pairs should exactly coincide.
#
binary <- function(a, b, zero=-1, one=1) rep(c(rep(zero, 2^a), rep(one, 2^a)), 2^b)
n <- 9
b <- sapply(1:n, function(a) binary(n-a, a-1))
par(mfrow=c(2,2))
set.seed(17)
for (i in 1:4) {
w <- rexp(n)
x <- b %*% w
y <- sapply(x, function(w0) f(w0, w)$Value) #$
plot(ecdf(x))
points(x, y, pch=16, cex=1/2, col="Red")
}
#
# Explore the efficiencies actually achieved.
#
n <- 15
qb <- function(q) qbeta(q, 1/5, 1/5); sigma <- sqrt(1/(1+2*1/5))/2
qg <- function(q) qgamma(q, 20)
dist <- list(Gamma=qg, Normal=qnorm, Uniform=qunif, Exponential=qexp, Beta=qb)
par(mfcol=c(2,4))
for (s in c("Beta", "Exponential", "Uniform", "Gamma")) {
d <- dist[[s]]
w <- d(((1:n)-1/2)/n)
w <- w / max(abs(w))
print(c(system.time({
y <- sapply(x <- seq(0, 2*sqrt(n), length.out=19),
function(w0) {x <- f(w0, w); c(x$Value, x$Count)})
})["elapsed"], count=sum(y[2, ])))
plot(x, y[1, ], ylim=c(1/2, 1), type="b", ylab="Probability", main=s)
plot(x, 2^n/y[2, ], ylim=c(1, 2^n), type="b", log="y", ylab="Efficiency")
}
|
Linear combination of discrete variables $T_i$ with $P(T_i=1)=P(T_i=-1)=1/2$
|
Yes.
Let's begin by simplifying the question. The event
$$T_1\sum_{i=1}^n T_i w_i \geq 0$$
is the union of the disjoint events (determined by $T_1=\pm 1$)
$$w_1 + \sum_{i=2}^n T_i w_i \geq 0,\ -w_1 +
|
Linear combination of discrete variables $T_i$ with $P(T_i=1)=P(T_i=-1)=1/2$
Yes.
Let's begin by simplifying the question. The event
$$T_1\sum_{i=1}^n T_i w_i \geq 0$$
is the union of the disjoint events (determined by $T_1=\pm 1$)
$$w_1 + \sum_{i=2}^n T_i w_i \geq 0,\ -w_1 + \sum_{i=2}^n T_i w_i \geq 0.$$
After simple algebraic manipulation, and using the fact that each $T_i$ has the same distribution as $-T_i$ (it is "symmetric"), these events are both equivalent to those of the form
$$\sum_{i=2}^n T_i w_i \leq w$$
for $w=\pm w_1$. Again exploiting the symmetries of the $T_i$ (to make all the $w_i$ non-negative) and re-ordering them, this can be written
$$\sum_{i=2}^n T_i |w_i| \leq w$$
where $|w_2| \ge |w_3| \ge \cdots \ge |w_n|$.
We need to compute the chances of two such events and wish to do so efficiently. I will assume that the chance needs to be computed to high accuracy, so that approximations would be unacceptable. (For many configurations of the $|w_i|$, Normal approximations to the distributions might otherwise work well. Deeper analysis can be carried out using the characteristic function $\phi$ of $\sum_{i=2}^n T_i |w_i|$, which by definition is $$\phi(t) = \prod_{i=2}^n\left(\frac{\exp(-j |w_i|t)}{2} + \frac{\exp(j |w_i|t)}{2}\right)=\prod_{i=2}^n\cos(w_it);$$ $j = \sqrt{-1}$.)
From now on, reduce $n$ by $1$, start the indexing with $i=1$, and assume all the $w_i$ are positive. (Obviously, any zero values can be ignored.) Let $1 \le k \lt n$. Consider the distribution of $X = \sum_{i=1}^n T_i w_i$ conditional on the first $k$ values of $T_i$:
$$\Pr(X \le w\,|\, T_1, \ldots, T_k) = {\Pr}_{(T_{k+1},\ldots,T_n)}\left(\sum_{i=k+1}^n T_i w_i \le w - \sum_{i=1}^k T_i w_i = w_0\right).$$
Since $|T_i| \le 1$, the left hand sum is bounded:
$$-u_{k+1} = -(w_{k+1} + \cdots + w_n) \le \sum_{i=k+1}^n T_i w_i \le w_{k+1} + \cdots + w_n = u_{k+1}.$$
Let $u_{k+1}$ be the right hand side: it is a cumulative sum of the $w_i$, accumulated from the rightmost (lowest) values. Obviously now if $u_{k+1} \le w_0$ then $X \le w$ is certain; and if $-u_{k+1} \gt w_0$, then $X \le w$ has zero probability. This leads to a simple branch and bound algorithm, because we needn't search any further to assess the distribution. Whereas exhaustive enumeration would have had to examine $2^{n-k}$ possible cases, we have made a determination of their contribution to the distribution in $O(1)$ time.
There is not much hope that this improvement will lead to a worst-case algorithm that is better than $O(2^n)$ in performance (although I think it can be reduced to $O(2^{n/2})$ which--although much better--is still non-polynomial). However, the improvement is good enough to be worth considering, especially for moderate values of $n$ where exhaustive enumeration starts becoming impracticable (somewhere above $20$ and certainly above $40$). Let us therefore turn to benchmarking the algorithm. How efficient is it?
The worst case is when most of the $w_i$ have comparable sizes, for then the branch-and-bound heuristic rarely accomplishes anything. Fortunately, this is exactly the situation where the Central Limit Theorem can supply excellent approximations! It will therefore be perhaps even more interesting to explore situations where the sizes of the $w_i$ are highly spread out.
To this end, I created four datasets with $n=15$ from four distributions with radically different shapes: Beta$(1/5,1/5)$ (sharply bimodal), Exponential (high mode near zero), Uniform, and Gamma$(20)$ (nearly Normal, with values closely arranged near $20$). Each dataset was normalized to a maximum of $1$. Using the branch-and-bound method, $\Pr(X \le w)$ was computed for $19$ values of $w$ ranging from $0$ up to $2\sqrt{n}$. (Negative values of $w$ need not be shown because the distributions of $X$ are nearly symmetric.) The figure displays the results, graphing the probabilities (the empirical cumulative distribution function of $X$) in the top row and the efficiencies (on log-linear scales) in the bottom row. The "efficiency" is the ratio of the number of configurations needed for exhaustive enumeration ($2^n$) to the number of configurations considered by the branch-and-bound algorithm.
For the Beta distribution, whose strong bimodality essentially limits the calculations to the higher half of the data, efficiencies are greatest. As expected, they are least for the Gamma distribution, whose values are all comparable. Nevertheless, even in this difficult case, the efficiencies all exceed $3$.
The smallest efficiencies are usually for $w=0$. Eventually efficiency will increase as $|w|$ increases. Collectively these results are strong evidence that the approach described here not only is computationally more efficient than exhaustive enumeration, it tends to be much more efficient.
The implementation of the algorithm is straightforward and simple. R code follows. It includes a section that tests the algorithm (by comparing its output to an exhaustive enumeration) and another section to reproduce the figure.
#
# The algorithm.
#
f <- function(w0, w) {
w <- sort(abs(w), decreasing=TRUE)
w.sum <- c(rev(cumsum(rev(w)))[-1], 0)
count <- 0 # Counts calls to f()
f <- function(u, u.sum, w0) {
count <<- count + 1
y <- sapply(w0 + c(-1,1)*u[1], function(w1) {
if (w1 < -u.sum[1]) return(0)
if (w1 >= u.sum[1]) return(1)
return(f(u[-1], u.sum[-1], w1))
})
return(mean(y)) # (This could easily be changed to accommodate
# other probabilities for the T[i].)
}
list(Value=f(w, w.sum, w0), Count=count)
}
#
# Test with complete enumeration. The plot pairs should exactly coincide.
#
binary <- function(a, b, zero=-1, one=1) rep(c(rep(zero, 2^a), rep(one, 2^a)), 2^b)
n <- 9
b <- sapply(1:n, function(a) binary(n-a, a-1))
par(mfrow=c(2,2))
set.seed(17)
for (i in 1:4) {
w <- rexp(n)
x <- b %*% w
y <- sapply(x, function(w0) f(w0, w)$Value) #$
plot(ecdf(x))
points(x, y, pch=16, cex=1/2, col="Red")
}
#
# Explore the efficiencies actually achieved.
#
n <- 15
qb <- function(q) qbeta(q, 1/5, 1/5); sigma <- sqrt(1/(1+2*1/5))/2
qg <- function(q) qgamma(q, 20)
dist <- list(Gamma=qg, Normal=qnorm, Uniform=qunif, Exponential=qexp, Beta=qb)
par(mfcol=c(2,4))
for (s in c("Beta", "Exponential", "Uniform", "Gamma")) {
d <- dist[[s]]
w <- d(((1:n)-1/2)/n)
w <- w / max(abs(w))
print(c(system.time({
y <- sapply(x <- seq(0, 2*sqrt(n), length.out=19),
function(w0) {x <- f(w0, w); c(x$Value, x$Count)})
})["elapsed"], count=sum(y[2, ])))
plot(x, y[1, ], ylim=c(1/2, 1), type="b", ylab="Probability", main=s)
plot(x, 2^n/y[2, ], ylim=c(1, 2^n), type="b", log="y", ylab="Efficiency")
}
|
Linear combination of discrete variables $T_i$ with $P(T_i=1)=P(T_i=-1)=1/2$
Yes.
Let's begin by simplifying the question. The event
$$T_1\sum_{i=1}^n T_i w_i \geq 0$$
is the union of the disjoint events (determined by $T_1=\pm 1$)
$$w_1 + \sum_{i=2}^n T_i w_i \geq 0,\ -w_1 +
|
47,329
|
Linear combination of discrete variables $T_i$ with $P(T_i=1)=P(T_i=-1)=1/2$
|
$$T_1\sum_{i=1}^n T_i w_i = w_1 + T_1\sum_{i=2}^n T_i w_i$$
since $T_1^2 = 1$.
Write the sum as $S_{2w}$. So we are looking at the probability
$$P\left(T_1S_{2w} \geq -w_1\right) = \\P\left(T_1S_{2w} \geq -w_1 \mid T_1 =1\right)\cdot P(T_1 =1) + P\left(T_1S_{2w} \geq -w_1 \mid T_1 =-1\right)\cdot P(T_1 =-1)$$
$$\Rightarrow P\left(T_1S_{2w} \geq -w_1\right)=\frac 12 P\left(S_{2w} \geq -w_1 \right)+ \frac 12P\left(-S_{2w} \geq -w_1 \right)$$
$$=\frac 12 \Big[1-P\left(S_{2w} \leq -w_1 \right)+P\left(S_{2w} \leq w_1 \right)\Big] \tag{1}$$
Now define $Z_i \equiv (T_i + 1)/2$. Then the $Z_i$'s are Bernoulli $(1/2)$ random variables.
So
$$S_{2w}=\sum_{i=2}^n (2Z_i-1) w_i = 2\sum_{i=2}^n Z_iw_i - \sum_{i=2}^n w_i \tag{2}$$
Inserting into $(1)$ and rearranging we obtain
$$P\left(T_1S_{2w} \geq -w_1\right) = \frac 12 \left[1-P\left(\sum_{i=2}^n Z_iw_i \leq (1/2)\sum_{i=2}^n w_i-(w_1/2) \right)+P\left(\sum_{i=2}^n Z_iw_i \leq (1/2)\sum_{i=2}^n w_i+(w_1/2) \right)\right]$$
So we need probabilities related to $S_{Zw}\equiv \sum_{i=2}^n Z_iw_i$. The Probability Generating Function , PGF, of a Bernoulli $(1/2)$ is
$$G_Z(z) = \frac 12(1+z)$$
and of the linear combination of independent Bernoullis
$$G_{S_{Zw}}(z) = \prod_{i=2}^{n}\left(\frac 12(1+z^{w_i})\right) = \frac 1{2^{n-1}}\prod_{i=2}^{n}(1+z^{w_i})$$
From the PGF we can recover the probabilities of the probability mass function and so of the cumulative distribution function that is our goal.
AN EXAMPLE
For exposition purposes, assume that $n=3$ and $(w_1 =2, w_2 =2, w_3 = 4)$.
Then
$$(1/2)\sum_{i=2}^n w_i-(w_1/2) = 2, \;\;\; (1/2)\sum_{i=2}^n w_i+(w_1/2) = 4$$
So we want to evaluate
$$P\left(T_1S_{2w} \geq -1\right) = \frac 12 \left[1-P\left(S_{Zw} \leq 2 \right)+P\left(S_{Zw} \leq 4 \right)\right]$$
$$=\frac 12 \left[1+P\left(S_{Zw} =3 \right)+P\left(S_{Zw} = 4 \right)\right]$$
In such a very simple example, we don't really need the PGF: given the assumed values of the weights on the Bernoullis, it is easy to see that $P\left(S_{Zw} =3 \right) = 0$ and that $P\left(S_{Zw} = 4\right) = 1/4$. So we obtain the answer, for the specific example
$$P\left(T_1S_{2w} \geq -1\right) = 5/8$$
Verification through the PGF
For the specific numerical example
$$G_{S_{Zw}}(z) = \frac 1{2^{n-1}}\prod_{i=2}^{n}(1+z^{w_i}) = \frac 1{4}(1+z^2)(1+z^4) = \frac 1{4}(1+z^2+z^4+z^6)$$
The relation linking the PGF with probabilities is ($(k)$ denoting the order of the derivative taken
$$P(S_{Zw} = k) =\frac{ G_{S_{Zw}}^{(k)}(0)}{k!}$$
We have
$$G_{S_{Zw}}^{(1)}(z) = \frac 1{4}(2z+4z^3+6z^5)$$
$$G_{S_{Zw}}^{(2)}(z) = \frac 1{4}(2+12z^2+30z^4)$$
$$G_{S_{Zw}}^{(3)}(z) = \frac 1{4}(24z+120z^3)$$
$$G_{S_{Zw}}^{(4)}(z) = \frac 1{4}(24+360z^2)$$
So
$$P\left(S_{Zw} =3 \right) = \frac{ G_{S_{Zw}}^{(3)}(0)}{3!} = 0$$
$$P\left(S_{Zw} =4 \right) = \frac{ G_{S_{Zw}}^{(4)}(0)}{4!} = \frac 1{4}$$
Therefore
$$P\left(T_1S_{2w} \geq -1\right) = \frac 12 \left[1+0+\frac 14 \right] = 5/8$$
Now imagine what would it take if the example was not so simple.
|
Linear combination of discrete variables $T_i$ with $P(T_i=1)=P(T_i=-1)=1/2$
|
$$T_1\sum_{i=1}^n T_i w_i = w_1 + T_1\sum_{i=2}^n T_i w_i$$
since $T_1^2 = 1$.
Write the sum as $S_{2w}$. So we are looking at the probability
$$P\left(T_1S_{2w} \geq -w_1\right) = \\P\left(T_1S_{2w}
|
Linear combination of discrete variables $T_i$ with $P(T_i=1)=P(T_i=-1)=1/2$
$$T_1\sum_{i=1}^n T_i w_i = w_1 + T_1\sum_{i=2}^n T_i w_i$$
since $T_1^2 = 1$.
Write the sum as $S_{2w}$. So we are looking at the probability
$$P\left(T_1S_{2w} \geq -w_1\right) = \\P\left(T_1S_{2w} \geq -w_1 \mid T_1 =1\right)\cdot P(T_1 =1) + P\left(T_1S_{2w} \geq -w_1 \mid T_1 =-1\right)\cdot P(T_1 =-1)$$
$$\Rightarrow P\left(T_1S_{2w} \geq -w_1\right)=\frac 12 P\left(S_{2w} \geq -w_1 \right)+ \frac 12P\left(-S_{2w} \geq -w_1 \right)$$
$$=\frac 12 \Big[1-P\left(S_{2w} \leq -w_1 \right)+P\left(S_{2w} \leq w_1 \right)\Big] \tag{1}$$
Now define $Z_i \equiv (T_i + 1)/2$. Then the $Z_i$'s are Bernoulli $(1/2)$ random variables.
So
$$S_{2w}=\sum_{i=2}^n (2Z_i-1) w_i = 2\sum_{i=2}^n Z_iw_i - \sum_{i=2}^n w_i \tag{2}$$
Inserting into $(1)$ and rearranging we obtain
$$P\left(T_1S_{2w} \geq -w_1\right) = \frac 12 \left[1-P\left(\sum_{i=2}^n Z_iw_i \leq (1/2)\sum_{i=2}^n w_i-(w_1/2) \right)+P\left(\sum_{i=2}^n Z_iw_i \leq (1/2)\sum_{i=2}^n w_i+(w_1/2) \right)\right]$$
So we need probabilities related to $S_{Zw}\equiv \sum_{i=2}^n Z_iw_i$. The Probability Generating Function , PGF, of a Bernoulli $(1/2)$ is
$$G_Z(z) = \frac 12(1+z)$$
and of the linear combination of independent Bernoullis
$$G_{S_{Zw}}(z) = \prod_{i=2}^{n}\left(\frac 12(1+z^{w_i})\right) = \frac 1{2^{n-1}}\prod_{i=2}^{n}(1+z^{w_i})$$
From the PGF we can recover the probabilities of the probability mass function and so of the cumulative distribution function that is our goal.
AN EXAMPLE
For exposition purposes, assume that $n=3$ and $(w_1 =2, w_2 =2, w_3 = 4)$.
Then
$$(1/2)\sum_{i=2}^n w_i-(w_1/2) = 2, \;\;\; (1/2)\sum_{i=2}^n w_i+(w_1/2) = 4$$
So we want to evaluate
$$P\left(T_1S_{2w} \geq -1\right) = \frac 12 \left[1-P\left(S_{Zw} \leq 2 \right)+P\left(S_{Zw} \leq 4 \right)\right]$$
$$=\frac 12 \left[1+P\left(S_{Zw} =3 \right)+P\left(S_{Zw} = 4 \right)\right]$$
In such a very simple example, we don't really need the PGF: given the assumed values of the weights on the Bernoullis, it is easy to see that $P\left(S_{Zw} =3 \right) = 0$ and that $P\left(S_{Zw} = 4\right) = 1/4$. So we obtain the answer, for the specific example
$$P\left(T_1S_{2w} \geq -1\right) = 5/8$$
Verification through the PGF
For the specific numerical example
$$G_{S_{Zw}}(z) = \frac 1{2^{n-1}}\prod_{i=2}^{n}(1+z^{w_i}) = \frac 1{4}(1+z^2)(1+z^4) = \frac 1{4}(1+z^2+z^4+z^6)$$
The relation linking the PGF with probabilities is ($(k)$ denoting the order of the derivative taken
$$P(S_{Zw} = k) =\frac{ G_{S_{Zw}}^{(k)}(0)}{k!}$$
We have
$$G_{S_{Zw}}^{(1)}(z) = \frac 1{4}(2z+4z^3+6z^5)$$
$$G_{S_{Zw}}^{(2)}(z) = \frac 1{4}(2+12z^2+30z^4)$$
$$G_{S_{Zw}}^{(3)}(z) = \frac 1{4}(24z+120z^3)$$
$$G_{S_{Zw}}^{(4)}(z) = \frac 1{4}(24+360z^2)$$
So
$$P\left(S_{Zw} =3 \right) = \frac{ G_{S_{Zw}}^{(3)}(0)}{3!} = 0$$
$$P\left(S_{Zw} =4 \right) = \frac{ G_{S_{Zw}}^{(4)}(0)}{4!} = \frac 1{4}$$
Therefore
$$P\left(T_1S_{2w} \geq -1\right) = \frac 12 \left[1+0+\frac 14 \right] = 5/8$$
Now imagine what would it take if the example was not so simple.
|
Linear combination of discrete variables $T_i$ with $P(T_i=1)=P(T_i=-1)=1/2$
$$T_1\sum_{i=1}^n T_i w_i = w_1 + T_1\sum_{i=2}^n T_i w_i$$
since $T_1^2 = 1$.
Write the sum as $S_{2w}$. So we are looking at the probability
$$P\left(T_1S_{2w} \geq -w_1\right) = \\P\left(T_1S_{2w}
|
47,330
|
Is high AIC a bad feature of the model?
|
This is from the description of AIC:
The Akaike information criterion (AIC) is a measure of the relative
quality of a statistical model for a given set of data. As such, AIC
provides a means for model selection.
I don't pay attention to the absolute value of AIC. I only use it to compare in-sample fit of the candidate models. Note, that if you're building the forecasting models, it is important to also consider out-of-sample fit.
|
Is high AIC a bad feature of the model?
|
This is from the description of AIC:
The Akaike information criterion (AIC) is a measure of the relative
quality of a statistical model for a given set of data. As such, AIC
provides a means for
|
Is high AIC a bad feature of the model?
This is from the description of AIC:
The Akaike information criterion (AIC) is a measure of the relative
quality of a statistical model for a given set of data. As such, AIC
provides a means for model selection.
I don't pay attention to the absolute value of AIC. I only use it to compare in-sample fit of the candidate models. Note, that if you're building the forecasting models, it is important to also consider out-of-sample fit.
|
Is high AIC a bad feature of the model?
This is from the description of AIC:
The Akaike information criterion (AIC) is a measure of the relative
quality of a statistical model for a given set of data. As such, AIC
provides a means for
|
47,331
|
Is high AIC a bad feature of the model?
|
As others said, there is not much point in evaluating a single model according to the absolute value of its AIC.
The point is to compare the AIC values of different models and the model which has lower AIC value than the other is better than the other in the sense that it is less complex but still a good fit for the data.
In no way I mean that ONLY less complex model = lower AIC. I am saying "less complex but still a good fit for the data". Obviously, a more complex problem may be preferable if your model is underfitting so obviously it is not necessary that a less complex model is better or has a lower AIC but in general a less complex problem which is not underfitting is better than a more complex one.
|
Is high AIC a bad feature of the model?
|
As others said, there is not much point in evaluating a single model according to the absolute value of its AIC.
The point is to compare the AIC values of different models and the model which has lowe
|
Is high AIC a bad feature of the model?
As others said, there is not much point in evaluating a single model according to the absolute value of its AIC.
The point is to compare the AIC values of different models and the model which has lower AIC value than the other is better than the other in the sense that it is less complex but still a good fit for the data.
In no way I mean that ONLY less complex model = lower AIC. I am saying "less complex but still a good fit for the data". Obviously, a more complex problem may be preferable if your model is underfitting so obviously it is not necessary that a less complex model is better or has a lower AIC but in general a less complex problem which is not underfitting is better than a more complex one.
|
Is high AIC a bad feature of the model?
As others said, there is not much point in evaluating a single model according to the absolute value of its AIC.
The point is to compare the AIC values of different models and the model which has lowe
|
47,332
|
Why do we use the term multicollinearity, when the vectors representing two variables are never truly collinear?
|
I don't think anyone worries about exact collinearity. If that was the case, $X'X$ would not be invertible. That is why full column rank of $X$ in one of the first assumptions. People worry about inexact relationships, since then there are coefficients to interpret, but they are too unreliable to be useful. The world multicollinearity is usually reserved for the latter. But one can easily become the other in the limit. Think about $\vert X'X\vert$. This determinant declines in value with increasing collinearity, tending to zero as the collinearity becomes exact. You can also consider the auxiliary regression $R^2_j$ tending to 1. Perhaps that is why we use the same term for both, though the extreme case is impossible if you have coefficients in hand.
Exact linear relationships most often arise in the context of the dummy variable trap and are easy to diagnose. The consequences of approximate linear relationship among some of the regressors in the sample at hand are indistinguishable from the consequences of inadequate variability of the regressors in a data set. Arthur Golberger joked that we should call this phenomenon "micronumerosity" instead. This is the one that people usually worry about, though it doesn't violate any of our usual assumptions.
This sort of multicollinearity, by definition, is a feature of your particular sample of data with which you're trying to fit a regression model. More or less, it means that there is insufficient information in your data to make reliable inferences about the individual parameters of the underlying (population) model, though jointly they may well be informative.
There are various sample measures that you can compute and report (VIFs or conditioning indices), to help gauge how severe this problem may be. But they're not statistical tests. Because multicollinearity is a characteristic of the sample, and not a characteristic of the population, you cannot test for it, in the same sense that it makes no sense to test that $\hat \beta = 0$, rather than $\beta = 0$. Of course, there are tests for relationships in the population that are often misinterpreted as test of multicollinearity.
|
Why do we use the term multicollinearity, when the vectors representing two variables are never trul
|
I don't think anyone worries about exact collinearity. If that was the case, $X'X$ would not be invertible. That is why full column rank of $X$ in one of the first assumptions. People worry about inex
|
Why do we use the term multicollinearity, when the vectors representing two variables are never truly collinear?
I don't think anyone worries about exact collinearity. If that was the case, $X'X$ would not be invertible. That is why full column rank of $X$ in one of the first assumptions. People worry about inexact relationships, since then there are coefficients to interpret, but they are too unreliable to be useful. The world multicollinearity is usually reserved for the latter. But one can easily become the other in the limit. Think about $\vert X'X\vert$. This determinant declines in value with increasing collinearity, tending to zero as the collinearity becomes exact. You can also consider the auxiliary regression $R^2_j$ tending to 1. Perhaps that is why we use the same term for both, though the extreme case is impossible if you have coefficients in hand.
Exact linear relationships most often arise in the context of the dummy variable trap and are easy to diagnose. The consequences of approximate linear relationship among some of the regressors in the sample at hand are indistinguishable from the consequences of inadequate variability of the regressors in a data set. Arthur Golberger joked that we should call this phenomenon "micronumerosity" instead. This is the one that people usually worry about, though it doesn't violate any of our usual assumptions.
This sort of multicollinearity, by definition, is a feature of your particular sample of data with which you're trying to fit a regression model. More or less, it means that there is insufficient information in your data to make reliable inferences about the individual parameters of the underlying (population) model, though jointly they may well be informative.
There are various sample measures that you can compute and report (VIFs or conditioning indices), to help gauge how severe this problem may be. But they're not statistical tests. Because multicollinearity is a characteristic of the sample, and not a characteristic of the population, you cannot test for it, in the same sense that it makes no sense to test that $\hat \beta = 0$, rather than $\beta = 0$. Of course, there are tests for relationships in the population that are often misinterpreted as test of multicollinearity.
|
Why do we use the term multicollinearity, when the vectors representing two variables are never trul
I don't think anyone worries about exact collinearity. If that was the case, $X'X$ would not be invertible. That is why full column rank of $X$ in one of the first assumptions. People worry about inex
|
47,333
|
How to test difference between standardized difference between means
|
This can be easily done with methods described in chapter 19 by Gleser and Olkin in the Handbook of Research Synthesis and Meta-Analysis (2009).
First, put the 5 d-values into a vector, $\vec{d}$.
Next, we need to construct the $5 \times 5$ variance-covariance matrix for $\vec{d}$. The diagonal elements (the variances) are given by
$$Var[d_i] = \frac{1}{n_1} + \frac{1}{n_2} + \frac{d_i^2}{2(n_1 + n_2)},$$
where $n_1$ and $n_2$ are the group sizes (see equation 19.26 in the chapter). The off-diagonal elements (the covariances) are given by
$$Cov[d_i, d_j] = \left(\frac{1}{n_1} + \frac{1}{n_2}\right) r_{ij} + \left(\frac{d_i d_j}{2(n_1 + n_2)}\right) r_{ij}^2,$$
where $r_{ij}$ is the correlation between variable $i$ and variable $j$ in your data (see equation 19.27 in the chapter). Let's call the resulting matrix $V$.
Now you can do several different things, including:
Test the null hypothesis that the true standardized mean differences underlying these 5 observed effects are the same (i.e., $H_0: \delta_1 = \delta_2 = \ldots = \delta_5$). This is commonly called a 'test for heterogeneity' in the meta-analytic literature and can be done with the so-called $Q$-test (see equation 19.31).
Test whether the true standardized mean difference for one particular effect is different from the rest (which are assumed to share the same common true effect). For this, you can fit a model that includes a dummy variable for that one effect believed to be significantly different and then test that dummy (see section 19.4.2 for regression models with such data).
I'll illustrate all of this with some made-up data and R code.
### group sizes
n1 <- 35
n2 <- 175-35
### vector with the observed d values
d <- c(.24, .10, .38, .86, .29)
### construct the var-cov matrix (R is the correlation matrix of the 5 variables)
R <- matrix(c( 1, .52, .35, .68, .44,
NA, 1, .48, .27, .33,
NA, NA, 1, .56, .25,
NA, NA, NA, 1, .49,
NA, NA, NA, NA, 1), nrow=5)
R[upper.tri(R)] <- t(R)[upper.tri(R)]
V <- (1/n1 + 1/n2) * R + (outer(d, d, '*') / (2*(n1 + n2))) * R^2
### load metafor package
library(metafor)
### fit model assuming homogeneous effects
res <- rma.mv(d, V)
### examine results (esp. Q-test for heterogeneity)
res
### test if the 4th effect is significantly different from the rest
### note: I(1:5 == 4) gives me a dummy variable that is equal to FALSE (0)
### for effects 1, 2, 3, and 5, and equal to TRUE (1) for effect 4
res <- rma.mv(d ~ I(1:5 == 4), V)
### examine results (esp. the p-value for the dummy variable)
res
So, in these data, we would reject the null hypothesis that the true effects are homogeneous ($Q(4) = 20.97$, $p = .0003$) and we would conclude that the 4th effect is significantly larger than the rest ($p < .0001$). In fact, the test for residual heterogeneity is not significant ($Q(3) = 2.23$, $p = .53$), which implies in this case that there is no significant amount of heterogeneity among effects 1, 2, 3, and 5.
One word of caution: You are picking out that one effect to test that appears to be different from the rest. But you did not choose it a priori -- you picked it after examining the effects. So, a better approach would be to consider all 5 possible tests you could have run and apply a correction for multiple testing. In the example above, the test easily survives a Bonferroni correction (just multiply the p-value for the dummy by 5), but that may not be the case in other data.
Addition: Here is code that allows you to fit all 5 models, extract the p-values, and then apply some correction for multiple testing, such as Holm's method.
pvals <- rep(NA, 5)
for (i in 1:5) {
res <- rma.mv(d ~ I(1:5 == i), V)
pvals[i] <- res$pval[2]
}
round(p.adjust(pvals, method="holm"), 4)
The results are:
[1] 0.0305 0.6274 0.3228 0.0001 0.3835
So, for these data, there is some evidence that the first and fourth values could be considered to be significantly different from the rest.
|
How to test difference between standardized difference between means
|
This can be easily done with methods described in chapter 19 by Gleser and Olkin in the Handbook of Research Synthesis and Meta-Analysis (2009).
First, put the 5 d-values into a vector, $\vec{d}$.
Nex
|
How to test difference between standardized difference between means
This can be easily done with methods described in chapter 19 by Gleser and Olkin in the Handbook of Research Synthesis and Meta-Analysis (2009).
First, put the 5 d-values into a vector, $\vec{d}$.
Next, we need to construct the $5 \times 5$ variance-covariance matrix for $\vec{d}$. The diagonal elements (the variances) are given by
$$Var[d_i] = \frac{1}{n_1} + \frac{1}{n_2} + \frac{d_i^2}{2(n_1 + n_2)},$$
where $n_1$ and $n_2$ are the group sizes (see equation 19.26 in the chapter). The off-diagonal elements (the covariances) are given by
$$Cov[d_i, d_j] = \left(\frac{1}{n_1} + \frac{1}{n_2}\right) r_{ij} + \left(\frac{d_i d_j}{2(n_1 + n_2)}\right) r_{ij}^2,$$
where $r_{ij}$ is the correlation between variable $i$ and variable $j$ in your data (see equation 19.27 in the chapter). Let's call the resulting matrix $V$.
Now you can do several different things, including:
Test the null hypothesis that the true standardized mean differences underlying these 5 observed effects are the same (i.e., $H_0: \delta_1 = \delta_2 = \ldots = \delta_5$). This is commonly called a 'test for heterogeneity' in the meta-analytic literature and can be done with the so-called $Q$-test (see equation 19.31).
Test whether the true standardized mean difference for one particular effect is different from the rest (which are assumed to share the same common true effect). For this, you can fit a model that includes a dummy variable for that one effect believed to be significantly different and then test that dummy (see section 19.4.2 for regression models with such data).
I'll illustrate all of this with some made-up data and R code.
### group sizes
n1 <- 35
n2 <- 175-35
### vector with the observed d values
d <- c(.24, .10, .38, .86, .29)
### construct the var-cov matrix (R is the correlation matrix of the 5 variables)
R <- matrix(c( 1, .52, .35, .68, .44,
NA, 1, .48, .27, .33,
NA, NA, 1, .56, .25,
NA, NA, NA, 1, .49,
NA, NA, NA, NA, 1), nrow=5)
R[upper.tri(R)] <- t(R)[upper.tri(R)]
V <- (1/n1 + 1/n2) * R + (outer(d, d, '*') / (2*(n1 + n2))) * R^2
### load metafor package
library(metafor)
### fit model assuming homogeneous effects
res <- rma.mv(d, V)
### examine results (esp. Q-test for heterogeneity)
res
### test if the 4th effect is significantly different from the rest
### note: I(1:5 == 4) gives me a dummy variable that is equal to FALSE (0)
### for effects 1, 2, 3, and 5, and equal to TRUE (1) for effect 4
res <- rma.mv(d ~ I(1:5 == 4), V)
### examine results (esp. the p-value for the dummy variable)
res
So, in these data, we would reject the null hypothesis that the true effects are homogeneous ($Q(4) = 20.97$, $p = .0003$) and we would conclude that the 4th effect is significantly larger than the rest ($p < .0001$). In fact, the test for residual heterogeneity is not significant ($Q(3) = 2.23$, $p = .53$), which implies in this case that there is no significant amount of heterogeneity among effects 1, 2, 3, and 5.
One word of caution: You are picking out that one effect to test that appears to be different from the rest. But you did not choose it a priori -- you picked it after examining the effects. So, a better approach would be to consider all 5 possible tests you could have run and apply a correction for multiple testing. In the example above, the test easily survives a Bonferroni correction (just multiply the p-value for the dummy by 5), but that may not be the case in other data.
Addition: Here is code that allows you to fit all 5 models, extract the p-values, and then apply some correction for multiple testing, such as Holm's method.
pvals <- rep(NA, 5)
for (i in 1:5) {
res <- rma.mv(d ~ I(1:5 == i), V)
pvals[i] <- res$pval[2]
}
round(p.adjust(pvals, method="holm"), 4)
The results are:
[1] 0.0305 0.6274 0.3228 0.0001 0.3835
So, for these data, there is some evidence that the first and fourth values could be considered to be significantly different from the rest.
|
How to test difference between standardized difference between means
This can be easily done with methods described in chapter 19 by Gleser and Olkin in the Handbook of Research Synthesis and Meta-Analysis (2009).
First, put the 5 d-values into a vector, $\vec{d}$.
Nex
|
47,334
|
How to test difference between standardized difference between means
|
I don't know any statistical test to check the difference of effect sizes. But nevertheless there is a possible solution to the problem: confidence intervals.
You can calculate the confidence interval for each of your d. If the confidence intervals have some large intersection it is OK to claim that they are similar. If they have no intersection, they are definitely not similar.
Calculating confidence intervals for effect sizes is not simple - it requires non-centrality parameters see for example wikipedia page. I use the R package MBESS
|
How to test difference between standardized difference between means
|
I don't know any statistical test to check the difference of effect sizes. But nevertheless there is a possible solution to the problem: confidence intervals.
You can calculate the confidence interval
|
How to test difference between standardized difference between means
I don't know any statistical test to check the difference of effect sizes. But nevertheless there is a possible solution to the problem: confidence intervals.
You can calculate the confidence interval for each of your d. If the confidence intervals have some large intersection it is OK to claim that they are similar. If they have no intersection, they are definitely not similar.
Calculating confidence intervals for effect sizes is not simple - it requires non-centrality parameters see for example wikipedia page. I use the R package MBESS
|
How to test difference between standardized difference between means
I don't know any statistical test to check the difference of effect sizes. But nevertheless there is a possible solution to the problem: confidence intervals.
You can calculate the confidence interval
|
47,335
|
How to test difference between standardized difference between means
|
I'm a little confused at your terminology (in particular, I think you mean d is an index for the variables, but I'm not 100% sure. You also don't provide a lot of context for how the d's are related. I'm going to assume the variables are continuous because you standardized them and compare means. Without making any other assumptions, you could try Multivariate Analysis of Variance, followed by ANOVA or t-tests for each variable assuming the MANOVA is significant.
If your data are repeated observations, MANOVA will work but you could do a longitudinal model, where you nest observations within the people. This can be done in a multilevel regression model.
If your data are reflective of an underlying latent variable, use structural equation modeling or confirmatory factor analysis, and include each variable a manifestation or indicator of your underlying factor.
You bring up the smaller sample size of one of the groups. That imbalance will affect the power of your test (i.e. the ability to detect a difference when it is really there), but shouldn't affect the validity of the tests.
|
How to test difference between standardized difference between means
|
I'm a little confused at your terminology (in particular, I think you mean d is an index for the variables, but I'm not 100% sure. You also don't provide a lot of context for how the d's are related.
|
How to test difference between standardized difference between means
I'm a little confused at your terminology (in particular, I think you mean d is an index for the variables, but I'm not 100% sure. You also don't provide a lot of context for how the d's are related. I'm going to assume the variables are continuous because you standardized them and compare means. Without making any other assumptions, you could try Multivariate Analysis of Variance, followed by ANOVA or t-tests for each variable assuming the MANOVA is significant.
If your data are repeated observations, MANOVA will work but you could do a longitudinal model, where you nest observations within the people. This can be done in a multilevel regression model.
If your data are reflective of an underlying latent variable, use structural equation modeling or confirmatory factor analysis, and include each variable a manifestation or indicator of your underlying factor.
You bring up the smaller sample size of one of the groups. That imbalance will affect the power of your test (i.e. the ability to detect a difference when it is really there), but shouldn't affect the validity of the tests.
|
How to test difference between standardized difference between means
I'm a little confused at your terminology (in particular, I think you mean d is an index for the variables, but I'm not 100% sure. You also don't provide a lot of context for how the d's are related.
|
47,336
|
Unbiased estimator and sufficient statistic from discrete uniform distribution
|
To find an unbiased estimator for $N$ using $z_1$, start from here: if $z_1 \sim \textrm{Unif}(1, N)$, then we want to find some function of $z_1$ such that $E(f(z_1)) = N$ (that's just what it means to be unbiased). Since $E(z_1) = \frac1N \sum_{i=1}^N i = \frac{N(N + 1)}{2N} = (N+1)/2$, it's hopefully pretty easy to come up with such a function...
You're on the right track. To prove it's sufficient you can use the Fisher-Neyman Factorization Theorem: a statistic $T(z_1, \dots, z_n)$ is sufficient for $N$ if the joint CDF $f_N(z_1, \dots, z_n)$ can be expressed as a product of two terms, one of which does not depend on $N$ (that is, it depends only on the $z_i$) and the other of which depends only on $N$ and $T$ (so not on the individual $z_1$, only on in this case their maximum). So you need only think of a way to express the joint CDF of the uniform distribution in this form, and then you're done.
Note: I suggest you don't read the rest of that Wikipedia page (only the section I linked to), as it spoils the answer to this problem.
|
Unbiased estimator and sufficient statistic from discrete uniform distribution
|
To find an unbiased estimator for $N$ using $z_1$, start from here: if $z_1 \sim \textrm{Unif}(1, N)$, then we want to find some function of $z_1$ such that $E(f(z_1)) = N$ (that's just what it means
|
Unbiased estimator and sufficient statistic from discrete uniform distribution
To find an unbiased estimator for $N$ using $z_1$, start from here: if $z_1 \sim \textrm{Unif}(1, N)$, then we want to find some function of $z_1$ such that $E(f(z_1)) = N$ (that's just what it means to be unbiased). Since $E(z_1) = \frac1N \sum_{i=1}^N i = \frac{N(N + 1)}{2N} = (N+1)/2$, it's hopefully pretty easy to come up with such a function...
You're on the right track. To prove it's sufficient you can use the Fisher-Neyman Factorization Theorem: a statistic $T(z_1, \dots, z_n)$ is sufficient for $N$ if the joint CDF $f_N(z_1, \dots, z_n)$ can be expressed as a product of two terms, one of which does not depend on $N$ (that is, it depends only on the $z_i$) and the other of which depends only on $N$ and $T$ (so not on the individual $z_1$, only on in this case their maximum). So you need only think of a way to express the joint CDF of the uniform distribution in this form, and then you're done.
Note: I suggest you don't read the rest of that Wikipedia page (only the section I linked to), as it spoils the answer to this problem.
|
Unbiased estimator and sufficient statistic from discrete uniform distribution
To find an unbiased estimator for $N$ using $z_1$, start from here: if $z_1 \sim \textrm{Unif}(1, N)$, then we want to find some function of $z_1$ such that $E(f(z_1)) = N$ (that's just what it means
|
47,337
|
What does muhaz return?
|
muhaz() doesn't return the baseline hazard rate, but the hazard function including the contribution of covariates to the final hazard. You can divide the two contribution as I do with this code. First start simulating a dataset with a fixed hazard rate $h_0$:
library(survival)
set.seed(6)
n <- 200
age <- 50 + 12*rnorm(n)
sex <- factor(sample(c('Male','Female'), n, rep=TRUE, prob=c(.6, .4)))
cens <- 15*runif(n)
h0 <- .02
h <- h0*exp(.05*age-.12*(sex=='Female')) # hazard
dt <- -log(runif(n))/h # calculated survival time
e <- ifelse(dt <= cens,1,0) # if time is lower than censoring
# time event = 1 else event = 0
dt <- pmin(dt, cens) # the effective observation time
# is the minimum between dt and cens
S <- Surv(dt, e) # create the Survival function
f <- coxph(S ~ age + sex) # define Cox model
cf <- f$coefficients # value of coefficients
pval <- summary(f)$coefficients[,5] # value of p-values
# create the data.frame:
dataset <- data.frame(cbind(age, sex, "time" = dt, "status" = e))
dataset$sex <- factor(x = dataset$sex, labels = c("Male", "Female"))
Afterwards you can calculate the hazard function by using muhaz. I prefer to create a more detailed (even if computationally intensive) function by setting the value of arguments n.min.grid = 1000, n.est.grid = 2000:
fmuhaz <- muhaz::muhaz(times = dataset$time,
delta = dataset$status,
n.min.grid = 1000, n.est.grid = 2000)
hfun <- approxfun(x = fmuhaz$est.grid, y = fmuhaz$haz.est)
dataset.order <- dataset[with(dataset, order(time)),]
dataset.order$BetaX <- exp( cf[1]*dataset.order$age +
cf[2]*as.numeric(dataset.order$sex=="Male") )
dataset.order$h0 <- NA
for (l in 1:(nrow(dataset) - 9)) {
dataset.order$h0[l] <- hfun(dataset.order$time[l]) /
mean(dataset.order$BetaX[l:nrow(dataset.order)])
}
plot(fmuhaz, lwd=2)
abline(h=h0, col="red", lty=2, lwd=2)
lines(x=dataset.order$time[1:(nrow(dataset.order) - 9)],
y=dataset.order$h0[ 1:(nrow(dataset.order) - 9)], lwd=2, col="blue")
After ordering the dataset according the time covariate I create the function that gives the values of the hazard rate by using approxfun. Then I calculate the values of the hazard rate for each time in the dataset ordered and divide the value by the $\sum_{i}^{T}\beta'X$ where $i$ is the number of the event and $T$ is the total number of the event, in other words I count only all cases remaining at risk at the moment of calculation. The sum stops when there are at least 10 more cases at risk, so giving the chance not to give high jumps in the value of hazard function. The number of 10 is taken from the help of muhaz where the authors give the boundaries of the calculation of the hazard function in terms of fmuhaz$est.grid and fmuhaz$haz.est. In the final plot you see in output it's possible to see the muhaz calculated hazard function (the black line), the original hazard function used for simulating the dataset (red dash line), and the baseline hazard function calculated by the method I explained (the blue line). You may see that actually the blue and red line lie close each other.
|
What does muhaz return?
|
muhaz() doesn't return the baseline hazard rate, but the hazard function including the contribution of covariates to the final hazard. You can divide the two contribution as I do with this code. Firs
|
What does muhaz return?
muhaz() doesn't return the baseline hazard rate, but the hazard function including the contribution of covariates to the final hazard. You can divide the two contribution as I do with this code. First start simulating a dataset with a fixed hazard rate $h_0$:
library(survival)
set.seed(6)
n <- 200
age <- 50 + 12*rnorm(n)
sex <- factor(sample(c('Male','Female'), n, rep=TRUE, prob=c(.6, .4)))
cens <- 15*runif(n)
h0 <- .02
h <- h0*exp(.05*age-.12*(sex=='Female')) # hazard
dt <- -log(runif(n))/h # calculated survival time
e <- ifelse(dt <= cens,1,0) # if time is lower than censoring
# time event = 1 else event = 0
dt <- pmin(dt, cens) # the effective observation time
# is the minimum between dt and cens
S <- Surv(dt, e) # create the Survival function
f <- coxph(S ~ age + sex) # define Cox model
cf <- f$coefficients # value of coefficients
pval <- summary(f)$coefficients[,5] # value of p-values
# create the data.frame:
dataset <- data.frame(cbind(age, sex, "time" = dt, "status" = e))
dataset$sex <- factor(x = dataset$sex, labels = c("Male", "Female"))
Afterwards you can calculate the hazard function by using muhaz. I prefer to create a more detailed (even if computationally intensive) function by setting the value of arguments n.min.grid = 1000, n.est.grid = 2000:
fmuhaz <- muhaz::muhaz(times = dataset$time,
delta = dataset$status,
n.min.grid = 1000, n.est.grid = 2000)
hfun <- approxfun(x = fmuhaz$est.grid, y = fmuhaz$haz.est)
dataset.order <- dataset[with(dataset, order(time)),]
dataset.order$BetaX <- exp( cf[1]*dataset.order$age +
cf[2]*as.numeric(dataset.order$sex=="Male") )
dataset.order$h0 <- NA
for (l in 1:(nrow(dataset) - 9)) {
dataset.order$h0[l] <- hfun(dataset.order$time[l]) /
mean(dataset.order$BetaX[l:nrow(dataset.order)])
}
plot(fmuhaz, lwd=2)
abline(h=h0, col="red", lty=2, lwd=2)
lines(x=dataset.order$time[1:(nrow(dataset.order) - 9)],
y=dataset.order$h0[ 1:(nrow(dataset.order) - 9)], lwd=2, col="blue")
After ordering the dataset according the time covariate I create the function that gives the values of the hazard rate by using approxfun. Then I calculate the values of the hazard rate for each time in the dataset ordered and divide the value by the $\sum_{i}^{T}\beta'X$ where $i$ is the number of the event and $T$ is the total number of the event, in other words I count only all cases remaining at risk at the moment of calculation. The sum stops when there are at least 10 more cases at risk, so giving the chance not to give high jumps in the value of hazard function. The number of 10 is taken from the help of muhaz where the authors give the boundaries of the calculation of the hazard function in terms of fmuhaz$est.grid and fmuhaz$haz.est. In the final plot you see in output it's possible to see the muhaz calculated hazard function (the black line), the original hazard function used for simulating the dataset (red dash line), and the baseline hazard function calculated by the method I explained (the blue line). You may see that actually the blue and red line lie close each other.
|
What does muhaz return?
muhaz() doesn't return the baseline hazard rate, but the hazard function including the contribution of covariates to the final hazard. You can divide the two contribution as I do with this code. Firs
|
47,338
|
OLS versus ML estimation of VECM
|
You are asking a complicated questions, to which there are no clear answers.
Is (1) more efficient than (2)?
Note actually that the Johansen ML estimator has a strange finite-sample distribution with no finite moments, and hence has a large variance. So it is most likely not more efficient than the "Granger 2-SLS". On the other side, "Granger 2-SLS" has a large bias in the first stage, which contaminates the second stage. A simple correction for that involves adding leads and lags in the first stage, as done by Saikonnen's estimator.
Will (2) and (3) give exactly the same estimates?
Mmh... I do not think you can use this procedure, as the restrictions due to B obviously have to be imposed with knowledge of B. So these will be the same only if you know in advance B, but then the restricted OLS procedure is of little interest...
Should any of the alternatives, or maybe yet another approach, be generally preferred?
There is no final answer to that, as in every case in statistics, it depends... There have been quite a lot of theoretical and Monte-Carlo comparisons, of these estimators, check Maddala and Kim (1998) for a discussion, or, one among others, or Gonzalo (1994).
and 5.
as you asked these questions in a separate post: Estimation of VECM via ML and OLS maybe you could remove from this one?
Refs:
G. S. Maddala and I-M. Kim (1998) Unit roots, Cointegration and Structural Change, Cambridge University Press
Gonzalo, Jesus, (1994) "Five alternative methods of estimating long-run equilibrium relationships," Journal of Econometrics, Elsevier, vol. 60(1-2), pages 203-233. http://www.eco.uc3m.es/~jgonzalo/teaching/PhDTimeSeries/gonzalojec94.pdf
|
OLS versus ML estimation of VECM
|
You are asking a complicated questions, to which there are no clear answers.
Is (1) more efficient than (2)?
Note actually that the Johansen ML estimator has a strange finite-sample distribution wit
|
OLS versus ML estimation of VECM
You are asking a complicated questions, to which there are no clear answers.
Is (1) more efficient than (2)?
Note actually that the Johansen ML estimator has a strange finite-sample distribution with no finite moments, and hence has a large variance. So it is most likely not more efficient than the "Granger 2-SLS". On the other side, "Granger 2-SLS" has a large bias in the first stage, which contaminates the second stage. A simple correction for that involves adding leads and lags in the first stage, as done by Saikonnen's estimator.
Will (2) and (3) give exactly the same estimates?
Mmh... I do not think you can use this procedure, as the restrictions due to B obviously have to be imposed with knowledge of B. So these will be the same only if you know in advance B, but then the restricted OLS procedure is of little interest...
Should any of the alternatives, or maybe yet another approach, be generally preferred?
There is no final answer to that, as in every case in statistics, it depends... There have been quite a lot of theoretical and Monte-Carlo comparisons, of these estimators, check Maddala and Kim (1998) for a discussion, or, one among others, or Gonzalo (1994).
and 5.
as you asked these questions in a separate post: Estimation of VECM via ML and OLS maybe you could remove from this one?
Refs:
G. S. Maddala and I-M. Kim (1998) Unit roots, Cointegration and Structural Change, Cambridge University Press
Gonzalo, Jesus, (1994) "Five alternative methods of estimating long-run equilibrium relationships," Journal of Econometrics, Elsevier, vol. 60(1-2), pages 203-233. http://www.eco.uc3m.es/~jgonzalo/teaching/PhDTimeSeries/gonzalojec94.pdf
|
OLS versus ML estimation of VECM
You are asking a complicated questions, to which there are no clear answers.
Is (1) more efficient than (2)?
Note actually that the Johansen ML estimator has a strange finite-sample distribution wit
|
47,339
|
OLS versus ML estimation of VECM
|
OLS assumptions do not cover the case when one or more predictors are equal to the lagged response. The so-called strict exogeneity assumption requires the predictor to be uncorrelated with the innovation. E.g. if in AR(1) we consider $y_{t-1}$ a predictor of $y_t$, then $y_{t-1}$ is correlated with $e_{t-1}$, $e_{t-2}$, etc. As a result, applying OLS to AR(1) will produce biased estimates that are still consistent.
The relevant links are here, here and Section 3.3 of this paper
|
OLS versus ML estimation of VECM
|
OLS assumptions do not cover the case when one or more predictors are equal to the lagged response. The so-called strict exogeneity assumption requires the predictor to be uncorrelated with the innova
|
OLS versus ML estimation of VECM
OLS assumptions do not cover the case when one or more predictors are equal to the lagged response. The so-called strict exogeneity assumption requires the predictor to be uncorrelated with the innovation. E.g. if in AR(1) we consider $y_{t-1}$ a predictor of $y_t$, then $y_{t-1}$ is correlated with $e_{t-1}$, $e_{t-2}$, etc. As a result, applying OLS to AR(1) will produce biased estimates that are still consistent.
The relevant links are here, here and Section 3.3 of this paper
|
OLS versus ML estimation of VECM
OLS assumptions do not cover the case when one or more predictors are equal to the lagged response. The so-called strict exogeneity assumption requires the predictor to be uncorrelated with the innova
|
47,340
|
How to "regress out" some variables? [duplicate]
|
It seems to me that the following is the mathematically simplest way to partial-out variables from a correlated set of items.
Consider a correlation matrix R for 5 items, where we want to "partial-out" the first two variables. This is the initial correlation-matrix:
$$ \text{ R =} \small \begin{bmatrix} \begin{array} {r}
1.00& -0.15& 0.27& 0.53& 0.24\\
-0.15& 1.00& -0.09& -0.50& -0.34\\
0.27& -0.09& 1.00& 0.22& 0.19\\
0.53& -0.50& 0.22& 1.00& 0.47\\
0.24& -0.34& 0.19& 0.47& 1.00 \end{array}
\end{bmatrix} $$
Now we want to partial out the first item. We determine the vector of correlations of all variables with it, this gives the vector $f_1$ (which is just the first column of R :
$$ f_1 = \small \begin{bmatrix} \begin{array} {r}
1.00\\
-0.15\\
0.27\\
0.53\\
0.24
\end{array} \end{bmatrix}
$$
Then build the matrix $R_1 = f_1 \cdot f_1^\tau$
$$ \text{ R}_1 =\small \begin{bmatrix} \begin{array} {rrrrr}
1.00& -0.15& 0.27& 0.53& 0.24\\
-0.15& 0.02& -0.04& -0.08& -0.04\\
0.27& -0.04& 0.07& 0.14& 0.06\\
0.53& -0.08& 0.14& 0.28& 0.12\\
0.24& -0.04& 0.06& 0.12& 0.06
\end{array} \end{bmatrix}
$$ and subtract this from the original matrix to get $R_{ \; \cdot 1}$
$$ \text{ R}_{\ \cdot 1} =\small \begin{bmatrix} \begin{array} {rrrrr}
0.00& 0.00& 0.00& 0.00& 0.00\\
0.00& 0.98& -0.05& -0.42& -0.30\\
0.00& -0.05& 0.93& 0.07& 0.13\\
0.00& -0.42& 0.07& 0.72& 0.35\\
0.00& -0.30& 0.13& 0.35& 0.94
\end{array}
\end{bmatrix}
$$
Now we look at the partial vector $f_{2 \cdot 1}$. First, we get just from extraction of the second column of the remaining covariance matrix. In order to have the entry in its second row such that then $R_{2 \cdot 1} = f_{2 \cdot 1} \cdot f_{2 \cdot 1}^\tau$ has the correct value in row and column 2 we must define $f_{2 \cdot 1} = f_{2 \cdot 1} / \sqrt{ f_{2 \cdot 1}[2]}$, thus we get:
$$ f_{2 \cdot 1}= \small \begin{bmatrix} \begin{array} {r}
0.00\\
0.99\\
-0.05\\
-0.42\\
-0.31
\end{array} \end{bmatrix} $$
Then $ \text{ R }_{2 \cdot 1} = f_{2 \cdot 1} \cdot f_{2 \cdot 1}^\tau $ and we find
$$ \text{ R }_{2 \cdot 1} = \small \begin{bmatrix} \begin{array} {rrrrr}
0.00& 0.00& 0.00& 0.00& 0.00\\
0.00& 0.98& -0.05& -0.42& -0.30\\
0.00& -0.05& 0.00& 0.02& 0.01\\
0.00& -0.42& 0.02& 0.18& 0.13\\
0.00& -0.30& 0.01& 0.13& 0.09
\end{array}
\end{bmatrix} $$
and after removing that covariance as well by $ \text{ R }_{ \cdot 12}= \text{ R }_{ \cdot 1}- \text{ R }_{ 2\cdot 1} $ we get
$$ \text{ R }_{ \cdot 12} =\small \begin{bmatrix} \begin{array} {rrrrr}
0.00& 0.00& 0.00& 0.00& 0.00\\
0.00& 0.00& 0.00& 0.00& 0.00\\
0.00& 0.00& 0.93& 0.05& 0.11\\
0.00& 0.00& 0.05& 0.54& 0.22\\
0.00& 0.00& 0.11& 0.22& 0.85
\end{array}
\end{bmatrix} $$
This can be iterated for the next variable(s) to be partialled out analoguously. You can then analyze the remaining nonzero-part as covariances, which are the "partial correlations" when the "partialled-out" variables are, so-to-say, "held constant".
|
How to "regress out" some variables? [duplicate]
|
It seems to me that the following is the mathematically simplest way to partial-out variables from a correlated set of items.
Consider a correlation matrix R for 5 items, where we want to "partial-
|
How to "regress out" some variables? [duplicate]
It seems to me that the following is the mathematically simplest way to partial-out variables from a correlated set of items.
Consider a correlation matrix R for 5 items, where we want to "partial-out" the first two variables. This is the initial correlation-matrix:
$$ \text{ R =} \small \begin{bmatrix} \begin{array} {r}
1.00& -0.15& 0.27& 0.53& 0.24\\
-0.15& 1.00& -0.09& -0.50& -0.34\\
0.27& -0.09& 1.00& 0.22& 0.19\\
0.53& -0.50& 0.22& 1.00& 0.47\\
0.24& -0.34& 0.19& 0.47& 1.00 \end{array}
\end{bmatrix} $$
Now we want to partial out the first item. We determine the vector of correlations of all variables with it, this gives the vector $f_1$ (which is just the first column of R :
$$ f_1 = \small \begin{bmatrix} \begin{array} {r}
1.00\\
-0.15\\
0.27\\
0.53\\
0.24
\end{array} \end{bmatrix}
$$
Then build the matrix $R_1 = f_1 \cdot f_1^\tau$
$$ \text{ R}_1 =\small \begin{bmatrix} \begin{array} {rrrrr}
1.00& -0.15& 0.27& 0.53& 0.24\\
-0.15& 0.02& -0.04& -0.08& -0.04\\
0.27& -0.04& 0.07& 0.14& 0.06\\
0.53& -0.08& 0.14& 0.28& 0.12\\
0.24& -0.04& 0.06& 0.12& 0.06
\end{array} \end{bmatrix}
$$ and subtract this from the original matrix to get $R_{ \; \cdot 1}$
$$ \text{ R}_{\ \cdot 1} =\small \begin{bmatrix} \begin{array} {rrrrr}
0.00& 0.00& 0.00& 0.00& 0.00\\
0.00& 0.98& -0.05& -0.42& -0.30\\
0.00& -0.05& 0.93& 0.07& 0.13\\
0.00& -0.42& 0.07& 0.72& 0.35\\
0.00& -0.30& 0.13& 0.35& 0.94
\end{array}
\end{bmatrix}
$$
Now we look at the partial vector $f_{2 \cdot 1}$. First, we get just from extraction of the second column of the remaining covariance matrix. In order to have the entry in its second row such that then $R_{2 \cdot 1} = f_{2 \cdot 1} \cdot f_{2 \cdot 1}^\tau$ has the correct value in row and column 2 we must define $f_{2 \cdot 1} = f_{2 \cdot 1} / \sqrt{ f_{2 \cdot 1}[2]}$, thus we get:
$$ f_{2 \cdot 1}= \small \begin{bmatrix} \begin{array} {r}
0.00\\
0.99\\
-0.05\\
-0.42\\
-0.31
\end{array} \end{bmatrix} $$
Then $ \text{ R }_{2 \cdot 1} = f_{2 \cdot 1} \cdot f_{2 \cdot 1}^\tau $ and we find
$$ \text{ R }_{2 \cdot 1} = \small \begin{bmatrix} \begin{array} {rrrrr}
0.00& 0.00& 0.00& 0.00& 0.00\\
0.00& 0.98& -0.05& -0.42& -0.30\\
0.00& -0.05& 0.00& 0.02& 0.01\\
0.00& -0.42& 0.02& 0.18& 0.13\\
0.00& -0.30& 0.01& 0.13& 0.09
\end{array}
\end{bmatrix} $$
and after removing that covariance as well by $ \text{ R }_{ \cdot 12}= \text{ R }_{ \cdot 1}- \text{ R }_{ 2\cdot 1} $ we get
$$ \text{ R }_{ \cdot 12} =\small \begin{bmatrix} \begin{array} {rrrrr}
0.00& 0.00& 0.00& 0.00& 0.00\\
0.00& 0.00& 0.00& 0.00& 0.00\\
0.00& 0.00& 0.93& 0.05& 0.11\\
0.00& 0.00& 0.05& 0.54& 0.22\\
0.00& 0.00& 0.11& 0.22& 0.85
\end{array}
\end{bmatrix} $$
This can be iterated for the next variable(s) to be partialled out analoguously. You can then analyze the remaining nonzero-part as covariances, which are the "partial correlations" when the "partialled-out" variables are, so-to-say, "held constant".
|
How to "regress out" some variables? [duplicate]
It seems to me that the following is the mathematically simplest way to partial-out variables from a correlated set of items.
Consider a correlation matrix R for 5 items, where we want to "partial-
|
47,341
|
Do Bayesians believe in Fixed Effect Models? [duplicate]
|
An excerpt from Jospeh B. Kadane's Principles of Uncertainty (p. 336, freely available):
This idea has old historical roots. Because these roots still play out in the current literature, it is useful to retrace a bit of them. The received wisdom in the early 1960's (see for example Scheffe (1959, 1999)) was to draw a distinction in linear models between “fixed effects” and “random effects”. “Mixed effect models" had both random effects and fixed effects. And what was the diference between random effects and fixed effects? It had to do with what you were interested in. If you were interested in the ability of each child, you would treat the $\alpha$’s as fixed effects parameters. If you were interested in the classes, but not the ability of each child, you would treat the $\beta$’s as random effects and the $\alpha$’s as fixed effects in the example. There are several peculiarities in this from a Bayesian point of view. First, “random effects” are parameters with priors. The classical analysis integrates those parameters out of the likelihood. But classically parameters are not supposed to have distributions, and integrating with respect to a parameter is supposedly an illegitimate move. Second, the distinction between “random" and “fixed” is essentially about what one wishes to estimate, and thus is a matter of the utility function. How can it be that the utility function can affect what the likelihood is, particularly in a classical context in which the likelihood is imagined to be the objective truth about how the data were generated? Third, what if I care both about the children individually and about how classes of children compare? I can't treat the same parameter as both fixed and random in the same analysis! I can remember confused social scientists wanting advice about which parameters to treat as random and which as fixed, and being surprised at the response that all parameters are random (i.e., are uncertain quantities that have distributions). From a Bayesian perspective there is no distinction, and no issue.
|
Do Bayesians believe in Fixed Effect Models? [duplicate]
|
An excerpt from Jospeh B. Kadane's Principles of Uncertainty (p. 336, freely available):
This idea has old historical roots. Because these roots still play out in the current literature, it is useful
|
Do Bayesians believe in Fixed Effect Models? [duplicate]
An excerpt from Jospeh B. Kadane's Principles of Uncertainty (p. 336, freely available):
This idea has old historical roots. Because these roots still play out in the current literature, it is useful to retrace a bit of them. The received wisdom in the early 1960's (see for example Scheffe (1959, 1999)) was to draw a distinction in linear models between “fixed effects” and “random effects”. “Mixed effect models" had both random effects and fixed effects. And what was the diference between random effects and fixed effects? It had to do with what you were interested in. If you were interested in the ability of each child, you would treat the $\alpha$’s as fixed effects parameters. If you were interested in the classes, but not the ability of each child, you would treat the $\beta$’s as random effects and the $\alpha$’s as fixed effects in the example. There are several peculiarities in this from a Bayesian point of view. First, “random effects” are parameters with priors. The classical analysis integrates those parameters out of the likelihood. But classically parameters are not supposed to have distributions, and integrating with respect to a parameter is supposedly an illegitimate move. Second, the distinction between “random" and “fixed” is essentially about what one wishes to estimate, and thus is a matter of the utility function. How can it be that the utility function can affect what the likelihood is, particularly in a classical context in which the likelihood is imagined to be the objective truth about how the data were generated? Third, what if I care both about the children individually and about how classes of children compare? I can't treat the same parameter as both fixed and random in the same analysis! I can remember confused social scientists wanting advice about which parameters to treat as random and which as fixed, and being surprised at the response that all parameters are random (i.e., are uncertain quantities that have distributions). From a Bayesian perspective there is no distinction, and no issue.
|
Do Bayesians believe in Fixed Effect Models? [duplicate]
An excerpt from Jospeh B. Kadane's Principles of Uncertainty (p. 336, freely available):
This idea has old historical roots. Because these roots still play out in the current literature, it is useful
|
47,342
|
Consistency of OLS in presence of deterministic trend
|
Not only is the OLS estimator consistent in the presence of a deterministic trend, it is, as they say, superconsistent, because it converges to the true value of the coefficient on the linear trend faster then the usual $O(T^{-1/2})$ rate -at $O(T^{-3/2})$. The estimator for the constant term converges at the usual rate, which makes a bit more complicated the derivation of the vector function that has an asymptotic distribution.
Consider
$y_t = \beta t + u_t$
The OLS estimator will be
$$\hat \beta = \frac {\sum_{t=1}^Tty_t}{\sum_{t=1}^Tt^2}= \beta +\frac {\sum_{t=1}^Ttu_t}{\sum_{t=1}^Tt^2}$$
One way to see the convergence is to consider
$$\operatorname {Var}(\hat \beta) = \sigma^2_u\frac {\sum_{t=1}^Tt^2}{\left(\sum_{t=1}^Tt^2\right)^2} = \sigma^2_u\frac {1}{\sum_{t=1}^Tt^2}$$
$$\Rightarrow \operatorname {Var}(\hat \beta) = \frac {\sigma^2_u}{T(T+1)(2T+1)/6}$$
This obviously goes to zero -and fast. So the variance of the estimator goes to zero (and it is also unbiased), which are sufficient conditions for consistency.
The result does not change if we add regressors in the specification -again we will have different rates of convergence of the estimators of the stationary regressor coefficients. It will require of course more sophisticated treatment.
Hamilton's "Time Series Analysis", ch. 16 contains a more elaborate discussion, examining also the asymptotic distribution of the estimator.
In short, from the two assumptions that you stated in your question, assumption 1) is a "convenient overkill", as regards consistency in the presence of a deterministic trend, and it is mainly needed for stochastic regressors. Note that it is critical for these results that we are talking about a deterministic trend.
|
Consistency of OLS in presence of deterministic trend
|
Not only is the OLS estimator consistent in the presence of a deterministic trend, it is, as they say, superconsistent, because it converges to the true value of the coefficient on the linear trend fa
|
Consistency of OLS in presence of deterministic trend
Not only is the OLS estimator consistent in the presence of a deterministic trend, it is, as they say, superconsistent, because it converges to the true value of the coefficient on the linear trend faster then the usual $O(T^{-1/2})$ rate -at $O(T^{-3/2})$. The estimator for the constant term converges at the usual rate, which makes a bit more complicated the derivation of the vector function that has an asymptotic distribution.
Consider
$y_t = \beta t + u_t$
The OLS estimator will be
$$\hat \beta = \frac {\sum_{t=1}^Tty_t}{\sum_{t=1}^Tt^2}= \beta +\frac {\sum_{t=1}^Ttu_t}{\sum_{t=1}^Tt^2}$$
One way to see the convergence is to consider
$$\operatorname {Var}(\hat \beta) = \sigma^2_u\frac {\sum_{t=1}^Tt^2}{\left(\sum_{t=1}^Tt^2\right)^2} = \sigma^2_u\frac {1}{\sum_{t=1}^Tt^2}$$
$$\Rightarrow \operatorname {Var}(\hat \beta) = \frac {\sigma^2_u}{T(T+1)(2T+1)/6}$$
This obviously goes to zero -and fast. So the variance of the estimator goes to zero (and it is also unbiased), which are sufficient conditions for consistency.
The result does not change if we add regressors in the specification -again we will have different rates of convergence of the estimators of the stationary regressor coefficients. It will require of course more sophisticated treatment.
Hamilton's "Time Series Analysis", ch. 16 contains a more elaborate discussion, examining also the asymptotic distribution of the estimator.
In short, from the two assumptions that you stated in your question, assumption 1) is a "convenient overkill", as regards consistency in the presence of a deterministic trend, and it is mainly needed for stochastic regressors. Note that it is critical for these results that we are talking about a deterministic trend.
|
Consistency of OLS in presence of deterministic trend
Not only is the OLS estimator consistent in the presence of a deterministic trend, it is, as they say, superconsistent, because it converges to the true value of the coefficient on the linear trend fa
|
47,343
|
Determining beta distribution parameters $\alpha$ and $\beta$ from two arbitrary points (quantiles)
|
Solution
The transformation
$$(p, x) \to (p, (x-L)/(U-L))$$
converts these points to ones on CDFs for a Beta$(\alpha,\beta)$ distribution. Assuming this has been done (so we don't need to change the notation), the problem is to find $\alpha$ and $\beta$ for which
$$F(\alpha, \beta; x_i) = p_i, i = 1, 2$$
where the Beta CDF equals
$$F(\alpha,\beta; x) = \frac{\Gamma(\alpha+\beta)}{\Gamma(\alpha)\Gamma(\beta)}\int_0^x t^{\alpha-1}(1-t)^{\beta-1} dt.$$
This is a nice function of $\alpha \gt 0$ and $\beta \gt 0$: it is differentiable in those arguments and not too expensive to evaluate. However, there exists no closed-form general solution, so numerical methods must be used.
Implementation Tips
Beware: when both $x_i$ are at the same tail of the distribution, or when either is close to $0$ or $1$, finding a reliable solution can be problematic. Techniques that are helpful in this circumstance are
Reparameterize the distributions to avoid enforcing the "hard" constraints $\alpha\ge 0, \beta \ge 0$. One that works is to use the logarithms of these parameters.
Optimize a measure of the relative error. A good way to do this for a CDF is to use the squared difference of the logits of the values: that is, replace the $p_i$ by $\text{logit}(p_i) = \log(p_i/(1-p_i))$ and fit $\text{logit}(F(\alpha,\beta;x_i))$ to these values by minimizing the sum of squared differences.
Either begin with a very good estimate of the parameters or--as experimentation shows--overestimate them. (This may be less necessary when following guideline #2.)
Examples
Illustrating these methods is the following sample code using the nlm minimizer in R. It produces perfect fits even in the first case, which is numerically challenging because the $x_i$ are small and far out into the same tail. The output includes plots of the true CDFs (in black) on which are overlaid the fits (in red). The points on the plots show the two $(x_i, p_i)$ pairs.
This solution can fail in more extreme circumstances: obtaining a close estimate of the correct parameters can help assure success.
#
# Logistic transformation of the Beta CDF.
#
f.beta <- function(alpha, beta, x, lower=0, upper=1) {
p <- pbeta((x-lower)/(upper-lower), alpha, beta)
log(p/(1-p))
}
#
# Sums of squares.
#
delta <- function(fit, actual) sum((fit-actual)^2)
#
# The objective function handles the transformed parameters `theta` and
# uses `f.beta` and `delta` to fit the values and measure their discrepancies.
#
objective <- function(theta, x, prob, ...) {
ab <- exp(theta) # Parameters are the *logs* of alpha and beta
fit <- f.beta(ab[1], ab[2], x, ...)
return (delta(fit, prob))
}
#
# Solve two problems.
#
par(mfrow=c(1,2))
alpha <- 15; beta <- 22 # The true parameters
for (x in list(c(1e-3, 2e-3), c(1/3, 2/3))) {
x.p <- f.beta(alpha, beta, x) # The correct values of the p_i
start <- log(c(1e1, 1e1)) # A good guess is useful here
sol <- nlm(objective, start, x=x, prob=x.p, lower=0, upper=1,
typsize=c(1,1), fscale=1e-12, gradtol=1e-12)
parms <- exp(sol$estimate) # Estimates of alpha and beta
#
# Display the actual and estimated values.
#
print(rbind(Actual=c(alpha=alpha, beta=beta), Fit=parms))
#
# Plot the true and estimated CDFs.
#
curve(pbeta(x, alpha, beta), 0, 1, n=1001, lwd=2)
curve(pbeta(x, parms[1], parms[2]), n=1001, add=TRUE, col="Red")
points(x, pbeta(x, alpha, beta))
}
|
Determining beta distribution parameters $\alpha$ and $\beta$ from two arbitrary points (quantiles)
|
Solution
The transformation
$$(p, x) \to (p, (x-L)/(U-L))$$
converts these points to ones on CDFs for a Beta$(\alpha,\beta)$ distribution. Assuming this has been done (so we don't need to change the
|
Determining beta distribution parameters $\alpha$ and $\beta$ from two arbitrary points (quantiles)
Solution
The transformation
$$(p, x) \to (p, (x-L)/(U-L))$$
converts these points to ones on CDFs for a Beta$(\alpha,\beta)$ distribution. Assuming this has been done (so we don't need to change the notation), the problem is to find $\alpha$ and $\beta$ for which
$$F(\alpha, \beta; x_i) = p_i, i = 1, 2$$
where the Beta CDF equals
$$F(\alpha,\beta; x) = \frac{\Gamma(\alpha+\beta)}{\Gamma(\alpha)\Gamma(\beta)}\int_0^x t^{\alpha-1}(1-t)^{\beta-1} dt.$$
This is a nice function of $\alpha \gt 0$ and $\beta \gt 0$: it is differentiable in those arguments and not too expensive to evaluate. However, there exists no closed-form general solution, so numerical methods must be used.
Implementation Tips
Beware: when both $x_i$ are at the same tail of the distribution, or when either is close to $0$ or $1$, finding a reliable solution can be problematic. Techniques that are helpful in this circumstance are
Reparameterize the distributions to avoid enforcing the "hard" constraints $\alpha\ge 0, \beta \ge 0$. One that works is to use the logarithms of these parameters.
Optimize a measure of the relative error. A good way to do this for a CDF is to use the squared difference of the logits of the values: that is, replace the $p_i$ by $\text{logit}(p_i) = \log(p_i/(1-p_i))$ and fit $\text{logit}(F(\alpha,\beta;x_i))$ to these values by minimizing the sum of squared differences.
Either begin with a very good estimate of the parameters or--as experimentation shows--overestimate them. (This may be less necessary when following guideline #2.)
Examples
Illustrating these methods is the following sample code using the nlm minimizer in R. It produces perfect fits even in the first case, which is numerically challenging because the $x_i$ are small and far out into the same tail. The output includes plots of the true CDFs (in black) on which are overlaid the fits (in red). The points on the plots show the two $(x_i, p_i)$ pairs.
This solution can fail in more extreme circumstances: obtaining a close estimate of the correct parameters can help assure success.
#
# Logistic transformation of the Beta CDF.
#
f.beta <- function(alpha, beta, x, lower=0, upper=1) {
p <- pbeta((x-lower)/(upper-lower), alpha, beta)
log(p/(1-p))
}
#
# Sums of squares.
#
delta <- function(fit, actual) sum((fit-actual)^2)
#
# The objective function handles the transformed parameters `theta` and
# uses `f.beta` and `delta` to fit the values and measure their discrepancies.
#
objective <- function(theta, x, prob, ...) {
ab <- exp(theta) # Parameters are the *logs* of alpha and beta
fit <- f.beta(ab[1], ab[2], x, ...)
return (delta(fit, prob))
}
#
# Solve two problems.
#
par(mfrow=c(1,2))
alpha <- 15; beta <- 22 # The true parameters
for (x in list(c(1e-3, 2e-3), c(1/3, 2/3))) {
x.p <- f.beta(alpha, beta, x) # The correct values of the p_i
start <- log(c(1e1, 1e1)) # A good guess is useful here
sol <- nlm(objective, start, x=x, prob=x.p, lower=0, upper=1,
typsize=c(1,1), fscale=1e-12, gradtol=1e-12)
parms <- exp(sol$estimate) # Estimates of alpha and beta
#
# Display the actual and estimated values.
#
print(rbind(Actual=c(alpha=alpha, beta=beta), Fit=parms))
#
# Plot the true and estimated CDFs.
#
curve(pbeta(x, alpha, beta), 0, 1, n=1001, lwd=2)
curve(pbeta(x, parms[1], parms[2]), n=1001, add=TRUE, col="Red")
points(x, pbeta(x, alpha, beta))
}
|
Determining beta distribution parameters $\alpha$ and $\beta$ from two arbitrary points (quantiles)
Solution
The transformation
$$(p, x) \to (p, (x-L)/(U-L))$$
converts these points to ones on CDFs for a Beta$(\alpha,\beta)$ distribution. Assuming this has been done (so we don't need to change the
|
47,344
|
Why am I getting a 10-15% type I error rate for a 2 x 2 ANOVA?
|
As we have already discussed in the comments above, ANOVA controls family-wise type I error rate across the "family" of levels, not across the "family" of factors. For example, one-way ANOVA with 10 groups (levels) controls the error rate, as opposed to performing all 45 pairwise t-tests that obviously runs into the multiple comparison problem. However, two-way ANOVA tests two factors and an interaction, so essentially performs three separate F tests. As is nicely demonstrated by your simulation, this also suffers from a multiple comparison problem, which is not controlled by ANOVA. Note that $1-(1-0.05)^3=0.14$, so your simulation provided a very precise estimate of the theoretically expected error rate.
I am no expert on that, but after I wrote my comments above I made a google search and stumbled upon Cramer et al. Hidden Multiplicity in Multiway ANOVA: Prevalence, Consequences, and Remedies, apparently a preprint from 2013. Let me quote their abstract verbatim:
Many empirical researchers do not realize that the common multiway analysis of variance (ANOVA) harbors a multiple comparison problem. In the case of two factors,
three separate null hypotheses are subject to test (i.e., two main effects and one interaction). Consequently, the probability of a Type I error is 14% rather than 5%. We explain the multiple comparison problem and demonstrate that researchers almost never correct for it. We describe one of several correction procedures (i.e., sequential Bonferroni), and show that its application alters at least one of the substantive conclusions in 45 out of 60 articles considered. An alternative method to
combat the multiplicity in multiway ANOVA is preregistration of hypotheses.
|
Why am I getting a 10-15% type I error rate for a 2 x 2 ANOVA?
|
As we have already discussed in the comments above, ANOVA controls family-wise type I error rate across the "family" of levels, not across the "family" of factors. For example, one-way ANOVA with 10 g
|
Why am I getting a 10-15% type I error rate for a 2 x 2 ANOVA?
As we have already discussed in the comments above, ANOVA controls family-wise type I error rate across the "family" of levels, not across the "family" of factors. For example, one-way ANOVA with 10 groups (levels) controls the error rate, as opposed to performing all 45 pairwise t-tests that obviously runs into the multiple comparison problem. However, two-way ANOVA tests two factors and an interaction, so essentially performs three separate F tests. As is nicely demonstrated by your simulation, this also suffers from a multiple comparison problem, which is not controlled by ANOVA. Note that $1-(1-0.05)^3=0.14$, so your simulation provided a very precise estimate of the theoretically expected error rate.
I am no expert on that, but after I wrote my comments above I made a google search and stumbled upon Cramer et al. Hidden Multiplicity in Multiway ANOVA: Prevalence, Consequences, and Remedies, apparently a preprint from 2013. Let me quote their abstract verbatim:
Many empirical researchers do not realize that the common multiway analysis of variance (ANOVA) harbors a multiple comparison problem. In the case of two factors,
three separate null hypotheses are subject to test (i.e., two main effects and one interaction). Consequently, the probability of a Type I error is 14% rather than 5%. We explain the multiple comparison problem and demonstrate that researchers almost never correct for it. We describe one of several correction procedures (i.e., sequential Bonferroni), and show that its application alters at least one of the substantive conclusions in 45 out of 60 articles considered. An alternative method to
combat the multiplicity in multiway ANOVA is preregistration of hypotheses.
|
Why am I getting a 10-15% type I error rate for a 2 x 2 ANOVA?
As we have already discussed in the comments above, ANOVA controls family-wise type I error rate across the "family" of levels, not across the "family" of factors. For example, one-way ANOVA with 10 g
|
47,345
|
Why am I getting a 10-15% type I error rate for a 2 x 2 ANOVA?
|
The ANOVA procedures can control the family wise error across the entire set of factors and interactions, but you need to do it correctly, not look at the minimum of multiple p-values. One way to see the overall F test is to run summary.lm on your result object rather than just summary then look at the bottom of the print out. For simulation it can be easier to compare to a null model (intercept only) using the anova function. Here is a new version of your simulation function that does the overall test:
do.anova2 <- function(dat) {
results <- aov(value ~ factor1 * factor2, data=dat)
results0 <- update(results, .~1)
anova(results0, results)[2,6]
}
When we run this version:
> out2 <- replicate(1000, do.anova2(generate.dat()))
> mean(out2 < 0.05)
[1] 0.043
> out2 <- replicate(1000, do.anova2(generate.dat()))
> mean(out2 < 0.05)
[1] 0.049
> out2 <- replicate(1000, do.anova2(generate.dat()))
> mean(out2 < 0.05)
[1] 0.051
>
We see the about 5% that you were expecting.
|
Why am I getting a 10-15% type I error rate for a 2 x 2 ANOVA?
|
The ANOVA procedures can control the family wise error across the entire set of factors and interactions, but you need to do it correctly, not look at the minimum of multiple p-values. One way to see
|
Why am I getting a 10-15% type I error rate for a 2 x 2 ANOVA?
The ANOVA procedures can control the family wise error across the entire set of factors and interactions, but you need to do it correctly, not look at the minimum of multiple p-values. One way to see the overall F test is to run summary.lm on your result object rather than just summary then look at the bottom of the print out. For simulation it can be easier to compare to a null model (intercept only) using the anova function. Here is a new version of your simulation function that does the overall test:
do.anova2 <- function(dat) {
results <- aov(value ~ factor1 * factor2, data=dat)
results0 <- update(results, .~1)
anova(results0, results)[2,6]
}
When we run this version:
> out2 <- replicate(1000, do.anova2(generate.dat()))
> mean(out2 < 0.05)
[1] 0.043
> out2 <- replicate(1000, do.anova2(generate.dat()))
> mean(out2 < 0.05)
[1] 0.049
> out2 <- replicate(1000, do.anova2(generate.dat()))
> mean(out2 < 0.05)
[1] 0.051
>
We see the about 5% that you were expecting.
|
Why am I getting a 10-15% type I error rate for a 2 x 2 ANOVA?
The ANOVA procedures can control the family wise error across the entire set of factors and interactions, but you need to do it correctly, not look at the minimum of multiple p-values. One way to see
|
47,346
|
How do betting sites update odds during a sporting match in real-time?
|
The collection of odds (which I will call 'the book') are set up so bookies will make a profit.
As the bets come in, those odds have to shift in response, to keep the book in profit, so a given bet placed at one time will get different odds than a bet placed at a different time.
A second factor: if bookies offer odds too different from other bookies, they may experience punters exploiting that by 'making a book' of their own. So they tend to pay very close attention to other bookmakers odds and adjust in response.
If a bookie gets a bet large enough to eat their profits if it wins, they may attempt to 'lay off' a chunk of the bet with other bookmakers.
In some sporting events, the use of point-spreads comes into the calculations, either in place of or along with over-round, depending on the situation.
These days the whole book can be managed by computers. (If they're working with point-spreads, there may be some more-or-less formal model for the point-distribution of the two sides that will update over time. It may include whatever factors it occurs to them to include. Such information tends to be secret, since telling people too much information about your models will make you more easy to exploit, and there's a lot of money involved.)
You may find the following details of some help Making a book and Spread betting.
|
How do betting sites update odds during a sporting match in real-time?
|
The collection of odds (which I will call 'the book') are set up so bookies will make a profit.
As the bets come in, those odds have to shift in response, to keep the book in profit, so a given bet pl
|
How do betting sites update odds during a sporting match in real-time?
The collection of odds (which I will call 'the book') are set up so bookies will make a profit.
As the bets come in, those odds have to shift in response, to keep the book in profit, so a given bet placed at one time will get different odds than a bet placed at a different time.
A second factor: if bookies offer odds too different from other bookies, they may experience punters exploiting that by 'making a book' of their own. So they tend to pay very close attention to other bookmakers odds and adjust in response.
If a bookie gets a bet large enough to eat their profits if it wins, they may attempt to 'lay off' a chunk of the bet with other bookmakers.
In some sporting events, the use of point-spreads comes into the calculations, either in place of or along with over-round, depending on the situation.
These days the whole book can be managed by computers. (If they're working with point-spreads, there may be some more-or-less formal model for the point-distribution of the two sides that will update over time. It may include whatever factors it occurs to them to include. Such information tends to be secret, since telling people too much information about your models will make you more easy to exploit, and there's a lot of money involved.)
You may find the following details of some help Making a book and Spread betting.
|
How do betting sites update odds during a sporting match in real-time?
The collection of odds (which I will call 'the book') are set up so bookies will make a profit.
As the bets come in, those odds have to shift in response, to keep the book in profit, so a given bet pl
|
47,347
|
How to calculate standard error of sample quantile from normal distribution with known mean and standard deviation?
|
This at least gives some pointers for - and a partial answer to - this question.
In the case of sample quantiles, the standard error depends on which definition of sample quantiles you actually use. I believe R, for example, includes 9 different definitions of quantiles in its quantile function.
For cases where the sample quantile is an exact order statistic, the standard error of the sample quantile follows from the standard error of that order statistic.
If a quantile is based on some weighted average of two order statistics, then the standard error can be obtained from their variances, their covariance and the weights.
As a result, confidence intervals can be formed; in the case of a quantile being an order statistic, a binomial distribution can be used to form a nonparametric interval directly from order statistics.
|
How to calculate standard error of sample quantile from normal distribution with known mean and stan
|
This at least gives some pointers for - and a partial answer to - this question.
In the case of sample quantiles, the standard error depends on which definition of sample quantiles you actually use. I
|
How to calculate standard error of sample quantile from normal distribution with known mean and standard deviation?
This at least gives some pointers for - and a partial answer to - this question.
In the case of sample quantiles, the standard error depends on which definition of sample quantiles you actually use. I believe R, for example, includes 9 different definitions of quantiles in its quantile function.
For cases where the sample quantile is an exact order statistic, the standard error of the sample quantile follows from the standard error of that order statistic.
If a quantile is based on some weighted average of two order statistics, then the standard error can be obtained from their variances, their covariance and the weights.
As a result, confidence intervals can be formed; in the case of a quantile being an order statistic, a binomial distribution can be used to form a nonparametric interval directly from order statistics.
|
How to calculate standard error of sample quantile from normal distribution with known mean and stan
This at least gives some pointers for - and a partial answer to - this question.
In the case of sample quantiles, the standard error depends on which definition of sample quantiles you actually use. I
|
47,348
|
How to calculate standard error of sample quantile from normal distribution with known mean and standard deviation?
|
I encountered the problem of computing the standard error for sample quantiles of a normal distribution while attending a course of Quantitative Finance during my MSc. The main topic related to this problem regarded the analysis of Value at Risk.
This is the closed form solution:
$$
s.e.\left( \widehat{z}_{\alpha}\right)=\sigma \cdot \sqrt{\dfrac{1}{n}} \cdot \sqrt{1+2z_{\alpha}^2\left( \dfrac{n-1}{2}-\dfrac{\Gamma^2(n/2)}{\Gamma^2((n-1)/2)} \right)}
$$
unfortunatly until now I can't provide you any reference for the proof.
|
How to calculate standard error of sample quantile from normal distribution with known mean and stan
|
I encountered the problem of computing the standard error for sample quantiles of a normal distribution while attending a course of Quantitative Finance during my MSc. The main topic related to this p
|
How to calculate standard error of sample quantile from normal distribution with known mean and standard deviation?
I encountered the problem of computing the standard error for sample quantiles of a normal distribution while attending a course of Quantitative Finance during my MSc. The main topic related to this problem regarded the analysis of Value at Risk.
This is the closed form solution:
$$
s.e.\left( \widehat{z}_{\alpha}\right)=\sigma \cdot \sqrt{\dfrac{1}{n}} \cdot \sqrt{1+2z_{\alpha}^2\left( \dfrac{n-1}{2}-\dfrac{\Gamma^2(n/2)}{\Gamma^2((n-1)/2)} \right)}
$$
unfortunatly until now I can't provide you any reference for the proof.
|
How to calculate standard error of sample quantile from normal distribution with known mean and stan
I encountered the problem of computing the standard error for sample quantiles of a normal distribution while attending a course of Quantitative Finance during my MSc. The main topic related to this p
|
47,349
|
What does the notation $(\textbf{X} \perp \textbf{Y} , \textbf{W}\mid \textbf{Z})$ mean?
|
The interpretation of the comma depends on context. In the case
$$A \perp B, C$$
which is a statement about (un-)conditional dependencies, it means "$A$ is independent of the combined set of events $B \cup C$".
In the case,
$$P(A = a, B = b)$$
which is about specific events, it means "the probability of both $a$ and $b$ occurring together", ie $P(A=a) \cap P(B=b)$.
I think this corresponds with how most people would intuitively interpret the comma in both situations. I certainly didn't find anything ambiguous or sloppy in the examples given.
If there's any ambiguity, I'd say it's in the order of precedence for the various symbols and punctuation marks. At first glance I thought $\textbf{X} \perp \textbf{Y} , \textbf{W}\mid \textbf{Z}$ meant $(\textbf{X} \perp \textbf{Y})$, followed by $(\textbf{W}\mid \textbf{Z})$....
|
What does the notation $(\textbf{X} \perp \textbf{Y} , \textbf{W}\mid \textbf{Z})$ mean?
|
The interpretation of the comma depends on context. In the case
$$A \perp B, C$$
which is a statement about (un-)conditional dependencies, it means "$A$ is independent of the combined set of events $B
|
What does the notation $(\textbf{X} \perp \textbf{Y} , \textbf{W}\mid \textbf{Z})$ mean?
The interpretation of the comma depends on context. In the case
$$A \perp B, C$$
which is a statement about (un-)conditional dependencies, it means "$A$ is independent of the combined set of events $B \cup C$".
In the case,
$$P(A = a, B = b)$$
which is about specific events, it means "the probability of both $a$ and $b$ occurring together", ie $P(A=a) \cap P(B=b)$.
I think this corresponds with how most people would intuitively interpret the comma in both situations. I certainly didn't find anything ambiguous or sloppy in the examples given.
If there's any ambiguity, I'd say it's in the order of precedence for the various symbols and punctuation marks. At first glance I thought $\textbf{X} \perp \textbf{Y} , \textbf{W}\mid \textbf{Z}$ meant $(\textbf{X} \perp \textbf{Y})$, followed by $(\textbf{W}\mid \textbf{Z})$....
|
What does the notation $(\textbf{X} \perp \textbf{Y} , \textbf{W}\mid \textbf{Z})$ mean?
The interpretation of the comma depends on context. In the case
$$A \perp B, C$$
which is a statement about (un-)conditional dependencies, it means "$A$ is independent of the combined set of events $B
|
47,350
|
What does the notation $(\textbf{X} \perp \textbf{Y} , \textbf{W}\mid \textbf{Z})$ mean?
|
The puzzling equation appears to be
$$(A \perp_{\sigma} (B \cup D) \mid C) \implies (A \perp_{\sigma} B \mid C) \text{ and } (A \perp_{\sigma} D \mid C)$$
Try to write the left-hand side as an intersection (an "and")
$$(A \perp_{\sigma} (B \cap D) \mid C) \implies (A \perp_{\sigma} B \mid C) \text{ and } (A \perp_{\sigma} D \mid C) \qquad ??$$
Is it now true? In the left-hand side, only the parts of $B$ and $D$ that coincide appear, and the relation of this "common part" with $A$ is characterized, under the light of $C$. But in the right hand side, both $B$ and $D$ appear in their wholeness - so we can not go from the LHS to the RHS, since the left hand side remains silent about either $B$ \ $D$, or $D$ \ $B$, which appear in the right-hand side.
But in the initial statement of the presentation, we cover in the left-hand side already the whole of $B$ and the whole of $D$ by using union.
|
What does the notation $(\textbf{X} \perp \textbf{Y} , \textbf{W}\mid \textbf{Z})$ mean?
|
The puzzling equation appears to be
$$(A \perp_{\sigma} (B \cup D) \mid C) \implies (A \perp_{\sigma} B \mid C) \text{ and } (A \perp_{\sigma} D \mid C)$$
Try to write the left-hand side as an interse
|
What does the notation $(\textbf{X} \perp \textbf{Y} , \textbf{W}\mid \textbf{Z})$ mean?
The puzzling equation appears to be
$$(A \perp_{\sigma} (B \cup D) \mid C) \implies (A \perp_{\sigma} B \mid C) \text{ and } (A \perp_{\sigma} D \mid C)$$
Try to write the left-hand side as an intersection (an "and")
$$(A \perp_{\sigma} (B \cap D) \mid C) \implies (A \perp_{\sigma} B \mid C) \text{ and } (A \perp_{\sigma} D \mid C) \qquad ??$$
Is it now true? In the left-hand side, only the parts of $B$ and $D$ that coincide appear, and the relation of this "common part" with $A$ is characterized, under the light of $C$. But in the right hand side, both $B$ and $D$ appear in their wholeness - so we can not go from the LHS to the RHS, since the left hand side remains silent about either $B$ \ $D$, or $D$ \ $B$, which appear in the right-hand side.
But in the initial statement of the presentation, we cover in the left-hand side already the whole of $B$ and the whole of $D$ by using union.
|
What does the notation $(\textbf{X} \perp \textbf{Y} , \textbf{W}\mid \textbf{Z})$ mean?
The puzzling equation appears to be
$$(A \perp_{\sigma} (B \cup D) \mid C) \implies (A \perp_{\sigma} B \mid C) \text{ and } (A \perp_{\sigma} D \mid C)$$
Try to write the left-hand side as an interse
|
47,351
|
What does the notation $(\textbf{X} \perp \textbf{Y} , \textbf{W}\mid \textbf{Z})$ mean?
|
In Koller's book(2009), the two cases in your question are weak union and decomposition respectively.
The proof of the decomposition is given on the book(page 25) using the reasoning by cases, and it seems very clear that the comma represents "AND".
For the weak union property, here is my proof. Hope it may be of any help.
We assume that $(X\perp Y, W|Z)$ holds, then we can obtain:
\begin{align}
P(X, Y|Z, W) &= \frac{P(X, Y, W|Z)}{P(W|Z)}\\
&= \frac{P(X|Z)P(Y,W|Z)}{P(W|Z)}\\
&= \frac{P(X|W,Z)P(Y,W|Z)}{P(W|Z)}\\
&= P(X|W, Z) P(Y|W,Z)
\end{align}
Then the weak union property holds.
For the third equality, it is because of the decomposition property: if $(X|Y,W|Z)$ holds we can get $P(X,W|Z) = P(X|Z)P(W|Z)$(and hence $P(X|Z)=\frac{P(X,W|Z)}{P(W|Z)}=P(X|W,Z)$).
|
What does the notation $(\textbf{X} \perp \textbf{Y} , \textbf{W}\mid \textbf{Z})$ mean?
|
In Koller's book(2009), the two cases in your question are weak union and decomposition respectively.
The proof of the decomposition is given on the book(page 25) using the reasoning by cases, and it
|
What does the notation $(\textbf{X} \perp \textbf{Y} , \textbf{W}\mid \textbf{Z})$ mean?
In Koller's book(2009), the two cases in your question are weak union and decomposition respectively.
The proof of the decomposition is given on the book(page 25) using the reasoning by cases, and it seems very clear that the comma represents "AND".
For the weak union property, here is my proof. Hope it may be of any help.
We assume that $(X\perp Y, W|Z)$ holds, then we can obtain:
\begin{align}
P(X, Y|Z, W) &= \frac{P(X, Y, W|Z)}{P(W|Z)}\\
&= \frac{P(X|Z)P(Y,W|Z)}{P(W|Z)}\\
&= \frac{P(X|W,Z)P(Y,W|Z)}{P(W|Z)}\\
&= P(X|W, Z) P(Y|W,Z)
\end{align}
Then the weak union property holds.
For the third equality, it is because of the decomposition property: if $(X|Y,W|Z)$ holds we can get $P(X,W|Z) = P(X|Z)P(W|Z)$(and hence $P(X|Z)=\frac{P(X,W|Z)}{P(W|Z)}=P(X|W,Z)$).
|
What does the notation $(\textbf{X} \perp \textbf{Y} , \textbf{W}\mid \textbf{Z})$ mean?
In Koller's book(2009), the two cases in your question are weak union and decomposition respectively.
The proof of the decomposition is given on the book(page 25) using the reasoning by cases, and it
|
47,352
|
Reference for dimension reduction techniques
|
Here's a good paper comparing various dimension reduction techniques to PCA:
http://www.iai.uni-bonn.de/~jz/dimensionality_reduction_a_comparative_review.pdf
In brief, the paper covers the following techniques, though there are many more:
(1) multidimensional scaling, (2) Isomap, (3) Maximum Variance Unfolding,
(4) Kernel PCA, (5) diffusion maps, (6) multilayer autoencoders, (7) Locally Linear Embedding, (8) Laplacian Eigenmaps, (9) Hessian LLE, (10) Local Tangent Space Analysis, (11) Locally Linear Coordination, and (12) manifold charting
In fact, many of the methods not covered are briefly described in Appendix A.
Moving into the paper, you can see that those above techniques are described in some detail as to their theoretical underpinnings. Table 1 compares the algorithms on convexity of optimization, parameters, computational complexity, and memory complexity.
Table 4 shows the results of the algorithms being run on many example datasets, and the resulting generalization error rates.
In the end, the authors believe that PCA is quite useful/good. For more info on dimension reduction, see his references.
Edit: here's a specific sentence highlighting what you wanted to know about MDS vs Isomap:
Performing MDS using geodesic distances is identical to performing Isomap.
Bonus: My favorite paper using PCA analysis
|
Reference for dimension reduction techniques
|
Here's a good paper comparing various dimension reduction techniques to PCA:
http://www.iai.uni-bonn.de/~jz/dimensionality_reduction_a_comparative_review.pdf
In brief, the paper covers the following
|
Reference for dimension reduction techniques
Here's a good paper comparing various dimension reduction techniques to PCA:
http://www.iai.uni-bonn.de/~jz/dimensionality_reduction_a_comparative_review.pdf
In brief, the paper covers the following techniques, though there are many more:
(1) multidimensional scaling, (2) Isomap, (3) Maximum Variance Unfolding,
(4) Kernel PCA, (5) diffusion maps, (6) multilayer autoencoders, (7) Locally Linear Embedding, (8) Laplacian Eigenmaps, (9) Hessian LLE, (10) Local Tangent Space Analysis, (11) Locally Linear Coordination, and (12) manifold charting
In fact, many of the methods not covered are briefly described in Appendix A.
Moving into the paper, you can see that those above techniques are described in some detail as to their theoretical underpinnings. Table 1 compares the algorithms on convexity of optimization, parameters, computational complexity, and memory complexity.
Table 4 shows the results of the algorithms being run on many example datasets, and the resulting generalization error rates.
In the end, the authors believe that PCA is quite useful/good. For more info on dimension reduction, see his references.
Edit: here's a specific sentence highlighting what you wanted to know about MDS vs Isomap:
Performing MDS using geodesic distances is identical to performing Isomap.
Bonus: My favorite paper using PCA analysis
|
Reference for dimension reduction techniques
Here's a good paper comparing various dimension reduction techniques to PCA:
http://www.iai.uni-bonn.de/~jz/dimensionality_reduction_a_comparative_review.pdf
In brief, the paper covers the following
|
47,353
|
How to normalize time series?
|
Normalization isn't always necessary. We use it with certain methods (such as Principal Component Analysis) because otherwise, the values that have a larger scale will be given an increased weight. Here's a discussion of why normalization is necessary within the PCA context -- the same basic argument applies to other techniques that are sensitive to scale: Why do we need to normalize data before analysis
It would depend on what your intention was with the normalization, and what type of analysis you intended to do. Feature scaling is a pretty common normalization technique, and what I usually default to unless there is a reason to attempt another technique. You can read about other normalization techniques here: http://en.wikipedia.org/wiki/Normalization_(statistics).
|
How to normalize time series?
|
Normalization isn't always necessary. We use it with certain methods (such as Principal Component Analysis) because otherwise, the values that have a larger scale will be given an increased weight. He
|
How to normalize time series?
Normalization isn't always necessary. We use it with certain methods (such as Principal Component Analysis) because otherwise, the values that have a larger scale will be given an increased weight. Here's a discussion of why normalization is necessary within the PCA context -- the same basic argument applies to other techniques that are sensitive to scale: Why do we need to normalize data before analysis
It would depend on what your intention was with the normalization, and what type of analysis you intended to do. Feature scaling is a pretty common normalization technique, and what I usually default to unless there is a reason to attempt another technique. You can read about other normalization techniques here: http://en.wikipedia.org/wiki/Normalization_(statistics).
|
How to normalize time series?
Normalization isn't always necessary. We use it with certain methods (such as Principal Component Analysis) because otherwise, the values that have a larger scale will be given an increased weight. He
|
47,354
|
wilson's adjustment for sample proportion
|
To my understanding the Wilson estimate is the center of the Wilson interval, which gives
the estimate
$$\tilde{p}=\frac{\hat p + \frac{1}{2n} z^2}{1 + \frac{1}{n} z^2}=\frac{X+ \frac{1}{2} z^2}{n + z^2}\,.$$
It is also the center of the Agresti-Coull interval.
If you take $\,\alpha=0.05\ $ and round 1.96 to 2, that gives the $\frac{X+2}{n+4}$ ("add 2 to both the successes and the failures") which is specifically mentioned in Agresti And Coull's paper, but rounding 1.96 to 2 is so often done that I'd be surprised if some people weren't using it since Wilson's paper appeared.
Wilson, E. B. (1927),
"Probable inference, the law of succession, and statistical inference,"
Journal of the American Statistical Association 22, 209–212.
Agresti, Alan; Coull, Brent A. (1998),
"Approximate is better than 'exact' for interval estimation of binomial proportions,"
The American Statistician 52: 119–126.
(This is at the first author's web pages here.)
Both papers are quite relevant.
|
wilson's adjustment for sample proportion
|
To my understanding the Wilson estimate is the center of the Wilson interval, which gives
the estimate
$$\tilde{p}=\frac{\hat p + \frac{1}{2n} z^2}{1 + \frac{1}{n} z^2}=\frac{X+ \frac{1}{2} z^2}{n +
|
wilson's adjustment for sample proportion
To my understanding the Wilson estimate is the center of the Wilson interval, which gives
the estimate
$$\tilde{p}=\frac{\hat p + \frac{1}{2n} z^2}{1 + \frac{1}{n} z^2}=\frac{X+ \frac{1}{2} z^2}{n + z^2}\,.$$
It is also the center of the Agresti-Coull interval.
If you take $\,\alpha=0.05\ $ and round 1.96 to 2, that gives the $\frac{X+2}{n+4}$ ("add 2 to both the successes and the failures") which is specifically mentioned in Agresti And Coull's paper, but rounding 1.96 to 2 is so often done that I'd be surprised if some people weren't using it since Wilson's paper appeared.
Wilson, E. B. (1927),
"Probable inference, the law of succession, and statistical inference,"
Journal of the American Statistical Association 22, 209–212.
Agresti, Alan; Coull, Brent A. (1998),
"Approximate is better than 'exact' for interval estimation of binomial proportions,"
The American Statistician 52: 119–126.
(This is at the first author's web pages here.)
Both papers are quite relevant.
|
wilson's adjustment for sample proportion
To my understanding the Wilson estimate is the center of the Wilson interval, which gives
the estimate
$$\tilde{p}=\frac{\hat p + \frac{1}{2n} z^2}{1 + \frac{1}{n} z^2}=\frac{X+ \frac{1}{2} z^2}{n +
|
47,355
|
Comparison of two means
|
The problem is that the subset is correlated with the whole.
This makes them dependent. Normally the right thing to do is compare two distinct sets - the subset with what's not in the subset.
Logically, the comparison of the whole with the subset is identical to comparing the subsets --
If they behave alike, then the subset behaves like the whole.
This is fairly simple logic. If girls have the same distribution as boys (the null in the test) and girls obviously have the same distribution as themselves(!), then girls have the same distribution as girls+boys.
Compare the answer here (almost identical in content, but about a different test):
How to compare two samples of frequencies with categorical x values where one is subset of the other
So you can just compare girls vs boys; you are automatically comparing girls vs girls+boys when you do.
So if you would say something like a t-test would be suitable, use an ordinary t-test.
If something akin to a gamma GLM seems suitable for your data, you might use that. If you would use a permutation test to compare the means, do that. If you want to assume a location-shift alternative and want to use a rank-test, the Wilcoxon-Mann-Whitney would work, and so on.
Let's look in more detail at what happens if you nevertheless insist on comparing the part with the whole.
Consider a statistic like the numerator of a two-sample t-test - the difference in means (then we'll standardize it on the denominator like with a t-test once we figure out what the numerator is).
That is, we start with the overall mean - mean of the girls:
$$\bar{y}_{boys+girls} - \bar{y}_{girls} $$
$$=\frac{1}{n_b + n_g}[\sum_{boys} y_i + \sum_{girls} y_i ] - \frac{1}{n_g}\sum_{girls} y_i\,.$$
What happens if you work through the algebra is that you just end up with a scaled version of mean of the boys - mean of the girls:
$$= \frac{n_g \sum_{boys} y_i + n_g \sum_{girls} y_i - (n_b + n_g)\sum_{girls} y_i }{(n_b+n_g)n_g}$$
$$=\frac{\frac{1}{n_b}\sum_{boys} y_i - \frac{1}{n_g}\sum_{girls} y_i}{1+\frac{n_g}{n_b}} $$
$$=\frac{\bar{y}_{boys} - \bar{y}_{girls}}{k} $$
where $k=1+\frac{n_g}{n_b}$.
If you properly standardize that difference for that scaling, you'll just end up with an ordinary t-test of boys vs girls (because the thing you divide this numerator by will also be divided by a factor of $k$).
So in fact, there's not only no logical difference, but if you go ahead and try it anyway (as long as you do that correctly!), you'll end up with exactly the same test statistic.
If instead you do a permutation test of difference in means (overall-girls), you have the same issue - the test statistic will only be a scaled version of the usual one (boys-girls) and you will again have the same p-value.
|
Comparison of two means
|
The problem is that the subset is correlated with the whole.
This makes them dependent. Normally the right thing to do is compare two distinct sets - the subset with what's not in the subset.
Logica
|
Comparison of two means
The problem is that the subset is correlated with the whole.
This makes them dependent. Normally the right thing to do is compare two distinct sets - the subset with what's not in the subset.
Logically, the comparison of the whole with the subset is identical to comparing the subsets --
If they behave alike, then the subset behaves like the whole.
This is fairly simple logic. If girls have the same distribution as boys (the null in the test) and girls obviously have the same distribution as themselves(!), then girls have the same distribution as girls+boys.
Compare the answer here (almost identical in content, but about a different test):
How to compare two samples of frequencies with categorical x values where one is subset of the other
So you can just compare girls vs boys; you are automatically comparing girls vs girls+boys when you do.
So if you would say something like a t-test would be suitable, use an ordinary t-test.
If something akin to a gamma GLM seems suitable for your data, you might use that. If you would use a permutation test to compare the means, do that. If you want to assume a location-shift alternative and want to use a rank-test, the Wilcoxon-Mann-Whitney would work, and so on.
Let's look in more detail at what happens if you nevertheless insist on comparing the part with the whole.
Consider a statistic like the numerator of a two-sample t-test - the difference in means (then we'll standardize it on the denominator like with a t-test once we figure out what the numerator is).
That is, we start with the overall mean - mean of the girls:
$$\bar{y}_{boys+girls} - \bar{y}_{girls} $$
$$=\frac{1}{n_b + n_g}[\sum_{boys} y_i + \sum_{girls} y_i ] - \frac{1}{n_g}\sum_{girls} y_i\,.$$
What happens if you work through the algebra is that you just end up with a scaled version of mean of the boys - mean of the girls:
$$= \frac{n_g \sum_{boys} y_i + n_g \sum_{girls} y_i - (n_b + n_g)\sum_{girls} y_i }{(n_b+n_g)n_g}$$
$$=\frac{\frac{1}{n_b}\sum_{boys} y_i - \frac{1}{n_g}\sum_{girls} y_i}{1+\frac{n_g}{n_b}} $$
$$=\frac{\bar{y}_{boys} - \bar{y}_{girls}}{k} $$
where $k=1+\frac{n_g}{n_b}$.
If you properly standardize that difference for that scaling, you'll just end up with an ordinary t-test of boys vs girls (because the thing you divide this numerator by will also be divided by a factor of $k$).
So in fact, there's not only no logical difference, but if you go ahead and try it anyway (as long as you do that correctly!), you'll end up with exactly the same test statistic.
If instead you do a permutation test of difference in means (overall-girls), you have the same issue - the test statistic will only be a scaled version of the usual one (boys-girls) and you will again have the same p-value.
|
Comparison of two means
The problem is that the subset is correlated with the whole.
This makes them dependent. Normally the right thing to do is compare two distinct sets - the subset with what's not in the subset.
Logica
|
47,356
|
ABC: Why not use the distance measure as a pseudo-likelihood instead?
|
This idea has in been implemented in several papers. Richard Wilkinson's SAGMB paper of 2013 explores the topic in some detail and makes precise the link to assuming a measurement error model.
It turns out to be useful to introduce a parameter $\epsilon$ to the weight function which corresponds to the scale of measurement error. This operates similarly to the standard ABC threshold; if taken too small the algorithm is very inefficient, but if too large the approximation is poor.
Once this parameter has been introduced, it's not clear whether weighting the simulations is better or worse than thresholding. In my experience the difference between the two is minimal, especially compared to the effect of other tuning choices, such as $\epsilon$ and the summary statistics. However, continuous weights are an advantageous feature in some algorithms, for example preventing particle degeneracy in ABC filtering algorithms and allowing emulation of the ABC likelihood.
|
ABC: Why not use the distance measure as a pseudo-likelihood instead?
|
This idea has in been implemented in several papers. Richard Wilkinson's SAGMB paper of 2013 explores the topic in some detail and makes precise the link to assuming a measurement error model.
It tur
|
ABC: Why not use the distance measure as a pseudo-likelihood instead?
This idea has in been implemented in several papers. Richard Wilkinson's SAGMB paper of 2013 explores the topic in some detail and makes precise the link to assuming a measurement error model.
It turns out to be useful to introduce a parameter $\epsilon$ to the weight function which corresponds to the scale of measurement error. This operates similarly to the standard ABC threshold; if taken too small the algorithm is very inefficient, but if too large the approximation is poor.
Once this parameter has been introduced, it's not clear whether weighting the simulations is better or worse than thresholding. In my experience the difference between the two is minimal, especially compared to the effect of other tuning choices, such as $\epsilon$ and the summary statistics. However, continuous weights are an advantageous feature in some algorithms, for example preventing particle degeneracy in ABC filtering algorithms and allowing emulation of the ABC likelihood.
|
ABC: Why not use the distance measure as a pseudo-likelihood instead?
This idea has in been implemented in several papers. Richard Wilkinson's SAGMB paper of 2013 explores the topic in some detail and makes precise the link to assuming a measurement error model.
It tur
|
47,357
|
ABC: Why not use the distance measure as a pseudo-likelihood instead?
|
I think that modelling the distribution of the summary statistics is preferable to thresholding, as long as you are able to find a good candidate distribution. For example here the author uses a multivariate normal approximation, which is justified by the asymptotic normality of the statistics. The same method, Synthetic Likelihood, has been used here were in one case 112 summary statistics were used. I don't think you could use that many statistics without making a parametric assumption on the distribution of the statistics. Other advantages of the multivariate normal approximation is that the correlations and scales of the statistics are automatically taken into account by the covariance matrix and that you don't have to choose the tolerance.
Disclosure: I am collaborating with the authors of both papers, so I might be biased.
|
ABC: Why not use the distance measure as a pseudo-likelihood instead?
|
I think that modelling the distribution of the summary statistics is preferable to thresholding, as long as you are able to find a good candidate distribution. For example here the author uses a multi
|
ABC: Why not use the distance measure as a pseudo-likelihood instead?
I think that modelling the distribution of the summary statistics is preferable to thresholding, as long as you are able to find a good candidate distribution. For example here the author uses a multivariate normal approximation, which is justified by the asymptotic normality of the statistics. The same method, Synthetic Likelihood, has been used here were in one case 112 summary statistics were used. I don't think you could use that many statistics without making a parametric assumption on the distribution of the statistics. Other advantages of the multivariate normal approximation is that the correlations and scales of the statistics are automatically taken into account by the covariance matrix and that you don't have to choose the tolerance.
Disclosure: I am collaborating with the authors of both papers, so I might be biased.
|
ABC: Why not use the distance measure as a pseudo-likelihood instead?
I think that modelling the distribution of the summary statistics is preferable to thresholding, as long as you are able to find a good candidate distribution. For example here the author uses a multi
|
47,358
|
When the confidence interval of an odds ratio includes one, can the p-value be less than 0.05?
|
If the confidence interval and the test are not quite based on the same calculation (in at least the somewhat loose sense that they give the same partial order to the sample space), then in some cases the two won't exactly correspond.
There are a number of cases where the usual interval and test are based on different statistics that give similar but not quite identical results.
If you give some more details of where (in what program) you saw this output and what data and commands you got it with, we might be able to give more details.
|
When the confidence interval of an odds ratio includes one, can the p-value be less than 0.05?
|
If the confidence interval and the test are not quite based on the same calculation (in at least the somewhat loose sense that they give the same partial order to the sample space), then in some cases
|
When the confidence interval of an odds ratio includes one, can the p-value be less than 0.05?
If the confidence interval and the test are not quite based on the same calculation (in at least the somewhat loose sense that they give the same partial order to the sample space), then in some cases the two won't exactly correspond.
There are a number of cases where the usual interval and test are based on different statistics that give similar but not quite identical results.
If you give some more details of where (in what program) you saw this output and what data and commands you got it with, we might be able to give more details.
|
When the confidence interval of an odds ratio includes one, can the p-value be less than 0.05?
If the confidence interval and the test are not quite based on the same calculation (in at least the somewhat loose sense that they give the same partial order to the sample space), then in some cases
|
47,359
|
Forecasting a time series with weights
|
This is an issue with lm.
wrapper = function(formula,...)
lm(formula=formula,...)
x=(1:27)
wrapper(ts.input~x,weights=ts.weights)
produces the exact same error. If you read the source code to tslm, you'll find that lm is called in more or less the sam way.
I found here that ..1 means the first argument included in ..., which in this case is the only argument, weights. It suggests that this kind of error could be caused because argument being passed doesn't exist in the environment from which the function is being called. You can see this behavior with wrapper(ts.input~x,weights=foo) if you don't have any object called foo.
Running a traceback on wrapper(ts.input~x,weights=ts.weights) reveals:
8 eval(expr, envir, enclos)
7 eval(extras, data, env)
6 model.frame.default(formula = formula, weights = ..1, drop.unused.levels = TRUE)
5 stats::model.frame(formula = formula, weights = ..1, drop.unused.levels = TRUE)
4 eval(expr, envir, enclos)
3 eval(mf, parent.frame())
2 lm(formula = formula, ...)
1 wrapper(ts.input ~ x, weights = ts.weights)
And in the source code of lm,
mf <- match.call(expand.dots = FALSE)
m <- match(c("formula", "data", "subset", "weights", "na.action",
"offset"), names(mf), 0L)
mf <- mf[c(1L, m)]
mf$drop.unused.levels <- TRUE
mf[[1L]] <- quote(stats::model.frame)
mf <- eval(mf, parent.frame())
if (method == "model.frame")
return(mf)
which suggests that the call to model.frame is picking up on the ... in a strange way.
So I decided to try it without ...:
wrapper = function(formula,weights)
lm(formula=formula,weights=weights)
x=(1:27)
wrapper(ts.input~x,weights=ts.weights)
which produced
Error in model.frame.default(formula = formula, weights = weights, drop.unused.levels = TRUE) :
invalid type (closure) for variable '(weights)'
A closure, of course, is a function in R. Which can mean only one thing... weights is already a function in the global environment. Indeed, ?weights reveals that it's ironically the extractor function for model weights. It's a no-brainer that it gets search priority over local variables. So I changed the argument names (since formula is also a function):
wrapper = function(fm,ws){
print(ws)
lm(formula=fm,weights=ws)
}
x=(1:27)
wrapper(fm=ts.input~x,ws=ts.weights)
now produces
[1] 2.260324e-05 6.385091e-05 1.803683e-04 5.094997e-04 1.439136e-03 4.064300e-03
[7] 1.147260e-02 3.234087e-02 9.082267e-02 2.523791e-01 6.815483e-01 1.712317e+00
[13] 3.685455e+00 6.224593e+00 8.232410e+00 9.293615e+00 9.737984e+00 9.905650e+00
[19] 9.966395e+00 9.988078e+00 9.995776e+00 9.998504e+00 9.999471e+00 9.999813e+00
[25] 9.999934e+00 9.999977e+00 9.999992e+00
Error in eval(expr, envir, enclos) : object 'ws' not found
And if you run traceback you still get the same issue with model.frame. So I'm completely baffled. My only conclusion is that a) it has nothing to do with tslm or time series analysis, and b) the problem lies somewhere in the way arguments are passed around inside lm.
That probably doesn't help you at all, but hopefully at least someone can come along and explain what's going on here. My provisional answer to your actual question of how to use weights in tslm is that you can't.
|
Forecasting a time series with weights
|
This is an issue with lm.
wrapper = function(formula,...)
lm(formula=formula,...)
x=(1:27)
wrapper(ts.input~x,weights=ts.weights)
produces the exact same error. If you read the source code to tslm,
|
Forecasting a time series with weights
This is an issue with lm.
wrapper = function(formula,...)
lm(formula=formula,...)
x=(1:27)
wrapper(ts.input~x,weights=ts.weights)
produces the exact same error. If you read the source code to tslm, you'll find that lm is called in more or less the sam way.
I found here that ..1 means the first argument included in ..., which in this case is the only argument, weights. It suggests that this kind of error could be caused because argument being passed doesn't exist in the environment from which the function is being called. You can see this behavior with wrapper(ts.input~x,weights=foo) if you don't have any object called foo.
Running a traceback on wrapper(ts.input~x,weights=ts.weights) reveals:
8 eval(expr, envir, enclos)
7 eval(extras, data, env)
6 model.frame.default(formula = formula, weights = ..1, drop.unused.levels = TRUE)
5 stats::model.frame(formula = formula, weights = ..1, drop.unused.levels = TRUE)
4 eval(expr, envir, enclos)
3 eval(mf, parent.frame())
2 lm(formula = formula, ...)
1 wrapper(ts.input ~ x, weights = ts.weights)
And in the source code of lm,
mf <- match.call(expand.dots = FALSE)
m <- match(c("formula", "data", "subset", "weights", "na.action",
"offset"), names(mf), 0L)
mf <- mf[c(1L, m)]
mf$drop.unused.levels <- TRUE
mf[[1L]] <- quote(stats::model.frame)
mf <- eval(mf, parent.frame())
if (method == "model.frame")
return(mf)
which suggests that the call to model.frame is picking up on the ... in a strange way.
So I decided to try it without ...:
wrapper = function(formula,weights)
lm(formula=formula,weights=weights)
x=(1:27)
wrapper(ts.input~x,weights=ts.weights)
which produced
Error in model.frame.default(formula = formula, weights = weights, drop.unused.levels = TRUE) :
invalid type (closure) for variable '(weights)'
A closure, of course, is a function in R. Which can mean only one thing... weights is already a function in the global environment. Indeed, ?weights reveals that it's ironically the extractor function for model weights. It's a no-brainer that it gets search priority over local variables. So I changed the argument names (since formula is also a function):
wrapper = function(fm,ws){
print(ws)
lm(formula=fm,weights=ws)
}
x=(1:27)
wrapper(fm=ts.input~x,ws=ts.weights)
now produces
[1] 2.260324e-05 6.385091e-05 1.803683e-04 5.094997e-04 1.439136e-03 4.064300e-03
[7] 1.147260e-02 3.234087e-02 9.082267e-02 2.523791e-01 6.815483e-01 1.712317e+00
[13] 3.685455e+00 6.224593e+00 8.232410e+00 9.293615e+00 9.737984e+00 9.905650e+00
[19] 9.966395e+00 9.988078e+00 9.995776e+00 9.998504e+00 9.999471e+00 9.999813e+00
[25] 9.999934e+00 9.999977e+00 9.999992e+00
Error in eval(expr, envir, enclos) : object 'ws' not found
And if you run traceback you still get the same issue with model.frame. So I'm completely baffled. My only conclusion is that a) it has nothing to do with tslm or time series analysis, and b) the problem lies somewhere in the way arguments are passed around inside lm.
That probably doesn't help you at all, but hopefully at least someone can come along and explain what's going on here. My provisional answer to your actual question of how to use weights in tslm is that you can't.
|
Forecasting a time series with weights
This is an issue with lm.
wrapper = function(formula,...)
lm(formula=formula,...)
x=(1:27)
wrapper(ts.input~x,weights=ts.weights)
produces the exact same error. If you read the source code to tslm,
|
47,360
|
The efficiency of Decision Tree
|
I will share my experience on implementing those kind of decision trees. There are some ideas which I found also in R, Weka, Python implementations. In order to keep things simple, I will suppose you talk about CART-like trees, but the things I explain could be extended trivially to any kind of decision tree.
You do not need to store all the splitting candidates. The reason is that you consistently use the same criteria at a given run: IG, IGR, Gini, entropy, error, or other. Thus you need to keep only the best candidate, and fort this candidate you need to have: splitting variable name, numerical split label (for numeric features), string split label (for nominal variable), value for given criteria (used for comparison) and that is all. This will save you some linear memory
You do not have to split the instances for every candidate, so you first find the best candidate, and only after you eliminated all other weaker candidates, you split your data set. I saw often this mistake, and could make running time explode to $O(n^2)$ at each evaluation node
For numeric variable to find the best split use a linear algorithm: create two sets of bins, one for left node, one for right, where each there are $k$ bins corresponding to the number of output classes. Initially the left bins will contain all the totals. While iterating substract from the left bins and add for the right bins and then compute splitting value criteria directly from bins. If for each split value you remake the totals from data points you will have again $O(n^2)$
For nominal variables use the same trick with bins, but this time having $P$ bins where $P$ is the number of factors of the nominal variable.
You might use presorting of the variables. Initially your sort all the variables before any learning. At each node evaluation use sorted vectors, and after one choose the best split, you will split the data points and also the sorted indexes, in order to send to the child nodes the subset of data and subsets of sorted indexes. Thus you can apply this idea in recursion. Note however that this works if the number of data instances is greater than number of input features
Use parallelism as much as possible. There are a lot of things which can be parallelized due to their design: evaluate multiple variables in parallel, evaluate multiple trees in parallel (for random forests, bagging)
Avoid evaluation when is not necessary: if a binary variable was used as split variable than is useless to try to evaluate that again in children nodes, since all the instances will have the same value for this variable
If you have a binary variable with labels: "male", "female" you can avoid evaluate sending "female" to left, "male" to right and also sending "female" to left and "male to right. Both variants are equivalent.
For numerical variables, if there are many data points one can avoid evaluating on all split candidate positions, only for a randomly chosen sample of them. This is as far as I know implemented in R. One can safely use this trick for random forests where the precision regarding the split point is not important because is covered by averaging
PS: however I believe this question belongs more to SO
|
The efficiency of Decision Tree
|
I will share my experience on implementing those kind of decision trees. There are some ideas which I found also in R, Weka, Python implementations. In order to keep things simple, I will suppose you
|
The efficiency of Decision Tree
I will share my experience on implementing those kind of decision trees. There are some ideas which I found also in R, Weka, Python implementations. In order to keep things simple, I will suppose you talk about CART-like trees, but the things I explain could be extended trivially to any kind of decision tree.
You do not need to store all the splitting candidates. The reason is that you consistently use the same criteria at a given run: IG, IGR, Gini, entropy, error, or other. Thus you need to keep only the best candidate, and fort this candidate you need to have: splitting variable name, numerical split label (for numeric features), string split label (for nominal variable), value for given criteria (used for comparison) and that is all. This will save you some linear memory
You do not have to split the instances for every candidate, so you first find the best candidate, and only after you eliminated all other weaker candidates, you split your data set. I saw often this mistake, and could make running time explode to $O(n^2)$ at each evaluation node
For numeric variable to find the best split use a linear algorithm: create two sets of bins, one for left node, one for right, where each there are $k$ bins corresponding to the number of output classes. Initially the left bins will contain all the totals. While iterating substract from the left bins and add for the right bins and then compute splitting value criteria directly from bins. If for each split value you remake the totals from data points you will have again $O(n^2)$
For nominal variables use the same trick with bins, but this time having $P$ bins where $P$ is the number of factors of the nominal variable.
You might use presorting of the variables. Initially your sort all the variables before any learning. At each node evaluation use sorted vectors, and after one choose the best split, you will split the data points and also the sorted indexes, in order to send to the child nodes the subset of data and subsets of sorted indexes. Thus you can apply this idea in recursion. Note however that this works if the number of data instances is greater than number of input features
Use parallelism as much as possible. There are a lot of things which can be parallelized due to their design: evaluate multiple variables in parallel, evaluate multiple trees in parallel (for random forests, bagging)
Avoid evaluation when is not necessary: if a binary variable was used as split variable than is useless to try to evaluate that again in children nodes, since all the instances will have the same value for this variable
If you have a binary variable with labels: "male", "female" you can avoid evaluate sending "female" to left, "male" to right and also sending "female" to left and "male to right. Both variants are equivalent.
For numerical variables, if there are many data points one can avoid evaluating on all split candidate positions, only for a randomly chosen sample of them. This is as far as I know implemented in R. One can safely use this trick for random forests where the precision regarding the split point is not important because is covered by averaging
PS: however I believe this question belongs more to SO
|
The efficiency of Decision Tree
I will share my experience on implementing those kind of decision trees. There are some ideas which I found also in R, Weka, Python implementations. In order to keep things simple, I will suppose you
|
47,361
|
Testing significance of a random effect glmmADMB model
|
Because glmmADMB (unlike lme4) can handle models without any random effects in the same framework, and thus get commensurate log-likelihood, you should be able to do this:
g1 <- glmmadmb(formula = Score ~ Sex * Age + Object + (1 | ID),
data = PGS, family = "nbinom1")
g2 <- glmmadmb(formula = Score ~ Sex * Age + Object,
data = PGS, family = "nbinom1")
anova(g1,g2)
(You haven't given a reproducible example so I'm not testing this.) However, even if this works it would be wise to take a look at the cautions under "how do I test whether a random effect is significant? on the GLMM FAQ (i.e., statistical/inferential issues rather than computational ones).
|
Testing significance of a random effect glmmADMB model
|
Because glmmADMB (unlike lme4) can handle models without any random effects in the same framework, and thus get commensurate log-likelihood, you should be able to do this:
g1 <- glmmadmb(formula = Sco
|
Testing significance of a random effect glmmADMB model
Because glmmADMB (unlike lme4) can handle models without any random effects in the same framework, and thus get commensurate log-likelihood, you should be able to do this:
g1 <- glmmadmb(formula = Score ~ Sex * Age + Object + (1 | ID),
data = PGS, family = "nbinom1")
g2 <- glmmadmb(formula = Score ~ Sex * Age + Object,
data = PGS, family = "nbinom1")
anova(g1,g2)
(You haven't given a reproducible example so I'm not testing this.) However, even if this works it would be wise to take a look at the cautions under "how do I test whether a random effect is significant? on the GLMM FAQ (i.e., statistical/inferential issues rather than computational ones).
|
Testing significance of a random effect glmmADMB model
Because glmmADMB (unlike lme4) can handle models without any random effects in the same framework, and thus get commensurate log-likelihood, you should be able to do this:
g1 <- glmmadmb(formula = Sco
|
47,362
|
What is the difference between (universal) kriging and spatial autoregressive models?
|
Short answers:
1) As you said the difference between the two is only in the spatial structure.
2) A lot of people work to find an equivalent mathematical formulation between the two, especially in the Bayesian framework. See for example the work of Rue of the paper of Lindgren http://www.math.ntnu.no/inla/r-inla.org/papers/spde-jrssb-revised.pdf
3) i do not see how. If you use the spatial autoregressive model, for each point in an area you predict the same value, while with the kriging, the mean on the entire are is the same but not the value of the process, you predict a different value for each point
Long answers:
Obviously, since the two processes are defined by the type of spatial interaction/structure, they are profound different. In the spatial autoregressive model, two spatial points $Y_1$ and $Y_2$ are dependent if they are close in some sense. As an example we can think about two states, what happen to the state $Y_2$ can depend on what happen in $Y_1$ only if they share a border. Generally to specify a spatial autoregressive model you have to specify also a matrix of proximity (or neighborhood). From a computational point of view the spatial autoregressive model is convenient since the covariance matrix between the observations is a sparse matrix and then if we need its inversion this can be done efficiently. On the other hand with this kind of model we are not able to predict the value of the process on some non-observed locations because we can not estimate the correlation between. This kind of models (the auto-model) should be used only for process that are spatially discrete, i.e. its realization can be observed only on specific locations, but they are used also for continuous process.
In the kriging model we suppose that the dependencies is continuous, between $Y_1$ and $Y_2$ the correlation generally depends on the distance between the observations, if they are close the correlation is higher. With this model we are able to make prediction on a new location since we know the value of the correlation between the process on the new location and the observed process (it depends on the distance). On the other hand in this case the covariance matrix is not sparse, unless you use a correlation function that goes to zero after a certain distance, its inversion is computationally intensive.
Since the computational advantage of the spatial autoregressive model (or the auto model in general), some people start to think about the possibility of approximate a continuous process with a discrete one, the paper of Lindgren I linked above is one of the best result in this field.
If you need some book where the autoregressive model and the Kriging are well exlained, i suggest Hierarchical Modeling and Analysis for Spatial Data (http://www.amazon.com/Hierarchical-Modeling-Monographs-Statistics-Probability/dp/158488410X)
|
What is the difference between (universal) kriging and spatial autoregressive models?
|
Short answers:
1) As you said the difference between the two is only in the spatial structure.
2) A lot of people work to find an equivalent mathematical formulation between the two, especially in th
|
What is the difference between (universal) kriging and spatial autoregressive models?
Short answers:
1) As you said the difference between the two is only in the spatial structure.
2) A lot of people work to find an equivalent mathematical formulation between the two, especially in the Bayesian framework. See for example the work of Rue of the paper of Lindgren http://www.math.ntnu.no/inla/r-inla.org/papers/spde-jrssb-revised.pdf
3) i do not see how. If you use the spatial autoregressive model, for each point in an area you predict the same value, while with the kriging, the mean on the entire are is the same but not the value of the process, you predict a different value for each point
Long answers:
Obviously, since the two processes are defined by the type of spatial interaction/structure, they are profound different. In the spatial autoregressive model, two spatial points $Y_1$ and $Y_2$ are dependent if they are close in some sense. As an example we can think about two states, what happen to the state $Y_2$ can depend on what happen in $Y_1$ only if they share a border. Generally to specify a spatial autoregressive model you have to specify also a matrix of proximity (or neighborhood). From a computational point of view the spatial autoregressive model is convenient since the covariance matrix between the observations is a sparse matrix and then if we need its inversion this can be done efficiently. On the other hand with this kind of model we are not able to predict the value of the process on some non-observed locations because we can not estimate the correlation between. This kind of models (the auto-model) should be used only for process that are spatially discrete, i.e. its realization can be observed only on specific locations, but they are used also for continuous process.
In the kriging model we suppose that the dependencies is continuous, between $Y_1$ and $Y_2$ the correlation generally depends on the distance between the observations, if they are close the correlation is higher. With this model we are able to make prediction on a new location since we know the value of the correlation between the process on the new location and the observed process (it depends on the distance). On the other hand in this case the covariance matrix is not sparse, unless you use a correlation function that goes to zero after a certain distance, its inversion is computationally intensive.
Since the computational advantage of the spatial autoregressive model (or the auto model in general), some people start to think about the possibility of approximate a continuous process with a discrete one, the paper of Lindgren I linked above is one of the best result in this field.
If you need some book where the autoregressive model and the Kriging are well exlained, i suggest Hierarchical Modeling and Analysis for Spatial Data (http://www.amazon.com/Hierarchical-Modeling-Monographs-Statistics-Probability/dp/158488410X)
|
What is the difference between (universal) kriging and spatial autoregressive models?
Short answers:
1) As you said the difference between the two is only in the spatial structure.
2) A lot of people work to find an equivalent mathematical formulation between the two, especially in th
|
47,363
|
Explanation of a censored regression model
|
By default, the estimated standard deviation of the residuals ($\sigma$) is returned as $\ln(\sigma)$ since that is how the Tobit log likelihood maximization is performed. If you use coef(estResult,logSigma = FALSE), you will get $\sigma$ instead, which is analogous to the square root of the residual variance in OLS regression. That value can be compared to the standard deviation of affairs. If it is much smaller, you may have a reasonably good model. Or you can do the exponentiation yourself with a calculator and use delta method for the variance. You will also need $\sigma$ to construct some of the marginal effects.
I don't think the hypothesis test about $\ln \sigma$ and the corresponding p-value have a clear interpretation, whereas the other coefficients can be interpreted as the marginal effects on the uncensored outcome, so the p-value on the null that the ME is zero makes sense for them. I believe R is just treating $\ln \sigma$ as another parameter.
Here's my replication of your analysis in Stata (where I am also treating the categorical variables as continuous) confirming what I wrote above.
First we load the affairs data:
. ssc install bcuse
checking bcuse consistency and verifying not already installed...
all files already exist and are up to date.
. bcuse affairs
Contains data from http://fmwww.bc.edu/ec-p/data/wooldridge/affairs.dta
obs: 601
vars: 19 22 May 2002 11:49
size: 15,626
-------------------------------------------------------------------------------------------------------
storage display value
variable name type format label variable label
-------------------------------------------------------------------------------------------------------
id int %9.0g identifier
male byte %9.0g =1 if male
age float %9.0g in years
yrsmarr float %9.0g years married
kids byte %9.0g =1 if have kids
relig byte %9.0g 5 = very relig., 4 = somewhat, 3 = slightly, 2 = not at
all, 1 = anti
educ byte %9.0g years schooling
occup byte %9.0g occupation, reverse Hollingshead scale
ratemarr byte %9.0g 5 = vry hap marr, 4 = hap than avg, 3 = avg, 2 = smewht
unhap, 1 = vry unhap
naffairs byte %9.0g number of affairs within last year
affair byte %9.0g =1 if had at least one affair
vryhap byte %9.0g ratemarr == 5
hapavg byte %9.0g ratemarr == 4
avgmarr byte %9.0g ratemarr == 3
unhap byte %9.0g ratemarr == 2
vryrel byte %9.0g relig == 5
smerel byte %9.0g relig == 4
slghtrel byte %9.0g relig == 3
notrel byte %9.0g relig == 2
-------------------------------------------------------------------------------------------------------
Sorted by: id
Here's the Stata equivalent of your censReg:
. tobit naffair age yrsmarr relig occup ratemarr , ll(0)
Tobit regression Number of obs = 601
LR chi2(5) = 78.32
Prob > chi2 = 0.0000
Log likelihood = -705.57622 Pseudo R2 = 0.0526
------------------------------------------------------------------------------
naffairs | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | -.1793326 .0790928 -2.27 0.024 -.3346672 -.023998
yrsmarr | .5541418 .1345172 4.12 0.000 .2899564 .8183273
relig | -1.68622 .4037495 -4.18 0.000 -2.479165 -.8932758
occup | .3260532 .2544235 1.28 0.201 -.1736224 .8257289
ratemarr | -2.284973 .4078258 -5.60 0.000 -3.085923 -1.484022
_cons | 8.174197 2.741432 2.98 0.003 2.790155 13.55824
-------------+----------------------------------------------------------------
/sigma | 8.24708 .5533582 7.160311 9.333849
------------------------------------------------------------------------------
Obs. summary: 451 left-censored observations at naffairs<=0
150 uncensored observations
0 right-censored observations
Stata reports $\sigma$ rather than $\ln \sigma$, but we can take logs too:
. nlcom logSigma: ln(_b[/sigma])
logSigma: ln(_b[/sigma])
------------------------------------------------------------------------------
naffairs | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
logSigma | 2.109859 .0670975 31.44 0.000 1.978351 2.241368
Note that this matches your R output. The z stat and the p-value are for the null that the log standard deviation of the residual is zero, which is definitely not the case here.
Here are the summary stats for the outcome for comparison to $\sigma$:
. sum naffairs
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
naffairs | 601 1.455907 3.298758 0 12
In this case, the model looks pretty bad, which is often the case with Tobit models, especially "toy" ones meant to illustrate syntax.
|
Explanation of a censored regression model
|
By default, the estimated standard deviation of the residuals ($\sigma$) is returned as $\ln(\sigma)$ since that is how the Tobit log likelihood maximization is performed. If you use coef(estResult,lo
|
Explanation of a censored regression model
By default, the estimated standard deviation of the residuals ($\sigma$) is returned as $\ln(\sigma)$ since that is how the Tobit log likelihood maximization is performed. If you use coef(estResult,logSigma = FALSE), you will get $\sigma$ instead, which is analogous to the square root of the residual variance in OLS regression. That value can be compared to the standard deviation of affairs. If it is much smaller, you may have a reasonably good model. Or you can do the exponentiation yourself with a calculator and use delta method for the variance. You will also need $\sigma$ to construct some of the marginal effects.
I don't think the hypothesis test about $\ln \sigma$ and the corresponding p-value have a clear interpretation, whereas the other coefficients can be interpreted as the marginal effects on the uncensored outcome, so the p-value on the null that the ME is zero makes sense for them. I believe R is just treating $\ln \sigma$ as another parameter.
Here's my replication of your analysis in Stata (where I am also treating the categorical variables as continuous) confirming what I wrote above.
First we load the affairs data:
. ssc install bcuse
checking bcuse consistency and verifying not already installed...
all files already exist and are up to date.
. bcuse affairs
Contains data from http://fmwww.bc.edu/ec-p/data/wooldridge/affairs.dta
obs: 601
vars: 19 22 May 2002 11:49
size: 15,626
-------------------------------------------------------------------------------------------------------
storage display value
variable name type format label variable label
-------------------------------------------------------------------------------------------------------
id int %9.0g identifier
male byte %9.0g =1 if male
age float %9.0g in years
yrsmarr float %9.0g years married
kids byte %9.0g =1 if have kids
relig byte %9.0g 5 = very relig., 4 = somewhat, 3 = slightly, 2 = not at
all, 1 = anti
educ byte %9.0g years schooling
occup byte %9.0g occupation, reverse Hollingshead scale
ratemarr byte %9.0g 5 = vry hap marr, 4 = hap than avg, 3 = avg, 2 = smewht
unhap, 1 = vry unhap
naffairs byte %9.0g number of affairs within last year
affair byte %9.0g =1 if had at least one affair
vryhap byte %9.0g ratemarr == 5
hapavg byte %9.0g ratemarr == 4
avgmarr byte %9.0g ratemarr == 3
unhap byte %9.0g ratemarr == 2
vryrel byte %9.0g relig == 5
smerel byte %9.0g relig == 4
slghtrel byte %9.0g relig == 3
notrel byte %9.0g relig == 2
-------------------------------------------------------------------------------------------------------
Sorted by: id
Here's the Stata equivalent of your censReg:
. tobit naffair age yrsmarr relig occup ratemarr , ll(0)
Tobit regression Number of obs = 601
LR chi2(5) = 78.32
Prob > chi2 = 0.0000
Log likelihood = -705.57622 Pseudo R2 = 0.0526
------------------------------------------------------------------------------
naffairs | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | -.1793326 .0790928 -2.27 0.024 -.3346672 -.023998
yrsmarr | .5541418 .1345172 4.12 0.000 .2899564 .8183273
relig | -1.68622 .4037495 -4.18 0.000 -2.479165 -.8932758
occup | .3260532 .2544235 1.28 0.201 -.1736224 .8257289
ratemarr | -2.284973 .4078258 -5.60 0.000 -3.085923 -1.484022
_cons | 8.174197 2.741432 2.98 0.003 2.790155 13.55824
-------------+----------------------------------------------------------------
/sigma | 8.24708 .5533582 7.160311 9.333849
------------------------------------------------------------------------------
Obs. summary: 451 left-censored observations at naffairs<=0
150 uncensored observations
0 right-censored observations
Stata reports $\sigma$ rather than $\ln \sigma$, but we can take logs too:
. nlcom logSigma: ln(_b[/sigma])
logSigma: ln(_b[/sigma])
------------------------------------------------------------------------------
naffairs | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
logSigma | 2.109859 .0670975 31.44 0.000 1.978351 2.241368
Note that this matches your R output. The z stat and the p-value are for the null that the log standard deviation of the residual is zero, which is definitely not the case here.
Here are the summary stats for the outcome for comparison to $\sigma$:
. sum naffairs
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
naffairs | 601 1.455907 3.298758 0 12
In this case, the model looks pretty bad, which is often the case with Tobit models, especially "toy" ones meant to illustrate syntax.
|
Explanation of a censored regression model
By default, the estimated standard deviation of the residuals ($\sigma$) is returned as $\ln(\sigma)$ since that is how the Tobit log likelihood maximization is performed. If you use coef(estResult,lo
|
47,364
|
Wald test and Likelihood ratio test, where do the confidence intervals on the regression coefficients come from?
|
When you fit a logistic regression model, there is no closed form solution for the parameter estimates unlike in linear regression. So instead, you search over the parameter space for a set of parameter estimates that maximize the log likelihood or minimize the deviance. (I usually prefer to think in terms of the deviance, but in this case it might be better to think of maximizing the log likelihood.) The most common search procedure is the Newton-Raphson algorithm.
As you search, you could map out the shape of the log likelihood, but this isn't really done. In the process of running the Newton-Raphson algorithm, you calculate the Hessian matrix (and it shouldn't be difficult to get if you run a search algorithm that doesn't use the Hessian instead). That provides a picture of the shape in the region of the parameter space where you are currently. The Wald test of the parameter is based on the assumption that the log likelihood has the shape of a normal distribution (which it would with infinite data but may not with small samples). An estimate of the standard deviation is calculated, and that is used as the standard error. This is typically what is used to form confidence intervals for betas.
The likelihood ratio test works differently. The ratio of the likelihoods is the difference of the log likelihoods. That is, it is the difference between the likelihoods of the model when a parameter is set at two different values. Essentially always, these two values are the maximum likelihood estimate and the null value (0). The difference between these two values should be distributed as chi-squared. It is less common to use this approach to determine the confidence interval for a beta, but it can be done. You need to search over possible beta estimates and work backward to find values that constitute the limits of the interval.
There is a very useful figure (actually taken from John Fox) at the bottom of the linked page that is extremely helpful for understanding this topic.
|
Wald test and Likelihood ratio test, where do the confidence intervals on the regression coefficient
|
When you fit a logistic regression model, there is no closed form solution for the parameter estimates unlike in linear regression. So instead, you search over the parameter space for a set of parame
|
Wald test and Likelihood ratio test, where do the confidence intervals on the regression coefficients come from?
When you fit a logistic regression model, there is no closed form solution for the parameter estimates unlike in linear regression. So instead, you search over the parameter space for a set of parameter estimates that maximize the log likelihood or minimize the deviance. (I usually prefer to think in terms of the deviance, but in this case it might be better to think of maximizing the log likelihood.) The most common search procedure is the Newton-Raphson algorithm.
As you search, you could map out the shape of the log likelihood, but this isn't really done. In the process of running the Newton-Raphson algorithm, you calculate the Hessian matrix (and it shouldn't be difficult to get if you run a search algorithm that doesn't use the Hessian instead). That provides a picture of the shape in the region of the parameter space where you are currently. The Wald test of the parameter is based on the assumption that the log likelihood has the shape of a normal distribution (which it would with infinite data but may not with small samples). An estimate of the standard deviation is calculated, and that is used as the standard error. This is typically what is used to form confidence intervals for betas.
The likelihood ratio test works differently. The ratio of the likelihoods is the difference of the log likelihoods. That is, it is the difference between the likelihoods of the model when a parameter is set at two different values. Essentially always, these two values are the maximum likelihood estimate and the null value (0). The difference between these two values should be distributed as chi-squared. It is less common to use this approach to determine the confidence interval for a beta, but it can be done. You need to search over possible beta estimates and work backward to find values that constitute the limits of the interval.
There is a very useful figure (actually taken from John Fox) at the bottom of the linked page that is extremely helpful for understanding this topic.
|
Wald test and Likelihood ratio test, where do the confidence intervals on the regression coefficient
When you fit a logistic regression model, there is no closed form solution for the parameter estimates unlike in linear regression. So instead, you search over the parameter space for a set of parame
|
47,365
|
Loss function for linear regression with calculus of variations
|
I am assuming your difficulty is in the jump between Eq.2 and Eq.3. All you need is an Euler-Lagrange equation, as in their equation (3). In their notation $f(x,y,\dot y)=\int \{y(x)-t\}^2p(x,t)dx$, so that $df/d\dot{y}=0$, for instance.
UPDATE:
answering comments to make a more verbose explanation.
The Eq. (2) can be rewritten as:
$$E[L]=\int f(t,y) dt$$
The stationary (optimal) solution is when in my link to E-L the condition (3) is satisfied, but since our $f(t,y,\dot y)\equiv f(t,y)$ doesn't have $\dot y$ in it, only the first term matters and it becomes:
$$\frac{\partial f}{\partial y}=0$$
This is Eq. (3) in the question. If you have trouble arriving to it, then review the Leibnitz integral rule. However, in this case it's unnecessary, because the integral is over $t$, so you can simply apply differentiation wrt $y$ trivially.
|
Loss function for linear regression with calculus of variations
|
I am assuming your difficulty is in the jump between Eq.2 and Eq.3. All you need is an Euler-Lagrange equation, as in their equation (3). In their notation $f(x,y,\dot y)=\int \{y(x)-t\}^2p(x,t)dx$, s
|
Loss function for linear regression with calculus of variations
I am assuming your difficulty is in the jump between Eq.2 and Eq.3. All you need is an Euler-Lagrange equation, as in their equation (3). In their notation $f(x,y,\dot y)=\int \{y(x)-t\}^2p(x,t)dx$, so that $df/d\dot{y}=0$, for instance.
UPDATE:
answering comments to make a more verbose explanation.
The Eq. (2) can be rewritten as:
$$E[L]=\int f(t,y) dt$$
The stationary (optimal) solution is when in my link to E-L the condition (3) is satisfied, but since our $f(t,y,\dot y)\equiv f(t,y)$ doesn't have $\dot y$ in it, only the first term matters and it becomes:
$$\frac{\partial f}{\partial y}=0$$
This is Eq. (3) in the question. If you have trouble arriving to it, then review the Leibnitz integral rule. However, in this case it's unnecessary, because the integral is over $t$, so you can simply apply differentiation wrt $y$ trivially.
|
Loss function for linear regression with calculus of variations
I am assuming your difficulty is in the jump between Eq.2 and Eq.3. All you need is an Euler-Lagrange equation, as in their equation (3). In their notation $f(x,y,\dot y)=\int \{y(x)-t\}^2p(x,t)dx$, s
|
47,366
|
Loss function for linear regression with calculus of variations
|
I don't think you need calculus of variations. First, define the loss for every fixed $\bf x$,
$$\mathbb{E}[L | {\bf x}] = \int \{ y (\mathbf{x}) - t \}^{2} p (t | \mathbf{x}) \, dt.
\tag{2*}$$
and the minimizer of that is $y (\mathbf{x}) = \mathbb{E}_{t} [t | \mathbf{x}]$
and then just
$$\mathbb{E}[L] = \int \mathbb{E}[L|x] f(x)\, dx$$
|
Loss function for linear regression with calculus of variations
|
I don't think you need calculus of variations. First, define the loss for every fixed $\bf x$,
$$\mathbb{E}[L | {\bf x}] = \int \{ y (\mathbf{x}) - t \}^{2} p (t | \mathbf{x}) \, dt.
\tag{2*}$$
and
|
Loss function for linear regression with calculus of variations
I don't think you need calculus of variations. First, define the loss for every fixed $\bf x$,
$$\mathbb{E}[L | {\bf x}] = \int \{ y (\mathbf{x}) - t \}^{2} p (t | \mathbf{x}) \, dt.
\tag{2*}$$
and the minimizer of that is $y (\mathbf{x}) = \mathbb{E}_{t} [t | \mathbf{x}]$
and then just
$$\mathbb{E}[L] = \int \mathbb{E}[L|x] f(x)\, dx$$
|
Loss function for linear regression with calculus of variations
I don't think you need calculus of variations. First, define the loss for every fixed $\bf x$,
$$\mathbb{E}[L | {\bf x}] = \int \{ y (\mathbf{x}) - t \}^{2} p (t | \mathbf{x}) \, dt.
\tag{2*}$$
and
|
47,367
|
Stepwise regression in R with both direction
|
The underlying procedure is beautifully documented in Chambers & Hastie (eds, 1992; Ch. 6) (contrary to what the help page says) on page 237.
stats::step() with the option direction = 'both' works by comparing the AIC improvements from
dropping each candidate variable, and adding each candidate variable between the upper and lower bound regressor sets supplied,
from the current model, and by dropping or adding the one variable that leads to the best AIC improvement (smallest AIC).
For example, assume that you are fitting a linear regression model with the upper set of variables $\mathcal{U} = \{X_1, X_2, X_3, X_4, X_5, X_6, X_7\}$, and lower set $\mathcal{L} = \{X_1\}$, and the starting object $\mathcal{S}_0 = \{X_1, X_3\}$, then the potential sets of retained regressors might be something like
$$
\begin{align}
\mathcal{S}_1 &= \{X_1, X_3, X_6\} &\text{ (add $X_6$) }\\
\mathcal{S}_2 &= \{X_1, X_3, X_6, X_4\} &\text{ (add $X_4$) }\\
\mathcal{S}_3 &= \{X_3, X_6, X_4\} &\text{ (drop $X_1$) }\\
\mathcal{S}_4 &= \{X_3, X_6, X_4, X_7\} &\text{ (add $X_7$) }\\
\mathcal{S}_5 &= \{X_3, X_4, X_7\} &\text{ (drop $X_6$) }
\end{align}
$$
and so on, till no AIC improvements can be made.
|
Stepwise regression in R with both direction
|
The underlying procedure is beautifully documented in Chambers & Hastie (eds, 1992; Ch. 6) (contrary to what the help page says) on page 237.
stats::step() with the option direction = 'both' works by
|
Stepwise regression in R with both direction
The underlying procedure is beautifully documented in Chambers & Hastie (eds, 1992; Ch. 6) (contrary to what the help page says) on page 237.
stats::step() with the option direction = 'both' works by comparing the AIC improvements from
dropping each candidate variable, and adding each candidate variable between the upper and lower bound regressor sets supplied,
from the current model, and by dropping or adding the one variable that leads to the best AIC improvement (smallest AIC).
For example, assume that you are fitting a linear regression model with the upper set of variables $\mathcal{U} = \{X_1, X_2, X_3, X_4, X_5, X_6, X_7\}$, and lower set $\mathcal{L} = \{X_1\}$, and the starting object $\mathcal{S}_0 = \{X_1, X_3\}$, then the potential sets of retained regressors might be something like
$$
\begin{align}
\mathcal{S}_1 &= \{X_1, X_3, X_6\} &\text{ (add $X_6$) }\\
\mathcal{S}_2 &= \{X_1, X_3, X_6, X_4\} &\text{ (add $X_4$) }\\
\mathcal{S}_3 &= \{X_3, X_6, X_4\} &\text{ (drop $X_1$) }\\
\mathcal{S}_4 &= \{X_3, X_6, X_4, X_7\} &\text{ (add $X_7$) }\\
\mathcal{S}_5 &= \{X_3, X_4, X_7\} &\text{ (drop $X_6$) }
\end{align}
$$
and so on, till no AIC improvements can be made.
|
Stepwise regression in R with both direction
The underlying procedure is beautifully documented in Chambers & Hastie (eds, 1992; Ch. 6) (contrary to what the help page says) on page 237.
stats::step() with the option direction = 'both' works by
|
47,368
|
When is a ARMA(p,q) process ergodic?
|
It is sufficient for any stationary process that the autocovariances are absolute summable, i.e. that $\sum_{j=0}^\infty |\gamma_j|<\infty$. You can find this in Hamilton's Time Series Analysis.
|
When is a ARMA(p,q) process ergodic?
|
It is sufficient for any stationary process that the autocovariances are absolute summable, i.e. that $\sum_{j=0}^\infty |\gamma_j|<\infty$. You can find this in Hamilton's Time Series Analysis.
|
When is a ARMA(p,q) process ergodic?
It is sufficient for any stationary process that the autocovariances are absolute summable, i.e. that $\sum_{j=0}^\infty |\gamma_j|<\infty$. You can find this in Hamilton's Time Series Analysis.
|
When is a ARMA(p,q) process ergodic?
It is sufficient for any stationary process that the autocovariances are absolute summable, i.e. that $\sum_{j=0}^\infty |\gamma_j|<\infty$. You can find this in Hamilton's Time Series Analysis.
|
47,369
|
Find the probability of an event determined by an inequality on exponential random variables
|
The probability density function of an Exponential($\lambda$) variate is, as shown in the question, given by
$$f_\lambda(x) = \lambda\exp(-\lambda x),\ x\ge 0.$$
($f$ is zero for $x\lt 0$.)
The independence assumption says the probability densities of $X$ and $Y$ multiply to give the joint probability density as
$$f_{X,Y}(x,y) = \left(1\times \exp(-1\times x)\right)\left(2\times \exp(-2\times y)\right) = 2\exp(-x-2y).$$
($f_{X,Y}$ is zero if either of $x$ or $y$ is negative.)
Joint densities give probabilities via integration: to find the probability of an event $E$, you integrate the density over the set $E$:
$${\Pr}_{f_{X,Y}}(E) = \iint_E 2 \exp(-x-2y)dx dy.$$
In this case, by remembering the restrictions $x\ge 0$ and $y\ge 0$, $E$ can be written as $\{(x,y)\ |\ 3x + 4y \le 5, x\ge 0, y\ge 0\}.$ Here is a picture of the graph of $f_{X,Y}$ near this region, with it filled in over $E$ to show how the volume under the graph (the integral) corresponds to the desired probability:
(The gray curves are contours of the graph of the joint density. Because the density does not change when $-x-2y$ is held fixed, these contours are all curves of the form $-x-2y=\text{ constant},$ which are portions of parallel lines all perpendicular to the vector $(-1,-2)$.)
Evidently $E$ is a triangle determined by $x\ge 0$, $y\ge 0$, and $3x+4y\le 5$. If we choose to perform the $x$ integration last, we find that for each $x$ the value of $y$ can range from a low of $0$ to a maximum of $(5-3x)/4,$ deduced by solving the simultaneous equations $3x+4y\le 5$ and $y\ge 0$. It is also evident from the figure and the inequalities that $3x$ cannot exceed $5$, whence $x$ must lie between $0$ and $5/3$. Therefore the desired probability should be computed with an integral like
$${\Pr}(3X+4Y\le 5) = \int_0^{5/3}\int_0^{(5-3x)/4} 2\exp(-x-2y) dy dx .$$
Working it out is elementary and not very instructive (but do it anyway to make sure the result is reasonable this time: partial steps in this direction appear in a duplicate thread on the Math site). The key thing to learn and remember is how to use joint densities to represent probabilities; the rest is part of the rote branch of Calculus. It might also be useful to remember that this kind of problem can be solved from first principles with relatively little work and the help of a simple sketch: you multiply (the marginal densities) and integrate the result over the event in question. It's always a good idea to draw a picture of it. The figure is a good summary of the general procedure.
|
Find the probability of an event determined by an inequality on exponential random variables
|
The probability density function of an Exponential($\lambda$) variate is, as shown in the question, given by
$$f_\lambda(x) = \lambda\exp(-\lambda x),\ x\ge 0.$$
($f$ is zero for $x\lt 0$.)
The indepe
|
Find the probability of an event determined by an inequality on exponential random variables
The probability density function of an Exponential($\lambda$) variate is, as shown in the question, given by
$$f_\lambda(x) = \lambda\exp(-\lambda x),\ x\ge 0.$$
($f$ is zero for $x\lt 0$.)
The independence assumption says the probability densities of $X$ and $Y$ multiply to give the joint probability density as
$$f_{X,Y}(x,y) = \left(1\times \exp(-1\times x)\right)\left(2\times \exp(-2\times y)\right) = 2\exp(-x-2y).$$
($f_{X,Y}$ is zero if either of $x$ or $y$ is negative.)
Joint densities give probabilities via integration: to find the probability of an event $E$, you integrate the density over the set $E$:
$${\Pr}_{f_{X,Y}}(E) = \iint_E 2 \exp(-x-2y)dx dy.$$
In this case, by remembering the restrictions $x\ge 0$ and $y\ge 0$, $E$ can be written as $\{(x,y)\ |\ 3x + 4y \le 5, x\ge 0, y\ge 0\}.$ Here is a picture of the graph of $f_{X,Y}$ near this region, with it filled in over $E$ to show how the volume under the graph (the integral) corresponds to the desired probability:
(The gray curves are contours of the graph of the joint density. Because the density does not change when $-x-2y$ is held fixed, these contours are all curves of the form $-x-2y=\text{ constant},$ which are portions of parallel lines all perpendicular to the vector $(-1,-2)$.)
Evidently $E$ is a triangle determined by $x\ge 0$, $y\ge 0$, and $3x+4y\le 5$. If we choose to perform the $x$ integration last, we find that for each $x$ the value of $y$ can range from a low of $0$ to a maximum of $(5-3x)/4,$ deduced by solving the simultaneous equations $3x+4y\le 5$ and $y\ge 0$. It is also evident from the figure and the inequalities that $3x$ cannot exceed $5$, whence $x$ must lie between $0$ and $5/3$. Therefore the desired probability should be computed with an integral like
$${\Pr}(3X+4Y\le 5) = \int_0^{5/3}\int_0^{(5-3x)/4} 2\exp(-x-2y) dy dx .$$
Working it out is elementary and not very instructive (but do it anyway to make sure the result is reasonable this time: partial steps in this direction appear in a duplicate thread on the Math site). The key thing to learn and remember is how to use joint densities to represent probabilities; the rest is part of the rote branch of Calculus. It might also be useful to remember that this kind of problem can be solved from first principles with relatively little work and the help of a simple sketch: you multiply (the marginal densities) and integrate the result over the event in question. It's always a good idea to draw a picture of it. The figure is a good summary of the general procedure.
|
Find the probability of an event determined by an inequality on exponential random variables
The probability density function of an Exponential($\lambda$) variate is, as shown in the question, given by
$$f_\lambda(x) = \lambda\exp(-\lambda x),\ x\ge 0.$$
($f$ is zero for $x\lt 0$.)
The indepe
|
47,370
|
Find the probability of an event determined by an inequality on exponential random variables
|
Check the distribution function of the generalized integer gamma distribution.
http://en.wikipedia.org/wiki/Generalized_integer_gamma_distribution
(Edit) Also, and answering your question better, check theorem 1 from here http://ac.els-cdn.com/S0047259X97917103/1-s2.0-S0047259X97917103-main.pdf?_tid=8558a38e-cfe5-11e3-b244-00000aacb35d&acdnat=1398807224_cff728a90ab971c59330b2f21843a383 This gives a closed expression for the distribution of what you're looking for.
|
Find the probability of an event determined by an inequality on exponential random variables
|
Check the distribution function of the generalized integer gamma distribution.
http://en.wikipedia.org/wiki/Generalized_integer_gamma_distribution
(Edit) Also, and answering your question better, chec
|
Find the probability of an event determined by an inequality on exponential random variables
Check the distribution function of the generalized integer gamma distribution.
http://en.wikipedia.org/wiki/Generalized_integer_gamma_distribution
(Edit) Also, and answering your question better, check theorem 1 from here http://ac.els-cdn.com/S0047259X97917103/1-s2.0-S0047259X97917103-main.pdf?_tid=8558a38e-cfe5-11e3-b244-00000aacb35d&acdnat=1398807224_cff728a90ab971c59330b2f21843a383 This gives a closed expression for the distribution of what you're looking for.
|
Find the probability of an event determined by an inequality on exponential random variables
Check the distribution function of the generalized integer gamma distribution.
http://en.wikipedia.org/wiki/Generalized_integer_gamma_distribution
(Edit) Also, and answering your question better, chec
|
47,371
|
Nested ANOVA: Unequal sample sizes? Variance components?
|
Hopefully your friend has graduated by now, but if not, the following might help.
You were on the right track in your original post Partitioning variance from logistic regression, using glmer() for mixed-effects logistic regression.
I would recommend against: the advisor's "solution", using lm() for logistic regression, and weighting rows equally (you should weight by N_indiv).
Generalized linear mixed models are tough. http://glmm.wikidot.com/faq has some good information - including the fact that you need many levels of a random factor in order to estimate its variance component.
My code below requires the lme4 package and the data from your link.
# Seroprevalance has been rounded, that's not OK
# to do logistic regression, (proportion * weight) must equal an integer
prev$seroexact <- round(prev$Seroprevalence * prev$N_indiv)/prev$N_indiv
# Host.Species is nested within Social.system, but you didn't reuse
# species letters between Social.systems, so you can specify
# Host.Species as a random effect without explicitly nesting it
# First random effect model
prev1.glmer = glmer(seroexact ~ Pathogen + Social.System + (1|Host.Species),
family=binomial(link="logit"), weights=N_indiv, data = prev)
summary(prev1.glmer)
## Fixed effects:
# Intercept is pathogen A and social.system A.
# The z-test of the intercept is testing if the logit=0
# I.e. it's testing whether the combination of
# pathogen A and social.system A has prob=0.5.
# The other z-tests are testing whether other levels of the factors
# yield different probabilities than pathogen A and social.system A
## Random effects:
# This doesn't give you separate Host.Species and residual variances,
# Host.Species is treated as a random effect, so this model is the same as if
# you had summed the results of all studies with identical values of
# Host.Species, Pathogen, and Social.System. I.e. sum the results of the
# first 8 rows and create a single proportion and N_indiv, like so:
prevsum<-aggregate(cbind(N_indiv, prop=(seroexact*N_indiv)) ~
Social.System+Host.Species+Pathogen, data=prev, sum)
prevsum$prop<-prevsum$prop/prevsum$N_indiv
# which gives the same model:
prevsum.glmer = glmer(prop ~ Pathogen + Social.System + (1|Host.Species),
family=binomial(link="logit"), weights=N_indiv, data = prevsum)
summary(prevsum.glmer)
# So why are they broken up into multiple rows? If each row represents
# one geographic area/time/litter/study/etc. then animals in one row
# might be more similar to eachother than they are to animals in
# another row that has the same values of Social, Species, & Pathogen.
# I think this is what the advisor wants as a "residual".
# To allow a random component for each row:
prev2<-cbind(resid=paste("Row_", row.names(prev), sep=""), prev)
prev2.glmer = glmer(seroexact ~ Pathogen + Social.System + (1|Host.Species) + (1|resid),
family=binomial(link="logit"), weights=N_indiv, data = prev2)
summary(prev2.glmer)
# This isn't a bad start, but I'm not comfortable with it because:
table(prev2[,2:3])
# Social.Sytstem D is only observed in Species F.
# This is called confounding, and it makes it hard to draw conclusions
# about Social Sytstem D. How do you know what is caused by social
# system D and what is caused by species F? If your friend really wants to
# make inferences about Social System D, she should collect data from
# another host species that uses Social System D.
# Leave out Soc_D:
prev3.glmer = glmer(seroexact ~ Pathogen + Social.System + (1|Host.Species) + (1|resid),
family=binomial(link="logit"), weights=N_indiv,
data = prev2[prev2$Social.System != "Soc_D",])
summary(prev3.glmer)
# Even though Host Species is conceptually a random factor, you really need to observe
# more than 2 species per social system for a mixed model to accurately estimate
# the species variance. As far as species variance is concerned, each species is a
# single sample (not animals or even litters), and you can't hope to estimate variance
# accurately with only two samples.
# We can fit the model with species as a fixed effect, but we don't have
# enough degrees of freedom to estimate all levels of Species:
prev4.glmer = glmer(seroexact ~ Pathogen + Social.System + Host.Species + (1|resid),
family=binomial(link="logit"), weights=N_indiv,
data = prev2[prev2$Social.System != "Soc_D",])
# Your friend doesn't need to estimate the level of each species in order to test
# whether species has any noticeable effect at all. Unfortunately, we can't just
# Use the F statistic from anova() because calculating the denominator df for a
# GLMM is not straightforward.
anova(prev4.glmer) #Gives you an F statistic, but no denominator df or p-value
# Instead we fit a simpler model without Species:
prev5.glmer = glmer(seroexact ~ Pathogen + Social.System + (1|resid),
family=binomial(link="logit"), weights=N_indiv,
data = prev2[prev2$Social.System != "Soc_D",])
# And we'll compare the two models With a Likelihood-Ratio test using anova()
anova(prev5.glmer,prev4.glmer)
# With a p-value of 0.01331 we can say it's worth keeping Species in the model.
# Now let's check the pathogen * social system interaction:
prev6.glmer = glmer(seroexact ~ Pathogen * Social.System + Host.Species + (1|resid),
family=binomial(link="logit"), weights=N_indiv, nAGQ=2,
data = prev2[prev2$Social.System != "Soc_D",])
summary(prev6.glmer) #Neither interaction term is significant
anova(prev6.glmer)
# We don't need a denominator df to know that the F statistic of 0.0774 for
# the interaction is insignificant.
# Since the interaction between Pathogen and Social System was not significant,
# we don't need to include the interaction term. Similarly, I don't see a
# statistical reason to split the model into two separate 'pathogen specific'
# models, but maybe there's a scientific reason to do so:
# Separate tests for each pathogen:
prev7A.glmer = glmer(seroexact ~ Social.System + Host.Species + (1|resid),
family=binomial(link="logit"), weights=N_indiv,
data = prev2[prev2$Social.System != "Soc_D" & prev$Pathogen == "Path_A",])
summary(prev7A.glmer)
# Social System B looks different from Social System A in pathogen A prevalance:
# Calculate the odds of having Pathogen A for Social System A vs B
beta7A<-fixef(prev7A.glmer)
exp(-beta7A[2]) #negative sign means odds of A:B instead of B:A
# So animals with Social System A have about 25 times the odds of
# animals with social system B of having Pathogen A
# Test for Pathogen B:
prev7B.glmer = glmer(seroexact ~ Social.System + Host.Species + (1|resid),
family=binomial(link="logit"), weights=N_indiv,
data = prev2[prev2$Social.System != "Soc_D" & prev$Pathogen == "Path_B",])
summary(prev7B.glmer)
# The only significant effects are species-specific, which are not of interest
# Let's return to prev4.glmer, which models both pathogens:
summary(prev4.glmer)
# The only significant fixed effect in prev4.glmer is Pathogen.
beta4<-fixef(prev4.glmer)
# For a randomly selected animal, the odds of having Pathogen B to having Pathogen A are:
exp(beta4[2])
# That's about as much as you can interpret with the data she has.
# To answer the Advisor's request for variance components:
# Residual variance is:
getME(prev4.glmer, "theta")^2
# You can't do a good job of estimating species variance with these data.
# If her advisor won't listen, then you can tell him that your estimate is:
getME(prev3.glmer, "theta")[2]^2
# But it's a really crappy estimate.
# There is no such thing as a variance component for Social System because
# it's a fixed effect. But you can get its sum of squares:
anova(prev4.glmer)
|
Nested ANOVA: Unequal sample sizes? Variance components?
|
Hopefully your friend has graduated by now, but if not, the following might help.
You were on the right track in your original post Partitioning variance from logistic regression, using glmer() for mi
|
Nested ANOVA: Unequal sample sizes? Variance components?
Hopefully your friend has graduated by now, but if not, the following might help.
You were on the right track in your original post Partitioning variance from logistic regression, using glmer() for mixed-effects logistic regression.
I would recommend against: the advisor's "solution", using lm() for logistic regression, and weighting rows equally (you should weight by N_indiv).
Generalized linear mixed models are tough. http://glmm.wikidot.com/faq has some good information - including the fact that you need many levels of a random factor in order to estimate its variance component.
My code below requires the lme4 package and the data from your link.
# Seroprevalance has been rounded, that's not OK
# to do logistic regression, (proportion * weight) must equal an integer
prev$seroexact <- round(prev$Seroprevalence * prev$N_indiv)/prev$N_indiv
# Host.Species is nested within Social.system, but you didn't reuse
# species letters between Social.systems, so you can specify
# Host.Species as a random effect without explicitly nesting it
# First random effect model
prev1.glmer = glmer(seroexact ~ Pathogen + Social.System + (1|Host.Species),
family=binomial(link="logit"), weights=N_indiv, data = prev)
summary(prev1.glmer)
## Fixed effects:
# Intercept is pathogen A and social.system A.
# The z-test of the intercept is testing if the logit=0
# I.e. it's testing whether the combination of
# pathogen A and social.system A has prob=0.5.
# The other z-tests are testing whether other levels of the factors
# yield different probabilities than pathogen A and social.system A
## Random effects:
# This doesn't give you separate Host.Species and residual variances,
# Host.Species is treated as a random effect, so this model is the same as if
# you had summed the results of all studies with identical values of
# Host.Species, Pathogen, and Social.System. I.e. sum the results of the
# first 8 rows and create a single proportion and N_indiv, like so:
prevsum<-aggregate(cbind(N_indiv, prop=(seroexact*N_indiv)) ~
Social.System+Host.Species+Pathogen, data=prev, sum)
prevsum$prop<-prevsum$prop/prevsum$N_indiv
# which gives the same model:
prevsum.glmer = glmer(prop ~ Pathogen + Social.System + (1|Host.Species),
family=binomial(link="logit"), weights=N_indiv, data = prevsum)
summary(prevsum.glmer)
# So why are they broken up into multiple rows? If each row represents
# one geographic area/time/litter/study/etc. then animals in one row
# might be more similar to eachother than they are to animals in
# another row that has the same values of Social, Species, & Pathogen.
# I think this is what the advisor wants as a "residual".
# To allow a random component for each row:
prev2<-cbind(resid=paste("Row_", row.names(prev), sep=""), prev)
prev2.glmer = glmer(seroexact ~ Pathogen + Social.System + (1|Host.Species) + (1|resid),
family=binomial(link="logit"), weights=N_indiv, data = prev2)
summary(prev2.glmer)
# This isn't a bad start, but I'm not comfortable with it because:
table(prev2[,2:3])
# Social.Sytstem D is only observed in Species F.
# This is called confounding, and it makes it hard to draw conclusions
# about Social Sytstem D. How do you know what is caused by social
# system D and what is caused by species F? If your friend really wants to
# make inferences about Social System D, she should collect data from
# another host species that uses Social System D.
# Leave out Soc_D:
prev3.glmer = glmer(seroexact ~ Pathogen + Social.System + (1|Host.Species) + (1|resid),
family=binomial(link="logit"), weights=N_indiv,
data = prev2[prev2$Social.System != "Soc_D",])
summary(prev3.glmer)
# Even though Host Species is conceptually a random factor, you really need to observe
# more than 2 species per social system for a mixed model to accurately estimate
# the species variance. As far as species variance is concerned, each species is a
# single sample (not animals or even litters), and you can't hope to estimate variance
# accurately with only two samples.
# We can fit the model with species as a fixed effect, but we don't have
# enough degrees of freedom to estimate all levels of Species:
prev4.glmer = glmer(seroexact ~ Pathogen + Social.System + Host.Species + (1|resid),
family=binomial(link="logit"), weights=N_indiv,
data = prev2[prev2$Social.System != "Soc_D",])
# Your friend doesn't need to estimate the level of each species in order to test
# whether species has any noticeable effect at all. Unfortunately, we can't just
# Use the F statistic from anova() because calculating the denominator df for a
# GLMM is not straightforward.
anova(prev4.glmer) #Gives you an F statistic, but no denominator df or p-value
# Instead we fit a simpler model without Species:
prev5.glmer = glmer(seroexact ~ Pathogen + Social.System + (1|resid),
family=binomial(link="logit"), weights=N_indiv,
data = prev2[prev2$Social.System != "Soc_D",])
# And we'll compare the two models With a Likelihood-Ratio test using anova()
anova(prev5.glmer,prev4.glmer)
# With a p-value of 0.01331 we can say it's worth keeping Species in the model.
# Now let's check the pathogen * social system interaction:
prev6.glmer = glmer(seroexact ~ Pathogen * Social.System + Host.Species + (1|resid),
family=binomial(link="logit"), weights=N_indiv, nAGQ=2,
data = prev2[prev2$Social.System != "Soc_D",])
summary(prev6.glmer) #Neither interaction term is significant
anova(prev6.glmer)
# We don't need a denominator df to know that the F statistic of 0.0774 for
# the interaction is insignificant.
# Since the interaction between Pathogen and Social System was not significant,
# we don't need to include the interaction term. Similarly, I don't see a
# statistical reason to split the model into two separate 'pathogen specific'
# models, but maybe there's a scientific reason to do so:
# Separate tests for each pathogen:
prev7A.glmer = glmer(seroexact ~ Social.System + Host.Species + (1|resid),
family=binomial(link="logit"), weights=N_indiv,
data = prev2[prev2$Social.System != "Soc_D" & prev$Pathogen == "Path_A",])
summary(prev7A.glmer)
# Social System B looks different from Social System A in pathogen A prevalance:
# Calculate the odds of having Pathogen A for Social System A vs B
beta7A<-fixef(prev7A.glmer)
exp(-beta7A[2]) #negative sign means odds of A:B instead of B:A
# So animals with Social System A have about 25 times the odds of
# animals with social system B of having Pathogen A
# Test for Pathogen B:
prev7B.glmer = glmer(seroexact ~ Social.System + Host.Species + (1|resid),
family=binomial(link="logit"), weights=N_indiv,
data = prev2[prev2$Social.System != "Soc_D" & prev$Pathogen == "Path_B",])
summary(prev7B.glmer)
# The only significant effects are species-specific, which are not of interest
# Let's return to prev4.glmer, which models both pathogens:
summary(prev4.glmer)
# The only significant fixed effect in prev4.glmer is Pathogen.
beta4<-fixef(prev4.glmer)
# For a randomly selected animal, the odds of having Pathogen B to having Pathogen A are:
exp(beta4[2])
# That's about as much as you can interpret with the data she has.
# To answer the Advisor's request for variance components:
# Residual variance is:
getME(prev4.glmer, "theta")^2
# You can't do a good job of estimating species variance with these data.
# If her advisor won't listen, then you can tell him that your estimate is:
getME(prev3.glmer, "theta")[2]^2
# But it's a really crappy estimate.
# There is no such thing as a variance component for Social System because
# it's a fixed effect. But you can get its sum of squares:
anova(prev4.glmer)
|
Nested ANOVA: Unequal sample sizes? Variance components?
Hopefully your friend has graduated by now, but if not, the following might help.
You were on the right track in your original post Partitioning variance from logistic regression, using glmer() for mi
|
47,372
|
Hypothesis testing on Poisson Binomial distribution
|
You can just use the number of successes itself as the test statistic.
If you want a one-tailed test this is simple (and I expect you will). For a two tailed test, because of the asymmetry, the usual approach would be to allocate $\alpha/2$ to each tail and compute a rejection region that way. There's some variation in exactly how this gets implemented since you can't get exactly $\alpha/2$ in either tail, but p-values are slightly complicated (you base them on whatever rules you come up with for how your rejection region would actually be computed).
1) If the $p_i$s are known and all are small, you can use a Poisson approximation for the number of successes.
If the p's are all pretty small, the mean of the sum is close to the variance of the sum, so one quick assessment of whether they're small enough is to compare the variance to the mean; if it's pretty close, this will normally work fairly well. What constitutes 'close' depends on your criteria, you really need to calibrate it yourself. As a very rough rule of thumb I'd suggest variance/mean above 0.9, but you may want it higher. If you want a more precise rule about when the Poisson will work, Le Cam's theorem bounds the sum of absolute deviations between the true probability function and the Poisson approximation (though this doesn't necessarily tell you how well it performs in the part of the tail that determines the accuracy of a nominal significance level).
2) If the $p_i$ are not necessarily small but there are a lot of them you can use a normal approximation (perhaps with continuity correction). Assuming the p's are typically less than 0.5, a simple rule would be if the coefficient of variation for the number of successes is sufficiently* small, the normal approximation should be fine.
* what constitutes 'sufficiently' depends on your criteria, again, you really need to calibrate it yourself. But as a very rough rule of thumb, I'd suggest that the reciprocal of the coefficient of variation should be more than 4 if you want roughly accurate p-values around 0.05 (one tailed), more than 5 if you want roughly accurate p-values around the 2.5% level, and more than 7 if you want reasonable accuracy around the 1% level. Those are pretty rough, though, you may well want more accuracy than that.
3) If there's very little variation in the $p_i$'s, you could use a binomial approximation.
4) You can simulate the distribution of the number of successes directly.
5) The probability function for the convolution of the Bernoulli($p_i$) variables is fairly easy to compute numerically. For small numbers of variables (up to a couple of dozen easily), it can be done by brute force with no difficulty. [For large numbers, you're probably better off using FFT, as it's much faster, though you'll likely hit the point where normal approximation is very accurate long before it's much of an issue.]
In each of the cases (1) to (3), you can check the quality of the approximation via simulation... but if you do that, you might as well get the p-value the same way.
Incidentally, the R package poibin offers four calculations or approximations (it does not include the Poisson). There's an associated paper
Hong, Y. (2012),
"On computing the distribution function for the Poisson binomial distribution."
Computational Statistics & Data Analysis.
http://dx.doi.org/10.1016/j.csda.2012.10.006. (Tech Report here)
where the author derives an expression based on the discrete Fourier transform.
Here's an example, using the Poisson approximation:
$p_1, ..., p_5 = 0.05, p_6, ...,p_9 = 0.10$
The mean is 0.65 and the standard deviation = $\sqrt{0.05\times 0.95\times 5 + 0.10 \times 0.90 \times 4} \approx 0.773$
The coefficient of variation rules out the normal approximation. The variance divided by the mean is 0.92, which suggests the Poisson may not do too badly.
The possible (typical range) one tailed significance levels for a Poisson(0.65) are 13.8%, 2.8%, 0.44% ... Let's say we choose 2.8%, which is to say if we see 3 or more successes we'll reject the null.
Now, the exact calculation is simply the convolution of a Binomial(5,0.05) and a Binomial(4,0.10), and this immediately is:
0 1 2 3 4 5 6 7 ...
exact 0.5076777 0.3592339 0.1110464 0.0196723 0.0022006 0.0001612 7.70e-06 2.0e-07
Pois 0.5220458 0.3393298 0.1102822 0.0238945 0.0038829 0.0005048 5.47e-05 5.1e-06
As you see they're at least close-ish except in the far tail (up to X=3 say); the exact significance level for a rejection rule of 'reject if there are at least 3 successes' is about 2.2%, while the Poisson gave about 2.8%. For my purposes that would be reasonable, but your own needs may differ.
|
Hypothesis testing on Poisson Binomial distribution
|
You can just use the number of successes itself as the test statistic.
If you want a one-tailed test this is simple (and I expect you will). For a two tailed test, because of the asymmetry, the usual
|
Hypothesis testing on Poisson Binomial distribution
You can just use the number of successes itself as the test statistic.
If you want a one-tailed test this is simple (and I expect you will). For a two tailed test, because of the asymmetry, the usual approach would be to allocate $\alpha/2$ to each tail and compute a rejection region that way. There's some variation in exactly how this gets implemented since you can't get exactly $\alpha/2$ in either tail, but p-values are slightly complicated (you base them on whatever rules you come up with for how your rejection region would actually be computed).
1) If the $p_i$s are known and all are small, you can use a Poisson approximation for the number of successes.
If the p's are all pretty small, the mean of the sum is close to the variance of the sum, so one quick assessment of whether they're small enough is to compare the variance to the mean; if it's pretty close, this will normally work fairly well. What constitutes 'close' depends on your criteria, you really need to calibrate it yourself. As a very rough rule of thumb I'd suggest variance/mean above 0.9, but you may want it higher. If you want a more precise rule about when the Poisson will work, Le Cam's theorem bounds the sum of absolute deviations between the true probability function and the Poisson approximation (though this doesn't necessarily tell you how well it performs in the part of the tail that determines the accuracy of a nominal significance level).
2) If the $p_i$ are not necessarily small but there are a lot of them you can use a normal approximation (perhaps with continuity correction). Assuming the p's are typically less than 0.5, a simple rule would be if the coefficient of variation for the number of successes is sufficiently* small, the normal approximation should be fine.
* what constitutes 'sufficiently' depends on your criteria, again, you really need to calibrate it yourself. But as a very rough rule of thumb, I'd suggest that the reciprocal of the coefficient of variation should be more than 4 if you want roughly accurate p-values around 0.05 (one tailed), more than 5 if you want roughly accurate p-values around the 2.5% level, and more than 7 if you want reasonable accuracy around the 1% level. Those are pretty rough, though, you may well want more accuracy than that.
3) If there's very little variation in the $p_i$'s, you could use a binomial approximation.
4) You can simulate the distribution of the number of successes directly.
5) The probability function for the convolution of the Bernoulli($p_i$) variables is fairly easy to compute numerically. For small numbers of variables (up to a couple of dozen easily), it can be done by brute force with no difficulty. [For large numbers, you're probably better off using FFT, as it's much faster, though you'll likely hit the point where normal approximation is very accurate long before it's much of an issue.]
In each of the cases (1) to (3), you can check the quality of the approximation via simulation... but if you do that, you might as well get the p-value the same way.
Incidentally, the R package poibin offers four calculations or approximations (it does not include the Poisson). There's an associated paper
Hong, Y. (2012),
"On computing the distribution function for the Poisson binomial distribution."
Computational Statistics & Data Analysis.
http://dx.doi.org/10.1016/j.csda.2012.10.006. (Tech Report here)
where the author derives an expression based on the discrete Fourier transform.
Here's an example, using the Poisson approximation:
$p_1, ..., p_5 = 0.05, p_6, ...,p_9 = 0.10$
The mean is 0.65 and the standard deviation = $\sqrt{0.05\times 0.95\times 5 + 0.10 \times 0.90 \times 4} \approx 0.773$
The coefficient of variation rules out the normal approximation. The variance divided by the mean is 0.92, which suggests the Poisson may not do too badly.
The possible (typical range) one tailed significance levels for a Poisson(0.65) are 13.8%, 2.8%, 0.44% ... Let's say we choose 2.8%, which is to say if we see 3 or more successes we'll reject the null.
Now, the exact calculation is simply the convolution of a Binomial(5,0.05) and a Binomial(4,0.10), and this immediately is:
0 1 2 3 4 5 6 7 ...
exact 0.5076777 0.3592339 0.1110464 0.0196723 0.0022006 0.0001612 7.70e-06 2.0e-07
Pois 0.5220458 0.3393298 0.1102822 0.0238945 0.0038829 0.0005048 5.47e-05 5.1e-06
As you see they're at least close-ish except in the far tail (up to X=3 say); the exact significance level for a rejection rule of 'reject if there are at least 3 successes' is about 2.2%, while the Poisson gave about 2.8%. For my purposes that would be reasonable, but your own needs may differ.
|
Hypothesis testing on Poisson Binomial distribution
You can just use the number of successes itself as the test statistic.
If you want a one-tailed test this is simple (and I expect you will). For a two tailed test, because of the asymmetry, the usual
|
47,373
|
Is it better to use data imputation for missing data or an analysis that is not affected by missing data (e.g., HLM/mixed effects modelling)?
|
I would hands down use mixed-effects modeling. First, I am not aware of an easy way to pool multiple-degree-of-freedom effects (as in ANOVA with a factor with more than two levels). Also, multiple imputation and full-information maximum likelihood estimation (the latter being what mixed-effects models use) make the same assumptions (like multivariate normality), and so tend to yield similar results (see Baraldi & Enders, 2010, available here).
The choice is more a choice of convenience (as the authors cited above point out), and in this case, given how easy full-information maximum likelihood is implemented, mixed-effects modeling is a natural choice. Also, a mixed-effects model would allow you to have a random effect for the change over time, meaning that change over time is allowed to vary across participants, whereas this is not possible in a repeated-measures ANOVA (repeated-measures ANOVA have random intercepts but fixed slopes).
By the way, one situation that might have made multiple imputation more attractive is if there had been missing data on the predictor variables as well, since full-information maximum likelihood in mixed-effects modeling software typically handles missing data on the dependent variable only.
Reference:
Baraldi, A. N., & Enders, C. K. (2010). An introduction to modern missing data analyses. Journal of School Psychology, 48, 5-37.
|
Is it better to use data imputation for missing data or an analysis that is not affected by missing
|
I would hands down use mixed-effects modeling. First, I am not aware of an easy way to pool multiple-degree-of-freedom effects (as in ANOVA with a factor with more than two levels). Also, multiple imp
|
Is it better to use data imputation for missing data or an analysis that is not affected by missing data (e.g., HLM/mixed effects modelling)?
I would hands down use mixed-effects modeling. First, I am not aware of an easy way to pool multiple-degree-of-freedom effects (as in ANOVA with a factor with more than two levels). Also, multiple imputation and full-information maximum likelihood estimation (the latter being what mixed-effects models use) make the same assumptions (like multivariate normality), and so tend to yield similar results (see Baraldi & Enders, 2010, available here).
The choice is more a choice of convenience (as the authors cited above point out), and in this case, given how easy full-information maximum likelihood is implemented, mixed-effects modeling is a natural choice. Also, a mixed-effects model would allow you to have a random effect for the change over time, meaning that change over time is allowed to vary across participants, whereas this is not possible in a repeated-measures ANOVA (repeated-measures ANOVA have random intercepts but fixed slopes).
By the way, one situation that might have made multiple imputation more attractive is if there had been missing data on the predictor variables as well, since full-information maximum likelihood in mixed-effects modeling software typically handles missing data on the dependent variable only.
Reference:
Baraldi, A. N., & Enders, C. K. (2010). An introduction to modern missing data analyses. Journal of School Psychology, 48, 5-37.
|
Is it better to use data imputation for missing data or an analysis that is not affected by missing
I would hands down use mixed-effects modeling. First, I am not aware of an easy way to pool multiple-degree-of-freedom effects (as in ANOVA with a factor with more than two levels). Also, multiple imp
|
47,374
|
How important it is to have an intuition of why various statistical tests work?
|
Broadly speaking, the more you understand a test (or indeed any other aspect of the vrious calculations one does in statistics), the better, but it's not usually necessary to understand every specific detail of each constant in a formula to have a good understanding of what's going on.
For example, sometimes (particularly when trying to compute the distribution under the null hypothesis), people formulate a Spearman correlation as $ \rho = 1- {\frac {6 \sum d_i^2}{n(n^2 - 1)}}$, where $d_i$ is the difference between the $x_i$ rank and the $y_i$ rank. Is it necessary to understand where the "6" comes from? I don't think it's necessary if you're just trying to get intuition about the test (though in fact it's pretty straightforward) - if you comprehend the test as "a correlation calculated on the ranks", you pretty much have most of the useful intuition there. There are some additional bits of intuition that can be gleaned from the fact that it can also be written as a linear function of squared rank-differences, but the constants themselves aren't especially enlightening.
You can check the formula easily enough, in several ways (e.g. by computing the value for both the 'correlation of the ranks' form and the '$ \sum d_i^2$' form for some small samples), and you can check the null distribution easily enough (by simple enumeration for very small samples, and by simulation for larger samples), without necessarily knowing how to do the algebra.
I'd urge you to do as much as you can - there are few things I've learned along those lines that don't help in some ways - but not to fret over much when you can't. There's always somewhere you can ask about how the details come to be as they are (in the case of the Spearman correlation, some of those details have been explained here already).
Basic intuition about t-tests would include, for example, what the denominator is trying to measure (the formulas for different t-statistics look different, but they're always an estimate of the standard deviation of the distribution of the numerator), and also if possible why the different numerators are as they are, and why the denominators are then of the form they have.
With F-tests, it's certainly useful to know that the numerator and denominator are two different estimates of variance - which if the null is true should be independence estimates of the same variance. (It's also useful to have some sense of how the distribution changes as the degrees of freedom change.)
|
How important it is to have an intuition of why various statistical tests work?
|
Broadly speaking, the more you understand a test (or indeed any other aspect of the vrious calculations one does in statistics), the better, but it's not usually necessary to understand every specifi
|
How important it is to have an intuition of why various statistical tests work?
Broadly speaking, the more you understand a test (or indeed any other aspect of the vrious calculations one does in statistics), the better, but it's not usually necessary to understand every specific detail of each constant in a formula to have a good understanding of what's going on.
For example, sometimes (particularly when trying to compute the distribution under the null hypothesis), people formulate a Spearman correlation as $ \rho = 1- {\frac {6 \sum d_i^2}{n(n^2 - 1)}}$, where $d_i$ is the difference between the $x_i$ rank and the $y_i$ rank. Is it necessary to understand where the "6" comes from? I don't think it's necessary if you're just trying to get intuition about the test (though in fact it's pretty straightforward) - if you comprehend the test as "a correlation calculated on the ranks", you pretty much have most of the useful intuition there. There are some additional bits of intuition that can be gleaned from the fact that it can also be written as a linear function of squared rank-differences, but the constants themselves aren't especially enlightening.
You can check the formula easily enough, in several ways (e.g. by computing the value for both the 'correlation of the ranks' form and the '$ \sum d_i^2$' form for some small samples), and you can check the null distribution easily enough (by simple enumeration for very small samples, and by simulation for larger samples), without necessarily knowing how to do the algebra.
I'd urge you to do as much as you can - there are few things I've learned along those lines that don't help in some ways - but not to fret over much when you can't. There's always somewhere you can ask about how the details come to be as they are (in the case of the Spearman correlation, some of those details have been explained here already).
Basic intuition about t-tests would include, for example, what the denominator is trying to measure (the formulas for different t-statistics look different, but they're always an estimate of the standard deviation of the distribution of the numerator), and also if possible why the different numerators are as they are, and why the denominators are then of the form they have.
With F-tests, it's certainly useful to know that the numerator and denominator are two different estimates of variance - which if the null is true should be independence estimates of the same variance. (It's also useful to have some sense of how the distribution changes as the degrees of freedom change.)
|
How important it is to have an intuition of why various statistical tests work?
Broadly speaking, the more you understand a test (or indeed any other aspect of the vrious calculations one does in statistics), the better, but it's not usually necessary to understand every specifi
|
47,375
|
How important it is to have an intuition of why various statistical tests work?
|
It's never bad to understand more details of what is going on, but I think there is an intermediate ground. E.g. take the formula for the pdf normal density
$
\frac{1}{\sigma\sqrt{2\pi}}\, e^{-\frac{(x - \mu)^2}{2 \sigma^2}}
$
Do you need to know how this was derived and why each part of it is the way it is in order to know a lot about normality and the requirement for it? No. But it's good to know more than just "normality of the residuals is a requirement".
(The above is if you are the data analyst sort of statistician; if you want to prove theorems and such, you will need to know a lot more about this sort of thing).
|
How important it is to have an intuition of why various statistical tests work?
|
It's never bad to understand more details of what is going on, but I think there is an intermediate ground. E.g. take the formula for the pdf normal density
$
\frac{1}{\sigma\sqrt{2\pi}}\, e^{-\frac{
|
How important it is to have an intuition of why various statistical tests work?
It's never bad to understand more details of what is going on, but I think there is an intermediate ground. E.g. take the formula for the pdf normal density
$
\frac{1}{\sigma\sqrt{2\pi}}\, e^{-\frac{(x - \mu)^2}{2 \sigma^2}}
$
Do you need to know how this was derived and why each part of it is the way it is in order to know a lot about normality and the requirement for it? No. But it's good to know more than just "normality of the residuals is a requirement".
(The above is if you are the data analyst sort of statistician; if you want to prove theorems and such, you will need to know a lot more about this sort of thing).
|
How important it is to have an intuition of why various statistical tests work?
It's never bad to understand more details of what is going on, but I think there is an intermediate ground. E.g. take the formula for the pdf normal density
$
\frac{1}{\sigma\sqrt{2\pi}}\, e^{-\frac{
|
47,376
|
F-values in ANOVA table
|
For age, $F=1.0812=\frac{MS_\text{age}}{MS_\text{Residuals}}$. The same is true of the other $F$ values replacing age with weight or protein. This partials out the variance in carb that is related to the other two factors not being tested directly by the $F$ test in question, whereas using $MS_\text{Residuals}$ from a single-factor GLM in the denominator would not. Thus the hypothesis test is of whether the residual variance in carb that is not explained by your other factors can be explained by your given factor. More specifically, the $p$ value represents the probability that this residual variance would relate to your given factor at least as much as it does in your sample if you were to sample again randomly from a population in which the null hypothesis of no relationship between those residuals and your factor is literally true. As for why 16 and not 18, remember that controlling for these other factors costs you degrees of freedom: one apiece.
To elaborate in response to your edit/comment, another way of looking at your $F=3.5821$ is as $F=\frac{MS_\text{weight}}{MS_\text{Residuals}}$ for a general linear model with only one factor (weight). With that one-factor GLM's ${MS_\text{Residuals}}$ instead of a three-factor GLM's ${MS_\text{Residuals}}$ as the denominator (because you're not controlling for anything, hence what would've been the residuals are the observations $-\ \mu_\text{carb}$ instead, $\mu_\text{carb}$ being the intercept of the null model), you haven't partialed out any of the variance that weight can't explain but age or protein can, so the effect of weight appears less clear by itself.
When you control for the effects of age and protein, you reduce the amount of variance that still needs explaining in your model. This makes the predictive job a little easier for weight, because it no longer has to contend with the independent effects of age or protein in explaining carb. In a post hoc / retrospective sense, you can look back and say, "Well, no wonder weight didn't predict these observations as well by itself; age and protein vary in my sample too, and their independent effects were mucking things up for poor ol' weight!" Of course, these results are even better in an epistemic, hypothesis-testing sense if you expected in advance that this would happen, and chose multiple regression to examine hypotheses of independent effects you also specified in advance.
|
F-values in ANOVA table
|
For age, $F=1.0812=\frac{MS_\text{age}}{MS_\text{Residuals}}$. The same is true of the other $F$ values replacing age with weight or protein. This partials out the variance in carb that is related to
|
F-values in ANOVA table
For age, $F=1.0812=\frac{MS_\text{age}}{MS_\text{Residuals}}$. The same is true of the other $F$ values replacing age with weight or protein. This partials out the variance in carb that is related to the other two factors not being tested directly by the $F$ test in question, whereas using $MS_\text{Residuals}$ from a single-factor GLM in the denominator would not. Thus the hypothesis test is of whether the residual variance in carb that is not explained by your other factors can be explained by your given factor. More specifically, the $p$ value represents the probability that this residual variance would relate to your given factor at least as much as it does in your sample if you were to sample again randomly from a population in which the null hypothesis of no relationship between those residuals and your factor is literally true. As for why 16 and not 18, remember that controlling for these other factors costs you degrees of freedom: one apiece.
To elaborate in response to your edit/comment, another way of looking at your $F=3.5821$ is as $F=\frac{MS_\text{weight}}{MS_\text{Residuals}}$ for a general linear model with only one factor (weight). With that one-factor GLM's ${MS_\text{Residuals}}$ instead of a three-factor GLM's ${MS_\text{Residuals}}$ as the denominator (because you're not controlling for anything, hence what would've been the residuals are the observations $-\ \mu_\text{carb}$ instead, $\mu_\text{carb}$ being the intercept of the null model), you haven't partialed out any of the variance that weight can't explain but age or protein can, so the effect of weight appears less clear by itself.
When you control for the effects of age and protein, you reduce the amount of variance that still needs explaining in your model. This makes the predictive job a little easier for weight, because it no longer has to contend with the independent effects of age or protein in explaining carb. In a post hoc / retrospective sense, you can look back and say, "Well, no wonder weight didn't predict these observations as well by itself; age and protein vary in my sample too, and their independent effects were mucking things up for poor ol' weight!" Of course, these results are even better in an epistemic, hypothesis-testing sense if you expected in advance that this would happen, and chose multiple regression to examine hypotheses of independent effects you also specified in advance.
|
F-values in ANOVA table
For age, $F=1.0812=\frac{MS_\text{age}}{MS_\text{Residuals}}$. The same is true of the other $F$ values replacing age with weight or protein. This partials out the variance in carb that is related to
|
47,377
|
F-values in ANOVA table
|
The anova function in R, when given only 1 model, produces the "Sequential" sums of squares. This means that each term is adjusted for those above it (to the left in the model formula) and don't include those below (to the right). So in your example you are testing weight vs. intercept only, protein + weight vs. weight only, and age + protein + weight vs. protein + weight.
If you change the order of the terms in the formula statement then it will change the conditioning in those tests.
If you give anova 2 models (with one of them nested in the other) then it will give the full and reduced test with the null that the smaller model is sufficient and the alternative that the additional terms in the fuller model do contribute.
|
F-values in ANOVA table
|
The anova function in R, when given only 1 model, produces the "Sequential" sums of squares. This means that each term is adjusted for those above it (to the left in the model formula) and don't incl
|
F-values in ANOVA table
The anova function in R, when given only 1 model, produces the "Sequential" sums of squares. This means that each term is adjusted for those above it (to the left in the model formula) and don't include those below (to the right). So in your example you are testing weight vs. intercept only, protein + weight vs. weight only, and age + protein + weight vs. protein + weight.
If you change the order of the terms in the formula statement then it will change the conditioning in those tests.
If you give anova 2 models (with one of them nested in the other) then it will give the full and reduced test with the null that the smaller model is sufficient and the alternative that the additional terms in the fuller model do contribute.
|
F-values in ANOVA table
The anova function in R, when given only 1 model, produces the "Sequential" sums of squares. This means that each term is adjusted for those above it (to the left in the model formula) and don't incl
|
47,378
|
Prediction interval for my bus journey
|
You don't explicitly state in your question whether you're prepared to assume independence of the two times, but some things about the way you wrote your question do seem to suggest it. I'm not at all sure that is a reasonable assumption, since if traffic turns bad, the average wait and the average trip will be longer, in both cases because the buses will tend to be delayed.
Nonetheless, I have written the rest of this under the assumption that you intended the question to apply to the situation where they're independent.
The convolution of a normal and an exponential has what is sometimes called an Exponentially modified Gaussian (ExGaussian) distribution.
Some ExGaussians are skewed, others are very nearly normal.
With your particular parameters, the distribution of the sum is not very close to normal. Here's a histogram of simulated values (100,000 of them) for the sum:
The mean and variance of the sum is easy - the mean is the sum of the means, and for independent variables, the variance is the sum of the variances; but this is not much use for getting the 99th percentile.
Incidentally, the same simulation above can be used to get a pretty good estimate of the 99th percentile:
The results from five simulations (of 1,000,000 values of $X+Y$ each) give 99.31, 99.23, 99.20, 99.26, 99.45 minutes respectively; if you need more accuracy, more simulations would be needed -- or actually finding the argument of the CDF that gives 0.99 (the CDF is given at the link to the ExGaussian I gave above).
A little trial and error with that CDF gives the value 99.34 minutes for the 99th percentile, which seems to be consistent with the simulations (and vice-versa).
(If you allow for even some mild positive dependence between the two times, it's going to go over 100 minutes.)
|
Prediction interval for my bus journey
|
You don't explicitly state in your question whether you're prepared to assume independence of the two times, but some things about the way you wrote your question do seem to suggest it. I'm not at all
|
Prediction interval for my bus journey
You don't explicitly state in your question whether you're prepared to assume independence of the two times, but some things about the way you wrote your question do seem to suggest it. I'm not at all sure that is a reasonable assumption, since if traffic turns bad, the average wait and the average trip will be longer, in both cases because the buses will tend to be delayed.
Nonetheless, I have written the rest of this under the assumption that you intended the question to apply to the situation where they're independent.
The convolution of a normal and an exponential has what is sometimes called an Exponentially modified Gaussian (ExGaussian) distribution.
Some ExGaussians are skewed, others are very nearly normal.
With your particular parameters, the distribution of the sum is not very close to normal. Here's a histogram of simulated values (100,000 of them) for the sum:
The mean and variance of the sum is easy - the mean is the sum of the means, and for independent variables, the variance is the sum of the variances; but this is not much use for getting the 99th percentile.
Incidentally, the same simulation above can be used to get a pretty good estimate of the 99th percentile:
The results from five simulations (of 1,000,000 values of $X+Y$ each) give 99.31, 99.23, 99.20, 99.26, 99.45 minutes respectively; if you need more accuracy, more simulations would be needed -- or actually finding the argument of the CDF that gives 0.99 (the CDF is given at the link to the ExGaussian I gave above).
A little trial and error with that CDF gives the value 99.34 minutes for the 99th percentile, which seems to be consistent with the simulations (and vice-versa).
(If you allow for even some mild positive dependence between the two times, it's going to go over 100 minutes.)
|
Prediction interval for my bus journey
You don't explicitly state in your question whether you're prepared to assume independence of the two times, but some things about the way you wrote your question do seem to suggest it. I'm not at all
|
47,379
|
Prediction interval for my bus journey
|
As indicated above by Glen_b, 99.34 minutes is the 99th percentile.
Below are the density(PDF) and cumulative distribution (CDF) plots and a table of CDF values for the combined distribution.
|
Prediction interval for my bus journey
|
As indicated above by Glen_b, 99.34 minutes is the 99th percentile.
Below are the density(PDF) and cumulative distribution (CDF) plots and a table of CDF values for the combined distribution.
|
Prediction interval for my bus journey
As indicated above by Glen_b, 99.34 minutes is the 99th percentile.
Below are the density(PDF) and cumulative distribution (CDF) plots and a table of CDF values for the combined distribution.
|
Prediction interval for my bus journey
As indicated above by Glen_b, 99.34 minutes is the 99th percentile.
Below are the density(PDF) and cumulative distribution (CDF) plots and a table of CDF values for the combined distribution.
|
47,380
|
ABC. How can it avoid the likelihood function?
|
Approximate Bayesian Computation (ABC) is useful when you can simulate data, but cannot evaluate the likelihood function analytically. You seem to assume that it is necessary to know the likelihood function $l(\theta) = P[D|\theta]$ to simulate data. I'm not sure how you came to that conclusion, but there are ways to simulate data that do not involve the likelihood. ABC does not 'provide' you with such a way of simulating data. You have to come up with some suitable simulation approach yourself.
In your example, one would draw values for $\mu$ from the prior distribution $p(\theta)$, and simulate a sample $\tilde D$ from an $N(\mu, \sigma)$ distribution. We can use a quantile-transformation $\Phi^{-1}(u)$ of a uniform distributed random number $u$ here. This requires that we know the quantile-function $\Phi^{-1}$ of $N(\mu, \sigma)$, but not the likelihood function $P[D|\theta]$. Alternative, we could even do a real world experiment which is known to produce $N(\mu,\sigma)$ disturbed measurements.
The idea of ABC now is, that if $\tilde D$ is identical to the real data $D$, then $\theta$ also is a sample from the posterior distribution $p(\theta|D)$. If we get enough of such samples, we can use the then to approximate the posterior distribution itself. As we normally would hardly ever observe a simulation with produces exactly $D$, we allow for a small mismatch $\epsilon$ between $D$ and $\tilde D$, which introduces another approximation.
|
ABC. How can it avoid the likelihood function?
|
Approximate Bayesian Computation (ABC) is useful when you can simulate data, but cannot evaluate the likelihood function analytically. You seem to assume that it is necessary to know the likelihood fu
|
ABC. How can it avoid the likelihood function?
Approximate Bayesian Computation (ABC) is useful when you can simulate data, but cannot evaluate the likelihood function analytically. You seem to assume that it is necessary to know the likelihood function $l(\theta) = P[D|\theta]$ to simulate data. I'm not sure how you came to that conclusion, but there are ways to simulate data that do not involve the likelihood. ABC does not 'provide' you with such a way of simulating data. You have to come up with some suitable simulation approach yourself.
In your example, one would draw values for $\mu$ from the prior distribution $p(\theta)$, and simulate a sample $\tilde D$ from an $N(\mu, \sigma)$ distribution. We can use a quantile-transformation $\Phi^{-1}(u)$ of a uniform distributed random number $u$ here. This requires that we know the quantile-function $\Phi^{-1}$ of $N(\mu, \sigma)$, but not the likelihood function $P[D|\theta]$. Alternative, we could even do a real world experiment which is known to produce $N(\mu,\sigma)$ disturbed measurements.
The idea of ABC now is, that if $\tilde D$ is identical to the real data $D$, then $\theta$ also is a sample from the posterior distribution $p(\theta|D)$. If we get enough of such samples, we can use the then to approximate the posterior distribution itself. As we normally would hardly ever observe a simulation with produces exactly $D$, we allow for a small mismatch $\epsilon$ between $D$ and $\tilde D$, which introduces another approximation.
|
ABC. How can it avoid the likelihood function?
Approximate Bayesian Computation (ABC) is useful when you can simulate data, but cannot evaluate the likelihood function analytically. You seem to assume that it is necessary to know the likelihood fu
|
47,381
|
Are there any probabilistic models for graph-based recommender systems?
|
There is the very-well known approach based on restricted BOltzmann machines (RBM), which won the Netflix competition. For more details you may have a look at the Wikipedia site, and the references therein.
Restricted Boltzmann machines are a particular instance of Markov Random Fields, with some properties that makes particularly attractive. Here a couple of points are made.
The approach is described in detail in this paper. The idea is that there is a RBM per user. Each RBM has as many hidden units as items rated by the user. The main insight is weight sharing: the weight referring to a corresponding item is shared by all users, i.e. it is the same parameter. So when many users give a good rating to an item, the corresponding weight becomes stronger for all users. And viceversa. Here is where collaboration takes place.
Now, in order to see what items to recommend to a given user, one clamp the visible units to the observed ratings, and evaluates the probability of obtaining a given rating for each user. You may have a look at these slides, where it is graphically explained in more detail.
As I understand, selecting a vertex would be equivalent to selecting one of the items. The RBM would give you back how likely will the user rate the item as k, where k is each of the possible ratings.
|
Are there any probabilistic models for graph-based recommender systems?
|
There is the very-well known approach based on restricted BOltzmann machines (RBM), which won the Netflix competition. For more details you may have a look at the Wikipedia site, and the references th
|
Are there any probabilistic models for graph-based recommender systems?
There is the very-well known approach based on restricted BOltzmann machines (RBM), which won the Netflix competition. For more details you may have a look at the Wikipedia site, and the references therein.
Restricted Boltzmann machines are a particular instance of Markov Random Fields, with some properties that makes particularly attractive. Here a couple of points are made.
The approach is described in detail in this paper. The idea is that there is a RBM per user. Each RBM has as many hidden units as items rated by the user. The main insight is weight sharing: the weight referring to a corresponding item is shared by all users, i.e. it is the same parameter. So when many users give a good rating to an item, the corresponding weight becomes stronger for all users. And viceversa. Here is where collaboration takes place.
Now, in order to see what items to recommend to a given user, one clamp the visible units to the observed ratings, and evaluates the probability of obtaining a given rating for each user. You may have a look at these slides, where it is graphically explained in more detail.
As I understand, selecting a vertex would be equivalent to selecting one of the items. The RBM would give you back how likely will the user rate the item as k, where k is each of the possible ratings.
|
Are there any probabilistic models for graph-based recommender systems?
There is the very-well known approach based on restricted BOltzmann machines (RBM), which won the Netflix competition. For more details you may have a look at the Wikipedia site, and the references th
|
47,382
|
Are there any probabilistic models for graph-based recommender systems?
|
There is another good paper on this for unrestricted Boltzmann machines. You might also look at sum/max product networks.
It may be that what you really want to do is compute marginal distributions rather than a real recommendation systems. In that case consider Markov Random Fields or perhaps log-linear models.
|
Are there any probabilistic models for graph-based recommender systems?
|
There is another good paper on this for unrestricted Boltzmann machines. You might also look at sum/max product networks.
It may be that what you really want to do is compute marginal distributions r
|
Are there any probabilistic models for graph-based recommender systems?
There is another good paper on this for unrestricted Boltzmann machines. You might also look at sum/max product networks.
It may be that what you really want to do is compute marginal distributions rather than a real recommendation systems. In that case consider Markov Random Fields or perhaps log-linear models.
|
Are there any probabilistic models for graph-based recommender systems?
There is another good paper on this for unrestricted Boltzmann machines. You might also look at sum/max product networks.
It may be that what you really want to do is compute marginal distributions r
|
47,383
|
Does Principle of Marginality apply to interactions of categorical variables?
|
In the full model there are $n-1$ coefficients for the main effect of $X$, $p-1$ for the main effect of $M$, & $np -n - p +1$ for the interaction; giving a total, as you say of $np-1$. In the model with interaction only, there are just $np -n - p +1$ coefficients; so some combinations of levels of $X$ & $M$ share the same coefficient, which ones depending on the coding scheme. So the principle of marginality applies; indeed it's less usual that violating it is justified by a meaningful interpretation.
[Here are the combinations of dummy variables used in the full model, your first one:
(Intercept) sexM educationPS educationS sexM:educationPS sexM:educationS
1 0 0 0 0 0
1 0 0 1 0 0
1 0 1 0 0 0
1 1 0 0 0 0
1 1 0 1 0 1
1 1 1 0 1 0
A true interactions-only model would use only the first & last two columns as predictors, thus lumping together all females with males having only primary education ('P'). Adapting @Peter's example, you'd be saying that for females, educational level had no effect on income; & that for people with only primary education, sex had no effect. I'm not sure there's a lot more to be said about the marginality principle other than that you'd want such a constraint to be a deliberate modelling decision based on substantive knowledge rather than an accidental consequence of the coding scheme.]
|
Does Principle of Marginality apply to interactions of categorical variables?
|
In the full model there are $n-1$ coefficients for the main effect of $X$, $p-1$ for the main effect of $M$, & $np -n - p +1$ for the interaction; giving a total, as you say of $np-1$. In the model wi
|
Does Principle of Marginality apply to interactions of categorical variables?
In the full model there are $n-1$ coefficients for the main effect of $X$, $p-1$ for the main effect of $M$, & $np -n - p +1$ for the interaction; giving a total, as you say of $np-1$. In the model with interaction only, there are just $np -n - p +1$ coefficients; so some combinations of levels of $X$ & $M$ share the same coefficient, which ones depending on the coding scheme. So the principle of marginality applies; indeed it's less usual that violating it is justified by a meaningful interpretation.
[Here are the combinations of dummy variables used in the full model, your first one:
(Intercept) sexM educationPS educationS sexM:educationPS sexM:educationS
1 0 0 0 0 0
1 0 0 1 0 0
1 0 1 0 0 0
1 1 0 0 0 0
1 1 0 1 0 1
1 1 1 0 1 0
A true interactions-only model would use only the first & last two columns as predictors, thus lumping together all females with males having only primary education ('P'). Adapting @Peter's example, you'd be saying that for females, educational level had no effect on income; & that for people with only primary education, sex had no effect. I'm not sure there's a lot more to be said about the marginality principle other than that you'd want such a constraint to be a deliberate modelling decision based on substantive knowledge rather than an accidental consequence of the coding scheme.]
|
Does Principle of Marginality apply to interactions of categorical variables?
In the full model there are $n-1$ coefficients for the main effect of $X$, $p-1$ for the main effect of $M$, & $np -n - p +1$ for the interaction; giving a total, as you say of $np-1$. In the model wi
|
47,384
|
Does Principle of Marginality apply to interactions of categorical variables?
|
@scortchi gave you a good answer, but I thought a specific example might be useful, if not for you then for others who will see this.
Suppose your dependent variable is log(income) and your two categorical independent variables are sex (male, female, other) and race (White, Black, Asian, Native American, Hawaiian/Pacific Islander). Let's say the reference categories are male and White.
With just the interaction you are assuming that, for White people, sex has no effect and, for males, race has no effect.
There may be situations where this is a sensible model, but I can't think of any, offhand.
|
Does Principle of Marginality apply to interactions of categorical variables?
|
@scortchi gave you a good answer, but I thought a specific example might be useful, if not for you then for others who will see this.
Suppose your dependent variable is log(income) and your two catego
|
Does Principle of Marginality apply to interactions of categorical variables?
@scortchi gave you a good answer, but I thought a specific example might be useful, if not for you then for others who will see this.
Suppose your dependent variable is log(income) and your two categorical independent variables are sex (male, female, other) and race (White, Black, Asian, Native American, Hawaiian/Pacific Islander). Let's say the reference categories are male and White.
With just the interaction you are assuming that, for White people, sex has no effect and, for males, race has no effect.
There may be situations where this is a sensible model, but I can't think of any, offhand.
|
Does Principle of Marginality apply to interactions of categorical variables?
@scortchi gave you a good answer, but I thought a specific example might be useful, if not for you then for others who will see this.
Suppose your dependent variable is log(income) and your two catego
|
47,385
|
Chi-squared test when two vectors have different lengths
|
I think (as mentioned in comments) that a hypothesis test doesn't really answer the question you say you're interested in. (It also lacks power if any of the factors are ordered).
The thing is, 'not so much different' relates to a question about effect size (how different are they?) not a hypothesis test ("is our sample large enough to pick up even unimportant differences?").
You say you have very large sample sizes. This will cause you to reject as different distributions that are quite similar (since you'll have enough power to pick up tiny differences). Is that really what you mean to do? Or would you rather be able to say 'actually, they're fairly similarly distributed' when that's the case?
The direct answer to the question is you use table on the pair of factors you want to test (e.g. Group and race) and then use that as input to chisq.test e.g.
# make up some data
set.seed(32892917)
mydata <- data.frame(group=as.factor(sample(1:5,199,replace=TRUE)),
race=as.factor(sample(1:3,199,replace=TRUE)))
# look at the table:
(mytab <- with(mydata,table(group,race)) )
race
group 1 2 3
1 16 19 11
2 14 15 13
3 9 14 20
4 12 13 11
5 11 11 10
(you'll note that each group is a different size - e.g. group 1 has 46 people, group 5 has 32)
# do the chi-square
chisq.test(mytab)
Pearson's Chi-squared test
data: mytab
X-squared = 6.0928, df = 8, p-value = 0.6368
|
Chi-squared test when two vectors have different lengths
|
I think (as mentioned in comments) that a hypothesis test doesn't really answer the question you say you're interested in. (It also lacks power if any of the factors are ordered).
The thing is, 'not s
|
Chi-squared test when two vectors have different lengths
I think (as mentioned in comments) that a hypothesis test doesn't really answer the question you say you're interested in. (It also lacks power if any of the factors are ordered).
The thing is, 'not so much different' relates to a question about effect size (how different are they?) not a hypothesis test ("is our sample large enough to pick up even unimportant differences?").
You say you have very large sample sizes. This will cause you to reject as different distributions that are quite similar (since you'll have enough power to pick up tiny differences). Is that really what you mean to do? Or would you rather be able to say 'actually, they're fairly similarly distributed' when that's the case?
The direct answer to the question is you use table on the pair of factors you want to test (e.g. Group and race) and then use that as input to chisq.test e.g.
# make up some data
set.seed(32892917)
mydata <- data.frame(group=as.factor(sample(1:5,199,replace=TRUE)),
race=as.factor(sample(1:3,199,replace=TRUE)))
# look at the table:
(mytab <- with(mydata,table(group,race)) )
race
group 1 2 3
1 16 19 11
2 14 15 13
3 9 14 20
4 12 13 11
5 11 11 10
(you'll note that each group is a different size - e.g. group 1 has 46 people, group 5 has 32)
# do the chi-square
chisq.test(mytab)
Pearson's Chi-squared test
data: mytab
X-squared = 6.0928, df = 8, p-value = 0.6368
|
Chi-squared test when two vectors have different lengths
I think (as mentioned in comments) that a hypothesis test doesn't really answer the question you say you're interested in. (It also lacks power if any of the factors are ordered).
The thing is, 'not s
|
47,386
|
Why the sample mean is not a good (sufficient) statistic?
|
Sufficiency pertains to data reduction, not estimation per se. This is an important distinction to understand. Yes, a "good" estimator is usually a function of a sufficient statistic, but that doesn't mean that all sufficient statistics are estimators.
As for your specific example, a simple way to understand why $\bar X$ is not a sufficient statistic for $\theta$ is to consider the following experiment: suppose I tell you $\bar X = 10$. Is this equivalent to all the information pertaining to $\theta$ that we can get from the sample? Of course not: for instance, $X_1 = 9.5, X_2 = 10.4, X_3 = 10.1$ could give us $10$, but so could $X_1 = X_2 = 9.75, X_3 = 10.5$. If you only have knowledge of $\bar X$, you have lost information about $\theta$ that was available in the original sample: namely, that in the first case, we must have $\theta \in [9.4,9.5]$, and in the second, $\theta \in [9.5,9.75]$. Notice those intervals are nearly disjoint. This is why $\bar X$ is insufficient for $\theta$. You may be able to use it to estimate $\theta$ when $n$ is large, but as I have pointed out, sufficiency has to do with data reduction, not estimation.
|
Why the sample mean is not a good (sufficient) statistic?
|
Sufficiency pertains to data reduction, not estimation per se. This is an important distinction to understand. Yes, a "good" estimator is usually a function of a sufficient statistic, but that doesn
|
Why the sample mean is not a good (sufficient) statistic?
Sufficiency pertains to data reduction, not estimation per se. This is an important distinction to understand. Yes, a "good" estimator is usually a function of a sufficient statistic, but that doesn't mean that all sufficient statistics are estimators.
As for your specific example, a simple way to understand why $\bar X$ is not a sufficient statistic for $\theta$ is to consider the following experiment: suppose I tell you $\bar X = 10$. Is this equivalent to all the information pertaining to $\theta$ that we can get from the sample? Of course not: for instance, $X_1 = 9.5, X_2 = 10.4, X_3 = 10.1$ could give us $10$, but so could $X_1 = X_2 = 9.75, X_3 = 10.5$. If you only have knowledge of $\bar X$, you have lost information about $\theta$ that was available in the original sample: namely, that in the first case, we must have $\theta \in [9.4,9.5]$, and in the second, $\theta \in [9.5,9.75]$. Notice those intervals are nearly disjoint. This is why $\bar X$ is insufficient for $\theta$. You may be able to use it to estimate $\theta$ when $n$ is large, but as I have pointed out, sufficiency has to do with data reduction, not estimation.
|
Why the sample mean is not a good (sufficient) statistic?
Sufficiency pertains to data reduction, not estimation per se. This is an important distinction to understand. Yes, a "good" estimator is usually a function of a sufficient statistic, but that doesn
|
47,387
|
How to deal with graphing overlapping error bars without color?
|
You've received some good comments so far. Offsetting as Glen_b mentions is what is used in clustered bar charts, and in the grammer of graphics is referred to as dodging. Below is an example of similar data (using SPSS). Also note that I took away the handle bars at the ends, they are typically distracting and wasted ink even when they don't cause overplotting (see similar advice from Andrew Gelman & Thom Baguley).
Your data has better groupings between the type and ordinate pairs, but you can see here a problem in my example. Our vision fails us and it is hard to associate the type with the correct location on the ordinate. Some software allows you to manipulate the degree of grouping better than SPSS does (particularly the ggplot2 R package), but this will generally be a problem with the clustered error bar charts when the groups are disparate. (With this data I would use color for the ordinate value if I wanted to use this chart - given your example though I'm intentionally giving further examples in black-white).
For this reason, I agree l0b0's comment is a good one as well, and you can typically make a more informative plot by using small multiples and constructing the panels to highlight the most informative comparisons you want to make.
Here you can make comparisons (listed in order of the easiest types of comparisons to make).
Within a panel
Across panel columns
Down panel rows
You have enough flexibility to rearrange components of the panels to display the comparisons you are interested in (and if your ordinate values are actually other categories you can use them as panels as well and use one of the other categories as the ordinate value).
|
How to deal with graphing overlapping error bars without color?
|
You've received some good comments so far. Offsetting as Glen_b mentions is what is used in clustered bar charts, and in the grammer of graphics is referred to as dodging. Below is an example of simil
|
How to deal with graphing overlapping error bars without color?
You've received some good comments so far. Offsetting as Glen_b mentions is what is used in clustered bar charts, and in the grammer of graphics is referred to as dodging. Below is an example of similar data (using SPSS). Also note that I took away the handle bars at the ends, they are typically distracting and wasted ink even when they don't cause overplotting (see similar advice from Andrew Gelman & Thom Baguley).
Your data has better groupings between the type and ordinate pairs, but you can see here a problem in my example. Our vision fails us and it is hard to associate the type with the correct location on the ordinate. Some software allows you to manipulate the degree of grouping better than SPSS does (particularly the ggplot2 R package), but this will generally be a problem with the clustered error bar charts when the groups are disparate. (With this data I would use color for the ordinate value if I wanted to use this chart - given your example though I'm intentionally giving further examples in black-white).
For this reason, I agree l0b0's comment is a good one as well, and you can typically make a more informative plot by using small multiples and constructing the panels to highlight the most informative comparisons you want to make.
Here you can make comparisons (listed in order of the easiest types of comparisons to make).
Within a panel
Across panel columns
Down panel rows
You have enough flexibility to rearrange components of the panels to display the comparisons you are interested in (and if your ordinate values are actually other categories you can use them as panels as well and use one of the other categories as the ordinate value).
|
How to deal with graphing overlapping error bars without color?
You've received some good comments so far. Offsetting as Glen_b mentions is what is used in clustered bar charts, and in the grammer of graphics is referred to as dodging. Below is an example of simil
|
47,388
|
Definition of likelihood ratio test
|
You're right in the context of "submodel" testing, the likelihood ratio statistic is the ratio of the maximum likelihoods (not the maximum likelihood estimates: the maximal values of the likelihoods).
Consider a statistical model with likelihood $l(\theta \mid y)$ where $y$ is the vector of observations generated from a distribution with parameter $\theta$ belonging to some space $\Theta$. Let $\Theta_0 \subset \Theta$ and imagine you are interested in testing $H_0\colon\{\theta \in \Theta_0\}$.
The likelihood ratio statistic is
$$lr(y) = \frac{\sup_{\theta \in \Theta}l(\theta \mid y)}{\sup_{\theta \in \Theta_0}l(\theta \mid y)}. $$
But when the test hypotheses are $H_0 \colon\{\theta =\theta_0\}$ vs $H_1 \colon\{\theta =\theta_1\}$, as in the classical Neymann-Pearson lemma, then the likelihood ratio statistic is the ratio of the likelihoods:
$$lr(y) = \frac{l(\theta_1 \mid y)}{l(\theta_0 \mid y)}.$$
|
Definition of likelihood ratio test
|
You're right in the context of "submodel" testing, the likelihood ratio statistic is the ratio of the maximum likelihoods (not the maximum likelihood estimates: the maximal values of the likelihoods).
|
Definition of likelihood ratio test
You're right in the context of "submodel" testing, the likelihood ratio statistic is the ratio of the maximum likelihoods (not the maximum likelihood estimates: the maximal values of the likelihoods).
Consider a statistical model with likelihood $l(\theta \mid y)$ where $y$ is the vector of observations generated from a distribution with parameter $\theta$ belonging to some space $\Theta$. Let $\Theta_0 \subset \Theta$ and imagine you are interested in testing $H_0\colon\{\theta \in \Theta_0\}$.
The likelihood ratio statistic is
$$lr(y) = \frac{\sup_{\theta \in \Theta}l(\theta \mid y)}{\sup_{\theta \in \Theta_0}l(\theta \mid y)}. $$
But when the test hypotheses are $H_0 \colon\{\theta =\theta_0\}$ vs $H_1 \colon\{\theta =\theta_1\}$, as in the classical Neymann-Pearson lemma, then the likelihood ratio statistic is the ratio of the likelihoods:
$$lr(y) = \frac{l(\theta_1 \mid y)}{l(\theta_0 \mid y)}.$$
|
Definition of likelihood ratio test
You're right in the context of "submodel" testing, the likelihood ratio statistic is the ratio of the maximum likelihoods (not the maximum likelihood estimates: the maximal values of the likelihoods).
|
47,389
|
Definition of likelihood ratio test
|
The distinction between the likelihood ratio for completely specified probability mass or density functions (simple hypotheses) & the likelihood ratio for incompletely specified ones (composite hypotheses) is sometimes expressed by calling the latter a generalized likelihood ratio. So your quote could be giving a precise definition of the likelihood ratio proper, or an vague definition (because it doesn't specify how particular parameter values are picked to calculate the likelihood for each model) of the generalized likelihood ratio.
|
Definition of likelihood ratio test
|
The distinction between the likelihood ratio for completely specified probability mass or density functions (simple hypotheses) & the likelihood ratio for incompletely specified ones (composite hypoth
|
Definition of likelihood ratio test
The distinction between the likelihood ratio for completely specified probability mass or density functions (simple hypotheses) & the likelihood ratio for incompletely specified ones (composite hypotheses) is sometimes expressed by calling the latter a generalized likelihood ratio. So your quote could be giving a precise definition of the likelihood ratio proper, or an vague definition (because it doesn't specify how particular parameter values are picked to calculate the likelihood for each model) of the generalized likelihood ratio.
|
Definition of likelihood ratio test
The distinction between the likelihood ratio for completely specified probability mass or density functions (simple hypotheses) & the likelihood ratio for incompletely specified ones (composite hypoth
|
47,390
|
Is there a branch of statistics that tries to explain "why" the dataset has certain statistical properties?
|
I am not sure if there is a pithy title for this entire topic but it is certainly an important issue. Maybe "robust statistics" would be a good place to start?
The aptly-named empirical influence function describes how an estimator (e.g., the mean or median) depends on the value of one of the points in its sample. It can also be generalized into the "influence" or sensitivity function, which asks how the estimator's value changes as the distribution of the data shifts.
You could also consider an estimator's breakdown point, which is essentially the proportion of "bogus" values (e.g., arbitrarily large) that an estimator can tolerate. The mean, for example, has a breakdown point of zero because you can completely change its value by subsituting an arbitrarily large positive or negative value for a single point in the data set. On the other hand, the median is very resistent to this sort of 'attack;.
In regression contexts, DDFITS is a diagnostic which asks "how does the prediction for this point change if that is included/excluded in the analysis?" Cook's Distance (or Cook's D) is a similar quantity (they're calculated differently, but are inter-convertible). Leverage is a related quantity but is only affected by the independent variables' values, rather than both the independent and dependent ones.
|
Is there a branch of statistics that tries to explain "why" the dataset has certain statistical prop
|
I am not sure if there is a pithy title for this entire topic but it is certainly an important issue. Maybe "robust statistics" would be a good place to start?
The aptly-named empirical influence func
|
Is there a branch of statistics that tries to explain "why" the dataset has certain statistical properties?
I am not sure if there is a pithy title for this entire topic but it is certainly an important issue. Maybe "robust statistics" would be a good place to start?
The aptly-named empirical influence function describes how an estimator (e.g., the mean or median) depends on the value of one of the points in its sample. It can also be generalized into the "influence" or sensitivity function, which asks how the estimator's value changes as the distribution of the data shifts.
You could also consider an estimator's breakdown point, which is essentially the proportion of "bogus" values (e.g., arbitrarily large) that an estimator can tolerate. The mean, for example, has a breakdown point of zero because you can completely change its value by subsituting an arbitrarily large positive or negative value for a single point in the data set. On the other hand, the median is very resistent to this sort of 'attack;.
In regression contexts, DDFITS is a diagnostic which asks "how does the prediction for this point change if that is included/excluded in the analysis?" Cook's Distance (or Cook's D) is a similar quantity (they're calculated differently, but are inter-convertible). Leverage is a related quantity but is only affected by the independent variables' values, rather than both the independent and dependent ones.
|
Is there a branch of statistics that tries to explain "why" the dataset has certain statistical prop
I am not sure if there is a pithy title for this entire topic but it is certainly an important issue. Maybe "robust statistics" would be a good place to start?
The aptly-named empirical influence func
|
47,391
|
Reformulation of OLS estimators in a simple Regression with a dummy variable
|
The theoretical model is
$$E(Y\mid X)=\alpha +\beta X$$
Assuming that $X$ is a $0/1$ binary variable we notice that
$$E(Y\mid X=1) - E(Y\mid X=0)=\alpha +\beta -\alpha = \beta $$
I think that the OP asks "does the OLS estimator "mimics" this relationship, being perhaps its sample analogue?"
Let's see: we have that
$$\hat{\beta}=\frac{\frac{1}{n}\sum (x_i-\bar x)(y_i-\bar y)}{\frac{1}{n}\sum (x_i-\bar x)^2} = \frac {\operatorname{\hat Cov(Y,X)}}{\operatorname{\hat Var(X)}} $$
Now since $X$ is a binary variable, i.e. a Bernoulli random variable, we have that ${\operatorname{Var(X)} = p(1-p)}$ where $p\equiv P(X=1)$. Under a stationarity assumption, the sample estimate of this probability is simply the sample mean of $X$, denoted $\bar x$ and one can verify that indeed
$$\frac{1}{n}\sum (x_i-\bar x)^2 = {\operatorname{\hat Var(X)}}=\bar x (1-\bar x) =\hat p(1-\hat p)$$
Let's turn now to the covariance. We have
$$\operatorname{\hat Cov(Y,X)}=\frac{1}{n}\sum (x_i-\bar x)(y_i-\bar y) = \frac{1}{n}\sum x_iy_i -\bar x \bar y$$
Denote $n_1$ the number of those observations for which $x_i=1$. We can write
$$\frac{1}{n}\sum x_iy_i = \frac{1}{n}\sum_{x_i=1} y_i = \frac{n_1}{n}\cdot \frac{1}{n_1}\sum_{x_i=1} y_i = \hat p\cdot (\bar y \mid X=1) = \hat p \cdot \hat E(Y\mid X=1)$$
Also $\bar y = \hat E(Y)$ and using the law of total expectations we have
$$\hat E(Y) = \hat E(Y \mid X=1) \cdot \hat p + \hat E(Y \mid X=0)\cdot (1-\hat p)$$
Inserting all these results in the expression for the sample covariance we have
$$\operatorname{\hat Cov(Y,X)}= \hat p \cdot \hat E(Y\mid X=1) - \hat p\cdot \left[\hat E(Y \mid X=1) \cdot \hat p + \hat E(Y \mid X=0)\cdot (1-\hat p)\right]$$
$$= \hat p(1-\hat p)\cdot \left[\hat E(Y \mid X=1) - \hat E(Y \mid X=0)\right]$$
Inserting all in the expression for $\hat \beta$ we have
$$=\hat{\beta} = \frac {\operatorname{\hat Cov(Y,X)}}{\operatorname{\hat Var(X)}} = \frac {\hat p(1-\hat p)\cdot \left[\hat E(Y \mid X=1) - \hat E(Y \mid X=0)\right]}{\hat p(1-\hat p)} $$
$$\Rightarrow \hat{\beta} = \hat E(Y \mid X=1) - \hat E(Y \mid X=0)$$
which is the sample analogue/feasible implementation of the theoretical relationship. I leave the demonstration related to the $\hat \alpha$ for the OP to work out.
|
Reformulation of OLS estimators in a simple Regression with a dummy variable
|
The theoretical model is
$$E(Y\mid X)=\alpha +\beta X$$
Assuming that $X$ is a $0/1$ binary variable we notice that
$$E(Y\mid X=1) - E(Y\mid X=0)=\alpha +\beta -\alpha = \beta $$
I think that the OP
|
Reformulation of OLS estimators in a simple Regression with a dummy variable
The theoretical model is
$$E(Y\mid X)=\alpha +\beta X$$
Assuming that $X$ is a $0/1$ binary variable we notice that
$$E(Y\mid X=1) - E(Y\mid X=0)=\alpha +\beta -\alpha = \beta $$
I think that the OP asks "does the OLS estimator "mimics" this relationship, being perhaps its sample analogue?"
Let's see: we have that
$$\hat{\beta}=\frac{\frac{1}{n}\sum (x_i-\bar x)(y_i-\bar y)}{\frac{1}{n}\sum (x_i-\bar x)^2} = \frac {\operatorname{\hat Cov(Y,X)}}{\operatorname{\hat Var(X)}} $$
Now since $X$ is a binary variable, i.e. a Bernoulli random variable, we have that ${\operatorname{Var(X)} = p(1-p)}$ where $p\equiv P(X=1)$. Under a stationarity assumption, the sample estimate of this probability is simply the sample mean of $X$, denoted $\bar x$ and one can verify that indeed
$$\frac{1}{n}\sum (x_i-\bar x)^2 = {\operatorname{\hat Var(X)}}=\bar x (1-\bar x) =\hat p(1-\hat p)$$
Let's turn now to the covariance. We have
$$\operatorname{\hat Cov(Y,X)}=\frac{1}{n}\sum (x_i-\bar x)(y_i-\bar y) = \frac{1}{n}\sum x_iy_i -\bar x \bar y$$
Denote $n_1$ the number of those observations for which $x_i=1$. We can write
$$\frac{1}{n}\sum x_iy_i = \frac{1}{n}\sum_{x_i=1} y_i = \frac{n_1}{n}\cdot \frac{1}{n_1}\sum_{x_i=1} y_i = \hat p\cdot (\bar y \mid X=1) = \hat p \cdot \hat E(Y\mid X=1)$$
Also $\bar y = \hat E(Y)$ and using the law of total expectations we have
$$\hat E(Y) = \hat E(Y \mid X=1) \cdot \hat p + \hat E(Y \mid X=0)\cdot (1-\hat p)$$
Inserting all these results in the expression for the sample covariance we have
$$\operatorname{\hat Cov(Y,X)}= \hat p \cdot \hat E(Y\mid X=1) - \hat p\cdot \left[\hat E(Y \mid X=1) \cdot \hat p + \hat E(Y \mid X=0)\cdot (1-\hat p)\right]$$
$$= \hat p(1-\hat p)\cdot \left[\hat E(Y \mid X=1) - \hat E(Y \mid X=0)\right]$$
Inserting all in the expression for $\hat \beta$ we have
$$=\hat{\beta} = \frac {\operatorname{\hat Cov(Y,X)}}{\operatorname{\hat Var(X)}} = \frac {\hat p(1-\hat p)\cdot \left[\hat E(Y \mid X=1) - \hat E(Y \mid X=0)\right]}{\hat p(1-\hat p)} $$
$$\Rightarrow \hat{\beta} = \hat E(Y \mid X=1) - \hat E(Y \mid X=0)$$
which is the sample analogue/feasible implementation of the theoretical relationship. I leave the demonstration related to the $\hat \alpha$ for the OP to work out.
|
Reformulation of OLS estimators in a simple Regression with a dummy variable
The theoretical model is
$$E(Y\mid X)=\alpha +\beta X$$
Assuming that $X$ is a $0/1$ binary variable we notice that
$$E(Y\mid X=1) - E(Y\mid X=0)=\alpha +\beta -\alpha = \beta $$
I think that the OP
|
47,392
|
What is an F test?
|
What is an F test is and what does it show?
The term "F test" may mean any test whose sampling distribution under the null hypothesis has an F-distribution. There are several quite distinct tests.
Here are a couple of the more common ones:
(i) an F-test for equality of means of multiple groups (also called ANOVA, short for ANalysis Of VAriance, since inequality of means will tend to lead to two different estimates of variance being different). If you reject the null, you have concluded that the sample means are too far apart to explain by random variation with equal population means; the alternative explanation is that the population means are not equal. For this test, large F values would cause you to reject the null hypothesis.
There are related tests, such as the overall F-test and partial-F tests for regression. The F-test in ANOVA can be seen as a special case of the regression one.
This test assumes normality but isn't especially sensitive to mild deviations from it.
(ii) a test for equality of variances. If you reject the null, you have concluded that the sample variances are too different to explain by random variation with equal variances; the alternative explanation is that the population variances are not equal.
This test** assumes normality and is quite sensitive to that assumption. I advise against using it, except under very limited circumstances. You are not likely to be in those circumstances.
** (Actually, there are a couple of these tests but I'm mostly referring to variance ratio test for equality of variances; Levene's test or the Brown-Forsythe test are used more nowadays and the strict assumption of normality is less of an issue)
There's additional discussion of both these tests (including some hopefully helpful diagrams) in this answer.
Also what is an alpha?
It is the chosen type I error rate$^\ddagger$. Before you test (indeed before you look at the data, and preferably before you even collect any data) you choose the chance you would reject null hypotheses that were true. It's also called the significance level.
It will probably help to read more about how hypothesis tests work in general.
For example, see Wikipedia on the role of significance in hypothesis testing
and type I and type II errors.
$^\ddagger$ more generally, it's the chosen upper bound on the type I error rate, since under composite null hypotheses you won't just have one.
... and how do I evaluate the p value?
It depends on whether you mean 'how do I calculate them?' or 'how do I interpret them?'
If you mean the first:
Calculation involves seeing "how extreme"$^\dagger$ the test statistic is.
$^\dagger$(deviant from the values of the test statistic you'd expect to see if the null hypothesis were true toward what you'd expect to see if it were false)
Calculation is done by computing the probability that a "random" test statistic from the null distribution would be at least as unusual as the calculated sample test statistic.
[The null distribution is the distribution the test statistic takes when the null hypothesis is true (an F-distribution for an F test), and more unusual here means further toward what you'd expect to see if the alternative hypothesis were true.]
So for an ANOVA, when the alternative is true (population means differ) the F-statistic tends to be larger, and you compute the probability that you'd see a value at least as large as the observed (sample) F if the null were true. That is, find the probability of being in the upper tail, at least as large as the observed value.
In practice one either looks up a table, or much more commonly nowadays, uses a computer program to find that tail probability.
If that's very small, then either the null hypothesis is true but a very low probability even occurred, or the null isn't true (and there's no need to think anything especially unlikely occurred). For sufficiently low p-values, the first position becomes untenable; you reject the null hypothesis. What makes it sufficiently low? Being smaller than the significance level, $\alpha$.
If you mean the second, it might help to read more about what a p-value is. We have many good posts on interpretation of p-values. Here are a few you might find helpful in some way:
How to interpret F- and p-value in ANOVA?
Is the exact value of a 'p-value' meaningless?
What is the meaning of a large p-value?
Misunderstanding a P-value?
What is the relationship between a p-value and a confidence interval?
The extent to which one can interpret a p-value (beyond it being above or below $\alpha$) is a matter of a bit of controversy. People who are more strictly in the Neyman-Pearson vein tend to say you shouldn't and people who take a more Fisherian approach (which distinction I haven't really covered) tend to be quite happy to do so. What we actually see in practice is usually a bit of a mixture of the two, a not entirely comfortable arrangement.
|
What is an F test?
|
What is an F test is and what does it show?
The term "F test" may mean any test whose sampling distribution under the null hypothesis has an F-distribution. There are several quite distinct tests.
H
|
What is an F test?
What is an F test is and what does it show?
The term "F test" may mean any test whose sampling distribution under the null hypothesis has an F-distribution. There are several quite distinct tests.
Here are a couple of the more common ones:
(i) an F-test for equality of means of multiple groups (also called ANOVA, short for ANalysis Of VAriance, since inequality of means will tend to lead to two different estimates of variance being different). If you reject the null, you have concluded that the sample means are too far apart to explain by random variation with equal population means; the alternative explanation is that the population means are not equal. For this test, large F values would cause you to reject the null hypothesis.
There are related tests, such as the overall F-test and partial-F tests for regression. The F-test in ANOVA can be seen as a special case of the regression one.
This test assumes normality but isn't especially sensitive to mild deviations from it.
(ii) a test for equality of variances. If you reject the null, you have concluded that the sample variances are too different to explain by random variation with equal variances; the alternative explanation is that the population variances are not equal.
This test** assumes normality and is quite sensitive to that assumption. I advise against using it, except under very limited circumstances. You are not likely to be in those circumstances.
** (Actually, there are a couple of these tests but I'm mostly referring to variance ratio test for equality of variances; Levene's test or the Brown-Forsythe test are used more nowadays and the strict assumption of normality is less of an issue)
There's additional discussion of both these tests (including some hopefully helpful diagrams) in this answer.
Also what is an alpha?
It is the chosen type I error rate$^\ddagger$. Before you test (indeed before you look at the data, and preferably before you even collect any data) you choose the chance you would reject null hypotheses that were true. It's also called the significance level.
It will probably help to read more about how hypothesis tests work in general.
For example, see Wikipedia on the role of significance in hypothesis testing
and type I and type II errors.
$^\ddagger$ more generally, it's the chosen upper bound on the type I error rate, since under composite null hypotheses you won't just have one.
... and how do I evaluate the p value?
It depends on whether you mean 'how do I calculate them?' or 'how do I interpret them?'
If you mean the first:
Calculation involves seeing "how extreme"$^\dagger$ the test statistic is.
$^\dagger$(deviant from the values of the test statistic you'd expect to see if the null hypothesis were true toward what you'd expect to see if it were false)
Calculation is done by computing the probability that a "random" test statistic from the null distribution would be at least as unusual as the calculated sample test statistic.
[The null distribution is the distribution the test statistic takes when the null hypothesis is true (an F-distribution for an F test), and more unusual here means further toward what you'd expect to see if the alternative hypothesis were true.]
So for an ANOVA, when the alternative is true (population means differ) the F-statistic tends to be larger, and you compute the probability that you'd see a value at least as large as the observed (sample) F if the null were true. That is, find the probability of being in the upper tail, at least as large as the observed value.
In practice one either looks up a table, or much more commonly nowadays, uses a computer program to find that tail probability.
If that's very small, then either the null hypothesis is true but a very low probability even occurred, or the null isn't true (and there's no need to think anything especially unlikely occurred). For sufficiently low p-values, the first position becomes untenable; you reject the null hypothesis. What makes it sufficiently low? Being smaller than the significance level, $\alpha$.
If you mean the second, it might help to read more about what a p-value is. We have many good posts on interpretation of p-values. Here are a few you might find helpful in some way:
How to interpret F- and p-value in ANOVA?
Is the exact value of a 'p-value' meaningless?
What is the meaning of a large p-value?
Misunderstanding a P-value?
What is the relationship between a p-value and a confidence interval?
The extent to which one can interpret a p-value (beyond it being above or below $\alpha$) is a matter of a bit of controversy. People who are more strictly in the Neyman-Pearson vein tend to say you shouldn't and people who take a more Fisherian approach (which distinction I haven't really covered) tend to be quite happy to do so. What we actually see in practice is usually a bit of a mixture of the two, a not entirely comfortable arrangement.
|
What is an F test?
What is an F test is and what does it show?
The term "F test" may mean any test whose sampling distribution under the null hypothesis has an F-distribution. There are several quite distinct tests.
H
|
47,393
|
Inverse function for a non-decreasing CDF
|
Let $U$ be a $\mathrm{U}[0,1]$ r.v. Let $F$ be a distribution function. Remember that every distribution function is non decreasing and right continuous . Define the quantile function
$$
F^{-1}(u) = \inf\,\{x:u \leq F(x)\}.
$$
Drawing a picture
we see that $F^{-1}(u)\leq x$ if and only if $u\leq F(x)$. Please, make sure that you understand both implications. Therefore, if $X=F^{-1}(U)$, then
$$
P(X\leq x)=P(F^{-1}(U)\leq x)=P(U\leq F(x))=F(x) \, .
$$
|
Inverse function for a non-decreasing CDF
|
Let $U$ be a $\mathrm{U}[0,1]$ r.v. Let $F$ be a distribution function. Remember that every distribution function is non decreasing and right continuous . Define the quantile function
$$
F^{-1}(u) =
|
Inverse function for a non-decreasing CDF
Let $U$ be a $\mathrm{U}[0,1]$ r.v. Let $F$ be a distribution function. Remember that every distribution function is non decreasing and right continuous . Define the quantile function
$$
F^{-1}(u) = \inf\,\{x:u \leq F(x)\}.
$$
Drawing a picture
we see that $F^{-1}(u)\leq x$ if and only if $u\leq F(x)$. Please, make sure that you understand both implications. Therefore, if $X=F^{-1}(U)$, then
$$
P(X\leq x)=P(F^{-1}(U)\leq x)=P(U\leq F(x))=F(x) \, .
$$
|
Inverse function for a non-decreasing CDF
Let $U$ be a $\mathrm{U}[0,1]$ r.v. Let $F$ be a distribution function. Remember that every distribution function is non decreasing and right continuous . Define the quantile function
$$
F^{-1}(u) =
|
47,394
|
Generalized linear models with continuous proportions
|
Generalized linear models for responses that are continuous proportions are well known in at least some literatures and well supported in at least some software. I will leave to others with R expertise to comment on how far and/or how well they are supported by R.
A friendly miniature review is offered by Baum in http://www.stata-journal.com/sjpdf.html?articlenum=st0147: although of use beyond the Stata community, this paper does underline that such models are well supported by Stata.
The literature can be extended back at least as far as Wedderburn in 1974
http://biomet.oxfordjournals.org/content/61/3/439.full.pdf+html
and sideways to include an account in Wooldridge's more advanced book
http://www.amazon.com/Econometric-Analysis-Cross-Section-Panel/dp/0262232588/
Whether this what R calls "quasibinomial" again I leave to others who know R well.
An alternative is to use beta regression.
I agree with the implication that arcsine transformation at best offers a partial solution here; it is preferable to have an integrated approach in which modelling is centred on respecting the range of the response variable.
|
Generalized linear models with continuous proportions
|
Generalized linear models for responses that are continuous proportions are well known in at least some literatures and well supported in at least some software. I will leave to others with R expertis
|
Generalized linear models with continuous proportions
Generalized linear models for responses that are continuous proportions are well known in at least some literatures and well supported in at least some software. I will leave to others with R expertise to comment on how far and/or how well they are supported by R.
A friendly miniature review is offered by Baum in http://www.stata-journal.com/sjpdf.html?articlenum=st0147: although of use beyond the Stata community, this paper does underline that such models are well supported by Stata.
The literature can be extended back at least as far as Wedderburn in 1974
http://biomet.oxfordjournals.org/content/61/3/439.full.pdf+html
and sideways to include an account in Wooldridge's more advanced book
http://www.amazon.com/Econometric-Analysis-Cross-Section-Panel/dp/0262232588/
Whether this what R calls "quasibinomial" again I leave to others who know R well.
An alternative is to use beta regression.
I agree with the implication that arcsine transformation at best offers a partial solution here; it is preferable to have an integrated approach in which modelling is centred on respecting the range of the response variable.
|
Generalized linear models with continuous proportions
Generalized linear models for responses that are continuous proportions are well known in at least some literatures and well supported in at least some software. I will leave to others with R expertis
|
47,395
|
Difference of 'centers' of 2 non-normal samples with Mann-Whitney test
|
Yes, if your alternative is a shift alternative, the corresponding estimate is the Hodges-Lehmann.
The estimate is easy enough.
The Hodges Lehmann estimate is the sample median of the cross-sample pairwise differences.
For really large samples, there are efficient methods (for example, ones that sort the two samples and then use the information in that to speed up the search for the median).
I'm going to assume your sample is not so large that its worth the effort of doing that, in which case, you simply want to find all pairwise differences and find the median of the result.
For example, if your x-sample is:
16.388 6.775 18.270 17.034 18.825 16.197 16.709 18.188 9.999
and your y-sample is:
9.305 9.799 11.103
then the matrix of differences, x-y is
7.083 6.589 5.285
-2.530 -3.024 -4.328
8.965 8.471 7.167
7.729 7.235 5.931
9.520 9.026 7.722
6.892 6.398 5.094
7.404 6.910 5.606
8.883 8.389 7.085
0.694 0.200 -1.104
(here columns correspond to particular y's and rows to particular y's). You then
take the median of the whole set of differences.
(In R this is just a matter of:
> median(outer(x,y,"-"))
[1] 6.91
It's doubtless just about as easy in Matlab; would something like [X,Y] = meshgrid(x,y); Z = X - Y; work to generate the matrix of differences?)
If you have samples so large that this isn't feasible, you should indicate this.
I don't know why it didn't click before, but the basic concept
of finding an interval for something like the Hodges-Lehmann shift
parameter in the Wilcoxon-Mann-Whitney (WMW) test is pretty obvious;
the same idea is widely used for other permutation tests.
The underlying idea is this: you shift the second sample left and right
until you hit the $\alpha/2$ and $1-\alpha/2$ quantiles of the WMW statistic
(being discrete, these will cut off less than $\alpha/2$ in the tails, but
you can legitimately have one a bit larger than $\alpha/2$ if the sum of
tail areas is less than $\alpha$; however, most people will prefer symmetry
even at the cost of a more-conservative-than-necessary interval).
This approach can be easily implemented in software via use of a canned
root-finding algorithm that doesn't require derivatives. Bounds are obvious
enough (if you haven't hit it by the time you get complete separation
of samples, you never will, so check those 'maximum shift' values first
and then use them as bounds; similarly, the HL estimate itself is the bound
for the other end of each search).
There are other approaches to doing this that will probably be more efficient,
but this should work well enough with a good root-finder (perhaps involving
only a dozen or so evaluations of statistics at different shift values).
In response to the comments about the issue being a change of scale, not location:
One possibility - you could consider looking at estimating the location shift in the logs, which should correspond to the log of the scale change (ratio of scales) in the untransformed values. That is if $X∼F(x)$ and $Y∼F(y/a)$ then if $X^∗=\ln X∼G(x), Y^∗=\ln Y∼G(y−\ln a)$, where $G(x)= F(\exp(x))$.
Intervals, at least should carry over nicely.
Here's an example of that in use:
The data are as follows. The x sample is 60 observations from a distribution with scale parameter $\mu=18$, while the y sample is 50 observations with scale parameter $\mu=25$. They have the same distribution, aside from a shift in scale.
The increase in scale is a factor of $25/18 \approx 1.3889$.
Here's a boxplot of the data on the original scale and on the log-scale:
Here we do a Wilcoxon-Mann-Whitney on the log-data:
> lx=log(x)
> ly=log(y)
> wilcox.test(ly,lx,conf.int=TRUE)
Wilcoxon rank sum test with continuity correction
data: ly and lx
W = 1743, p-value = 0.1455
alternative hypothesis: true location shift is not equal to 0
95 percent confidence interval:
-0.09044406 0.68813695
sample estimates:
difference in location
0.2917924
If we exponentiate the interval, it should contain the true ratio of scales 95% of the time. It does contain the population ratio on this occasion:
> exp(wilcox.test(ly,lx,conf.int=TRUE)$conf.int)
[1] 0.9135254 1.9900046
attr(,"conf.level")
[1] 0.95
If we exponentiate the estimated shift in the logs, it will be a (somewhat) downward-biased estimate of the scale-ratio, but it's fairly good:
> exp(wilcox.test(ly,lx,conf.int=TRUE)$estimate)
difference in location
1.338825
[The data used in the example were generated as follows:
> set.seed(94394381)
> x=rexp(60,1/18)
> y=rexp(50,1/25)
... just in case anyone wants to try it]
There are other ways to estimate the scale change; one could, for example, divide the y-sample by a constant, $c$, and try different values of $c$ until the WMW statistic was equal to its expected value under the null hypothesis. One could also try different values until the statistic was equal to the $\alpha/2$ and $1-\alpha/2$ quantiles of the null distribution of the WMW. As above, this will be the point estimate of and interval for the ratio of scales.
(That would have the advantage of not introducing a small bias into the central estimate.)
|
Difference of 'centers' of 2 non-normal samples with Mann-Whitney test
|
Yes, if your alternative is a shift alternative, the corresponding estimate is the Hodges-Lehmann.
The estimate is easy enough.
The Hodges Lehmann estimate is the sample median of the cross-sample pai
|
Difference of 'centers' of 2 non-normal samples with Mann-Whitney test
Yes, if your alternative is a shift alternative, the corresponding estimate is the Hodges-Lehmann.
The estimate is easy enough.
The Hodges Lehmann estimate is the sample median of the cross-sample pairwise differences.
For really large samples, there are efficient methods (for example, ones that sort the two samples and then use the information in that to speed up the search for the median).
I'm going to assume your sample is not so large that its worth the effort of doing that, in which case, you simply want to find all pairwise differences and find the median of the result.
For example, if your x-sample is:
16.388 6.775 18.270 17.034 18.825 16.197 16.709 18.188 9.999
and your y-sample is:
9.305 9.799 11.103
then the matrix of differences, x-y is
7.083 6.589 5.285
-2.530 -3.024 -4.328
8.965 8.471 7.167
7.729 7.235 5.931
9.520 9.026 7.722
6.892 6.398 5.094
7.404 6.910 5.606
8.883 8.389 7.085
0.694 0.200 -1.104
(here columns correspond to particular y's and rows to particular y's). You then
take the median of the whole set of differences.
(In R this is just a matter of:
> median(outer(x,y,"-"))
[1] 6.91
It's doubtless just about as easy in Matlab; would something like [X,Y] = meshgrid(x,y); Z = X - Y; work to generate the matrix of differences?)
If you have samples so large that this isn't feasible, you should indicate this.
I don't know why it didn't click before, but the basic concept
of finding an interval for something like the Hodges-Lehmann shift
parameter in the Wilcoxon-Mann-Whitney (WMW) test is pretty obvious;
the same idea is widely used for other permutation tests.
The underlying idea is this: you shift the second sample left and right
until you hit the $\alpha/2$ and $1-\alpha/2$ quantiles of the WMW statistic
(being discrete, these will cut off less than $\alpha/2$ in the tails, but
you can legitimately have one a bit larger than $\alpha/2$ if the sum of
tail areas is less than $\alpha$; however, most people will prefer symmetry
even at the cost of a more-conservative-than-necessary interval).
This approach can be easily implemented in software via use of a canned
root-finding algorithm that doesn't require derivatives. Bounds are obvious
enough (if you haven't hit it by the time you get complete separation
of samples, you never will, so check those 'maximum shift' values first
and then use them as bounds; similarly, the HL estimate itself is the bound
for the other end of each search).
There are other approaches to doing this that will probably be more efficient,
but this should work well enough with a good root-finder (perhaps involving
only a dozen or so evaluations of statistics at different shift values).
In response to the comments about the issue being a change of scale, not location:
One possibility - you could consider looking at estimating the location shift in the logs, which should correspond to the log of the scale change (ratio of scales) in the untransformed values. That is if $X∼F(x)$ and $Y∼F(y/a)$ then if $X^∗=\ln X∼G(x), Y^∗=\ln Y∼G(y−\ln a)$, where $G(x)= F(\exp(x))$.
Intervals, at least should carry over nicely.
Here's an example of that in use:
The data are as follows. The x sample is 60 observations from a distribution with scale parameter $\mu=18$, while the y sample is 50 observations with scale parameter $\mu=25$. They have the same distribution, aside from a shift in scale.
The increase in scale is a factor of $25/18 \approx 1.3889$.
Here's a boxplot of the data on the original scale and on the log-scale:
Here we do a Wilcoxon-Mann-Whitney on the log-data:
> lx=log(x)
> ly=log(y)
> wilcox.test(ly,lx,conf.int=TRUE)
Wilcoxon rank sum test with continuity correction
data: ly and lx
W = 1743, p-value = 0.1455
alternative hypothesis: true location shift is not equal to 0
95 percent confidence interval:
-0.09044406 0.68813695
sample estimates:
difference in location
0.2917924
If we exponentiate the interval, it should contain the true ratio of scales 95% of the time. It does contain the population ratio on this occasion:
> exp(wilcox.test(ly,lx,conf.int=TRUE)$conf.int)
[1] 0.9135254 1.9900046
attr(,"conf.level")
[1] 0.95
If we exponentiate the estimated shift in the logs, it will be a (somewhat) downward-biased estimate of the scale-ratio, but it's fairly good:
> exp(wilcox.test(ly,lx,conf.int=TRUE)$estimate)
difference in location
1.338825
[The data used in the example were generated as follows:
> set.seed(94394381)
> x=rexp(60,1/18)
> y=rexp(50,1/25)
... just in case anyone wants to try it]
There are other ways to estimate the scale change; one could, for example, divide the y-sample by a constant, $c$, and try different values of $c$ until the WMW statistic was equal to its expected value under the null hypothesis. One could also try different values until the statistic was equal to the $\alpha/2$ and $1-\alpha/2$ quantiles of the null distribution of the WMW. As above, this will be the point estimate of and interval for the ratio of scales.
(That would have the advantage of not introducing a small bias into the central estimate.)
|
Difference of 'centers' of 2 non-normal samples with Mann-Whitney test
Yes, if your alternative is a shift alternative, the corresponding estimate is the Hodges-Lehmann.
The estimate is easy enough.
The Hodges Lehmann estimate is the sample median of the cross-sample pai
|
47,396
|
When finding outliers from the Interquartile range why I have to multiply by 1.5?
|
Certainly you can change the criterion.
The 1.5 multiplier is so that a certain proportion of the sample in a normal population will be outside it. But there is nothing sacred about it.
However, I would caution against any automatic method of selecting outliers.
|
When finding outliers from the Interquartile range why I have to multiply by 1.5?
|
Certainly you can change the criterion.
The 1.5 multiplier is so that a certain proportion of the sample in a normal population will be outside it. But there is nothing sacred about it.
However, I wou
|
When finding outliers from the Interquartile range why I have to multiply by 1.5?
Certainly you can change the criterion.
The 1.5 multiplier is so that a certain proportion of the sample in a normal population will be outside it. But there is nothing sacred about it.
However, I would caution against any automatic method of selecting outliers.
|
When finding outliers from the Interquartile range why I have to multiply by 1.5?
Certainly you can change the criterion.
The 1.5 multiplier is so that a certain proportion of the sample in a normal population will be outside it. But there is nothing sacred about it.
However, I wou
|
47,397
|
Where does the term "covariate" come from in statistics?
|
(Making comment into an answer.)
A good starting point is the list of earliest known uses of mathematical terms: jeff560.tripod.com/c.html which gives a reference to 1949 (but with covariate meaning specifically the "x" variable in a regression.) The same source says that the word variate goes back to Pearson in 1909, meaning a random variable.
COVARIATE. When R. A. Fisher introduced the analysis of covariance he called the regression variable the concomitant variable. In the 1940s the term covariate came into use for the variable in that role: see e.g. Biometrics, 5, (1949), p. 73. (JSTOR search) More recently covariate has been detached from the analysis of covariance (and from the analysis of experiments) to be used more broadly. It is now employed where independent variable or exogenous variable or regressor might also be used. An early instance of this usage is found in D. A. Sprott and John D. Kalbfleisch "Examples of Likelihoods and Comparison with Point Estimates and Large Sample Approximations," Journal of the American Statistical Association, 64, (1969), p. 477. (JSTOR search)
See the entries COVARIANCE, DEPENDENT/INDEPENDENT VARIABLE, ENDOGENOUS/EXOGENOUS VARIABLE, REGRESSION.
|
Where does the term "covariate" come from in statistics?
|
(Making comment into an answer.)
A good starting point is the list of earliest known uses of mathematical terms: jeff560.tripod.com/c.html which gives a reference to 1949 (but with covariate meaning s
|
Where does the term "covariate" come from in statistics?
(Making comment into an answer.)
A good starting point is the list of earliest known uses of mathematical terms: jeff560.tripod.com/c.html which gives a reference to 1949 (but with covariate meaning specifically the "x" variable in a regression.) The same source says that the word variate goes back to Pearson in 1909, meaning a random variable.
COVARIATE. When R. A. Fisher introduced the analysis of covariance he called the regression variable the concomitant variable. In the 1940s the term covariate came into use for the variable in that role: see e.g. Biometrics, 5, (1949), p. 73. (JSTOR search) More recently covariate has been detached from the analysis of covariance (and from the analysis of experiments) to be used more broadly. It is now employed where independent variable or exogenous variable or regressor might also be used. An early instance of this usage is found in D. A. Sprott and John D. Kalbfleisch "Examples of Likelihoods and Comparison with Point Estimates and Large Sample Approximations," Journal of the American Statistical Association, 64, (1969), p. 477. (JSTOR search)
See the entries COVARIANCE, DEPENDENT/INDEPENDENT VARIABLE, ENDOGENOUS/EXOGENOUS VARIABLE, REGRESSION.
|
Where does the term "covariate" come from in statistics?
(Making comment into an answer.)
A good starting point is the list of earliest known uses of mathematical terms: jeff560.tripod.com/c.html which gives a reference to 1949 (but with covariate meaning s
|
47,398
|
Selecting the best subset of variables for parsimonious binary logistic regression models
|
Variable selection without penalization is invalid.
|
Selecting the best subset of variables for parsimonious binary logistic regression models
|
Variable selection without penalization is invalid.
|
Selecting the best subset of variables for parsimonious binary logistic regression models
Variable selection without penalization is invalid.
|
Selecting the best subset of variables for parsimonious binary logistic regression models
Variable selection without penalization is invalid.
|
47,399
|
Selecting the best subset of variables for parsimonious binary logistic regression models
|
Rarely does a question appear that I believe I can answer.
This isn't in R (at least I don't believe there is a addin for it). It doesn't answer your exact questions either, although I believe may be of help.
I am seeking other methods of variable selection in lieu of using
stepwise methods for building more parsimonious binary logistic
regression models (containing 8 to 12 variables to predict outcomes
such as loan payment/default or current/late payment history) from a
wide array of potential predictor variables (500+ variables, 200k+
records).
Perhaps Correlated Component Analysis would answer your problems.
See here: http://www.xlstat.com/en/products-solutions/ccr.html
Predictor Selection Using the CCR/Step-Down Algorithm
In step 1 of the step-down option, a model containing all predictors is estimated
with K* components (where K* is specified by the user or determined by
the program if the Automatic option is activated), and the relevant CV
statistics are computed. In step 2, the model is then re-estimated
after excluding the predictor whose standardized coefficient is
smallest in absolute value, and CV statistics are computed again. Note
that both steps 1 and 2 are performed within each subsample formed by
eliminating one of the folds. This process continues until the
user-specified minimum number of predictors remains in the model (by
default, Pmin = 1). The number of predictors included in the reported
model, P*, is the one with the best CV statistic.
Here is the summarization for when it was presented at the Paris workshop on PLS developments 2 years ago.
Jay Magidson. "Correlated Component Regression A Sparse Alternative to PLS Regression." http://statisticalinnovations.com/technicalsupport/ParisWorkshop.pdf
It sounds like what you are partially trying to accomplish is done with this algorithm in this tutorial:
"Using Correlated Component Regression with a Dichotomous Y and Many Correlated Predictors."
http://statisticalinnovations.com/products/xlstattutorials/XLCCRtutorial2.pdf
I also hate it when people answer questions by just referencing other works instead of actually answering the question, but, I just feel this is the best answer if I'm understanding everything correctly. Hope it helps.
|
Selecting the best subset of variables for parsimonious binary logistic regression models
|
Rarely does a question appear that I believe I can answer.
This isn't in R (at least I don't believe there is a addin for it). It doesn't answer your exact questions either, although I believe may be
|
Selecting the best subset of variables for parsimonious binary logistic regression models
Rarely does a question appear that I believe I can answer.
This isn't in R (at least I don't believe there is a addin for it). It doesn't answer your exact questions either, although I believe may be of help.
I am seeking other methods of variable selection in lieu of using
stepwise methods for building more parsimonious binary logistic
regression models (containing 8 to 12 variables to predict outcomes
such as loan payment/default or current/late payment history) from a
wide array of potential predictor variables (500+ variables, 200k+
records).
Perhaps Correlated Component Analysis would answer your problems.
See here: http://www.xlstat.com/en/products-solutions/ccr.html
Predictor Selection Using the CCR/Step-Down Algorithm
In step 1 of the step-down option, a model containing all predictors is estimated
with K* components (where K* is specified by the user or determined by
the program if the Automatic option is activated), and the relevant CV
statistics are computed. In step 2, the model is then re-estimated
after excluding the predictor whose standardized coefficient is
smallest in absolute value, and CV statistics are computed again. Note
that both steps 1 and 2 are performed within each subsample formed by
eliminating one of the folds. This process continues until the
user-specified minimum number of predictors remains in the model (by
default, Pmin = 1). The number of predictors included in the reported
model, P*, is the one with the best CV statistic.
Here is the summarization for when it was presented at the Paris workshop on PLS developments 2 years ago.
Jay Magidson. "Correlated Component Regression A Sparse Alternative to PLS Regression." http://statisticalinnovations.com/technicalsupport/ParisWorkshop.pdf
It sounds like what you are partially trying to accomplish is done with this algorithm in this tutorial:
"Using Correlated Component Regression with a Dichotomous Y and Many Correlated Predictors."
http://statisticalinnovations.com/products/xlstattutorials/XLCCRtutorial2.pdf
I also hate it when people answer questions by just referencing other works instead of actually answering the question, but, I just feel this is the best answer if I'm understanding everything correctly. Hope it helps.
|
Selecting the best subset of variables for parsimonious binary logistic regression models
Rarely does a question appear that I believe I can answer.
This isn't in R (at least I don't believe there is a addin for it). It doesn't answer your exact questions either, although I believe may be
|
47,400
|
Selecting the best subset of variables for parsimonious binary logistic regression models
|
To answer the above two questions:
1) In layman terms, Kullback-Leibler divergence, as displayed in R when using the FSelector package, is the relative amount of information that can be gained by using a given potential predictor variable.
2) It is NOT a valid approach to select a desired number of variables for a binary logistic regression model (e.g., selecting the 8 highest "ranked" variables for use in a parsimonious model) as no such approach exists. Most importantly, it does not take into account collinearity among predictor variables, as it simply rank orders variables by information gain. Information gain is very similar to the c-statistic or information value in terms of being a univariate measurement for classification strength for a given predictor variable. As such, it is useful to rank variables, but other methods must also be applied to further build parsimonious models (eg. PCA and Lasso or Ridge Regression).
I hope this helps someone!
|
Selecting the best subset of variables for parsimonious binary logistic regression models
|
To answer the above two questions:
1) In layman terms, Kullback-Leibler divergence, as displayed in R when using the FSelector package, is the relative amount of information that can be gained by usin
|
Selecting the best subset of variables for parsimonious binary logistic regression models
To answer the above two questions:
1) In layman terms, Kullback-Leibler divergence, as displayed in R when using the FSelector package, is the relative amount of information that can be gained by using a given potential predictor variable.
2) It is NOT a valid approach to select a desired number of variables for a binary logistic regression model (e.g., selecting the 8 highest "ranked" variables for use in a parsimonious model) as no such approach exists. Most importantly, it does not take into account collinearity among predictor variables, as it simply rank orders variables by information gain. Information gain is very similar to the c-statistic or information value in terms of being a univariate measurement for classification strength for a given predictor variable. As such, it is useful to rank variables, but other methods must also be applied to further build parsimonious models (eg. PCA and Lasso or Ridge Regression).
I hope this helps someone!
|
Selecting the best subset of variables for parsimonious binary logistic regression models
To answer the above two questions:
1) In layman terms, Kullback-Leibler divergence, as displayed in R when using the FSelector package, is the relative amount of information that can be gained by usin
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.