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
|
|---|---|---|---|---|---|---|
13,301
|
Changing null hypothesis in linear regression
|
You can simply not make probability or likelihood statements about the parameter using a confidence interval, this is a Bayesian paradigm.
What John is saying is confusing because it there is an equivalence between CIs and Pvalues, so at a 5%, saying that your CI includes 1 is equivalent to saying that Pval>0.05.
linearHypothesis allows you to test restrictions different from the standard beta=0
|
Changing null hypothesis in linear regression
|
You can simply not make probability or likelihood statements about the parameter using a confidence interval, this is a Bayesian paradigm.
What John is saying is confusing because it there is an equiv
|
Changing null hypothesis in linear regression
You can simply not make probability or likelihood statements about the parameter using a confidence interval, this is a Bayesian paradigm.
What John is saying is confusing because it there is an equivalence between CIs and Pvalues, so at a 5%, saying that your CI includes 1 is equivalent to saying that Pval>0.05.
linearHypothesis allows you to test restrictions different from the standard beta=0
|
Changing null hypothesis in linear regression
You can simply not make probability or likelihood statements about the parameter using a confidence interval, this is a Bayesian paradigm.
What John is saying is confusing because it there is an equiv
|
13,302
|
Advantages of the Exponential Family: why should we study it and use it?
|
...why should we study it and use it?
I think your list of advantages effectively answers your own question, but let me offer some meta-mathematical commentary that might elucidate this topic. Generally speaking, mathematicians like to generalise concepts and results up to the maximal point that they can, to the limits of their usefulness. That is, when mathematicians develop a concept, and find that one or more useful theorems apply to that concept, they will generally seek to generalise the concept and results more and more, until they get to the point where further generalisation would render the results inapplicable or no longer useful. As can be seen from your list, the exponential family has a number of useful theorems attached to it, and it encompasses a wide class of distributions. This is sufficient to make it a worthy object of study, and a useful mathematical class in practice.
Can anyone provide any other advantage?
This class has various good properties in Bayesian analysis. In particular, the exponential family distributions always have conjugate priors, and the resulting posterior predictive distribution has a simple form. This makes is an extremely useful class of distributions in Bayesian statistics. Indeed, it allows you to undertake Bayesian analysis using conjugate priors at an extremely high level of generality, encompassing all the distributional families in the exponential family.
|
Advantages of the Exponential Family: why should we study it and use it?
|
...why should we study it and use it?
I think your list of advantages effectively answers your own question, but let me offer some meta-mathematical commentary that might elucidate this topic. Gener
|
Advantages of the Exponential Family: why should we study it and use it?
...why should we study it and use it?
I think your list of advantages effectively answers your own question, but let me offer some meta-mathematical commentary that might elucidate this topic. Generally speaking, mathematicians like to generalise concepts and results up to the maximal point that they can, to the limits of their usefulness. That is, when mathematicians develop a concept, and find that one or more useful theorems apply to that concept, they will generally seek to generalise the concept and results more and more, until they get to the point where further generalisation would render the results inapplicable or no longer useful. As can be seen from your list, the exponential family has a number of useful theorems attached to it, and it encompasses a wide class of distributions. This is sufficient to make it a worthy object of study, and a useful mathematical class in practice.
Can anyone provide any other advantage?
This class has various good properties in Bayesian analysis. In particular, the exponential family distributions always have conjugate priors, and the resulting posterior predictive distribution has a simple form. This makes is an extremely useful class of distributions in Bayesian statistics. Indeed, it allows you to undertake Bayesian analysis using conjugate priors at an extremely high level of generality, encompassing all the distributional families in the exponential family.
|
Advantages of the Exponential Family: why should we study it and use it?
...why should we study it and use it?
I think your list of advantages effectively answers your own question, but let me offer some meta-mathematical commentary that might elucidate this topic. Gener
|
13,303
|
Advantages of the Exponential Family: why should we study it and use it?
|
I would say the most compelling motivation for the exponential families is that they are minimum assumptive distribution given measurements. If you have a real-valued sensor whose measurements are summarized by mean and variance, then the minimum assumption you can make about its observations is that they are normally distributed. Each exponential family is the result of a similar set of assumptions.
Jaynes avers this principle of maximum entropy:
“the maximum-entropy distribution may be asserted for the positive reason that it is uniquely determined as the one which is maximally noncommittal with regard to missing information, instead of the negative one that there was no reason to think otherwise. Thus the concept of entropy supplies the missing criterion of choice…”
|
Advantages of the Exponential Family: why should we study it and use it?
|
I would say the most compelling motivation for the exponential families is that they are minimum assumptive distribution given measurements. If you have a real-valued sensor whose measurements are su
|
Advantages of the Exponential Family: why should we study it and use it?
I would say the most compelling motivation for the exponential families is that they are minimum assumptive distribution given measurements. If you have a real-valued sensor whose measurements are summarized by mean and variance, then the minimum assumption you can make about its observations is that they are normally distributed. Each exponential family is the result of a similar set of assumptions.
Jaynes avers this principle of maximum entropy:
“the maximum-entropy distribution may be asserted for the positive reason that it is uniquely determined as the one which is maximally noncommittal with regard to missing information, instead of the negative one that there was no reason to think otherwise. Thus the concept of entropy supplies the missing criterion of choice…”
|
Advantages of the Exponential Family: why should we study it and use it?
I would say the most compelling motivation for the exponential families is that they are minimum assumptive distribution given measurements. If you have a real-valued sensor whose measurements are su
|
13,304
|
Data Augmentation strategies for Time Series Forecasting
|
Any other ideas to do data augmentation for time series forecasting?
I'm currently thinking about the same problem. I've found the paper "Data Augmentation for Time Series Classification
using Convolutional Neural Networks" by Le Guennec et al. which doesn't cover forecasting however. Still the augmentation methods mentioned there look promising. The authors communicate 2 methods:
Window Slicing (WS)
A first method that is inspired from the computer vision community [8,10]
consists in extracting slices from time series and performing classification at the slice level. This method has been introduced for time series in [6]. At training, each slice extracted from a time series of class y is assigned the same class and a classifier is learned using the slices. The size of the slice is a parameter of this method. At test time, each slice from a test time series is classified using the learned classifier and a majority vote is performed to decide a predicted label. This method is referred to as
window slicing (WS) in the following.
Window Warping (WW)
The last data augmentation technique we use is more time-series specific. It consists in warping a randomly selected slice of a time series by speeding it up or down, as shown in Fig. 2. The size of the original slice is a parameter of this method. Fig. 2 shows a time series from the “ECG200” dataset and corresponding transformed data. Note that this method generates input time series of different lengths. To deal with this issue, we perform
window slicing on transformed time series for all to have equal length. In this paper, we only consider warping ratios equal to 0.5 or 2, but other ratios could be used and the optimal ratio could even be fine tuned through cross-validation on the training set. In the following, this method will be referred to as window warping (WW).
The authors kept 90% of the series unchanged (i.e. WS was set to a 90% slice and for WW 10% of the series were warped). The methods are reported to reduce classification error on several types of (time) series data, except on 1D representations of image outlines. The authors took their data from here: http://timeseriesclassification.com
How to weight the synthetic data in the training set?
In image augmentation, since the augmentation isn't expected to change the class of an image, it's afaik common to weight it as any real data. Time series forecasting (and even time series classification) might be different:
A time series is not easily perceivable as a contiguous object for humans, so depending on how much you tamper with it, is it still the same class? If you only slice and warp a little and classes are visually distinct, this might not pose a problem for classification tasks
For forecasting, I would argue that
2.1 WS is still a nice method. No matter at which 90%-part of the series you look, you would still expect a forecast based on the same rules => full weight.
2.2 WW: The closer it happens to the end of the series, the more cautious I would be. Intuitively, I would come up with a weight factor sliding between 0 (warping at the end) and 1 (warping at the beginning), assuming that the most recent features of the curve are the most relevant.
|
Data Augmentation strategies for Time Series Forecasting
|
Any other ideas to do data augmentation for time series forecasting?
I'm currently thinking about the same problem. I've found the paper "Data Augmentation for Time Series Classification
using Convol
|
Data Augmentation strategies for Time Series Forecasting
Any other ideas to do data augmentation for time series forecasting?
I'm currently thinking about the same problem. I've found the paper "Data Augmentation for Time Series Classification
using Convolutional Neural Networks" by Le Guennec et al. which doesn't cover forecasting however. Still the augmentation methods mentioned there look promising. The authors communicate 2 methods:
Window Slicing (WS)
A first method that is inspired from the computer vision community [8,10]
consists in extracting slices from time series and performing classification at the slice level. This method has been introduced for time series in [6]. At training, each slice extracted from a time series of class y is assigned the same class and a classifier is learned using the slices. The size of the slice is a parameter of this method. At test time, each slice from a test time series is classified using the learned classifier and a majority vote is performed to decide a predicted label. This method is referred to as
window slicing (WS) in the following.
Window Warping (WW)
The last data augmentation technique we use is more time-series specific. It consists in warping a randomly selected slice of a time series by speeding it up or down, as shown in Fig. 2. The size of the original slice is a parameter of this method. Fig. 2 shows a time series from the “ECG200” dataset and corresponding transformed data. Note that this method generates input time series of different lengths. To deal with this issue, we perform
window slicing on transformed time series for all to have equal length. In this paper, we only consider warping ratios equal to 0.5 or 2, but other ratios could be used and the optimal ratio could even be fine tuned through cross-validation on the training set. In the following, this method will be referred to as window warping (WW).
The authors kept 90% of the series unchanged (i.e. WS was set to a 90% slice and for WW 10% of the series were warped). The methods are reported to reduce classification error on several types of (time) series data, except on 1D representations of image outlines. The authors took their data from here: http://timeseriesclassification.com
How to weight the synthetic data in the training set?
In image augmentation, since the augmentation isn't expected to change the class of an image, it's afaik common to weight it as any real data. Time series forecasting (and even time series classification) might be different:
A time series is not easily perceivable as a contiguous object for humans, so depending on how much you tamper with it, is it still the same class? If you only slice and warp a little and classes are visually distinct, this might not pose a problem for classification tasks
For forecasting, I would argue that
2.1 WS is still a nice method. No matter at which 90%-part of the series you look, you would still expect a forecast based on the same rules => full weight.
2.2 WW: The closer it happens to the end of the series, the more cautious I would be. Intuitively, I would come up with a weight factor sliding between 0 (warping at the end) and 1 (warping at the beginning), assuming that the most recent features of the curve are the most relevant.
|
Data Augmentation strategies for Time Series Forecasting
Any other ideas to do data augmentation for time series forecasting?
I'm currently thinking about the same problem. I've found the paper "Data Augmentation for Time Series Classification
using Convol
|
13,305
|
Data Augmentation strategies for Time Series Forecasting
|
I have recently implemented another approach inspired by this paper from Bergmeir, Hyndman and Benitez.
The idea is to take a time series and first apply a transformation such as the Box Cox transformation or Yeo-johnson (which solves some problems with the Box Cox) to stabilise the variance of the series, then applying an STL decomposition on the transformed series for seasonal series or a loess decomposition to get the residuals of the series. Taking these residuals and bootstrapping them with a moving block bootstrap to generate $B$ additional series. These $B$ additional series then have the initial trend and seasonality of the starting series added back to the bootstrapped residuals before lastly inverting the power transform applied in the first step.
In this way as many additional time series as needed can be generated that represent the initial time series quite well. Here is an example of the application on some real data to generate additional similar time series:
Here the augmentation is shown using a Yeo-johnson transformation and not Box Cox as suggested in the original paper.
|
Data Augmentation strategies for Time Series Forecasting
|
I have recently implemented another approach inspired by this paper from Bergmeir, Hyndman and Benitez.
The idea is to take a time series and first apply a transformation such as the Box Cox transfo
|
Data Augmentation strategies for Time Series Forecasting
I have recently implemented another approach inspired by this paper from Bergmeir, Hyndman and Benitez.
The idea is to take a time series and first apply a transformation such as the Box Cox transformation or Yeo-johnson (which solves some problems with the Box Cox) to stabilise the variance of the series, then applying an STL decomposition on the transformed series for seasonal series or a loess decomposition to get the residuals of the series. Taking these residuals and bootstrapping them with a moving block bootstrap to generate $B$ additional series. These $B$ additional series then have the initial trend and seasonality of the starting series added back to the bootstrapped residuals before lastly inverting the power transform applied in the first step.
In this way as many additional time series as needed can be generated that represent the initial time series quite well. Here is an example of the application on some real data to generate additional similar time series:
Here the augmentation is shown using a Yeo-johnson transformation and not Box Cox as suggested in the original paper.
|
Data Augmentation strategies for Time Series Forecasting
I have recently implemented another approach inspired by this paper from Bergmeir, Hyndman and Benitez.
The idea is to take a time series and first apply a transformation such as the Box Cox transfo
|
13,306
|
Data Augmentation strategies for Time Series Forecasting
|
Any other ideas to do data augmentation for time series forecasting?
Another answer with a different approach, based on "Dataset Augmentation in Feature Space" by DeVries and Taylor.
In this work, we demonstrate that extrapolating between samples in feature space can be used to augment datasets and improve the performance of supervised learning algorithms. The main benefit of our approach is that it is domain-independent, requiring no specialized knowledge, and can therefore be applied to many different types of problems.
Sounds promising to me. In principle you can take any autoencoder to create representations in the feature space. These features can be interpolated or extrapolated.
The figure below shows as an example interpolation of two feature space vectors $C_j$ and $C_k$ (be aware that more positive results are reported for extrapolating from two vectors, see the paper for details). The resulting augmented vector $C'$ is then decoded back to the input space and fed into the network for training.
The paper again covers only sequence classification. But again IMO the principles are the same for regression analysis. You get new data from presumably the same distribution as your real data, that's what you want.
If we elaborate this principle of data generation by a neural network further, we'll end up with Generative Adversarial Networks (GAN). They could be used in a similar fashion to generate augmented data which will probably be the most sophisticated state-of-the-art way to do so.
|
Data Augmentation strategies for Time Series Forecasting
|
Any other ideas to do data augmentation for time series forecasting?
Another answer with a different approach, based on "Dataset Augmentation in Feature Space" by DeVries and Taylor.
In this work, w
|
Data Augmentation strategies for Time Series Forecasting
Any other ideas to do data augmentation for time series forecasting?
Another answer with a different approach, based on "Dataset Augmentation in Feature Space" by DeVries and Taylor.
In this work, we demonstrate that extrapolating between samples in feature space can be used to augment datasets and improve the performance of supervised learning algorithms. The main benefit of our approach is that it is domain-independent, requiring no specialized knowledge, and can therefore be applied to many different types of problems.
Sounds promising to me. In principle you can take any autoencoder to create representations in the feature space. These features can be interpolated or extrapolated.
The figure below shows as an example interpolation of two feature space vectors $C_j$ and $C_k$ (be aware that more positive results are reported for extrapolating from two vectors, see the paper for details). The resulting augmented vector $C'$ is then decoded back to the input space and fed into the network for training.
The paper again covers only sequence classification. But again IMO the principles are the same for regression analysis. You get new data from presumably the same distribution as your real data, that's what you want.
If we elaborate this principle of data generation by a neural network further, we'll end up with Generative Adversarial Networks (GAN). They could be used in a similar fashion to generate augmented data which will probably be the most sophisticated state-of-the-art way to do so.
|
Data Augmentation strategies for Time Series Forecasting
Any other ideas to do data augmentation for time series forecasting?
Another answer with a different approach, based on "Dataset Augmentation in Feature Space" by DeVries and Taylor.
In this work, w
|
13,307
|
Overfitting: No silver bullet?
|
Not a whole answer, but one thing that people overlook in this discussion is what does Cross-Validation (for example) mean, why do you use it, and what does it cover?
The problem I see with searching too hard is that the CV that people are doing is often within a single model. Easy to do by setting a folds= argument of the model fitting procedure. But when you go to multiple models, and even multiple procedures for creating multiple models, you add another layer or two which you haven't wrapped in CV.
So they should be using nested CV. And they should also be using "Target Shuffling" (resampling/permutation testing) wrapped around their whole process to see how well their procedure would do if you break the relationship between dependent and independent variables -- i.e. how much better are you doing than random considering your entire process?
|
Overfitting: No silver bullet?
|
Not a whole answer, but one thing that people overlook in this discussion is what does Cross-Validation (for example) mean, why do you use it, and what does it cover?
The problem I see with searching
|
Overfitting: No silver bullet?
Not a whole answer, but one thing that people overlook in this discussion is what does Cross-Validation (for example) mean, why do you use it, and what does it cover?
The problem I see with searching too hard is that the CV that people are doing is often within a single model. Easy to do by setting a folds= argument of the model fitting procedure. But when you go to multiple models, and even multiple procedures for creating multiple models, you add another layer or two which you haven't wrapped in CV.
So they should be using nested CV. And they should also be using "Target Shuffling" (resampling/permutation testing) wrapped around their whole process to see how well their procedure would do if you break the relationship between dependent and independent variables -- i.e. how much better are you doing than random considering your entire process?
|
Overfitting: No silver bullet?
Not a whole answer, but one thing that people overlook in this discussion is what does Cross-Validation (for example) mean, why do you use it, and what does it cover?
The problem I see with searching
|
13,308
|
Overfitting: No silver bullet?
|
In my 4 or so years of experience, I've found that trying out every model available in caret (or scikit-learn) doesn't necessarily lead to overfitting. I've found that if you have a sufficiently large dataset (10,000+ rows) and a more or less even balance of classes (i.e., no class imbalance like in credit risk or marketing problems), then overfitting tends to be minimal. It's worth noting that my grid search on tuning parameters tends to be no more than 30 permutations per model. At the extreme end, if you used 100 or 1,000 permutations per model, you would probably overfit.
The way you've worded your question makes the answer pretty easy: at the extreme, yes, overfitting is likely if not certain. There is no silver bullet, and I doubt anyone would suggest otherwise. However, there is still a reasonably wide spectrum where the degree of overfitting is minimal enough to be acceptable. Having a healthy amount of unseen data in your validation holdout set definitely helps. Having multiple unseen validation holdout sets is even better. I'm fortunate enough to work in a field where I have large amounts of new data coming on a daily basis.
If I'm in a position where I'm stuck with a static dataset of fewer than 2,000-3,000 observations (ex: medical data that's hard to come by), I generally only use linear models because I've frequently seen overfitting with gradient boosting and support vector machines on sufficiently small datasets. On the other hand, I've talked to a top Kaggler (top 5%) that said he builds tens of thousands of models for each competition and then ensembles them, using several thousand models in his final ensemble. He said this was the main reason for his success on the final leaderboards.
|
Overfitting: No silver bullet?
|
In my 4 or so years of experience, I've found that trying out every model available in caret (or scikit-learn) doesn't necessarily lead to overfitting. I've found that if you have a sufficiently large
|
Overfitting: No silver bullet?
In my 4 or so years of experience, I've found that trying out every model available in caret (or scikit-learn) doesn't necessarily lead to overfitting. I've found that if you have a sufficiently large dataset (10,000+ rows) and a more or less even balance of classes (i.e., no class imbalance like in credit risk or marketing problems), then overfitting tends to be minimal. It's worth noting that my grid search on tuning parameters tends to be no more than 30 permutations per model. At the extreme end, if you used 100 or 1,000 permutations per model, you would probably overfit.
The way you've worded your question makes the answer pretty easy: at the extreme, yes, overfitting is likely if not certain. There is no silver bullet, and I doubt anyone would suggest otherwise. However, there is still a reasonably wide spectrum where the degree of overfitting is minimal enough to be acceptable. Having a healthy amount of unseen data in your validation holdout set definitely helps. Having multiple unseen validation holdout sets is even better. I'm fortunate enough to work in a field where I have large amounts of new data coming on a daily basis.
If I'm in a position where I'm stuck with a static dataset of fewer than 2,000-3,000 observations (ex: medical data that's hard to come by), I generally only use linear models because I've frequently seen overfitting with gradient boosting and support vector machines on sufficiently small datasets. On the other hand, I've talked to a top Kaggler (top 5%) that said he builds tens of thousands of models for each competition and then ensembles them, using several thousand models in his final ensemble. He said this was the main reason for his success on the final leaderboards.
|
Overfitting: No silver bullet?
In my 4 or so years of experience, I've found that trying out every model available in caret (or scikit-learn) doesn't necessarily lead to overfitting. I've found that if you have a sufficiently large
|
13,309
|
Overfitting: No silver bullet?
|
So much depends on scale. I wish I could count on having more than 2,000-3,000 cases like @RyanZotti typically has; I seldom have 1/10th that many. That's a big difference in perspective between "big data" machine learning folk and those working in fields like biomedicine, which might account for some of the different perspectives you will find on this site.
I'll present a heuristic explanation of my take on this problem. The basic issue in overfitting, as described on the Wikipedia page, is the relation between the number of cases and the number of parameters you are evaluating. So start with the rough idea that if you have M models you are choosing among and p parameters per model then you are evaluating something on the order of Mp parameters in total.
If there is danger of overfitting there are two general ways to pull back to a more generalizable model: reduce the number of parameters or penalize them in some way.
With adequately large data sets you might never come close to overfitting. If you have 20,000 cases and 20 different models with 100 parameters per model, then you might not be in trouble even without penalization as you still have 10 cases per effective parameter. Don't try that modeling strategy with only 200 cases.
Model averaging might be thought of as a form of penalization. In the example of the Kaggler cited by @RyanZotti, the number of cases is presumably enormous and each of the "several thousand" models in the final ensemble individually contributes only a small fraction of the final model. Any overfitting specific to a particular contributing model will not have a great influence on the final result, and the extremely large numbers of cases in a Kaggler competition further reduces the danger of overfitting.
So, as with so many issues here, the only reasonable answer is: "It depends." In this case, it depends on the relation between the number of cases and the effective number of parameters examined, together with how much penalization is being applied.
|
Overfitting: No silver bullet?
|
So much depends on scale. I wish I could count on having more than 2,000-3,000 cases like @RyanZotti typically has; I seldom have 1/10th that many. That's a big difference in perspective between "big
|
Overfitting: No silver bullet?
So much depends on scale. I wish I could count on having more than 2,000-3,000 cases like @RyanZotti typically has; I seldom have 1/10th that many. That's a big difference in perspective between "big data" machine learning folk and those working in fields like biomedicine, which might account for some of the different perspectives you will find on this site.
I'll present a heuristic explanation of my take on this problem. The basic issue in overfitting, as described on the Wikipedia page, is the relation between the number of cases and the number of parameters you are evaluating. So start with the rough idea that if you have M models you are choosing among and p parameters per model then you are evaluating something on the order of Mp parameters in total.
If there is danger of overfitting there are two general ways to pull back to a more generalizable model: reduce the number of parameters or penalize them in some way.
With adequately large data sets you might never come close to overfitting. If you have 20,000 cases and 20 different models with 100 parameters per model, then you might not be in trouble even without penalization as you still have 10 cases per effective parameter. Don't try that modeling strategy with only 200 cases.
Model averaging might be thought of as a form of penalization. In the example of the Kaggler cited by @RyanZotti, the number of cases is presumably enormous and each of the "several thousand" models in the final ensemble individually contributes only a small fraction of the final model. Any overfitting specific to a particular contributing model will not have a great influence on the final result, and the extremely large numbers of cases in a Kaggler competition further reduces the danger of overfitting.
So, as with so many issues here, the only reasonable answer is: "It depends." In this case, it depends on the relation between the number of cases and the effective number of parameters examined, together with how much penalization is being applied.
|
Overfitting: No silver bullet?
So much depends on scale. I wish I could count on having more than 2,000-3,000 cases like @RyanZotti typically has; I seldom have 1/10th that many. That's a big difference in perspective between "big
|
13,310
|
Overfitting: No silver bullet?
|
I agree with @ryan-zotti that searching hard enough does not necessarily lead to overfitting - or at least not to an amount so that we would call it overfitting. Let me try to state my point of view on this:
Box once said:
Remember that all models are wrong; the practical question is how wrong do they have to be to not be useful.
(Being perfect would require all the data, which in turn would eliminate the need for a model in the first place).
Models being wrong also comprises over- and underfitting$^1$. But we won't necessarily care about or even notice it. The question is which amount of the model deviating from reality can we a) measure at all and b) find acceptable to not call it over- or underfitting - because both will always apply a little to all model we will ever build. If our models in the end satisfy our requirements but e.g. over-/underfit just minimal, or over-/underfit on parts of (possible) data that is not considered in our application case we would accept it - it's not necessarily about preventing all over-/underfitting.
This boils down to a proper setup to measure/detect model error to decide if this is what we would want to have. So what we can do is make the process as robust as possible by trying to get data with minimal noise and representative+sufficient samples, to model, evaluate and select as best as possible, and to do all this in a reasonable way (e.g. few samples, many features $\rightarrow$ less complex model; select the least complex model with yet acceptable performance, etc.).
Because: in the end we will always have model error/over-/underfitting - it's the capability of detecting/measuring this error within our focus of interest to make reasonable choices that matters.
$^1$ a) each model has a bias and variance problem at the same time (we usually try to find the right trade-off to satisfy our needs). Models satisfying our requirements will necessarily still have bias and variance. b) Consider noisy data and non representative samples as reasons for overfitting. Each model will necessarily model noise as well as model a relation for which parts of the information is missing, so about which wrong assumptions will necessarily be made.
|
Overfitting: No silver bullet?
|
I agree with @ryan-zotti that searching hard enough does not necessarily lead to overfitting - or at least not to an amount so that we would call it overfitting. Let me try to state my point of view o
|
Overfitting: No silver bullet?
I agree with @ryan-zotti that searching hard enough does not necessarily lead to overfitting - or at least not to an amount so that we would call it overfitting. Let me try to state my point of view on this:
Box once said:
Remember that all models are wrong; the practical question is how wrong do they have to be to not be useful.
(Being perfect would require all the data, which in turn would eliminate the need for a model in the first place).
Models being wrong also comprises over- and underfitting$^1$. But we won't necessarily care about or even notice it. The question is which amount of the model deviating from reality can we a) measure at all and b) find acceptable to not call it over- or underfitting - because both will always apply a little to all model we will ever build. If our models in the end satisfy our requirements but e.g. over-/underfit just minimal, or over-/underfit on parts of (possible) data that is not considered in our application case we would accept it - it's not necessarily about preventing all over-/underfitting.
This boils down to a proper setup to measure/detect model error to decide if this is what we would want to have. So what we can do is make the process as robust as possible by trying to get data with minimal noise and representative+sufficient samples, to model, evaluate and select as best as possible, and to do all this in a reasonable way (e.g. few samples, many features $\rightarrow$ less complex model; select the least complex model with yet acceptable performance, etc.).
Because: in the end we will always have model error/over-/underfitting - it's the capability of detecting/measuring this error within our focus of interest to make reasonable choices that matters.
$^1$ a) each model has a bias and variance problem at the same time (we usually try to find the right trade-off to satisfy our needs). Models satisfying our requirements will necessarily still have bias and variance. b) Consider noisy data and non representative samples as reasons for overfitting. Each model will necessarily model noise as well as model a relation for which parts of the information is missing, so about which wrong assumptions will necessarily be made.
|
Overfitting: No silver bullet?
I agree with @ryan-zotti that searching hard enough does not necessarily lead to overfitting - or at least not to an amount so that we would call it overfitting. Let me try to state my point of view o
|
13,311
|
Overfitting: No silver bullet?
|
I think this is a very good question. I always want to observe the "U" shape curve in cross validation experiments with real data. However, my experience with real world data (~ 5 years in credit card transactions and education data) does not tell me over fitting can easily happen in huge amount (billion rows) real world data.
I often observe that you can try you best over fit the training set, but you cannot do too much (e.g., reduce the loss to 0), because the training set is really large and contains a lot of information and noise.
At the same time, you can try the most complicated model (without any regularization) on testing data, and it seems fine and even better than some with regularization.
Finally, I think my statements might be true only under the condition of you have billions data points in training. Intuitively, the data is much complex than you model so you will not over fit. For billion rows of data, even you are using a model with thousands of parameters, it is fine. At the same time you cannot afford the computation for building a model with million free parameters.
In my opinion this is also why neural network and deep learning got popular these days. Comparing to billions of images in Internet, any model you can afford training is not enough to over fit.
|
Overfitting: No silver bullet?
|
I think this is a very good question. I always want to observe the "U" shape curve in cross validation experiments with real data. However, my experience with real world data (~ 5 years in credit card
|
Overfitting: No silver bullet?
I think this is a very good question. I always want to observe the "U" shape curve in cross validation experiments with real data. However, my experience with real world data (~ 5 years in credit card transactions and education data) does not tell me over fitting can easily happen in huge amount (billion rows) real world data.
I often observe that you can try you best over fit the training set, but you cannot do too much (e.g., reduce the loss to 0), because the training set is really large and contains a lot of information and noise.
At the same time, you can try the most complicated model (without any regularization) on testing data, and it seems fine and even better than some with regularization.
Finally, I think my statements might be true only under the condition of you have billions data points in training. Intuitively, the data is much complex than you model so you will not over fit. For billion rows of data, even you are using a model with thousands of parameters, it is fine. At the same time you cannot afford the computation for building a model with million free parameters.
In my opinion this is also why neural network and deep learning got popular these days. Comparing to billions of images in Internet, any model you can afford training is not enough to over fit.
|
Overfitting: No silver bullet?
I think this is a very good question. I always want to observe the "U" shape curve in cross validation experiments with real data. However, my experience with real world data (~ 5 years in credit card
|
13,312
|
Overfitting: No silver bullet?
|
overfitting will happen if one searches for a model hard enough, unless one imposes restrictions on model complexity, period
I guess the simple answer is yes, if the search space (complexity of considered model class(es)) is large enough).
If data is the new oil, then note that oil is usually burnt during use.
Consider training a gazillion of random forests by tuning the random seed. One of them will by chance be optimal on the test set. Cross validation won't change this result in the end.
More recently, the "double decent" was discovered, see for example [1] and the review [2]. There is a whole new regime for overparametrized models that interpolate the training data. In this regime, the notion of overfitting is not adequate anymore. If a model is very much overparametrized, it may (or may not) have a better statistical risk (generalization error) than the optimal point in the classical bias-variance-trade-off regime.
[1] Belkin, Hsu, Xu "Two Models of Double Descent for Weak Features" 2020, https://epubs.siam.org/doi/10.1137/20M1336072
[2] Dar, Muthukumar, Baraniuk "A Farewell to the Bias-Variance Tradeoff? An Overview of the Theory of Overparameterized Machine Learning" 2021, https://arxiv.org/abs/2109.02355
|
Overfitting: No silver bullet?
|
overfitting will happen if one searches for a model hard enough, unless one imposes restrictions on model complexity, period
I guess the simple answer is yes, if the search space (complexity of consi
|
Overfitting: No silver bullet?
overfitting will happen if one searches for a model hard enough, unless one imposes restrictions on model complexity, period
I guess the simple answer is yes, if the search space (complexity of considered model class(es)) is large enough).
If data is the new oil, then note that oil is usually burnt during use.
Consider training a gazillion of random forests by tuning the random seed. One of them will by chance be optimal on the test set. Cross validation won't change this result in the end.
More recently, the "double decent" was discovered, see for example [1] and the review [2]. There is a whole new regime for overparametrized models that interpolate the training data. In this regime, the notion of overfitting is not adequate anymore. If a model is very much overparametrized, it may (or may not) have a better statistical risk (generalization error) than the optimal point in the classical bias-variance-trade-off regime.
[1] Belkin, Hsu, Xu "Two Models of Double Descent for Weak Features" 2020, https://epubs.siam.org/doi/10.1137/20M1336072
[2] Dar, Muthukumar, Baraniuk "A Farewell to the Bias-Variance Tradeoff? An Overview of the Theory of Overparameterized Machine Learning" 2021, https://arxiv.org/abs/2109.02355
|
Overfitting: No silver bullet?
overfitting will happen if one searches for a model hard enough, unless one imposes restrictions on model complexity, period
I guess the simple answer is yes, if the search space (complexity of consi
|
13,313
|
Overfitting: No silver bullet?
|
Already existing answers are mostly fine, but I add one small aspect that I haven't seen mentioned.
Let's assume you compare lots of models by cross-validation in a correct manner (avoiding information leakage, if necessary using nested CV, see answer by Wayne), and ultimately you choose the one that gives you the best result.
As you're optimising the CV-loss, the then achieved CV-loss will be optimistic for the true loss to be achieved by that model (optimism is worse the fewer observations you have). This is usually called "overfitting". This will automatically happen, unless you do a final CV evaluating only the winning model (which may require double nesting of the CV and is rarely done).
However, the chosen model is still the model estimated to be best by the CV, and therefore your best bet of being the best model. Granted, it may in fact not be the best, but it should still be seen as a good choice (and it normally will be, unless a too small data set causes a too large variance in CV-estimated loss).
We need to distinguish between overfitting as a problem for estimating the true prediction loss, and choosing a good model. With a reasonably large data set and CV run correctly (i.e., avoiding information leakage), it may be a problem for the former (which can be amended by adding another nesting level) but not the latter.
|
Overfitting: No silver bullet?
|
Already existing answers are mostly fine, but I add one small aspect that I haven't seen mentioned.
Let's assume you compare lots of models by cross-validation in a correct manner (avoiding informatio
|
Overfitting: No silver bullet?
Already existing answers are mostly fine, but I add one small aspect that I haven't seen mentioned.
Let's assume you compare lots of models by cross-validation in a correct manner (avoiding information leakage, if necessary using nested CV, see answer by Wayne), and ultimately you choose the one that gives you the best result.
As you're optimising the CV-loss, the then achieved CV-loss will be optimistic for the true loss to be achieved by that model (optimism is worse the fewer observations you have). This is usually called "overfitting". This will automatically happen, unless you do a final CV evaluating only the winning model (which may require double nesting of the CV and is rarely done).
However, the chosen model is still the model estimated to be best by the CV, and therefore your best bet of being the best model. Granted, it may in fact not be the best, but it should still be seen as a good choice (and it normally will be, unless a too small data set causes a too large variance in CV-estimated loss).
We need to distinguish between overfitting as a problem for estimating the true prediction loss, and choosing a good model. With a reasonably large data set and CV run correctly (i.e., avoiding information leakage), it may be a problem for the former (which can be amended by adding another nesting level) but not the latter.
|
Overfitting: No silver bullet?
Already existing answers are mostly fine, but I add one small aspect that I haven't seen mentioned.
Let's assume you compare lots of models by cross-validation in a correct manner (avoiding informatio
|
13,314
|
How to get predictions in terms of survival time from a Cox PH model?
|
The Cox Proportional Hazards model doesn't model the underlying hazard, which is what you'd need to predict survival time like that - this is both the model's great strength and one of it's major drawbacks.
If you are particularly interested in obtaining estimates of the probability of survival at particular time points, I would point you towards parametric survival models (aka accelerated failure time models). These are implemented in the survival package for R, and will give you parametric survival time distributions, wherein you can simply plug in the time you are interested in and get back a survival probability.
|
How to get predictions in terms of survival time from a Cox PH model?
|
The Cox Proportional Hazards model doesn't model the underlying hazard, which is what you'd need to predict survival time like that - this is both the model's great strength and one of it's major draw
|
How to get predictions in terms of survival time from a Cox PH model?
The Cox Proportional Hazards model doesn't model the underlying hazard, which is what you'd need to predict survival time like that - this is both the model's great strength and one of it's major drawbacks.
If you are particularly interested in obtaining estimates of the probability of survival at particular time points, I would point you towards parametric survival models (aka accelerated failure time models). These are implemented in the survival package for R, and will give you parametric survival time distributions, wherein you can simply plug in the time you are interested in and get back a survival probability.
|
How to get predictions in terms of survival time from a Cox PH model?
The Cox Proportional Hazards model doesn't model the underlying hazard, which is what you'd need to predict survival time like that - this is both the model's great strength and one of it's major draw
|
13,315
|
How to get predictions in terms of survival time from a Cox PH model?
|
@statBeginner Yes it will. It requires two steps:
x <- survfit(cox.ph.model, newdata = dataset)
dataset$Results <- summary(x)$table[,"median"]
but I am not sure if median time to survival is accurate enough.
|
How to get predictions in terms of survival time from a Cox PH model?
|
@statBeginner Yes it will. It requires two steps:
x <- survfit(cox.ph.model, newdata = dataset)
dataset$Results <- summary(x)$table[,"median"]
but I am not sure if median time to survival is accurate
|
How to get predictions in terms of survival time from a Cox PH model?
@statBeginner Yes it will. It requires two steps:
x <- survfit(cox.ph.model, newdata = dataset)
dataset$Results <- summary(x)$table[,"median"]
but I am not sure if median time to survival is accurate enough.
|
How to get predictions in terms of survival time from a Cox PH model?
@statBeginner Yes it will. It requires two steps:
x <- survfit(cox.ph.model, newdata = dataset)
dataset$Results <- summary(x)$table[,"median"]
but I am not sure if median time to survival is accurate
|
13,316
|
How to get predictions in terms of survival time from a Cox PH model?
|
Although I agree with these point, median survival IS clinically useful.
You might be interested in our work (and others) looking at using the median as a basis for survival intervals - we think these are more useful.
https://academic.oup.com/annonc/article/25/10/2014/2801274
|
How to get predictions in terms of survival time from a Cox PH model?
|
Although I agree with these point, median survival IS clinically useful.
You might be interested in our work (and others) looking at using the median as a basis for survival intervals - we think these
|
How to get predictions in terms of survival time from a Cox PH model?
Although I agree with these point, median survival IS clinically useful.
You might be interested in our work (and others) looking at using the median as a basis for survival intervals - we think these are more useful.
https://academic.oup.com/annonc/article/25/10/2014/2801274
|
How to get predictions in terms of survival time from a Cox PH model?
Although I agree with these point, median survival IS clinically useful.
You might be interested in our work (and others) looking at using the median as a basis for survival intervals - we think these
|
13,317
|
Is a p-value of 0.04993 enough to reject null hypothesis?
|
There are two issues here:
1) If you're doing a formal hypothesis test (and if you're going as far as quoting a p-value in my book you already are), what is the formal rejection rule?
When comparing test statistics to critical values, the critical value is in the rejection region. While this formality doesn't matter much when everything is continuous, it does matter when the distribution of the test statistic is discrete.
Correspondingly, when comparing p-values and significance levels, the rule is:
Reject if $p\leq\alpha$
Please note that, even if you rounded your p-value up to 0.05, indeed even if the $p$ value was exactly 0.05, formally, you should still reject.
2) In terms of 'what is our p-value telling us', then assuming you can even interpret a p-value as 'evidence against the null' (let's say that opinion on that is somewhat divided), 0.0499 and 0.0501 are not really saying different things about the data (effect sizes would tend to be almost identical).
My suggestion would be to (1) formally reject the null, and perhaps point out that even if it were exactly 0.05 it should still be rejected; (2) note that there's nothing particularly special about $\alpha = 0.05$ and it's very close to that borderline -- even a slightly smaller significance threshold would not lead to rejection.
|
Is a p-value of 0.04993 enough to reject null hypothesis?
|
There are two issues here:
1) If you're doing a formal hypothesis test (and if you're going as far as quoting a p-value in my book you already are), what is the formal rejection rule?
When comparing t
|
Is a p-value of 0.04993 enough to reject null hypothesis?
There are two issues here:
1) If you're doing a formal hypothesis test (and if you're going as far as quoting a p-value in my book you already are), what is the formal rejection rule?
When comparing test statistics to critical values, the critical value is in the rejection region. While this formality doesn't matter much when everything is continuous, it does matter when the distribution of the test statistic is discrete.
Correspondingly, when comparing p-values and significance levels, the rule is:
Reject if $p\leq\alpha$
Please note that, even if you rounded your p-value up to 0.05, indeed even if the $p$ value was exactly 0.05, formally, you should still reject.
2) In terms of 'what is our p-value telling us', then assuming you can even interpret a p-value as 'evidence against the null' (let's say that opinion on that is somewhat divided), 0.0499 and 0.0501 are not really saying different things about the data (effect sizes would tend to be almost identical).
My suggestion would be to (1) formally reject the null, and perhaps point out that even if it were exactly 0.05 it should still be rejected; (2) note that there's nothing particularly special about $\alpha = 0.05$ and it's very close to that borderline -- even a slightly smaller significance threshold would not lead to rejection.
|
Is a p-value of 0.04993 enough to reject null hypothesis?
There are two issues here:
1) If you're doing a formal hypothesis test (and if you're going as far as quoting a p-value in my book you already are), what is the formal rejection rule?
When comparing t
|
13,318
|
Is a p-value of 0.04993 enough to reject null hypothesis?
|
It lies in the eye of the beholder.
Formally, if there is a strict decision rule for your problem, follow it. This means $\alpha$ is given. However, I am not aware of any problem where this is the case (though setting $\alpha=0.05$ is what many practitioners do after Statistics101).
So it really boils down to what AlefSin commented before. There cannot be a "correct answer" to your question. Report what you got, rounded or not.
There is a huge literature on the "significance of significance"; see for example the recent paper of one of the leading German statisticians Walter Krämer on "The cult of statistical significance - What economists should and should not do to make their data talk", Schmollers Jahrbuch 131, 455-468, 2011.
|
Is a p-value of 0.04993 enough to reject null hypothesis?
|
It lies in the eye of the beholder.
Formally, if there is a strict decision rule for your problem, follow it. This means $\alpha$ is given. However, I am not aware of any problem where this is the cas
|
Is a p-value of 0.04993 enough to reject null hypothesis?
It lies in the eye of the beholder.
Formally, if there is a strict decision rule for your problem, follow it. This means $\alpha$ is given. However, I am not aware of any problem where this is the case (though setting $\alpha=0.05$ is what many practitioners do after Statistics101).
So it really boils down to what AlefSin commented before. There cannot be a "correct answer" to your question. Report what you got, rounded or not.
There is a huge literature on the "significance of significance"; see for example the recent paper of one of the leading German statisticians Walter Krämer on "The cult of statistical significance - What economists should and should not do to make their data talk", Schmollers Jahrbuch 131, 455-468, 2011.
|
Is a p-value of 0.04993 enough to reject null hypothesis?
It lies in the eye of the beholder.
Formally, if there is a strict decision rule for your problem, follow it. This means $\alpha$ is given. However, I am not aware of any problem where this is the cas
|
13,319
|
Is a p-value of 0.04993 enough to reject null hypothesis?
|
In light of the assumptions of your model, you should reject the null because dichotomizing claims based on hypothesis tests have clear epistemological and pragmatic functions. But never forget that: “No isolated experiment, however significant in itself, can suffice for the experimental demonstration of any natural phenomenon; for the ‘one chance in a million’ will undoubtedly occur, with no less and no more than its appropriate frequency, however surprised we may be that it should occur to us. In order to assert that a natural phenomenon is experimentally demonstrable we need, not an isolated record, but a reliable method of procedure. In relation to the test of significance, we may say that a phenomenon is experimentally demonstrable when we know how to conduct an experiment which will rarely fail to give us a statistically significant result.” Fisher, R. A. (1935). The design of experiments. Oliver & Boyd.
In the pragmatic sense, you should reject. In the statistical sense, you need more data.
|
Is a p-value of 0.04993 enough to reject null hypothesis?
|
In light of the assumptions of your model, you should reject the null because dichotomizing claims based on hypothesis tests have clear epistemological and pragmatic functions. But never forget that:
|
Is a p-value of 0.04993 enough to reject null hypothesis?
In light of the assumptions of your model, you should reject the null because dichotomizing claims based on hypothesis tests have clear epistemological and pragmatic functions. But never forget that: “No isolated experiment, however significant in itself, can suffice for the experimental demonstration of any natural phenomenon; for the ‘one chance in a million’ will undoubtedly occur, with no less and no more than its appropriate frequency, however surprised we may be that it should occur to us. In order to assert that a natural phenomenon is experimentally demonstrable we need, not an isolated record, but a reliable method of procedure. In relation to the test of significance, we may say that a phenomenon is experimentally demonstrable when we know how to conduct an experiment which will rarely fail to give us a statistically significant result.” Fisher, R. A. (1935). The design of experiments. Oliver & Boyd.
In the pragmatic sense, you should reject. In the statistical sense, you need more data.
|
Is a p-value of 0.04993 enough to reject null hypothesis?
In light of the assumptions of your model, you should reject the null because dichotomizing claims based on hypothesis tests have clear epistemological and pragmatic functions. But never forget that:
|
13,320
|
Is a p-value of 0.04993 enough to reject null hypothesis?
|
The 0.05 threshold is a hurdle that you have set for yourself in order to enforce a degree of self-skepticism about your alternative hypothesis. It somewhat weakens that self-skepticism if you change the definition of the threshold after seeing the result. The real question is why you are performing an NHST, what do you think it tells you (probably not very much in most cases)?
The threshold should be set according to the nature of the experiment, so there is no one-true threshold anyway. It would have been just as valid to set the threshold at 0.04992 (bit of an odd choice) before performing the NHST, so the difference isn't really meaningful (except in what it tells us about our self-skepticism).
You could always just report the p-value and let the reader draw their own conclusions (i.e. not reject or accept anything).
|
Is a p-value of 0.04993 enough to reject null hypothesis?
|
The 0.05 threshold is a hurdle that you have set for yourself in order to enforce a degree of self-skepticism about your alternative hypothesis. It somewhat weakens that self-skepticism if you change
|
Is a p-value of 0.04993 enough to reject null hypothesis?
The 0.05 threshold is a hurdle that you have set for yourself in order to enforce a degree of self-skepticism about your alternative hypothesis. It somewhat weakens that self-skepticism if you change the definition of the threshold after seeing the result. The real question is why you are performing an NHST, what do you think it tells you (probably not very much in most cases)?
The threshold should be set according to the nature of the experiment, so there is no one-true threshold anyway. It would have been just as valid to set the threshold at 0.04992 (bit of an odd choice) before performing the NHST, so the difference isn't really meaningful (except in what it tells us about our self-skepticism).
You could always just report the p-value and let the reader draw their own conclusions (i.e. not reject or accept anything).
|
Is a p-value of 0.04993 enough to reject null hypothesis?
The 0.05 threshold is a hurdle that you have set for yourself in order to enforce a degree of self-skepticism about your alternative hypothesis. It somewhat weakens that self-skepticism if you change
|
13,321
|
Is a p-value of 0.04993 enough to reject null hypothesis?
|
The answer is absolutely not. There is no "in the eye of the beholder", there is no argument, the answer is no, your data is not significant at the $p=0.05$ level. (Ok, there is one way out, but its a very narrow path.)
The key problem is this phrase: "We came across some data...".
This suggests that you looked at several other statistical hypothesis, and rejected them because they did not reach your significance level. You found one hypothesis that (barely) met your standard, and you are wondering whether it is significant. Unless your $p$ value accounts for such multiple hypothesis testing, it is overly optimistic. Given that you are just three decimal points away from your threshold, considering even one additional hypothesis would surely push $p$ over the line.
There is a name for this sort of statistical malfeasance: data dredging. I'm ambivalent about reporting it in the paper as an interesting hypothesis; does it have some physical reason you expect it to hold?
There is, however, one way out. Perhaps you decided a priori to perform just this one test on just this one data set. You wrote that down in your lab notebook, in front of someone so that you could prove it later. Then you did your test.
If you did this, then your result is valid at the $p=0.05$ level, and you can back it up to skeptics like me. Otherwise, sorry, it is not a statistically significant result.
|
Is a p-value of 0.04993 enough to reject null hypothesis?
|
The answer is absolutely not. There is no "in the eye of the beholder", there is no argument, the answer is no, your data is not significant at the $p=0.05$ level. (Ok, there is one way out, but its
|
Is a p-value of 0.04993 enough to reject null hypothesis?
The answer is absolutely not. There is no "in the eye of the beholder", there is no argument, the answer is no, your data is not significant at the $p=0.05$ level. (Ok, there is one way out, but its a very narrow path.)
The key problem is this phrase: "We came across some data...".
This suggests that you looked at several other statistical hypothesis, and rejected them because they did not reach your significance level. You found one hypothesis that (barely) met your standard, and you are wondering whether it is significant. Unless your $p$ value accounts for such multiple hypothesis testing, it is overly optimistic. Given that you are just three decimal points away from your threshold, considering even one additional hypothesis would surely push $p$ over the line.
There is a name for this sort of statistical malfeasance: data dredging. I'm ambivalent about reporting it in the paper as an interesting hypothesis; does it have some physical reason you expect it to hold?
There is, however, one way out. Perhaps you decided a priori to perform just this one test on just this one data set. You wrote that down in your lab notebook, in front of someone so that you could prove it later. Then you did your test.
If you did this, then your result is valid at the $p=0.05$ level, and you can back it up to skeptics like me. Otherwise, sorry, it is not a statistically significant result.
|
Is a p-value of 0.04993 enough to reject null hypothesis?
The answer is absolutely not. There is no "in the eye of the beholder", there is no argument, the answer is no, your data is not significant at the $p=0.05$ level. (Ok, there is one way out, but its
|
13,322
|
How can it be trapped in a saddle point?
|
Take a look at the image below from Off Convex. In a convex function (leftmost image), there is only one local minimum, which is also the global minimum. But in a non-convex function (rightmost image), there may be multiple local minima and often joining two local minima is a saddle point. If you are approaching from a higher point, the gradient is comparatively flatter, and you risk getting stuck there, especially if you are moving only in one direction.
Now the thing is, whether you are optimizing using mini-batch or stochastic gradient descent, the underlying non-convex function is the same, and the gradient is a property of the this function. When doing mini-batch, you consider many samples at a time and take the gradient step averaged over all of them. This reduces variance. But if the average gradient direction is still pointing in the same direction as the saddle point, then you still risk getting stuck there. The analogy is, if you're taking 2 steps forward and 1 step back, averaging over those, you ultimately end up taking 1 step forward.
If you perform SGD instead, you take all the steps one after the other, but if you're still moving in a single direction, you can reach the saddle point and find that the gradient on all sides is fairly flat and the step size is too small to go over this flat part. This doesn't have anything to do with whether you considered a bunch of points at once, or one by one in random order.
Take a look at the visualization here. Even with SGD, if the fluctuations occur only along one dimension, with the steps getting smaller and smaller, it would converge at the saddle point. In this case, the mini-batch method would just reduce the amount of fluctuation but would not be able to change the gradient's direction.
SGD can sometimes break out of simple saddle points, if the fluctuations are along other directions, and if the step size is large enough for it to go over the flatness. But sometimes the saddle regions can be fairly complex, such as in the image below.
The way methods like momentum, ADAGRAD, Adam etc are able to break out of this, is by considering the past gradients. Consider momentum,
$$
v_t = \gamma v_{t-1} + \eta \nabla_{theta} J(\theta)
$$
which adds a portion of the last gradient, $v_{t-1}$. In case you've just been going back and forth in one direction, essentially changing signs, it ends up dampening your progress. While if there has consistently been positive progress in one direction, it ends up building up and going down that way.
|
How can it be trapped in a saddle point?
|
Take a look at the image below from Off Convex. In a convex function (leftmost image), there is only one local minimum, which is also the global minimum. But in a non-convex function (rightmost image)
|
How can it be trapped in a saddle point?
Take a look at the image below from Off Convex. In a convex function (leftmost image), there is only one local minimum, which is also the global minimum. But in a non-convex function (rightmost image), there may be multiple local minima and often joining two local minima is a saddle point. If you are approaching from a higher point, the gradient is comparatively flatter, and you risk getting stuck there, especially if you are moving only in one direction.
Now the thing is, whether you are optimizing using mini-batch or stochastic gradient descent, the underlying non-convex function is the same, and the gradient is a property of the this function. When doing mini-batch, you consider many samples at a time and take the gradient step averaged over all of them. This reduces variance. But if the average gradient direction is still pointing in the same direction as the saddle point, then you still risk getting stuck there. The analogy is, if you're taking 2 steps forward and 1 step back, averaging over those, you ultimately end up taking 1 step forward.
If you perform SGD instead, you take all the steps one after the other, but if you're still moving in a single direction, you can reach the saddle point and find that the gradient on all sides is fairly flat and the step size is too small to go over this flat part. This doesn't have anything to do with whether you considered a bunch of points at once, or one by one in random order.
Take a look at the visualization here. Even with SGD, if the fluctuations occur only along one dimension, with the steps getting smaller and smaller, it would converge at the saddle point. In this case, the mini-batch method would just reduce the amount of fluctuation but would not be able to change the gradient's direction.
SGD can sometimes break out of simple saddle points, if the fluctuations are along other directions, and if the step size is large enough for it to go over the flatness. But sometimes the saddle regions can be fairly complex, such as in the image below.
The way methods like momentum, ADAGRAD, Adam etc are able to break out of this, is by considering the past gradients. Consider momentum,
$$
v_t = \gamma v_{t-1} + \eta \nabla_{theta} J(\theta)
$$
which adds a portion of the last gradient, $v_{t-1}$. In case you've just been going back and forth in one direction, essentially changing signs, it ends up dampening your progress. While if there has consistently been positive progress in one direction, it ends up building up and going down that way.
|
How can it be trapped in a saddle point?
Take a look at the image below from Off Convex. In a convex function (leftmost image), there is only one local minimum, which is also the global minimum. But in a non-convex function (rightmost image)
|
13,323
|
How can it be trapped in a saddle point?
|
It should not.
[1] has shown that gradient descent with random initialization and appropriate constant step size does not converge to a saddle point. It is a long discussion but to give you an idea of why see the following example:
$$f(x,y)=\frac12 x^2+ \frac14y^4 - \frac12y^2$$
The critical points are
$$z_1=\begin{bmatrix}0\\0\end{bmatrix}, z_2=\begin{bmatrix}0\\1\end{bmatrix}, z_3=\begin{bmatrix}0\\-1\end{bmatrix}$$.
The points $z_2$ and $z_3$ are isolated local minima, and $z_1$ is a saddle point.
Gradient descent initialized from any point of the form $z_0=\begin{bmatrix}x\\0\end{bmatrix}$ converges to the saddle point $z_1$. Any other initial point either diverges or converges to a local minimum, so the stable set of $z_1$ is the $x$-axis, which is a zero measure set in $\mathbb{R}^2$. By computing the Hessian,
$$\nabla^2f(x,y)=\begin{bmatrix}1&&0\\0&&3y^2-1\end{bmatrix}$$
we find that $\nabla^2f(z_1)$ has one positive eigenvalue with eigenvector that spans the $x$-axis, thus agreeing with our above characterization of the stable set. If the initial point is chosen randomly, there is zero probability
of initializing on the $x$-axis and thus zero probability of converging to the saddle point $z_1$.
|
How can it be trapped in a saddle point?
|
It should not.
[1] has shown that gradient descent with random initialization and appropriate constant step size does not converge to a saddle point. It is a long discussion but to give you an idea of
|
How can it be trapped in a saddle point?
It should not.
[1] has shown that gradient descent with random initialization and appropriate constant step size does not converge to a saddle point. It is a long discussion but to give you an idea of why see the following example:
$$f(x,y)=\frac12 x^2+ \frac14y^4 - \frac12y^2$$
The critical points are
$$z_1=\begin{bmatrix}0\\0\end{bmatrix}, z_2=\begin{bmatrix}0\\1\end{bmatrix}, z_3=\begin{bmatrix}0\\-1\end{bmatrix}$$.
The points $z_2$ and $z_3$ are isolated local minima, and $z_1$ is a saddle point.
Gradient descent initialized from any point of the form $z_0=\begin{bmatrix}x\\0\end{bmatrix}$ converges to the saddle point $z_1$. Any other initial point either diverges or converges to a local minimum, so the stable set of $z_1$ is the $x$-axis, which is a zero measure set in $\mathbb{R}^2$. By computing the Hessian,
$$\nabla^2f(x,y)=\begin{bmatrix}1&&0\\0&&3y^2-1\end{bmatrix}$$
we find that $\nabla^2f(z_1)$ has one positive eigenvalue with eigenvector that spans the $x$-axis, thus agreeing with our above characterization of the stable set. If the initial point is chosen randomly, there is zero probability
of initializing on the $x$-axis and thus zero probability of converging to the saddle point $z_1$.
|
How can it be trapped in a saddle point?
It should not.
[1] has shown that gradient descent with random initialization and appropriate constant step size does not converge to a saddle point. It is a long discussion but to give you an idea of
|
13,324
|
How can it be trapped in a saddle point?
|
If you go to the referenced paper (they also emperically show how their saddle-free approach does indeed improve upon mini-batch SGD) they state:
A step of the gradient descent method always points in the right direction close to a saddle point...and so small steps are taken in directions corresponding to eigenvalues of small absolute value.
They also note the presence of "plateaus" near saddle points (in other words, the saddle is not steep) - in these cases, taking too small steps would indeed result in premature convergence before having escaped the saddle region. Since this is a non-convex optimization, the convergence of the learning rate would make this worse.
It does seem possible that one could try an iterative approach, where one restarts the mini-batch SGD once it completes (i.e., resetting the learning rate) to see if one can escape the problematic region.
|
How can it be trapped in a saddle point?
|
If you go to the referenced paper (they also emperically show how their saddle-free approach does indeed improve upon mini-batch SGD) they state:
A step of the gradient descent method always points i
|
How can it be trapped in a saddle point?
If you go to the referenced paper (they also emperically show how their saddle-free approach does indeed improve upon mini-batch SGD) they state:
A step of the gradient descent method always points in the right direction close to a saddle point...and so small steps are taken in directions corresponding to eigenvalues of small absolute value.
They also note the presence of "plateaus" near saddle points (in other words, the saddle is not steep) - in these cases, taking too small steps would indeed result in premature convergence before having escaped the saddle region. Since this is a non-convex optimization, the convergence of the learning rate would make this worse.
It does seem possible that one could try an iterative approach, where one restarts the mini-batch SGD once it completes (i.e., resetting the learning rate) to see if one can escape the problematic region.
|
How can it be trapped in a saddle point?
If you go to the referenced paper (they also emperically show how their saddle-free approach does indeed improve upon mini-batch SGD) they state:
A step of the gradient descent method always points i
|
13,325
|
How can it be trapped in a saddle point?
|
I think the problem is that while approaching a saddle point you enter a plateau, i.e. an area with low (in absolute value) gradients. Especially when you're approaching from the ridge. So your algorithm decreases the step size. With a decreased step size now all gradients (in all directions) are small in absolute value. So the algorithm stops, thinking it's at the minimum.
If you don't decrease the steps then you'll be jumping over the minimum, and missing them a lot. You must decrease the step size somehow.
|
How can it be trapped in a saddle point?
|
I think the problem is that while approaching a saddle point you enter a plateau, i.e. an area with low (in absolute value) gradients. Especially when you're approaching from the ridge. So your algori
|
How can it be trapped in a saddle point?
I think the problem is that while approaching a saddle point you enter a plateau, i.e. an area with low (in absolute value) gradients. Especially when you're approaching from the ridge. So your algorithm decreases the step size. With a decreased step size now all gradients (in all directions) are small in absolute value. So the algorithm stops, thinking it's at the minimum.
If you don't decrease the steps then you'll be jumping over the minimum, and missing them a lot. You must decrease the step size somehow.
|
How can it be trapped in a saddle point?
I think the problem is that while approaching a saddle point you enter a plateau, i.e. an area with low (in absolute value) gradients. Especially when you're approaching from the ridge. So your algori
|
13,326
|
XGBoost can handle missing data in the forecasting phase
|
xgboost decides at training time whether missing values go into the right or left node. It chooses which to minimise loss. If there are no missing values at training time, it defaults to sending any new missings to the right node.
If there is signal in the distribution of your missings, then this is essentially fit by the model.
Be careful if your scoring data has its missing values distributed differently from your training data. xgboost's missing handling is convenient but doesn't protect against masking.
Source: this answer
|
XGBoost can handle missing data in the forecasting phase
|
xgboost decides at training time whether missing values go into the right or left node. It chooses which to minimise loss. If there are no missing values at training time, it defaults to sending any n
|
XGBoost can handle missing data in the forecasting phase
xgboost decides at training time whether missing values go into the right or left node. It chooses which to minimise loss. If there are no missing values at training time, it defaults to sending any new missings to the right node.
If there is signal in the distribution of your missings, then this is essentially fit by the model.
Be careful if your scoring data has its missing values distributed differently from your training data. xgboost's missing handling is convenient but doesn't protect against masking.
Source: this answer
|
XGBoost can handle missing data in the forecasting phase
xgboost decides at training time whether missing values go into the right or left node. It chooses which to minimise loss. If there are no missing values at training time, it defaults to sending any n
|
13,327
|
What would be an example of a really simple model with an intractable likelihood?
|
Two distributions that are used a lot in the literature are:
The g-and-k distribution. This is defined by its quantile function (inverse cdf) but has an intractable density. Rayner and MacGillivray (2002) is a good overview of these, and one of many ABC papers which use it as a toy example is Drovandi and Pettitt (2011).
Alpha stable distributions. These are defined by their characteristic function but have an intractable density except for a couple of special cases. This has applications in finance and is often used in sequential ABC papers, for example Yildirim et al (2013).
|
What would be an example of a really simple model with an intractable likelihood?
|
Two distributions that are used a lot in the literature are:
The g-and-k distribution. This is defined by its quantile function (inverse cdf) but has an intractable density. Rayner and MacGillivray (
|
What would be an example of a really simple model with an intractable likelihood?
Two distributions that are used a lot in the literature are:
The g-and-k distribution. This is defined by its quantile function (inverse cdf) but has an intractable density. Rayner and MacGillivray (2002) is a good overview of these, and one of many ABC papers which use it as a toy example is Drovandi and Pettitt (2011).
Alpha stable distributions. These are defined by their characteristic function but have an intractable density except for a couple of special cases. This has applications in finance and is often used in sequential ABC papers, for example Yildirim et al (2013).
|
What would be an example of a really simple model with an intractable likelihood?
Two distributions that are used a lot in the literature are:
The g-and-k distribution. This is defined by its quantile function (inverse cdf) but has an intractable density. Rayner and MacGillivray (
|
13,328
|
What would be an example of a really simple model with an intractable likelihood?
|
One example I came through a few weeks ago and quite like for its simplicity is the following one: given an original normal dataset
$$
x_1,\ldots,x_n\stackrel{\text{iid}}{\sim}\text{N}(\theta,\sigma^2)\,,
$$
the reported data is (alas!) made of the two-dimensional summary
$$
S(x_1,\ldots,x_n)=(\text{med}(x_1,\ldots,x_n),\text{mad}(x_1,\ldots,x_n))\,,
$$
which is not sufficient and which does not have a closed form joint density.
|
What would be an example of a really simple model with an intractable likelihood?
|
One example I came through a few weeks ago and quite like for its simplicity is the following one: given an original normal dataset
$$
x_1,\ldots,x_n\stackrel{\text{iid}}{\sim}\text{N}(\theta,\sigma^2
|
What would be an example of a really simple model with an intractable likelihood?
One example I came through a few weeks ago and quite like for its simplicity is the following one: given an original normal dataset
$$
x_1,\ldots,x_n\stackrel{\text{iid}}{\sim}\text{N}(\theta,\sigma^2)\,,
$$
the reported data is (alas!) made of the two-dimensional summary
$$
S(x_1,\ldots,x_n)=(\text{med}(x_1,\ldots,x_n),\text{mad}(x_1,\ldots,x_n))\,,
$$
which is not sufficient and which does not have a closed form joint density.
|
What would be an example of a really simple model with an intractable likelihood?
One example I came through a few weeks ago and quite like for its simplicity is the following one: given an original normal dataset
$$
x_1,\ldots,x_n\stackrel{\text{iid}}{\sim}\text{N}(\theta,\sigma^2
|
13,329
|
Beta distribution fitting in Scipy
|
Despite an apparent lack of documentation on the output of beta.fit, it does output in the following order:
$\alpha$, $\beta$, loc (lower limit), scale (upper limit - lower limit)
|
Beta distribution fitting in Scipy
|
Despite an apparent lack of documentation on the output of beta.fit, it does output in the following order:
$\alpha$, $\beta$, loc (lower limit), scale (upper limit - lower limit)
|
Beta distribution fitting in Scipy
Despite an apparent lack of documentation on the output of beta.fit, it does output in the following order:
$\alpha$, $\beta$, loc (lower limit), scale (upper limit - lower limit)
|
Beta distribution fitting in Scipy
Despite an apparent lack of documentation on the output of beta.fit, it does output in the following order:
$\alpha$, $\beta$, loc (lower limit), scale (upper limit - lower limit)
|
13,330
|
To what extent is the distinction between correlation and causation relevant to Google?
|
The simple answer is that Google (or anyone) should care about the distinction to the extent that they intend to intervene. Causal knowledge tells you about the effects of interventions (actions) in a given domain.
If, for example, Google wishes to increase click-through rates on ads, increase the number of users of GMail or Google+, or induce users to use Google rather than Bing, then they need to know the effects of potential actions (e.g., increasing the font size of ads, promoting Google+ in print magazines, or publicizing differences between Google and Bing search results, respectively). Correlation is good enough to make Google's search engine work well, but for their other systems (and their business overall) the distinction often matters.
It is worth noting that Google (and many firms with web-based businesses) are constantly running online experiments. This is of the simplest and best ways to identify and estimate causal dependencies.
|
To what extent is the distinction between correlation and causation relevant to Google?
|
The simple answer is that Google (or anyone) should care about the distinction to the extent that they intend to intervene. Causal knowledge tells you about the effects of interventions (actions) in
|
To what extent is the distinction between correlation and causation relevant to Google?
The simple answer is that Google (or anyone) should care about the distinction to the extent that they intend to intervene. Causal knowledge tells you about the effects of interventions (actions) in a given domain.
If, for example, Google wishes to increase click-through rates on ads, increase the number of users of GMail or Google+, or induce users to use Google rather than Bing, then they need to know the effects of potential actions (e.g., increasing the font size of ads, promoting Google+ in print magazines, or publicizing differences between Google and Bing search results, respectively). Correlation is good enough to make Google's search engine work well, but for their other systems (and their business overall) the distinction often matters.
It is worth noting that Google (and many firms with web-based businesses) are constantly running online experiments. This is of the simplest and best ways to identify and estimate causal dependencies.
|
To what extent is the distinction between correlation and causation relevant to Google?
The simple answer is that Google (or anyone) should care about the distinction to the extent that they intend to intervene. Causal knowledge tells you about the effects of interventions (actions) in
|
13,331
|
To what extent is the distinction between correlation and causation relevant to Google?
|
First, it is just a quip and is incorrect. Google has a lot of very talented statisticians, information retrieval experts, linguists, economists, some psychologists, and others. These folks spend a lot of time educating a lot of non-statisticians about the difference between correlation and causation. Given that it's a large organization, there may be pockets, even big pockets, of ignorance, but the assertion is definitely false. Moreover, a lot of that education faces customers, especially advertisers.
Deeper answer:
The difference is extremely important. Just look at search results ranking, and allow me to extend beyond just "correlation" to include measures of similarity, scoring functions, etc. Some pages are measured to be good results for certain queries. These have a variety of predictor features that are important to their ranking. In contrast to these good pages that are good results for queries is a set of webpages that are pages that are very bad results for the same queries. However, creators of those pages spend a lot of effort to make them look like good pages from a numerical point of view, such as text matches, internet linkage, and more. However, just because these pages are numerically "similar" to good pages doesn't mean that these are, in fact, good pages. Therefore, Google has invested and will continue to invest a lot of effort determining what reasonable features distinguish (separate) good and bad pages.
This isn't quite correlation and causation, but it's deeper than that. Good pages for certain queries may map into a numerical space where they appear similar and distinct from many irrelevant or bad pages, but just because results are in the same region of the feature space does not imply they come from the same "high quality" subset of the web.
Simpler answer:
A very simple perspective is to address the ranking of the results. The best result should be first, but just because something is ranked first doesn't mean that it's the best result. By some metrics of scoring, you may find that Google's ranking is correlated to a golden standard of quality assessments, but that doesn't mean that their ranking implies that the results are truly in this order in terms of quality and relevance.
Update (third answer):
Over time, there is another aspect that affects all of us: it is that the top Google result may be deemed authoritative, because it is the top result on Google. Although link analysis (e.g. "PageRank" - one method for link analysis) is an attempt to reflect perceived authoritativeness, over time new pages on a topic may simply reinforce that link structure by linking to the top result on Google. A newer page that is more authoritative has a problem with the headstart relative to the first result. As Google wants to deliver the most relevant page at present, a variety of factors, including a so-called "rich-get-richer" phenomenon, arise due to an implicit effect of correlation on perceived causation.
Update (fourth answer):
I realized (for a comment below) that it might be useful to read Plato's Allegory of the Cave to get a sense of how to interpret correlation and causation as a result of "reflections/projections" of reality & how we (or our machines) perceive it. Correlation, strictly limited to Pearson's Correlation, is far too limited as an interpretation of the issue of misunderstanding association (broader than just correlation) and causation.
|
To what extent is the distinction between correlation and causation relevant to Google?
|
First, it is just a quip and is incorrect. Google has a lot of very talented statisticians, information retrieval experts, linguists, economists, some psychologists, and others. These folks spend a
|
To what extent is the distinction between correlation and causation relevant to Google?
First, it is just a quip and is incorrect. Google has a lot of very talented statisticians, information retrieval experts, linguists, economists, some psychologists, and others. These folks spend a lot of time educating a lot of non-statisticians about the difference between correlation and causation. Given that it's a large organization, there may be pockets, even big pockets, of ignorance, but the assertion is definitely false. Moreover, a lot of that education faces customers, especially advertisers.
Deeper answer:
The difference is extremely important. Just look at search results ranking, and allow me to extend beyond just "correlation" to include measures of similarity, scoring functions, etc. Some pages are measured to be good results for certain queries. These have a variety of predictor features that are important to their ranking. In contrast to these good pages that are good results for queries is a set of webpages that are pages that are very bad results for the same queries. However, creators of those pages spend a lot of effort to make them look like good pages from a numerical point of view, such as text matches, internet linkage, and more. However, just because these pages are numerically "similar" to good pages doesn't mean that these are, in fact, good pages. Therefore, Google has invested and will continue to invest a lot of effort determining what reasonable features distinguish (separate) good and bad pages.
This isn't quite correlation and causation, but it's deeper than that. Good pages for certain queries may map into a numerical space where they appear similar and distinct from many irrelevant or bad pages, but just because results are in the same region of the feature space does not imply they come from the same "high quality" subset of the web.
Simpler answer:
A very simple perspective is to address the ranking of the results. The best result should be first, but just because something is ranked first doesn't mean that it's the best result. By some metrics of scoring, you may find that Google's ranking is correlated to a golden standard of quality assessments, but that doesn't mean that their ranking implies that the results are truly in this order in terms of quality and relevance.
Update (third answer):
Over time, there is another aspect that affects all of us: it is that the top Google result may be deemed authoritative, because it is the top result on Google. Although link analysis (e.g. "PageRank" - one method for link analysis) is an attempt to reflect perceived authoritativeness, over time new pages on a topic may simply reinforce that link structure by linking to the top result on Google. A newer page that is more authoritative has a problem with the headstart relative to the first result. As Google wants to deliver the most relevant page at present, a variety of factors, including a so-called "rich-get-richer" phenomenon, arise due to an implicit effect of correlation on perceived causation.
Update (fourth answer):
I realized (for a comment below) that it might be useful to read Plato's Allegory of the Cave to get a sense of how to interpret correlation and causation as a result of "reflections/projections" of reality & how we (or our machines) perceive it. Correlation, strictly limited to Pearson's Correlation, is far too limited as an interpretation of the issue of misunderstanding association (broader than just correlation) and causation.
|
To what extent is the distinction between correlation and causation relevant to Google?
First, it is just a quip and is incorrect. Google has a lot of very talented statisticians, information retrieval experts, linguists, economists, some psychologists, and others. These folks spend a
|
13,332
|
To what extent is the distinction between correlation and causation relevant to Google?
|
Author of the quip here.
The comment was partially inspired by a talk by David Mease (at Google), where he said, and I paraphrase, car insurance companies don't care if being male causes more accidents, as long as it's correlated, they have to charge more. It is, in fact, impossible to change someone's gender in an experiment, so the cause could never be shown.
In the same way, Google doesn't really need to care if the color red makes someone click an ad, if it's correlated with more clicks, they can charge more for that ad.
It was also inspired by this article in Wired: The End of Theory: The Data Deluge Makes the Scientific Method Obsolete. A quote:
"Google's founding philosophy is that we don't know why this page is better than that one: If the statistics of incoming links say it is, that's good enough."
Obviously, Google has many very smart people that know the difference between causation and correlation, but in their case, they can make plenty of money not caring about it.
|
To what extent is the distinction between correlation and causation relevant to Google?
|
Author of the quip here.
The comment was partially inspired by a talk by David Mease (at Google), where he said, and I paraphrase, car insurance companies don't care if being male causes more accident
|
To what extent is the distinction between correlation and causation relevant to Google?
Author of the quip here.
The comment was partially inspired by a talk by David Mease (at Google), where he said, and I paraphrase, car insurance companies don't care if being male causes more accidents, as long as it's correlated, they have to charge more. It is, in fact, impossible to change someone's gender in an experiment, so the cause could never be shown.
In the same way, Google doesn't really need to care if the color red makes someone click an ad, if it's correlated with more clicks, they can charge more for that ad.
It was also inspired by this article in Wired: The End of Theory: The Data Deluge Makes the Scientific Method Obsolete. A quote:
"Google's founding philosophy is that we don't know why this page is better than that one: If the statistics of incoming links say it is, that's good enough."
Obviously, Google has many very smart people that know the difference between causation and correlation, but in their case, they can make plenty of money not caring about it.
|
To what extent is the distinction between correlation and causation relevant to Google?
Author of the quip here.
The comment was partially inspired by a talk by David Mease (at Google), where he said, and I paraphrase, car insurance companies don't care if being male causes more accident
|
13,333
|
To what extent is the distinction between correlation and causation relevant to Google?
|
I agree with David: The difference matters if you intend to intervene, and Google can test the results of interventions by running controlled experiments. (The optimal schedule of such experiments depends on your set of causal hypotheses, which you learn from previous experiments plus observational data, so correlations are still useful!)
There's a second reason Google might want to learn causal relationships. Causal relationships are more robust to other players' interventions. Interventions tend to be local, so they might change one part of the causal network but leave all other causal mechanisms unchanged. By contrast, predictive relationships can fail if a distant causal link is broken. The internet is constantly changing, and Google should be interested in which features of the online environment are more robust to those changes.
|
To what extent is the distinction between correlation and causation relevant to Google?
|
I agree with David: The difference matters if you intend to intervene, and Google can test the results of interventions by running controlled experiments. (The optimal schedule of such experiments dep
|
To what extent is the distinction between correlation and causation relevant to Google?
I agree with David: The difference matters if you intend to intervene, and Google can test the results of interventions by running controlled experiments. (The optimal schedule of such experiments depends on your set of causal hypotheses, which you learn from previous experiments plus observational data, so correlations are still useful!)
There's a second reason Google might want to learn causal relationships. Causal relationships are more robust to other players' interventions. Interventions tend to be local, so they might change one part of the causal network but leave all other causal mechanisms unchanged. By contrast, predictive relationships can fail if a distant causal link is broken. The internet is constantly changing, and Google should be interested in which features of the online environment are more robust to those changes.
|
To what extent is the distinction between correlation and causation relevant to Google?
I agree with David: The difference matters if you intend to intervene, and Google can test the results of interventions by running controlled experiments. (The optimal schedule of such experiments dep
|
13,334
|
Interpreting 2D correspondence analysis plots
|
First, there are different ways to construct so-called biplots in the case of correspondence analysis. In all cases, the basic idea is to find a way to show the best 2D approximation of the "distances" between row cells and column cells. In other words, we seek a hierarchy (we also speak of "ordination") of the relationships between rows and columns of a contingency table.
Very briefly, CA decomposes the chi-square statistic associated with the two-way table into orthogonal factors that maximize the separation between row and column scores (i.e. the frequencies computed from the table of profiles). Here, you see that there is some connection with PCA but the measure of variance (or the metric) retained in CA is the $\chi^2$, which only depends on column profiles (As it tends to give more importance to modalities that have large marginal values, we can also re-weight the initial data, but this is another story).
Here is a more detailed answer.
The implementation that is proposed in the corresp() function (in MASS) follows from a view of CA as an SVD decomposition of dummy coded matrices representing the rows and columns (such that $R^tC=N$, with $N$ the total sample). This is in light with canonical correlation analysis.
In contrast, the French school of data analysis considers CA as a variant of the PCA, where you seek the directions that maximize the "inertia" in the data cloud. This is done by diagonalizing the inertia matrix computed from the centered and scaled (by marginals frequencies) two-way table, and expressing row and column profiles in this new coordinate system.
If you consider a table with $i=1,\dots,I$ rows, and $j=1,\dots,J$ columns, each row is weighted by its corresponding marginal sum which yields a series of conditional frequencies associated to each row: $f_{j|i}=n_{ij}/n_{i\cdot}$. The marginal column is called the mean profile (for rows). This gives us a vector of coordinates, also called a profile (by row). For the column, we have $f_{i|j}=n_{ij}/n_{\cdot j}$. In both cases, we will consider the $I$ row profiles (associated to their weight $f_{i\cdot}$) as individuals in the column space, and the $J$ column profiles (associated to their weight $f_{\cdot j}$) as individuals in the row space. The metric used to compute the proximity between any two individuals is the $\chi^2$ distance. For instance, between two rows $i$ and $i'$, we have
$$
d^2_{\chi^2}(i,i')=\sum_{j=1}^J\frac{n}{n_{\cdot j}}\left(\frac{n_{ij}}{n_{i\cdot}}-\frac{n_{i'j}}{n_{i'\cdot}} \right)^2
$$
You may also see the link with the $\chi^2$ statistic by noting that it is simply the distance between observed and expected counts, where expected counts (under $H_0$, independence of the two variables) are computed as $n_{i\cdot}\times n_{\cdot j}/n$ for each cell $(i,j)$. If the two variables were to be independent, the row profiles would be all equal, and identical to the corresponding marginal profile. In other words, when there is independence, your contingency table is entirely determined by its margins.
If you realize an PCA on the row profiles (viewed as individuals), replacing the euclidean distance by the $\chi^2$ distance, then you get your CA. The first principal axis is the line that is the closest to all points, and the corresponding eigenvalue is the inertia explained by this dimension. You can do the same with the column profiles. It can be shown that there is a symmetry between the two approaches, and more specifically that the principal components (PC) for the column profiles are associated to the same eigenvalues than the PCs for the row profiles. What is shown on a biplot is the coordinates of the individuals in this new coordinate system, although the individuals are represented in a separate factorial space. Provided each individual/modality is well represented in its factorial space (you can look at the $\cos^2$ of the modality with the 1st principal axis, which is a measure of the correlation/association), you can even interpret the proximity between elements $i$ and $j$ of your contingency table (as can be done by looking at the residuals of your $\chi^2$ test of independence, e.g. chisq.test(tab)$expected-chisq.test(tab)$observed).
The total inertia of your CA (= the sum of eigenvalues) is the $\chi^2$ statistic divided by $n$ (which is Pearson's $\phi^2$).
Actually, there are several packages that may provide you with enhanced CAs compared to the function available in the MASS package: ade4, FactoMineR, anacor, and ca.
The latest is the one that was used for your particular illustration, and a paper was published in the Journal of Statistical Software that explains most of its functionnalities: Correspondence Analysis in R, with Two- and Three-dimensional Graphics: The ca Package.
So, your example on eye/hair colors can be reproduced in many ways:
data(HairEyeColor)
tab <- apply(HairEyeColor, c(1, 2), sum) # aggregate on gender
tab
library(MASS)
plot(corresp(tab, nf=2))
corresp(tab, nf=2)
library(ca)
plot(ca(tab))
summary(ca(tab, nd=2))
library(FactoMineR)
CA(tab)
CA(tab, graph=FALSE)$eig # == summary(ca(tab))$scree[,"values"]
CA(tab, graph=FALSE)$row$contrib
library(ade4)
scatter(dudi.coa(tab, scannf=FALSE, nf=2))
In all cases, what we read in the resulting biplot is basically (I limit my interpretation to the 1st axis which explained most of the inertia):
the first axis highlights the clear opposition between light and dark hair color, and between blue and brown eyes;
people with blond hair tend to also have blue eyes, and people with black hair tend to have brown eyes.
There is a lot of additional resources on data analysis on the bioinformatics lab from Lyon, in France. This is mostly in French, but I think it would not be too much a problem for you. The following two handouts should be interesting as a first start:
Initiation à l'analyse factorielle des correspondances
Pratique de l'analyse des correspondances
Finally, when you consider a full disjonctive (dummy) coding of $k$ variables, you get the multiple correspondence analysis.
|
Interpreting 2D correspondence analysis plots
|
First, there are different ways to construct so-called biplots in the case of correspondence analysis. In all cases, the basic idea is to find a way to show the best 2D approximation of the "distances
|
Interpreting 2D correspondence analysis plots
First, there are different ways to construct so-called biplots in the case of correspondence analysis. In all cases, the basic idea is to find a way to show the best 2D approximation of the "distances" between row cells and column cells. In other words, we seek a hierarchy (we also speak of "ordination") of the relationships between rows and columns of a contingency table.
Very briefly, CA decomposes the chi-square statistic associated with the two-way table into orthogonal factors that maximize the separation between row and column scores (i.e. the frequencies computed from the table of profiles). Here, you see that there is some connection with PCA but the measure of variance (or the metric) retained in CA is the $\chi^2$, which only depends on column profiles (As it tends to give more importance to modalities that have large marginal values, we can also re-weight the initial data, but this is another story).
Here is a more detailed answer.
The implementation that is proposed in the corresp() function (in MASS) follows from a view of CA as an SVD decomposition of dummy coded matrices representing the rows and columns (such that $R^tC=N$, with $N$ the total sample). This is in light with canonical correlation analysis.
In contrast, the French school of data analysis considers CA as a variant of the PCA, where you seek the directions that maximize the "inertia" in the data cloud. This is done by diagonalizing the inertia matrix computed from the centered and scaled (by marginals frequencies) two-way table, and expressing row and column profiles in this new coordinate system.
If you consider a table with $i=1,\dots,I$ rows, and $j=1,\dots,J$ columns, each row is weighted by its corresponding marginal sum which yields a series of conditional frequencies associated to each row: $f_{j|i}=n_{ij}/n_{i\cdot}$. The marginal column is called the mean profile (for rows). This gives us a vector of coordinates, also called a profile (by row). For the column, we have $f_{i|j}=n_{ij}/n_{\cdot j}$. In both cases, we will consider the $I$ row profiles (associated to their weight $f_{i\cdot}$) as individuals in the column space, and the $J$ column profiles (associated to their weight $f_{\cdot j}$) as individuals in the row space. The metric used to compute the proximity between any two individuals is the $\chi^2$ distance. For instance, between two rows $i$ and $i'$, we have
$$
d^2_{\chi^2}(i,i')=\sum_{j=1}^J\frac{n}{n_{\cdot j}}\left(\frac{n_{ij}}{n_{i\cdot}}-\frac{n_{i'j}}{n_{i'\cdot}} \right)^2
$$
You may also see the link with the $\chi^2$ statistic by noting that it is simply the distance between observed and expected counts, where expected counts (under $H_0$, independence of the two variables) are computed as $n_{i\cdot}\times n_{\cdot j}/n$ for each cell $(i,j)$. If the two variables were to be independent, the row profiles would be all equal, and identical to the corresponding marginal profile. In other words, when there is independence, your contingency table is entirely determined by its margins.
If you realize an PCA on the row profiles (viewed as individuals), replacing the euclidean distance by the $\chi^2$ distance, then you get your CA. The first principal axis is the line that is the closest to all points, and the corresponding eigenvalue is the inertia explained by this dimension. You can do the same with the column profiles. It can be shown that there is a symmetry between the two approaches, and more specifically that the principal components (PC) for the column profiles are associated to the same eigenvalues than the PCs for the row profiles. What is shown on a biplot is the coordinates of the individuals in this new coordinate system, although the individuals are represented in a separate factorial space. Provided each individual/modality is well represented in its factorial space (you can look at the $\cos^2$ of the modality with the 1st principal axis, which is a measure of the correlation/association), you can even interpret the proximity between elements $i$ and $j$ of your contingency table (as can be done by looking at the residuals of your $\chi^2$ test of independence, e.g. chisq.test(tab)$expected-chisq.test(tab)$observed).
The total inertia of your CA (= the sum of eigenvalues) is the $\chi^2$ statistic divided by $n$ (which is Pearson's $\phi^2$).
Actually, there are several packages that may provide you with enhanced CAs compared to the function available in the MASS package: ade4, FactoMineR, anacor, and ca.
The latest is the one that was used for your particular illustration, and a paper was published in the Journal of Statistical Software that explains most of its functionnalities: Correspondence Analysis in R, with Two- and Three-dimensional Graphics: The ca Package.
So, your example on eye/hair colors can be reproduced in many ways:
data(HairEyeColor)
tab <- apply(HairEyeColor, c(1, 2), sum) # aggregate on gender
tab
library(MASS)
plot(corresp(tab, nf=2))
corresp(tab, nf=2)
library(ca)
plot(ca(tab))
summary(ca(tab, nd=2))
library(FactoMineR)
CA(tab)
CA(tab, graph=FALSE)$eig # == summary(ca(tab))$scree[,"values"]
CA(tab, graph=FALSE)$row$contrib
library(ade4)
scatter(dudi.coa(tab, scannf=FALSE, nf=2))
In all cases, what we read in the resulting biplot is basically (I limit my interpretation to the 1st axis which explained most of the inertia):
the first axis highlights the clear opposition between light and dark hair color, and between blue and brown eyes;
people with blond hair tend to also have blue eyes, and people with black hair tend to have brown eyes.
There is a lot of additional resources on data analysis on the bioinformatics lab from Lyon, in France. This is mostly in French, but I think it would not be too much a problem for you. The following two handouts should be interesting as a first start:
Initiation à l'analyse factorielle des correspondances
Pratique de l'analyse des correspondances
Finally, when you consider a full disjonctive (dummy) coding of $k$ variables, you get the multiple correspondence analysis.
|
Interpreting 2D correspondence analysis plots
First, there are different ways to construct so-called biplots in the case of correspondence analysis. In all cases, the basic idea is to find a way to show the best 2D approximation of the "distances
|
13,335
|
Why is the bias term in SVM estimated separately, instead of an extra dimension in the feature vector?
|
Why bias is important?
The bias term $b$ is, indeed, a special parameter in SVM. Without it, the classifier will always go through the origin. So, SVM does not give you the separating hyperplane with the maximum margin if it does not happen to pass through the origin, unless you have a bias term.
Below is a visualization of the bias issue. An SVM trained with (without) a bias term is shown on the left (right). Even though both SVMs are trained on the same data, however, they look very different.
Why should the bias be treated separately?
As user logistic pointed out, the bias term $b$ should be treated separately because of regularization. SVM maximizes the margin size, which is $\frac{1}{||w||^2}$ (or $\frac{2}{||w||^2}$ depending on how you define it).
Maximizing the margin is the same as minimizing $||w||^2$. This is also called the regularization term and can be interpreted as a measure of the complexity of the classifier. However, you do not want to regularize the bias term because, the bias shifts the classification scores up or down by the same amount for all data points. In particular, the bias does not change the shape of the classifier or its margin size. Therefore, ...
the bias term in SVM should NOT be regularized.
In practice, however, it is easier to just push the bias into the feature vector
instead of having to deal with as a special case.
Note: when pushing the bias to the feature function, it is best to fix that dimension of the feature vector to a large number, e.g. $\phi_0(x) = 10$, so as to minimize the side-effects of regularization of the bias.
|
Why is the bias term in SVM estimated separately, instead of an extra dimension in the feature vecto
|
Why bias is important?
The bias term $b$ is, indeed, a special parameter in SVM. Without it, the classifier will always go through the origin. So, SVM does not give you the separating hyperplane with
|
Why is the bias term in SVM estimated separately, instead of an extra dimension in the feature vector?
Why bias is important?
The bias term $b$ is, indeed, a special parameter in SVM. Without it, the classifier will always go through the origin. So, SVM does not give you the separating hyperplane with the maximum margin if it does not happen to pass through the origin, unless you have a bias term.
Below is a visualization of the bias issue. An SVM trained with (without) a bias term is shown on the left (right). Even though both SVMs are trained on the same data, however, they look very different.
Why should the bias be treated separately?
As user logistic pointed out, the bias term $b$ should be treated separately because of regularization. SVM maximizes the margin size, which is $\frac{1}{||w||^2}$ (or $\frac{2}{||w||^2}$ depending on how you define it).
Maximizing the margin is the same as minimizing $||w||^2$. This is also called the regularization term and can be interpreted as a measure of the complexity of the classifier. However, you do not want to regularize the bias term because, the bias shifts the classification scores up or down by the same amount for all data points. In particular, the bias does not change the shape of the classifier or its margin size. Therefore, ...
the bias term in SVM should NOT be regularized.
In practice, however, it is easier to just push the bias into the feature vector
instead of having to deal with as a special case.
Note: when pushing the bias to the feature function, it is best to fix that dimension of the feature vector to a large number, e.g. $\phi_0(x) = 10$, so as to minimize the side-effects of regularization of the bias.
|
Why is the bias term in SVM estimated separately, instead of an extra dimension in the feature vecto
Why bias is important?
The bias term $b$ is, indeed, a special parameter in SVM. Without it, the classifier will always go through the origin. So, SVM does not give you the separating hyperplane with
|
13,336
|
Why is the bias term in SVM estimated separately, instead of an extra dimension in the feature vector?
|
Sometimes, people will just omit the intercept in SVM, but i think the reason maybe we can penalizing intercept in order to omit it. i.e.,
we can modify the data $\mathbf{\hat{x}} = (\mathbf{1}, \mathbf{x})$, and $\mathbf{\hat{w}} = (w_{0}, \mathbf{w}^{T})^{T}$ so that omit the intercept
$$\mathbf{x} ~ \mathbf{w} + b = \mathbf{\hat{x}} ~ \mathbf{\hat{w}} $$
As you said, similar technique can be used in kernel version.
However, if we put the intercept in the weights, the objective function will slightly different with original one. That's why we call "penalize".
|
Why is the bias term in SVM estimated separately, instead of an extra dimension in the feature vecto
|
Sometimes, people will just omit the intercept in SVM, but i think the reason maybe we can penalizing intercept in order to omit it. i.e.,
we can modify the data $\mathbf{\hat{x}} = (\mathbf{1}, \math
|
Why is the bias term in SVM estimated separately, instead of an extra dimension in the feature vector?
Sometimes, people will just omit the intercept in SVM, but i think the reason maybe we can penalizing intercept in order to omit it. i.e.,
we can modify the data $\mathbf{\hat{x}} = (\mathbf{1}, \mathbf{x})$, and $\mathbf{\hat{w}} = (w_{0}, \mathbf{w}^{T})^{T}$ so that omit the intercept
$$\mathbf{x} ~ \mathbf{w} + b = \mathbf{\hat{x}} ~ \mathbf{\hat{w}} $$
As you said, similar technique can be used in kernel version.
However, if we put the intercept in the weights, the objective function will slightly different with original one. That's why we call "penalize".
|
Why is the bias term in SVM estimated separately, instead of an extra dimension in the feature vecto
Sometimes, people will just omit the intercept in SVM, but i think the reason maybe we can penalizing intercept in order to omit it. i.e.,
we can modify the data $\mathbf{\hat{x}} = (\mathbf{1}, \math
|
13,337
|
Why is the bias term in SVM estimated separately, instead of an extra dimension in the feature vector?
|
In additional to the reasons mentioned above, the distance of a point $x$ to a hyperplane defined by slope $\theta$ and intercept $b$ is $$\frac{|\theta^T x + b|}{||\theta||}$$
This is how the concept of margin in SVM is movitated. If you change the $\theta$ to include the intercept term $b$, the norm of the $\theta$ will be affected by the size of the intercept, which will cause the SVM to optimize towards a small intercept, which does not make sense in many cases.
|
Why is the bias term in SVM estimated separately, instead of an extra dimension in the feature vecto
|
In additional to the reasons mentioned above, the distance of a point $x$ to a hyperplane defined by slope $\theta$ and intercept $b$ is $$\frac{|\theta^T x + b|}{||\theta||}$$
This is how the concep
|
Why is the bias term in SVM estimated separately, instead of an extra dimension in the feature vector?
In additional to the reasons mentioned above, the distance of a point $x$ to a hyperplane defined by slope $\theta$ and intercept $b$ is $$\frac{|\theta^T x + b|}{||\theta||}$$
This is how the concept of margin in SVM is movitated. If you change the $\theta$ to include the intercept term $b$, the norm of the $\theta$ will be affected by the size of the intercept, which will cause the SVM to optimize towards a small intercept, which does not make sense in many cases.
|
Why is the bias term in SVM estimated separately, instead of an extra dimension in the feature vecto
In additional to the reasons mentioned above, the distance of a point $x$ to a hyperplane defined by slope $\theta$ and intercept $b$ is $$\frac{|\theta^T x + b|}{||\theta||}$$
This is how the concep
|
13,338
|
How much missing data is too much? Multiple Imputation (MICE) & R
|
In principle, MICE should be able to handle large amounts of missing data. Variables with lots of missing data points would be expected to end up with larger error terms than those with fewer missing data points, so your ability to detect significant relations to those variables would be limited accordingly. That's an advantage of having multiple imputations and analyzing results from all of the imputations.
The greater the fraction of (a) cases with missing data or (b) predictors that are frequently missing, the more imputed data sets you will need. See Section 3.10 of Frank Harrell's Regression Modeling Strategies for some "rough guidelines" about how to proceed. If the missing values are for variables that you consider important based on your understanding of the subject matter, he says: "Extreme amount of missing data does not prevent one from using multiple imputation, because alternatives are worse."
More important than a "cutoff" for missing data is to consider carefully (1) the intended use of your model and (2) whether the "missing-at-random" assumptions needed for multiple imputation holds in your case.
In terms of (1) if you, say, intend to use the model for prediction but some variables are inherently hard to get, then there's no sense including them in the model. Also, you should use your knowledge of the subject matter to consider variables for inclusion. If you suspect that only 10 or so will be important based on such knowledge, maybe you should just use those 10.
In terms of (2), "missing at random" means that the probability of missingness doesn't depend on unobserved data. As Stef van Buuren says in Section 1.2 of Flexible Imputation of Missing Data (FIMD):
If the probability of being missing is the same only within groups defined by the observed data, then the data are missing at random.
That's a typical starting point for analysis. van Buuren discusses ways to evaluate the sensitivity of the results to violations of the assumption in Section 9.2 of FIMD.
|
How much missing data is too much? Multiple Imputation (MICE) & R
|
In principle, MICE should be able to handle large amounts of missing data. Variables with lots of missing data points would be expected to end up with larger error terms than those with fewer missing
|
How much missing data is too much? Multiple Imputation (MICE) & R
In principle, MICE should be able to handle large amounts of missing data. Variables with lots of missing data points would be expected to end up with larger error terms than those with fewer missing data points, so your ability to detect significant relations to those variables would be limited accordingly. That's an advantage of having multiple imputations and analyzing results from all of the imputations.
The greater the fraction of (a) cases with missing data or (b) predictors that are frequently missing, the more imputed data sets you will need. See Section 3.10 of Frank Harrell's Regression Modeling Strategies for some "rough guidelines" about how to proceed. If the missing values are for variables that you consider important based on your understanding of the subject matter, he says: "Extreme amount of missing data does not prevent one from using multiple imputation, because alternatives are worse."
More important than a "cutoff" for missing data is to consider carefully (1) the intended use of your model and (2) whether the "missing-at-random" assumptions needed for multiple imputation holds in your case.
In terms of (1) if you, say, intend to use the model for prediction but some variables are inherently hard to get, then there's no sense including them in the model. Also, you should use your knowledge of the subject matter to consider variables for inclusion. If you suspect that only 10 or so will be important based on such knowledge, maybe you should just use those 10.
In terms of (2), "missing at random" means that the probability of missingness doesn't depend on unobserved data. As Stef van Buuren says in Section 1.2 of Flexible Imputation of Missing Data (FIMD):
If the probability of being missing is the same only within groups defined by the observed data, then the data are missing at random.
That's a typical starting point for analysis. van Buuren discusses ways to evaluate the sensitivity of the results to violations of the assumption in Section 9.2 of FIMD.
|
How much missing data is too much? Multiple Imputation (MICE) & R
In principle, MICE should be able to handle large amounts of missing data. Variables with lots of missing data points would be expected to end up with larger error terms than those with fewer missing
|
13,339
|
How much missing data is too much? Multiple Imputation (MICE) & R
|
Mice can handle a large amount of missing data. Especially if there are a lot of columns with few missing data, one with 80% is no problem.
You can also expect that in most of the times adding this variable leads to better imputation results than leaving it out.
( because more information / correlations available that help estimating the other variables)
But:
The hard truth is, you will never know for sure, how good the imputation is anyway. Because the true values are well ... "missing"
If I'd have several imputation options to choose from, I'd take the one which leads to the best results for the prediction model.
|
How much missing data is too much? Multiple Imputation (MICE) & R
|
Mice can handle a large amount of missing data. Especially if there are a lot of columns with few missing data, one with 80% is no problem.
You can also expect that in most of the times adding this va
|
How much missing data is too much? Multiple Imputation (MICE) & R
Mice can handle a large amount of missing data. Especially if there are a lot of columns with few missing data, one with 80% is no problem.
You can also expect that in most of the times adding this variable leads to better imputation results than leaving it out.
( because more information / correlations available that help estimating the other variables)
But:
The hard truth is, you will never know for sure, how good the imputation is anyway. Because the true values are well ... "missing"
If I'd have several imputation options to choose from, I'd take the one which leads to the best results for the prediction model.
|
How much missing data is too much? Multiple Imputation (MICE) & R
Mice can handle a large amount of missing data. Especially if there are a lot of columns with few missing data, one with 80% is no problem.
You can also expect that in most of the times adding this va
|
13,340
|
How much missing data is too much? Multiple Imputation (MICE) & R
|
This is not a coding question but if you want an answer here it is...
Missing data are very complicated. There is not a percentage value to accept of discard your variables. The variance of your variable is what is important to watch before imputation of data.
If you do not want to take some time to review all the statistic behind missing values, just take your variables with less missing value.
If you take the time read the MICE manual there is some basic information that will help you to impute correctly.
Missing data are not simple task, you have know what you do. Otherwise you will introduce bias!
|
How much missing data is too much? Multiple Imputation (MICE) & R
|
This is not a coding question but if you want an answer here it is...
Missing data are very complicated. There is not a percentage value to accept of discard your variables. The variance of your varia
|
How much missing data is too much? Multiple Imputation (MICE) & R
This is not a coding question but if you want an answer here it is...
Missing data are very complicated. There is not a percentage value to accept of discard your variables. The variance of your variable is what is important to watch before imputation of data.
If you do not want to take some time to review all the statistic behind missing values, just take your variables with less missing value.
If you take the time read the MICE manual there is some basic information that will help you to impute correctly.
Missing data are not simple task, you have know what you do. Otherwise you will introduce bias!
|
How much missing data is too much? Multiple Imputation (MICE) & R
This is not a coding question but if you want an answer here it is...
Missing data are very complicated. There is not a percentage value to accept of discard your variables. The variance of your varia
|
13,341
|
How much missing data is too much? Multiple Imputation (MICE) & R
|
(Unable to comment yet - sorry! I would have like to have commented on Joel's response.)
I want to point out that, I believe, the quality of the imputation algorithm has bearing on the amount of data that may be validly imputed.
If the imputation method is poor (i.e., it predicts missing values in a biased manner), then it doesn't matter if only 5% or 10% of your data are missing - it will still yield biased results (though, perhaps tolerably so). The more missing data you have, the more you are relying on your imputation algorithm to be valid. E.g., if you are imputing 80% of your data, I believe you would want to be very confident that you are imputing it well; otherwise, you could introduce considerable bias.
|
How much missing data is too much? Multiple Imputation (MICE) & R
|
(Unable to comment yet - sorry! I would have like to have commented on Joel's response.)
I want to point out that, I believe, the quality of the imputation algorithm has bearing on the amount of data
|
How much missing data is too much? Multiple Imputation (MICE) & R
(Unable to comment yet - sorry! I would have like to have commented on Joel's response.)
I want to point out that, I believe, the quality of the imputation algorithm has bearing on the amount of data that may be validly imputed.
If the imputation method is poor (i.e., it predicts missing values in a biased manner), then it doesn't matter if only 5% or 10% of your data are missing - it will still yield biased results (though, perhaps tolerably so). The more missing data you have, the more you are relying on your imputation algorithm to be valid. E.g., if you are imputing 80% of your data, I believe you would want to be very confident that you are imputing it well; otherwise, you could introduce considerable bias.
|
How much missing data is too much? Multiple Imputation (MICE) & R
(Unable to comment yet - sorry! I would have like to have commented on Joel's response.)
I want to point out that, I believe, the quality of the imputation algorithm has bearing on the amount of data
|
13,342
|
How to check for normal distribution using Excel for performing a t-test?
|
You have the right idea. This can be done systematically, comprehensively, and with relatively simple calculations. A graph of the results is called a normal probability plot (or sometimes a P-P plot). From it you can see much more detail than appears in other graphical representations, especially histograms, and with a little practice you can even learn to determine ways to re-express your data to make them closer to Normal in situations where that is warranted.
Here is an example:
Data are in column A (and named Data). The rest is all calculation, although you can control the "hinge rank" value used to fit a reference line to the plot.
This plot is a scatterplot comparing the data to values that would be attained by numbers drawn independently from a standard Normal distribution. When the points line up along the diagonal, they are close to Normal; horizontal departures (along the data axis) indicate departures from normality. In this example the points are remarkably close to the reference line; the largest departure occurs at the highest value, which is about $1.5$ units to the left of the line. Thus we see at a glance that these data are very close to Normally distributed but perhaps have a slightly "light" right tail. This is perfectly fine for applying a t-test.
The comparison values on the vertical axis are computed in two steps. First each data value is ranked from $1$ through $n$, the amount of data (shown in the Count field in cell F2). These are proportionally converted to values in the range $0$ to $1$. A good formula to use is $\left(\text{rank}-1/6\right)/\left(n+2/3\right).$ (See http://www.quantdec.com/envstats/notes/class_02/characterizing_distributions.htm for where that comes from.) Then these are converted to standard Normal values via the NormSInv function. These values appear in the Normal score column. The plot at the right is an XY scatterplot of Normal Score against the data. (In some references you will see the transpose of this plot, which perhaps is more natural, but Excel prefers to place the leftmost column on the horizontal axis and the rightmost column on the vertical axis, so I have let it do what it prefers.)
(As you can see, I simulated these data with independent random draws from a Normal distribution with mean $5$ and standard deviation $2$. It is therefore no surprise that the probability plot looks so nice.) There really are only two formulas to type in, which you propagate downward to match the data: they appear in cells B2:C2 and rely on the Count value computed in cell F2. That's really all there is to it, apart from the plotting.
The rest of this sheet is not necessary but it's helpful for judging the plot: it provides a robust estimate of a reference line. This is done by picking two points equally far in from the left and right of the plot and connecting them with a line. In the example these points are the third lowest and third highest, as determined by the $3$ in the Hinge Rank cell, F3. As a bonus, its slope and intercept are robust estimates of the standard deviation and mean of the data, respectively.
To plot the reference line, two extreme points are computed and added to the plot: their calculation occurs in columns I:J, labeled X and Y.
|
How to check for normal distribution using Excel for performing a t-test?
|
You have the right idea. This can be done systematically, comprehensively, and with relatively simple calculations. A graph of the results is called a normal probability plot (or sometimes a P-P plo
|
How to check for normal distribution using Excel for performing a t-test?
You have the right idea. This can be done systematically, comprehensively, and with relatively simple calculations. A graph of the results is called a normal probability plot (or sometimes a P-P plot). From it you can see much more detail than appears in other graphical representations, especially histograms, and with a little practice you can even learn to determine ways to re-express your data to make them closer to Normal in situations where that is warranted.
Here is an example:
Data are in column A (and named Data). The rest is all calculation, although you can control the "hinge rank" value used to fit a reference line to the plot.
This plot is a scatterplot comparing the data to values that would be attained by numbers drawn independently from a standard Normal distribution. When the points line up along the diagonal, they are close to Normal; horizontal departures (along the data axis) indicate departures from normality. In this example the points are remarkably close to the reference line; the largest departure occurs at the highest value, which is about $1.5$ units to the left of the line. Thus we see at a glance that these data are very close to Normally distributed but perhaps have a slightly "light" right tail. This is perfectly fine for applying a t-test.
The comparison values on the vertical axis are computed in two steps. First each data value is ranked from $1$ through $n$, the amount of data (shown in the Count field in cell F2). These are proportionally converted to values in the range $0$ to $1$. A good formula to use is $\left(\text{rank}-1/6\right)/\left(n+2/3\right).$ (See http://www.quantdec.com/envstats/notes/class_02/characterizing_distributions.htm for where that comes from.) Then these are converted to standard Normal values via the NormSInv function. These values appear in the Normal score column. The plot at the right is an XY scatterplot of Normal Score against the data. (In some references you will see the transpose of this plot, which perhaps is more natural, but Excel prefers to place the leftmost column on the horizontal axis and the rightmost column on the vertical axis, so I have let it do what it prefers.)
(As you can see, I simulated these data with independent random draws from a Normal distribution with mean $5$ and standard deviation $2$. It is therefore no surprise that the probability plot looks so nice.) There really are only two formulas to type in, which you propagate downward to match the data: they appear in cells B2:C2 and rely on the Count value computed in cell F2. That's really all there is to it, apart from the plotting.
The rest of this sheet is not necessary but it's helpful for judging the plot: it provides a robust estimate of a reference line. This is done by picking two points equally far in from the left and right of the plot and connecting them with a line. In the example these points are the third lowest and third highest, as determined by the $3$ in the Hinge Rank cell, F3. As a bonus, its slope and intercept are robust estimates of the standard deviation and mean of the data, respectively.
To plot the reference line, two extreme points are computed and added to the plot: their calculation occurs in columns I:J, labeled X and Y.
|
How to check for normal distribution using Excel for performing a t-test?
You have the right idea. This can be done systematically, comprehensively, and with relatively simple calculations. A graph of the results is called a normal probability plot (or sometimes a P-P plo
|
13,343
|
How to check for normal distribution using Excel for performing a t-test?
|
You could plot a histogram using the data analysis toolpack in Excel. Graphical approaches are more likely to communicate the degree of non-normality, which is typically more relevant for assumption testing (see this discussion of normality).
The data analysis toolpack in Excel will also give you skewness and kurtosis if you ask for descriptive statistics and choose the "summary statistics" option. You might for example consider values of skewness above plus or minus one be a form of substantive non-normality.
That said, the assumption with t-tests is that the residuals are normally distributed and not the variable. Furthermore, they also quite robust such that even with fairly large amounts of non-normality, p-values are still fairly valid.
|
How to check for normal distribution using Excel for performing a t-test?
|
You could plot a histogram using the data analysis toolpack in Excel. Graphical approaches are more likely to communicate the degree of non-normality, which is typically more relevant for assumption t
|
How to check for normal distribution using Excel for performing a t-test?
You could plot a histogram using the data analysis toolpack in Excel. Graphical approaches are more likely to communicate the degree of non-normality, which is typically more relevant for assumption testing (see this discussion of normality).
The data analysis toolpack in Excel will also give you skewness and kurtosis if you ask for descriptive statistics and choose the "summary statistics" option. You might for example consider values of skewness above plus or minus one be a form of substantive non-normality.
That said, the assumption with t-tests is that the residuals are normally distributed and not the variable. Furthermore, they also quite robust such that even with fairly large amounts of non-normality, p-values are still fairly valid.
|
How to check for normal distribution using Excel for performing a t-test?
You could plot a histogram using the data analysis toolpack in Excel. Graphical approaches are more likely to communicate the degree of non-normality, which is typically more relevant for assumption t
|
13,344
|
How to check for normal distribution using Excel for performing a t-test?
|
This question borders on statistics theory too - testing for normality with limited data may be questionable (although we all have done this from time to time).
As an alternative, you can look at kurtosis and skewness coefficients. From Hahn and Shapiro: Statistical Models in Engineering some background is provided on the properties Beta1 and Beta2 (pages 42 to 49) and the Fig 6-1 of Page 197. Additional theory behind this can be found on Wikipedia (see Pearson Distribution).
Basically you need to calculate the so-called properties Beta1 and Beta2. A Beta1 = 0 and Beta2 = 3 suggests that the data set approaches normality. This is a rough test but with limited data it could be argued that any test could be considered a rough one.
Beta1 is related to the moments 2 and 3, or variance and skewness, respectively. In Excel, these are VAR and SKEW. Where ... is your data array, the formula is:
Beta1 = SKEW(...)^2/VAR(...)^3
Beta2 is related to the moments 2 and 4, or the variance and kurtosis, respectively. In Excel, these are VAR and KURT. Where ... is your data array, the formula is:
Beta2 = KURT(...)/VAR(...)^2
Then you can check these against the values of 0 and 3, respectively. This has the advantage of potentially identifying other distributions (including Pearson Distributions I, I(U), I(J), II, II(U), III, IV, V, VI, VII). For example, many of the commonly used distributions such as Uniform, Normal, Student's t, Beta, Gamma, Exponential, and Log-Normal can be indicated from these properties:
Where: 0 <= Beta1 <= 4
1 <= Beta2 <= 10
Uniform: [0,1.8] [point]
Exponential: [4,9] [point]
Normal: [0,3] [point]
Students-t: (0,3) to [0,10] [line]
Lognormal: (0,3) to [3.6,10] [line]
Gamma: (0,3) to (4,9) [line]
Beta: (0,3) to (4,9), (0,1.8) to (4,9) [area]
Beta J: (0,1.8) to (4,9), (0,1.8) to [4,6*] [area]
Beta U: (0,1.8) to (4,6), [0,1] to [4.5) [area]
Impossible: (0,1) to (4.5), (0,1) to (4,1] [area]
Undefined: (0,3) to (3.6,10), (0,10) to (3.6,10) [area]
Values of Beta1, Beta2 where brackets mean:
[ ] : includes (closed)
( ) : approaches but does not include (open)
* : approximate
These are illustrated in Hahn and Shapiro Fig 6-1.
Granted this is a very rough test (with some issues) but you may want to consider it as a preliminary check before going to a more rigorous method.
There are also adjustment mechanisms to the calculation of Beta1 and Beta2 where data is limited - but that is beyond this post.
|
How to check for normal distribution using Excel for performing a t-test?
|
This question borders on statistics theory too - testing for normality with limited data may be questionable (although we all have done this from time to time).
As an alternative, you can look at kurt
|
How to check for normal distribution using Excel for performing a t-test?
This question borders on statistics theory too - testing for normality with limited data may be questionable (although we all have done this from time to time).
As an alternative, you can look at kurtosis and skewness coefficients. From Hahn and Shapiro: Statistical Models in Engineering some background is provided on the properties Beta1 and Beta2 (pages 42 to 49) and the Fig 6-1 of Page 197. Additional theory behind this can be found on Wikipedia (see Pearson Distribution).
Basically you need to calculate the so-called properties Beta1 and Beta2. A Beta1 = 0 and Beta2 = 3 suggests that the data set approaches normality. This is a rough test but with limited data it could be argued that any test could be considered a rough one.
Beta1 is related to the moments 2 and 3, or variance and skewness, respectively. In Excel, these are VAR and SKEW. Where ... is your data array, the formula is:
Beta1 = SKEW(...)^2/VAR(...)^3
Beta2 is related to the moments 2 and 4, or the variance and kurtosis, respectively. In Excel, these are VAR and KURT. Where ... is your data array, the formula is:
Beta2 = KURT(...)/VAR(...)^2
Then you can check these against the values of 0 and 3, respectively. This has the advantage of potentially identifying other distributions (including Pearson Distributions I, I(U), I(J), II, II(U), III, IV, V, VI, VII). For example, many of the commonly used distributions such as Uniform, Normal, Student's t, Beta, Gamma, Exponential, and Log-Normal can be indicated from these properties:
Where: 0 <= Beta1 <= 4
1 <= Beta2 <= 10
Uniform: [0,1.8] [point]
Exponential: [4,9] [point]
Normal: [0,3] [point]
Students-t: (0,3) to [0,10] [line]
Lognormal: (0,3) to [3.6,10] [line]
Gamma: (0,3) to (4,9) [line]
Beta: (0,3) to (4,9), (0,1.8) to (4,9) [area]
Beta J: (0,1.8) to (4,9), (0,1.8) to [4,6*] [area]
Beta U: (0,1.8) to (4,6), [0,1] to [4.5) [area]
Impossible: (0,1) to (4.5), (0,1) to (4,1] [area]
Undefined: (0,3) to (3.6,10), (0,10) to (3.6,10) [area]
Values of Beta1, Beta2 where brackets mean:
[ ] : includes (closed)
( ) : approaches but does not include (open)
* : approximate
These are illustrated in Hahn and Shapiro Fig 6-1.
Granted this is a very rough test (with some issues) but you may want to consider it as a preliminary check before going to a more rigorous method.
There are also adjustment mechanisms to the calculation of Beta1 and Beta2 where data is limited - but that is beyond this post.
|
How to check for normal distribution using Excel for performing a t-test?
This question borders on statistics theory too - testing for normality with limited data may be questionable (although we all have done this from time to time).
As an alternative, you can look at kurt
|
13,345
|
"Investigator intention" and thresholds/p-values
|
Here's some more info: http://doingbayesiandataanalysis.blogspot.com/2012/07/sampling-distributions-of-t-when.html
A more complete discussion is provided here: http://www.indiana.edu/~kruschke/BEST/ That article considers p values for stopping at threshold N, stopping at threshold duration, and stopping at threshold t value.
|
"Investigator intention" and thresholds/p-values
|
Here's some more info: http://doingbayesiandataanalysis.blogspot.com/2012/07/sampling-distributions-of-t-when.html
A more complete discussion is provided here: http://www.indiana.edu/~kruschke/BEST/
|
"Investigator intention" and thresholds/p-values
Here's some more info: http://doingbayesiandataanalysis.blogspot.com/2012/07/sampling-distributions-of-t-when.html
A more complete discussion is provided here: http://www.indiana.edu/~kruschke/BEST/ That article considers p values for stopping at threshold N, stopping at threshold duration, and stopping at threshold t value.
|
"Investigator intention" and thresholds/p-values
Here's some more info: http://doingbayesiandataanalysis.blogspot.com/2012/07/sampling-distributions-of-t-when.html
A more complete discussion is provided here: http://www.indiana.edu/~kruschke/BEST/
|
13,346
|
"Investigator intention" and thresholds/p-values
|
I finally tracked down the paper associated with the slides: Kruschke (2010), also available directly from the author (via CiteSeerX) here, since the journal is not widely carried. The explanation is a little bit prosaic, but I'm still not sure I buy it.
In the fixed-N case, the critical $t$-value is computed as follows: $2N$ samples are randomly drawn from the (same) population and a $t$-value is calculated. This process is repeated many times to build up a null distribution. Finally, $t_{crit}$ is set to be the 95th percentile of that distribution.
For the fixed duration case, he assumes that subjects arrive at a mean rate $\lambda$. The null distribution is constructed by repeating two steps. In the first step, the number of subjects for each condition $N_1$ and $N_2$ is drawn from a possion distribution with parameter $\lambda$. Next, $N_1$ and $N_2$ random draws from the population are used to calculate a $t$-value. This is repeated many times, and $t_{crit}$ is set to be the 95th percentile of that distribution.
This seems a little...cheeky...to me. As I understand it, there isn't a single $t$-distribution; instead it's a family of distributions, with a shape partly determined by the degrees-of-freedom parameter. For the fixed-$N$ condition, there are $N$ subjects per group and the appropriate $t$-value for an unpaired t-test is the one with $2N-2$ degrees of freedom, which is presumably what his simulation reproduces.
In the other condition, it seems like the "$t$"-like distribution is actually a combination of samples from many different $t$-distributions, depending on the specific draws. By setting $\lambda=N$, one could get the average degrees of freedom to equal $2N-N$, but that's not quite enough. For example, the average of the $t$-distributions for $\nu=1$ and $\nu=5$ doesn't seem to be the $t$-distribution with 3 degrees of freedom.
In summary:
The author was generating $t_{crit}$ by simulation, instead of just calculating them from the CDF.
The way the author simulated the fixed-duration scenario seems like it might fatten up the tails of the corresponding $t$-distribution.
I remain unconvinced that this is actually a problem, but would be happy to read/upvote/accept answers if anyone thinks otherwise.
|
"Investigator intention" and thresholds/p-values
|
I finally tracked down the paper associated with the slides: Kruschke (2010), also available directly from the author (via CiteSeerX) here, since the journal is not widely carried. The explanation is
|
"Investigator intention" and thresholds/p-values
I finally tracked down the paper associated with the slides: Kruschke (2010), also available directly from the author (via CiteSeerX) here, since the journal is not widely carried. The explanation is a little bit prosaic, but I'm still not sure I buy it.
In the fixed-N case, the critical $t$-value is computed as follows: $2N$ samples are randomly drawn from the (same) population and a $t$-value is calculated. This process is repeated many times to build up a null distribution. Finally, $t_{crit}$ is set to be the 95th percentile of that distribution.
For the fixed duration case, he assumes that subjects arrive at a mean rate $\lambda$. The null distribution is constructed by repeating two steps. In the first step, the number of subjects for each condition $N_1$ and $N_2$ is drawn from a possion distribution with parameter $\lambda$. Next, $N_1$ and $N_2$ random draws from the population are used to calculate a $t$-value. This is repeated many times, and $t_{crit}$ is set to be the 95th percentile of that distribution.
This seems a little...cheeky...to me. As I understand it, there isn't a single $t$-distribution; instead it's a family of distributions, with a shape partly determined by the degrees-of-freedom parameter. For the fixed-$N$ condition, there are $N$ subjects per group and the appropriate $t$-value for an unpaired t-test is the one with $2N-2$ degrees of freedom, which is presumably what his simulation reproduces.
In the other condition, it seems like the "$t$"-like distribution is actually a combination of samples from many different $t$-distributions, depending on the specific draws. By setting $\lambda=N$, one could get the average degrees of freedom to equal $2N-N$, but that's not quite enough. For example, the average of the $t$-distributions for $\nu=1$ and $\nu=5$ doesn't seem to be the $t$-distribution with 3 degrees of freedom.
In summary:
The author was generating $t_{crit}$ by simulation, instead of just calculating them from the CDF.
The way the author simulated the fixed-duration scenario seems like it might fatten up the tails of the corresponding $t$-distribution.
I remain unconvinced that this is actually a problem, but would be happy to read/upvote/accept answers if anyone thinks otherwise.
|
"Investigator intention" and thresholds/p-values
I finally tracked down the paper associated with the slides: Kruschke (2010), also available directly from the author (via CiteSeerX) here, since the journal is not widely carried. The explanation is
|
13,347
|
How do Bayesian Statistics handle the absence of priors?
|
Q1: Is the absence of a prior equivalent (in the strict theoretical sense) to having an uninformative prior?
No.
First, there is no mathematical definition for an "uninformative prior". This word is only used informally to describe some priors.
For example, Jeffrey's prior is often called "uninformative". This prior generalizes the uniform prior for translation invariant problems. Jeffrey's prior somehow adapts to the (information theoretic) Riemannian geometry of the model and thus is independent of parametrization, only dependent on the geometry of the manifold (in the space of distributions) that is the model. It might be perceived as canonical, but it's only a choice. It's just the uniform prior according to Riemannian structure. It's not absurd to define "uninformative = uniform" as a simplification of the question. This applies to many cases and helps to ask a clear and simple question.
Doing Bayesian inference without a prior is like "how can I guess $E(X)$ without any assumption about the distribution of $X$ only knowing that $X$ has values in $[0;1]$?" This question obviously makes no sense. If you answer 0.5, you probably have a distribution in mind.
The Bayesian and frequentist approaches simply answer different questions. For example, about estimators which is maybe the simplest:
Frequentist (for example): "How can I estimate $\theta$ such that my answer has the smallest error (only averaged over $x$) in the worst case (over $\theta$)?". This leads to minimax estimators.
Bayesian: "How can I estimate $\theta$ such that my answer has the smallest error in average (over $\theta$) ?". This leads to Bayes estimators. But the question is incomplete and must specify "average in what sense?". Thus the question is only complete when it contains a prior.
Somehow, frequentist aims at worst case control and does not need a prior. Bayesian aims at average control and requires a prior to say "average in what sense?".
Q2 : If the answer to Q1 is "No", does this mean that, in cases where there are no priors, the Bayesian approach is not applicable from the beginning, and we have to first form a prior by some non-Bayesian way, so that we can subsequently apply the Bayesian approach?
Yes.
But beware of canonical prior construction. It might sound mathematically appealing but is not automatically realistic from a Bayesian point of view. It is possible a mathematically nice prior actually corresponds to a dumb belief system. For example if you study $X\sim N(\mu,1)$, Jeffrey's prior on $\mu$ is uniform and if about people's average size, this might not be a very realistic system. However with only a few observations, the problem actually disappears quite fast. The choice is not very important.
True problems with prior specification happen in more complicated problems in my opinion. What is important here is to understand what a certain prior says.
|
How do Bayesian Statistics handle the absence of priors?
|
Q1: Is the absence of a prior equivalent (in the strict theoretical sense) to having an uninformative prior?
No.
First, there is no mathematical definition for an "uninformative prior". This word is o
|
How do Bayesian Statistics handle the absence of priors?
Q1: Is the absence of a prior equivalent (in the strict theoretical sense) to having an uninformative prior?
No.
First, there is no mathematical definition for an "uninformative prior". This word is only used informally to describe some priors.
For example, Jeffrey's prior is often called "uninformative". This prior generalizes the uniform prior for translation invariant problems. Jeffrey's prior somehow adapts to the (information theoretic) Riemannian geometry of the model and thus is independent of parametrization, only dependent on the geometry of the manifold (in the space of distributions) that is the model. It might be perceived as canonical, but it's only a choice. It's just the uniform prior according to Riemannian structure. It's not absurd to define "uninformative = uniform" as a simplification of the question. This applies to many cases and helps to ask a clear and simple question.
Doing Bayesian inference without a prior is like "how can I guess $E(X)$ without any assumption about the distribution of $X$ only knowing that $X$ has values in $[0;1]$?" This question obviously makes no sense. If you answer 0.5, you probably have a distribution in mind.
The Bayesian and frequentist approaches simply answer different questions. For example, about estimators which is maybe the simplest:
Frequentist (for example): "How can I estimate $\theta$ such that my answer has the smallest error (only averaged over $x$) in the worst case (over $\theta$)?". This leads to minimax estimators.
Bayesian: "How can I estimate $\theta$ such that my answer has the smallest error in average (over $\theta$) ?". This leads to Bayes estimators. But the question is incomplete and must specify "average in what sense?". Thus the question is only complete when it contains a prior.
Somehow, frequentist aims at worst case control and does not need a prior. Bayesian aims at average control and requires a prior to say "average in what sense?".
Q2 : If the answer to Q1 is "No", does this mean that, in cases where there are no priors, the Bayesian approach is not applicable from the beginning, and we have to first form a prior by some non-Bayesian way, so that we can subsequently apply the Bayesian approach?
Yes.
But beware of canonical prior construction. It might sound mathematically appealing but is not automatically realistic from a Bayesian point of view. It is possible a mathematically nice prior actually corresponds to a dumb belief system. For example if you study $X\sim N(\mu,1)$, Jeffrey's prior on $\mu$ is uniform and if about people's average size, this might not be a very realistic system. However with only a few observations, the problem actually disappears quite fast. The choice is not very important.
True problems with prior specification happen in more complicated problems in my opinion. What is important here is to understand what a certain prior says.
|
How do Bayesian Statistics handle the absence of priors?
Q1: Is the absence of a prior equivalent (in the strict theoretical sense) to having an uninformative prior?
No.
First, there is no mathematical definition for an "uninformative prior". This word is o
|
13,348
|
How do Bayesian Statistics handle the absence of priors?
|
First of all, Bayesian approach is often used because you want to include prior knowledge in your model to enrich it. If you don't have any prior knowledge, then you stick to so-called "uninformative" or weekly informative priors. Notice that uniform prior is not "uninformative" by definition, since assumption about uniformity is an assumption. There is no such a thing as a truly uninformative prior. There are cases where "it could be anything" is a reasonable "uninformative" prior assumption, but there are also cases where stating that "all values are equally likely" is a very strong and unreasonable assumption. For example, if you assumed that my height can be anything between 0 centimeters and 3 meters, with all of the values being equally likely a priori, this wouldn't be a reasonable assumption and it would give too much weight to the extreme values, so it could possibly distort your posterior.
On another hand, Bayesian would argue that there is really no situations where you have no prior knowledge or beliefs whatsoever. You always can assume something and as a human being, you're doing it all the time (psychologists and behavioral economists made tons of research on this topic). The whole Bayesian fuss with the priors is about quantifying those preconception and stating them explicitly in your model, since Bayesian inference is about updating your beliefs.
It is easy to come up with "no prior assumptions" arguments, or uniform priors, for abstract problems, but for real-life problems you'd have prior knowledge. If you needed to make a bet about amount of money in an envelope, you'd know that the amount needs to be non-negative and finite. You also could make an educated guess about the upper bound for the possible amount of the money given your knowledge about the rules of the contest, funds available for your adversary, knowledge about physical size of the envelope and the amount of money that could physically fit in it, etc. You could also make some guesses about the amount of money that your adversary could be willing to put in the envelope and possibly loose. There is lots of things that you would know as a base for your prior.
|
How do Bayesian Statistics handle the absence of priors?
|
First of all, Bayesian approach is often used because you want to include prior knowledge in your model to enrich it. If you don't have any prior knowledge, then you stick to so-called "uninformative"
|
How do Bayesian Statistics handle the absence of priors?
First of all, Bayesian approach is often used because you want to include prior knowledge in your model to enrich it. If you don't have any prior knowledge, then you stick to so-called "uninformative" or weekly informative priors. Notice that uniform prior is not "uninformative" by definition, since assumption about uniformity is an assumption. There is no such a thing as a truly uninformative prior. There are cases where "it could be anything" is a reasonable "uninformative" prior assumption, but there are also cases where stating that "all values are equally likely" is a very strong and unreasonable assumption. For example, if you assumed that my height can be anything between 0 centimeters and 3 meters, with all of the values being equally likely a priori, this wouldn't be a reasonable assumption and it would give too much weight to the extreme values, so it could possibly distort your posterior.
On another hand, Bayesian would argue that there is really no situations where you have no prior knowledge or beliefs whatsoever. You always can assume something and as a human being, you're doing it all the time (psychologists and behavioral economists made tons of research on this topic). The whole Bayesian fuss with the priors is about quantifying those preconception and stating them explicitly in your model, since Bayesian inference is about updating your beliefs.
It is easy to come up with "no prior assumptions" arguments, or uniform priors, for abstract problems, but for real-life problems you'd have prior knowledge. If you needed to make a bet about amount of money in an envelope, you'd know that the amount needs to be non-negative and finite. You also could make an educated guess about the upper bound for the possible amount of the money given your knowledge about the rules of the contest, funds available for your adversary, knowledge about physical size of the envelope and the amount of money that could physically fit in it, etc. You could also make some guesses about the amount of money that your adversary could be willing to put in the envelope and possibly loose. There is lots of things that you would know as a base for your prior.
|
How do Bayesian Statistics handle the absence of priors?
First of all, Bayesian approach is often used because you want to include prior knowledge in your model to enrich it. If you don't have any prior knowledge, then you stick to so-called "uninformative"
|
13,349
|
How do Bayesian Statistics handle the absence of priors?
|
question 1
I think the answer is probably no. My reason is we don't really have a definition for "uninformative" except for somehow measuring how far the final answer is from some arbitrarily informative model/likelihood.
Many uninformative priors are validated against "intuitive" examples where we already have "the model/likelihood" and "the answer" in mind. We then ask the uninformative prior to give us the answer we want.
My problem with this is I struggle with believing that someone can have a really good, well informed model or model structure for their population, and simultaneously have "no information" about likely and unlikely parameter values for that model. For example using logistic regression, see "A WEAKLY INFORMATIVE DEFAULT PRIOR DISTRIBUTION. FOR LOGISTIC AND OTHER REGRESSION MODELS"
I think the discrete uniform prior is the only one we could reasonably say is the "first-first" prior. But you run into problems of using it, thinking you have "no information", but then suddenly having reactions to "unintuitive" answers (hint: if you don't like a bayesian answer - you might have left information out of the prior or likelihood!).
Another problem you run into is getting the discretisation right for your problem.
And even thinking of this, you need to know the number of discrete values to apply the discrete uniform prior.
Another property to consider for your prior is the "tail behaviour" relative to the likelihood you are using.
on to question 2
Conceptually, I don't see anything wrong with specifying a distribution without the use of a prior or likelihood. You can start a problem by saying "my pdf is ... and I want to calculate ... wrt this pdf". Then you are creating a constraint for the prior, prior predictive, and likelihood. The bayesian method is for when you have a prior and a likelihood, and you want to combine them into a posterior distribution.
It's probably a matter of being clear on what your probabilities are. Then the argument shifts to "does this pdf/pmf represent what I say it represents?" - which is the space you want to be in I think. From your example, you are saying the single distribution reflects all the available information - there is no "prior" because it's already contained (implicitly) in the distribution you are using.
You can also apply bayes in reverse - what "prior", "likelihood" and "data" gives me the actual prior I am considering? This is one way you can see that a $U (0,1) $ prior for a $Bin(n,p) $ likelihood "looks" like it corresponds to a "posterior" for a $Beta (0,0) $ "prior" with $2$ observations - $1$ from each category.
on the so called blatantly wrong comment
To be honest, I would be very interested to see how any numbet of observation could be used to predict a "statistically independent" observation. As an example, if I tell you I'll generate 100 standard normal variables. I give you 99, and get you to give me your best prediction for 100th. I say you cannot make a better prediction for the 100th than 0. But this is the same you would predict for the 100th if I gave you no data. Hence you learn nothing from the 99 data points.
However, if I tell you that it was "some normal distribution", you can use the 99 data points to estimate the parameters. Then the data are now no longer "statistically independent", because we learn more about the common structure as we observe more data. Your best prediction now uses all 99 data points
|
How do Bayesian Statistics handle the absence of priors?
|
question 1
I think the answer is probably no. My reason is we don't really have a definition for "uninformative" except for somehow measuring how far the final answer is from some arbitrarily informat
|
How do Bayesian Statistics handle the absence of priors?
question 1
I think the answer is probably no. My reason is we don't really have a definition for "uninformative" except for somehow measuring how far the final answer is from some arbitrarily informative model/likelihood.
Many uninformative priors are validated against "intuitive" examples where we already have "the model/likelihood" and "the answer" in mind. We then ask the uninformative prior to give us the answer we want.
My problem with this is I struggle with believing that someone can have a really good, well informed model or model structure for their population, and simultaneously have "no information" about likely and unlikely parameter values for that model. For example using logistic regression, see "A WEAKLY INFORMATIVE DEFAULT PRIOR DISTRIBUTION. FOR LOGISTIC AND OTHER REGRESSION MODELS"
I think the discrete uniform prior is the only one we could reasonably say is the "first-first" prior. But you run into problems of using it, thinking you have "no information", but then suddenly having reactions to "unintuitive" answers (hint: if you don't like a bayesian answer - you might have left information out of the prior or likelihood!).
Another problem you run into is getting the discretisation right for your problem.
And even thinking of this, you need to know the number of discrete values to apply the discrete uniform prior.
Another property to consider for your prior is the "tail behaviour" relative to the likelihood you are using.
on to question 2
Conceptually, I don't see anything wrong with specifying a distribution without the use of a prior or likelihood. You can start a problem by saying "my pdf is ... and I want to calculate ... wrt this pdf". Then you are creating a constraint for the prior, prior predictive, and likelihood. The bayesian method is for when you have a prior and a likelihood, and you want to combine them into a posterior distribution.
It's probably a matter of being clear on what your probabilities are. Then the argument shifts to "does this pdf/pmf represent what I say it represents?" - which is the space you want to be in I think. From your example, you are saying the single distribution reflects all the available information - there is no "prior" because it's already contained (implicitly) in the distribution you are using.
You can also apply bayes in reverse - what "prior", "likelihood" and "data" gives me the actual prior I am considering? This is one way you can see that a $U (0,1) $ prior for a $Bin(n,p) $ likelihood "looks" like it corresponds to a "posterior" for a $Beta (0,0) $ "prior" with $2$ observations - $1$ from each category.
on the so called blatantly wrong comment
To be honest, I would be very interested to see how any numbet of observation could be used to predict a "statistically independent" observation. As an example, if I tell you I'll generate 100 standard normal variables. I give you 99, and get you to give me your best prediction for 100th. I say you cannot make a better prediction for the 100th than 0. But this is the same you would predict for the 100th if I gave you no data. Hence you learn nothing from the 99 data points.
However, if I tell you that it was "some normal distribution", you can use the 99 data points to estimate the parameters. Then the data are now no longer "statistically independent", because we learn more about the common structure as we observe more data. Your best prediction now uses all 99 data points
|
How do Bayesian Statistics handle the absence of priors?
question 1
I think the answer is probably no. My reason is we don't really have a definition for "uninformative" except for somehow measuring how far the final answer is from some arbitrarily informat
|
13,350
|
How do Bayesian Statistics handle the absence of priors?
|
This is only a short remark as addition to the other excellent answers. Often, or at least sometimes, it is somewhat arbitrary (or conventional) what part of the information entering a statistical analysis is called data and which part is called prior. Or, more generally, we can say that information in a statistical analysis comes from three sources: the model, the data, and the prior. In some cases, such as linear models or glm's, the separation is quite clear, at least conventionally.
I will reuse an example from Maximum Likelihood Estimation (MLE) in layman terms to illustrate my point. Say a patient enters a physician's office, with some medical problems that turn out to be difficult to diagnose. This physician hasn't seen something quite similar before. Then, talking with the patient it surfaces some new information: this patient visited tropical Africa quite recently. Then it appears to the physician that this could be malaria or some other tropical disease. But note, that this information is clearly to us data, but at least in many statistical models that could be used, it will enter the analysis in the form of a prior distribution, a prior distribution giving higher probability to some tropical diseases. But we could, maybe, make some (larger), more complete model, where this information enters as data. So, at least in part, the distinction data/prior is conventional.
We are used to, and accept, this convention because of our emphasis on some classes of conventional models. But, in the larger scheme of things, outside the world of stylized statistical models, the situation is less clear.
|
How do Bayesian Statistics handle the absence of priors?
|
This is only a short remark as addition to the other excellent answers. Often, or at least sometimes, it is somewhat arbitrary (or conventional) what part of the information entering a statistical ana
|
How do Bayesian Statistics handle the absence of priors?
This is only a short remark as addition to the other excellent answers. Often, or at least sometimes, it is somewhat arbitrary (or conventional) what part of the information entering a statistical analysis is called data and which part is called prior. Or, more generally, we can say that information in a statistical analysis comes from three sources: the model, the data, and the prior. In some cases, such as linear models or glm's, the separation is quite clear, at least conventionally.
I will reuse an example from Maximum Likelihood Estimation (MLE) in layman terms to illustrate my point. Say a patient enters a physician's office, with some medical problems that turn out to be difficult to diagnose. This physician hasn't seen something quite similar before. Then, talking with the patient it surfaces some new information: this patient visited tropical Africa quite recently. Then it appears to the physician that this could be malaria or some other tropical disease. But note, that this information is clearly to us data, but at least in many statistical models that could be used, it will enter the analysis in the form of a prior distribution, a prior distribution giving higher probability to some tropical diseases. But we could, maybe, make some (larger), more complete model, where this information enters as data. So, at least in part, the distinction data/prior is conventional.
We are used to, and accept, this convention because of our emphasis on some classes of conventional models. But, in the larger scheme of things, outside the world of stylized statistical models, the situation is less clear.
|
How do Bayesian Statistics handle the absence of priors?
This is only a short remark as addition to the other excellent answers. Often, or at least sometimes, it is somewhat arbitrary (or conventional) what part of the information entering a statistical ana
|
13,351
|
Expectation of a product of $n$ dependent random variables when $n\to\infty$
|
The answer is indeed $1/e$, as guessed in the earlier replies based on simulations and finite approximations.
The solution is easily arrived at by introducing a sequence of functions $f_n: [0,1]\to[0,1]$. Although we could proceed to that step immediately, it might appear rather mysterious. The first part of this solution explains how one might cook up these $f_n(t)$. The second part shows how they are exploited to find a functional equation satisfied by the limiting function $f(t) = \lim_{n\to\infty}f_n(t)$. The third part displays the (routine) calculations needed to solve this functional equation.
1. Motivation
We can arrive at this by applying some standard mathematical problem-solving techniques. In this case, where some kind of operation is repeated ad infinitum, the limit will exist as a fixed point of that operation. The key, then, is to identify the operation.
The difficulty is that the move from $E[X_1X_2\cdots X_{n-1}]$ to $E[X_1X_2\cdots X_{n-1}X_n]$ looks complicated. It is simpler to view this step as arising from adjoining $X_1$ to the variables $(X_2, \ldots, X_n)$ rather than adjoining $X_n$ to the variables $(X_1, X_2, \ldots, X_{n-1})$. If we were to consider $(X_2, \ldots, X_n)$ as being constructed as described in the question--with $X_2$ uniformly distributed on $[0,1]$, $X_3$ conditionally uniformly distributed on $[X_2, 1]$, and so on--then introducing $X_1$ will cause every one of the subsequent $X_i$ to shrink by a factor of $1-X_1$ towards the upper limit $1$. This reasoning leads naturally to the following construction.
As a preliminary matter, since it's a little simpler to shrink numbers towards $0$ than towards $1$, let $Y_i = 1-X_i$. Thus, $Y_1$ is uniformly distributed in $[0,1]$ and $Y_{i+1}$ is uniformly distributed in $[0, Y_i]$ conditional on $(Y_1, Y_2, \ldots, Y_i)$ for all $i=1, 2, 3, \ldots.$ We are interested in two things:
The limiting value of $E[X_1X_2\cdots X_n]=E[(1-Y_1)(1-Y_2)\cdots(1-Y_n)]$.
How these values behave when shrinking all the $Y_i$ uniformly towards $0$: that is, by scaling them all by some common factor $t$, $0 \le t \le 1$.
To this end, define
$$f_n(t) = E[(1-tY_1)(1-tY_2)\cdots(1-tY_n)].$$
Clearly each $f_n$ is defined and continuous (infinitely differentiable, actually) for all real $t$. We will focus on their behavior for $t\in[0,1]$.
2. The Key Step
The following are obvious:
Each $f_n(t)$ is a monotonically decreasing function from $[0,1]$ to $[0,1]$.
$f_n(t) \gt f_{n+1}(t)$ for all $n$.
$f_n(0) = 1$ for all $n$.
$E(X_1X_2\cdots X_n) = f_n(1).$
These imply that $f(t) = \lim_{n\to\infty} f_n(t)$ exists for all $t\in[0,1]$ and $f(0)=1$.
Observe that, conditional on $Y_1$, the variable $Y_2/Y_1$ is uniform in $[0,1]$ and variables $Y_{i+1}/Y_1$ (conditional on all preceding variables) are uniform in $[0, Y_i/Y_1]$: that is, $(Y_2/Y_1, Y_3/Y_1, \ldots, Y_n/Y_1)$ satisfy precisely the conditions satisfied by $(Y_1, \ldots, Y_{n-1})$. Consequently
$$\eqalign{
f_n(t) &= E[(1-tY_1) E[(1-tY_2)\cdots(1-tY_n)\,|\, Y_1]] \\
&= E\left[(1-tY_1) E\left[\left(1 - tY_1 \frac{Y_2}{Y_1}\right)\cdots \left(1 - tY_1 \frac{Y_n}{Y_1}\right)\,|\, Y_1\right]\right] \\
&= E\left[(1-tY_1) f_{n-1}(tY_1)\right].
}$$
This is the recursive relationship we were looking for.
In the limit as $n\to \infty$ it must therefore be the case that for $Y$ uniformly distributed in $[0,1]$ independently of all the $Y_i$,
$$f(t) = E[(1 - tY)f(tY)]=\int_0^1 (1 - ty) f(ty) dy = \frac{1}{t}\int_0^t (1-x)f(x)dx.$$
That is, $f$ must be a fixed point of the functional $\mathcal{L}$ for which
$$\mathcal{L}[g](t) = \frac{1}{t}\int_0^t (1-x)g(x)dx.$$
3. Calculation of the Solution
Clear the fraction $1/t$ by multiplying both sides of the equation $f(t)=\mathcal{L}[f](t)$ by $t$. Because the right hand side is an integral, we may differentiate it with respect to $t$, giving
$$f(t) + tf'(t) = (1-t)f(t).$$
Equivalently, upon subtracting $f(t)$ and dividing both sides by $t$,
$$f'(t) = -f(t)$$
for $0 \lt t \le 1$. We may extend this by continuity to include $t=0$. With the initial condition (3) $f(0)=1$, the unique solution is
$$f(t) = e^{-t}.$$
Consequently, by (4), the limiting expectation of $X_1X_2\cdots X_n$ is $f(1)=e^{-1} = 1/e$, QED.
Because Mathematica appears to be a popular tool for studying this problem, here is Mathematica code to compute and plot $f_n$ for small $n$. The plot of $f_1, f_2, f_3, f_4$ displays rapid convergence to $e^{-t}$ (shown as the black graph).
a = 0 <= t <= 1;
l[g_] := Function[{t}, (1/t) Integrate[(1 - x) g[x], {x, 0, t}, Assumptions -> a]];
f = Evaluate@Through[NestList[l, 1 - #/2 &, 3][t]]
Plot[f, {t,0,1}]
|
Expectation of a product of $n$ dependent random variables when $n\to\infty$
|
The answer is indeed $1/e$, as guessed in the earlier replies based on simulations and finite approximations.
The solution is easily arrived at by introducing a sequence of functions $f_n: [0,1]\to[0,
|
Expectation of a product of $n$ dependent random variables when $n\to\infty$
The answer is indeed $1/e$, as guessed in the earlier replies based on simulations and finite approximations.
The solution is easily arrived at by introducing a sequence of functions $f_n: [0,1]\to[0,1]$. Although we could proceed to that step immediately, it might appear rather mysterious. The first part of this solution explains how one might cook up these $f_n(t)$. The second part shows how they are exploited to find a functional equation satisfied by the limiting function $f(t) = \lim_{n\to\infty}f_n(t)$. The third part displays the (routine) calculations needed to solve this functional equation.
1. Motivation
We can arrive at this by applying some standard mathematical problem-solving techniques. In this case, where some kind of operation is repeated ad infinitum, the limit will exist as a fixed point of that operation. The key, then, is to identify the operation.
The difficulty is that the move from $E[X_1X_2\cdots X_{n-1}]$ to $E[X_1X_2\cdots X_{n-1}X_n]$ looks complicated. It is simpler to view this step as arising from adjoining $X_1$ to the variables $(X_2, \ldots, X_n)$ rather than adjoining $X_n$ to the variables $(X_1, X_2, \ldots, X_{n-1})$. If we were to consider $(X_2, \ldots, X_n)$ as being constructed as described in the question--with $X_2$ uniformly distributed on $[0,1]$, $X_3$ conditionally uniformly distributed on $[X_2, 1]$, and so on--then introducing $X_1$ will cause every one of the subsequent $X_i$ to shrink by a factor of $1-X_1$ towards the upper limit $1$. This reasoning leads naturally to the following construction.
As a preliminary matter, since it's a little simpler to shrink numbers towards $0$ than towards $1$, let $Y_i = 1-X_i$. Thus, $Y_1$ is uniformly distributed in $[0,1]$ and $Y_{i+1}$ is uniformly distributed in $[0, Y_i]$ conditional on $(Y_1, Y_2, \ldots, Y_i)$ for all $i=1, 2, 3, \ldots.$ We are interested in two things:
The limiting value of $E[X_1X_2\cdots X_n]=E[(1-Y_1)(1-Y_2)\cdots(1-Y_n)]$.
How these values behave when shrinking all the $Y_i$ uniformly towards $0$: that is, by scaling them all by some common factor $t$, $0 \le t \le 1$.
To this end, define
$$f_n(t) = E[(1-tY_1)(1-tY_2)\cdots(1-tY_n)].$$
Clearly each $f_n$ is defined and continuous (infinitely differentiable, actually) for all real $t$. We will focus on their behavior for $t\in[0,1]$.
2. The Key Step
The following are obvious:
Each $f_n(t)$ is a monotonically decreasing function from $[0,1]$ to $[0,1]$.
$f_n(t) \gt f_{n+1}(t)$ for all $n$.
$f_n(0) = 1$ for all $n$.
$E(X_1X_2\cdots X_n) = f_n(1).$
These imply that $f(t) = \lim_{n\to\infty} f_n(t)$ exists for all $t\in[0,1]$ and $f(0)=1$.
Observe that, conditional on $Y_1$, the variable $Y_2/Y_1$ is uniform in $[0,1]$ and variables $Y_{i+1}/Y_1$ (conditional on all preceding variables) are uniform in $[0, Y_i/Y_1]$: that is, $(Y_2/Y_1, Y_3/Y_1, \ldots, Y_n/Y_1)$ satisfy precisely the conditions satisfied by $(Y_1, \ldots, Y_{n-1})$. Consequently
$$\eqalign{
f_n(t) &= E[(1-tY_1) E[(1-tY_2)\cdots(1-tY_n)\,|\, Y_1]] \\
&= E\left[(1-tY_1) E\left[\left(1 - tY_1 \frac{Y_2}{Y_1}\right)\cdots \left(1 - tY_1 \frac{Y_n}{Y_1}\right)\,|\, Y_1\right]\right] \\
&= E\left[(1-tY_1) f_{n-1}(tY_1)\right].
}$$
This is the recursive relationship we were looking for.
In the limit as $n\to \infty$ it must therefore be the case that for $Y$ uniformly distributed in $[0,1]$ independently of all the $Y_i$,
$$f(t) = E[(1 - tY)f(tY)]=\int_0^1 (1 - ty) f(ty) dy = \frac{1}{t}\int_0^t (1-x)f(x)dx.$$
That is, $f$ must be a fixed point of the functional $\mathcal{L}$ for which
$$\mathcal{L}[g](t) = \frac{1}{t}\int_0^t (1-x)g(x)dx.$$
3. Calculation of the Solution
Clear the fraction $1/t$ by multiplying both sides of the equation $f(t)=\mathcal{L}[f](t)$ by $t$. Because the right hand side is an integral, we may differentiate it with respect to $t$, giving
$$f(t) + tf'(t) = (1-t)f(t).$$
Equivalently, upon subtracting $f(t)$ and dividing both sides by $t$,
$$f'(t) = -f(t)$$
for $0 \lt t \le 1$. We may extend this by continuity to include $t=0$. With the initial condition (3) $f(0)=1$, the unique solution is
$$f(t) = e^{-t}.$$
Consequently, by (4), the limiting expectation of $X_1X_2\cdots X_n$ is $f(1)=e^{-1} = 1/e$, QED.
Because Mathematica appears to be a popular tool for studying this problem, here is Mathematica code to compute and plot $f_n$ for small $n$. The plot of $f_1, f_2, f_3, f_4$ displays rapid convergence to $e^{-t}$ (shown as the black graph).
a = 0 <= t <= 1;
l[g_] := Function[{t}, (1/t) Integrate[(1 - x) g[x], {x, 0, t}, Assumptions -> a]];
f = Evaluate@Through[NestList[l, 1 - #/2 &, 3][t]]
Plot[f, {t,0,1}]
|
Expectation of a product of $n$ dependent random variables when $n\to\infty$
The answer is indeed $1/e$, as guessed in the earlier replies based on simulations and finite approximations.
The solution is easily arrived at by introducing a sequence of functions $f_n: [0,1]\to[0,
|
13,352
|
Expectation of a product of $n$ dependent random variables when $n\to\infty$
|
Update
I think it's a safe bet that the answer is $1/e$. I ran the integrals for the expected value from $n=2$ to $n=100$ using Mathematica and with $n=100$ I got
0.367879441171442321595523770161567628159853507344458757185018968311538556667710938369307469618599737077005261635286940285462842065735614
(to 100 decimal places). The reciprocal of that value is
2.718281828459045235360287471351873636852026081893477137766637293458245150821149822195768231483133554
The difference with that reciprocal and $e$ is
-7.88860905221011806482437200330334265831479532397772375613947042032873*10^-31
I think that's too close, dare I say, to be a rational coincidence.
The Mathematica code follows:
Do[
x = Table[ToExpression["x" <> ToString[i]], {i, n}];
integrand = Expand[Simplify[(x[[n - 1]]/(1 - x[[n - 1]]))
Integrate[x[[n]], {x[[n]], x[[n - 1]], 1}]]];
Do[
integrand = Expand[Simplify[x[[i - 1]]
Integrate[integrand, {x[[i]], x[[i - 1]], 1}]/(1 - x[[i -
1]])]],
{i, n - 1, 2, -1}]
Print[{n, N[Integrate[integrand, {x1, 0, 1}], 100]}],
{n, 2, 100}]
End of update
This is more of an extended comment than an answer.
If we go a brute force route by determining the expected value for several values of $n$, maybe someone will recognize a pattern and then be able to take a limit.
For $n=5$, we have the expected value of the product being
$$\mu_n=\int _0^1\int _{x_1}^1\int _{x_2}^1\int _{x_3}^1\int _{x_4}^1\frac{x_1 x_2 x_3 x_4 x_5}{(1-x_1) (1-x_2) (1-x_3) (1-x_4)}dx_5 dx_4 dx_3 dx_2 dx_1$$
which is 96547/259200 or approximately 0.3724807098765432.
If we drop the integral from 0 to 1, we have a polynomial in $x_1$ with the following results for $n=1$ to $n=6$ (and I've dropped the subscript to make things a bit easier to read):
$x$
$(x + x^2)/2$
$(5x + 5x^2 + 2x^3)/12$
$(28x + 28x^2 + 13x^3 + 3x^4)/72$
$(1631x + 1631x^2 + 791x^3 + 231x^4 + 36x^5)/4320$
$(96547x + 96547x^2 + 47617x^3 + 14997x^4 + 3132x^5 + 360x^6)/259200$
If someone recognizes the form of the integer coefficients, then maybe a limit as $n\rightarrow\infty$ can be determined (after performing the integration from 0 to 1 that was removed to show the underlying polynomial).
|
Expectation of a product of $n$ dependent random variables when $n\to\infty$
|
Update
I think it's a safe bet that the answer is $1/e$. I ran the integrals for the expected value from $n=2$ to $n=100$ using Mathematica and with $n=100$ I got
0.3678794411714423215955237701615676
|
Expectation of a product of $n$ dependent random variables when $n\to\infty$
Update
I think it's a safe bet that the answer is $1/e$. I ran the integrals for the expected value from $n=2$ to $n=100$ using Mathematica and with $n=100$ I got
0.367879441171442321595523770161567628159853507344458757185018968311538556667710938369307469618599737077005261635286940285462842065735614
(to 100 decimal places). The reciprocal of that value is
2.718281828459045235360287471351873636852026081893477137766637293458245150821149822195768231483133554
The difference with that reciprocal and $e$ is
-7.88860905221011806482437200330334265831479532397772375613947042032873*10^-31
I think that's too close, dare I say, to be a rational coincidence.
The Mathematica code follows:
Do[
x = Table[ToExpression["x" <> ToString[i]], {i, n}];
integrand = Expand[Simplify[(x[[n - 1]]/(1 - x[[n - 1]]))
Integrate[x[[n]], {x[[n]], x[[n - 1]], 1}]]];
Do[
integrand = Expand[Simplify[x[[i - 1]]
Integrate[integrand, {x[[i]], x[[i - 1]], 1}]/(1 - x[[i -
1]])]],
{i, n - 1, 2, -1}]
Print[{n, N[Integrate[integrand, {x1, 0, 1}], 100]}],
{n, 2, 100}]
End of update
This is more of an extended comment than an answer.
If we go a brute force route by determining the expected value for several values of $n$, maybe someone will recognize a pattern and then be able to take a limit.
For $n=5$, we have the expected value of the product being
$$\mu_n=\int _0^1\int _{x_1}^1\int _{x_2}^1\int _{x_3}^1\int _{x_4}^1\frac{x_1 x_2 x_3 x_4 x_5}{(1-x_1) (1-x_2) (1-x_3) (1-x_4)}dx_5 dx_4 dx_3 dx_2 dx_1$$
which is 96547/259200 or approximately 0.3724807098765432.
If we drop the integral from 0 to 1, we have a polynomial in $x_1$ with the following results for $n=1$ to $n=6$ (and I've dropped the subscript to make things a bit easier to read):
$x$
$(x + x^2)/2$
$(5x + 5x^2 + 2x^3)/12$
$(28x + 28x^2 + 13x^3 + 3x^4)/72$
$(1631x + 1631x^2 + 791x^3 + 231x^4 + 36x^5)/4320$
$(96547x + 96547x^2 + 47617x^3 + 14997x^4 + 3132x^5 + 360x^6)/259200$
If someone recognizes the form of the integer coefficients, then maybe a limit as $n\rightarrow\infty$ can be determined (after performing the integration from 0 to 1 that was removed to show the underlying polynomial).
|
Expectation of a product of $n$ dependent random variables when $n\to\infty$
Update
I think it's a safe bet that the answer is $1/e$. I ran the integrals for the expected value from $n=2$ to $n=100$ using Mathematica and with $n=100$ I got
0.3678794411714423215955237701615676
|
13,353
|
Expectation of a product of $n$ dependent random variables when $n\to\infty$
|
Nice question. Just as a quick comment, I would note that:
$X_n$ will converge to 1 rapidly, so for Monte Carlo checking, setting $n = 1000$ will more than do the trick.
If $Z_n = X_1 X_2 \dots X_n$, then by Monte Carlo simulation, as $n \rightarrow \infty$, $E[Z_n] \approx 0.367$.
The following diagram compares the simulated Monte Carlo pdf of $Z_n$ to a Power Function distribution [ i.e. a Beta(a,1) pdf) ]
$$f(z) = a z^{a-1}$$
... here with parameter $a=0.57$:
(source: tri.org.au)
where:
the blue curve denotes the Monte Carlo 'empirical' pdf of $Z_n$
the red dashed curve is a PowerFunction pdf.
The fit appears pretty good.
Code
Here are 1 million pseudorandom drawings of the product $Z_n$ (say with $n = 1000$), here using Mathematica:
data = Table[Times @@ NestList[RandomReal[{#, 1}] &,
RandomReal[], 1000], {10^6}];
The sample mean is:
Mean[data]
> 0.367657
|
Expectation of a product of $n$ dependent random variables when $n\to\infty$
|
Nice question. Just as a quick comment, I would note that:
$X_n$ will converge to 1 rapidly, so for Monte Carlo checking, setting $n = 1000$ will more than do the trick.
If $Z_n = X_1 X_2 \dots X_n$
|
Expectation of a product of $n$ dependent random variables when $n\to\infty$
Nice question. Just as a quick comment, I would note that:
$X_n$ will converge to 1 rapidly, so for Monte Carlo checking, setting $n = 1000$ will more than do the trick.
If $Z_n = X_1 X_2 \dots X_n$, then by Monte Carlo simulation, as $n \rightarrow \infty$, $E[Z_n] \approx 0.367$.
The following diagram compares the simulated Monte Carlo pdf of $Z_n$ to a Power Function distribution [ i.e. a Beta(a,1) pdf) ]
$$f(z) = a z^{a-1}$$
... here with parameter $a=0.57$:
(source: tri.org.au)
where:
the blue curve denotes the Monte Carlo 'empirical' pdf of $Z_n$
the red dashed curve is a PowerFunction pdf.
The fit appears pretty good.
Code
Here are 1 million pseudorandom drawings of the product $Z_n$ (say with $n = 1000$), here using Mathematica:
data = Table[Times @@ NestList[RandomReal[{#, 1}] &,
RandomReal[], 1000], {10^6}];
The sample mean is:
Mean[data]
> 0.367657
|
Expectation of a product of $n$ dependent random variables when $n\to\infty$
Nice question. Just as a quick comment, I would note that:
$X_n$ will converge to 1 rapidly, so for Monte Carlo checking, setting $n = 1000$ will more than do the trick.
If $Z_n = X_1 X_2 \dots X_n$
|
13,354
|
Expectation of a product of $n$ dependent random variables when $n\to\infty$
|
Purely intuitively, and based on Rusty's other answer, I think the answer should be something like this:
n = 1:1000
x = (1 + (n^2 - 1)/(n^2)) / 2
prod(x)
Which gives us 0.3583668. For each $X$, you are splitting the $(a,1)$ range in half, where $a$ starts out at $0$. So it's a product of $1/2, (1 + 3/4)/2, (1 + 8/9)/2$, etc.
This is just intuition.
The problem with Rusty's answer is that U[1] is identical in every single simulation. The simulations are not independent. A fix for this is easy. Move the line with U[1] = runif(1, 0, 1) to inside the first loop. The result is:
set.seed(3) #Just for reproducibility of my solution
n = 1000 #Number of random variables
S = 1000 #Number of Monte Carlo samples
Z = rep(NA,S)
U = rep(NA,n)
for(j in 1:S){
U[1] = runif(1,0,1)
for(i in 2:n){
U[i] = runif(1,U[i-1],1)
}
Z[j] = prod(U)
}
mean(Z)
This gives 0.3545284.
|
Expectation of a product of $n$ dependent random variables when $n\to\infty$
|
Purely intuitively, and based on Rusty's other answer, I think the answer should be something like this:
n = 1:1000
x = (1 + (n^2 - 1)/(n^2)) / 2
prod(x)
Which gives us 0.3583668. For eac
|
Expectation of a product of $n$ dependent random variables when $n\to\infty$
Purely intuitively, and based on Rusty's other answer, I think the answer should be something like this:
n = 1:1000
x = (1 + (n^2 - 1)/(n^2)) / 2
prod(x)
Which gives us 0.3583668. For each $X$, you are splitting the $(a,1)$ range in half, where $a$ starts out at $0$. So it's a product of $1/2, (1 + 3/4)/2, (1 + 8/9)/2$, etc.
This is just intuition.
The problem with Rusty's answer is that U[1] is identical in every single simulation. The simulations are not independent. A fix for this is easy. Move the line with U[1] = runif(1, 0, 1) to inside the first loop. The result is:
set.seed(3) #Just for reproducibility of my solution
n = 1000 #Number of random variables
S = 1000 #Number of Monte Carlo samples
Z = rep(NA,S)
U = rep(NA,n)
for(j in 1:S){
U[1] = runif(1,0,1)
for(i in 2:n){
U[i] = runif(1,U[i-1],1)
}
Z[j] = prod(U)
}
mean(Z)
This gives 0.3545284.
|
Expectation of a product of $n$ dependent random variables when $n\to\infty$
Purely intuitively, and based on Rusty's other answer, I think the answer should be something like this:
n = 1:1000
x = (1 + (n^2 - 1)/(n^2)) / 2
prod(x)
Which gives us 0.3583668. For eac
|
13,355
|
How to interpret notched box plots
|
In my case (second plot), the notches don't meaningfully overlap. But
why does the bottom of the box on the right hand side take that
strange form? How do I explain that?
It indicates that the 25th percentile is about 21, 75th percentile about 30.5. And the lower and upper limits of the notch are about 18 and 27.
A common reason is that your distribution is skewed or sample size is low. The notch's boundary is based on:
$median \pm 1.57 \times \frac{IQR}{\sqrt{n}}$
If the distance between median and the 25th percentile and the distance between median and the 75th percentile are extremely different (like the one at the right) and/or the sample size is low, the notch will be wider. If it's wide enough that the notch boundary is more extreme than the 25th and 75th percentiles (aka, the box), then the notched box plot will display this "inside out" shape.
|
How to interpret notched box plots
|
In my case (second plot), the notches don't meaningfully overlap. But
why does the bottom of the box on the right hand side take that
strange form? How do I explain that?
It indicates that the 25
|
How to interpret notched box plots
In my case (second plot), the notches don't meaningfully overlap. But
why does the bottom of the box on the right hand side take that
strange form? How do I explain that?
It indicates that the 25th percentile is about 21, 75th percentile about 30.5. And the lower and upper limits of the notch are about 18 and 27.
A common reason is that your distribution is skewed or sample size is low. The notch's boundary is based on:
$median \pm 1.57 \times \frac{IQR}{\sqrt{n}}$
If the distance between median and the 25th percentile and the distance between median and the 75th percentile are extremely different (like the one at the right) and/or the sample size is low, the notch will be wider. If it's wide enough that the notch boundary is more extreme than the 25th and 75th percentiles (aka, the box), then the notched box plot will display this "inside out" shape.
|
How to interpret notched box plots
In my case (second plot), the notches don't meaningfully overlap. But
why does the bottom of the box on the right hand side take that
strange form? How do I explain that?
It indicates that the 25
|
13,356
|
How to recode categorical variable into numerical variable when using SVM or Neural Network
|
In NLP, where words are typically encoded as 1-of-k, the use of word embeddings has emerged recently. The wikipedia page with its references is a good start.
The general idea is to learn a vectorial representation $x_i \in \mathbb{R}^n$ for each word $i$ where semantically similar words are close in that space. Consequently, the inputs are of size $n$ instead of the size of the vocabulary.
Maybe you can transfer that idea to your setting.
|
How to recode categorical variable into numerical variable when using SVM or Neural Network
|
In NLP, where words are typically encoded as 1-of-k, the use of word embeddings has emerged recently. The wikipedia page with its references is a good start.
The general idea is to learn a vectorial r
|
How to recode categorical variable into numerical variable when using SVM or Neural Network
In NLP, where words are typically encoded as 1-of-k, the use of word embeddings has emerged recently. The wikipedia page with its references is a good start.
The general idea is to learn a vectorial representation $x_i \in \mathbb{R}^n$ for each word $i$ where semantically similar words are close in that space. Consequently, the inputs are of size $n$ instead of the size of the vocabulary.
Maybe you can transfer that idea to your setting.
|
How to recode categorical variable into numerical variable when using SVM or Neural Network
In NLP, where words are typically encoded as 1-of-k, the use of word embeddings has emerged recently. The wikipedia page with its references is a good start.
The general idea is to learn a vectorial r
|
13,357
|
How to recode categorical variable into numerical variable when using SVM or Neural Network
|
The 'standard' methods are: one-hot encoding (which you mentioned in the question).
If there are too many possible categories, but you need 0-1 encoding, you can use hashing trick.
The other frequently used method is averaging answer over category: see picture from comment at kaggle.
|
How to recode categorical variable into numerical variable when using SVM or Neural Network
|
The 'standard' methods are: one-hot encoding (which you mentioned in the question).
If there are too many possible categories, but you need 0-1 encoding, you can use hashing trick.
The other frequentl
|
How to recode categorical variable into numerical variable when using SVM or Neural Network
The 'standard' methods are: one-hot encoding (which you mentioned in the question).
If there are too many possible categories, but you need 0-1 encoding, you can use hashing trick.
The other frequently used method is averaging answer over category: see picture from comment at kaggle.
|
How to recode categorical variable into numerical variable when using SVM or Neural Network
The 'standard' methods are: one-hot encoding (which you mentioned in the question).
If there are too many possible categories, but you need 0-1 encoding, you can use hashing trick.
The other frequentl
|
13,358
|
How to recode categorical variable into numerical variable when using SVM or Neural Network
|
You can use dummyVars in R, from the caret package. It will automatically create different columns based on number of levels. Afterwards, you can use cbind and attach it to you original data. Other options include model.matrix and sparse.model.matrix.
|
How to recode categorical variable into numerical variable when using SVM or Neural Network
|
You can use dummyVars in R, from the caret package. It will automatically create different columns based on number of levels. Afterwards, you can use cbind and attach it to you original data. Other op
|
How to recode categorical variable into numerical variable when using SVM or Neural Network
You can use dummyVars in R, from the caret package. It will automatically create different columns based on number of levels. Afterwards, you can use cbind and attach it to you original data. Other options include model.matrix and sparse.model.matrix.
|
How to recode categorical variable into numerical variable when using SVM or Neural Network
You can use dummyVars in R, from the caret package. It will automatically create different columns based on number of levels. Afterwards, you can use cbind and attach it to you original data. Other op
|
13,359
|
How to recode categorical variable into numerical variable when using SVM or Neural Network
|
You can try binary encoding which is more compact and sometimes outperforms one-hot. You can implement categorical embedding in Keras, for example.
|
How to recode categorical variable into numerical variable when using SVM or Neural Network
|
You can try binary encoding which is more compact and sometimes outperforms one-hot. You can implement categorical embedding in Keras, for example.
|
How to recode categorical variable into numerical variable when using SVM or Neural Network
You can try binary encoding which is more compact and sometimes outperforms one-hot. You can implement categorical embedding in Keras, for example.
|
How to recode categorical variable into numerical variable when using SVM or Neural Network
You can try binary encoding which is more compact and sometimes outperforms one-hot. You can implement categorical embedding in Keras, for example.
|
13,360
|
How to recode categorical variable into numerical variable when using SVM or Neural Network
|
You can use entity encoding, which is a more sophisticated network structure. It adds between 1 and $k-1$ hidden, linear neurons between the categorical input and the first fully-connected layer. This has some nice empirical results behind it.
"Entity Embeddings of Categorical Variables" by Cheng Guo, Felix Berkhahn
We map categorical variables in a function approximation problem into Euclidean spaces, which are the entity embeddings of the categorical variables. The mapping is learned by a neural network during the standard supervised training process. Entity embedding not only reduces memory usage and speeds up neural networks compared with one-hot encoding, but more importantly by mapping similar values close to each other in the embedding space it reveals the intrinsic properties of the categorical variables. We applied it successfully in a recent Kaggle competition and were able to reach the third position with relative simple features. We further demonstrate in this paper that entity embedding helps the neural network to generalize better when the data is sparse and statistics is unknown. Thus it is especially useful for datasets with lots of high cardinality features, where other methods tend to overfit. We also demonstrate that the embeddings obtained from the trained neural network boost the performance of all tested machine learning methods considerably when used as the input features instead. As entity embedding defines a distance measure for categorical variables it can be used for visualizing categorical data and for data clustering.
|
How to recode categorical variable into numerical variable when using SVM or Neural Network
|
You can use entity encoding, which is a more sophisticated network structure. It adds between 1 and $k-1$ hidden, linear neurons between the categorical input and the first fully-connected layer. This
|
How to recode categorical variable into numerical variable when using SVM or Neural Network
You can use entity encoding, which is a more sophisticated network structure. It adds between 1 and $k-1$ hidden, linear neurons between the categorical input and the first fully-connected layer. This has some nice empirical results behind it.
"Entity Embeddings of Categorical Variables" by Cheng Guo, Felix Berkhahn
We map categorical variables in a function approximation problem into Euclidean spaces, which are the entity embeddings of the categorical variables. The mapping is learned by a neural network during the standard supervised training process. Entity embedding not only reduces memory usage and speeds up neural networks compared with one-hot encoding, but more importantly by mapping similar values close to each other in the embedding space it reveals the intrinsic properties of the categorical variables. We applied it successfully in a recent Kaggle competition and were able to reach the third position with relative simple features. We further demonstrate in this paper that entity embedding helps the neural network to generalize better when the data is sparse and statistics is unknown. Thus it is especially useful for datasets with lots of high cardinality features, where other methods tend to overfit. We also demonstrate that the embeddings obtained from the trained neural network boost the performance of all tested machine learning methods considerably when used as the input features instead. As entity embedding defines a distance measure for categorical variables it can be used for visualizing categorical data and for data clustering.
|
How to recode categorical variable into numerical variable when using SVM or Neural Network
You can use entity encoding, which is a more sophisticated network structure. It adds between 1 and $k-1$ hidden, linear neurons between the categorical input and the first fully-connected layer. This
|
13,361
|
Training a Hidden Markov Model, multiple training instances
|
Neither concatenating nor running each iteration of training with a different sequence is right thing to do. The correct approach requires some explanation:
One usually trains an HMM using an E-M algorithm. This consists of several iterations. Each iteration has one "estimate" and one "maximize" step. In the "maximize" step, you align each observation vector x with a state s in your model so that some likelihood measure is maximized. In the "estimate" step, for each state s, you estimate (a) the parameters of a statistical model for the x vectors aligned to s and (b) the state transition probabilities. In the following iteration, the maximize step runs again with the updated statistical models, etc. The process is repeated a set number of times or when the likelihood measure stops rising significantly (i.e, the model converges to a stable solution). Finally, (at least in speech recognition) an HMM will typically have a designated "start" state which is aligned to the first observation of the observation sequence and have a "left to right" topology so that once you leave a state you don't return to it.
So, if you have multiple training sequences, on the estimate step you should run each sequence so that it's initial observation vector aligns with the initial state. That way, the statistics on that initial state are collected from the first observations over all your observation sequences, and in general observation vectors are aligned to the most likely states throughout each sequence. You would only do the maximize step (and future iterations) after all sequences have been provided for training. On next iteration, you'd do exactly same thing.
By aligning the start of each observation sequence to the initial state you avoid the problem of concatenating sequences where you'd be incorrectly modelling transitions between the end of one sequence and beginning of next. And by using all the sequences on each iteration you avoid providing different sequences each iteration, which as the responder noted, will not guarantee convergence.
|
Training a Hidden Markov Model, multiple training instances
|
Neither concatenating nor running each iteration of training with a different sequence is right thing to do. The correct approach requires some explanation:
One usually trains an HMM using an E-M algo
|
Training a Hidden Markov Model, multiple training instances
Neither concatenating nor running each iteration of training with a different sequence is right thing to do. The correct approach requires some explanation:
One usually trains an HMM using an E-M algorithm. This consists of several iterations. Each iteration has one "estimate" and one "maximize" step. In the "maximize" step, you align each observation vector x with a state s in your model so that some likelihood measure is maximized. In the "estimate" step, for each state s, you estimate (a) the parameters of a statistical model for the x vectors aligned to s and (b) the state transition probabilities. In the following iteration, the maximize step runs again with the updated statistical models, etc. The process is repeated a set number of times or when the likelihood measure stops rising significantly (i.e, the model converges to a stable solution). Finally, (at least in speech recognition) an HMM will typically have a designated "start" state which is aligned to the first observation of the observation sequence and have a "left to right" topology so that once you leave a state you don't return to it.
So, if you have multiple training sequences, on the estimate step you should run each sequence so that it's initial observation vector aligns with the initial state. That way, the statistics on that initial state are collected from the first observations over all your observation sequences, and in general observation vectors are aligned to the most likely states throughout each sequence. You would only do the maximize step (and future iterations) after all sequences have been provided for training. On next iteration, you'd do exactly same thing.
By aligning the start of each observation sequence to the initial state you avoid the problem of concatenating sequences where you'd be incorrectly modelling transitions between the end of one sequence and beginning of next. And by using all the sequences on each iteration you avoid providing different sequences each iteration, which as the responder noted, will not guarantee convergence.
|
Training a Hidden Markov Model, multiple training instances
Neither concatenating nor running each iteration of training with a different sequence is right thing to do. The correct approach requires some explanation:
One usually trains an HMM using an E-M algo
|
13,362
|
Training a Hidden Markov Model, multiple training instances
|
Lawrence Rabiner describes a mathematically well-founded approach in this tutorial from IEEE 77. The tutorial is also the 6th chapter of the book Fundamentals of Speech Recognition by Rabiner and Juang.
R.I.A Davis et. al. provides some additional suggestions in this paper.
I have not gone thoroughly through the math, but to me Rabiner's approach sounds the most promising, while Davis's approach seems to lack the mathematical foundation.
|
Training a Hidden Markov Model, multiple training instances
|
Lawrence Rabiner describes a mathematically well-founded approach in this tutorial from IEEE 77. The tutorial is also the 6th chapter of the book Fundamentals of Speech Recognition by Rabiner and Juan
|
Training a Hidden Markov Model, multiple training instances
Lawrence Rabiner describes a mathematically well-founded approach in this tutorial from IEEE 77. The tutorial is also the 6th chapter of the book Fundamentals of Speech Recognition by Rabiner and Juang.
R.I.A Davis et. al. provides some additional suggestions in this paper.
I have not gone thoroughly through the math, but to me Rabiner's approach sounds the most promising, while Davis's approach seems to lack the mathematical foundation.
|
Training a Hidden Markov Model, multiple training instances
Lawrence Rabiner describes a mathematically well-founded approach in this tutorial from IEEE 77. The tutorial is also the 6th chapter of the book Fundamentals of Speech Recognition by Rabiner and Juan
|
13,363
|
Training a Hidden Markov Model, multiple training instances
|
If you follow the math, adding extra training examples implies to recalculate the way you compute the likelihood. Instead of summing over dimensions, you also sum over training examples.
If you train one model after the other, there is no guarantee that the EM is going to coverage for every training example, and you are going to end up with bad estimates.
Here is a paper that does that for the Kalman Filter (which is an HMM with Gaussian Probabilities), it can give you a taste of how to modify your code so you can support more examples.
http://ntp-0.cs.ucl.ac.uk/staff/S.Prince/4C75/WellingKalmanFilter.pdf
He also has a lecture on HMM, but the logic is pretty straightforward.
|
Training a Hidden Markov Model, multiple training instances
|
If you follow the math, adding extra training examples implies to recalculate the way you compute the likelihood. Instead of summing over dimensions, you also sum over training examples.
If you train
|
Training a Hidden Markov Model, multiple training instances
If you follow the math, adding extra training examples implies to recalculate the way you compute the likelihood. Instead of summing over dimensions, you also sum over training examples.
If you train one model after the other, there is no guarantee that the EM is going to coverage for every training example, and you are going to end up with bad estimates.
Here is a paper that does that for the Kalman Filter (which is an HMM with Gaussian Probabilities), it can give you a taste of how to modify your code so you can support more examples.
http://ntp-0.cs.ucl.ac.uk/staff/S.Prince/4C75/WellingKalmanFilter.pdf
He also has a lecture on HMM, but the logic is pretty straightforward.
|
Training a Hidden Markov Model, multiple training instances
If you follow the math, adding extra training examples implies to recalculate the way you compute the likelihood. Instead of summing over dimensions, you also sum over training examples.
If you train
|
13,364
|
Training a Hidden Markov Model, multiple training instances
|
This is more of a comment on the paper by RIA Davis referenced by Bittenus (above). I will have to agree with Bittenus, there is not much of a mathematical backing behind the techniques proposed in the paper - it is more of an empirical comparison.
The paper only considers the case wherein the HMM is of a restricted topology (feed-forward). (in my case I have a standard topology, and I found the most consistent results by implementing a non-weighted averaging of all models trained with Baum-Welch. This approach is mentioned in the paper but only cited with marginal results).
Another type of model-averaging training was detailed by RIA Davis in a journal article and uses Vitterbi Training instead of Baum-Welch Comparing and Evaluating HMM Ensemble Training Algorithms Using Train and Test and Condition Number Criteria. However this paper only explores the HMMs with the same restricted feed-forward topology. (I plan to explore this method and will update this post with my findings.)
|
Training a Hidden Markov Model, multiple training instances
|
This is more of a comment on the paper by RIA Davis referenced by Bittenus (above). I will have to agree with Bittenus, there is not much of a mathematical backing behind the techniques proposed in th
|
Training a Hidden Markov Model, multiple training instances
This is more of a comment on the paper by RIA Davis referenced by Bittenus (above). I will have to agree with Bittenus, there is not much of a mathematical backing behind the techniques proposed in the paper - it is more of an empirical comparison.
The paper only considers the case wherein the HMM is of a restricted topology (feed-forward). (in my case I have a standard topology, and I found the most consistent results by implementing a non-weighted averaging of all models trained with Baum-Welch. This approach is mentioned in the paper but only cited with marginal results).
Another type of model-averaging training was detailed by RIA Davis in a journal article and uses Vitterbi Training instead of Baum-Welch Comparing and Evaluating HMM Ensemble Training Algorithms Using Train and Test and Condition Number Criteria. However this paper only explores the HMMs with the same restricted feed-forward topology. (I plan to explore this method and will update this post with my findings.)
|
Training a Hidden Markov Model, multiple training instances
This is more of a comment on the paper by RIA Davis referenced by Bittenus (above). I will have to agree with Bittenus, there is not much of a mathematical backing behind the techniques proposed in th
|
13,365
|
Cholesky versus eigendecomposition for drawing samples from a multivariate normal distribution
|
The problem was studied by by Straka et.al for the Unscented Kalman Filter which draws (deterministic) samples from a multivariate Normal distribution as part of the algorithm. With some luck, the results might be applicable to the monte-carlo problem.
The Cholesky Decomposition (CD) and the Eigen Decomposition (ED) - and for that matter the actual Matrix Square Root (MSR) are all ways in which a positive semi-definite matrix (PSD) can be broken down.
Consider the SVD of a PSD matrix, $P = USV^T$. Since P is PSD, this is actually the same as the ED with $P = USU^T$. Moreover, we can split the diagonal matrix by its square root: $P = U\sqrt{S}\sqrt{S}^TU^T$, noting that $\sqrt{S} = \sqrt{S}^T$.
We may now introduce an arbitrary orthogonal matrix $O$:
$P = U\sqrt{S}OO^T\sqrt{S}^TU^T = (U\sqrt{S}O)(U\sqrt{S}O)^T$.
The choice of $O$ actually affects the estimation performance, especially when there is strong off-diagonal elements of the covariance matrix.
The paper studied three choices of $O$:
$O = I$, which corresponds to the ED;
$O = Q$ from the QR decomposition of $U\sqrt{S} = QR$, which corresponds to the CD; and
$O = U^T$ which leads to a symmetric matrix (i.e. MSR)
From which the following conclusions were drawn in the paper after much analysis (quoting):
For a to-be-transformed random variable with uncorrelated elements all the three considered MDs provide identical sigma points and hence
they make almost no difference on quality of the [Unscented Transform] approximation. In
such a case the CD may be preferred for its low costs.
If the random variable contains correlated elements, the use of different [decompositions] may significantly affect quality of the [Unscented Transform] approximation
of the mean or covariance matrix of the transformed random variable.
The two cases above showed that the [ED] should be preferred.
If the elements of the to-be-transformed variable exhibit strong correlation so that the corresponding covariance matrix is nearly
singular, another issue must be taken into account, which is numerical
stability of the algorithm computing the MD. The SVD is much more
numerically stable for nearly singular covariance matrices than the
ChD.
Reference:
Straka, O.; Dunik, J.; Simandl, M. & Havlik, J. "Aspects and comparison of matrix decompositions in unscented Kalman filter", American Control Conference (ACC), 2013, 2013, 3075-3080.
|
Cholesky versus eigendecomposition for drawing samples from a multivariate normal distribution
|
The problem was studied by by Straka et.al for the Unscented Kalman Filter which draws (deterministic) samples from a multivariate Normal distribution as part of the algorithm. With some luck, the re
|
Cholesky versus eigendecomposition for drawing samples from a multivariate normal distribution
The problem was studied by by Straka et.al for the Unscented Kalman Filter which draws (deterministic) samples from a multivariate Normal distribution as part of the algorithm. With some luck, the results might be applicable to the monte-carlo problem.
The Cholesky Decomposition (CD) and the Eigen Decomposition (ED) - and for that matter the actual Matrix Square Root (MSR) are all ways in which a positive semi-definite matrix (PSD) can be broken down.
Consider the SVD of a PSD matrix, $P = USV^T$. Since P is PSD, this is actually the same as the ED with $P = USU^T$. Moreover, we can split the diagonal matrix by its square root: $P = U\sqrt{S}\sqrt{S}^TU^T$, noting that $\sqrt{S} = \sqrt{S}^T$.
We may now introduce an arbitrary orthogonal matrix $O$:
$P = U\sqrt{S}OO^T\sqrt{S}^TU^T = (U\sqrt{S}O)(U\sqrt{S}O)^T$.
The choice of $O$ actually affects the estimation performance, especially when there is strong off-diagonal elements of the covariance matrix.
The paper studied three choices of $O$:
$O = I$, which corresponds to the ED;
$O = Q$ from the QR decomposition of $U\sqrt{S} = QR$, which corresponds to the CD; and
$O = U^T$ which leads to a symmetric matrix (i.e. MSR)
From which the following conclusions were drawn in the paper after much analysis (quoting):
For a to-be-transformed random variable with uncorrelated elements all the three considered MDs provide identical sigma points and hence
they make almost no difference on quality of the [Unscented Transform] approximation. In
such a case the CD may be preferred for its low costs.
If the random variable contains correlated elements, the use of different [decompositions] may significantly affect quality of the [Unscented Transform] approximation
of the mean or covariance matrix of the transformed random variable.
The two cases above showed that the [ED] should be preferred.
If the elements of the to-be-transformed variable exhibit strong correlation so that the corresponding covariance matrix is nearly
singular, another issue must be taken into account, which is numerical
stability of the algorithm computing the MD. The SVD is much more
numerically stable for nearly singular covariance matrices than the
ChD.
Reference:
Straka, O.; Dunik, J.; Simandl, M. & Havlik, J. "Aspects and comparison of matrix decompositions in unscented Kalman filter", American Control Conference (ACC), 2013, 2013, 3075-3080.
|
Cholesky versus eigendecomposition for drawing samples from a multivariate normal distribution
The problem was studied by by Straka et.al for the Unscented Kalman Filter which draws (deterministic) samples from a multivariate Normal distribution as part of the algorithm. With some luck, the re
|
13,366
|
Cholesky versus eigendecomposition for drawing samples from a multivariate normal distribution
|
Here is a simple illustration using R to compare the computation time of the two method.
library(mvtnorm)
library(clusterGeneration)
set.seed(1234)
mean <- rnorm(1000, 0, 1)
sigma <- genPositiveDefMat(1000)
sigma <- sigma$Sigma
eigen.time <- system.time(
rmvnorm(n=1000, mean=mean, sigma = sigma, method = "eigen")
)
chol.time <- system.time(
rmvnorm(n=1000, mean=mean, sigma = sigma, method = "chol")
)
The running times are
> eigen.time
user system elapsed
5.16 0.06 5.33
> chol.time
user system elapsed
1.74 0.15 1.90
When increasing the sample size to 10000, the running times are
> eigen.time <- system.time(
+ rmvnorm(n=10000, mean=mean, sigma = sigma, method = "eigen")
+ )
>
> chol.time <- system.time(
+ rmvnorm(n=10000, mean=mean, sigma = sigma, method = "chol")
+ )
> eigen.time
user system elapsed
15.74 0.28 16.19
> chol.time
user system elapsed
11.61 0.19 11.89
Hope this helps.
|
Cholesky versus eigendecomposition for drawing samples from a multivariate normal distribution
|
Here is a simple illustration using R to compare the computation time of the two method.
library(mvtnorm)
library(clusterGeneration)
set.seed(1234)
mean <- rnorm(1000, 0, 1)
sigma <- genPositiveDefMat
|
Cholesky versus eigendecomposition for drawing samples from a multivariate normal distribution
Here is a simple illustration using R to compare the computation time of the two method.
library(mvtnorm)
library(clusterGeneration)
set.seed(1234)
mean <- rnorm(1000, 0, 1)
sigma <- genPositiveDefMat(1000)
sigma <- sigma$Sigma
eigen.time <- system.time(
rmvnorm(n=1000, mean=mean, sigma = sigma, method = "eigen")
)
chol.time <- system.time(
rmvnorm(n=1000, mean=mean, sigma = sigma, method = "chol")
)
The running times are
> eigen.time
user system elapsed
5.16 0.06 5.33
> chol.time
user system elapsed
1.74 0.15 1.90
When increasing the sample size to 10000, the running times are
> eigen.time <- system.time(
+ rmvnorm(n=10000, mean=mean, sigma = sigma, method = "eigen")
+ )
>
> chol.time <- system.time(
+ rmvnorm(n=10000, mean=mean, sigma = sigma, method = "chol")
+ )
> eigen.time
user system elapsed
15.74 0.28 16.19
> chol.time
user system elapsed
11.61 0.19 11.89
Hope this helps.
|
Cholesky versus eigendecomposition for drawing samples from a multivariate normal distribution
Here is a simple illustration using R to compare the computation time of the two method.
library(mvtnorm)
library(clusterGeneration)
set.seed(1234)
mean <- rnorm(1000, 0, 1)
sigma <- genPositiveDefMat
|
13,367
|
Cholesky versus eigendecomposition for drawing samples from a multivariate normal distribution
|
Here's the manual, or poor-man's, prove-it-to-myself demonstration:
> set.seed(0)
> # The correlation matrix
> corr_matrix = matrix(cbind(1, .80, .2, .80, 1, .7, .2, .7, 1), nrow=3)
> nvar = 3 # Three columns of correlated data points
> nobs = 1e6 # One million observations for each column
> std_norm = matrix(rnorm(nvar * nobs),nrow=nobs, ncol=nvar) # N(0,1)
$$\text{Corr}=\small \begin{bmatrix}
1 & .8 & .2\\
.8& 1 & .7 \\
.2&.7&1
\end{bmatrix}$$
$$\text{N}=\tiny \begin{bmatrix}
& [,1] & [,2] & [,3] \\
[1,] & -1.0806338 & 0.6563913 & 0.8400443 \\
[2,] & -1.1434241 & -0.1729738 & -0.9884772 \\
\vdots & \vdots & \vdots & \vdots \\
\vdots & \vdots & \vdots & \vdots \\
[999999,] & 0.4861827 & 0.03563006 & -2.1176976 \\
[1000000,] & -0.4394551 & 1.69265517 & -1.9534729\\
\end{bmatrix}$$
1. SVD METHOD:
$$\left[ \bf \underset{[3 \times 3]}{\color{blue}{\Large\,U}}\,\,\,\,\,\underset{\tiny \begin{bmatrix}\sqrt{d_1}&0&0\\0&\sqrt{d_2}&0\\0&0&\sqrt{d_3}\end{bmatrix}}{\Large\color{blue}{\Sigma^{0.5}}} \, \underset{[3\times 10^6]}{\Large\color{blue}{N^T}} \right]^T$$
> ptm <- proc.time()
> # Singular Value Decomposition method:
> svd = svd(corr_matrix)
> rand_data_svd = t(svd$u %*% (diag(3) * sqrt(svd$d)) %*% t(std_norm))
> proc.time() - ptm
user system elapsed
0.29 0.05 0.34
>
> ptm <- proc.time()
2. CHOLESKY METHOD:
$$\bf \left[ \underset{\begin{bmatrix}c_{11}&0&0\\c_{21}&c_{22}&0\\c_{31}&c_{32}&c_{33}\end{bmatrix}}{\Large\color{blue}{\text{Ch}}}\,\,\underset{[3\times 10^6]}{\Large\color{blue}{N^T}} \right]^T$$
> # Cholesky method:
> chole = t(chol(corr_matrix))
> rand_data_chole = t(chole %*% t(std_norm))
> proc.time() - ptm
user system elapsed
0.25 0.03 0.31
Thank you to @userr11852 for pointing out to me that there is a better way to calculate the difference in performance between SVD and Cholesky, in favor of the latter, using the function microbenchmark. At his suggestion, here is the result:
microbenchmark(chol(corr_matrix), svd(corr_matrix))
Unit: microseconds
expr min lq mean median uq max neval cld
chol(corr_matrix) 24.104 25.05 28.74036 25.995 26.467 95.469 100 a
svd(corr_matrix) 108.701 110.12 116.27794 111.065 112.719 223.074 100 b
|
Cholesky versus eigendecomposition for drawing samples from a multivariate normal distribution
|
Here's the manual, or poor-man's, prove-it-to-myself demonstration:
> set.seed(0)
> # The correlation matrix
> corr_matrix = matrix(cbind(1, .80, .2, .80, 1, .7, .2, .7, 1), nrow=3)
> nvar = 3 # Three
|
Cholesky versus eigendecomposition for drawing samples from a multivariate normal distribution
Here's the manual, or poor-man's, prove-it-to-myself demonstration:
> set.seed(0)
> # The correlation matrix
> corr_matrix = matrix(cbind(1, .80, .2, .80, 1, .7, .2, .7, 1), nrow=3)
> nvar = 3 # Three columns of correlated data points
> nobs = 1e6 # One million observations for each column
> std_norm = matrix(rnorm(nvar * nobs),nrow=nobs, ncol=nvar) # N(0,1)
$$\text{Corr}=\small \begin{bmatrix}
1 & .8 & .2\\
.8& 1 & .7 \\
.2&.7&1
\end{bmatrix}$$
$$\text{N}=\tiny \begin{bmatrix}
& [,1] & [,2] & [,3] \\
[1,] & -1.0806338 & 0.6563913 & 0.8400443 \\
[2,] & -1.1434241 & -0.1729738 & -0.9884772 \\
\vdots & \vdots & \vdots & \vdots \\
\vdots & \vdots & \vdots & \vdots \\
[999999,] & 0.4861827 & 0.03563006 & -2.1176976 \\
[1000000,] & -0.4394551 & 1.69265517 & -1.9534729\\
\end{bmatrix}$$
1. SVD METHOD:
$$\left[ \bf \underset{[3 \times 3]}{\color{blue}{\Large\,U}}\,\,\,\,\,\underset{\tiny \begin{bmatrix}\sqrt{d_1}&0&0\\0&\sqrt{d_2}&0\\0&0&\sqrt{d_3}\end{bmatrix}}{\Large\color{blue}{\Sigma^{0.5}}} \, \underset{[3\times 10^6]}{\Large\color{blue}{N^T}} \right]^T$$
> ptm <- proc.time()
> # Singular Value Decomposition method:
> svd = svd(corr_matrix)
> rand_data_svd = t(svd$u %*% (diag(3) * sqrt(svd$d)) %*% t(std_norm))
> proc.time() - ptm
user system elapsed
0.29 0.05 0.34
>
> ptm <- proc.time()
2. CHOLESKY METHOD:
$$\bf \left[ \underset{\begin{bmatrix}c_{11}&0&0\\c_{21}&c_{22}&0\\c_{31}&c_{32}&c_{33}\end{bmatrix}}{\Large\color{blue}{\text{Ch}}}\,\,\underset{[3\times 10^6]}{\Large\color{blue}{N^T}} \right]^T$$
> # Cholesky method:
> chole = t(chol(corr_matrix))
> rand_data_chole = t(chole %*% t(std_norm))
> proc.time() - ptm
user system elapsed
0.25 0.03 0.31
Thank you to @userr11852 for pointing out to me that there is a better way to calculate the difference in performance between SVD and Cholesky, in favor of the latter, using the function microbenchmark. At his suggestion, here is the result:
microbenchmark(chol(corr_matrix), svd(corr_matrix))
Unit: microseconds
expr min lq mean median uq max neval cld
chol(corr_matrix) 24.104 25.05 28.74036 25.995 26.467 95.469 100 a
svd(corr_matrix) 108.701 110.12 116.27794 111.065 112.719 223.074 100 b
|
Cholesky versus eigendecomposition for drawing samples from a multivariate normal distribution
Here's the manual, or poor-man's, prove-it-to-myself demonstration:
> set.seed(0)
> # The correlation matrix
> corr_matrix = matrix(cbind(1, .80, .2, .80, 1, .7, .2, .7, 1), nrow=3)
> nvar = 3 # Three
|
13,368
|
Cox baseline hazard
|
Apparently, basehaz() actually computes a cumulative hazard rate, rather than the hazard rate itself. The formula is as follows:
$$
\hat{H}_0(t) = \sum_{y_{(l)} \leq t} \hat{h}_0(y_{(l)}),
$$
with
$$
\hat{h}_0(y_{(l)}) = \frac{d_{(l)}}{\sum_{j \in R(y_{(l)})} \exp(\mathbf{x}^{\prime}_j \mathbf{\beta})}
$$
where $y_{(1)} < y_{(2)} < \cdots$ denote the distinct event times, $d_{(l)}$ is the number of events at $y_{(l)}$, and $R(y_{(l)})$ is the risk set at $y_{(l)}$ containing all individuals still susceptible to the event at $y_{(l)}$.
Let's try this. (The following code is there for illustration only and is not intended to be very well written.)
#------package------
library(survival)
#------some data------
data(kidney)
#------preparation------
tab <- data.frame(table(kidney[kidney$status == 1, "time"]))
y <- as.numeric(levels(tab[, 1]))[tab[, 1]] #ordered distinct event times
d <- tab[, 2] #number of events
#------Cox model------
fit<-coxph(Surv(time, status)~age, data=kidney)
#------cumulative hazard obtained from basehaz()------
H0 <- basehaz(fit, centered=FALSE)
H0 <- H0[H0[, 2] %in% y, ] #only keep rows where events occurred
#------my quick implementation------
betaHat <- fit$coef
h0 <- rep(NA, length(y))
for(l in 1:length(y))
{
h0[l] <- d[l] / sum(exp(kidney[kidney$time >= y[l], "age"] * betaHat))
}
#------comparison------
cbind(H0, cumsum(h0))
partial output:
hazard time cumsum(h0)
1 0.01074980 2 0.01074980
5 0.03399089 7 0.03382306
6 0.05790570 8 0.05757756
7 0.07048941 9 0.07016127
8 0.09625105 12 0.09573508
9 0.10941921 13 0.10890324
10 0.13691424 15 0.13616338
I suspect that the slight difference might be due to the approximation of the partial likelihood in coxph() due to ties in the data...
|
Cox baseline hazard
|
Apparently, basehaz() actually computes a cumulative hazard rate, rather than the hazard rate itself. The formula is as follows:
$$
\hat{H}_0(t) = \sum_{y_{(l)} \leq t} \hat{h}_0(y_{(l)}),
$$
with
$$
|
Cox baseline hazard
Apparently, basehaz() actually computes a cumulative hazard rate, rather than the hazard rate itself. The formula is as follows:
$$
\hat{H}_0(t) = \sum_{y_{(l)} \leq t} \hat{h}_0(y_{(l)}),
$$
with
$$
\hat{h}_0(y_{(l)}) = \frac{d_{(l)}}{\sum_{j \in R(y_{(l)})} \exp(\mathbf{x}^{\prime}_j \mathbf{\beta})}
$$
where $y_{(1)} < y_{(2)} < \cdots$ denote the distinct event times, $d_{(l)}$ is the number of events at $y_{(l)}$, and $R(y_{(l)})$ is the risk set at $y_{(l)}$ containing all individuals still susceptible to the event at $y_{(l)}$.
Let's try this. (The following code is there for illustration only and is not intended to be very well written.)
#------package------
library(survival)
#------some data------
data(kidney)
#------preparation------
tab <- data.frame(table(kidney[kidney$status == 1, "time"]))
y <- as.numeric(levels(tab[, 1]))[tab[, 1]] #ordered distinct event times
d <- tab[, 2] #number of events
#------Cox model------
fit<-coxph(Surv(time, status)~age, data=kidney)
#------cumulative hazard obtained from basehaz()------
H0 <- basehaz(fit, centered=FALSE)
H0 <- H0[H0[, 2] %in% y, ] #only keep rows where events occurred
#------my quick implementation------
betaHat <- fit$coef
h0 <- rep(NA, length(y))
for(l in 1:length(y))
{
h0[l] <- d[l] / sum(exp(kidney[kidney$time >= y[l], "age"] * betaHat))
}
#------comparison------
cbind(H0, cumsum(h0))
partial output:
hazard time cumsum(h0)
1 0.01074980 2 0.01074980
5 0.03399089 7 0.03382306
6 0.05790570 8 0.05757756
7 0.07048941 9 0.07016127
8 0.09625105 12 0.09573508
9 0.10941921 13 0.10890324
10 0.13691424 15 0.13616338
I suspect that the slight difference might be due to the approximation of the partial likelihood in coxph() due to ties in the data...
|
Cox baseline hazard
Apparently, basehaz() actually computes a cumulative hazard rate, rather than the hazard rate itself. The formula is as follows:
$$
\hat{H}_0(t) = \sum_{y_{(l)} \leq t} \hat{h}_0(y_{(l)}),
$$
with
$$
|
13,369
|
Confidence interval around the ratio of two proportions
|
The standard way to do this in epidemiology (where a ratio of proportions is usually referred to as a risk ratio) is to first log-transform the ratio, calculate a confidence interval on the log scale using the delta method and assuming a normal distribution, then transform back. This works better in moderate sample sizes than using the delta method on the untransformed scale, though it will still behave poorly if the number of events in either group is very small, and fails completely if there are no events in either group.
If there are $x_1$ and $x_2$ successes in the two groups out of totals $n_1$ and $n_2$, then the obvious estimate for the ratio of proportions is $$\hat\theta = \frac{x_1/n_1}{x_2/n_2}.$$
Using the delta method and assuming the two groups are independent and the successes are binomially distributed, you can show that $$\operatorname{Var}(\log \hat\theta) = 1/x_1 - 1/n_1 +1/x_2 - 1/n_2.$$
Taking the square-root of this gives the standard error $\operatorname{SE}(\log \hat\theta)$. Assuming that $\log \hat\theta$ is normally distributed, a 95% confidence interval for $\log \theta$ is $$\log \hat\theta \pm 1.96 \operatorname{SE}(\log \hat\theta).$$
Exponentiating this gives a 95% confidence interval for the ratio of proportions $\theta$ as $$\hat\theta \exp\left[ \pm1.96 \operatorname{SE}(\log\hat\theta)\right].$$
|
Confidence interval around the ratio of two proportions
|
The standard way to do this in epidemiology (where a ratio of proportions is usually referred to as a risk ratio) is to first log-transform the ratio, calculate a confidence interval on the log scale
|
Confidence interval around the ratio of two proportions
The standard way to do this in epidemiology (where a ratio of proportions is usually referred to as a risk ratio) is to first log-transform the ratio, calculate a confidence interval on the log scale using the delta method and assuming a normal distribution, then transform back. This works better in moderate sample sizes than using the delta method on the untransformed scale, though it will still behave poorly if the number of events in either group is very small, and fails completely if there are no events in either group.
If there are $x_1$ and $x_2$ successes in the two groups out of totals $n_1$ and $n_2$, then the obvious estimate for the ratio of proportions is $$\hat\theta = \frac{x_1/n_1}{x_2/n_2}.$$
Using the delta method and assuming the two groups are independent and the successes are binomially distributed, you can show that $$\operatorname{Var}(\log \hat\theta) = 1/x_1 - 1/n_1 +1/x_2 - 1/n_2.$$
Taking the square-root of this gives the standard error $\operatorname{SE}(\log \hat\theta)$. Assuming that $\log \hat\theta$ is normally distributed, a 95% confidence interval for $\log \theta$ is $$\log \hat\theta \pm 1.96 \operatorname{SE}(\log \hat\theta).$$
Exponentiating this gives a 95% confidence interval for the ratio of proportions $\theta$ as $$\hat\theta \exp\left[ \pm1.96 \operatorname{SE}(\log\hat\theta)\right].$$
|
Confidence interval around the ratio of two proportions
The standard way to do this in epidemiology (where a ratio of proportions is usually referred to as a risk ratio) is to first log-transform the ratio, calculate a confidence interval on the log scale
|
13,370
|
Why does ridge regression classifier work quite well for text classification?
|
Text classification problems tend to be quite high dimensional (many features), and high dimensional problems are likely to be linearly separable (as you can separate any d+1 points in a d-dimensional space with a linear classifier, regardless of how the points are labelled). So linear classifiers, whether ridge regression or SVM with a linear kernel, are likely to do well. In both cases, the ridge parameter or C for the SVM (as tdc mentions +1) control the complexity of the classifier and help to avoid over-fitting by separating the patterns of each class by large margins (i.e. the decision surface passes down the middle of the gap between the two collections of points). However to get good performance the ridge/regularisation parameters need to be properly tuned (I use leave-one-out cross-validation as it is cheap).
However, the reason that ridge regression works well is that non-linear methods are too powerful and it is difficult to avoid over-fitting. There may be a non-linear classifier that gives better generalisation performance than the best linear model, but it is too difficult to estimate those parameters using the finite sample of training data that we have. In practice, the simpler the model, the less problem we have in estimating the parameters, so there is less tendency to over-fit, so we get better results in practice.
Another issues is feature selection, ridge regression avoids over-fitting by regularising the weights to keep them small, and model selection is straight forward as you only have to choose the value of a single regression parameter. If you try to avoid over-fitting by picking the optimal set of features, then model selection becomes difficult as there is a degree of freedom (sort of) for each feature, which makes it possible to over-fit the feature selection criterion and you end up with a set of features that is optimal for this particular sample of data, but which gives poor generalisation performance. So not performing feature selection and using regularisation can often give better predictive performance.
I often use Bagging (form a committee of models trained on bootstraped samples from the training set) with ridge-regression models, which often gives an improvement in performance, and as all the models are linear you can combine them to form a single linear model, so there is no performance hit in operation.
|
Why does ridge regression classifier work quite well for text classification?
|
Text classification problems tend to be quite high dimensional (many features), and high dimensional problems are likely to be linearly separable (as you can separate any d+1 points in a d-dimensional
|
Why does ridge regression classifier work quite well for text classification?
Text classification problems tend to be quite high dimensional (many features), and high dimensional problems are likely to be linearly separable (as you can separate any d+1 points in a d-dimensional space with a linear classifier, regardless of how the points are labelled). So linear classifiers, whether ridge regression or SVM with a linear kernel, are likely to do well. In both cases, the ridge parameter or C for the SVM (as tdc mentions +1) control the complexity of the classifier and help to avoid over-fitting by separating the patterns of each class by large margins (i.e. the decision surface passes down the middle of the gap between the two collections of points). However to get good performance the ridge/regularisation parameters need to be properly tuned (I use leave-one-out cross-validation as it is cheap).
However, the reason that ridge regression works well is that non-linear methods are too powerful and it is difficult to avoid over-fitting. There may be a non-linear classifier that gives better generalisation performance than the best linear model, but it is too difficult to estimate those parameters using the finite sample of training data that we have. In practice, the simpler the model, the less problem we have in estimating the parameters, so there is less tendency to over-fit, so we get better results in practice.
Another issues is feature selection, ridge regression avoids over-fitting by regularising the weights to keep them small, and model selection is straight forward as you only have to choose the value of a single regression parameter. If you try to avoid over-fitting by picking the optimal set of features, then model selection becomes difficult as there is a degree of freedom (sort of) for each feature, which makes it possible to over-fit the feature selection criterion and you end up with a set of features that is optimal for this particular sample of data, but which gives poor generalisation performance. So not performing feature selection and using regularisation can often give better predictive performance.
I often use Bagging (form a committee of models trained on bootstraped samples from the training set) with ridge-regression models, which often gives an improvement in performance, and as all the models are linear you can combine them to form a single linear model, so there is no performance hit in operation.
|
Why does ridge regression classifier work quite well for text classification?
Text classification problems tend to be quite high dimensional (many features), and high dimensional problems are likely to be linearly separable (as you can separate any d+1 points in a d-dimensional
|
13,371
|
Why does ridge regression classifier work quite well for text classification?
|
Ridge regression, as the name suggests, is a method for regression rather than classification. Presumably you are using a threshold to turn it into a classifier. In any case, you are simply learning a linear classifier that is defined by a hyperplane. The reason it is working is because the task at hand is essentially linearly separable - i.e. a simple hyperplane is all that is needed to separate the classes. The "ridge" parameter allows it to work in cases that are not completely linearly separable or problems which are rank deficient (in which case the optimisation would be degenerate).
In this case, there is no reason why other classifiers shouldn't also perform well, assuming that they have been implemented correctly. For example, the SVM finds the "optimal separating hyperplane" (i.e. the hyperplane that maximises the margin, or gap, between the classes). The C parameter of the SVM is a capacity control parameter analogous to the ridge parameter, which allows for some misclassifications (outliers). Assuming the parameter selection process has been carried out diligently, I would expect the two methods to produce almost exactly the same results on such a dataset.
|
Why does ridge regression classifier work quite well for text classification?
|
Ridge regression, as the name suggests, is a method for regression rather than classification. Presumably you are using a threshold to turn it into a classifier. In any case, you are simply learning a
|
Why does ridge regression classifier work quite well for text classification?
Ridge regression, as the name suggests, is a method for regression rather than classification. Presumably you are using a threshold to turn it into a classifier. In any case, you are simply learning a linear classifier that is defined by a hyperplane. The reason it is working is because the task at hand is essentially linearly separable - i.e. a simple hyperplane is all that is needed to separate the classes. The "ridge" parameter allows it to work in cases that are not completely linearly separable or problems which are rank deficient (in which case the optimisation would be degenerate).
In this case, there is no reason why other classifiers shouldn't also perform well, assuming that they have been implemented correctly. For example, the SVM finds the "optimal separating hyperplane" (i.e. the hyperplane that maximises the margin, or gap, between the classes). The C parameter of the SVM is a capacity control parameter analogous to the ridge parameter, which allows for some misclassifications (outliers). Assuming the parameter selection process has been carried out diligently, I would expect the two methods to produce almost exactly the same results on such a dataset.
|
Why does ridge regression classifier work quite well for text classification?
Ridge regression, as the name suggests, is a method for regression rather than classification. Presumably you are using a threshold to turn it into a classifier. In any case, you are simply learning a
|
13,372
|
How to add periodic component to linear regression model?
|
You could try the wonderful stl() method -- it decomposes (using iterated loess() fitting) into trend and seasonal and remainder. This may just pick up your oscillations here.
|
How to add periodic component to linear regression model?
|
You could try the wonderful stl() method -- it decomposes (using iterated loess() fitting) into trend and seasonal and remainder. This may just pick up your oscillations here.
|
How to add periodic component to linear regression model?
You could try the wonderful stl() method -- it decomposes (using iterated loess() fitting) into trend and seasonal and remainder. This may just pick up your oscillations here.
|
How to add periodic component to linear regression model?
You could try the wonderful stl() method -- it decomposes (using iterated loess() fitting) into trend and seasonal and remainder. This may just pick up your oscillations here.
|
13,373
|
How to add periodic component to linear regression model?
|
If you know the frequency of the oscillation, you can include two additional predictors, sin(2π w t) and cos(2π w t) -- set w to get the desired wavelength -- and this will model the oscillation. You need both terms to fit the amplitude and the phase angle. If there is more than one frequency, you will need a sine and cosine term for each frequency.
If you don't know what the frequencies are, the standard way to isolate multiple frequencies is to detrend the data (get the residuals from the linear fit, as you have done) and run a discrete Fourier transform against the residuals. A quick and dirty way to do this is in MS-Excel, which has a Fourier Analysis tool in the Data Analysis Add-In. Run the analysis against the residuals, take the absolute value of the transforms, and bar graph the result. The peaks will be your major frequency components that you want to model.
When you add these cyclic predictors, pay close attention to their p-values in your regression, and don't overfit. Use only those frequencies that are statistically significant. Unfortunately, this may make fitting the low frequencies a little difficult.
|
How to add periodic component to linear regression model?
|
If you know the frequency of the oscillation, you can include two additional predictors, sin(2π w t) and cos(2π w t) -- set w to get the desired wavelength -- and this will model the oscillation. You
|
How to add periodic component to linear regression model?
If you know the frequency of the oscillation, you can include two additional predictors, sin(2π w t) and cos(2π w t) -- set w to get the desired wavelength -- and this will model the oscillation. You need both terms to fit the amplitude and the phase angle. If there is more than one frequency, you will need a sine and cosine term for each frequency.
If you don't know what the frequencies are, the standard way to isolate multiple frequencies is to detrend the data (get the residuals from the linear fit, as you have done) and run a discrete Fourier transform against the residuals. A quick and dirty way to do this is in MS-Excel, which has a Fourier Analysis tool in the Data Analysis Add-In. Run the analysis against the residuals, take the absolute value of the transforms, and bar graph the result. The peaks will be your major frequency components that you want to model.
When you add these cyclic predictors, pay close attention to their p-values in your regression, and don't overfit. Use only those frequencies that are statistically significant. Unfortunately, this may make fitting the low frequencies a little difficult.
|
How to add periodic component to linear regression model?
If you know the frequency of the oscillation, you can include two additional predictors, sin(2π w t) and cos(2π w t) -- set w to get the desired wavelength -- and this will model the oscillation. You
|
13,374
|
How to add periodic component to linear regression model?
|
Let's begin by observing that ordinary least squares fitting for these data is likely inappropriate. If the individual data being accumulated are assumed, as usual, to have random error components, then the error in the cumulative data (not the cumulative frequencies--that's something different than what you have) is the cumulative sum of all the error terms. This makes the cumulative data heteroscedastic (they become more and more variable over time) and strongly positively correlated. Because these data are so regularly behaved, and there's so much of them, there's little problem with the fit you will get, but your estimates of errors, your predictions (which is what the question is all about), and especially your standard errors of prediction can be way off.
A standard procedure for analyzing such data starts with the original values. Take the day-to-day differences to remove the higher-frequency sinusoidal component. Take the weekly differences of those to remove a possible week-to-week cycle. Analyze what's left. ARIMA modeling is a powerful flexible approach, but start simply: graph those differenced data to see what's going on, then move on from there. Note, too, that with less than two weeks of data your estimates of the weekly cycle will be poor and this uncertainty will dominate the uncertainty in the predictions.
|
How to add periodic component to linear regression model?
|
Let's begin by observing that ordinary least squares fitting for these data is likely inappropriate. If the individual data being accumulated are assumed, as usual, to have random error components, t
|
How to add periodic component to linear regression model?
Let's begin by observing that ordinary least squares fitting for these data is likely inappropriate. If the individual data being accumulated are assumed, as usual, to have random error components, then the error in the cumulative data (not the cumulative frequencies--that's something different than what you have) is the cumulative sum of all the error terms. This makes the cumulative data heteroscedastic (they become more and more variable over time) and strongly positively correlated. Because these data are so regularly behaved, and there's so much of them, there's little problem with the fit you will get, but your estimates of errors, your predictions (which is what the question is all about), and especially your standard errors of prediction can be way off.
A standard procedure for analyzing such data starts with the original values. Take the day-to-day differences to remove the higher-frequency sinusoidal component. Take the weekly differences of those to remove a possible week-to-week cycle. Analyze what's left. ARIMA modeling is a powerful flexible approach, but start simply: graph those differenced data to see what's going on, then move on from there. Note, too, that with less than two weeks of data your estimates of the weekly cycle will be poor and this uncertainty will dominate the uncertainty in the predictions.
|
How to add periodic component to linear regression model?
Let's begin by observing that ordinary least squares fitting for these data is likely inappropriate. If the individual data being accumulated are assumed, as usual, to have random error components, t
|
13,375
|
How to add periodic component to linear regression model?
|
Clearly the dominant oscillation has period one day. Looks like there are also lower-frequency components relating to the day of the week, so add a component with frequency one week (i.e. one-seventh of a day) and its first few harmonics. That gives a model of the form:
$$\mbox{E}(y) = c + a_0 \cos(2\pi t) + b_0 \sin(2\pi t) + a_1 \cos(2 \pi t/7) + b_1 \sin(2 \pi t/7) + a_2 \cos(4 \pi t/7) + b_2 \sin(4 \pi t/7) + \ldots $$
– assuming $t$ is measured in days. Here $y$ is the raw data, not its cumulative sum.
|
How to add periodic component to linear regression model?
|
Clearly the dominant oscillation has period one day. Looks like there are also lower-frequency components relating to the day of the week, so add a component with frequency one week (i.e. one-seventh
|
How to add periodic component to linear regression model?
Clearly the dominant oscillation has period one day. Looks like there are also lower-frequency components relating to the day of the week, so add a component with frequency one week (i.e. one-seventh of a day) and its first few harmonics. That gives a model of the form:
$$\mbox{E}(y) = c + a_0 \cos(2\pi t) + b_0 \sin(2\pi t) + a_1 \cos(2 \pi t/7) + b_1 \sin(2 \pi t/7) + a_2 \cos(4 \pi t/7) + b_2 \sin(4 \pi t/7) + \ldots $$
– assuming $t$ is measured in days. Here $y$ is the raw data, not its cumulative sum.
|
How to add periodic component to linear regression model?
Clearly the dominant oscillation has period one day. Looks like there are also lower-frequency components relating to the day of the week, so add a component with frequency one week (i.e. one-seventh
|
13,376
|
Moments of a distribution - any use for partial or higher moments?
|
Aside from special properties of a few numbers (e.g., 2), the only real reason to single out integer moments as opposed to fractional moments is convenience.
Higher moments can be used to understand tail behavior. For example, a centered random variable $X$ with variance 1 has subgaussian tails (i.e. $\mathbb{P}(|X| > t) < C e^{-ct^2}$ for some constants $c,C > 0$) if and only if $\mathbb{E}|X|^p \le (A \sqrt{p})^p$ for every $p\ge 1$ and some constant $A > 0$.
|
Moments of a distribution - any use for partial or higher moments?
|
Aside from special properties of a few numbers (e.g., 2), the only real reason to single out integer moments as opposed to fractional moments is convenience.
Higher moments can be used to understand t
|
Moments of a distribution - any use for partial or higher moments?
Aside from special properties of a few numbers (e.g., 2), the only real reason to single out integer moments as opposed to fractional moments is convenience.
Higher moments can be used to understand tail behavior. For example, a centered random variable $X$ with variance 1 has subgaussian tails (i.e. $\mathbb{P}(|X| > t) < C e^{-ct^2}$ for some constants $c,C > 0$) if and only if $\mathbb{E}|X|^p \le (A \sqrt{p})^p$ for every $p\ge 1$ and some constant $A > 0$.
|
Moments of a distribution - any use for partial or higher moments?
Aside from special properties of a few numbers (e.g., 2), the only real reason to single out integer moments as opposed to fractional moments is convenience.
Higher moments can be used to understand t
|
13,377
|
Moments of a distribution - any use for partial or higher moments?
|
I get suspicious when I hear people ask about third and fourth moments. There are two common errors people often have in mind when they bring up the topic. I'm not saying that you are necessarily making these mistakes, but they do come up often.
First, it sounds like they implicitly believe that distributions can be boiled down to four numbers; they suspect that just two numbers is not enough, but three or four should be plenty.
Second, it sounds like hearkening back to the moment-matching approach to statistics that has largely lost out to maximum likelihood methods in contemporary statistics.
Update: I expanded this answer into a blog post.
|
Moments of a distribution - any use for partial or higher moments?
|
I get suspicious when I hear people ask about third and fourth moments. There are two common errors people often have in mind when they bring up the topic. I'm not saying that you are necessarily mak
|
Moments of a distribution - any use for partial or higher moments?
I get suspicious when I hear people ask about third and fourth moments. There are two common errors people often have in mind when they bring up the topic. I'm not saying that you are necessarily making these mistakes, but they do come up often.
First, it sounds like they implicitly believe that distributions can be boiled down to four numbers; they suspect that just two numbers is not enough, but three or four should be plenty.
Second, it sounds like hearkening back to the moment-matching approach to statistics that has largely lost out to maximum likelihood methods in contemporary statistics.
Update: I expanded this answer into a blog post.
|
Moments of a distribution - any use for partial or higher moments?
I get suspicious when I hear people ask about third and fourth moments. There are two common errors people often have in mind when they bring up the topic. I'm not saying that you are necessarily mak
|
13,378
|
Moments of a distribution - any use for partial or higher moments?
|
One example of use (interpretation is a better qualifier) of a higher moment: the fifth moment of a univariate distribution measures the asymmetry of its tails.
|
Moments of a distribution - any use for partial or higher moments?
|
One example of use (interpretation is a better qualifier) of a higher moment: the fifth moment of a univariate distribution measures the asymmetry of its tails.
|
Moments of a distribution - any use for partial or higher moments?
One example of use (interpretation is a better qualifier) of a higher moment: the fifth moment of a univariate distribution measures the asymmetry of its tails.
|
Moments of a distribution - any use for partial or higher moments?
One example of use (interpretation is a better qualifier) of a higher moment: the fifth moment of a univariate distribution measures the asymmetry of its tails.
|
13,379
|
How to simulate data to be statistically significant?
|
General Comments
"I am in 10th grade and I am looking to simulate data for a machine learning science fair project." Awesome. I did not care at all about math in 10th grade; I think I took something like Algebra 2 that year...? I can't wait until you put me out of a job in a few years! I give some advice below, but: What are you trying to learn from this simulation? What are you already familiar with in statistics and machine learning? Knowing this would help me (and others) put together some more specific help.
Python is a very useful language, but I'm of the opinion that R is better for simulating data. Most of the books/blogs/studies/classes I've come across on simulating data (also what people call "Monte Carlo methods" to be fancy) are in R. The R language is known as being "by statisticians, for statisticians," and most academics—that rely on simulation studies to show their methods work—use R. A lot of cool functions are in the base R language (that is, no additional packages necessary), such as rnorm for a normal distribution, runif for the uniform distribution, rbeta for the beta distribution, and so on. In R, typing in ?Distributions will show you a help page on them. However, there are many other cool packages like mvtnorm or simstudy that are useful. I would recommend DataCamp.com for learning R, if you only know Python; I think they are good for getting gently introduced to things
It seems like you have a lot going on here: You want data that are over time (longitudinal), within-subject (maybe using a multilevel model), and have a seasonal component to them (perhaps a time series model), all predicting a dichotomous outcome (something like a logistic regression). I think a lot of people starting out with simulation studies (including myself) want to throw a bunch of stuff in at once, but this can be really daunting and complicated. So what I would recommend doing is starting with something simple—maybe making a function or two for generating data—and then build up from there.
Specific Comments
It looks like your basic hypothesis is: "The time of the day predicts whether or not someone adheres to taking their medication." And you would like two create two simulated data sets: One where there is a relationship and one where there is not.
You also mention simulating data to represent multiple observations from the same person. This means that each person would have their own probability of adherence as well as, perhaps, their own slope for the relationship between time of day and probability of adhering. I would suggest looking into "multilevel" or "hierarchical" regression models for this type of relationship, but I think you could start simpler than this.
Also, you mention a continuous relationship between time and probability of adhering to the medication regimen, which also makes me think time series modeling—specifically looking at seasonal trends—would be helpful for you. This is also simulate-able, but again, I think we can start simpler.
Let's say we have 1000 people, and we measure whether or not they took their medicine only once. We also know if they were assigned to take it in the morning, afternoon, or evening. Let's say that taking the medicine is 1, not taking it is 0. We can simulate dichotomous data using rbinom for draws from a binomial distribution. We can set each person to have 1 observation with a given probability. Let's say people are 80% likely to take it in the morning, 50% in afternoon, and 65% at night. I paste the code below, with some comments after #:
set.seed(1839) # this makes sure the results are replicable when you do it
n <- 1000 # sample size is 1000
times <- c("morning", "afternoon", "evening") # create a vector of times
time <- sample(times, n, TRUE) # create our time variable
# make adherence probabilities based on time
adhere_prob <- ifelse(
time == "morning", .80,
ifelse(
time == "afternoon", .50, .65
)
)
# simulate observations from binomial distribution with those probabilities
adhere <- rbinom(n, 1, adhere_prob)
# run a logistic regression, predicting adherence from time
model <- glm(adhere ~ time, family = binomial)
summary(model)
This summary shows, in part:
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.02882 0.10738 0.268 0.78839
timeevening 0.45350 0.15779 2.874 0.00405 **
timemorning 1.39891 0.17494 7.996 1.28e-15 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
The Intercept represents the afternoon, and we can see that both the evening and morning are significantly higher probability of adhering. There are a lot of details about logistic regression that I can't explain in this post, but t-tests assume that you have a conditionally normally-distributed dependent variable. Logistic regression models are more appropriate when you have dichotomous (0 vs. 1) outcomes like these. Most introductory statistics books will talk about the t-test, and a lot of introductory machine learning books will talk about logistic regression. I think Introduction to Statistical Learning: With Applications in R is great, and the authors posted the whole thing online: https://www-bcf.usc.edu/~gareth/ISL/ISLR%20First%20Printing.pdf
I'm not as sure about good books for simulation studies; I learned just from messing around, reading what other people did, and from a graduate course I took on statistical computing (professor's materials are here: http://pj.freefaculty.org/guides/).
Lastly, you can also simulate having no effect by setting all of the times to have the same probability:
set.seed(1839)
n <- 1000
times <- c("morning", "afternoon", "evening")
time <- sample(times, n, TRUE)
adhere <- rbinom(n, 1, .6) # same for all times
summary(glm(adhere ~ time, binomial))
Which returns:
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.40306 0.10955 3.679 0.000234 ***
timeevening -0.06551 0.15806 -0.414 0.678535
timemorning 0.18472 0.15800 1.169 0.242360
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
This shows no significant differences between the times, as we would expect from the probability being the same across times.
|
How to simulate data to be statistically significant?
|
General Comments
"I am in 10th grade and I am looking to simulate data for a machine learning science fair project." Awesome. I did not care at all about math in 10th grade; I think I took something
|
How to simulate data to be statistically significant?
General Comments
"I am in 10th grade and I am looking to simulate data for a machine learning science fair project." Awesome. I did not care at all about math in 10th grade; I think I took something like Algebra 2 that year...? I can't wait until you put me out of a job in a few years! I give some advice below, but: What are you trying to learn from this simulation? What are you already familiar with in statistics and machine learning? Knowing this would help me (and others) put together some more specific help.
Python is a very useful language, but I'm of the opinion that R is better for simulating data. Most of the books/blogs/studies/classes I've come across on simulating data (also what people call "Monte Carlo methods" to be fancy) are in R. The R language is known as being "by statisticians, for statisticians," and most academics—that rely on simulation studies to show their methods work—use R. A lot of cool functions are in the base R language (that is, no additional packages necessary), such as rnorm for a normal distribution, runif for the uniform distribution, rbeta for the beta distribution, and so on. In R, typing in ?Distributions will show you a help page on them. However, there are many other cool packages like mvtnorm or simstudy that are useful. I would recommend DataCamp.com for learning R, if you only know Python; I think they are good for getting gently introduced to things
It seems like you have a lot going on here: You want data that are over time (longitudinal), within-subject (maybe using a multilevel model), and have a seasonal component to them (perhaps a time series model), all predicting a dichotomous outcome (something like a logistic regression). I think a lot of people starting out with simulation studies (including myself) want to throw a bunch of stuff in at once, but this can be really daunting and complicated. So what I would recommend doing is starting with something simple—maybe making a function or two for generating data—and then build up from there.
Specific Comments
It looks like your basic hypothesis is: "The time of the day predicts whether or not someone adheres to taking their medication." And you would like two create two simulated data sets: One where there is a relationship and one where there is not.
You also mention simulating data to represent multiple observations from the same person. This means that each person would have their own probability of adherence as well as, perhaps, their own slope for the relationship between time of day and probability of adhering. I would suggest looking into "multilevel" or "hierarchical" regression models for this type of relationship, but I think you could start simpler than this.
Also, you mention a continuous relationship between time and probability of adhering to the medication regimen, which also makes me think time series modeling—specifically looking at seasonal trends—would be helpful for you. This is also simulate-able, but again, I think we can start simpler.
Let's say we have 1000 people, and we measure whether or not they took their medicine only once. We also know if they were assigned to take it in the morning, afternoon, or evening. Let's say that taking the medicine is 1, not taking it is 0. We can simulate dichotomous data using rbinom for draws from a binomial distribution. We can set each person to have 1 observation with a given probability. Let's say people are 80% likely to take it in the morning, 50% in afternoon, and 65% at night. I paste the code below, with some comments after #:
set.seed(1839) # this makes sure the results are replicable when you do it
n <- 1000 # sample size is 1000
times <- c("morning", "afternoon", "evening") # create a vector of times
time <- sample(times, n, TRUE) # create our time variable
# make adherence probabilities based on time
adhere_prob <- ifelse(
time == "morning", .80,
ifelse(
time == "afternoon", .50, .65
)
)
# simulate observations from binomial distribution with those probabilities
adhere <- rbinom(n, 1, adhere_prob)
# run a logistic regression, predicting adherence from time
model <- glm(adhere ~ time, family = binomial)
summary(model)
This summary shows, in part:
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.02882 0.10738 0.268 0.78839
timeevening 0.45350 0.15779 2.874 0.00405 **
timemorning 1.39891 0.17494 7.996 1.28e-15 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
The Intercept represents the afternoon, and we can see that both the evening and morning are significantly higher probability of adhering. There are a lot of details about logistic regression that I can't explain in this post, but t-tests assume that you have a conditionally normally-distributed dependent variable. Logistic regression models are more appropriate when you have dichotomous (0 vs. 1) outcomes like these. Most introductory statistics books will talk about the t-test, and a lot of introductory machine learning books will talk about logistic regression. I think Introduction to Statistical Learning: With Applications in R is great, and the authors posted the whole thing online: https://www-bcf.usc.edu/~gareth/ISL/ISLR%20First%20Printing.pdf
I'm not as sure about good books for simulation studies; I learned just from messing around, reading what other people did, and from a graduate course I took on statistical computing (professor's materials are here: http://pj.freefaculty.org/guides/).
Lastly, you can also simulate having no effect by setting all of the times to have the same probability:
set.seed(1839)
n <- 1000
times <- c("morning", "afternoon", "evening")
time <- sample(times, n, TRUE)
adhere <- rbinom(n, 1, .6) # same for all times
summary(glm(adhere ~ time, binomial))
Which returns:
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.40306 0.10955 3.679 0.000234 ***
timeevening -0.06551 0.15806 -0.414 0.678535
timemorning 0.18472 0.15800 1.169 0.242360
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
This shows no significant differences between the times, as we would expect from the probability being the same across times.
|
How to simulate data to be statistically significant?
General Comments
"I am in 10th grade and I am looking to simulate data for a machine learning science fair project." Awesome. I did not care at all about math in 10th grade; I think I took something
|
13,380
|
How to simulate data to be statistically significant?
|
If you already know some Python, then you will definitely be able to achieve what you need using base Python along with numpy and/or pandas. As Mark White suggests though, a lot of simulation and stats-related stuff is baked into R, so definitely worth a look.
Below is a basic framework for how you might approach this using a Python class. You could use np.random.normal to adjust the baseline_adherence of each subject to insert some noise. This gives you a pseudo-random adherence, to which you can add the targeted reduced adherence on specific days.
import pandas as pd
import numpy as np
from itertools import product
class Patient:
def __init__(self, number, baseline_adherence=0.95):
self.number = number
self.baseline_adherence = baseline_adherence
self.schedule = self.create_schedule()
def __repr__(self):
return "I am patient number {}".format(self.number)
def create_schedule(self):
time_slots = []
for (day, time) in product(range(1, 8), range(1, 4)):
time_slots.append("Day {}; Slot {}".format(day, time))
week_labels = ["Week {}".format(x) for x in range(1, 31)]
df = pd.DataFrame(np.random.choice([0, 1],
size=(30, 21),#1 row per week, 1 column per time slot
p=(1-self.baseline_adherence, self.baseline_adherence)),
index=week_labels,
columns=time_slots
)
return df
def targeted_adherence(self, timeslot, adherence=0.8):
if timeslot in self.schedule.columns:
ad = np.random.choice([0, 1],
size=self.schedule[timeslot].shape,
p=(1-adherence, adherence)
)
self.schedule[timeslot] = ad
sim_patients = [Patient(x) for x in range(10)]
p = sim_patients[0]
p.targeted_adherence("Day 1; Slot 3")
|
How to simulate data to be statistically significant?
|
If you already know some Python, then you will definitely be able to achieve what you need using base Python along with numpy and/or pandas. As Mark White suggests though, a lot of simulation and stat
|
How to simulate data to be statistically significant?
If you already know some Python, then you will definitely be able to achieve what you need using base Python along with numpy and/or pandas. As Mark White suggests though, a lot of simulation and stats-related stuff is baked into R, so definitely worth a look.
Below is a basic framework for how you might approach this using a Python class. You could use np.random.normal to adjust the baseline_adherence of each subject to insert some noise. This gives you a pseudo-random adherence, to which you can add the targeted reduced adherence on specific days.
import pandas as pd
import numpy as np
from itertools import product
class Patient:
def __init__(self, number, baseline_adherence=0.95):
self.number = number
self.baseline_adherence = baseline_adherence
self.schedule = self.create_schedule()
def __repr__(self):
return "I am patient number {}".format(self.number)
def create_schedule(self):
time_slots = []
for (day, time) in product(range(1, 8), range(1, 4)):
time_slots.append("Day {}; Slot {}".format(day, time))
week_labels = ["Week {}".format(x) for x in range(1, 31)]
df = pd.DataFrame(np.random.choice([0, 1],
size=(30, 21),#1 row per week, 1 column per time slot
p=(1-self.baseline_adherence, self.baseline_adherence)),
index=week_labels,
columns=time_slots
)
return df
def targeted_adherence(self, timeslot, adherence=0.8):
if timeslot in self.schedule.columns:
ad = np.random.choice([0, 1],
size=self.schedule[timeslot].shape,
p=(1-adherence, adherence)
)
self.schedule[timeslot] = ad
sim_patients = [Patient(x) for x in range(10)]
p = sim_patients[0]
p.targeted_adherence("Day 1; Slot 3")
|
How to simulate data to be statistically significant?
If you already know some Python, then you will definitely be able to achieve what you need using base Python along with numpy and/or pandas. As Mark White suggests though, a lot of simulation and stat
|
13,381
|
How to simulate data to be statistically significant?
|
This is a great project. There is a challenge for projects like this, and your method of using simulated data is a great way of assessing it.
Do you have an a priori hypothesis, e.g. "people are more forgetful in the evening"? In that case, a statistical test that compares the frequency of forgetting in the evening compared to the morning will test it. This is a Bernoulli distribution, as previous responders said.
The other approach is to trawl your data to find out which time slot has the highest rate of failure. There is bound to be one, so the question is "is this just a chance result?". The threshold for significance is higher in this case. If you want to read up about this, search for "false discovery rate".
In your case the system is simple enough that you can calculate the threshold with a bit of thought. But the general method could also be used: similate 1000 datasets with no rate variation, then find out the frequency distribution of coincidental low numbers. Compare your real dataset to it. If 1pm is the sparse slot in the real data, but 50/1000 simulated datasets have an equally sparse slot, then the result is not robust.
|
How to simulate data to be statistically significant?
|
This is a great project. There is a challenge for projects like this, and your method of using simulated data is a great way of assessing it.
Do you have an a priori hypothesis, e.g. "people are more
|
How to simulate data to be statistically significant?
This is a great project. There is a challenge for projects like this, and your method of using simulated data is a great way of assessing it.
Do you have an a priori hypothesis, e.g. "people are more forgetful in the evening"? In that case, a statistical test that compares the frequency of forgetting in the evening compared to the morning will test it. This is a Bernoulli distribution, as previous responders said.
The other approach is to trawl your data to find out which time slot has the highest rate of failure. There is bound to be one, so the question is "is this just a chance result?". The threshold for significance is higher in this case. If you want to read up about this, search for "false discovery rate".
In your case the system is simple enough that you can calculate the threshold with a bit of thought. But the general method could also be used: similate 1000 datasets with no rate variation, then find out the frequency distribution of coincidental low numbers. Compare your real dataset to it. If 1pm is the sparse slot in the real data, but 50/1000 simulated datasets have an equally sparse slot, then the result is not robust.
|
How to simulate data to be statistically significant?
This is a great project. There is a challenge for projects like this, and your method of using simulated data is a great way of assessing it.
Do you have an a priori hypothesis, e.g. "people are more
|
13,382
|
An example where the likelihood principle *really* matters?
|
Think about a hypothetical situation when a point null hypothesis is true but one keeps sampling until $p<0.05$ (this will always happen sooner or later, i.e. it will happen with probability 1) and then decides to stop the trial and reject the null. This is an admittedly extreme stopping rule but consider it for the sake of the argument.
This moronic procedure will have 100% Type I error rate, but there is nothing wrong with it according to the Likelihood Principle.
I'd say this does count as "really" mattering. You can of course choose any $\alpha$ in this argument. Bayesians can use a fixed cut-off on Bayes factor if they please. The same logic applies. The main lesson here is that you cannot adhere to LP and have an error rate guarantee. There is no free lunch.
|
An example where the likelihood principle *really* matters?
|
Think about a hypothetical situation when a point null hypothesis is true but one keeps sampling until $p<0.05$ (this will always happen sooner or later, i.e. it will happen with probability 1) and th
|
An example where the likelihood principle *really* matters?
Think about a hypothetical situation when a point null hypothesis is true but one keeps sampling until $p<0.05$ (this will always happen sooner or later, i.e. it will happen with probability 1) and then decides to stop the trial and reject the null. This is an admittedly extreme stopping rule but consider it for the sake of the argument.
This moronic procedure will have 100% Type I error rate, but there is nothing wrong with it according to the Likelihood Principle.
I'd say this does count as "really" mattering. You can of course choose any $\alpha$ in this argument. Bayesians can use a fixed cut-off on Bayes factor if they please. The same logic applies. The main lesson here is that you cannot adhere to LP and have an error rate guarantee. There is no free lunch.
|
An example where the likelihood principle *really* matters?
Think about a hypothetical situation when a point null hypothesis is true but one keeps sampling until $p<0.05$ (this will always happen sooner or later, i.e. it will happen with probability 1) and th
|
13,383
|
An example where the likelihood principle *really* matters?
|
Disclaimer: I believe this answer is at the core of the entire argument, so it worth discussion, but I haven't fully explored the issue. As such, I welcome corrections, refinements and comments.
The most important aspect is in regards to sequentially collected data. For example, suppose you observed binary outcomes, and you saw 10 success and 5 failures. The likelihood principle says that you should come to the same conclusion about the probability of success, regardless of whether you collected data until you had 10 successes (negative binomial) or ran 15 trials, of which 10 were successes (binomial).
Why is this of any importance?
Because according to the likelihood principle (or at least, a certain interpretation of the it), it's totally fine to let the data influence when you're going to stop collecting data, without having to alter your inference tools.
Conflict with Sequential Methods
The idea that using your data to decide when to stop collecting data without altering your inferential tools flies completely in the face of traditional sequential analysis methods. The classic example of this is with methods used in clinical trials. In order to reduce potential exposure to harmful treatments, data is often analyzed at intermediate times before the analysis is done. If the trial hasn't finished yet, but the researchers already have enough data to conclude that the treatment works or is harmful, medical ethics tells us we should stop the trial; if the treatment works, it is ethical to stop the trial and start making the treatment available to non-trial patients. If it is harmful, it is more ethical to stop so that we stop exposing trial patients to a harmful treatment.
The problem is now we've started to do multiple comparisons, so we've increased our Type I error rate if we do not adjust our methods to account for the multiple comparisons. This isn't quite the same as traditional multiple comparisons problems, as it's really multiple partial comparisons (i.e., if we analyze the data once with 50% of the data collected and once with 100%, these two samples clearly are not independent!), but in general the more comparisons we do, the more we need to change our criteria for rejecting the null hypothesis to preserve the type I error rate, with more comparisons planned requiring more evidence to reject the null.
This puts clinical researchers in a dilemma; do you want to frequently check your data, but then increase your required evidence to reject the null, or do you want to infrequently check your data, increasing your power but potentially not acting in an optimal manner in regards to medical ethics (i.e., may delay product to market or expose patients unnecessarily long to harmful treatment).
It is my (perhaps mistaken) understanding that the likelihood principle appears to tell us that it doesn't matter how many times we check the data, we should make the same inference. This basically says that all the approaches to sequential trial design are completely unnecessary; just use the likelihood principle and stop once you've collected enough data to make a conclusion. Since you don't need to alter your inference methods to adjust for the number of analyses you've prepared, there is no trade off dilemma between number of times checked and power. Bam, whole field of sequential analysis is solved (according to this interpretation).
Personally, what is very confusing about this to me is that a fact that is well know in the sequential design field, but fairly subtle, is that the likelihood of the final test statistic is largely altered by the stopping rule; basically, the stopping rules increase the probability in a discontinuous manner at the stopping points. Here is a plot of such a distortion; the dashed line is the PDF of the final test statistic under the null if data is only analyzed after all data is collected, while the solid line gives you the distribution under the null of the test statistic if you check the data 4 times with a given rule.
With that said, it's my understanding that the likelihood principle seems to imply that we can throw out all we know about Frequentist sequential design and forget about how many times we analyze our data. Clearly, the implications of this, especially for the field of clinical designs, is enormous. However, I haven't wrapped my mind around how they justify ignoring how stopping rules alter the likelihood of the final statistic.
Some light discussion can be found here, mostly on the final slides.
|
An example where the likelihood principle *really* matters?
|
Disclaimer: I believe this answer is at the core of the entire argument, so it worth discussion, but I haven't fully explored the issue. As such, I welcome corrections, refinements and comments.
The m
|
An example where the likelihood principle *really* matters?
Disclaimer: I believe this answer is at the core of the entire argument, so it worth discussion, but I haven't fully explored the issue. As such, I welcome corrections, refinements and comments.
The most important aspect is in regards to sequentially collected data. For example, suppose you observed binary outcomes, and you saw 10 success and 5 failures. The likelihood principle says that you should come to the same conclusion about the probability of success, regardless of whether you collected data until you had 10 successes (negative binomial) or ran 15 trials, of which 10 were successes (binomial).
Why is this of any importance?
Because according to the likelihood principle (or at least, a certain interpretation of the it), it's totally fine to let the data influence when you're going to stop collecting data, without having to alter your inference tools.
Conflict with Sequential Methods
The idea that using your data to decide when to stop collecting data without altering your inferential tools flies completely in the face of traditional sequential analysis methods. The classic example of this is with methods used in clinical trials. In order to reduce potential exposure to harmful treatments, data is often analyzed at intermediate times before the analysis is done. If the trial hasn't finished yet, but the researchers already have enough data to conclude that the treatment works or is harmful, medical ethics tells us we should stop the trial; if the treatment works, it is ethical to stop the trial and start making the treatment available to non-trial patients. If it is harmful, it is more ethical to stop so that we stop exposing trial patients to a harmful treatment.
The problem is now we've started to do multiple comparisons, so we've increased our Type I error rate if we do not adjust our methods to account for the multiple comparisons. This isn't quite the same as traditional multiple comparisons problems, as it's really multiple partial comparisons (i.e., if we analyze the data once with 50% of the data collected and once with 100%, these two samples clearly are not independent!), but in general the more comparisons we do, the more we need to change our criteria for rejecting the null hypothesis to preserve the type I error rate, with more comparisons planned requiring more evidence to reject the null.
This puts clinical researchers in a dilemma; do you want to frequently check your data, but then increase your required evidence to reject the null, or do you want to infrequently check your data, increasing your power but potentially not acting in an optimal manner in regards to medical ethics (i.e., may delay product to market or expose patients unnecessarily long to harmful treatment).
It is my (perhaps mistaken) understanding that the likelihood principle appears to tell us that it doesn't matter how many times we check the data, we should make the same inference. This basically says that all the approaches to sequential trial design are completely unnecessary; just use the likelihood principle and stop once you've collected enough data to make a conclusion. Since you don't need to alter your inference methods to adjust for the number of analyses you've prepared, there is no trade off dilemma between number of times checked and power. Bam, whole field of sequential analysis is solved (according to this interpretation).
Personally, what is very confusing about this to me is that a fact that is well know in the sequential design field, but fairly subtle, is that the likelihood of the final test statistic is largely altered by the stopping rule; basically, the stopping rules increase the probability in a discontinuous manner at the stopping points. Here is a plot of such a distortion; the dashed line is the PDF of the final test statistic under the null if data is only analyzed after all data is collected, while the solid line gives you the distribution under the null of the test statistic if you check the data 4 times with a given rule.
With that said, it's my understanding that the likelihood principle seems to imply that we can throw out all we know about Frequentist sequential design and forget about how many times we analyze our data. Clearly, the implications of this, especially for the field of clinical designs, is enormous. However, I haven't wrapped my mind around how they justify ignoring how stopping rules alter the likelihood of the final statistic.
Some light discussion can be found here, mostly on the final slides.
|
An example where the likelihood principle *really* matters?
Disclaimer: I believe this answer is at the core of the entire argument, so it worth discussion, but I haven't fully explored the issue. As such, I welcome corrections, refinements and comments.
The m
|
13,384
|
An example where the likelihood principle *really* matters?
|
Outline of LR tests for exponential data.
Let $X_1, X_2, \dots, X_n$ be a random sample from
$\mathsf{Exp}(\text{rate} =\lambda),$ so that $E(X_i) = \mu = 1/\lambda.$
For $x > 0,$ the density function is $f(x) = \lambda e^{-\lambda x}$ and
the CDF is $F(x) = 1 - e^{-\lambda x}.$
1. Test statistic is sample minimum.
Let $V = X_{(1)} = \min_n (X_i).$ Then
$V \sim \mathsf{Exp}(n\lambda).$ As an outline of the proof,
$$P(V > v) = P(X_1 > v, \dots, X_n > v) = \left[e^{-\lambda v}\right]^n=
e^{-n\lambda v},$$
so that $P(V \le v) = 1 - e^{-n\lambda v},$ for $v > 0.$
To test $H_9:\mu \le \mu_0$ against $H_a: \mu > \mu_0,$ at level $\alpha = 5\%,$ we regard $V$ as a single observation from its exponential distribution.
We find that
the log likelihood ratio indicates rejection when $V > c,$ where
$P(V > c\, |\, \mu = \mu_0) = 0.05.$
For the specific case in which $n = 100$ and $\mu_0 =10,\, \lambda_0 = 0.1,$
we have exponential rate $10 = n/\mu_0 = 100/10 = 10,$ so that $c = 0.2295$
from R, where the exponential distribution is parameterized by the rate.
qexp(.95, 10)
[1] 0.2995732
1 - pexp(0.2996, 10)
[1] 0.04998662
Accordingly, the power against the alternative $\mu_a = 100$ (rate $n/\mu_a = 1)$ is about 74%.
1 - pexp(0.2996, 1)
[1] 0.7411146
2. Test statistic is the sample mean.
Oxford U. class notes (second page) show that
the likelihood ratio test of $H_0: \mu \le \mu_0$ against $H_0: \mu > \mu_0$
at the 5% level of significance rejects for $\bar X > c,$ where $P(\bar X > c\, |\, \mu = \mu_0) = 0.5.$
Furthermore, one can show using moment generating functions that
$\bar X \sim \mathsf{Gamma}(n, n\lambda).$
For the specific case in which $n = 100$ and $\mu_0 =10,\, \lambda_0 = 0.1,$ we have $\bar X \sim \mathsf{Gamma}(100, 10),$ so that $c = 11.7.$
qgamma(.95, 100, 10)
[1] 11.69971
1 - pgamma(11.7, 100, 10)
[1] 0.04997338
Accordingly, power against the alternative $\mu_a = 14$ is about 95.6%.
1 - pgamma(11.7, 100, 100/14)
[1] 0.9562513
Clearly, for purposes of testing hypotheses about the exponential mean $\mu,$ the information in the sufficient statistic $\bar X$ is much greater than the
information in the sample minimum.
|
An example where the likelihood principle *really* matters?
|
Outline of LR tests for exponential data.
Let $X_1, X_2, \dots, X_n$ be a random sample from
$\mathsf{Exp}(\text{rate} =\lambda),$ so that $E(X_i) = \mu = 1/\lambda.$
For $x > 0,$ the density functio
|
An example where the likelihood principle *really* matters?
Outline of LR tests for exponential data.
Let $X_1, X_2, \dots, X_n$ be a random sample from
$\mathsf{Exp}(\text{rate} =\lambda),$ so that $E(X_i) = \mu = 1/\lambda.$
For $x > 0,$ the density function is $f(x) = \lambda e^{-\lambda x}$ and
the CDF is $F(x) = 1 - e^{-\lambda x}.$
1. Test statistic is sample minimum.
Let $V = X_{(1)} = \min_n (X_i).$ Then
$V \sim \mathsf{Exp}(n\lambda).$ As an outline of the proof,
$$P(V > v) = P(X_1 > v, \dots, X_n > v) = \left[e^{-\lambda v}\right]^n=
e^{-n\lambda v},$$
so that $P(V \le v) = 1 - e^{-n\lambda v},$ for $v > 0.$
To test $H_9:\mu \le \mu_0$ against $H_a: \mu > \mu_0,$ at level $\alpha = 5\%,$ we regard $V$ as a single observation from its exponential distribution.
We find that
the log likelihood ratio indicates rejection when $V > c,$ where
$P(V > c\, |\, \mu = \mu_0) = 0.05.$
For the specific case in which $n = 100$ and $\mu_0 =10,\, \lambda_0 = 0.1,$
we have exponential rate $10 = n/\mu_0 = 100/10 = 10,$ so that $c = 0.2295$
from R, where the exponential distribution is parameterized by the rate.
qexp(.95, 10)
[1] 0.2995732
1 - pexp(0.2996, 10)
[1] 0.04998662
Accordingly, the power against the alternative $\mu_a = 100$ (rate $n/\mu_a = 1)$ is about 74%.
1 - pexp(0.2996, 1)
[1] 0.7411146
2. Test statistic is the sample mean.
Oxford U. class notes (second page) show that
the likelihood ratio test of $H_0: \mu \le \mu_0$ against $H_0: \mu > \mu_0$
at the 5% level of significance rejects for $\bar X > c,$ where $P(\bar X > c\, |\, \mu = \mu_0) = 0.5.$
Furthermore, one can show using moment generating functions that
$\bar X \sim \mathsf{Gamma}(n, n\lambda).$
For the specific case in which $n = 100$ and $\mu_0 =10,\, \lambda_0 = 0.1,$ we have $\bar X \sim \mathsf{Gamma}(100, 10),$ so that $c = 11.7.$
qgamma(.95, 100, 10)
[1] 11.69971
1 - pgamma(11.7, 100, 10)
[1] 0.04997338
Accordingly, power against the alternative $\mu_a = 14$ is about 95.6%.
1 - pgamma(11.7, 100, 100/14)
[1] 0.9562513
Clearly, for purposes of testing hypotheses about the exponential mean $\mu,$ the information in the sufficient statistic $\bar X$ is much greater than the
information in the sample minimum.
|
An example where the likelihood principle *really* matters?
Outline of LR tests for exponential data.
Let $X_1, X_2, \dots, X_n$ be a random sample from
$\mathsf{Exp}(\text{rate} =\lambda),$ so that $E(X_i) = \mu = 1/\lambda.$
For $x > 0,$ the density functio
|
13,385
|
An example where the likelihood principle *really* matters?
|
Violation by different pdf functions $f(x,\theta)$ and $g(x,\theta)$
This case will be an example of 'violation' because the probability distribution functions $f(x,\theta)$ $g(x,\theta)$ are intrinsically different. Even when $f$ and $g$, differ, they may relate to the likelihood principle because at fixed measurement $x$ they give the same functions of $\theta$ up to scaling. The difference, opens up a possibility for "violations".
The coin flip with or without optional stopping rule
The coin flip with or without optional stopping rule is a typical example, the pdf is binomial or negative binomial which are different pdf functions and lead to different calculation of p-values, and confidence intervals, but they lead to the same likelihood functions for fixed sample/measurement (up to scaling).
$$\begin{array}{rcrl}
f_{\text{Negative Binomial}}(n|k,p) &=& {{n-1}\choose{k-1}}&p^k(1-p)^{n-k} \\
f_{\text{Binomial}}(k|n,p) &=& {{n}\choose{k}}&p^k(1-p)^{n-k}
\end{array}$$
More extreme example
Consider some measurement of $X$ which is distributed as
$$\mathcal{L}(\theta | x) = f(x|\theta) = \begin{cases} 0 & \text{ if } \quad x < 0 \\a & \text{ if }\quad 0 \geq x < 1 \\ (1-a) \theta \exp(-\theta (x-1)) & \text{ if }\quad x \geq 1
\end{cases}$$
where $a$ is some known parameter that depends on the type of experiment, and $\theta$ is some parameter that may be unknown and could be inferred from the measurement $x$.
For any given $x$ and $a$ the likelihood function is proportional to the same function that is independent from $a$:
If $x<1$ then $\mathcal{L}(\theta | x) \propto 1$
If $x\geq 1$ then $\mathcal{L}(\theta | x) \propto \theta \exp(-\theta (x-1))$
But, albeit the same likelihood function, the p-value can vary widely depending on the experiment (ie the value of $a $). For instance when you measure $x=2$ and test $H_0:\theta = 1$ against $H_0:\theta < 1$ then the p-value is
$$P(X>2|\theta = 1) = \frac{(1-a)}{\exp(1)} $$
Intuition: The reason for violation in these cases is that p-values and hypothesis tests are not solely based on the likelihood function for the particular observed value $x$.
The p-value is not calculated from the likelihood $f(θ|x)$ with $x$ fixed, but with the pdf $f(x|θ)$ with $θ$ fixed which is a different slice. Confidence intervals, p-value, and hypothesis tests, are different things than the information from likelihood ratios.
p-values are not really evidence: The p-value relates to type I error which is a measure that relates to an ensemble of measurements rather than to a single measurement. This type I error or p-value is not the same as 'evidential meaning' from Birnbaums 'foundations of statistical evidence'. This relates a lot to the problems with p-values and scientist searching for outcomes solely with statistical significance rather than important effects.
Do we need examples where inferences are markedly different? The extreme case is a contrived example. Such a case, or anything with a similar extreme difference, is of course not occurring easily in practice. It is more often the case that the difference will be small such as in the cases that you refer to as silly.
To ask for examples where the likelihood principle 'really matters', or where two different inferences lead to extremely different results, is a bit of a loaded question. At least when the intention for this question relates to some philosophical argument. It is a loaded question because it presupposes that principles that matter should lead to extremely varying results. In many practical cases the results are however small (in terms of different p-values less than an order). I believe that this is not a strange for two different, but both plausible, methods to result in more or less similar results. I would consider the likelihood principle not to be 'less violated' when the differences are only small.
|
An example where the likelihood principle *really* matters?
|
Violation by different pdf functions $f(x,\theta)$ and $g(x,\theta)$
This case will be an example of 'violation' because the probability distribution functions $f(x,\theta)$ $g(x,\theta)$ are intrinsi
|
An example where the likelihood principle *really* matters?
Violation by different pdf functions $f(x,\theta)$ and $g(x,\theta)$
This case will be an example of 'violation' because the probability distribution functions $f(x,\theta)$ $g(x,\theta)$ are intrinsically different. Even when $f$ and $g$, differ, they may relate to the likelihood principle because at fixed measurement $x$ they give the same functions of $\theta$ up to scaling. The difference, opens up a possibility for "violations".
The coin flip with or without optional stopping rule
The coin flip with or without optional stopping rule is a typical example, the pdf is binomial or negative binomial which are different pdf functions and lead to different calculation of p-values, and confidence intervals, but they lead to the same likelihood functions for fixed sample/measurement (up to scaling).
$$\begin{array}{rcrl}
f_{\text{Negative Binomial}}(n|k,p) &=& {{n-1}\choose{k-1}}&p^k(1-p)^{n-k} \\
f_{\text{Binomial}}(k|n,p) &=& {{n}\choose{k}}&p^k(1-p)^{n-k}
\end{array}$$
More extreme example
Consider some measurement of $X$ which is distributed as
$$\mathcal{L}(\theta | x) = f(x|\theta) = \begin{cases} 0 & \text{ if } \quad x < 0 \\a & \text{ if }\quad 0 \geq x < 1 \\ (1-a) \theta \exp(-\theta (x-1)) & \text{ if }\quad x \geq 1
\end{cases}$$
where $a$ is some known parameter that depends on the type of experiment, and $\theta$ is some parameter that may be unknown and could be inferred from the measurement $x$.
For any given $x$ and $a$ the likelihood function is proportional to the same function that is independent from $a$:
If $x<1$ then $\mathcal{L}(\theta | x) \propto 1$
If $x\geq 1$ then $\mathcal{L}(\theta | x) \propto \theta \exp(-\theta (x-1))$
But, albeit the same likelihood function, the p-value can vary widely depending on the experiment (ie the value of $a $). For instance when you measure $x=2$ and test $H_0:\theta = 1$ against $H_0:\theta < 1$ then the p-value is
$$P(X>2|\theta = 1) = \frac{(1-a)}{\exp(1)} $$
Intuition: The reason for violation in these cases is that p-values and hypothesis tests are not solely based on the likelihood function for the particular observed value $x$.
The p-value is not calculated from the likelihood $f(θ|x)$ with $x$ fixed, but with the pdf $f(x|θ)$ with $θ$ fixed which is a different slice. Confidence intervals, p-value, and hypothesis tests, are different things than the information from likelihood ratios.
p-values are not really evidence: The p-value relates to type I error which is a measure that relates to an ensemble of measurements rather than to a single measurement. This type I error or p-value is not the same as 'evidential meaning' from Birnbaums 'foundations of statistical evidence'. This relates a lot to the problems with p-values and scientist searching for outcomes solely with statistical significance rather than important effects.
Do we need examples where inferences are markedly different? The extreme case is a contrived example. Such a case, or anything with a similar extreme difference, is of course not occurring easily in practice. It is more often the case that the difference will be small such as in the cases that you refer to as silly.
To ask for examples where the likelihood principle 'really matters', or where two different inferences lead to extremely different results, is a bit of a loaded question. At least when the intention for this question relates to some philosophical argument. It is a loaded question because it presupposes that principles that matter should lead to extremely varying results. In many practical cases the results are however small (in terms of different p-values less than an order). I believe that this is not a strange for two different, but both plausible, methods to result in more or less similar results. I would consider the likelihood principle not to be 'less violated' when the differences are only small.
|
An example where the likelihood principle *really* matters?
Violation by different pdf functions $f(x,\theta)$ and $g(x,\theta)$
This case will be an example of 'violation' because the probability distribution functions $f(x,\theta)$ $g(x,\theta)$ are intrinsi
|
13,386
|
An example where the likelihood principle *really* matters?
|
Here is an example adapted from Statistical decision theory and Bayesian analysis by James O. Berger (Second edition page 29).
Say that two species of wasps can be distinguished by the number of notches on the wings (call this $x$) and by the number of black rings around the abdomen (call this $y$). The distribution of the characters in the two species (labelled $H_0$ and $H_1$) are as follows:
Say that we find a specimen with 1 notch on the wings and 1 ring around the abdomen. The weight of evidence if 100 times bigger in favor of $H_1$ against $H_0$ for both characters.
Now if someone wanted to set up a test for $H_0$ at 5% level, the decision rule would be for the first character “accept $H_0$ if there is 1 notch on the wing, otherwise reject it”, and for the second character “accept $H_0$ if there are 3 rings around the abdomen, otherwise reject it”. There are many other possibilities, but these ones are most powerful tests at this level. Yet, they lead to different conclusions for both characters.
Note: one could of course set up a test with the rule “accept $H_0$ if there are 1 or 3 rings around the abdomen, otherwise reject it”. The question is whether we prefer a test at 5% level with type II risk 0, or a test at 4.9% level with type II risk 0.00001. The difference is so small that we would probably not care, but as I understand it, this is the core of the argument for the likelihood principle: it is not a good idea to make the result depend on something that seems irrelevant.
The likelihood functions are proportional, and yet the p-value of $x = 1$ is 0.95, and that of $y = 1$ is 0.001 (assuming that we reject $H_0$ with events of the form $y \leq \alpha$). It is obvious from the structure of the table that I could have chosen any number smaller than 0.001. Also, the type II risk of the rejection is 0, so it looks like there is nothing “wrong” here.
Still, I admit that this example is somewhat contrived and not completely honest because it plays with the difficulty of arranging tests with discrete data. One could find equivalent examples with continuous data but they would be even more contrived. I agree with the OP that the likelihood principle has almost no practical value; I interpret it as a principle to guarantee some consistency within the theory.
|
An example where the likelihood principle *really* matters?
|
Here is an example adapted from Statistical decision theory and Bayesian analysis by James O. Berger (Second edition page 29).
Say that two species of wasps can be distinguished by the number of notch
|
An example where the likelihood principle *really* matters?
Here is an example adapted from Statistical decision theory and Bayesian analysis by James O. Berger (Second edition page 29).
Say that two species of wasps can be distinguished by the number of notches on the wings (call this $x$) and by the number of black rings around the abdomen (call this $y$). The distribution of the characters in the two species (labelled $H_0$ and $H_1$) are as follows:
Say that we find a specimen with 1 notch on the wings and 1 ring around the abdomen. The weight of evidence if 100 times bigger in favor of $H_1$ against $H_0$ for both characters.
Now if someone wanted to set up a test for $H_0$ at 5% level, the decision rule would be for the first character “accept $H_0$ if there is 1 notch on the wing, otherwise reject it”, and for the second character “accept $H_0$ if there are 3 rings around the abdomen, otherwise reject it”. There are many other possibilities, but these ones are most powerful tests at this level. Yet, they lead to different conclusions for both characters.
Note: one could of course set up a test with the rule “accept $H_0$ if there are 1 or 3 rings around the abdomen, otherwise reject it”. The question is whether we prefer a test at 5% level with type II risk 0, or a test at 4.9% level with type II risk 0.00001. The difference is so small that we would probably not care, but as I understand it, this is the core of the argument for the likelihood principle: it is not a good idea to make the result depend on something that seems irrelevant.
The likelihood functions are proportional, and yet the p-value of $x = 1$ is 0.95, and that of $y = 1$ is 0.001 (assuming that we reject $H_0$ with events of the form $y \leq \alpha$). It is obvious from the structure of the table that I could have chosen any number smaller than 0.001. Also, the type II risk of the rejection is 0, so it looks like there is nothing “wrong” here.
Still, I admit that this example is somewhat contrived and not completely honest because it plays with the difficulty of arranging tests with discrete data. One could find equivalent examples with continuous data but they would be even more contrived. I agree with the OP that the likelihood principle has almost no practical value; I interpret it as a principle to guarantee some consistency within the theory.
|
An example where the likelihood principle *really* matters?
Here is an example adapted from Statistical decision theory and Bayesian analysis by James O. Berger (Second edition page 29).
Say that two species of wasps can be distinguished by the number of notch
|
13,387
|
How to calculate out of sample R squared?
|
First of all is need to say that for prediction evaluation, then out of sample, the usual $R^2$ is not adequate. It is so because the usual $R^2$ is computed on residuals, that are in sample quantities.
We can define: $R^2 = 1 – RSS/TSS$
RSS = residual sum of square
TSS = total sum of square
The main problem here is that residuals are not a good proxy for forecast errors because in residuals the same data would be used for both, model estimation and model prediction accuracy. If residuals (RSS) are used the prediction accuracy would be overstated; probably overfitting occur. Even TSS is not adequate as we see later. However we have to say that in the past the mistaken use of standard $R^2$ for forecast evaluation was quite common.
The out of sample $R^2$ ($R_{oos}^2$) maintain the idea of usual $R^2$ but in place of RSS is used the out of sample MSE of the model under analysis (MSE_m). In place of TSS is used the the out of sample MSE of one benchmark model (MSE_bmk).
$R_{oos}^2 = 1 – MSE_m/MSE_{bmk}$
One notable difference between $R^2$ and $R_{oos}^2$ is that
$0 \leq R^2 \leq 1$ (if the constant term is included)
while $-\infty \leq R_{oos}^2 \leq 1$
If $R_{oos}^2 < = > 0$ the competing model perform worse/equal/better than the benchmark one. If $R_{oos}^2 =1$ the competing model predict perfectly the (new) data.
Here we have to keep in mind that the even for the benchmark model we have to consider the out of sample performance. Therefore the variance of the out of sample data underestimate $MSE_{bmk}$.
In this sense something like
$$ MSE_{bmk} = (1/n)\Sigma (y - \bar{y}_{test})^2 $$
seems to me a wrong choice.
While something like
$$ MSE_{bmk} = (1/n)\Sigma (y - \bar{y}_{train})^2 $$
seems to me plausible.
In my knowledge this measure was proposed for the first time in:
Predicting excess stock returns out of sample: Can anything beat the historical average? - Campbell and Thompson (2008) - Review of Financial Studies.
In it the the bmk forecast is based on the prevailing mean given information at time of the forecast.
|
How to calculate out of sample R squared?
|
First of all is need to say that for prediction evaluation, then out of sample, the usual $R^2$ is not adequate. It is so because the usual $R^2$ is computed on residuals, that are in sample quantiti
|
How to calculate out of sample R squared?
First of all is need to say that for prediction evaluation, then out of sample, the usual $R^2$ is not adequate. It is so because the usual $R^2$ is computed on residuals, that are in sample quantities.
We can define: $R^2 = 1 – RSS/TSS$
RSS = residual sum of square
TSS = total sum of square
The main problem here is that residuals are not a good proxy for forecast errors because in residuals the same data would be used for both, model estimation and model prediction accuracy. If residuals (RSS) are used the prediction accuracy would be overstated; probably overfitting occur. Even TSS is not adequate as we see later. However we have to say that in the past the mistaken use of standard $R^2$ for forecast evaluation was quite common.
The out of sample $R^2$ ($R_{oos}^2$) maintain the idea of usual $R^2$ but in place of RSS is used the out of sample MSE of the model under analysis (MSE_m). In place of TSS is used the the out of sample MSE of one benchmark model (MSE_bmk).
$R_{oos}^2 = 1 – MSE_m/MSE_{bmk}$
One notable difference between $R^2$ and $R_{oos}^2$ is that
$0 \leq R^2 \leq 1$ (if the constant term is included)
while $-\infty \leq R_{oos}^2 \leq 1$
If $R_{oos}^2 < = > 0$ the competing model perform worse/equal/better than the benchmark one. If $R_{oos}^2 =1$ the competing model predict perfectly the (new) data.
Here we have to keep in mind that the even for the benchmark model we have to consider the out of sample performance. Therefore the variance of the out of sample data underestimate $MSE_{bmk}$.
In this sense something like
$$ MSE_{bmk} = (1/n)\Sigma (y - \bar{y}_{test})^2 $$
seems to me a wrong choice.
While something like
$$ MSE_{bmk} = (1/n)\Sigma (y - \bar{y}_{train})^2 $$
seems to me plausible.
In my knowledge this measure was proposed for the first time in:
Predicting excess stock returns out of sample: Can anything beat the historical average? - Campbell and Thompson (2008) - Review of Financial Studies.
In it the the bmk forecast is based on the prevailing mean given information at time of the forecast.
|
How to calculate out of sample R squared?
First of all is need to say that for prediction evaluation, then out of sample, the usual $R^2$ is not adequate. It is so because the usual $R^2$ is computed on residuals, that are in sample quantiti
|
13,388
|
How to calculate out of sample R squared?
|
You are correct.
The OSR$^2$ residuals are based on testing data, but the baseline should still be training data. With that said, your SST is $SST=Σ(y−\bar y_{train})^2$; notice that the is the same for $R^2$
|
How to calculate out of sample R squared?
|
You are correct.
The OSR$^2$ residuals are based on testing data, but the baseline should still be training data. With that said, your SST is $SST=Σ(y−\bar y_{train})^2$; notice that the is the same
|
How to calculate out of sample R squared?
You are correct.
The OSR$^2$ residuals are based on testing data, but the baseline should still be training data. With that said, your SST is $SST=Σ(y−\bar y_{train})^2$; notice that the is the same for $R^2$
|
How to calculate out of sample R squared?
You are correct.
The OSR$^2$ residuals are based on testing data, but the baseline should still be training data. With that said, your SST is $SST=Σ(y−\bar y_{train})^2$; notice that the is the same
|
13,389
|
How to calculate out of sample R squared?
|
We have just published an article on this subject in The American Statistician here
Similar to @markowitz, we define out-of-sample $R^2$ as a comparison of two out-of-sample models: the null model using only the mean outcome of the training data $\bar{y}_{train}$, and the more elaborate model using covariate information.
For the squared error loss of the null model (which we call the MST), we derive an analytical expression showing that
$$
MST = \operatorname{Var}(\bar{Y}_{train}) + \operatorname{Var}(Y) = \frac{n+1}{n}\operatorname{Var}(Y),
$$
meaning that the prediction error is a sum of estimation error on $\bar{y}_{train}$ and irreducible error. This is a useful expression in absence of a test set. But if you have an independent test set, I would indeed prefer the expression $n^{-1}\sum_{i \in \text{test}}(y_i-\bar{y}_{train})$ as suggested above. In principle, both estimators have the same estimand, but the latter is more robust to differences between training and test sets. Finally, we show through simulation that the expression $n^{-1}\sum_{i \in \text{test}}(y_i-\bar{y}_{test})$ can be badly biased for estimation the true $R^2$.
The squared error loss of the elaborate model (the MSE) is then to be estimated through cross-validation or on your test set. Corresponding out-of-sample $R^2$ is then simply
$$\hat{R}^2 = 1-\frac{\widehat{MSE}}{\widehat{MST}}$$
We provide a standard error for this estimate, unlocking hypothesis testing and confidence intervals.
|
How to calculate out of sample R squared?
|
We have just published an article on this subject in The American Statistician here
Similar to @markowitz, we define out-of-sample $R^2$ as a comparison of two out-of-sample models: the null model usi
|
How to calculate out of sample R squared?
We have just published an article on this subject in The American Statistician here
Similar to @markowitz, we define out-of-sample $R^2$ as a comparison of two out-of-sample models: the null model using only the mean outcome of the training data $\bar{y}_{train}$, and the more elaborate model using covariate information.
For the squared error loss of the null model (which we call the MST), we derive an analytical expression showing that
$$
MST = \operatorname{Var}(\bar{Y}_{train}) + \operatorname{Var}(Y) = \frac{n+1}{n}\operatorname{Var}(Y),
$$
meaning that the prediction error is a sum of estimation error on $\bar{y}_{train}$ and irreducible error. This is a useful expression in absence of a test set. But if you have an independent test set, I would indeed prefer the expression $n^{-1}\sum_{i \in \text{test}}(y_i-\bar{y}_{train})$ as suggested above. In principle, both estimators have the same estimand, but the latter is more robust to differences between training and test sets. Finally, we show through simulation that the expression $n^{-1}\sum_{i \in \text{test}}(y_i-\bar{y}_{test})$ can be badly biased for estimation the true $R^2$.
The squared error loss of the elaborate model (the MSE) is then to be estimated through cross-validation or on your test set. Corresponding out-of-sample $R^2$ is then simply
$$\hat{R}^2 = 1-\frac{\widehat{MSE}}{\widehat{MST}}$$
We provide a standard error for this estimate, unlocking hypothesis testing and confidence intervals.
|
How to calculate out of sample R squared?
We have just published an article on this subject in The American Statistician here
Similar to @markowitz, we define out-of-sample $R^2$ as a comparison of two out-of-sample models: the null model usi
|
13,390
|
Why do we say "Residual standard error"?
|
As in mentioned by a comment by NRH to one of the other answers, the documentation for stats::sigma says:
The misnomer “Residual standard error” has been part of too many R (and S) outputs to be easily changed there.
This tells me that the developers know this terminology to be bogus. However, since it has crept into the software, changing to correct terminology is difficult and not worth the trouble of doing so when experienced statisticians know what is meant.
|
Why do we say "Residual standard error"?
|
As in mentioned by a comment by NRH to one of the other answers, the documentation for stats::sigma says:
The misnomer “Residual standard error” has been part of too many R (and S) outputs to be easi
|
Why do we say "Residual standard error"?
As in mentioned by a comment by NRH to one of the other answers, the documentation for stats::sigma says:
The misnomer “Residual standard error” has been part of too many R (and S) outputs to be easily changed there.
This tells me that the developers know this terminology to be bogus. However, since it has crept into the software, changing to correct terminology is difficult and not worth the trouble of doing so when experienced statisticians know what is meant.
|
Why do we say "Residual standard error"?
As in mentioned by a comment by NRH to one of the other answers, the documentation for stats::sigma says:
The misnomer “Residual standard error” has been part of too many R (and S) outputs to be easi
|
13,391
|
Why do we say "Residual standard error"?
|
I think that phrasing is specific to R's summary.lm() output. Notice that the underlying value is actually called "sigma" (summary.lm()$sigma). I don't think other software necessarily uses that name for the standard deviation of the residuals. In addition, the phrasing 'residual standard deviation' is common in textbooks, for instance. I don't know how that came to be the phrasing used in R's summary.lm() output, but I always thought it was weird.
|
Why do we say "Residual standard error"?
|
I think that phrasing is specific to R's summary.lm() output. Notice that the underlying value is actually called "sigma" (summary.lm()$sigma). I don't think other software necessarily uses that nam
|
Why do we say "Residual standard error"?
I think that phrasing is specific to R's summary.lm() output. Notice that the underlying value is actually called "sigma" (summary.lm()$sigma). I don't think other software necessarily uses that name for the standard deviation of the residuals. In addition, the phrasing 'residual standard deviation' is common in textbooks, for instance. I don't know how that came to be the phrasing used in R's summary.lm() output, but I always thought it was weird.
|
Why do we say "Residual standard error"?
I think that phrasing is specific to R's summary.lm() output. Notice that the underlying value is actually called "sigma" (summary.lm()$sigma). I don't think other software necessarily uses that nam
|
13,392
|
Why do we say "Residual standard error"?
|
From my econometrics training, it is called "residual standard error" because it is an estimate of the actual "residual standard deviation". See this related question that corroborates this terminology.
A Google search for the term residual standard error also shows up a lot of hits, so it is by no means an R oddity. I tried both terms with quotes, and both show up roughly 60,000 times.
|
Why do we say "Residual standard error"?
|
From my econometrics training, it is called "residual standard error" because it is an estimate of the actual "residual standard deviation". See this related question that corroborates this terminolog
|
Why do we say "Residual standard error"?
From my econometrics training, it is called "residual standard error" because it is an estimate of the actual "residual standard deviation". See this related question that corroborates this terminology.
A Google search for the term residual standard error also shows up a lot of hits, so it is by no means an R oddity. I tried both terms with quotes, and both show up roughly 60,000 times.
|
Why do we say "Residual standard error"?
From my econometrics training, it is called "residual standard error" because it is an estimate of the actual "residual standard deviation". See this related question that corroborates this terminolog
|
13,393
|
Why do we say "Residual standard error"?
|
This is really, really confusing use of the term "standard error". I teach Introductory Statistics at a college, and this is one of the most confusing details in R for students (along with R using standard deviation and not variance in its various pnorm, qnorm, etc. commands).
A standard error, from a statistical sense, is defined as "a standard deviation of an estimator/statistic". It is a resampling concept: the standard error of the slope estimate, for example. If you were to resample your data, the estimate of the slope will vary, and this type of standard deviation we call a standard error.
But the standard deviation of the residuals is not a resampling concept – it is directly observable in the data. So what R reports as "residual standard error" really is an "estimated standard deviation of the residuals". It is like the difference between $s$ (an estimated standard deviation) and $\sigma$ (a true/theoretical standard deviation), not the difference between $\sigma$ (a true/theoretical standard deviation) and $\sigma/\sqrt{n}$ (a true/theoretical standard error).
|
Why do we say "Residual standard error"?
|
This is really, really confusing use of the term "standard error". I teach Introductory Statistics at a college, and this is one of the most confusing details in R for students (along with R using st
|
Why do we say "Residual standard error"?
This is really, really confusing use of the term "standard error". I teach Introductory Statistics at a college, and this is one of the most confusing details in R for students (along with R using standard deviation and not variance in its various pnorm, qnorm, etc. commands).
A standard error, from a statistical sense, is defined as "a standard deviation of an estimator/statistic". It is a resampling concept: the standard error of the slope estimate, for example. If you were to resample your data, the estimate of the slope will vary, and this type of standard deviation we call a standard error.
But the standard deviation of the residuals is not a resampling concept – it is directly observable in the data. So what R reports as "residual standard error" really is an "estimated standard deviation of the residuals". It is like the difference between $s$ (an estimated standard deviation) and $\sigma$ (a true/theoretical standard deviation), not the difference between $\sigma$ (a true/theoretical standard deviation) and $\sigma/\sqrt{n}$ (a true/theoretical standard error).
|
Why do we say "Residual standard error"?
This is really, really confusing use of the term "standard error". I teach Introductory Statistics at a college, and this is one of the most confusing details in R for students (along with R using st
|
13,394
|
Why do we say "Residual standard error"?
|
Put simply, the standard error of the sample is an estimate of how far the sample mean is likely to be from the population mean, whereas the standard deviation of the sample is the degree to which individuals within the sample differ from the sample mean.
Standard error - Wikipedia, the free encyclopedia
|
Why do we say "Residual standard error"?
|
Put simply, the standard error of the sample is an estimate of how far the sample mean is likely to be from the population mean, whereas the standard deviation of the sample is the degree to which ind
|
Why do we say "Residual standard error"?
Put simply, the standard error of the sample is an estimate of how far the sample mean is likely to be from the population mean, whereas the standard deviation of the sample is the degree to which individuals within the sample differ from the sample mean.
Standard error - Wikipedia, the free encyclopedia
|
Why do we say "Residual standard error"?
Put simply, the standard error of the sample is an estimate of how far the sample mean is likely to be from the population mean, whereas the standard deviation of the sample is the degree to which ind
|
13,395
|
Why do we say "Residual standard error"?
|
A fitted regression model uses the parameters to generate point estimate predictions which are the means of observed responses if you were to replicate the study with the same XX values an infinite number of times (when the linear model is true).
The difference between these predicted values and the ones used to fit the model are called "Residuals" which, when replicating the data collection process, have properties of random variables with 0 means. The observed residuals are then used to subsequently estimate the variability in these values and to estimate the sampling distribution of the parameters.
Note:
When the residual standard error is exactly 0 then the model fits the data perfectly (likely due to overfitting).
If the residual standard error can not be shown to be significantly different from the variability in the unconditional response, then there is little evidence to suggest the linear model has any predictive ability.
|
Why do we say "Residual standard error"?
|
A fitted regression model uses the parameters to generate point estimate predictions which are the means of observed responses if you were to replicate the study with the same XX values an infinite nu
|
Why do we say "Residual standard error"?
A fitted regression model uses the parameters to generate point estimate predictions which are the means of observed responses if you were to replicate the study with the same XX values an infinite number of times (when the linear model is true).
The difference between these predicted values and the ones used to fit the model are called "Residuals" which, when replicating the data collection process, have properties of random variables with 0 means. The observed residuals are then used to subsequently estimate the variability in these values and to estimate the sampling distribution of the parameters.
Note:
When the residual standard error is exactly 0 then the model fits the data perfectly (likely due to overfitting).
If the residual standard error can not be shown to be significantly different from the variability in the unconditional response, then there is little evidence to suggest the linear model has any predictive ability.
|
Why do we say "Residual standard error"?
A fitted regression model uses the parameters to generate point estimate predictions which are the means of observed responses if you were to replicate the study with the same XX values an infinite nu
|
13,396
|
Why do we say "Residual standard error"?
|
For the nls (nonlinear least squares fit) R function, the "Residual standard error" seems to be:
$$\sqrt{\frac{\mathrm{RSS}}{n-p}}$$
where RSS is the "residual sum-of-squares", n is the number of observations and p is the number of estimated parameters. There's absolutely no description in the documentation, this assumption is based on a "numerical experiment".
|
Why do we say "Residual standard error"?
|
For the nls (nonlinear least squares fit) R function, the "Residual standard error" seems to be:
$$\sqrt{\frac{\mathrm{RSS}}{n-p}}$$
where RSS is the "residual sum-of-squares", n is the number of obse
|
Why do we say "Residual standard error"?
For the nls (nonlinear least squares fit) R function, the "Residual standard error" seems to be:
$$\sqrt{\frac{\mathrm{RSS}}{n-p}}$$
where RSS is the "residual sum-of-squares", n is the number of observations and p is the number of estimated parameters. There's absolutely no description in the documentation, this assumption is based on a "numerical experiment".
|
Why do we say "Residual standard error"?
For the nls (nonlinear least squares fit) R function, the "Residual standard error" seems to be:
$$\sqrt{\frac{\mathrm{RSS}}{n-p}}$$
where RSS is the "residual sum-of-squares", n is the number of obse
|
13,397
|
Generalized additive models -- who does research on them besides Simon Wood?
|
There are many researchers on GAMs: it's just that basically the same model (GLM with linear predictor given by sum of smooth functions) is given lots of different names. You'll find models that you could refer to as GAMs called: semiparametric regression models, smoothing spline ANOVA models, structured additive regression models, generalized linear additive structure models, generalized additive models for location scale and shape, Gaussian latent variable models, etc.
A small selection of researchers on GAM-related topics with a computational angle is:
Ray Carroll, Maria Durban, Paul Eilers, Trevor Hastie, Chong Gu, Sonja Greven, Thomas Kneib, Stephan Lang, Brian Marx, Bob Rigby, David Ruppert, Harvard Rue, Fabian Scheipl, Mikis Stasinopoulus, Matt Wand, Grace Wahba, Thomas Yee.
(and there are a whole lot more people working on boosted GAMs, GAM-related theory and closely related functional data analysis methods). My papers are mostly about developing GAM methods that are efficient and general to compute with, but that's certainly not all there is to say on the subject.
|
Generalized additive models -- who does research on them besides Simon Wood?
|
There are many researchers on GAMs: it's just that basically the same model (GLM with linear predictor given by sum of smooth functions) is given lots of different names. You'll find models that you c
|
Generalized additive models -- who does research on them besides Simon Wood?
There are many researchers on GAMs: it's just that basically the same model (GLM with linear predictor given by sum of smooth functions) is given lots of different names. You'll find models that you could refer to as GAMs called: semiparametric regression models, smoothing spline ANOVA models, structured additive regression models, generalized linear additive structure models, generalized additive models for location scale and shape, Gaussian latent variable models, etc.
A small selection of researchers on GAM-related topics with a computational angle is:
Ray Carroll, Maria Durban, Paul Eilers, Trevor Hastie, Chong Gu, Sonja Greven, Thomas Kneib, Stephan Lang, Brian Marx, Bob Rigby, David Ruppert, Harvard Rue, Fabian Scheipl, Mikis Stasinopoulus, Matt Wand, Grace Wahba, Thomas Yee.
(and there are a whole lot more people working on boosted GAMs, GAM-related theory and closely related functional data analysis methods). My papers are mostly about developing GAM methods that are efficient and general to compute with, but that's certainly not all there is to say on the subject.
|
Generalized additive models -- who does research on them besides Simon Wood?
There are many researchers on GAMs: it's just that basically the same model (GLM with linear predictor given by sum of smooth functions) is given lots of different names. You'll find models that you c
|
13,398
|
Generalized additive models -- who does research on them besides Simon Wood?
|
google scholar gives a lot of hits, in addition to the references above, and in comments, some which looks interesting is:
http://www.sciencedirect.com/science/article/pii/S0304380002002041 GAM's in studies of species distributions, published in "Ecological Modelling"
http://aje.oxfordjournals.org/content/156/3/193.short Use of GAM's in studies of air pollution and health
but the OP seems to care more for statistical theory, so:
http://www.sciencedirect.com/science/article/pii/S0167947398000334 this is about better fitting algorithms
http://onlinelibrary.wiley.com/doi/10.1111/1467-9876.00229/abstract Bayesian inference based on MArkov Random Field priors
http://onlinelibrary.wiley.com/doi/10.1111/1467-9469.00333/abstract?deniedAccessCustomisedMessage=&userIsAuthenticated=false about estimation methods in GAM's ...
all this with many different authors, so the answer to original question seems to be many.
|
Generalized additive models -- who does research on them besides Simon Wood?
|
google scholar gives a lot of hits, in addition to the references above, and in comments, some which looks interesting is:
http://www.sciencedirect.com/science/article/pii/S0304380002002041 GAM's
|
Generalized additive models -- who does research on them besides Simon Wood?
google scholar gives a lot of hits, in addition to the references above, and in comments, some which looks interesting is:
http://www.sciencedirect.com/science/article/pii/S0304380002002041 GAM's in studies of species distributions, published in "Ecological Modelling"
http://aje.oxfordjournals.org/content/156/3/193.short Use of GAM's in studies of air pollution and health
but the OP seems to care more for statistical theory, so:
http://www.sciencedirect.com/science/article/pii/S0167947398000334 this is about better fitting algorithms
http://onlinelibrary.wiley.com/doi/10.1111/1467-9876.00229/abstract Bayesian inference based on MArkov Random Field priors
http://onlinelibrary.wiley.com/doi/10.1111/1467-9469.00333/abstract?deniedAccessCustomisedMessage=&userIsAuthenticated=false about estimation methods in GAM's ...
all this with many different authors, so the answer to original question seems to be many.
|
Generalized additive models -- who does research on them besides Simon Wood?
google scholar gives a lot of hits, in addition to the references above, and in comments, some which looks interesting is:
http://www.sciencedirect.com/science/article/pii/S0304380002002041 GAM's
|
13,399
|
When can we speak of collinearity
|
There is no 'bright line' between not too much collinearity and too much collinearity (except in the trivial sense that $r = 1.0$ is definitely too much). Analysts would not typically think of $r = .50$ as too much collinearity between two variables. A rule of thumb regarding multicollinearity is that you have too much when the VIF is greater than 10 (this is probably because we have 10 fingers, so take such rules of thumb for what they're worth). The implication would be that you have too much collinearity between two variables if $r \ge .95$. You can read more about the VIF and multicollinearity in my answer here: What is the effect of having correlated predictors in a multiple regression model?
This depends on what you mean by "fully determine". If the correlation between two variables were $r \ge .95$, then most data analysts would say you had problematic collinearity. However, you can have multiple variables where no two variables have a pairwise correlation that high, and still have problematic collinearity hidden amongst the whole set of variables. This is where other metrics, such as the VIFs and condition numbers come in handy. You can read more on this topic at my question here: Is there a reason to prefer a specific measure of multicollinearity?
It is always smart to look at your data, and not simply numerical summaries / test results. The canonical reference here is Anscomb's quartet.
|
When can we speak of collinearity
|
There is no 'bright line' between not too much collinearity and too much collinearity (except in the trivial sense that $r = 1.0$ is definitely too much). Analysts would not typically think of $r = .
|
When can we speak of collinearity
There is no 'bright line' between not too much collinearity and too much collinearity (except in the trivial sense that $r = 1.0$ is definitely too much). Analysts would not typically think of $r = .50$ as too much collinearity between two variables. A rule of thumb regarding multicollinearity is that you have too much when the VIF is greater than 10 (this is probably because we have 10 fingers, so take such rules of thumb for what they're worth). The implication would be that you have too much collinearity between two variables if $r \ge .95$. You can read more about the VIF and multicollinearity in my answer here: What is the effect of having correlated predictors in a multiple regression model?
This depends on what you mean by "fully determine". If the correlation between two variables were $r \ge .95$, then most data analysts would say you had problematic collinearity. However, you can have multiple variables where no two variables have a pairwise correlation that high, and still have problematic collinearity hidden amongst the whole set of variables. This is where other metrics, such as the VIFs and condition numbers come in handy. You can read more on this topic at my question here: Is there a reason to prefer a specific measure of multicollinearity?
It is always smart to look at your data, and not simply numerical summaries / test results. The canonical reference here is Anscomb's quartet.
|
When can we speak of collinearity
There is no 'bright line' between not too much collinearity and too much collinearity (except in the trivial sense that $r = 1.0$ is definitely too much). Analysts would not typically think of $r = .
|
13,400
|
When can we speak of collinearity
|
My take on the three questions is
Question 1 What classifies as too much correlation? For example: a pearson correlation of 0.5 is that too much?
Many authors argue that (multi-)collinearity is not a problem. Take a look here and here for a rather acid opinion on the subject. The bottom line is that multicollinearity does not have an impact on the hypothesis testing other than having a lower (effective) sample size. It will be hard for you to interpret the regression coefficients if you do a regression, for instance, but you do not violate any basic assumption if you choose to do so.
Question 2 Can we fully determine whether there is collinearity between two variables based on the correlation coefficient or does it depend on other factors?
I think there are several ways of measuring the correlation between two variables, from calculating Pearson's correlation coefficient (if you assume linearity, and apparently you did so), to Spearman's rank, distance correlation, and even doing PCA on your dataset. But I would leave the answer of this question to better informed people than me.
Question 3 Does a graphical check of the scatter plot of the two variables add anything to what the correlation coefficient indicates?
IMO, the answer is sound no.
|
When can we speak of collinearity
|
My take on the three questions is
Question 1 What classifies as too much correlation? For example: a pearson correlation of 0.5 is that too much?
Many authors argue that (multi-)collinearity is not
|
When can we speak of collinearity
My take on the three questions is
Question 1 What classifies as too much correlation? For example: a pearson correlation of 0.5 is that too much?
Many authors argue that (multi-)collinearity is not a problem. Take a look here and here for a rather acid opinion on the subject. The bottom line is that multicollinearity does not have an impact on the hypothesis testing other than having a lower (effective) sample size. It will be hard for you to interpret the regression coefficients if you do a regression, for instance, but you do not violate any basic assumption if you choose to do so.
Question 2 Can we fully determine whether there is collinearity between two variables based on the correlation coefficient or does it depend on other factors?
I think there are several ways of measuring the correlation between two variables, from calculating Pearson's correlation coefficient (if you assume linearity, and apparently you did so), to Spearman's rank, distance correlation, and even doing PCA on your dataset. But I would leave the answer of this question to better informed people than me.
Question 3 Does a graphical check of the scatter plot of the two variables add anything to what the correlation coefficient indicates?
IMO, the answer is sound no.
|
When can we speak of collinearity
My take on the three questions is
Question 1 What classifies as too much correlation? For example: a pearson correlation of 0.5 is that too much?
Many authors argue that (multi-)collinearity is not
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.