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
11,601
Mother milk of 6 Corona-positive (COVID-19) women does not contain the virus - can we make a confidence statement about this?
These tests of mother's milk are not useful to determine a confidence interval for the risk of contamination of children. Kjetil explained this very nicely in his answer that we end up with a large confidence interval of [0, 0.5], and AdamO has mentioned in the comments that this actually makes no sense because the binomial distribution is not a good model (below I argue that, while we may not have a clear idea of a better model, we can be reasonably certain that it will make the situation only/likely worse*). But these tests are not made in order to make some estimate of the probability that mother's milk might be contaminated. Instead, they are used as a search for a Black Swan and to test the theory that babies do not get sick. We have already good reasons to believe that mother's milk is not contaminated, or at least not such that it makes babies get COVID-19 (at least not with heavy symptoms). This test is a trial for that theory. If for some weird reason mother's milk would be heavily contaminated but babies still do not get sick, then this test would have shown that. AdamO: It depends on the probability model for the outcome. From a biology perspective, I don't think it makes sense to assume a binomial model. Tomka: Which models are alternatives? It's difficult to pinpoint a particular model, but at least some effects warn us that the binomial model may be inaccurate Should we consider the six tests independent? Possibly they have some correlation ,e.g. some testing-problem that simultaneously occurred in all samples. (RNA is unstable, maybe the virus makes it to the baby but not to the lab) Is infectivity of breast milk considered a constant? Potentially the breast milk will be more or less infectious depending on the difference in the time that the mother got infected and the time that the breast milk was sampled. So while there might not be a particular alternative model, we should treat the binomial model with a lot of caution. It is a bit of an ideal postitive situation. Also, the probability that the milk contains the virus is not equal to the probabilitiy that kids get sick from it. If the breast milk of infected mothers only contains virus, say, 10% of the time for each mother, then sampling milk from those mother's may easily give 6 negaŧive results but still, nearly 100% of the babies may get sick A better measure that we do not need to worry about babies (and breast milk) would be more direct measurements of the outcome (do babies/kids get sick?). Sample a set of babies that have pneumonia for the presence of nCoV-19 virus (or, if the sampling/testing is too expensive or otherwise not possible, then look at the number of cases and see whether it increase like the cases in the elderly population). In that way, you can see whether the risk of getting pneumonia/SARS increases for babies. What I understand from the stories (but I have not seen raw numbers and I am not sure whether babies are actually actively tested) is that babies do not get the virus. So, since babies do not get COVID-19 (at least not many), we do not need to worry about nCoV-19 virus in mother's milk (unless we give mother's milk also to the elderly population). Keep on breastfeeding (as also noted by the RCPCH: the benefits of breastfeeding outweigh the risks) If babies can get sick from nCoV-19 then breastmilk might actually be the thing that protects them and get's them better. We know that breastfeeding is good. But regarding a risk of COVID-19 for babies**... there isn't any data that shows that babies are under considerable risk due to the spread of this new virus. Data, data, data, use real data and not a panic interpretation of the data. Let's not kill the cats to control the plague. (*)One loophole in my reasoning, that the situation will only be worse when we use alternative models, would be some particular Bayesian models. Say that, based on prior knowledge, the probability that mother's milk is considered either heavily contaminated with probability of contamination p larger than 0.9, or very little contaminated with probability of contamination p smaller than 0.1. Then a posterior distribution for $p$ would lean heavily towards $p<0.1$. So the evaluation of this test with 6 moms may depend a lot on prior knowledge. The computed posterior is demonstrated below. On the left when we would have a continuous prior for p<0.1 and p>0.9 ,in which case the posterior scales like $p^7$. On the right when we would have a beta distribution as the prior, in which case the posterior is also a beta distribution (and simple to compute by just adding the observations to the parameters of the prior distribution). In both cases a prior distribution that places the probability more to the edges rather than the center (either the contamination probability of breats milk is high or it is low, will make that the result of the 6 cases is stronger than we would imagine from using the confidence interval that has no idea of these prior distribution. (**) Besides a risk for babies getting sick we actually would also need to consider the risk that babies may not get sick but still pass on the disease. However since babies have not much close contact with many other people this may not be expected to be a main/important route of transmission. And the advise given by the RCPCH (to have other people feed expressed breastmilk to the babies/kids) may actually increase the risk of spread, and get those others sick.
Mother milk of 6 Corona-positive (COVID-19) women does not contain the virus - can we make a confide
These tests of mother's milk are not useful to determine a confidence interval for the risk of contamination of children. Kjetil explained this very nicely in his answer that we end up with a large co
Mother milk of 6 Corona-positive (COVID-19) women does not contain the virus - can we make a confidence statement about this? These tests of mother's milk are not useful to determine a confidence interval for the risk of contamination of children. Kjetil explained this very nicely in his answer that we end up with a large confidence interval of [0, 0.5], and AdamO has mentioned in the comments that this actually makes no sense because the binomial distribution is not a good model (below I argue that, while we may not have a clear idea of a better model, we can be reasonably certain that it will make the situation only/likely worse*). But these tests are not made in order to make some estimate of the probability that mother's milk might be contaminated. Instead, they are used as a search for a Black Swan and to test the theory that babies do not get sick. We have already good reasons to believe that mother's milk is not contaminated, or at least not such that it makes babies get COVID-19 (at least not with heavy symptoms). This test is a trial for that theory. If for some weird reason mother's milk would be heavily contaminated but babies still do not get sick, then this test would have shown that. AdamO: It depends on the probability model for the outcome. From a biology perspective, I don't think it makes sense to assume a binomial model. Tomka: Which models are alternatives? It's difficult to pinpoint a particular model, but at least some effects warn us that the binomial model may be inaccurate Should we consider the six tests independent? Possibly they have some correlation ,e.g. some testing-problem that simultaneously occurred in all samples. (RNA is unstable, maybe the virus makes it to the baby but not to the lab) Is infectivity of breast milk considered a constant? Potentially the breast milk will be more or less infectious depending on the difference in the time that the mother got infected and the time that the breast milk was sampled. So while there might not be a particular alternative model, we should treat the binomial model with a lot of caution. It is a bit of an ideal postitive situation. Also, the probability that the milk contains the virus is not equal to the probabilitiy that kids get sick from it. If the breast milk of infected mothers only contains virus, say, 10% of the time for each mother, then sampling milk from those mother's may easily give 6 negaŧive results but still, nearly 100% of the babies may get sick A better measure that we do not need to worry about babies (and breast milk) would be more direct measurements of the outcome (do babies/kids get sick?). Sample a set of babies that have pneumonia for the presence of nCoV-19 virus (or, if the sampling/testing is too expensive or otherwise not possible, then look at the number of cases and see whether it increase like the cases in the elderly population). In that way, you can see whether the risk of getting pneumonia/SARS increases for babies. What I understand from the stories (but I have not seen raw numbers and I am not sure whether babies are actually actively tested) is that babies do not get the virus. So, since babies do not get COVID-19 (at least not many), we do not need to worry about nCoV-19 virus in mother's milk (unless we give mother's milk also to the elderly population). Keep on breastfeeding (as also noted by the RCPCH: the benefits of breastfeeding outweigh the risks) If babies can get sick from nCoV-19 then breastmilk might actually be the thing that protects them and get's them better. We know that breastfeeding is good. But regarding a risk of COVID-19 for babies**... there isn't any data that shows that babies are under considerable risk due to the spread of this new virus. Data, data, data, use real data and not a panic interpretation of the data. Let's not kill the cats to control the plague. (*)One loophole in my reasoning, that the situation will only be worse when we use alternative models, would be some particular Bayesian models. Say that, based on prior knowledge, the probability that mother's milk is considered either heavily contaminated with probability of contamination p larger than 0.9, or very little contaminated with probability of contamination p smaller than 0.1. Then a posterior distribution for $p$ would lean heavily towards $p<0.1$. So the evaluation of this test with 6 moms may depend a lot on prior knowledge. The computed posterior is demonstrated below. On the left when we would have a continuous prior for p<0.1 and p>0.9 ,in which case the posterior scales like $p^7$. On the right when we would have a beta distribution as the prior, in which case the posterior is also a beta distribution (and simple to compute by just adding the observations to the parameters of the prior distribution). In both cases a prior distribution that places the probability more to the edges rather than the center (either the contamination probability of breats milk is high or it is low, will make that the result of the 6 cases is stronger than we would imagine from using the confidence interval that has no idea of these prior distribution. (**) Besides a risk for babies getting sick we actually would also need to consider the risk that babies may not get sick but still pass on the disease. However since babies have not much close contact with many other people this may not be expected to be a main/important route of transmission. And the advise given by the RCPCH (to have other people feed expressed breastmilk to the babies/kids) may actually increase the risk of spread, and get those others sick.
Mother milk of 6 Corona-positive (COVID-19) women does not contain the virus - can we make a confide These tests of mother's milk are not useful to determine a confidence interval for the risk of contamination of children. Kjetil explained this very nicely in his answer that we end up with a large co
11,602
How true is this slide on deep learning claiming that all improvements from 1980s are only due to much more data and much faster computers?
I was browsing the AI StackExchange and ran across a very similar question: What distinguishes “Deep Learning” from other neural networks? Since the AI StackExchange will close tomorrow (again), I'll copy the two top answers here (user contributions licensed under cc by-sa 3.0 with attribution required): Author: mommi84less Two well-cited 2006 papers brought the research interest back to deep learning. In "A fast learning algorithm for deep belief nets", the authors define a deep belief net as: [...] densely-connected belief nets that have many hidden layers. We find almost the same description for deep networks in "Greedy Layer-Wise Training of Deep Networks": Deep multi-layer neural networks have many levels of non-linearities [...] Then, in the survey paper "Representation Learning: A Review and New Perspectives", deep learning is used to encompass all techniques (see also this talk) and is defined as: [...] constructing multiple levels of representation or learning a hierarchy of features. The adjective "deep" was thus used by the authors above to highlight the use of multiple non-linear hidden layers. Author: lejlot Just to add to @mommi84 answer. Deep learning is not limited to neural networks. This is more broad concept than just Hinton's DBNs etc. Deep learning is about the constructing multiple levels of representation or learning a hierarchy of features. So it is a name for hierarchical representation learning algorithms. There are deep models based on Hidden Markov Models, Conditional Random Fields, Support Vector Machines etc. The only common thing is, that instead of (popular in '90s) feature engineering, where researchers were trying to create set of features, which is the best for solving some classification problem - these machines can work out their own representation from raw data. In particular - applied to image recognition (raw images) they produce multi level representation consisting of pixels, then lines, then face features (if we are working with faces) like noses, eyes, and finally - generalized faces. If applied to Natural Language Processing - they construct language model, which connects words into chunks, chunks into sentences etc. Another interesting slide: source
How true is this slide on deep learning claiming that all improvements from 1980s are only due to mu
I was browsing the AI StackExchange and ran across a very similar question: What distinguishes “Deep Learning” from other neural networks? Since the AI StackExchange will close tomorrow (again), I'll
How true is this slide on deep learning claiming that all improvements from 1980s are only due to much more data and much faster computers? I was browsing the AI StackExchange and ran across a very similar question: What distinguishes “Deep Learning” from other neural networks? Since the AI StackExchange will close tomorrow (again), I'll copy the two top answers here (user contributions licensed under cc by-sa 3.0 with attribution required): Author: mommi84less Two well-cited 2006 papers brought the research interest back to deep learning. In "A fast learning algorithm for deep belief nets", the authors define a deep belief net as: [...] densely-connected belief nets that have many hidden layers. We find almost the same description for deep networks in "Greedy Layer-Wise Training of Deep Networks": Deep multi-layer neural networks have many levels of non-linearities [...] Then, in the survey paper "Representation Learning: A Review and New Perspectives", deep learning is used to encompass all techniques (see also this talk) and is defined as: [...] constructing multiple levels of representation or learning a hierarchy of features. The adjective "deep" was thus used by the authors above to highlight the use of multiple non-linear hidden layers. Author: lejlot Just to add to @mommi84 answer. Deep learning is not limited to neural networks. This is more broad concept than just Hinton's DBNs etc. Deep learning is about the constructing multiple levels of representation or learning a hierarchy of features. So it is a name for hierarchical representation learning algorithms. There are deep models based on Hidden Markov Models, Conditional Random Fields, Support Vector Machines etc. The only common thing is, that instead of (popular in '90s) feature engineering, where researchers were trying to create set of features, which is the best for solving some classification problem - these machines can work out their own representation from raw data. In particular - applied to image recognition (raw images) they produce multi level representation consisting of pixels, then lines, then face features (if we are working with faces) like noses, eyes, and finally - generalized faces. If applied to Natural Language Processing - they construct language model, which connects words into chunks, chunks into sentences etc. Another interesting slide: source
How true is this slide on deep learning claiming that all improvements from 1980s are only due to mu I was browsing the AI StackExchange and ran across a very similar question: What distinguishes “Deep Learning” from other neural networks? Since the AI StackExchange will close tomorrow (again), I'll
11,603
How true is this slide on deep learning claiming that all improvements from 1980s are only due to much more data and much faster computers?
Dropout, from Hinton in 2006, is said to be the greatest improvement in deep learning of the last 10 years, because it reduces a lot overfitting.
How true is this slide on deep learning claiming that all improvements from 1980s are only due to mu
Dropout, from Hinton in 2006, is said to be the greatest improvement in deep learning of the last 10 years, because it reduces a lot overfitting.
How true is this slide on deep learning claiming that all improvements from 1980s are only due to much more data and much faster computers? Dropout, from Hinton in 2006, is said to be the greatest improvement in deep learning of the last 10 years, because it reduces a lot overfitting.
How true is this slide on deep learning claiming that all improvements from 1980s are only due to mu Dropout, from Hinton in 2006, is said to be the greatest improvement in deep learning of the last 10 years, because it reduces a lot overfitting.
11,604
How true is this slide on deep learning claiming that all improvements from 1980s are only due to much more data and much faster computers?
This is certainly a question that will provoke controversy. When neural networks are used in deep learning they are typically trained in ways that weren't used in the 1980's. In particular strategies that pretrain individual layers of the neural network to recognize features at different level are claimed to make it easier to train networks with several layers. That's certainly a new development since the 1980's.
How true is this slide on deep learning claiming that all improvements from 1980s are only due to mu
This is certainly a question that will provoke controversy. When neural networks are used in deep learning they are typically trained in ways that weren't used in the 1980's. In particular strategi
How true is this slide on deep learning claiming that all improvements from 1980s are only due to much more data and much faster computers? This is certainly a question that will provoke controversy. When neural networks are used in deep learning they are typically trained in ways that weren't used in the 1980's. In particular strategies that pretrain individual layers of the neural network to recognize features at different level are claimed to make it easier to train networks with several layers. That's certainly a new development since the 1980's.
How true is this slide on deep learning claiming that all improvements from 1980s are only due to mu This is certainly a question that will provoke controversy. When neural networks are used in deep learning they are typically trained in ways that weren't used in the 1980's. In particular strategi
11,605
How true is this slide on deep learning claiming that all improvements from 1980s are only due to much more data and much faster computers?
The key is the word "deep" in deep learning. Someone (forgot ref) in the 80s proved that all non-linear functions could be approximated by a single layer neural network with, of course, a sufficiently large number of hidden units. I think this result probably discouraged people from seeking deeper network in the earlier era. But depth of the network is what proved to be the crucial element in hierarchical representation that drives the success of many of today's applications.
How true is this slide on deep learning claiming that all improvements from 1980s are only due to mu
The key is the word "deep" in deep learning. Someone (forgot ref) in the 80s proved that all non-linear functions could be approximated by a single layer neural network with, of course, a sufficiently
How true is this slide on deep learning claiming that all improvements from 1980s are only due to much more data and much faster computers? The key is the word "deep" in deep learning. Someone (forgot ref) in the 80s proved that all non-linear functions could be approximated by a single layer neural network with, of course, a sufficiently large number of hidden units. I think this result probably discouraged people from seeking deeper network in the earlier era. But depth of the network is what proved to be the crucial element in hierarchical representation that drives the success of many of today's applications.
How true is this slide on deep learning claiming that all improvements from 1980s are only due to mu The key is the word "deep" in deep learning. Someone (forgot ref) in the 80s proved that all non-linear functions could be approximated by a single layer neural network with, of course, a sufficiently
11,606
How true is this slide on deep learning claiming that all improvements from 1980s are only due to much more data and much faster computers?
Not exactly, the ANN starts in the 50s. Check out one of ML rock stars Yann LeCun's slides for an authentic and comprehensive intro. http://www.cs.nyu.edu/~yann/talks/lecun-ranzato-icml2013.pdf
How true is this slide on deep learning claiming that all improvements from 1980s are only due to mu
Not exactly, the ANN starts in the 50s. Check out one of ML rock stars Yann LeCun's slides for an authentic and comprehensive intro. http://www.cs.nyu.edu/~yann/talks/lecun-ranzato-icml2013.pdf
How true is this slide on deep learning claiming that all improvements from 1980s are only due to much more data and much faster computers? Not exactly, the ANN starts in the 50s. Check out one of ML rock stars Yann LeCun's slides for an authentic and comprehensive intro. http://www.cs.nyu.edu/~yann/talks/lecun-ranzato-icml2013.pdf
How true is this slide on deep learning claiming that all improvements from 1980s are only due to mu Not exactly, the ANN starts in the 50s. Check out one of ML rock stars Yann LeCun's slides for an authentic and comprehensive intro. http://www.cs.nyu.edu/~yann/talks/lecun-ranzato-icml2013.pdf
11,607
What are the four axes on PCA biplot?
Do you mean, e.g., in the plot that the following command returns? biplot(prcomp(USArrests, scale = TRUE)) If yes, then the top and the right axes are meant to be used for interpreting the red arrows (points depicting the variables) in the plot. If you know how the principal component analysis works, and you can read R code, the code below shows you how the results from prcomp() are initially treated by biplot.prcomp() before the final plotting by biplot.default(). These two functions are called in the background when you plot with biplot(), and the following modified code excerpt is from biplot.prcomp(). x<-prcomp(USArrests, scale=TRUE) choices = 1L:2L scale = 1 pc.biplot = FALSE scores<-x$x lam <- x$sdev[choices] n <- NROW(scores) lam <- lam * sqrt(n) lam <- lam^scale yy<-t(t(x$rotation[, choices]) * lam) xx<-t(t(scores[, choices])/lam) biplot(xx,yy) Shortly, in the example above, the the matrix of variable loadings (x$rotation) is scaled by the standard deviation of the principal components (x$sdev) times square root of the number of observations. This sets the scale for the top and right axes to what is seen on the plot. There are other methods to scale the variable loadings, also. These are offered e.g. by the R package vegan.
What are the four axes on PCA biplot?
Do you mean, e.g., in the plot that the following command returns? biplot(prcomp(USArrests, scale = TRUE)) If yes, then the top and the right axes are meant to be used for interpreting the red arrow
What are the four axes on PCA biplot? Do you mean, e.g., in the plot that the following command returns? biplot(prcomp(USArrests, scale = TRUE)) If yes, then the top and the right axes are meant to be used for interpreting the red arrows (points depicting the variables) in the plot. If you know how the principal component analysis works, and you can read R code, the code below shows you how the results from prcomp() are initially treated by biplot.prcomp() before the final plotting by biplot.default(). These two functions are called in the background when you plot with biplot(), and the following modified code excerpt is from biplot.prcomp(). x<-prcomp(USArrests, scale=TRUE) choices = 1L:2L scale = 1 pc.biplot = FALSE scores<-x$x lam <- x$sdev[choices] n <- NROW(scores) lam <- lam * sqrt(n) lam <- lam^scale yy<-t(t(x$rotation[, choices]) * lam) xx<-t(t(scores[, choices])/lam) biplot(xx,yy) Shortly, in the example above, the the matrix of variable loadings (x$rotation) is scaled by the standard deviation of the principal components (x$sdev) times square root of the number of observations. This sets the scale for the top and right axes to what is seen on the plot. There are other methods to scale the variable loadings, also. These are offered e.g. by the R package vegan.
What are the four axes on PCA biplot? Do you mean, e.g., in the plot that the following command returns? biplot(prcomp(USArrests, scale = TRUE)) If yes, then the top and the right axes are meant to be used for interpreting the red arrow
11,608
What are the four axes on PCA biplot?
I have a better visualization for the biplot. Please check following figure. In the experiment, I am trying to mapping 3d points into 2d (simulated data set). The trick to understand biplot in 2d is finding the correct angle to see same thing in 3d. All the data points are numbered, you can see the mapping clearly. Here is the code to reproduce the results. require(rgl) set.seed(0) feature1=round(rnorm(50)*10+20) feature2=round(rnorm(50)*10+30) feature3=round(runif(50)*feature1) d=data.frame(feature1,feature2,feature3) head(d) plot(feature1,feature2) plot(feature2,feature3) plot(feature1,feature3) plot3d(d$feature1, d$feature2, d$feature3, type = 'n') points3d(d$feature1, d$feature2, d$feature3, color = 'red', size = 10) shift <- matrix(c(-2, 2, 0), 12, 3, byrow = TRUE) text3d(d+shift,texts=1:50) grid3d(c("x", "y", "z")) pr.out=prcomp(d,scale.=T) biplot(pr.out) grid()
What are the four axes on PCA biplot?
I have a better visualization for the biplot. Please check following figure. In the experiment, I am trying to mapping 3d points into 2d (simulated data set). The trick to understand biplot in 2d is
What are the four axes on PCA biplot? I have a better visualization for the biplot. Please check following figure. In the experiment, I am trying to mapping 3d points into 2d (simulated data set). The trick to understand biplot in 2d is finding the correct angle to see same thing in 3d. All the data points are numbered, you can see the mapping clearly. Here is the code to reproduce the results. require(rgl) set.seed(0) feature1=round(rnorm(50)*10+20) feature2=round(rnorm(50)*10+30) feature3=round(runif(50)*feature1) d=data.frame(feature1,feature2,feature3) head(d) plot(feature1,feature2) plot(feature2,feature3) plot(feature1,feature3) plot3d(d$feature1, d$feature2, d$feature3, type = 'n') points3d(d$feature1, d$feature2, d$feature3, color = 'red', size = 10) shift <- matrix(c(-2, 2, 0), 12, 3, byrow = TRUE) text3d(d+shift,texts=1:50) grid3d(c("x", "y", "z")) pr.out=prcomp(d,scale.=T) biplot(pr.out) grid()
What are the four axes on PCA biplot? I have a better visualization for the biplot. Please check following figure. In the experiment, I am trying to mapping 3d points into 2d (simulated data set). The trick to understand biplot in 2d is
11,609
Why bother with low-rank approximations?
A low rank approximation $\hat{X}$ of $X$ can be decomposed into a matrix square root as $G=U_{r}\lambda_{r}^\frac{1}{2}$ where the eigen decomposition of $X$ is $U\lambda U^T$, thereby reducing the number of features, which can be represented by $G$ based on the rank-r approximation as $\hat{X}=GG^T$. Note that the subscript $r$ represents the number of eigen-vectors and eigen-values used in the approximation. Hence, it does reduce the number of features to represent the data. In some examples low-rank approximations are considered as basis or latent variable (dictionary) based expansions of the original data, under special constraints like orthogonality, non-negativity (non-negative matrix factorization) etc.
Why bother with low-rank approximations?
A low rank approximation $\hat{X}$ of $X$ can be decomposed into a matrix square root as $G=U_{r}\lambda_{r}^\frac{1}{2}$ where the eigen decomposition of $X$ is $U\lambda U^T$, thereby reducing the n
Why bother with low-rank approximations? A low rank approximation $\hat{X}$ of $X$ can be decomposed into a matrix square root as $G=U_{r}\lambda_{r}^\frac{1}{2}$ where the eigen decomposition of $X$ is $U\lambda U^T$, thereby reducing the number of features, which can be represented by $G$ based on the rank-r approximation as $\hat{X}=GG^T$. Note that the subscript $r$ represents the number of eigen-vectors and eigen-values used in the approximation. Hence, it does reduce the number of features to represent the data. In some examples low-rank approximations are considered as basis or latent variable (dictionary) based expansions of the original data, under special constraints like orthogonality, non-negativity (non-negative matrix factorization) etc.
Why bother with low-rank approximations? A low rank approximation $\hat{X}$ of $X$ can be decomposed into a matrix square root as $G=U_{r}\lambda_{r}^\frac{1}{2}$ where the eigen decomposition of $X$ is $U\lambda U^T$, thereby reducing the n
11,610
Why bother with low-rank approximations?
The point of low-rank approximation is not necessarily just for performing dimension reduction. The idea is that based on domain knowledge, the data/entries of the matrix will somehow make the matrix low rank. But that is in the ideal case where the entries are not affected by noise, corruption, missing values etc. The observed matrix typically will have much higher rank. Low-rank approximation is thus a way to recover the "original" (the "ideal" matrix before it was messed up by noise etc.) low-rank matrix i.e., find the matrix that is most consistent (in terms of observed entries) with the current matrix and is low-rank so that it can be used as an approximation to the ideal matrix. Having recovered this matrix, we can use it as a substitute for the noisy version and hopefully get better results.
Why bother with low-rank approximations?
The point of low-rank approximation is not necessarily just for performing dimension reduction. The idea is that based on domain knowledge, the data/entries of the matrix will somehow make the matrix
Why bother with low-rank approximations? The point of low-rank approximation is not necessarily just for performing dimension reduction. The idea is that based on domain knowledge, the data/entries of the matrix will somehow make the matrix low rank. But that is in the ideal case where the entries are not affected by noise, corruption, missing values etc. The observed matrix typically will have much higher rank. Low-rank approximation is thus a way to recover the "original" (the "ideal" matrix before it was messed up by noise etc.) low-rank matrix i.e., find the matrix that is most consistent (in terms of observed entries) with the current matrix and is low-rank so that it can be used as an approximation to the ideal matrix. Having recovered this matrix, we can use it as a substitute for the noisy version and hopefully get better results.
Why bother with low-rank approximations? The point of low-rank approximation is not necessarily just for performing dimension reduction. The idea is that based on domain knowledge, the data/entries of the matrix will somehow make the matrix
11,611
Why bother with low-rank approximations?
Once you have decided the rank of the approximation(say $r<m$) , you will only retain the $r$ basis vectors for future use (say, as predictors in a regression or classification problem) and not the original $m$.
Why bother with low-rank approximations?
Once you have decided the rank of the approximation(say $r<m$) , you will only retain the $r$ basis vectors for future use (say, as predictors in a regression or classification problem) and not the or
Why bother with low-rank approximations? Once you have decided the rank of the approximation(say $r<m$) , you will only retain the $r$ basis vectors for future use (say, as predictors in a regression or classification problem) and not the original $m$.
Why bother with low-rank approximations? Once you have decided the rank of the approximation(say $r<m$) , you will only retain the $r$ basis vectors for future use (say, as predictors in a regression or classification problem) and not the or
11,612
Why bother with low-rank approximations?
Two more reasons not mentioned so far: Reducing colinearity. I believe that most of these techniques remove colinearity, which can be helpful for follow-on processing. Our imaginations are low-rank, so it can be helpful for exploring low-rank relationships.
Why bother with low-rank approximations?
Two more reasons not mentioned so far: Reducing colinearity. I believe that most of these techniques remove colinearity, which can be helpful for follow-on processing. Our imaginations are low-rank,
Why bother with low-rank approximations? Two more reasons not mentioned so far: Reducing colinearity. I believe that most of these techniques remove colinearity, which can be helpful for follow-on processing. Our imaginations are low-rank, so it can be helpful for exploring low-rank relationships.
Why bother with low-rank approximations? Two more reasons not mentioned so far: Reducing colinearity. I believe that most of these techniques remove colinearity, which can be helpful for follow-on processing. Our imaginations are low-rank,
11,613
Why bother with low-rank approximations?
According to "Modern multivariate statistical techniques (Izenman)" reduced rank regression covers several interesting methods as special cases including PCA, factor analysis, canonical variate and correlation analysis, LDA and correspondence analysis
Why bother with low-rank approximations?
According to "Modern multivariate statistical techniques (Izenman)" reduced rank regression covers several interesting methods as special cases including PCA, factor analysis, canonical variate and co
Why bother with low-rank approximations? According to "Modern multivariate statistical techniques (Izenman)" reduced rank regression covers several interesting methods as special cases including PCA, factor analysis, canonical variate and correlation analysis, LDA and correspondence analysis
Why bother with low-rank approximations? According to "Modern multivariate statistical techniques (Izenman)" reduced rank regression covers several interesting methods as special cases including PCA, factor analysis, canonical variate and co
11,614
Post-hoc tests after Kruskal-Wallis: Dunn's test or Bonferroni corrected Mann-Whitney tests?
You should use a proper post hoc pairwise test like Dunn's test.* If one proceeds by moving from a rejection of Kruskal-Wallis to performing ordinary pair-wise rank sum tests (with or without multiple comparison adjustments), one runs into two problems: the ranks that the pair-wise rank sum tests use are not the ranks used by the Kruskal-Wallis test (i.e. you are, in effect, pretending to perform post hoc tests, but are actually using different data than was used in the Kruskal-Wallis test to do so); and Dunn's test preserves a pooled variance for the tests implied by the Kruskal-Wallis null hypothesis. Of course, as with any omnibus test (e.g., ANOVA, Cochran's $Q$, etc.), post hoc tests following rejection of a Kruskal-Wallis test which have been adjusted for multiple comparisons may fail to reject all pairwise tests for a given family-wise error rate or given false discovery rate corresponding to a given $\alpha$ for the omnibus test. * Dunn's test is implemented in Stata in the dunntest package (within Stata type net describe dunntest, from(https://alexisdinno.com/stata)), and in R in the dunn.test package. Caveat: there are a few less well-known post hoc pair-wise tests to follow a rejected Kruskal-Wallis, including Conover-Iman (like Dunn, but based on the t distribution, rather than the z distribution, and strictly more powerful as a post hoc test) which is implemented for Stata in the conovertest package (within Stata type net describe conovertest, from(https://alexisdinno.com/stata)), and for R in the conover.test package, and the Dwass-Steel-Critchlow-Fligner tests.
Post-hoc tests after Kruskal-Wallis: Dunn's test or Bonferroni corrected Mann-Whitney tests?
You should use a proper post hoc pairwise test like Dunn's test.* If one proceeds by moving from a rejection of Kruskal-Wallis to performing ordinary pair-wise rank sum tests (with or without multiple
Post-hoc tests after Kruskal-Wallis: Dunn's test or Bonferroni corrected Mann-Whitney tests? You should use a proper post hoc pairwise test like Dunn's test.* If one proceeds by moving from a rejection of Kruskal-Wallis to performing ordinary pair-wise rank sum tests (with or without multiple comparison adjustments), one runs into two problems: the ranks that the pair-wise rank sum tests use are not the ranks used by the Kruskal-Wallis test (i.e. you are, in effect, pretending to perform post hoc tests, but are actually using different data than was used in the Kruskal-Wallis test to do so); and Dunn's test preserves a pooled variance for the tests implied by the Kruskal-Wallis null hypothesis. Of course, as with any omnibus test (e.g., ANOVA, Cochran's $Q$, etc.), post hoc tests following rejection of a Kruskal-Wallis test which have been adjusted for multiple comparisons may fail to reject all pairwise tests for a given family-wise error rate or given false discovery rate corresponding to a given $\alpha$ for the omnibus test. * Dunn's test is implemented in Stata in the dunntest package (within Stata type net describe dunntest, from(https://alexisdinno.com/stata)), and in R in the dunn.test package. Caveat: there are a few less well-known post hoc pair-wise tests to follow a rejected Kruskal-Wallis, including Conover-Iman (like Dunn, but based on the t distribution, rather than the z distribution, and strictly more powerful as a post hoc test) which is implemented for Stata in the conovertest package (within Stata type net describe conovertest, from(https://alexisdinno.com/stata)), and for R in the conover.test package, and the Dwass-Steel-Critchlow-Fligner tests.
Post-hoc tests after Kruskal-Wallis: Dunn's test or Bonferroni corrected Mann-Whitney tests? You should use a proper post hoc pairwise test like Dunn's test.* If one proceeds by moving from a rejection of Kruskal-Wallis to performing ordinary pair-wise rank sum tests (with or without multiple
11,615
Can a GAN be used for data augmentation?
Yes, GAN can be used to "hallucinate" additional data as a form of data augmentation. See these papers which do pretty much what you are asking: Data Augmentation Generative Adversarial Networks Low-Shot Learning from Imaginary Data GAN-based Synthetic Medical Image Augmentation for increased CNN Performance in Liver Lesion Classification If your GAN is sufficiently well trained, there's no reason why this shouldn't help improve model performance. If your GAN is bad, you'll get garbage.
Can a GAN be used for data augmentation?
Yes, GAN can be used to "hallucinate" additional data as a form of data augmentation. See these papers which do pretty much what you are asking: Data Augmentation Generative Adversarial Networks Low-
Can a GAN be used for data augmentation? Yes, GAN can be used to "hallucinate" additional data as a form of data augmentation. See these papers which do pretty much what you are asking: Data Augmentation Generative Adversarial Networks Low-Shot Learning from Imaginary Data GAN-based Synthetic Medical Image Augmentation for increased CNN Performance in Liver Lesion Classification If your GAN is sufficiently well trained, there's no reason why this shouldn't help improve model performance. If your GAN is bad, you'll get garbage.
Can a GAN be used for data augmentation? Yes, GAN can be used to "hallucinate" additional data as a form of data augmentation. See these papers which do pretty much what you are asking: Data Augmentation Generative Adversarial Networks Low-
11,616
Can a GAN be used for data augmentation?
If you train your GAN on dataset A and use it to augment data on B, I think the answer is yes, since it absorb some knowledge from A. If you train your data on B and try to augment on B, I think GAN is useless here because there is no gain in information.
Can a GAN be used for data augmentation?
If you train your GAN on dataset A and use it to augment data on B, I think the answer is yes, since it absorb some knowledge from A. If you train your data on B and try to augment on B, I think GAN i
Can a GAN be used for data augmentation? If you train your GAN on dataset A and use it to augment data on B, I think the answer is yes, since it absorb some knowledge from A. If you train your data on B and try to augment on B, I think GAN is useless here because there is no gain in information.
Can a GAN be used for data augmentation? If you train your GAN on dataset A and use it to augment data on B, I think the answer is yes, since it absorb some knowledge from A. If you train your data on B and try to augment on B, I think GAN i
11,617
Can a GAN be used for data augmentation?
As already mentioned, it depends on what data you train your GAN. But it also depends on what you expect as an outcome of the GAN. Most methods focus on complete new synthetic data, but that's not the only option. This approach of landing AI seems to be more promising than just generating new artificial data, they augment existing data using a GAN to enrich it with rare events. This can help to generate data for classes that are underrepresented in the training data or could help to mitigate bias in some cases.
Can a GAN be used for data augmentation?
As already mentioned, it depends on what data you train your GAN. But it also depends on what you expect as an outcome of the GAN. Most methods focus on complete new synthetic data, but that's not the
Can a GAN be used for data augmentation? As already mentioned, it depends on what data you train your GAN. But it also depends on what you expect as an outcome of the GAN. Most methods focus on complete new synthetic data, but that's not the only option. This approach of landing AI seems to be more promising than just generating new artificial data, they augment existing data using a GAN to enrich it with rare events. This can help to generate data for classes that are underrepresented in the training data or could help to mitigate bias in some cases.
Can a GAN be used for data augmentation? As already mentioned, it depends on what data you train your GAN. But it also depends on what you expect as an outcome of the GAN. Most methods focus on complete new synthetic data, but that's not the
11,618
Can a GAN be used for data augmentation?
(My answer will mostly focus on tabular data as it has proven the hardest to synthesize owning to its heterogeneity and general arbitrariness) Yes, we can get a generative adversarial network (GAN) to generate synthetic data. An exceptional resource on this is: the Synthetic Data Vault initiative where a number of different approaches regarding synthetic data generation are included. As you correctly assess, GANs can be used for synthetic data generation, a number of approaches are implemented in the accompanying sdv package. I will note here that actually variational auto-encoders (VAEs) seem to be a very competitive alternative to GANs for this task. The last couple of years there have been quite a good papers on the subject, some obvious picks would be: Modeling Tabular data using Conditional GAN (2019) by Xu et al. Data Synthesis based on Generative Adversarial Networks (2018) by Park et al. Learning vine copula models for synthetic data generation (2018) by Sun et al. From personal experience: Synthetic data generation can be exceptionally hard to get "arbitrarily correct" but it can be possible to get reasonable mileage out it. For example: Making a synthetic dataset where a classifier cannot distinguish between original and synthetic data is very hard. Making a synthetic dataset to pass to collaborators for them to train some classifier such that it performs adequately in unseen real data is just hard. Making a synthetic dataset to pass to a collaborator to make some EDA and presentation material is usually doable. As such we need to consider why we need the synthetic data to begin with: is it for a privacy preserving task? is it a data-scarcity issue? is it for model-testing requirements? (common in financial applications - eg. stress testing in banking) (Other, more exotic use cases, also exist: complicated data-sharing agreements, adversarial learning applications, agent-based modelling, etc. but they are rarer beasts.) These points are not particular to tabular data but rather extend to all types of data. For example, one healthcare trust might want/have to avoid sharing real patient MRI scans (imaging data / privacy preserving scenario), similarly a tech start-up might need to train its voice recognition software on multiple speakers (speech data / data-scarcity scenario). Notably even GANs models with strong theoretical foundations (Wassenstein GAN (2017) Arjovsky et al.) might not be fully appropriate, for example financial time-series data have long-term correlations, volatility clustering and asymmetries (e.g. many small positive moves but few large negative ones) that we require us to use specialised metrics to assess their representativeness. To recap: using deep generative models (GANs, VAEs, EBMs) for synthetic data generation is an extremely fruitful area of ML research. They are already proofs of concepts from research groups as well as some early industrial products; their usefulness will vary wildly among different applications both in terms of data types (images, speech, tabular, etc.) as well as application fields (healthcare, retail, etc.). Therefore we have no established way to generally quantify their impact on the performance of a model. That said, we will have a clearer view in a couple of years; GDPR/CCPA are powerful motivators for certain multi-billion dollar companies to convince legislators about the benignity of their data usage - synthetic data generation is a piece of that puzzle.
Can a GAN be used for data augmentation?
(My answer will mostly focus on tabular data as it has proven the hardest to synthesize owning to its heterogeneity and general arbitrariness) Yes, we can get a generative adversarial network (GAN) to
Can a GAN be used for data augmentation? (My answer will mostly focus on tabular data as it has proven the hardest to synthesize owning to its heterogeneity and general arbitrariness) Yes, we can get a generative adversarial network (GAN) to generate synthetic data. An exceptional resource on this is: the Synthetic Data Vault initiative where a number of different approaches regarding synthetic data generation are included. As you correctly assess, GANs can be used for synthetic data generation, a number of approaches are implemented in the accompanying sdv package. I will note here that actually variational auto-encoders (VAEs) seem to be a very competitive alternative to GANs for this task. The last couple of years there have been quite a good papers on the subject, some obvious picks would be: Modeling Tabular data using Conditional GAN (2019) by Xu et al. Data Synthesis based on Generative Adversarial Networks (2018) by Park et al. Learning vine copula models for synthetic data generation (2018) by Sun et al. From personal experience: Synthetic data generation can be exceptionally hard to get "arbitrarily correct" but it can be possible to get reasonable mileage out it. For example: Making a synthetic dataset where a classifier cannot distinguish between original and synthetic data is very hard. Making a synthetic dataset to pass to collaborators for them to train some classifier such that it performs adequately in unseen real data is just hard. Making a synthetic dataset to pass to a collaborator to make some EDA and presentation material is usually doable. As such we need to consider why we need the synthetic data to begin with: is it for a privacy preserving task? is it a data-scarcity issue? is it for model-testing requirements? (common in financial applications - eg. stress testing in banking) (Other, more exotic use cases, also exist: complicated data-sharing agreements, adversarial learning applications, agent-based modelling, etc. but they are rarer beasts.) These points are not particular to tabular data but rather extend to all types of data. For example, one healthcare trust might want/have to avoid sharing real patient MRI scans (imaging data / privacy preserving scenario), similarly a tech start-up might need to train its voice recognition software on multiple speakers (speech data / data-scarcity scenario). Notably even GANs models with strong theoretical foundations (Wassenstein GAN (2017) Arjovsky et al.) might not be fully appropriate, for example financial time-series data have long-term correlations, volatility clustering and asymmetries (e.g. many small positive moves but few large negative ones) that we require us to use specialised metrics to assess their representativeness. To recap: using deep generative models (GANs, VAEs, EBMs) for synthetic data generation is an extremely fruitful area of ML research. They are already proofs of concepts from research groups as well as some early industrial products; their usefulness will vary wildly among different applications both in terms of data types (images, speech, tabular, etc.) as well as application fields (healthcare, retail, etc.). Therefore we have no established way to generally quantify their impact on the performance of a model. That said, we will have a clearer view in a couple of years; GDPR/CCPA are powerful motivators for certain multi-billion dollar companies to convince legislators about the benignity of their data usage - synthetic data generation is a piece of that puzzle.
Can a GAN be used for data augmentation? (My answer will mostly focus on tabular data as it has proven the hardest to synthesize owning to its heterogeneity and general arbitrariness) Yes, we can get a generative adversarial network (GAN) to
11,619
Can a GAN be used for data augmentation?
After long time, I would conclude the answer is no, based on some quite solid theoretical basis https://en.wikipedia.org/wiki/Data_processing_inequality
Can a GAN be used for data augmentation?
After long time, I would conclude the answer is no, based on some quite solid theoretical basis https://en.wikipedia.org/wiki/Data_processing_inequality
Can a GAN be used for data augmentation? After long time, I would conclude the answer is no, based on some quite solid theoretical basis https://en.wikipedia.org/wiki/Data_processing_inequality
Can a GAN be used for data augmentation? After long time, I would conclude the answer is no, based on some quite solid theoretical basis https://en.wikipedia.org/wiki/Data_processing_inequality
11,620
Can a GAN be used for data augmentation?
For visual tasks, data augmentation can often be accomplished by rotation, scaling, or rearranging patches. These transformations do not necessarily add information, but can be useful for models to learn to generalize better. The generator in a GAN learns a complex distribution from its training data from which you can sample, and you can view these new samples as another type of transformation of the original data, akin to rotation, scaling, etc.
Can a GAN be used for data augmentation?
For visual tasks, data augmentation can often be accomplished by rotation, scaling, or rearranging patches. These transformations do not necessarily add information, but can be useful for models to l
Can a GAN be used for data augmentation? For visual tasks, data augmentation can often be accomplished by rotation, scaling, or rearranging patches. These transformations do not necessarily add information, but can be useful for models to learn to generalize better. The generator in a GAN learns a complex distribution from its training data from which you can sample, and you can view these new samples as another type of transformation of the original data, akin to rotation, scaling, etc.
Can a GAN be used for data augmentation? For visual tasks, data augmentation can often be accomplished by rotation, scaling, or rearranging patches. These transformations do not necessarily add information, but can be useful for models to l
11,621
Regression for categorical independent variables and a continuous dependent one
Just some semantics and to be clear: dependent variable == outcome == "$y$" in regression formulas such as $y = β_0 + β_1x_1 + β_2x_2 + ... + β_kx_k$ independent variable == predictor == one of "$x_k$" in regression formulas such as $y = β_0 + β_1x_1 + β_2x_2 + ... + β_kx_k$ So in most situations the type of regression is dependend on the type of dependent, outcome or "$y$" variable. For example, linear regression is used when the dependent variable is continuous, logistic regression when the dependent is categorical with 2 categories, and multinomi(n)al regression when the dependent is categorical with more than 2 categories. The predictors can be anything (nominal or ordinal categorical, or continuous, or a mix). (The remark below might be redundant for you, but I add it anyway) However, do note that most software requires you to recode categorical predictors to a binary numeric system. This just means coding sex to 0 for females and 1 for males or vice versa. For categorical variables with more than 2 levels you'll need to recode these into $L-1$ dummy variables where $L$ is the number of levels and these dummies contain a 0 or 1 when they are in the corresponding category. This way each individual (sample) should be represented by having a 1 for the dummy variable he/she is part of and a 0 for the others, or a 0 for all dummies when he/she is part of the reference group.
Regression for categorical independent variables and a continuous dependent one
Just some semantics and to be clear: dependent variable == outcome == "$y$" in regression formulas such as $y = β_0 + β_1x_1 + β_2x_2 + ... + β_kx_k$ independent variable == predictor == one of "$x_k
Regression for categorical independent variables and a continuous dependent one Just some semantics and to be clear: dependent variable == outcome == "$y$" in regression formulas such as $y = β_0 + β_1x_1 + β_2x_2 + ... + β_kx_k$ independent variable == predictor == one of "$x_k$" in regression formulas such as $y = β_0 + β_1x_1 + β_2x_2 + ... + β_kx_k$ So in most situations the type of regression is dependend on the type of dependent, outcome or "$y$" variable. For example, linear regression is used when the dependent variable is continuous, logistic regression when the dependent is categorical with 2 categories, and multinomi(n)al regression when the dependent is categorical with more than 2 categories. The predictors can be anything (nominal or ordinal categorical, or continuous, or a mix). (The remark below might be redundant for you, but I add it anyway) However, do note that most software requires you to recode categorical predictors to a binary numeric system. This just means coding sex to 0 for females and 1 for males or vice versa. For categorical variables with more than 2 levels you'll need to recode these into $L-1$ dummy variables where $L$ is the number of levels and these dummies contain a 0 or 1 when they are in the corresponding category. This way each individual (sample) should be represented by having a 1 for the dummy variable he/she is part of and a 0 for the others, or a 0 for all dummies when he/she is part of the reference group.
Regression for categorical independent variables and a continuous dependent one Just some semantics and to be clear: dependent variable == outcome == "$y$" in regression formulas such as $y = β_0 + β_1x_1 + β_2x_2 + ... + β_kx_k$ independent variable == predictor == one of "$x_k
11,622
What is the logic behind method of moments?
A sample consisting of $n$ realizations from identically and independently distributed random variables is ergodic. In a such a case, "sample moments" are consistent estimators of theoretical moments of the common distribution, if the theoretical moments exist and are finite. This means that $$\hat \mu_k(n) = \mu_k(\theta) + e_k(n), \;\;\; e_k(n) \xrightarrow{p} 0 \tag{1}$$ So by equating the theoretical moment with the corresponding sample moment we have $$\hat \mu_k(n) = \mu_k(\theta) \Rightarrow \hat \theta(n) = \mu_k^{-1}(\hat \mu_k(n)) = \mu_k^{-1}[\mu_k(\theta) + e_k(n)]$$ So ($\mu_k$ does not depend on $n$) $$\text{plim} \hat \theta(n) = \text{plim}\big[\mu_k^{-1}(\mu_k(\theta) + e_k)\big] = \mu_k^{-1}\big(\mu_k(\theta) + \text{plim}e_k(n)\big)$$ $$=\mu_k^{-1}\big(\mu_k(\theta) + 0\big) = \mu_k^{-1}\mu_k(\theta) = \theta$$ So we do that because we obtain consistent estimators for the unknown parameters.
What is the logic behind method of moments?
A sample consisting of $n$ realizations from identically and independently distributed random variables is ergodic. In a such a case, "sample moments" are consistent estimators of theoretical moments
What is the logic behind method of moments? A sample consisting of $n$ realizations from identically and independently distributed random variables is ergodic. In a such a case, "sample moments" are consistent estimators of theoretical moments of the common distribution, if the theoretical moments exist and are finite. This means that $$\hat \mu_k(n) = \mu_k(\theta) + e_k(n), \;\;\; e_k(n) \xrightarrow{p} 0 \tag{1}$$ So by equating the theoretical moment with the corresponding sample moment we have $$\hat \mu_k(n) = \mu_k(\theta) \Rightarrow \hat \theta(n) = \mu_k^{-1}(\hat \mu_k(n)) = \mu_k^{-1}[\mu_k(\theta) + e_k(n)]$$ So ($\mu_k$ does not depend on $n$) $$\text{plim} \hat \theta(n) = \text{plim}\big[\mu_k^{-1}(\mu_k(\theta) + e_k)\big] = \mu_k^{-1}\big(\mu_k(\theta) + \text{plim}e_k(n)\big)$$ $$=\mu_k^{-1}\big(\mu_k(\theta) + 0\big) = \mu_k^{-1}\mu_k(\theta) = \theta$$ So we do that because we obtain consistent estimators for the unknown parameters.
What is the logic behind method of moments? A sample consisting of $n$ realizations from identically and independently distributed random variables is ergodic. In a such a case, "sample moments" are consistent estimators of theoretical moments
11,623
What is the logic behind method of moments?
Econometricians call this "the analogy principle". You compute the population mean as the expected value with respect to the population distribution; you compute the estimator as the expected value with respect to the sample distribution, and it turns out to be the sample mean. You have a unified expression $$ T(F) = \int t(x) \, {\rm d}F(x) $$ into which you plug either the population $F(x)$, say $F(x) = \int_{\infty}^x \frac1{\sqrt{2\pi\sigma^2}} \exp\bigl[ - \frac{(u-\mu)^2}{2\sigma^2} \bigr] \, {\rm d}u $ or the sample $F_n(x) = \frac 1n \sum_{i=1}^n 1\{ x_i \le x \}$, so that ${\rm d}F_n(x)$ is a bunch of delta-functions, and the (Lebesgue) integral with respect to ${\rm d}F_n(x)$ is the sample sum $\frac1n \sum_{i=1}^n t(x_i)$. If your functional $T(\cdot)$ is (weakly) differentiable, and $F_n(x)$ converges in the appropriate sense to $F(x)$, then it is easy to establish that the estimate is consistent, although of course more hoopla is needed to obtain say asymptotic normality.
What is the logic behind method of moments?
Econometricians call this "the analogy principle". You compute the population mean as the expected value with respect to the population distribution; you compute the estimator as the expected value wi
What is the logic behind method of moments? Econometricians call this "the analogy principle". You compute the population mean as the expected value with respect to the population distribution; you compute the estimator as the expected value with respect to the sample distribution, and it turns out to be the sample mean. You have a unified expression $$ T(F) = \int t(x) \, {\rm d}F(x) $$ into which you plug either the population $F(x)$, say $F(x) = \int_{\infty}^x \frac1{\sqrt{2\pi\sigma^2}} \exp\bigl[ - \frac{(u-\mu)^2}{2\sigma^2} \bigr] \, {\rm d}u $ or the sample $F_n(x) = \frac 1n \sum_{i=1}^n 1\{ x_i \le x \}$, so that ${\rm d}F_n(x)$ is a bunch of delta-functions, and the (Lebesgue) integral with respect to ${\rm d}F_n(x)$ is the sample sum $\frac1n \sum_{i=1}^n t(x_i)$. If your functional $T(\cdot)$ is (weakly) differentiable, and $F_n(x)$ converges in the appropriate sense to $F(x)$, then it is easy to establish that the estimate is consistent, although of course more hoopla is needed to obtain say asymptotic normality.
What is the logic behind method of moments? Econometricians call this "the analogy principle". You compute the population mean as the expected value with respect to the population distribution; you compute the estimator as the expected value wi
11,624
What is the logic behind method of moments?
I might be wrong but the way that I think about it is as follows: Let's say you have samples $X_1, X_2, \dotsc, X_n$. Then, the method of the moments suggest that we should compare $m-th$ moment of sample with $m$th moment of population $$(X_1 + X_2 + \dotsm + X_n) / n = μ$$ here, we are averaging all the samples out which seems like a good estimate of population mean $$(X_1^2 + X_2^2 + \dotsm + X_n^2) / n = σ^2$$ here, we are averaging all the sample variances out which also seems like a good estimate of population variance And so on, That is what I think is a good explanation of how method of moment works!
What is the logic behind method of moments?
I might be wrong but the way that I think about it is as follows: Let's say you have samples $X_1, X_2, \dotsc, X_n$. Then, the method of the moments suggest that we should compare $m-th$ moment of sa
What is the logic behind method of moments? I might be wrong but the way that I think about it is as follows: Let's say you have samples $X_1, X_2, \dotsc, X_n$. Then, the method of the moments suggest that we should compare $m-th$ moment of sample with $m$th moment of population $$(X_1 + X_2 + \dotsm + X_n) / n = μ$$ here, we are averaging all the samples out which seems like a good estimate of population mean $$(X_1^2 + X_2^2 + \dotsm + X_n^2) / n = σ^2$$ here, we are averaging all the sample variances out which also seems like a good estimate of population variance And so on, That is what I think is a good explanation of how method of moment works!
What is the logic behind method of moments? I might be wrong but the way that I think about it is as follows: Let's say you have samples $X_1, X_2, \dotsc, X_n$. Then, the method of the moments suggest that we should compare $m-th$ moment of sa
11,625
Is it possible to apply KL divergence between discrete and continuous distribution?
KL divergence is only defined on distributions over a common space. If $p$ is a distribution on $\mathbb{R}^3$ and $q$ a distribution on $\mathbb{Z}$, then $q(x)$ doesn't make sense for points $p \in \mathbb{R}^3$ and $p(z)$ doesn't make sense for points $z \in \mathbb{Z}$. However, if you have a discrete distribution over the same space as a continuous distribution, e.g. both on $\mathbb R$ (although the discrete distribution obviously doesn't have support on all of $\mathbb R$), the KL divergence can be defined, as in Olivier's answer. To do this, we have to use densities with respect to a common "dominating measure" $\mu$: if $\frac{\mathrm d P}{\mathrm d \mu} = p$ and $\frac{\mathrm d Q}{\mathrm d \mu} = q$, then $\operatorname{KL}(P \,\|\, Q) = \int p(x) \log \frac{p(x)}{q(x)} \mathrm d\mu(x)$. These densities are called Radon-Nikodym derivatives, and $\mu$ should dominate the distributions $P$ and $Q$. This is always possible, e.g. by using $\mu = P + Q$ as Olivier did. Also, I believe (agreeing with Olivier's comments) that the value of the KL divergence should be invariant to the choice of dominating measure, though I haven't written out a full proof – so the choice of $\mu$ shouldn't matter. Then, if one distribution is continuous and the other discrete, both directions of the KL are always infinite (shown below). This makes it not a very interesting measure. The same is true, I believe, for any $f$-divergence (not always infinite, but always a particular constant value). A much more interesting class of measures are the integral probability metrics, $$D(P, Q) = \sup_{f \in \mathcal F} \mathbb E_{X \sim P} f(X) - \mathbb E_{Y \sim Q} f(Y),$$ particularly the Wasserstein distance or also the kernel MMD, both of which can meaningfully compare distributions with different supports. To see this: I find it kind of confusing to take derivatives with respect to $P + Q$, so let's do something I find simpler. If $P$ is a continuous distribution, then typically what we mean by that is that it's dominated by Lebesgue measure $\lambda$, and has density $p$ with respect to $\lambda$, where $p$ is exactly the typical probability density function. If $Q$ is a discrete distribution, its support is some at-most-countable set; call it $K$, and define the measure $k(A) = \lvert A \cap K \rvert$. Then $Q$ has density $q$ with respect to $k$, where $q$ is exactly the typical probability mass function. So, let's use as our base measure $\mu = \lambda + k$. (Note that indeed $\mu$ is $\sigma$-finite.) Now, $\frac{\mathrm d P}{\mathrm d \mu}$ is a function $\tilde p$ such that $P(A) = \int_A \tilde p(x) \mathrm d \mu(x) = \int_A \tilde p(x) \mathrm d \lambda(x) + \sum_{x \in K} \tilde p(x)$. To make this work, we should choose $$\tilde p(x) = \begin{cases} 0 & \text{if } x \in K \\ p(x) & \text{otherwise} \end{cases}.$$ Then $\sum_{x \in K} \tilde p(x) = 0$, and $$\int_A \tilde p(x) \mathrm d \lambda(x) = \int_A p(x) \mathrm d \lambda(x) - \int_K p(x) \mathrm d \lambda(x) = P(A) - 0,$$ since $\lambda(K) = 0$. Thus $\tilde p$ is a valid derivative. The $Q$ derivative is similar: pick $\tilde q(x) = \begin{cases} q(x) & \text{if } x \in K \\ 0 & \text{otherwise} \end{cases}$. Armed with these derivatives, we can now evaluate the KL divergence. For one direction, we have \begin{align*} \operatorname{KL}(P \,\|\, Q) &= \int \tilde p(x) \log \frac{\tilde p(x)}{\tilde q(x)} \mathrm d\mu(x) \\&= \int \tilde p(x) \log \frac{\tilde p(x)}{\tilde q(x)} \mathrm d\lambda(x) + \sum_{x \in K} \tilde p(x) \log \frac{\tilde p(x)}{\tilde q(x)} .\end{align*} In the last line, each term inside the sum will always be $0 \log \frac{0}{\text{nonzero}}$. This is unfortunate, but typically we'll treat the definition of KL divergence (and entropy) as defining that as zero, and the sum is zero. Meanwhile, each element of the integral is going to be $\tilde p(x) \log \frac{\tilde p(x)}{0}$, with many nonzero values for $\tilde p(x)$ (everything in $\operatorname{supp}(P) \setminus K$). That makes the integral, and $\operatorname{KL}(P \,\|\, Q)$, infinity. The other direction is much the same; we get $$ \operatorname{KL}(Q \,\|\, P) = \int \tilde q(x) \log \frac{\tilde q(x)}{\tilde p(x)} \mathrm d\lambda(x) + \sum_{x \in K} \tilde q(x) \log \frac{\tilde q(x)}{\tilde p(x)} ,$$ and everything in the integral is $0 \log 0$ while the sum is $\sum_{x \in K} q(x) \log \frac{q(x)}{0}$, making this direction of KL also infinite.
Is it possible to apply KL divergence between discrete and continuous distribution?
KL divergence is only defined on distributions over a common space. If $p$ is a distribution on $\mathbb{R}^3$ and $q$ a distribution on $\mathbb{Z}$, then $q(x)$ doesn't make sense for points $p \in
Is it possible to apply KL divergence between discrete and continuous distribution? KL divergence is only defined on distributions over a common space. If $p$ is a distribution on $\mathbb{R}^3$ and $q$ a distribution on $\mathbb{Z}$, then $q(x)$ doesn't make sense for points $p \in \mathbb{R}^3$ and $p(z)$ doesn't make sense for points $z \in \mathbb{Z}$. However, if you have a discrete distribution over the same space as a continuous distribution, e.g. both on $\mathbb R$ (although the discrete distribution obviously doesn't have support on all of $\mathbb R$), the KL divergence can be defined, as in Olivier's answer. To do this, we have to use densities with respect to a common "dominating measure" $\mu$: if $\frac{\mathrm d P}{\mathrm d \mu} = p$ and $\frac{\mathrm d Q}{\mathrm d \mu} = q$, then $\operatorname{KL}(P \,\|\, Q) = \int p(x) \log \frac{p(x)}{q(x)} \mathrm d\mu(x)$. These densities are called Radon-Nikodym derivatives, and $\mu$ should dominate the distributions $P$ and $Q$. This is always possible, e.g. by using $\mu = P + Q$ as Olivier did. Also, I believe (agreeing with Olivier's comments) that the value of the KL divergence should be invariant to the choice of dominating measure, though I haven't written out a full proof – so the choice of $\mu$ shouldn't matter. Then, if one distribution is continuous and the other discrete, both directions of the KL are always infinite (shown below). This makes it not a very interesting measure. The same is true, I believe, for any $f$-divergence (not always infinite, but always a particular constant value). A much more interesting class of measures are the integral probability metrics, $$D(P, Q) = \sup_{f \in \mathcal F} \mathbb E_{X \sim P} f(X) - \mathbb E_{Y \sim Q} f(Y),$$ particularly the Wasserstein distance or also the kernel MMD, both of which can meaningfully compare distributions with different supports. To see this: I find it kind of confusing to take derivatives with respect to $P + Q$, so let's do something I find simpler. If $P$ is a continuous distribution, then typically what we mean by that is that it's dominated by Lebesgue measure $\lambda$, and has density $p$ with respect to $\lambda$, where $p$ is exactly the typical probability density function. If $Q$ is a discrete distribution, its support is some at-most-countable set; call it $K$, and define the measure $k(A) = \lvert A \cap K \rvert$. Then $Q$ has density $q$ with respect to $k$, where $q$ is exactly the typical probability mass function. So, let's use as our base measure $\mu = \lambda + k$. (Note that indeed $\mu$ is $\sigma$-finite.) Now, $\frac{\mathrm d P}{\mathrm d \mu}$ is a function $\tilde p$ such that $P(A) = \int_A \tilde p(x) \mathrm d \mu(x) = \int_A \tilde p(x) \mathrm d \lambda(x) + \sum_{x \in K} \tilde p(x)$. To make this work, we should choose $$\tilde p(x) = \begin{cases} 0 & \text{if } x \in K \\ p(x) & \text{otherwise} \end{cases}.$$ Then $\sum_{x \in K} \tilde p(x) = 0$, and $$\int_A \tilde p(x) \mathrm d \lambda(x) = \int_A p(x) \mathrm d \lambda(x) - \int_K p(x) \mathrm d \lambda(x) = P(A) - 0,$$ since $\lambda(K) = 0$. Thus $\tilde p$ is a valid derivative. The $Q$ derivative is similar: pick $\tilde q(x) = \begin{cases} q(x) & \text{if } x \in K \\ 0 & \text{otherwise} \end{cases}$. Armed with these derivatives, we can now evaluate the KL divergence. For one direction, we have \begin{align*} \operatorname{KL}(P \,\|\, Q) &= \int \tilde p(x) \log \frac{\tilde p(x)}{\tilde q(x)} \mathrm d\mu(x) \\&= \int \tilde p(x) \log \frac{\tilde p(x)}{\tilde q(x)} \mathrm d\lambda(x) + \sum_{x \in K} \tilde p(x) \log \frac{\tilde p(x)}{\tilde q(x)} .\end{align*} In the last line, each term inside the sum will always be $0 \log \frac{0}{\text{nonzero}}$. This is unfortunate, but typically we'll treat the definition of KL divergence (and entropy) as defining that as zero, and the sum is zero. Meanwhile, each element of the integral is going to be $\tilde p(x) \log \frac{\tilde p(x)}{0}$, with many nonzero values for $\tilde p(x)$ (everything in $\operatorname{supp}(P) \setminus K$). That makes the integral, and $\operatorname{KL}(P \,\|\, Q)$, infinity. The other direction is much the same; we get $$ \operatorname{KL}(Q \,\|\, P) = \int \tilde q(x) \log \frac{\tilde q(x)}{\tilde p(x)} \mathrm d\lambda(x) + \sum_{x \in K} \tilde q(x) \log \frac{\tilde q(x)}{\tilde p(x)} ,$$ and everything in the integral is $0 \log 0$ while the sum is $\sum_{x \in K} q(x) \log \frac{q(x)}{0}$, making this direction of KL also infinite.
Is it possible to apply KL divergence between discrete and continuous distribution? KL divergence is only defined on distributions over a common space. If $p$ is a distribution on $\mathbb{R}^3$ and $q$ a distribution on $\mathbb{Z}$, then $q(x)$ doesn't make sense for points $p \in
11,626
Is it possible to apply KL divergence between discrete and continuous distribution?
Yes, the KL divergence between continuous and discrete random variables is well defined. If $P$ and $Q$ are distributions on some space $\mathbb{X}$, then both $P$ and $Q$ have densities $f$, $g$ with respect to $\mu = P+Q$ and $$ D_{KL}(P,Q) = \int_{\mathbb{X}} f \log\frac{f}{g}d\mu. $$ For example, if $\mathbb{X} = [0,1]$, $P$ is Lebesgue's measure and $Q = \delta_0$ is a point mass at $0$, then $f(x) = 1-\mathbb{1}_{x=0}$, $g(x) = \mathbb{1}_{x=0}$ and $$D_{KL}(P, Q) = \infty.$$
Is it possible to apply KL divergence between discrete and continuous distribution?
Yes, the KL divergence between continuous and discrete random variables is well defined. If $P$ and $Q$ are distributions on some space $\mathbb{X}$, then both $P$ and $Q$ have densities $f$, $g$ with
Is it possible to apply KL divergence between discrete and continuous distribution? Yes, the KL divergence between continuous and discrete random variables is well defined. If $P$ and $Q$ are distributions on some space $\mathbb{X}$, then both $P$ and $Q$ have densities $f$, $g$ with respect to $\mu = P+Q$ and $$ D_{KL}(P,Q) = \int_{\mathbb{X}} f \log\frac{f}{g}d\mu. $$ For example, if $\mathbb{X} = [0,1]$, $P$ is Lebesgue's measure and $Q = \delta_0$ is a point mass at $0$, then $f(x) = 1-\mathbb{1}_{x=0}$, $g(x) = \mathbb{1}_{x=0}$ and $$D_{KL}(P, Q) = \infty.$$
Is it possible to apply KL divergence between discrete and continuous distribution? Yes, the KL divergence between continuous and discrete random variables is well defined. If $P$ and $Q$ are distributions on some space $\mathbb{X}$, then both $P$ and $Q$ have densities $f$, $g$ with
11,627
Is it possible to apply KL divergence between discrete and continuous distribution?
Not in general. The KL divergence is $$ D_{KL}(P \ || \ Q) = \int_{\mathcal{X}} \log \left(\frac{dP}{dQ}\right)dP $$ provided that $P$ is absolutely continuous with respect to $Q$ and both $P$ and $Q$ are $\sigma$-finite (i.e. under conditions where $\frac{dP}{dQ}$ is well-defined). For a 'continuous-to-discrete' KL divergence between measures on some usual space, you have the case where Lebesgue measure is absolutely continuous with respect to counting measure, but counting measure is not $\sigma$-finite.
Is it possible to apply KL divergence between discrete and continuous distribution?
Not in general. The KL divergence is $$ D_{KL}(P \ || \ Q) = \int_{\mathcal{X}} \log \left(\frac{dP}{dQ}\right)dP $$ provided that $P$ is absolutely continuous with respect to $Q$ and both $P$ and $Q
Is it possible to apply KL divergence between discrete and continuous distribution? Not in general. The KL divergence is $$ D_{KL}(P \ || \ Q) = \int_{\mathcal{X}} \log \left(\frac{dP}{dQ}\right)dP $$ provided that $P$ is absolutely continuous with respect to $Q$ and both $P$ and $Q$ are $\sigma$-finite (i.e. under conditions where $\frac{dP}{dQ}$ is well-defined). For a 'continuous-to-discrete' KL divergence between measures on some usual space, you have the case where Lebesgue measure is absolutely continuous with respect to counting measure, but counting measure is not $\sigma$-finite.
Is it possible to apply KL divergence between discrete and continuous distribution? Not in general. The KL divergence is $$ D_{KL}(P \ || \ Q) = \int_{\mathcal{X}} \log \left(\frac{dP}{dQ}\right)dP $$ provided that $P$ is absolutely continuous with respect to $Q$ and both $P$ and $Q
11,628
Balanced accuracy vs F-1 score
Mathematically, b_acc is the arithmetic mean of recall_P and recall_N and f1 is the harmonic mean of recall_P and precision_P. Both F1 and b_acc are metrics for classifier evaluation, that (to some extent) handle class imbalance. Depending of which of the two classes (N or P) outnumbers the other, each metric is outperforms the other. 1) If N >> P, f1 is a better. 2) If P >> N, b_acc is better. Clearly, if you can label-switch, both the metrics can be used in any of the two imbalance cases above. If not, then depending on the imbalance in the training data, you can select the appropriate metric.
Balanced accuracy vs F-1 score
Mathematically, b_acc is the arithmetic mean of recall_P and recall_N and f1 is the harmonic mean of recall_P and precision_P. Both F1 and b_acc are metrics for classifier evaluation, that (to some e
Balanced accuracy vs F-1 score Mathematically, b_acc is the arithmetic mean of recall_P and recall_N and f1 is the harmonic mean of recall_P and precision_P. Both F1 and b_acc are metrics for classifier evaluation, that (to some extent) handle class imbalance. Depending of which of the two classes (N or P) outnumbers the other, each metric is outperforms the other. 1) If N >> P, f1 is a better. 2) If P >> N, b_acc is better. Clearly, if you can label-switch, both the metrics can be used in any of the two imbalance cases above. If not, then depending on the imbalance in the training data, you can select the appropriate metric.
Balanced accuracy vs F-1 score Mathematically, b_acc is the arithmetic mean of recall_P and recall_N and f1 is the harmonic mean of recall_P and precision_P. Both F1 and b_acc are metrics for classifier evaluation, that (to some e
11,629
Measures of model complexity
Besides the various measures of Minimum Description Length (e.g., normalized maximum likelihood, Fisher Information approximation), there are two other methods worth to mention: Parametric Bootstrap. It's a lot easier to implement than the demanding MDL measures. A nice paper is by Wagenmaker and colleagues: Wagenmakers, E.-J., Ratcliff, R., Gomez, P., & Iverson, G. J. (2004). Assessing model mimicry using the parametric bootstrap. Journal of Mathematical Psychology, 48, 28-50. The abstract: We present a general sampling procedure to quantify model mimicry, defined as the ability of a model to account for data generated by a competing model. This sampling procedure, called the parametric bootstrap cross-fitting method (PBCM; cf. Williams (J. R. Statist. Soc. B 32 (1970) 350; Biometrics 26 (1970) 23)), generates distributions of differences in goodness-of-fit expected under each of the competing models. In the data informed version of the PBCM, the generating models have specific parameter values obtained by fitting the experimental data under consideration. The data informed difference distributions can be compared to the observed difference in goodness-of-fit to allow a quantification of model adequacy. In the data uninformed version of the PBCM, the generating models have a relatively broad range of parameter values based on prior knowledge. Application of both the data informed and the data uninformed PBCM is illustrated with several examples. Update: Assessing model mimicry in plain English. You take one of the two competing models and randomly pick a set of parameters for that model (either data informed or not). Then, you produce data from this model with the picked set of parameters. Next, you let both models fit the produced data and check which of the two candidate models gives the better fit. If both models are equally flexible or complex, the model from which you produced the data should give a better fit. However, if the other model is more complex, it could give a better fit, although the data was produced from the other model. You repeat this several times with both models (i.e., let both models produce data and look which of the two fits better). The model that "overfits" the data produced by the other model is the more complex one. Cross-Validation: It is also quite easy to implement. See the answers to this question. However, note that the issue with it is that the choice among the sample-cutting rule (leave-one-out, K-fold, etc) is an unprincipled one.
Measures of model complexity
Besides the various measures of Minimum Description Length (e.g., normalized maximum likelihood, Fisher Information approximation), there are two other methods worth to mention: Parametric Bootstra
Measures of model complexity Besides the various measures of Minimum Description Length (e.g., normalized maximum likelihood, Fisher Information approximation), there are two other methods worth to mention: Parametric Bootstrap. It's a lot easier to implement than the demanding MDL measures. A nice paper is by Wagenmaker and colleagues: Wagenmakers, E.-J., Ratcliff, R., Gomez, P., & Iverson, G. J. (2004). Assessing model mimicry using the parametric bootstrap. Journal of Mathematical Psychology, 48, 28-50. The abstract: We present a general sampling procedure to quantify model mimicry, defined as the ability of a model to account for data generated by a competing model. This sampling procedure, called the parametric bootstrap cross-fitting method (PBCM; cf. Williams (J. R. Statist. Soc. B 32 (1970) 350; Biometrics 26 (1970) 23)), generates distributions of differences in goodness-of-fit expected under each of the competing models. In the data informed version of the PBCM, the generating models have specific parameter values obtained by fitting the experimental data under consideration. The data informed difference distributions can be compared to the observed difference in goodness-of-fit to allow a quantification of model adequacy. In the data uninformed version of the PBCM, the generating models have a relatively broad range of parameter values based on prior knowledge. Application of both the data informed and the data uninformed PBCM is illustrated with several examples. Update: Assessing model mimicry in plain English. You take one of the two competing models and randomly pick a set of parameters for that model (either data informed or not). Then, you produce data from this model with the picked set of parameters. Next, you let both models fit the produced data and check which of the two candidate models gives the better fit. If both models are equally flexible or complex, the model from which you produced the data should give a better fit. However, if the other model is more complex, it could give a better fit, although the data was produced from the other model. You repeat this several times with both models (i.e., let both models produce data and look which of the two fits better). The model that "overfits" the data produced by the other model is the more complex one. Cross-Validation: It is also quite easy to implement. See the answers to this question. However, note that the issue with it is that the choice among the sample-cutting rule (leave-one-out, K-fold, etc) is an unprincipled one.
Measures of model complexity Besides the various measures of Minimum Description Length (e.g., normalized maximum likelihood, Fisher Information approximation), there are two other methods worth to mention: Parametric Bootstra
11,630
Measures of model complexity
I think it would depend on the actual model fitting procedure. For a generally applicable measure, you might consider Generalized Degrees of Freedom described in Ye 1998 -- essentially the sensitivity of change of model estimates to perturbation of observations -- which works quite well as a measure of model complexity.
Measures of model complexity
I think it would depend on the actual model fitting procedure. For a generally applicable measure, you might consider Generalized Degrees of Freedom described in Ye 1998 -- essentially the sensitivit
Measures of model complexity I think it would depend on the actual model fitting procedure. For a generally applicable measure, you might consider Generalized Degrees of Freedom described in Ye 1998 -- essentially the sensitivity of change of model estimates to perturbation of observations -- which works quite well as a measure of model complexity.
Measures of model complexity I think it would depend on the actual model fitting procedure. For a generally applicable measure, you might consider Generalized Degrees of Freedom described in Ye 1998 -- essentially the sensitivit
11,631
Measures of model complexity
Minimum Description Length (MDL) and Minimum Message Length (MML) are certainly worth checking out. As far as MDL is concerned, a simple paper that illustrates the Normalized Maximum Likelihood (NML) procedure as well as the asymptotic approximation is: S. de Rooij & P. Grünwald. An empirical study of minimum description length model selection with infinite parametric complexity. Journal of Mathematical Psychology, 2006, 50, 180-192 Here, they look at the model complexity of a Geometric vs. a Poisson distribution. An excellent (free) tutorial on MDL can be found here. Alternatively, a paper on the complexity of the exponential distribution examined with both MML and MDL can be found here. Unfortunately, there is no up-to-date tutorial on MML, but the book is an excellent reference, and highly recommended.
Measures of model complexity
Minimum Description Length (MDL) and Minimum Message Length (MML) are certainly worth checking out. As far as MDL is concerned, a simple paper that illustrates the Normalized Maximum Likelihood (NML)
Measures of model complexity Minimum Description Length (MDL) and Minimum Message Length (MML) are certainly worth checking out. As far as MDL is concerned, a simple paper that illustrates the Normalized Maximum Likelihood (NML) procedure as well as the asymptotic approximation is: S. de Rooij & P. Grünwald. An empirical study of minimum description length model selection with infinite parametric complexity. Journal of Mathematical Psychology, 2006, 50, 180-192 Here, they look at the model complexity of a Geometric vs. a Poisson distribution. An excellent (free) tutorial on MDL can be found here. Alternatively, a paper on the complexity of the exponential distribution examined with both MML and MDL can be found here. Unfortunately, there is no up-to-date tutorial on MML, but the book is an excellent reference, and highly recommended.
Measures of model complexity Minimum Description Length (MDL) and Minimum Message Length (MML) are certainly worth checking out. As far as MDL is concerned, a simple paper that illustrates the Normalized Maximum Likelihood (NML)
11,632
Measures of model complexity
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. Minimum Description Length may be an avenue worth pursuing.
Measures of model complexity
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
Measures of model complexity Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. Minimum Description Length may be an avenue worth pursuing.
Measures of model complexity Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
11,633
Measures of model complexity
By "model complexity" one usually means the richness of the model space. Note that this definition does not depend on data. For linear models, the richness of the model space is trivially measured with the diminution of the space. This is what some authors call the "degrees of freedom" (although historically, the degrees-of-freedom was reserved for the difference between the model space and the sample space). For non linear models, quantifying the richness of the space is less trivial. The Generalized Degrees of Freedom (see ars's reply) is such a measure. It is indeed very general and can be used for any "weird" model space such as trees, KNN, and the likes. The VC dimension is another measure. As mentioned above, this definition of "complexity" is data independent. So two models with the same number of parameters will typically have the same "complexity".
Measures of model complexity
By "model complexity" one usually means the richness of the model space. Note that this definition does not depend on data. For linear models, the richness of the model space is trivially measured wit
Measures of model complexity By "model complexity" one usually means the richness of the model space. Note that this definition does not depend on data. For linear models, the richness of the model space is trivially measured with the diminution of the space. This is what some authors call the "degrees of freedom" (although historically, the degrees-of-freedom was reserved for the difference between the model space and the sample space). For non linear models, quantifying the richness of the space is less trivial. The Generalized Degrees of Freedom (see ars's reply) is such a measure. It is indeed very general and can be used for any "weird" model space such as trees, KNN, and the likes. The VC dimension is another measure. As mentioned above, this definition of "complexity" is data independent. So two models with the same number of parameters will typically have the same "complexity".
Measures of model complexity By "model complexity" one usually means the richness of the model space. Note that this definition does not depend on data. For linear models, the richness of the model space is trivially measured wit
11,634
Measures of model complexity
From Yaroslav's comments to Henrik's answer: but cross-validation seems to just postpone the task of assessing complexity. If you use data to pick your parameters and your model as in cross-validation, the relevant question becomes how estimate the amount of data needed for this "meta"-fitter to perform well I wonder whether this is not in itself informative. You perform several $k$-fold CV with varying $k$ (say along a grid) and look which model performs better as $k$ increases. More specifically: I wonder whether any differentiation among the two model in there $CV(k)$ performance as a function of $k$ can be taken as evidence that this model (the one whose relative performance decreases less when $k$ increases) would be the less complex one. You could even give a 'significance' flavor to this since the result of the procedure is directly in terms (units) of difference in out of sample forecasting error.
Measures of model complexity
From Yaroslav's comments to Henrik's answer: but cross-validation seems to just postpone the task of assessing complexity. If you use data to pick your parameters and your model as in cross-validation
Measures of model complexity From Yaroslav's comments to Henrik's answer: but cross-validation seems to just postpone the task of assessing complexity. If you use data to pick your parameters and your model as in cross-validation, the relevant question becomes how estimate the amount of data needed for this "meta"-fitter to perform well I wonder whether this is not in itself informative. You perform several $k$-fold CV with varying $k$ (say along a grid) and look which model performs better as $k$ increases. More specifically: I wonder whether any differentiation among the two model in there $CV(k)$ performance as a function of $k$ can be taken as evidence that this model (the one whose relative performance decreases less when $k$ increases) would be the less complex one. You could even give a 'significance' flavor to this since the result of the procedure is directly in terms (units) of difference in out of sample forecasting error.
Measures of model complexity From Yaroslav's comments to Henrik's answer: but cross-validation seems to just postpone the task of assessing complexity. If you use data to pick your parameters and your model as in cross-validation
11,635
Measures of model complexity
What about the information criterion for model comparison? See e.g. http://en.wikipedia.org/wiki/Akaike_information_criterion Model complexity is here the number of parameters of the model.
Measures of model complexity
What about the information criterion for model comparison? See e.g. http://en.wikipedia.org/wiki/Akaike_information_criterion Model complexity is here the number of parameters of the model.
Measures of model complexity What about the information criterion for model comparison? See e.g. http://en.wikipedia.org/wiki/Akaike_information_criterion Model complexity is here the number of parameters of the model.
Measures of model complexity What about the information criterion for model comparison? See e.g. http://en.wikipedia.org/wiki/Akaike_information_criterion Model complexity is here the number of parameters of the model.
11,636
Is this an appropriate method to test for seasonal effects in suicide count data?
What about a Poisson regression? I created a data frame containing your data, plus an index t for the time (in months) and a variable monthdays for the number of days in each month. T <- read.table("suicide.txt", header=TRUE) U <- data.frame( year = as.numeric(rep(rownames(T),each=12)), month = rep(colnames(T),nrow(T)), t = seq(0, length = nrow(T)*ncol(T)), suicides = as.vector(t(T))) U$monthdays <- c(31,28,31,30,31,30,31,31,30,31,30,31) U$monthdays[ !(U$year %% 4) & U$month == "Feb" ] <- 29 So it looks like this: > head(U,14) year month t suicides monthdays 1 1995 Jan 0 62 31 2 1995 Feb 1 47 28 3 1995 Mar 2 55 31 4 1995 Apr 3 74 30 5 1995 May 4 71 31 6 1995 Jun 5 70 30 7 1995 Jul 6 67 31 8 1995 Aug 7 69 31 9 1995 Sep 8 61 30 10 1995 Oct 9 76 31 11 1995 Nov 10 68 30 12 1995 Dec 11 68 31 13 1996 Jan 12 64 31 14 1996 Feb 13 69 29 Now let’s compare a model with a time effect and a number of days effect with a model in which we add a month effect: > a0 <- glm( suicides ~ t + monthdays, family="poisson", data = U ) > a1 <- glm( suicides ~ t + monthdays + month, family="poisson", data = U ) Here is the summary of the "small" model: > summary(a0) Call: glm(formula = suicides ~ t + monthdays, family = "poisson", data = U) Deviance Residuals: Min 1Q Median 3Q Max -2.7163 -0.6865 -0.1161 0.6363 3.2104 Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) 2.8060135 0.3259116 8.610 < 2e-16 *** t 0.0013650 0.0001443 9.461 < 2e-16 *** monthdays 0.0418509 0.0106874 3.916 9.01e-05 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 (Dispersion parameter for poisson family taken to be 1) Null deviance: 302.67 on 203 degrees of freedom Residual deviance: 196.64 on 201 degrees of freedom AIC: 1437.2 Number of Fisher Scoring iterations: 4 You can see that the two variables have largely significant marginal effects. Now look at the larger model: > summary(a1) Call: glm(formula = suicides ~ t + monthdays + month, family = "poisson", data = U) Deviance Residuals: Min 1Q Median 3Q Max -2.56164 -0.72363 -0.05581 0.58897 3.09423 Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) 1.4559200 2.1586699 0.674 0.500 t 0.0013810 0.0001446 9.550 <2e-16 *** monthdays 0.0869293 0.0719304 1.209 0.227 monthAug -0.0845759 0.0832327 -1.016 0.310 monthDec -0.1094669 0.0833577 -1.313 0.189 monthFeb 0.0657800 0.1331944 0.494 0.621 monthJan -0.0372652 0.0830087 -0.449 0.653 monthJul -0.0125179 0.0828694 -0.151 0.880 monthJun 0.0452746 0.0414287 1.093 0.274 monthMar -0.0638177 0.0831378 -0.768 0.443 monthMay -0.0146418 0.0828840 -0.177 0.860 monthNov -0.0381897 0.0422365 -0.904 0.366 monthOct -0.0463416 0.0830329 -0.558 0.577 monthSep 0.0070567 0.0417829 0.169 0.866 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 (Dispersion parameter for poisson family taken to be 1) Null deviance: 302.67 on 203 degrees of freedom Residual deviance: 182.72 on 190 degrees of freedom AIC: 1445.3 Number of Fisher Scoring iterations: 4 Well, of course the monthdays effect vanishes; it can be estimated only thanks to leap years!! Keeping it in the model (and taking into account leap years) allows to use the residual deviances to compare the two models. > anova(a0, a1, test="Chisq") Analysis of Deviance Table Model 1: suicides ~ t + monthdays Model 2: suicides ~ t + monthdays + month Resid. Df Resid. Dev Df Deviance Pr(>Chi) 1 201 196.65 2 190 182.72 11 13.928 0.237 So, no (significant) month effect? But what about a seasonal effect? We can try to capture seasonality using two variables $\cos\left( {2\pi t \over 12}\right)$ and $\sin\left( {2\pi t \over 12}\right)$: > a2 <- glm( suicides ~ t + monthdays + cos(2*pi*t/12) + sin(2*pi*t/12), family="poisson", data = U ) > summary(a2) Call: glm(formula = suicides ~ t + monthdays + cos(2 * pi * t/12) + sin(2 * pi * t/12), family = "poisson", data = U) Deviance Residuals: Min 1Q Median 3Q Max -2.4782 -0.7095 -0.0544 0.6471 3.2236 Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) 2.8676170 0.3381954 8.479 < 2e-16 *** t 0.0013711 0.0001444 9.493 < 2e-16 *** monthdays 0.0397990 0.0110877 3.589 0.000331 *** cos(2 * pi * t/12) -0.0245589 0.0122658 -2.002 0.045261 * sin(2 * pi * t/12) 0.0172967 0.0121591 1.423 0.154874 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 (Dispersion parameter for poisson family taken to be 1) Null deviance: 302.67 on 203 degrees of freedom Residual deviance: 190.37 on 199 degrees of freedom AIC: 1434.9 Number of Fisher Scoring iterations: 4 Now compare it with the null model: > anova(a0, a2, test="Chisq") Analysis of Deviance Table Model 1: suicides ~ t + monthdays Model 2: suicides ~ t + monthdays + cos(2 * pi * t/12) + sin(2 * pi * t/12) Resid. Df Resid. Dev Df Deviance Pr(>Chi) 1 201 196.65 2 199 190.38 2 6.2698 0.0435 * --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 So, one can surely say that this suggests a seasonal effect...
Is this an appropriate method to test for seasonal effects in suicide count data?
What about a Poisson regression? I created a data frame containing your data, plus an index t for the time (in months) and a variable monthdays for the number of days in each month. T <- read.table("s
Is this an appropriate method to test for seasonal effects in suicide count data? What about a Poisson regression? I created a data frame containing your data, plus an index t for the time (in months) and a variable monthdays for the number of days in each month. T <- read.table("suicide.txt", header=TRUE) U <- data.frame( year = as.numeric(rep(rownames(T),each=12)), month = rep(colnames(T),nrow(T)), t = seq(0, length = nrow(T)*ncol(T)), suicides = as.vector(t(T))) U$monthdays <- c(31,28,31,30,31,30,31,31,30,31,30,31) U$monthdays[ !(U$year %% 4) & U$month == "Feb" ] <- 29 So it looks like this: > head(U,14) year month t suicides monthdays 1 1995 Jan 0 62 31 2 1995 Feb 1 47 28 3 1995 Mar 2 55 31 4 1995 Apr 3 74 30 5 1995 May 4 71 31 6 1995 Jun 5 70 30 7 1995 Jul 6 67 31 8 1995 Aug 7 69 31 9 1995 Sep 8 61 30 10 1995 Oct 9 76 31 11 1995 Nov 10 68 30 12 1995 Dec 11 68 31 13 1996 Jan 12 64 31 14 1996 Feb 13 69 29 Now let’s compare a model with a time effect and a number of days effect with a model in which we add a month effect: > a0 <- glm( suicides ~ t + monthdays, family="poisson", data = U ) > a1 <- glm( suicides ~ t + monthdays + month, family="poisson", data = U ) Here is the summary of the "small" model: > summary(a0) Call: glm(formula = suicides ~ t + monthdays, family = "poisson", data = U) Deviance Residuals: Min 1Q Median 3Q Max -2.7163 -0.6865 -0.1161 0.6363 3.2104 Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) 2.8060135 0.3259116 8.610 < 2e-16 *** t 0.0013650 0.0001443 9.461 < 2e-16 *** monthdays 0.0418509 0.0106874 3.916 9.01e-05 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 (Dispersion parameter for poisson family taken to be 1) Null deviance: 302.67 on 203 degrees of freedom Residual deviance: 196.64 on 201 degrees of freedom AIC: 1437.2 Number of Fisher Scoring iterations: 4 You can see that the two variables have largely significant marginal effects. Now look at the larger model: > summary(a1) Call: glm(formula = suicides ~ t + monthdays + month, family = "poisson", data = U) Deviance Residuals: Min 1Q Median 3Q Max -2.56164 -0.72363 -0.05581 0.58897 3.09423 Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) 1.4559200 2.1586699 0.674 0.500 t 0.0013810 0.0001446 9.550 <2e-16 *** monthdays 0.0869293 0.0719304 1.209 0.227 monthAug -0.0845759 0.0832327 -1.016 0.310 monthDec -0.1094669 0.0833577 -1.313 0.189 monthFeb 0.0657800 0.1331944 0.494 0.621 monthJan -0.0372652 0.0830087 -0.449 0.653 monthJul -0.0125179 0.0828694 -0.151 0.880 monthJun 0.0452746 0.0414287 1.093 0.274 monthMar -0.0638177 0.0831378 -0.768 0.443 monthMay -0.0146418 0.0828840 -0.177 0.860 monthNov -0.0381897 0.0422365 -0.904 0.366 monthOct -0.0463416 0.0830329 -0.558 0.577 monthSep 0.0070567 0.0417829 0.169 0.866 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 (Dispersion parameter for poisson family taken to be 1) Null deviance: 302.67 on 203 degrees of freedom Residual deviance: 182.72 on 190 degrees of freedom AIC: 1445.3 Number of Fisher Scoring iterations: 4 Well, of course the monthdays effect vanishes; it can be estimated only thanks to leap years!! Keeping it in the model (and taking into account leap years) allows to use the residual deviances to compare the two models. > anova(a0, a1, test="Chisq") Analysis of Deviance Table Model 1: suicides ~ t + monthdays Model 2: suicides ~ t + monthdays + month Resid. Df Resid. Dev Df Deviance Pr(>Chi) 1 201 196.65 2 190 182.72 11 13.928 0.237 So, no (significant) month effect? But what about a seasonal effect? We can try to capture seasonality using two variables $\cos\left( {2\pi t \over 12}\right)$ and $\sin\left( {2\pi t \over 12}\right)$: > a2 <- glm( suicides ~ t + monthdays + cos(2*pi*t/12) + sin(2*pi*t/12), family="poisson", data = U ) > summary(a2) Call: glm(formula = suicides ~ t + monthdays + cos(2 * pi * t/12) + sin(2 * pi * t/12), family = "poisson", data = U) Deviance Residuals: Min 1Q Median 3Q Max -2.4782 -0.7095 -0.0544 0.6471 3.2236 Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) 2.8676170 0.3381954 8.479 < 2e-16 *** t 0.0013711 0.0001444 9.493 < 2e-16 *** monthdays 0.0397990 0.0110877 3.589 0.000331 *** cos(2 * pi * t/12) -0.0245589 0.0122658 -2.002 0.045261 * sin(2 * pi * t/12) 0.0172967 0.0121591 1.423 0.154874 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 (Dispersion parameter for poisson family taken to be 1) Null deviance: 302.67 on 203 degrees of freedom Residual deviance: 190.37 on 199 degrees of freedom AIC: 1434.9 Number of Fisher Scoring iterations: 4 Now compare it with the null model: > anova(a0, a2, test="Chisq") Analysis of Deviance Table Model 1: suicides ~ t + monthdays Model 2: suicides ~ t + monthdays + cos(2 * pi * t/12) + sin(2 * pi * t/12) Resid. Df Resid. Dev Df Deviance Pr(>Chi) 1 201 196.65 2 199 190.38 2 6.2698 0.0435 * --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 So, one can surely say that this suggests a seasonal effect...
Is this an appropriate method to test for seasonal effects in suicide count data? What about a Poisson regression? I created a data frame containing your data, plus an index t for the time (in months) and a variable monthdays for the number of days in each month. T <- read.table("s
11,637
Is this an appropriate method to test for seasonal effects in suicide count data?
A chi-square test is a good approach as a preliminary view to your question. The stl decomposition can be misleading as a tool to test for the presence of seasonality. This procedure manages to return a stable seasonal pattern even if a white noise (random signal with no structure) is passed as input. Try for example: plot(stl(ts(rnorm(144), frequency=12), s.window="periodic")) Looking at the orders chosen by an automatic ARIMA model selection procedure is also a bit risky since a seasonal ARIMA model does not always involve seasonality (for details see this discussion). In this case, the chosen model generates seasonal cycles and the comment by @RichardHardy is reasonable, however, a further insight is required in order to conclude that suicides are driven by a seasonal pattern. Below, I summarize some results based on the analysis of the monthly series that you posted. This is the seasonal component estimated upon the basic structural time series model: require(stsm) m <- stsm.model(model = "llm+seas", y = x) fit <- stsmFit(m, stsm.method = "maxlik.td.scoring") plot(tsSmooth(fit)$states[,2], ylab = "") mtext(text = "seasonal component", side = 3, adj = 0, font = 2) A similar component was extracted using the software TRAMO-SEATS with default options. We can see that the estimated seasonal pattern is not stable across time and, hence, does not support the hypothesis of a recurrent pattern in the number of suicides across months during the sample period. Running the software X-13ARIMA-SEATS with default options, the combined test for seasonality concluded that identifiable seasonality is not present. Edit (see this answer and my comment below for a definition of identifiable seasonality). Given the nature of your data, it would be worth complementing this analysis based on time series methods with a model for count data (e.g. Poisson model) and test for the significance of seasonality in that model. Adding the tag count-data to your question may result in more views and potential answers in this direction.
Is this an appropriate method to test for seasonal effects in suicide count data?
A chi-square test is a good approach as a preliminary view to your question. The stl decomposition can be misleading as a tool to test for the presence of seasonality. This procedure manages to return
Is this an appropriate method to test for seasonal effects in suicide count data? A chi-square test is a good approach as a preliminary view to your question. The stl decomposition can be misleading as a tool to test for the presence of seasonality. This procedure manages to return a stable seasonal pattern even if a white noise (random signal with no structure) is passed as input. Try for example: plot(stl(ts(rnorm(144), frequency=12), s.window="periodic")) Looking at the orders chosen by an automatic ARIMA model selection procedure is also a bit risky since a seasonal ARIMA model does not always involve seasonality (for details see this discussion). In this case, the chosen model generates seasonal cycles and the comment by @RichardHardy is reasonable, however, a further insight is required in order to conclude that suicides are driven by a seasonal pattern. Below, I summarize some results based on the analysis of the monthly series that you posted. This is the seasonal component estimated upon the basic structural time series model: require(stsm) m <- stsm.model(model = "llm+seas", y = x) fit <- stsmFit(m, stsm.method = "maxlik.td.scoring") plot(tsSmooth(fit)$states[,2], ylab = "") mtext(text = "seasonal component", side = 3, adj = 0, font = 2) A similar component was extracted using the software TRAMO-SEATS with default options. We can see that the estimated seasonal pattern is not stable across time and, hence, does not support the hypothesis of a recurrent pattern in the number of suicides across months during the sample period. Running the software X-13ARIMA-SEATS with default options, the combined test for seasonality concluded that identifiable seasonality is not present. Edit (see this answer and my comment below for a definition of identifiable seasonality). Given the nature of your data, it would be worth complementing this analysis based on time series methods with a model for count data (e.g. Poisson model) and test for the significance of seasonality in that model. Adding the tag count-data to your question may result in more views and potential answers in this direction.
Is this an appropriate method to test for seasonal effects in suicide count data? A chi-square test is a good approach as a preliminary view to your question. The stl decomposition can be misleading as a tool to test for the presence of seasonality. This procedure manages to return
11,638
Is this an appropriate method to test for seasonal effects in suicide count data?
As noted in my comment, this is a very interesting problem. Detecting seasonality is not a statistical exercise alone. A reasonable approach would be to consult theory and experts such as: Psychologist Psychiatrist Sociologist on this problem to understand "why" there would be seasonality to supplement data analysis. Coming to the data, I used an excellent decomposition method called unobserved components model (UCM) which is a form of state space method. See also this very accessible article by Koopman. My approach is similar to @Javlacalle. It not only provides a tool to decompose time series data but also objectively assesses the presence or absence of seasonality via significance testing. I'm not a big fan of significance testing on non-experimental data but I don't know of any other procedure that you would be able to test your hypothesis on presence/absence of seasonality on a time series data. Many ignore but a very important feature that one would want to understand is the type of seasonality: Stochastic - changes randomly and tough to predict Deterministic - does not change, perfectly predictable. You could use dummy or trigonometry (sin/cos etc.,) to model For a lengthy time series data such as yours, it is possible that seasonality might have changed over time. Again UCM is the only approach that I know that can detect these stochastic/deterministic seasonality. UCM can decompose your problem into following "components": Time Series Data = level + Slope + Seasonality + Cycle + Causal + Error(Noise). You could also test if level, slope, cycle is deterministic or stochastic. Please note that level + slope = trend. Below I present some analysis on your data using UCM. I used SAS to do the analysis. data input; format date mmddyy10.; date = intnx( 'month', '1jan1995'd, _n_-1 ); input deaths@@; datalines; 62 47 55 74 71 70 67 69 61 76 68 68 64 69 68 53 72 73 62 63 64 72 55 61 71 61 64 63 60 64 67 50 48 49 59 72 67 54 72 69 78 45 59 53 48 65 64 44 69 64 65 58 73 83 70 73 58 75 71 58 60 54 67 59 54 69 62 60 58 61 68 56 67 60 54 57 51 61 67 63 55 70 54 55 65 68 65 72 79 72 64 70 59 66 63 66 69 50 59 67 73 77 64 66 71 68 59 69 68 61 66 62 69 84 73 62 71 64 59 70 67 53 76 65 77 68 65 60 68 71 60 79 65 54 65 68 69 68 81 64 69 71 67 67 77 63 61 78 73 69 92 68 72 61 65 77 67 73 81 73 66 63 96 71 75 74 81 63 80 68 76 65 82 69 74 88 80 86 78 76 80 77 82 80 77 70 81 89 91 82 71 73 93 64 87 75 101 89 87 78 106 84 64 71 ; run; ods graphics on; proc ucm data = input plots=all; id date interval = month; model deaths ; irregular ; level checkbreak; season length = 12 type=trig var = 0 noest; * Note I have used trigonometry to model seasonality; run; ods graphics off; After several iterations considering different components and combinations, I ended with a parsimonious model of the following form: There is a stochastic level + deterministic seasonality + some outliers and the data does not have any other detectable features. Below is significance analysis of various components. Notice that I used trigonometry (that is sin/cos in the seasonality statement in PROC UCM) similar to @Elvis and @Nick Cox. You could also use dummy coding in UCM and when I tested both gave similar results. See this documentation for differences between the two ways to model seasonality in SAS. As shown above you have outliers: two pulses and one level shift in 2009 (Did economy/housing bubble play a role after 2009 ??) which could be explained by further deep dive analysis. A good feature of using Proc UCM is that it provides excellent graphical output. Below is seasonality and a combined trend and seasonality plot. Whatever is left over is noise. A more important diagnostic test if you want to use p values and significance testing is to check if your residuals are pattern-less and normally distributed which is satisfied in the above model using UCM and as shown below in the residual diagnostic plots like acf/pacf and others. Conclusion: Based on data analysis using UCM and significance testing the data appears to have seasonality and we see high number of deaths in summer months of May/June/July and lowest in winter months of December and February. Additional Considerations: Please also consider the practical significance of the magnitude of seasonal variation. To negate counterfactual arguments please consult domain experts to further complement and validate your hypothesis. I'm by no means saying that this is the only approach to solve this problem. The feature that I like about UCM is that it allows you to explicitly model all the time series features and is highly visual as well.
Is this an appropriate method to test for seasonal effects in suicide count data?
As noted in my comment, this is a very interesting problem. Detecting seasonality is not a statistical exercise alone. A reasonable approach would be to consult theory and experts such as: Psychologi
Is this an appropriate method to test for seasonal effects in suicide count data? As noted in my comment, this is a very interesting problem. Detecting seasonality is not a statistical exercise alone. A reasonable approach would be to consult theory and experts such as: Psychologist Psychiatrist Sociologist on this problem to understand "why" there would be seasonality to supplement data analysis. Coming to the data, I used an excellent decomposition method called unobserved components model (UCM) which is a form of state space method. See also this very accessible article by Koopman. My approach is similar to @Javlacalle. It not only provides a tool to decompose time series data but also objectively assesses the presence or absence of seasonality via significance testing. I'm not a big fan of significance testing on non-experimental data but I don't know of any other procedure that you would be able to test your hypothesis on presence/absence of seasonality on a time series data. Many ignore but a very important feature that one would want to understand is the type of seasonality: Stochastic - changes randomly and tough to predict Deterministic - does not change, perfectly predictable. You could use dummy or trigonometry (sin/cos etc.,) to model For a lengthy time series data such as yours, it is possible that seasonality might have changed over time. Again UCM is the only approach that I know that can detect these stochastic/deterministic seasonality. UCM can decompose your problem into following "components": Time Series Data = level + Slope + Seasonality + Cycle + Causal + Error(Noise). You could also test if level, slope, cycle is deterministic or stochastic. Please note that level + slope = trend. Below I present some analysis on your data using UCM. I used SAS to do the analysis. data input; format date mmddyy10.; date = intnx( 'month', '1jan1995'd, _n_-1 ); input deaths@@; datalines; 62 47 55 74 71 70 67 69 61 76 68 68 64 69 68 53 72 73 62 63 64 72 55 61 71 61 64 63 60 64 67 50 48 49 59 72 67 54 72 69 78 45 59 53 48 65 64 44 69 64 65 58 73 83 70 73 58 75 71 58 60 54 67 59 54 69 62 60 58 61 68 56 67 60 54 57 51 61 67 63 55 70 54 55 65 68 65 72 79 72 64 70 59 66 63 66 69 50 59 67 73 77 64 66 71 68 59 69 68 61 66 62 69 84 73 62 71 64 59 70 67 53 76 65 77 68 65 60 68 71 60 79 65 54 65 68 69 68 81 64 69 71 67 67 77 63 61 78 73 69 92 68 72 61 65 77 67 73 81 73 66 63 96 71 75 74 81 63 80 68 76 65 82 69 74 88 80 86 78 76 80 77 82 80 77 70 81 89 91 82 71 73 93 64 87 75 101 89 87 78 106 84 64 71 ; run; ods graphics on; proc ucm data = input plots=all; id date interval = month; model deaths ; irregular ; level checkbreak; season length = 12 type=trig var = 0 noest; * Note I have used trigonometry to model seasonality; run; ods graphics off; After several iterations considering different components and combinations, I ended with a parsimonious model of the following form: There is a stochastic level + deterministic seasonality + some outliers and the data does not have any other detectable features. Below is significance analysis of various components. Notice that I used trigonometry (that is sin/cos in the seasonality statement in PROC UCM) similar to @Elvis and @Nick Cox. You could also use dummy coding in UCM and when I tested both gave similar results. See this documentation for differences between the two ways to model seasonality in SAS. As shown above you have outliers: two pulses and one level shift in 2009 (Did economy/housing bubble play a role after 2009 ??) which could be explained by further deep dive analysis. A good feature of using Proc UCM is that it provides excellent graphical output. Below is seasonality and a combined trend and seasonality plot. Whatever is left over is noise. A more important diagnostic test if you want to use p values and significance testing is to check if your residuals are pattern-less and normally distributed which is satisfied in the above model using UCM and as shown below in the residual diagnostic plots like acf/pacf and others. Conclusion: Based on data analysis using UCM and significance testing the data appears to have seasonality and we see high number of deaths in summer months of May/June/July and lowest in winter months of December and February. Additional Considerations: Please also consider the practical significance of the magnitude of seasonal variation. To negate counterfactual arguments please consult domain experts to further complement and validate your hypothesis. I'm by no means saying that this is the only approach to solve this problem. The feature that I like about UCM is that it allows you to explicitly model all the time series features and is highly visual as well.
Is this an appropriate method to test for seasonal effects in suicide count data? As noted in my comment, this is a very interesting problem. Detecting seasonality is not a statistical exercise alone. A reasonable approach would be to consult theory and experts such as: Psychologi
11,639
Is this an appropriate method to test for seasonal effects in suicide count data?
For initial visual estimation, following graph can be used. Plotting the monthly data with loess curve and its 95% confidence interval, it appears that there is a mid-year rise peaking at June. Other factors may be causing the data to have wide distribution, hence the seasonal trend may be getting masked in this raw data loess plot. The data points have been jittered. Edit: Following plot shows loess curve and confidence interval for change in number of cases from the number in the previous month: This also shows that during the months in first half of the year, the number of cases keep rising, while they are falling in the second half of the year. This also suggest a peak in mid-year. However, the confidence intervals are wide and goes across 0, i.e. no change, throughout the year, indicating a lack of statistical significance. The difference of a month's number can be compared with average of previous 3 months' values: This shows a clear increase in numbers in May and a fall in October.
Is this an appropriate method to test for seasonal effects in suicide count data?
For initial visual estimation, following graph can be used. Plotting the monthly data with loess curve and its 95% confidence interval, it appears that there is a mid-year rise peaking at June. Other
Is this an appropriate method to test for seasonal effects in suicide count data? For initial visual estimation, following graph can be used. Plotting the monthly data with loess curve and its 95% confidence interval, it appears that there is a mid-year rise peaking at June. Other factors may be causing the data to have wide distribution, hence the seasonal trend may be getting masked in this raw data loess plot. The data points have been jittered. Edit: Following plot shows loess curve and confidence interval for change in number of cases from the number in the previous month: This also shows that during the months in first half of the year, the number of cases keep rising, while they are falling in the second half of the year. This also suggest a peak in mid-year. However, the confidence intervals are wide and goes across 0, i.e. no change, throughout the year, indicating a lack of statistical significance. The difference of a month's number can be compared with average of previous 3 months' values: This shows a clear increase in numbers in May and a fall in October.
Is this an appropriate method to test for seasonal effects in suicide count data? For initial visual estimation, following graph can be used. Plotting the monthly data with loess curve and its 95% confidence interval, it appears that there is a mid-year rise peaking at June. Other
11,640
Can a statistical test return a p-value of zero?
It will be the case that if you observed a sample that's impossible under the null (and if the statistic is able to detect that), you can get a p-value of exactly zero. That can happen in real world problems. For example, if you do an Anderson-Darling test of goodness of fit of data to a standard uniform with some data outside that range - e.g. where your sample is (0.430, 0.712, 0.885, 1.08) - the p-value is actually zero (but a Kolmogorov-Smirnov test by contrast would give a p-value that isn't zero, even though we can rule it out by inspection). Likelihood ratio tests will likewise give a p-value of zero if the sample is not possible under the null. As whuber mentioned in comments, hypothesis tests don't evaluate the probability of the null hypothesis (or the alternative). We don't (can't, really) talk about the probability of the null being true in that framework (we can do it explicitly in a Bayesian framework, though -- but then we cast the decision problem somewhat differently from the outset).
Can a statistical test return a p-value of zero?
It will be the case that if you observed a sample that's impossible under the null (and if the statistic is able to detect that), you can get a p-value of exactly zero. That can happen in real world p
Can a statistical test return a p-value of zero? It will be the case that if you observed a sample that's impossible under the null (and if the statistic is able to detect that), you can get a p-value of exactly zero. That can happen in real world problems. For example, if you do an Anderson-Darling test of goodness of fit of data to a standard uniform with some data outside that range - e.g. where your sample is (0.430, 0.712, 0.885, 1.08) - the p-value is actually zero (but a Kolmogorov-Smirnov test by contrast would give a p-value that isn't zero, even though we can rule it out by inspection). Likelihood ratio tests will likewise give a p-value of zero if the sample is not possible under the null. As whuber mentioned in comments, hypothesis tests don't evaluate the probability of the null hypothesis (or the alternative). We don't (can't, really) talk about the probability of the null being true in that framework (we can do it explicitly in a Bayesian framework, though -- but then we cast the decision problem somewhat differently from the outset).
Can a statistical test return a p-value of zero? It will be the case that if you observed a sample that's impossible under the null (and if the statistic is able to detect that), you can get a p-value of exactly zero. That can happen in real world p
11,641
Can a statistical test return a p-value of zero?
In R, the binomial test gives a P value of 'TRUE' presumably 0, if all trials succeed and hypothesis is 100% success, even if number of trials is just 1: > binom.test(100,100,1) Exact binomial test data: 100 and 100 number of successes = 100, number of trials = 100, p-value = TRUE <<<< NOTE alternative hypothesis: true probability of success is not equal to 1 95 percent confidence interval: 0.9637833 1.0000000 sample estimates: probability of success 1 > > > binom.test(1,1,1) Exact binomial test data: 1 and 1 number of successes = 1, number of trials = 1, p-value = TRUE <<<< NOTE alternative hypothesis: true probability of success is not equal to 1 95 percent confidence interval: 0.025 1.000 sample estimates: probability of success 1
Can a statistical test return a p-value of zero?
In R, the binomial test gives a P value of 'TRUE' presumably 0, if all trials succeed and hypothesis is 100% success, even if number of trials is just 1: > binom.test(100,100,1) Exact binomia
Can a statistical test return a p-value of zero? In R, the binomial test gives a P value of 'TRUE' presumably 0, if all trials succeed and hypothesis is 100% success, even if number of trials is just 1: > binom.test(100,100,1) Exact binomial test data: 100 and 100 number of successes = 100, number of trials = 100, p-value = TRUE <<<< NOTE alternative hypothesis: true probability of success is not equal to 1 95 percent confidence interval: 0.9637833 1.0000000 sample estimates: probability of success 1 > > > binom.test(1,1,1) Exact binomial test data: 1 and 1 number of successes = 1, number of trials = 1, p-value = TRUE <<<< NOTE alternative hypothesis: true probability of success is not equal to 1 95 percent confidence interval: 0.025 1.000 sample estimates: probability of success 1
Can a statistical test return a p-value of zero? In R, the binomial test gives a P value of 'TRUE' presumably 0, if all trials succeed and hypothesis is 100% success, even if number of trials is just 1: > binom.test(100,100,1) Exact binomia
11,642
How to choose prior in Bayesian parameter estimation
As stated in comment, the prior distribution represents prior beliefs about the distribution of the parameters. When prior beliefs are actually available, you can: convert them in terms of moments (e.g. mean and variance) to fit a common distribution to these moments (e.g. Gaussian if your parameter lies to the real line, Gamma if it lies to $R^+$). use your intuitive understanding of these beliefs to propose a given prior distribution and check if it really fits your purpose and that it is not to sensitive to arbitrary choices (performing a robustness or sensibility analysis) When no explicit prior beliefs are available, you can: derive (or simply use if already available, a great ressource is http://www.stats.org.uk/priors/noninformative/YangBerger1998.pdf) a Jeffreys (e.g. uniform for a location parameter) or a reference prior (especially in case of multivariate parameters). sometimes such choices are impossible or quite difficult to derive and in this case, you can try to choose among one of the many "generic" weakly informative prior (e.g. uniform shrinkage distribution for scale parameters of hierarchical model or $g$-prior for gaussian regression). Having said that, there is no restriction to use a joint or an independent prior ($p(a,b)$ Vs $p(a) \cdot p(b)$). As a complement, I would say that in my humble opinion, there are three major things to take care when choosing a prior: take care that your posterior is integrable almost everywhere (or proper), which is always true if you use an integrable prior (see Does the Bayesian posterior need to be a proper distribution? for more details), limit the support of your prior only if you are highly confident on the support bounds (so avoid to do it). and last but not least, make sure (most of the time experimentally) that your choice of prior means what you want to express. In my opinion, this task is sometimes the most critical. Never forget, that when doing inference a prior means nothing by itself, you have to consider the posterior (which is the combination of prior and likelihood).
How to choose prior in Bayesian parameter estimation
As stated in comment, the prior distribution represents prior beliefs about the distribution of the parameters. When prior beliefs are actually available, you can: convert them in terms of moments (e
How to choose prior in Bayesian parameter estimation As stated in comment, the prior distribution represents prior beliefs about the distribution of the parameters. When prior beliefs are actually available, you can: convert them in terms of moments (e.g. mean and variance) to fit a common distribution to these moments (e.g. Gaussian if your parameter lies to the real line, Gamma if it lies to $R^+$). use your intuitive understanding of these beliefs to propose a given prior distribution and check if it really fits your purpose and that it is not to sensitive to arbitrary choices (performing a robustness or sensibility analysis) When no explicit prior beliefs are available, you can: derive (or simply use if already available, a great ressource is http://www.stats.org.uk/priors/noninformative/YangBerger1998.pdf) a Jeffreys (e.g. uniform for a location parameter) or a reference prior (especially in case of multivariate parameters). sometimes such choices are impossible or quite difficult to derive and in this case, you can try to choose among one of the many "generic" weakly informative prior (e.g. uniform shrinkage distribution for scale parameters of hierarchical model or $g$-prior for gaussian regression). Having said that, there is no restriction to use a joint or an independent prior ($p(a,b)$ Vs $p(a) \cdot p(b)$). As a complement, I would say that in my humble opinion, there are three major things to take care when choosing a prior: take care that your posterior is integrable almost everywhere (or proper), which is always true if you use an integrable prior (see Does the Bayesian posterior need to be a proper distribution? for more details), limit the support of your prior only if you are highly confident on the support bounds (so avoid to do it). and last but not least, make sure (most of the time experimentally) that your choice of prior means what you want to express. In my opinion, this task is sometimes the most critical. Never forget, that when doing inference a prior means nothing by itself, you have to consider the posterior (which is the combination of prior and likelihood).
How to choose prior in Bayesian parameter estimation As stated in comment, the prior distribution represents prior beliefs about the distribution of the parameters. When prior beliefs are actually available, you can: convert them in terms of moments (e
11,643
How to choose prior in Bayesian parameter estimation
There is also empirical Bayes. The idea is to tune the prior to the data: $$\text{max}_{p(z)} \int p(\mathcal{D}|z)p(z) dz$$ While this might seem awkward at first, there are actually relations to minimum description length. This is also the typical way to estimate the kernel parameters of Gaussian processes.
How to choose prior in Bayesian parameter estimation
There is also empirical Bayes. The idea is to tune the prior to the data: $$\text{max}_{p(z)} \int p(\mathcal{D}|z)p(z) dz$$ While this might seem awkward at first, there are actually relations to mi
How to choose prior in Bayesian parameter estimation There is also empirical Bayes. The idea is to tune the prior to the data: $$\text{max}_{p(z)} \int p(\mathcal{D}|z)p(z) dz$$ While this might seem awkward at first, there are actually relations to minimum description length. This is also the typical way to estimate the kernel parameters of Gaussian processes.
How to choose prior in Bayesian parameter estimation There is also empirical Bayes. The idea is to tune the prior to the data: $$\text{max}_{p(z)} \int p(\mathcal{D}|z)p(z) dz$$ While this might seem awkward at first, there are actually relations to mi
11,644
How to choose prior in Bayesian parameter estimation
To answer the two questions above directly: You have other choices to choose non-conjugate priors other than conjugate priors. The problem is that if you choose non-conjugate priors, you cannot make exact Bayesian inference (simply put, you cannot derive a close-form posterior). Rather, you need to make approximate inference or use sampling methods such as Gibbs sampling, Rejection sampling, MCMC, etc. to derive you posterior. The problem with sampling methods is that intuitively, it's like drawing a picture of elephant in darkness by repetitively touching it----you may be biased and incomplete. The reason people choose non-conjugate prior is that for certain likelihood, conjugate prior option is pretty limited, or to say, most are non-conjugate. Yes, you definitely can. If α and β are independent, which is the idealistic condition, you can derive their joint distribution by p(α)p(β). If they are not independent, you may need to figure out the conditional probability and do integral to derive joint distribution.
How to choose prior in Bayesian parameter estimation
To answer the two questions above directly: You have other choices to choose non-conjugate priors other than conjugate priors. The problem is that if you choose non-conjugate priors, you cannot make
How to choose prior in Bayesian parameter estimation To answer the two questions above directly: You have other choices to choose non-conjugate priors other than conjugate priors. The problem is that if you choose non-conjugate priors, you cannot make exact Bayesian inference (simply put, you cannot derive a close-form posterior). Rather, you need to make approximate inference or use sampling methods such as Gibbs sampling, Rejection sampling, MCMC, etc. to derive you posterior. The problem with sampling methods is that intuitively, it's like drawing a picture of elephant in darkness by repetitively touching it----you may be biased and incomplete. The reason people choose non-conjugate prior is that for certain likelihood, conjugate prior option is pretty limited, or to say, most are non-conjugate. Yes, you definitely can. If α and β are independent, which is the idealistic condition, you can derive their joint distribution by p(α)p(β). If they are not independent, you may need to figure out the conditional probability and do integral to derive joint distribution.
How to choose prior in Bayesian parameter estimation To answer the two questions above directly: You have other choices to choose non-conjugate priors other than conjugate priors. The problem is that if you choose non-conjugate priors, you cannot make
11,645
What is the difference between lm() and rlm()?
It (rlm) is for robust linear models. It is describe in Venables & Ripley. However, details of the robust calculations would not fit in a "short answer": you need to look into several papers by Ripley, Tukey, and others. It a form of robust regression that uses M-estimators. Check out this paper by Ripley for more information: http://www.stats.ox.ac.uk/pub/StatMeth/Robust.pdf
What is the difference between lm() and rlm()?
It (rlm) is for robust linear models. It is describe in Venables & Ripley. However, details of the robust calculations would not fit in a "short answer": you need to look into several papers by Ripl
What is the difference between lm() and rlm()? It (rlm) is for robust linear models. It is describe in Venables & Ripley. However, details of the robust calculations would not fit in a "short answer": you need to look into several papers by Ripley, Tukey, and others. It a form of robust regression that uses M-estimators. Check out this paper by Ripley for more information: http://www.stats.ox.ac.uk/pub/StatMeth/Robust.pdf
What is the difference between lm() and rlm()? It (rlm) is for robust linear models. It is describe in Venables & Ripley. However, details of the robust calculations would not fit in a "short answer": you need to look into several papers by Ripl
11,646
What is the difference between lm() and rlm()?
lm function uses Ordinary Least Squares(OLS) method for reducing the residuals. whereas rlm function uses M-estimators. OLS is very sensitive to outliers, M-estimation method is not.
What is the difference between lm() and rlm()?
lm function uses Ordinary Least Squares(OLS) method for reducing the residuals. whereas rlm function uses M-estimators. OLS is very sensitive to outliers, M-estimation method is not.
What is the difference between lm() and rlm()? lm function uses Ordinary Least Squares(OLS) method for reducing the residuals. whereas rlm function uses M-estimators. OLS is very sensitive to outliers, M-estimation method is not.
What is the difference between lm() and rlm()? lm function uses Ordinary Least Squares(OLS) method for reducing the residuals. whereas rlm function uses M-estimators. OLS is very sensitive to outliers, M-estimation method is not.
11,647
What is the difference between lm() and rlm()?
Short answer: In rlm(), points are not treated equally. The weight of each point would be adjusted in an iterative process. rlm() is less sensitive to outliers, as outliers will get reduced weight. If you want a short answer for the math, I suggest an article provided by Johns Hopkins Bloomberg School of Public Health
What is the difference between lm() and rlm()?
Short answer: In rlm(), points are not treated equally. The weight of each point would be adjusted in an iterative process. rlm() is less sensitive to outliers, as outliers will get reduced weight.
What is the difference between lm() and rlm()? Short answer: In rlm(), points are not treated equally. The weight of each point would be adjusted in an iterative process. rlm() is less sensitive to outliers, as outliers will get reduced weight. If you want a short answer for the math, I suggest an article provided by Johns Hopkins Bloomberg School of Public Health
What is the difference between lm() and rlm()? Short answer: In rlm(), points are not treated equally. The weight of each point would be adjusted in an iterative process. rlm() is less sensitive to outliers, as outliers will get reduced weight.
11,648
What's the effect of scaling a loss function in deep learning?
Short answer: It depends on the optimizer and the regularization term: Without regularization, using SGD optimizer: scaling loss by $\alpha$ is equivalent to scaling SGD's learning rate by $\alpha$. Without regularization, using Nadam: scaling loss by $\alpha$ has no effect. With regularization, using either SGD or Nadam optimizer: changing the scale of prediction loss will affect the trade-off between prediction loss and regularization. Full answer: No regularization + SGD: Assuming your total loss consists of a prediction loss (e.g. mean-squared error) and no regularization loss (such as L2 weight decay), then scaling the output value of the loss function by $\alpha$ would be equivalent to scaling the learning rate ($\eta$) by $\alpha$ when using SGD: $$L_{\text{new}} = \alpha L_{\text{old}}\\ \Rightarrow \nabla_{W_{t}}L_{\text{new}} = \alpha\nabla_{W_{t}}L_{\text{old}}\\ W_{t+1} = W_{t} - \eta \nabla_{W_{t}}L_{\text{new}}\\ = W_{t} - \eta \alpha\nabla_{W_{t}}L_{\text{old}}\\ = W_{t} - \eta'\nabla_{W_{t}}L_{\text{old}} \quad \text{where } \eta'=\eta\alpha$$ No regularization + Nadam: Using Nadam, assuming you do not have a regularization term, I do not believe there is going to be a difference in the training procedure if you just multiply the loss output by $\alpha$ all the way through training. In this case, in the update rule, $\hat{m_t}$ will be multiplied by $\alpha$ and $\hat{n_t}$ will be multiplied by $\alpha^2$, causing the scales to cancel each other out: $$ W_{t+1} = W_{t} - \frac{\eta} {\sqrt{\hat{n_t}+\epsilon}}\hat{m_t} $$ With regularization: This is most likely the case you are facing. If you have an explicit regularization term such as L2 weight decay in your loss, then scaling the output of your prediction loss changes the trade-off between your prediction loss and the regularization loss: $$L_\text{old} = \text{MSE} + \lambda*\text{weight_decay}\\ L_\text{new} = \alpha\text{MSE} + \lambda*\text{weight_decay}\\ = \alpha\left(\text{MSE} + \frac{\lambda}{\alpha}*\text{weight_decay}\right)$$ Using SGD, this would be equivalent to using $\alpha\eta$ as your new learning rate instead of $\eta$, and using $\frac{\lambda}{\alpha}$ as your new L2 regularization scale. Using Nadam, the $\alpha$ scale in the back would have no effect, and in the end you just end up with $\frac{\lambda}{\alpha}$ as your new L2 regularization scale.
What's the effect of scaling a loss function in deep learning?
Short answer: It depends on the optimizer and the regularization term: Without regularization, using SGD optimizer: scaling loss by $\alpha$ is equivalent to scaling SGD's learning rate by $\alpha$.
What's the effect of scaling a loss function in deep learning? Short answer: It depends on the optimizer and the regularization term: Without regularization, using SGD optimizer: scaling loss by $\alpha$ is equivalent to scaling SGD's learning rate by $\alpha$. Without regularization, using Nadam: scaling loss by $\alpha$ has no effect. With regularization, using either SGD or Nadam optimizer: changing the scale of prediction loss will affect the trade-off between prediction loss and regularization. Full answer: No regularization + SGD: Assuming your total loss consists of a prediction loss (e.g. mean-squared error) and no regularization loss (such as L2 weight decay), then scaling the output value of the loss function by $\alpha$ would be equivalent to scaling the learning rate ($\eta$) by $\alpha$ when using SGD: $$L_{\text{new}} = \alpha L_{\text{old}}\\ \Rightarrow \nabla_{W_{t}}L_{\text{new}} = \alpha\nabla_{W_{t}}L_{\text{old}}\\ W_{t+1} = W_{t} - \eta \nabla_{W_{t}}L_{\text{new}}\\ = W_{t} - \eta \alpha\nabla_{W_{t}}L_{\text{old}}\\ = W_{t} - \eta'\nabla_{W_{t}}L_{\text{old}} \quad \text{where } \eta'=\eta\alpha$$ No regularization + Nadam: Using Nadam, assuming you do not have a regularization term, I do not believe there is going to be a difference in the training procedure if you just multiply the loss output by $\alpha$ all the way through training. In this case, in the update rule, $\hat{m_t}$ will be multiplied by $\alpha$ and $\hat{n_t}$ will be multiplied by $\alpha^2$, causing the scales to cancel each other out: $$ W_{t+1} = W_{t} - \frac{\eta} {\sqrt{\hat{n_t}+\epsilon}}\hat{m_t} $$ With regularization: This is most likely the case you are facing. If you have an explicit regularization term such as L2 weight decay in your loss, then scaling the output of your prediction loss changes the trade-off between your prediction loss and the regularization loss: $$L_\text{old} = \text{MSE} + \lambda*\text{weight_decay}\\ L_\text{new} = \alpha\text{MSE} + \lambda*\text{weight_decay}\\ = \alpha\left(\text{MSE} + \frac{\lambda}{\alpha}*\text{weight_decay}\right)$$ Using SGD, this would be equivalent to using $\alpha\eta$ as your new learning rate instead of $\eta$, and using $\frac{\lambda}{\alpha}$ as your new L2 regularization scale. Using Nadam, the $\alpha$ scale in the back would have no effect, and in the end you just end up with $\frac{\lambda}{\alpha}$ as your new L2 regularization scale.
What's the effect of scaling a loss function in deep learning? Short answer: It depends on the optimizer and the regularization term: Without regularization, using SGD optimizer: scaling loss by $\alpha$ is equivalent to scaling SGD's learning rate by $\alpha$.
11,649
Are deep learning models parametric? Or non-parametric?
Deep learning models are generally parametric - in fact they have a huge number of parameters, one for each weight that is tuned during training. As the number of weights generally stays constant, they technically have fixed degrees of freedom. However, as there are generally so many parameters they may be seen to emulate non-parametric. Gaussian processes (for example) use each observation as a new weight and as the number of points goes to infinity so too do the number of weights (not to be confused with hyper parameters). I say generally because there are so many different flavours of each model. For example low rank GPs have a bounded number of parameters which are inferred by the data and I'm sure someone has been making some type of non-parametric dnn at some research group!
Are deep learning models parametric? Or non-parametric?
Deep learning models are generally parametric - in fact they have a huge number of parameters, one for each weight that is tuned during training. As the number of weights generally stays constant, th
Are deep learning models parametric? Or non-parametric? Deep learning models are generally parametric - in fact they have a huge number of parameters, one for each weight that is tuned during training. As the number of weights generally stays constant, they technically have fixed degrees of freedom. However, as there are generally so many parameters they may be seen to emulate non-parametric. Gaussian processes (for example) use each observation as a new weight and as the number of points goes to infinity so too do the number of weights (not to be confused with hyper parameters). I say generally because there are so many different flavours of each model. For example low rank GPs have a bounded number of parameters which are inferred by the data and I'm sure someone has been making some type of non-parametric dnn at some research group!
Are deep learning models parametric? Or non-parametric? Deep learning models are generally parametric - in fact they have a huge number of parameters, one for each weight that is tuned during training. As the number of weights generally stays constant, th
11,650
Are deep learning models parametric? Or non-parametric?
A standard deep neural network (DNN) is, technically speaking, parametric since it has a fixed number of parameters. However, most DNNs have so many parameters that they could be interpreted as nonparametric; it has been proven that in the limit of infinite width, a deep neural network can be seen as a Gaussian process (GP), which is a nonparametric model [Lee et al., 2018]. Nevertheless, let's strictly interpret DNNs as parametric for the rest of this answer. Some examples of parametric deep learning models are: Deep autoregressive network (DARN) Sigmoid belief network (SBN) Recurrent neural network (RNN), Pixel CNN/RNN Variational autoencoder (VAE), other deep latent Gaussian models e.g. DRAW Some examples of nonparametric deep learning models are: Deep Gaussian process (GPs) Recurrent GP State space GP Hierarchical Dirichlet process Cascaded Indian Buffet process Image from Shakir Mohamed's tutorial on deep generative models. References: "Deep Neural Networks as Gaussian Processes" (Lee et al., 2018)
Are deep learning models parametric? Or non-parametric?
A standard deep neural network (DNN) is, technically speaking, parametric since it has a fixed number of parameters. However, most DNNs have so many parameters that they could be interpreted as nonpar
Are deep learning models parametric? Or non-parametric? A standard deep neural network (DNN) is, technically speaking, parametric since it has a fixed number of parameters. However, most DNNs have so many parameters that they could be interpreted as nonparametric; it has been proven that in the limit of infinite width, a deep neural network can be seen as a Gaussian process (GP), which is a nonparametric model [Lee et al., 2018]. Nevertheless, let's strictly interpret DNNs as parametric for the rest of this answer. Some examples of parametric deep learning models are: Deep autoregressive network (DARN) Sigmoid belief network (SBN) Recurrent neural network (RNN), Pixel CNN/RNN Variational autoencoder (VAE), other deep latent Gaussian models e.g. DRAW Some examples of nonparametric deep learning models are: Deep Gaussian process (GPs) Recurrent GP State space GP Hierarchical Dirichlet process Cascaded Indian Buffet process Image from Shakir Mohamed's tutorial on deep generative models. References: "Deep Neural Networks as Gaussian Processes" (Lee et al., 2018)
Are deep learning models parametric? Or non-parametric? A standard deep neural network (DNN) is, technically speaking, parametric since it has a fixed number of parameters. However, most DNNs have so many parameters that they could be interpreted as nonpar
11,651
Are deep learning models parametric? Or non-parametric?
Deep learning models should not be considered parametric. Parametric models are defined as models based off an a priori assumption about the distributions that generate the data. Deep nets do not make assumptions about the data generating process, rather they use large amounts of data to learn a function that maps inputs to outputs. Deep learning is non-parametric by any reasonable definition.
Are deep learning models parametric? Or non-parametric?
Deep learning models should not be considered parametric. Parametric models are defined as models based off an a priori assumption about the distributions that generate the data. Deep nets do not make
Are deep learning models parametric? Or non-parametric? Deep learning models should not be considered parametric. Parametric models are defined as models based off an a priori assumption about the distributions that generate the data. Deep nets do not make assumptions about the data generating process, rather they use large amounts of data to learn a function that maps inputs to outputs. Deep learning is non-parametric by any reasonable definition.
Are deep learning models parametric? Or non-parametric? Deep learning models should not be considered parametric. Parametric models are defined as models based off an a priori assumption about the distributions that generate the data. Deep nets do not make
11,652
Are deep learning models parametric? Or non-parametric?
Deutsch and Journel (1997, pp. 16-17) opined on the misleading nature of the term "non-parametric". They suggested that ≪...the terminology "parameter-rich" model should be retained for indicator based models instead of the traditional but misleading qualifier "non-parametric".≫ "Parameter rich" may be an accurate description, but "rich" has an emotional loading that lends a positive view which may not always be warranted (!). Some professors may yet persist who refer collectively to neural nets, random forests, and the like as all being "non-parametric". The increased opacity and piecewise nature of neural nets (especially with the spread of ReLU activation functions) makes them non-parameteric-esque.
Are deep learning models parametric? Or non-parametric?
Deutsch and Journel (1997, pp. 16-17) opined on the misleading nature of the term "non-parametric". They suggested that ≪...the terminology "parameter-rich" model should be retained for indicator bas
Are deep learning models parametric? Or non-parametric? Deutsch and Journel (1997, pp. 16-17) opined on the misleading nature of the term "non-parametric". They suggested that ≪...the terminology "parameter-rich" model should be retained for indicator based models instead of the traditional but misleading qualifier "non-parametric".≫ "Parameter rich" may be an accurate description, but "rich" has an emotional loading that lends a positive view which may not always be warranted (!). Some professors may yet persist who refer collectively to neural nets, random forests, and the like as all being "non-parametric". The increased opacity and piecewise nature of neural nets (especially with the spread of ReLU activation functions) makes them non-parameteric-esque.
Are deep learning models parametric? Or non-parametric? Deutsch and Journel (1997, pp. 16-17) opined on the misleading nature of the term "non-parametric". They suggested that ≪...the terminology "parameter-rich" model should be retained for indicator bas
11,653
Now that I've rejected the null hypothesis what's next?
You can generally continue to improve your estimate of whatever parameter you might be testing with more data. Stopping data collection once a test achieves some semi-arbitrary degree of significance is a good way to make bad inferences. That analysts may misunderstand a significant result as a sign that the job is done is one of many unintended consequences of the Neyman–Pearson framework, according to which people interpret p values as cause to either reject or fail to reject a null without reservation depending on which side of the critical threshold they fall on. Without considering Bayesian alternatives to the frequentist paradigm (hopefully someone else will), confidence intervals continue to be more informative well beyond the point at which a basic null hypothesis can be rejected. Assuming collecting more data would just make your basic significance test achieve even greater significance (and not reveal that your earlier finding of significance was a false positive), you might find this useless because you'd reject the null either way. However, in this scenario, your confidence interval around the parameter in question would continue to shrink, improving the degree of confidence with which you can describe your population of interest precisely. Here's a very simple example in r – testing the null hypothesis that $\mu=0$ for a simulated variable: One Sample t-test data: rnorm(99) t = -2.057, df = 98, p-value = 0.04234 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: -0.377762241 -0.006780574 sample estimates: mean of x -0.1922714 Here I just used t.test(rnorm(99)), and I happened to get a false positive (assuming I've defaulted to $\alpha=.05$ as my choice of acceptable false positive error rate). If I ignore the confidence interval, I can claim my sample comes from a population with a mean that differs significantly from zero. Technically the confidence interval doesn't dispute this either, but it suggests that the mean could be very close to zero, or even further from it than I think based on this sample. Of course, I know the null is actually literally true here, because the mean of the rnorm population defaults to zero, but one rarely knows with real data. Running this again as set.seed(8);t.test(rnorm(99,1)) produces a sample mean of .91, a p = 5.3E-13, and a 95% confidence interval for $\mu=[.69,1.12]$. This time I can be quite confident that the null is false, especially because I constructed it to be by setting the mean of my simulated data to 1. Still, say it's important to know how different from zero it is; maybe a mean of .8 would be too close to zero for the difference to matter. I can see I don't have enough data to rule out the possibility that $\mu=.8$ from both my confidence interval and from a t-test with mu=.8, which gives a p = .33. My sample mean is high enough to seem meaningfully different from zero according to this .8 threshold though; collecting more data can help improve my confidence that the difference is at least this large, and not just trivially larger than zero. Since I'm "collecting data" by simulation, I can be a little unrealistic and increase my sample size by an order of magnitude. Running set.seed(8);t.test(rnorm(999,1),mu=.8) reveals that more data continue to be useful after rejecting the null hypothesis of $\mu=0$ in this scenario, because I can now reject a null of $\mu=.8$ with my larger sample. The confidence interval of $\mu=[.90,1.02]$ even suggests I could've rejected null hypotheses up to $\mu=.89$ if I'd set out to do so initially. I can't revise my null hypothesis after the fact, but without collecting new data to test an even stronger hypothesis after this result, I can say with 95% confidence that replicating my "study" would allow me to reject a $H_0:\mu=.9$. Again, just because I can simulate this easily, I'll rerun the code as set.seed(9);t.test(rnorm(999,1),mu=.9): doing so demonstrates my confidence wasn't misplaced. Testing progressively more stringent null hypotheses, or better yet, simply focusing on shrinking your confidence intervals is just one way to proceed. Of course, most studies that reject null hypotheses lay the groundwork for other studies that build on the alternative hypothesis. E.g., if I was testing an alternative hypothesis that a correlation is greater than zero, I could test for mediators or moderators in a follow-up study next...and while I'm at it, I'd definitely want to make sure I could replicate the original result. Another approach to consider is equivalence testing. If you want to conclude that a parameter is within a certain range of possible values, not just different from a single value, you can specify that range of values you'd want the parameter to lie within according to your conventional alternative hypothesis and test it against a different set of null hypotheses that together represent the possibility that the parameter lies outside that range. This last possibility might be most similar to what you had in mind when you wrote: We have "some evidence" for the alternative to be true, but we can't draw that conclusion. If I really want to draw that conclusion conclusively... Here's an example using similar data as above (using set.seed(8), rnorm(99) is the same as rnorm(99,1)-1, so the sample mean is -.09). Say I want to test the null hypothesis of two one-sided t-tests that jointly posit that the sample mean is not between -.2 and .2. This corresponds loosely to the previous example's premise, according to which I wanted to test if $\mu=.8$. The difference is that I've shifted my data down by 1, and I'm now going to perform two one-sided tests of the alternative hypothesis that $-.2\le\mu\le.2$. Here's how that looks: require(equivalence);set.seed(8);tost(rnorm(99),epsilon=.2) tost sets the confidence level of the interval to 90%, so the confidence interval around the sample mean of -.09 is $\mu=[-.27,.09]$, and p = .17. However, running this again with rnorm(999) (and the same seed) shrinks the 90% confidence interval to $\mu=[-.09,.01]$, which is within the equivalence range specified in the null hypothesis with p = 4.55E-07. I still think the confidence interval is more interesting than the equivalence test result. It represents what the data suggest the population mean is more specifically than the alternative hypothesis, and suggests I can be reasonably confident that it lies within an even smaller interval than I've specified in the alternative hypothesis. To demonstrate, I'll abuse my unrealistic powers of simulation once more and "replicate" using set.seed(7);tost(rnorm(999),epsilon=.09345092): sure enough, p = .002.
Now that I've rejected the null hypothesis what's next?
You can generally continue to improve your estimate of whatever parameter you might be testing with more data. Stopping data collection once a test achieves some semi-arbitrary degree of significance
Now that I've rejected the null hypothesis what's next? You can generally continue to improve your estimate of whatever parameter you might be testing with more data. Stopping data collection once a test achieves some semi-arbitrary degree of significance is a good way to make bad inferences. That analysts may misunderstand a significant result as a sign that the job is done is one of many unintended consequences of the Neyman–Pearson framework, according to which people interpret p values as cause to either reject or fail to reject a null without reservation depending on which side of the critical threshold they fall on. Without considering Bayesian alternatives to the frequentist paradigm (hopefully someone else will), confidence intervals continue to be more informative well beyond the point at which a basic null hypothesis can be rejected. Assuming collecting more data would just make your basic significance test achieve even greater significance (and not reveal that your earlier finding of significance was a false positive), you might find this useless because you'd reject the null either way. However, in this scenario, your confidence interval around the parameter in question would continue to shrink, improving the degree of confidence with which you can describe your population of interest precisely. Here's a very simple example in r – testing the null hypothesis that $\mu=0$ for a simulated variable: One Sample t-test data: rnorm(99) t = -2.057, df = 98, p-value = 0.04234 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: -0.377762241 -0.006780574 sample estimates: mean of x -0.1922714 Here I just used t.test(rnorm(99)), and I happened to get a false positive (assuming I've defaulted to $\alpha=.05$ as my choice of acceptable false positive error rate). If I ignore the confidence interval, I can claim my sample comes from a population with a mean that differs significantly from zero. Technically the confidence interval doesn't dispute this either, but it suggests that the mean could be very close to zero, or even further from it than I think based on this sample. Of course, I know the null is actually literally true here, because the mean of the rnorm population defaults to zero, but one rarely knows with real data. Running this again as set.seed(8);t.test(rnorm(99,1)) produces a sample mean of .91, a p = 5.3E-13, and a 95% confidence interval for $\mu=[.69,1.12]$. This time I can be quite confident that the null is false, especially because I constructed it to be by setting the mean of my simulated data to 1. Still, say it's important to know how different from zero it is; maybe a mean of .8 would be too close to zero for the difference to matter. I can see I don't have enough data to rule out the possibility that $\mu=.8$ from both my confidence interval and from a t-test with mu=.8, which gives a p = .33. My sample mean is high enough to seem meaningfully different from zero according to this .8 threshold though; collecting more data can help improve my confidence that the difference is at least this large, and not just trivially larger than zero. Since I'm "collecting data" by simulation, I can be a little unrealistic and increase my sample size by an order of magnitude. Running set.seed(8);t.test(rnorm(999,1),mu=.8) reveals that more data continue to be useful after rejecting the null hypothesis of $\mu=0$ in this scenario, because I can now reject a null of $\mu=.8$ with my larger sample. The confidence interval of $\mu=[.90,1.02]$ even suggests I could've rejected null hypotheses up to $\mu=.89$ if I'd set out to do so initially. I can't revise my null hypothesis after the fact, but without collecting new data to test an even stronger hypothesis after this result, I can say with 95% confidence that replicating my "study" would allow me to reject a $H_0:\mu=.9$. Again, just because I can simulate this easily, I'll rerun the code as set.seed(9);t.test(rnorm(999,1),mu=.9): doing so demonstrates my confidence wasn't misplaced. Testing progressively more stringent null hypotheses, or better yet, simply focusing on shrinking your confidence intervals is just one way to proceed. Of course, most studies that reject null hypotheses lay the groundwork for other studies that build on the alternative hypothesis. E.g., if I was testing an alternative hypothesis that a correlation is greater than zero, I could test for mediators or moderators in a follow-up study next...and while I'm at it, I'd definitely want to make sure I could replicate the original result. Another approach to consider is equivalence testing. If you want to conclude that a parameter is within a certain range of possible values, not just different from a single value, you can specify that range of values you'd want the parameter to lie within according to your conventional alternative hypothesis and test it against a different set of null hypotheses that together represent the possibility that the parameter lies outside that range. This last possibility might be most similar to what you had in mind when you wrote: We have "some evidence" for the alternative to be true, but we can't draw that conclusion. If I really want to draw that conclusion conclusively... Here's an example using similar data as above (using set.seed(8), rnorm(99) is the same as rnorm(99,1)-1, so the sample mean is -.09). Say I want to test the null hypothesis of two one-sided t-tests that jointly posit that the sample mean is not between -.2 and .2. This corresponds loosely to the previous example's premise, according to which I wanted to test if $\mu=.8$. The difference is that I've shifted my data down by 1, and I'm now going to perform two one-sided tests of the alternative hypothesis that $-.2\le\mu\le.2$. Here's how that looks: require(equivalence);set.seed(8);tost(rnorm(99),epsilon=.2) tost sets the confidence level of the interval to 90%, so the confidence interval around the sample mean of -.09 is $\mu=[-.27,.09]$, and p = .17. However, running this again with rnorm(999) (and the same seed) shrinks the 90% confidence interval to $\mu=[-.09,.01]$, which is within the equivalence range specified in the null hypothesis with p = 4.55E-07. I still think the confidence interval is more interesting than the equivalence test result. It represents what the data suggest the population mean is more specifically than the alternative hypothesis, and suggests I can be reasonably confident that it lies within an even smaller interval than I've specified in the alternative hypothesis. To demonstrate, I'll abuse my unrealistic powers of simulation once more and "replicate" using set.seed(7);tost(rnorm(999),epsilon=.09345092): sure enough, p = .002.
Now that I've rejected the null hypothesis what's next? You can generally continue to improve your estimate of whatever parameter you might be testing with more data. Stopping data collection once a test achieves some semi-arbitrary degree of significance
11,654
Now that I've rejected the null hypothesis what's next?
Note first that @Nick Stauner makes some very important arguments regarding optional stopping. If you repeatedly test the data as samples come in, stopping once a test is significant, you're all but guaranteed a significant result. However, a guaranteed result is practically worthless. In the following, I'll present my best attempts to elaborate on a deductivist, skeptical, falsificationist position. It's certainly not the only one, but I think a rather mainstream one, or at least one with a bit of tradition. As far as I understand it, Fisher originally introduced significance tests as a first step in data exploration - establish which factors might be worth investigating further. Unless the null hypothesis you've put under test actually was the critical hypothesis your favoured theory depended on (unlikely), in a way, your initial test was rather exploratory in nature. Amongst the possible steps following exploration I see Further exploration Parameter Estimation Prediction & Confirmation Further exploration consists of follow-up tests where you try to infer if any variables you have information on moderate or interact with your effect. For example, maybe the age of the participants plays a role? Note that such analyses must be clearly labelled as exploratory, or they basically amount to lying. If you stumble upon something, it first requires confirmation. Generally, you should always be clear- both in your thoughts, and in your writings - about when you're working exploratory, and when confirmatory. Next, once you have established that you have no confidence in one parameter's value being precisely zero - once you have decided you'll for now consider the factor under test to have some influence - one feasible next step could be to further estimate the precise value of the parameter. For example, for now, you've only excluded one value, 0 (assuming a two-sided test). However, your data also cast doubt on many further possible values. A (100-$\alpha$)% Confidence Interval/CI contains the range of parameter values not rejected at p<$\alpha$, corresponding to the many more possible hypotheses your data also concern beyond your initial H0. Since your test is significant, the value associated with H0 is not amongst them. But many extremely large and small values will also be excluded. Hume famously argued we can never inductively prove correct a statement. Generally, non-trivial hypotheses are always a lot easier to falsify than to support; being easy to falsify in principle (by being non-trivial, making precise predictions), but yet not being falsified so far is in fact one of the highest virtues of a theory. So a CI won't get you to proving a specific value. However, it narrows down the candidate set. Maybe the only candidates left alive help you decide between two theories both incompatible with H0. For example, maybe 0 is excluded, but theory 1 predicts a value around 5, and theory 2 predicts a value around 15. If your 95% CI includes 5, but excludes 15, you have now also lost confidence in theory 2, but theory 1 remains in the game. Note that this is actually independent of your initial test being significant - even if 0 is amongst the values not rejected, many values will be rejected. Maybe for some other researchers, some of these values were of interest. After you have thus somewhat specified your understanding of the effect at hand, you could ideally make a more precise prediction for a follow-up confirmatory experiment that would aim to test a more precise hypothesis you can derive from your current analysis. Admittedly, rejecting your initial statistical null hypothesis wasn't that severe of a test of your original research hypothesis, wasn't it? Many more explanations than the one you prefer do not depend on H0. Also, since you never were in danger to actually accept H0, you were in no position to falsify your favoured theory! So you need a more severe test. Arguably, this is actually what you want; you do not want to prove your theory, you want to put it under increasingly severe tests, attempting to falsify it. Withstanding such genuine (but fair) efforts to disprove it is the best a theory can deliver. But for a severe test, you need a more precise theory than "0 it ain't". You now have learned multiple important facts concerning a confirmatory study; for example, you have an idea of the variance and effect magnitude in question, allowing you to estimate the required sample size for a follow-up study via power analysis. You can also predict a specific value and assume a region of practical equivalence/ROPE around it. You won't ever be able to prove that this specific value is the true value; however, if the CI from a follow-up experiment falls entirely within your ROPE, you have corroborating evidence for your theory (and possibly brought in trouble the competition).
Now that I've rejected the null hypothesis what's next?
Note first that @Nick Stauner makes some very important arguments regarding optional stopping. If you repeatedly test the data as samples come in, stopping once a test is significant, you're all but g
Now that I've rejected the null hypothesis what's next? Note first that @Nick Stauner makes some very important arguments regarding optional stopping. If you repeatedly test the data as samples come in, stopping once a test is significant, you're all but guaranteed a significant result. However, a guaranteed result is practically worthless. In the following, I'll present my best attempts to elaborate on a deductivist, skeptical, falsificationist position. It's certainly not the only one, but I think a rather mainstream one, or at least one with a bit of tradition. As far as I understand it, Fisher originally introduced significance tests as a first step in data exploration - establish which factors might be worth investigating further. Unless the null hypothesis you've put under test actually was the critical hypothesis your favoured theory depended on (unlikely), in a way, your initial test was rather exploratory in nature. Amongst the possible steps following exploration I see Further exploration Parameter Estimation Prediction & Confirmation Further exploration consists of follow-up tests where you try to infer if any variables you have information on moderate or interact with your effect. For example, maybe the age of the participants plays a role? Note that such analyses must be clearly labelled as exploratory, or they basically amount to lying. If you stumble upon something, it first requires confirmation. Generally, you should always be clear- both in your thoughts, and in your writings - about when you're working exploratory, and when confirmatory. Next, once you have established that you have no confidence in one parameter's value being precisely zero - once you have decided you'll for now consider the factor under test to have some influence - one feasible next step could be to further estimate the precise value of the parameter. For example, for now, you've only excluded one value, 0 (assuming a two-sided test). However, your data also cast doubt on many further possible values. A (100-$\alpha$)% Confidence Interval/CI contains the range of parameter values not rejected at p<$\alpha$, corresponding to the many more possible hypotheses your data also concern beyond your initial H0. Since your test is significant, the value associated with H0 is not amongst them. But many extremely large and small values will also be excluded. Hume famously argued we can never inductively prove correct a statement. Generally, non-trivial hypotheses are always a lot easier to falsify than to support; being easy to falsify in principle (by being non-trivial, making precise predictions), but yet not being falsified so far is in fact one of the highest virtues of a theory. So a CI won't get you to proving a specific value. However, it narrows down the candidate set. Maybe the only candidates left alive help you decide between two theories both incompatible with H0. For example, maybe 0 is excluded, but theory 1 predicts a value around 5, and theory 2 predicts a value around 15. If your 95% CI includes 5, but excludes 15, you have now also lost confidence in theory 2, but theory 1 remains in the game. Note that this is actually independent of your initial test being significant - even if 0 is amongst the values not rejected, many values will be rejected. Maybe for some other researchers, some of these values were of interest. After you have thus somewhat specified your understanding of the effect at hand, you could ideally make a more precise prediction for a follow-up confirmatory experiment that would aim to test a more precise hypothesis you can derive from your current analysis. Admittedly, rejecting your initial statistical null hypothesis wasn't that severe of a test of your original research hypothesis, wasn't it? Many more explanations than the one you prefer do not depend on H0. Also, since you never were in danger to actually accept H0, you were in no position to falsify your favoured theory! So you need a more severe test. Arguably, this is actually what you want; you do not want to prove your theory, you want to put it under increasingly severe tests, attempting to falsify it. Withstanding such genuine (but fair) efforts to disprove it is the best a theory can deliver. But for a severe test, you need a more precise theory than "0 it ain't". You now have learned multiple important facts concerning a confirmatory study; for example, you have an idea of the variance and effect magnitude in question, allowing you to estimate the required sample size for a follow-up study via power analysis. You can also predict a specific value and assume a region of practical equivalence/ROPE around it. You won't ever be able to prove that this specific value is the true value; however, if the CI from a follow-up experiment falls entirely within your ROPE, you have corroborating evidence for your theory (and possibly brought in trouble the competition).
Now that I've rejected the null hypothesis what's next? Note first that @Nick Stauner makes some very important arguments regarding optional stopping. If you repeatedly test the data as samples come in, stopping once a test is significant, you're all but g
11,655
Now that I've rejected the null hypothesis what's next?
The idea that you cannot prove a positive scientific proposition, but only disprove one, is a principle of Popper's falsificationism. I do agree that you cannot prove an effect is exactly equal to any given point value (cf., my answer here: Why do statisticians say a non-significant result means "you cannot reject the null" as opposed to accept the null hypothesis?). But so what? People (or at least I) complain a lot about hypothesis testing. This is because $p$-values are commonly misunderstood, and hypothesis tests are used for tasks they logically cannot accomplish. For example, hypothesis testing should not be used to generate hypotheses or to select variables. Moreover, with observational data essentially all 'nil' null hypotheses must be false, so testing such makes little sense. However, scientists often do have a-priori hypotheses suggested by current theories that they want to test, and in a true experiment a nil null could be true, so testing it is perfectly reasonable. Typically, researchers do have some reason to suspect that the null might be false, so a significant result in conjunction with a strong experiment is a valid piece of information. You can always form confidence intervals to get a clearer picture of the precision of your estimate, and continue to collect more data to increase its precision. Nonetheless, in economic terms you will get diminishing returns. At some point, you simply do not believe the null hypothesis provides a reasonable account of the phenomenon under study. In which case, why are you bothering? If there are others in your field who are not yet convinced, but would be with more (of the same) data, then you could continue, but this seems like an uncommon situation. It seems more likely to me that the skeptics have other, substantive concerns regarding whether that line of inquiry is sufficiently informative about the underlying question. Thus, you need to determine the nature of those concerns, and if you think they merit the work, seek out different data that more adequately address the issues at hand. For example, you might try to replicate the finding using a different measure, in a different setting, and/or with different control conditions. On the other hand, everyone (more or less) may be satisfied with your data and conclusions (congratulations!). Under such happy circumstances, there are two directions you could pursue to further your research program: A reductionist approach would seek to understand the mechanisms that produce the effect you have established. In statistical terms, you would often be seeking mediators and/or a refining of the pattern of causal forces that connect the variables you have shown to be related. You could also move in the other direction by seeking to integrate your findings into a larger pattern. This is a kind of systems thinking. G.H. Hardy once defined the elegance of a theory as the range of phenomena that it could explain in conjunction with the ease and magnitude of the epistemic shift it induced. Of course, you may not be so lucky that the phenomenon you have established is quite that deep, however it can still be part of something bigger than itself. Establishing a link between $B$ and $C$ that makes it possible to see that $A$ unifies disparate phenomena can be just as important to the process, and just as much a crystallizing moment, as the discovery of $A$ itself. tl;dr: If you have sufficient evidence for your purposes that the null is false, figure out what other theoretically motivated questions you could try to answer and move on.
Now that I've rejected the null hypothesis what's next?
The idea that you cannot prove a positive scientific proposition, but only disprove one, is a principle of Popper's falsificationism. I do agree that you cannot prove an effect is exactly equal to an
Now that I've rejected the null hypothesis what's next? The idea that you cannot prove a positive scientific proposition, but only disprove one, is a principle of Popper's falsificationism. I do agree that you cannot prove an effect is exactly equal to any given point value (cf., my answer here: Why do statisticians say a non-significant result means "you cannot reject the null" as opposed to accept the null hypothesis?). But so what? People (or at least I) complain a lot about hypothesis testing. This is because $p$-values are commonly misunderstood, and hypothesis tests are used for tasks they logically cannot accomplish. For example, hypothesis testing should not be used to generate hypotheses or to select variables. Moreover, with observational data essentially all 'nil' null hypotheses must be false, so testing such makes little sense. However, scientists often do have a-priori hypotheses suggested by current theories that they want to test, and in a true experiment a nil null could be true, so testing it is perfectly reasonable. Typically, researchers do have some reason to suspect that the null might be false, so a significant result in conjunction with a strong experiment is a valid piece of information. You can always form confidence intervals to get a clearer picture of the precision of your estimate, and continue to collect more data to increase its precision. Nonetheless, in economic terms you will get diminishing returns. At some point, you simply do not believe the null hypothesis provides a reasonable account of the phenomenon under study. In which case, why are you bothering? If there are others in your field who are not yet convinced, but would be with more (of the same) data, then you could continue, but this seems like an uncommon situation. It seems more likely to me that the skeptics have other, substantive concerns regarding whether that line of inquiry is sufficiently informative about the underlying question. Thus, you need to determine the nature of those concerns, and if you think they merit the work, seek out different data that more adequately address the issues at hand. For example, you might try to replicate the finding using a different measure, in a different setting, and/or with different control conditions. On the other hand, everyone (more or less) may be satisfied with your data and conclusions (congratulations!). Under such happy circumstances, there are two directions you could pursue to further your research program: A reductionist approach would seek to understand the mechanisms that produce the effect you have established. In statistical terms, you would often be seeking mediators and/or a refining of the pattern of causal forces that connect the variables you have shown to be related. You could also move in the other direction by seeking to integrate your findings into a larger pattern. This is a kind of systems thinking. G.H. Hardy once defined the elegance of a theory as the range of phenomena that it could explain in conjunction with the ease and magnitude of the epistemic shift it induced. Of course, you may not be so lucky that the phenomenon you have established is quite that deep, however it can still be part of something bigger than itself. Establishing a link between $B$ and $C$ that makes it possible to see that $A$ unifies disparate phenomena can be just as important to the process, and just as much a crystallizing moment, as the discovery of $A$ itself. tl;dr: If you have sufficient evidence for your purposes that the null is false, figure out what other theoretically motivated questions you could try to answer and move on.
Now that I've rejected the null hypothesis what's next? The idea that you cannot prove a positive scientific proposition, but only disprove one, is a principle of Popper's falsificationism. I do agree that you cannot prove an effect is exactly equal to an
11,656
Now that I've rejected the null hypothesis what's next?
One think I would like to add is that your question reminds me of my younger self: I wanted desperately to prove my hypothesis because I did not how to write "the hypothesis was wrong" in a way which helped to improve the paper I was writing. But then I realized that the "damn my absolutely lovely hypothesis cannot be proven" also holds scientific value: 1. Think about WHY your hypothesis doesn't hold water. It's some problem with the data, or probabyly something with the hypothesis itself? 2. What are the consequences for older research? As an example: I wrote my master's thesis about ethnic conflect using a then new dataset which was larger than previous datasets. I tested several disputed hypothesis like "oil fuels ethnic conflict" or "mountaineous regrions are more likely to expierience conflict". I could not prove that oil fuels ethnic conflict - but I wrote two pages about how the quality of the available oil-dataset impacted the analysis (the dataset itself is a time-series, the oil-well dataset is not). The "mountains are causing conflict" thesis was also a failure - but a fruitful one: previous research analyzed this thesis with country-level data (e.g. mean height of the country or so), while I did it on the level of ethnic groups - so I spent a lot of paper to discuss the differences and why my analysis was better than other famous research... Keep in mind: disproving a hypothesis is not a failure but a result as good as a proved hypothesis.
Now that I've rejected the null hypothesis what's next?
One think I would like to add is that your question reminds me of my younger self: I wanted desperately to prove my hypothesis because I did not how to write "the hypothesis was wrong" in a way which
Now that I've rejected the null hypothesis what's next? One think I would like to add is that your question reminds me of my younger self: I wanted desperately to prove my hypothesis because I did not how to write "the hypothesis was wrong" in a way which helped to improve the paper I was writing. But then I realized that the "damn my absolutely lovely hypothesis cannot be proven" also holds scientific value: 1. Think about WHY your hypothesis doesn't hold water. It's some problem with the data, or probabyly something with the hypothesis itself? 2. What are the consequences for older research? As an example: I wrote my master's thesis about ethnic conflect using a then new dataset which was larger than previous datasets. I tested several disputed hypothesis like "oil fuels ethnic conflict" or "mountaineous regrions are more likely to expierience conflict". I could not prove that oil fuels ethnic conflict - but I wrote two pages about how the quality of the available oil-dataset impacted the analysis (the dataset itself is a time-series, the oil-well dataset is not). The "mountains are causing conflict" thesis was also a failure - but a fruitful one: previous research analyzed this thesis with country-level data (e.g. mean height of the country or so), while I did it on the level of ethnic groups - so I spent a lot of paper to discuss the differences and why my analysis was better than other famous research... Keep in mind: disproving a hypothesis is not a failure but a result as good as a proved hypothesis.
Now that I've rejected the null hypothesis what's next? One think I would like to add is that your question reminds me of my younger self: I wanted desperately to prove my hypothesis because I did not how to write "the hypothesis was wrong" in a way which
11,657
Now that I've rejected the null hypothesis what's next?
There is a method for combing probabilities across studies described here. You should not apply the formula blindly without considering the pattern of results.
Now that I've rejected the null hypothesis what's next?
There is a method for combing probabilities across studies described here. You should not apply the formula blindly without considering the pattern of results.
Now that I've rejected the null hypothesis what's next? There is a method for combing probabilities across studies described here. You should not apply the formula blindly without considering the pattern of results.
Now that I've rejected the null hypothesis what's next? There is a method for combing probabilities across studies described here. You should not apply the formula blindly without considering the pattern of results.
11,658
What's the probability that from 25 random numbers between 1 and 100, the highest appears more than once?
Let $x$ be the top end of your range, $x=100$ in your case. $n$ be the total number of draws, $n=25$ in your case. For any number $y\le x$, the number of sequences of $n$ numbers with each number in the sequence $\le y$ is $y^n$. Of these sequence, the number containing no $y$s is $(y-1)^n$, and the number containing one $y$ is $n(y-1)^{n-1}$. Hence the number of sequences with two or more $y$s is $$y^n - (y-1)^n - n(y-1)^{n-1}$$ The total number of sequences of $n$ numbers with highest number $y$ containing at least two $y$s is \begin{align} \sum_{y=1}^x \left(y^n - (y-1)^n - n(y-1)^{n-1}\right) &= \sum_{y=1}^x y^n - \sum_{y=1}^x(y-1)^n - \sum_{y=1}^xn(y-1)^{n-1}\\ &= x^n - n\sum_{y=1}^x(y-1)^{n-1}\\ &= x^n - n\sum_{y=1}^{x-1}y^{n-1}\\ \end{align} The total number of sequences is simply $x^n$. All sequences are equally likely and so the probability is $$ \frac{x^n - n\sum_{y=1}^{y=x-1}y^{n-1}}{x^n}$$ With $x=100,n=25$ I make the probability 0.120004212454. I've tested this using the following Python program, which counts the sequences that match manually (for low $x,n$), simulates and calculates using the above formula. import itertools import numpy.random as np def countinlist(x, n): count = 0 total = 0 for perm in itertools.product(range(1, x+1), repeat=n): total += 1 if perm.count(max(perm)) > 1: count += 1 print "Counting: x", x, "n", n, "total", total, "count", count def simulate(x,n,N): count = 0 for i in range(N): perm = np.randint(x, size=n) m = max(perm) if sum(perm==m) > 1: count += 1 print "Simulation: x", x, "n", n, "total", N, "count", count, "prob", count/float(N) x=100 n=25 N = 1000000 # number of trials in simulation #countinlist(x,n) # only call this for reasonably small x and n!!!! simulate(x,n,N) formula = x**n - n*sum([i**(n-1) for i in range(x)]) print "Formula count", formula, "out of", x**n, "probability", float(formula) / x**n This program outputted Simulation: x 100 n 25 total 1000000 count 120071 prob 0.120071 Formula count 12000421245360277498241319178764675560017783666750 out of 100000000000000000000000000000000000000000000000000 probability 0.120004212454
What's the probability that from 25 random numbers between 1 and 100, the highest appears more than
Let $x$ be the top end of your range, $x=100$ in your case. $n$ be the total number of draws, $n=25$ in your case. For any number $y\le x$, the number of sequences of $n$ numbers with each number in
What's the probability that from 25 random numbers between 1 and 100, the highest appears more than once? Let $x$ be the top end of your range, $x=100$ in your case. $n$ be the total number of draws, $n=25$ in your case. For any number $y\le x$, the number of sequences of $n$ numbers with each number in the sequence $\le y$ is $y^n$. Of these sequence, the number containing no $y$s is $(y-1)^n$, and the number containing one $y$ is $n(y-1)^{n-1}$. Hence the number of sequences with two or more $y$s is $$y^n - (y-1)^n - n(y-1)^{n-1}$$ The total number of sequences of $n$ numbers with highest number $y$ containing at least two $y$s is \begin{align} \sum_{y=1}^x \left(y^n - (y-1)^n - n(y-1)^{n-1}\right) &= \sum_{y=1}^x y^n - \sum_{y=1}^x(y-1)^n - \sum_{y=1}^xn(y-1)^{n-1}\\ &= x^n - n\sum_{y=1}^x(y-1)^{n-1}\\ &= x^n - n\sum_{y=1}^{x-1}y^{n-1}\\ \end{align} The total number of sequences is simply $x^n$. All sequences are equally likely and so the probability is $$ \frac{x^n - n\sum_{y=1}^{y=x-1}y^{n-1}}{x^n}$$ With $x=100,n=25$ I make the probability 0.120004212454. I've tested this using the following Python program, which counts the sequences that match manually (for low $x,n$), simulates and calculates using the above formula. import itertools import numpy.random as np def countinlist(x, n): count = 0 total = 0 for perm in itertools.product(range(1, x+1), repeat=n): total += 1 if perm.count(max(perm)) > 1: count += 1 print "Counting: x", x, "n", n, "total", total, "count", count def simulate(x,n,N): count = 0 for i in range(N): perm = np.randint(x, size=n) m = max(perm) if sum(perm==m) > 1: count += 1 print "Simulation: x", x, "n", n, "total", N, "count", count, "prob", count/float(N) x=100 n=25 N = 1000000 # number of trials in simulation #countinlist(x,n) # only call this for reasonably small x and n!!!! simulate(x,n,N) formula = x**n - n*sum([i**(n-1) for i in range(x)]) print "Formula count", formula, "out of", x**n, "probability", float(formula) / x**n This program outputted Simulation: x 100 n 25 total 1000000 count 120071 prob 0.120071 Formula count 12000421245360277498241319178764675560017783666750 out of 100000000000000000000000000000000000000000000000000 probability 0.120004212454
What's the probability that from 25 random numbers between 1 and 100, the highest appears more than Let $x$ be the top end of your range, $x=100$ in your case. $n$ be the total number of draws, $n=25$ in your case. For any number $y\le x$, the number of sequences of $n$ numbers with each number in
11,659
What's the probability that from 25 random numbers between 1 and 100, the highest appears more than once?
I would consider to find the probability of having a unique winner first Probability of having a unique winner and his number is $x$ equals to $\frac{{25\choose1} (x-1)^{24}}{{100}^{25} }$ as there is 25 choices for winner, and the remaining can have number ranging from 1 to $y-1$ The winner can win with his number equals to 2 to 100 so the total probability is \begin{align} &\sum_{i=2}^{100} \frac {25(i-1)^{24}}{{100}^{25}}\\ =& 25\sum_{i=1}^{99} \frac{i^{24}}{{100}^{25}}\\ =& -{1 \over 4}+25\sum_{i=1}^{100} \frac{i^{24}}{{100}^{25}}\\\approx&-{1 \over 4}+25 {{1\over24+1}{100}^{24+1}+{{1\over2}{100}^{24}+{{{24\over2} {1\over6}}{100}^{23} }}\over{100}^{25}}\\ =&0.88 \end{align} Here I used the approximation up to $100^{23}$ For reference: Faulhaber's formula from Wikipedia Hence the probability of having a tie is $1-0.88=0.12$
What's the probability that from 25 random numbers between 1 and 100, the highest appears more than
I would consider to find the probability of having a unique winner first Probability of having a unique winner and his number is $x$ equals to $\frac{{25\choose1} (x-1)^{24}}{{100}^{25} }$ as there i
What's the probability that from 25 random numbers between 1 and 100, the highest appears more than once? I would consider to find the probability of having a unique winner first Probability of having a unique winner and his number is $x$ equals to $\frac{{25\choose1} (x-1)^{24}}{{100}^{25} }$ as there is 25 choices for winner, and the remaining can have number ranging from 1 to $y-1$ The winner can win with his number equals to 2 to 100 so the total probability is \begin{align} &\sum_{i=2}^{100} \frac {25(i-1)^{24}}{{100}^{25}}\\ =& 25\sum_{i=1}^{99} \frac{i^{24}}{{100}^{25}}\\ =& -{1 \over 4}+25\sum_{i=1}^{100} \frac{i^{24}}{{100}^{25}}\\\approx&-{1 \over 4}+25 {{1\over24+1}{100}^{24+1}+{{1\over2}{100}^{24}+{{{24\over2} {1\over6}}{100}^{23} }}\over{100}^{25}}\\ =&0.88 \end{align} Here I used the approximation up to $100^{23}$ For reference: Faulhaber's formula from Wikipedia Hence the probability of having a tie is $1-0.88=0.12$
What's the probability that from 25 random numbers between 1 and 100, the highest appears more than I would consider to find the probability of having a unique winner first Probability of having a unique winner and his number is $x$ equals to $\frac{{25\choose1} (x-1)^{24}}{{100}^{25} }$ as there i
11,660
What's the probability that from 25 random numbers between 1 and 100, the highest appears more than once?
It seems a very similar question to the Birthday paradox (http://en.wikipedia.org/wiki/Birthday_problem), the only difference is that in this case you don't want to match any number but only the highest number. The first step in the calculation calculate the probability that non of the random numbers overlap ($p$). (see the link above) and then the probability that some of the 25 numbers overlap is $1-p$ where p is the probability you already calculated. In this case the probability the the 25 numbers don't overlap with the maximum is given by: $p=1*(1-1/100)*(1-1/100)......*(1-1/10)=(1-1/100)^{24}$ then the probability you are looking for is $P=1-p=1-(1-1/100)^{24} = 0.214$
What's the probability that from 25 random numbers between 1 and 100, the highest appears more than
It seems a very similar question to the Birthday paradox (http://en.wikipedia.org/wiki/Birthday_problem), the only difference is that in this case you don't want to match any number but only the highe
What's the probability that from 25 random numbers between 1 and 100, the highest appears more than once? It seems a very similar question to the Birthday paradox (http://en.wikipedia.org/wiki/Birthday_problem), the only difference is that in this case you don't want to match any number but only the highest number. The first step in the calculation calculate the probability that non of the random numbers overlap ($p$). (see the link above) and then the probability that some of the 25 numbers overlap is $1-p$ where p is the probability you already calculated. In this case the probability the the 25 numbers don't overlap with the maximum is given by: $p=1*(1-1/100)*(1-1/100)......*(1-1/10)=(1-1/100)^{24}$ then the probability you are looking for is $P=1-p=1-(1-1/100)^{24} = 0.214$
What's the probability that from 25 random numbers between 1 and 100, the highest appears more than It seems a very similar question to the Birthday paradox (http://en.wikipedia.org/wiki/Birthday_problem), the only difference is that in this case you don't want to match any number but only the highe
11,661
How can I align/synchronize two signals?
The question asks how to find the amount by which one time series ("expansion") lags another ("volume") when the series are sampled at regular but different intervals. In this case both series exhibit reasonably continuous behavior, as the figures will show. This implies (1) little or no initial smoothing may be needed and (2) resampling can be as simple as linear or quadratic interpolation. Quadratic may be slightly better due to the smoothness. After resampling, the lag is found by maximizing the cross-correlation, as shown in the thread, For two offset sampled data series, what is the best estimate of the offset between them?. To illustrate, we can use the data supplied in the question, employing R for the pseudocode. Let's begin with the basic functionality, cross-correlation and resampling: cor.cross <- function(x0, y0, i=0) { # # Sample autocorrelation at (integral) lag `i`: # Positive `i` compares future values of `x` to present values of `y`'; # negative `i` compares past values of `x` to present values of `y`. # if (i < 0) {x<-y0; y<-x0; i<- -i} else {x<-x0; y<-y0} n <- length(x) cor(x[(i+1):n], y[1:(n-i)], use="complete.obs") } This is a crude algorithm: an FFT-based calculation would be faster. But for these data (involving about 4000 values) it's good enough. resample <- function(x,t) { # # Resample time series `x`, assumed to have unit time intervals, at time `t`. # Uses quadratic interpolation. # n <- length(x) if (n < 3) stop("First argument to resample is too short; need 3 elements.") i <- median(c(2, floor(t+1/2), n-1)) # Clamp `i` to the range 2..n-1 u <- t-i x[i-1]*u*(u-1)/2 - x[i]*(u+1)*(u-1) + x[i+1]*u*(u+1)/2 } I downloaded the data as a comma-separated CSV file and stripped its header. (The header caused some problems for R which I didn't care to diagnose.) data <- read.table("f:/temp/a.csv", header=FALSE, sep=",", col.names=c("Sample","Time32Hz","Expansion","Time100Hz","Volume")) NB This solution assumes each series of data is in temporal order with no gaps in either one. This allows it to use indexes into the values as proxies for time and to scale those indexes by the temporal sampling frequencies to convert them to times. It turns out that one or both of these instruments drifts a little over time. It's good to remove such trends before proceeding. Also, because there is a tapering of the volume signal at the end, we should clip it out. n.clip <- 350 # Number of terminal volume values to eliminate n <- length(data$Volume) - n.clip indexes <- 1:n v <- residuals(lm(data$Volume[indexes] ~ indexes)) expansion <- residuals(lm(data$Expansion[indexes] ~ indexes) I resample the less-frequent series in order to get the most precision out of the result. e.frequency <- 32 # Herz v.frequency <- 100 # Herz e <- sapply(1:length(v), function(t) resample(expansion, e.frequency*t/v.frequency)) Now the cross-correlation can be computed--for efficiency we search only a reasonable window of lags--and the lag where the maximum value is found can be identified. lag.max <- 5 # Seconds lag.min <- -2 # Seconds (use 0 if expansion must lag volume) time.range <- (lag.min*v.frequency):(lag.max*v.frequency) data.cor <- sapply(time.range, function(i) cor.cross(e, v, i)) i <- time.range[which.max(data.cor)] print(paste("Expansion lags volume by", i / v.frequency, "seconds.")) The output tells us that expansion lags volume by 1.85 seconds. (If the last 3.5 seconds of data weren't clipped, the output would be 1.84 seconds.) It's a good idea to check everything in several ways, preferably visually. First, the cross-correlation function: plot(time.range * (1/v.frequency), data.cor, type="l", lwd=2, xlab="Lag (seconds)", ylab="Correlation") points(i * (1/v.frequency), max(data.cor), col="Red", cex=2.5) Next, let's register the two series in time and plot them together on the same axes. normalize <- function(x) { # # Normalize vector `x` to the range 0..1. # x.max <- max(x); x.min <- min(x); dx <- x.max - x.min if (dx==0) dx <- 1 (x-x.min) / dx } times <- (1:(n-i))* (1/v.frequency) plot(times, normalize(e)[(i+1):n], type="l", lwd=2, xlab="Time of volume measurement, seconds", ylab="Normalized values (volume is red)") lines(times, normalize(v)[1:(n-i)], col="Red", lwd=2) It looks pretty good! We can get a better sense of the registration quality with a scatterplot, though. I vary the colors by time to show the progression. colors <- hsv(1:(n-i)/(n-i+1), .8, .8) plot(e[(i+1):n], v[1:(n-i)], col=colors, cex = 0.7, xlab="Expansion (lagged)", ylab="Volume") We're looking for the points to track back and forth along a line: variations from that reflect nonlinearities in the time-lagged response of expansion to volume. Although there are some variations, they are pretty small. Yet, how these variations change over time may be of some physiological interest. The wonderful thing about statistics, especially its exploratory and visual aspect, is how it tends to create good questions and ideas along with useful answers.
How can I align/synchronize two signals?
The question asks how to find the amount by which one time series ("expansion") lags another ("volume") when the series are sampled at regular but different intervals. In this case both series exhibit
How can I align/synchronize two signals? The question asks how to find the amount by which one time series ("expansion") lags another ("volume") when the series are sampled at regular but different intervals. In this case both series exhibit reasonably continuous behavior, as the figures will show. This implies (1) little or no initial smoothing may be needed and (2) resampling can be as simple as linear or quadratic interpolation. Quadratic may be slightly better due to the smoothness. After resampling, the lag is found by maximizing the cross-correlation, as shown in the thread, For two offset sampled data series, what is the best estimate of the offset between them?. To illustrate, we can use the data supplied in the question, employing R for the pseudocode. Let's begin with the basic functionality, cross-correlation and resampling: cor.cross <- function(x0, y0, i=0) { # # Sample autocorrelation at (integral) lag `i`: # Positive `i` compares future values of `x` to present values of `y`'; # negative `i` compares past values of `x` to present values of `y`. # if (i < 0) {x<-y0; y<-x0; i<- -i} else {x<-x0; y<-y0} n <- length(x) cor(x[(i+1):n], y[1:(n-i)], use="complete.obs") } This is a crude algorithm: an FFT-based calculation would be faster. But for these data (involving about 4000 values) it's good enough. resample <- function(x,t) { # # Resample time series `x`, assumed to have unit time intervals, at time `t`. # Uses quadratic interpolation. # n <- length(x) if (n < 3) stop("First argument to resample is too short; need 3 elements.") i <- median(c(2, floor(t+1/2), n-1)) # Clamp `i` to the range 2..n-1 u <- t-i x[i-1]*u*(u-1)/2 - x[i]*(u+1)*(u-1) + x[i+1]*u*(u+1)/2 } I downloaded the data as a comma-separated CSV file and stripped its header. (The header caused some problems for R which I didn't care to diagnose.) data <- read.table("f:/temp/a.csv", header=FALSE, sep=",", col.names=c("Sample","Time32Hz","Expansion","Time100Hz","Volume")) NB This solution assumes each series of data is in temporal order with no gaps in either one. This allows it to use indexes into the values as proxies for time and to scale those indexes by the temporal sampling frequencies to convert them to times. It turns out that one or both of these instruments drifts a little over time. It's good to remove such trends before proceeding. Also, because there is a tapering of the volume signal at the end, we should clip it out. n.clip <- 350 # Number of terminal volume values to eliminate n <- length(data$Volume) - n.clip indexes <- 1:n v <- residuals(lm(data$Volume[indexes] ~ indexes)) expansion <- residuals(lm(data$Expansion[indexes] ~ indexes) I resample the less-frequent series in order to get the most precision out of the result. e.frequency <- 32 # Herz v.frequency <- 100 # Herz e <- sapply(1:length(v), function(t) resample(expansion, e.frequency*t/v.frequency)) Now the cross-correlation can be computed--for efficiency we search only a reasonable window of lags--and the lag where the maximum value is found can be identified. lag.max <- 5 # Seconds lag.min <- -2 # Seconds (use 0 if expansion must lag volume) time.range <- (lag.min*v.frequency):(lag.max*v.frequency) data.cor <- sapply(time.range, function(i) cor.cross(e, v, i)) i <- time.range[which.max(data.cor)] print(paste("Expansion lags volume by", i / v.frequency, "seconds.")) The output tells us that expansion lags volume by 1.85 seconds. (If the last 3.5 seconds of data weren't clipped, the output would be 1.84 seconds.) It's a good idea to check everything in several ways, preferably visually. First, the cross-correlation function: plot(time.range * (1/v.frequency), data.cor, type="l", lwd=2, xlab="Lag (seconds)", ylab="Correlation") points(i * (1/v.frequency), max(data.cor), col="Red", cex=2.5) Next, let's register the two series in time and plot them together on the same axes. normalize <- function(x) { # # Normalize vector `x` to the range 0..1. # x.max <- max(x); x.min <- min(x); dx <- x.max - x.min if (dx==0) dx <- 1 (x-x.min) / dx } times <- (1:(n-i))* (1/v.frequency) plot(times, normalize(e)[(i+1):n], type="l", lwd=2, xlab="Time of volume measurement, seconds", ylab="Normalized values (volume is red)") lines(times, normalize(v)[1:(n-i)], col="Red", lwd=2) It looks pretty good! We can get a better sense of the registration quality with a scatterplot, though. I vary the colors by time to show the progression. colors <- hsv(1:(n-i)/(n-i+1), .8, .8) plot(e[(i+1):n], v[1:(n-i)], col=colors, cex = 0.7, xlab="Expansion (lagged)", ylab="Volume") We're looking for the points to track back and forth along a line: variations from that reflect nonlinearities in the time-lagged response of expansion to volume. Although there are some variations, they are pretty small. Yet, how these variations change over time may be of some physiological interest. The wonderful thing about statistics, especially its exploratory and visual aspect, is how it tends to create good questions and ideas along with useful answers.
How can I align/synchronize two signals? The question asks how to find the amount by which one time series ("expansion") lags another ("volume") when the series are sampled at regular but different intervals. In this case both series exhibit
11,662
Role of n.minobsinnode parameter of GBM in R
At each step of the GBM algorithm, a new decision tree is constructed. The question when growing a decision tree is 'when to stop?'. The furthest you can go is to split each node until there is only 1 observation in each terminal node. This would correspond to n.minobsinnode=1. Alternatively, the splitting of nodes can cease when a certain number of observations are in each node. The default for the R GBM package is 10. What is the best value to use? It depends on the data set and whether you are doing classification or regression. Since each trees' prediction is taken as the average of the dependant variable of all inputs in the terminal node, a value of 1 probably won't work so well for regression(!) but may be suitable for classification. Higher values mean smaller trees so make the algorithm run faster and use less memory, which may be a consideration. Generally, results are not very sensitive to this parameter and given the stochastic nature of GBM performance it might actually be difficult to determine exactly what value is 'the best'. The interaction depth, shrinkage and number of trees will all be much more significant in general.
Role of n.minobsinnode parameter of GBM in R
At each step of the GBM algorithm, a new decision tree is constructed. The question when growing a decision tree is 'when to stop?'. The furthest you can go is to split each node until there is only 1
Role of n.minobsinnode parameter of GBM in R At each step of the GBM algorithm, a new decision tree is constructed. The question when growing a decision tree is 'when to stop?'. The furthest you can go is to split each node until there is only 1 observation in each terminal node. This would correspond to n.minobsinnode=1. Alternatively, the splitting of nodes can cease when a certain number of observations are in each node. The default for the R GBM package is 10. What is the best value to use? It depends on the data set and whether you are doing classification or regression. Since each trees' prediction is taken as the average of the dependant variable of all inputs in the terminal node, a value of 1 probably won't work so well for regression(!) but may be suitable for classification. Higher values mean smaller trees so make the algorithm run faster and use less memory, which may be a consideration. Generally, results are not very sensitive to this parameter and given the stochastic nature of GBM performance it might actually be difficult to determine exactly what value is 'the best'. The interaction depth, shrinkage and number of trees will all be much more significant in general.
Role of n.minobsinnode parameter of GBM in R At each step of the GBM algorithm, a new decision tree is constructed. The question when growing a decision tree is 'when to stop?'. The furthest you can go is to split each node until there is only 1
11,663
Estimating gamma distribution parameters using sample mean and std
Both the MLEs and moment based estimators are consistent and so you'd expect that in sufficiently large samples from a gamma distribution they'd tend to be quite similar. However, they won't necessarily be alike when the distribution is not close to a gamma. Looking at the distribution of the log of the data, it is roughly symmetric - or indeed actually somewhat right skew. This indicates that the gamma model is inappropriate (for a gamma the log should be left skew). It may be that an inverse gamma model may perform better for these data. But the same mild right-skew in the logs would be seen with any number of other distributions -- we can't really say much for sure based on the direction of skewness on the log scale. This may be part of the explanation for why the two sets of estimates are dissimilar -- the method of moments and the MLEs won't tend to be consistent with each other. You can estimate inverse gamma parameters by inverting the data, fitting a gamma, and then keeping those parameter estimates as is. You can also estimate lognormal parameters from mean and standard deviation (several posts on site show how, or see wikipedia), but the heavier the tail of the distribution, the worse those method of moments estimators will tend to be. It seems (from comments below my answer) that the real issue is that parameter estimates must be updated "on-line" - to take only summary information, not the entire data - and update parameter estimates from the summary information. The reason for using the sample mean and variance in the question is that they can be quickly updated. However, they're not the only things that can be quickly updated! Distributions in the exponential family, where $f_{X}(x\mid \theta )=\exp \left(\eta (\theta )\cdot T(x)-A(\theta )+B(x)\right)\,$ have a sufficient statistic, $T(x)$. (NB here $\theta$ is a vector of parameters, and $T$ is vector of sufficient statistics -- of the same dimension) For all of the distributions I discuss (gamma, lognormal, inverse gamma) the sufficient statistics are easily updated. For reasons of stability, I suggest updating the following quantities (which between them are sufficient for all three distributions): the mean of the data the mean of the logs of the data the variance of the logs of the data For actual maximum likelihood, you'd use $s^2_n$ rather than the Bessel-corrected version of the variance, but it doesn't matter all that much (and if you update the Bessel-corrected version you can get the $n$-denominator version easily so it won't matter which you update). Stable variance-updates should be used. [Do not update the mean of the squares and use $\frac{1}{n}\sum x_i^2-\bar{x}^2$ to compute variance -- that's asking for trouble.] If you want to assess the suitability of the model over time, you will want to store more than sufficient statistics. Binned data might serve for that. A few hundred (say 500 or so) well chosen bins will be barely distinguishable in a plot from raw data (even in a Q-Q plot), but bin counts take little room to store and are rapidly updated. You'll probably need a much wider range of bins than you expect the data to take up, so perhaps 2000 bins total even if only a fraction of them might be used in a plot, and you'll need end-bins that cover values out to the ends of the possible range for the variable ($0$ and $\infty$). I'd suggest binning the logs rather than the original data for model assessment purposes.
Estimating gamma distribution parameters using sample mean and std
Both the MLEs and moment based estimators are consistent and so you'd expect that in sufficiently large samples from a gamma distribution they'd tend to be quite similar. However, they won't necessari
Estimating gamma distribution parameters using sample mean and std Both the MLEs and moment based estimators are consistent and so you'd expect that in sufficiently large samples from a gamma distribution they'd tend to be quite similar. However, they won't necessarily be alike when the distribution is not close to a gamma. Looking at the distribution of the log of the data, it is roughly symmetric - or indeed actually somewhat right skew. This indicates that the gamma model is inappropriate (for a gamma the log should be left skew). It may be that an inverse gamma model may perform better for these data. But the same mild right-skew in the logs would be seen with any number of other distributions -- we can't really say much for sure based on the direction of skewness on the log scale. This may be part of the explanation for why the two sets of estimates are dissimilar -- the method of moments and the MLEs won't tend to be consistent with each other. You can estimate inverse gamma parameters by inverting the data, fitting a gamma, and then keeping those parameter estimates as is. You can also estimate lognormal parameters from mean and standard deviation (several posts on site show how, or see wikipedia), but the heavier the tail of the distribution, the worse those method of moments estimators will tend to be. It seems (from comments below my answer) that the real issue is that parameter estimates must be updated "on-line" - to take only summary information, not the entire data - and update parameter estimates from the summary information. The reason for using the sample mean and variance in the question is that they can be quickly updated. However, they're not the only things that can be quickly updated! Distributions in the exponential family, where $f_{X}(x\mid \theta )=\exp \left(\eta (\theta )\cdot T(x)-A(\theta )+B(x)\right)\,$ have a sufficient statistic, $T(x)$. (NB here $\theta$ is a vector of parameters, and $T$ is vector of sufficient statistics -- of the same dimension) For all of the distributions I discuss (gamma, lognormal, inverse gamma) the sufficient statistics are easily updated. For reasons of stability, I suggest updating the following quantities (which between them are sufficient for all three distributions): the mean of the data the mean of the logs of the data the variance of the logs of the data For actual maximum likelihood, you'd use $s^2_n$ rather than the Bessel-corrected version of the variance, but it doesn't matter all that much (and if you update the Bessel-corrected version you can get the $n$-denominator version easily so it won't matter which you update). Stable variance-updates should be used. [Do not update the mean of the squares and use $\frac{1}{n}\sum x_i^2-\bar{x}^2$ to compute variance -- that's asking for trouble.] If you want to assess the suitability of the model over time, you will want to store more than sufficient statistics. Binned data might serve for that. A few hundred (say 500 or so) well chosen bins will be barely distinguishable in a plot from raw data (even in a Q-Q plot), but bin counts take little room to store and are rapidly updated. You'll probably need a much wider range of bins than you expect the data to take up, so perhaps 2000 bins total even if only a fraction of them might be used in a plot, and you'll need end-bins that cover values out to the ends of the possible range for the variable ($0$ and $\infty$). I'd suggest binning the logs rather than the original data for model assessment purposes.
Estimating gamma distribution parameters using sample mean and std Both the MLEs and moment based estimators are consistent and so you'd expect that in sufficiently large samples from a gamma distribution they'd tend to be quite similar. However, they won't necessari
11,664
Estimating gamma distribution parameters using sample mean and std
The estimates obtained this way are method of moments estimates. In particular, we know that $\mbox{E}(X) = \alpha \theta$ and $\mbox{Var}[X] = \alpha \theta^2$ for a gamma distribution with shape parameter $\alpha$ and scale parameter $\theta$ (see wikipedia). Solving these equations for $\alpha$ and $\theta$ yields $\alpha = \mbox{E}[X]^2/\mbox{Var}[X]$ and $\theta = \mbox{Var}[X] / \mbox{E}[X]$. Now substitute the sample estimates to obtain the method of moments estimates $\hat{\alpha} = \bar{x}^2 / s^2$ and $\hat{\theta} = s^2 / \bar{x}$. Those are not the MLEs (again, see wikipedia). I don't know what library you used for estimating the parameters, but typically such libraries yield MLEs. And those could be rather different than the method of moment estimates. Also, the "sum under the curve" is not quite the right thing to compute for a continuous random variable -- you really need to integrate. And regardless of what you plug in for $\alpha$ and $\theta$ (of course with the constraint that these parameters must be > 0, this must always integrate to 1. Update: After posting the data, I used R for obtaining the MLEs and method of moment estimates. This yields: > library(MASS) > fitdistr(y, dgamma, start=list(shape=1, scale=1)) shape scale 0.73684030 93.26893829 ( 0.02613277) ( 4.59104121) > mean(y)^2 / var(y) [1] 0.2468195 > var(y) / mean(y) [1] 278.3942 So, essentially the same as was obtained with Python. So, the estimates simply are just that different using maximum likelihood estimation versus the method of moments.
Estimating gamma distribution parameters using sample mean and std
The estimates obtained this way are method of moments estimates. In particular, we know that $\mbox{E}(X) = \alpha \theta$ and $\mbox{Var}[X] = \alpha \theta^2$ for a gamma distribution with shape par
Estimating gamma distribution parameters using sample mean and std The estimates obtained this way are method of moments estimates. In particular, we know that $\mbox{E}(X) = \alpha \theta$ and $\mbox{Var}[X] = \alpha \theta^2$ for a gamma distribution with shape parameter $\alpha$ and scale parameter $\theta$ (see wikipedia). Solving these equations for $\alpha$ and $\theta$ yields $\alpha = \mbox{E}[X]^2/\mbox{Var}[X]$ and $\theta = \mbox{Var}[X] / \mbox{E}[X]$. Now substitute the sample estimates to obtain the method of moments estimates $\hat{\alpha} = \bar{x}^2 / s^2$ and $\hat{\theta} = s^2 / \bar{x}$. Those are not the MLEs (again, see wikipedia). I don't know what library you used for estimating the parameters, but typically such libraries yield MLEs. And those could be rather different than the method of moment estimates. Also, the "sum under the curve" is not quite the right thing to compute for a continuous random variable -- you really need to integrate. And regardless of what you plug in for $\alpha$ and $\theta$ (of course with the constraint that these parameters must be > 0, this must always integrate to 1. Update: After posting the data, I used R for obtaining the MLEs and method of moment estimates. This yields: > library(MASS) > fitdistr(y, dgamma, start=list(shape=1, scale=1)) shape scale 0.73684030 93.26893829 ( 0.02613277) ( 4.59104121) > mean(y)^2 / var(y) [1] 0.2468195 > var(y) / mean(y) [1] 278.3942 So, essentially the same as was obtained with Python. So, the estimates simply are just that different using maximum likelihood estimation versus the method of moments.
Estimating gamma distribution parameters using sample mean and std The estimates obtained this way are method of moments estimates. In particular, we know that $\mbox{E}(X) = \alpha \theta$ and $\mbox{Var}[X] = \alpha \theta^2$ for a gamma distribution with shape par
11,665
Cross Validation (error generalization) after model selection
The key thing to remember is that for cross-validation to give an (almost) unbiased performance estimate every step involved in fitting the model must also be performed independently in each fold of the cross-validation procedure. The best thing to do is to view feature selection, meta/hyper-parameter setting and optimising the parameters as integral parts of model fitting and never do any one of these steps without doing the other two. The optimistic bias that can be introduced by departing from that recipe can be surprisingly large, as demonstrated by Cawley and Talbot, where the bias introduced by an apparently benign departure was larger than the difference in performance between competing classifiers. Worse still biased protocols favours bad models most strongly, as they are more sensitive to the tuning of hyper-parameters and hence are more prone to over-fitting the model selection criterion! Answers to specific questions: The procedure in step 1 is valid because feature selection is performed separately in each fold, so what you are cross-validating is whole procedure used to fit the final model. The cross-validation estimate will have a slight pessimistic bias as the dataset for each fold is slightly smaller than the whole dataset used for the final model. For 2, as cross-validation is used to select the model parameters then you need to repeat that procedure independently in each fold of the cross-validation used for performance estimation, you you end up with nested cross-validation. For 3, essentially, yes you need to do nested-nested cross-validation. Essentially you need to repeat in each fold of the outermost cross-validation (used for performance estimation) everything you intend to do to to fit the final model. For 4 - yes, if you have a separate hold-out set, then that will give an unbiased estimate of performance without needing an additional cross-validation.
Cross Validation (error generalization) after model selection
The key thing to remember is that for cross-validation to give an (almost) unbiased performance estimate every step involved in fitting the model must also be performed independently in each fold of t
Cross Validation (error generalization) after model selection The key thing to remember is that for cross-validation to give an (almost) unbiased performance estimate every step involved in fitting the model must also be performed independently in each fold of the cross-validation procedure. The best thing to do is to view feature selection, meta/hyper-parameter setting and optimising the parameters as integral parts of model fitting and never do any one of these steps without doing the other two. The optimistic bias that can be introduced by departing from that recipe can be surprisingly large, as demonstrated by Cawley and Talbot, where the bias introduced by an apparently benign departure was larger than the difference in performance between competing classifiers. Worse still biased protocols favours bad models most strongly, as they are more sensitive to the tuning of hyper-parameters and hence are more prone to over-fitting the model selection criterion! Answers to specific questions: The procedure in step 1 is valid because feature selection is performed separately in each fold, so what you are cross-validating is whole procedure used to fit the final model. The cross-validation estimate will have a slight pessimistic bias as the dataset for each fold is slightly smaller than the whole dataset used for the final model. For 2, as cross-validation is used to select the model parameters then you need to repeat that procedure independently in each fold of the cross-validation used for performance estimation, you you end up with nested cross-validation. For 3, essentially, yes you need to do nested-nested cross-validation. Essentially you need to repeat in each fold of the outermost cross-validation (used for performance estimation) everything you intend to do to to fit the final model. For 4 - yes, if you have a separate hold-out set, then that will give an unbiased estimate of performance without needing an additional cross-validation.
Cross Validation (error generalization) after model selection The key thing to remember is that for cross-validation to give an (almost) unbiased performance estimate every step involved in fitting the model must also be performed independently in each fold of t
11,666
Cross Validation (error generalization) after model selection
I have been doing an extensive cross-validation analysis on a data set that cost millions to acquire, and there is no external validation set available. In this case, I performed extensive nested cross validation to ensure validity. I selected features and optimized parameters only from the respective training sets. This is computationally expensive for large data sets, but it's what I had to do to maintain validity. However, there are complications that come with it...for example, different features are selected in each training set. So my answer is that in cases where you don't have feasible access to an external data set, this is a reasonable way to go. When you do have an external data set, you can pretty much go to town however you want on the main data set and then test once on the external data set.
Cross Validation (error generalization) after model selection
I have been doing an extensive cross-validation analysis on a data set that cost millions to acquire, and there is no external validation set available. In this case, I performed extensive nested cros
Cross Validation (error generalization) after model selection I have been doing an extensive cross-validation analysis on a data set that cost millions to acquire, and there is no external validation set available. In this case, I performed extensive nested cross validation to ensure validity. I selected features and optimized parameters only from the respective training sets. This is computationally expensive for large data sets, but it's what I had to do to maintain validity. However, there are complications that come with it...for example, different features are selected in each training set. So my answer is that in cases where you don't have feasible access to an external data set, this is a reasonable way to go. When you do have an external data set, you can pretty much go to town however you want on the main data set and then test once on the external data set.
Cross Validation (error generalization) after model selection I have been doing an extensive cross-validation analysis on a data set that cost millions to acquire, and there is no external validation set available. In this case, I performed extensive nested cros
11,667
What is wrong with this "naive" shuffling algorithm?
It is broken, although if you perform enough shuffles it can be an excellent approximation (as the previous answers have indicated). Just to get a handle on what's going on, consider how often your algorithm will generate shuffles of a $k$ element array in which the first element is fixed, $k \ge 2$. When permutations are generated with equal probability, this should happen $1/k$ of the time. Let $p_n$ be the relative frequency of this occurrence after $n$ shuffles with your algorithm. Let's be generous, too, and suppose you are actually selecting distinct pairs of indexes uniformly at random for your shuffles, so that each pair is selected with probability $1/{k \choose 2}$ = $2/\left( k (k-1) \right)$. (This means there are no "trivial" shuffles wasted. On the other hand, it totally breaks your algorithm for a two-element array, because you alternate between fixing the two elements and swapping them, so if you stop after a predetermined number of steps, there is no randomness to the outcome whatsoever!) This frequency satisfies a simple recurrence, because the first element is found in its original place after $n+1$ shuffles in two disjoint ways. One is that it was fixed after $n$ shuffles and the next shuffle does not move the first element. The other is that it was moved after $n$ shuffles but the $n+1^{st}$ shuffle moves it back. The chance of not moving the first element equals ${k-1 \choose 2}/{k \choose 2}$ = $(k-2)/k$, whereas the chance of moving the first element back equals $1/{k \choose 2}$ = $2/\left( k (k-1) \right)$. Whence: $$p_0 =1$$ because the first element starts out in its rightful place; $$p_{n+1} = \frac{k-2}{k} p_n + \frac{2}{k(k-1)} \left( 1 - p_n \right).$$ The solution is $$p_n = 1/k + \left( \frac{k-3}{k-1} \right) ^n \frac{k-1}{k}.$$ Subtracting $1/k$, we see that the frequency is wrong by $\left( \frac{k-3}{k-1} \right) ^n \frac{k-1}{k}$. For large $k$ and $n$, a good approximation is $\frac{k-1}{k} \exp(-\frac{2n}{k-1})$. This shows that the error in this particular frequency will decrease exponentially with the number of swaps relative to the size of the array ($n/k$), indicating it will be difficult to detect with large arrays if you have made a relatively large number of swaps--but the error is always there. It is difficult to provide a comprehensive analysis of the errors in all frequencies. It's likely they will behave like this one, though, which shows that at a minimum you would need $n$ (the number of swaps) to be large enough to make the error acceptably small. An approximate solution is $$n \gt \frac{1}{2} \left(1 - (k-1) \log(\epsilon) \right)$$ where $\epsilon$ should be very small compared to $1/k$. This implies $n$ should be several times $k$ for even crude approximations (i.e., where $\epsilon$ is on the order of $0.01$ times $1/k$ or so.) All this begs the question: why would you choose to use an algorithm that is not quite (but only approximately) correct, employs exactly the same techniques as another algorithm that is provably correct, and yet which requires more computation? Edit Thilo's comment is apt (and I was hoping nobody would point this out, so I could be spared this extra work!). Let me explain the logic. If you make sure to generate actual swaps each time, you're utterly screwed. The problem I pointed out for the case $k=2$ extends to all arrays. Only half of all the possible permutations can be obtained by applying an even number of swaps; the other half is obtained by applying an odd number of swaps. Thus, in this situation, you can never generate anywhere near a uniform distribution of permutations (but there are so many possible ones that a simulation study for any sizable $k$ will be unable to detect the problem). That's really bad. Therefore it is wise to generate swaps at random by generating the two positions independently at random. This means there is a $1/k$ chance each time of swapping an element with itself; that is, of doing nothing. This process effectively slows down the algorithm a little bit: after $n$ steps, we expect only about $\frac{k-1}{k} N \lt N$ true swaps to have occurred. Notice that the size of the error decreases monotonically with the number of distinct swaps. Therefore, conducting fewer swaps on average also increases the error, on average. But this is a price you should be willing to pay in order to overcome the problem described in the first bullet. Consequently, my error estimate is conservatively low, approximately by a factor of $(k-1)/k$. I also wanted to point out an interesting apparent exception: a close look at the error formula suggests that there is no error in the case $k=3$. This is not a mistake: it is correct. However, here I have examined only one statistic related to the uniform distribution of permutations. The fact that the algorithm can reproduce this one statistic when $k=3$ (namely, getting the right frequency of permutations that fix any given position) does not guarantee the permutations have indeed been distributed uniformly. Indeed, after $2n$ actual swaps, the only possible permutations that can be generated are $(123)$, $(321)$, and the identity. Only the latter fixes any given position, so indeed exactly one-third of the permutations fix a position. But half the permutations are missing! In the other case, after $2n+1$ actual swaps, the only possible permutations are $(12)$, $(23)$, and $(13)$. Again, exactly one of these will fix any given position, so again we obtain the correct frequency of permutations fixing that position, but again we obtain only half of the possible permutations. This little example helps reveal the main strands of the argument: by being "generous" we conservatively underestimate the error rate for one particular statistic. Because that error rate is nonzero for all $k \ge 4$, we see that the algorithm is broken. Furthermore, by analyzing the decay in the error rate for this statistic we establish a lower bound on the number of iterations of the algorithm needed to have any hope at all of approximating a uniform distribution of permutations.
What is wrong with this "naive" shuffling algorithm?
It is broken, although if you perform enough shuffles it can be an excellent approximation (as the previous answers have indicated). Just to get a handle on what's going on, consider how often your al
What is wrong with this "naive" shuffling algorithm? It is broken, although if you perform enough shuffles it can be an excellent approximation (as the previous answers have indicated). Just to get a handle on what's going on, consider how often your algorithm will generate shuffles of a $k$ element array in which the first element is fixed, $k \ge 2$. When permutations are generated with equal probability, this should happen $1/k$ of the time. Let $p_n$ be the relative frequency of this occurrence after $n$ shuffles with your algorithm. Let's be generous, too, and suppose you are actually selecting distinct pairs of indexes uniformly at random for your shuffles, so that each pair is selected with probability $1/{k \choose 2}$ = $2/\left( k (k-1) \right)$. (This means there are no "trivial" shuffles wasted. On the other hand, it totally breaks your algorithm for a two-element array, because you alternate between fixing the two elements and swapping them, so if you stop after a predetermined number of steps, there is no randomness to the outcome whatsoever!) This frequency satisfies a simple recurrence, because the first element is found in its original place after $n+1$ shuffles in two disjoint ways. One is that it was fixed after $n$ shuffles and the next shuffle does not move the first element. The other is that it was moved after $n$ shuffles but the $n+1^{st}$ shuffle moves it back. The chance of not moving the first element equals ${k-1 \choose 2}/{k \choose 2}$ = $(k-2)/k$, whereas the chance of moving the first element back equals $1/{k \choose 2}$ = $2/\left( k (k-1) \right)$. Whence: $$p_0 =1$$ because the first element starts out in its rightful place; $$p_{n+1} = \frac{k-2}{k} p_n + \frac{2}{k(k-1)} \left( 1 - p_n \right).$$ The solution is $$p_n = 1/k + \left( \frac{k-3}{k-1} \right) ^n \frac{k-1}{k}.$$ Subtracting $1/k$, we see that the frequency is wrong by $\left( \frac{k-3}{k-1} \right) ^n \frac{k-1}{k}$. For large $k$ and $n$, a good approximation is $\frac{k-1}{k} \exp(-\frac{2n}{k-1})$. This shows that the error in this particular frequency will decrease exponentially with the number of swaps relative to the size of the array ($n/k$), indicating it will be difficult to detect with large arrays if you have made a relatively large number of swaps--but the error is always there. It is difficult to provide a comprehensive analysis of the errors in all frequencies. It's likely they will behave like this one, though, which shows that at a minimum you would need $n$ (the number of swaps) to be large enough to make the error acceptably small. An approximate solution is $$n \gt \frac{1}{2} \left(1 - (k-1) \log(\epsilon) \right)$$ where $\epsilon$ should be very small compared to $1/k$. This implies $n$ should be several times $k$ for even crude approximations (i.e., where $\epsilon$ is on the order of $0.01$ times $1/k$ or so.) All this begs the question: why would you choose to use an algorithm that is not quite (but only approximately) correct, employs exactly the same techniques as another algorithm that is provably correct, and yet which requires more computation? Edit Thilo's comment is apt (and I was hoping nobody would point this out, so I could be spared this extra work!). Let me explain the logic. If you make sure to generate actual swaps each time, you're utterly screwed. The problem I pointed out for the case $k=2$ extends to all arrays. Only half of all the possible permutations can be obtained by applying an even number of swaps; the other half is obtained by applying an odd number of swaps. Thus, in this situation, you can never generate anywhere near a uniform distribution of permutations (but there are so many possible ones that a simulation study for any sizable $k$ will be unable to detect the problem). That's really bad. Therefore it is wise to generate swaps at random by generating the two positions independently at random. This means there is a $1/k$ chance each time of swapping an element with itself; that is, of doing nothing. This process effectively slows down the algorithm a little bit: after $n$ steps, we expect only about $\frac{k-1}{k} N \lt N$ true swaps to have occurred. Notice that the size of the error decreases monotonically with the number of distinct swaps. Therefore, conducting fewer swaps on average also increases the error, on average. But this is a price you should be willing to pay in order to overcome the problem described in the first bullet. Consequently, my error estimate is conservatively low, approximately by a factor of $(k-1)/k$. I also wanted to point out an interesting apparent exception: a close look at the error formula suggests that there is no error in the case $k=3$. This is not a mistake: it is correct. However, here I have examined only one statistic related to the uniform distribution of permutations. The fact that the algorithm can reproduce this one statistic when $k=3$ (namely, getting the right frequency of permutations that fix any given position) does not guarantee the permutations have indeed been distributed uniformly. Indeed, after $2n$ actual swaps, the only possible permutations that can be generated are $(123)$, $(321)$, and the identity. Only the latter fixes any given position, so indeed exactly one-third of the permutations fix a position. But half the permutations are missing! In the other case, after $2n+1$ actual swaps, the only possible permutations are $(12)$, $(23)$, and $(13)$. Again, exactly one of these will fix any given position, so again we obtain the correct frequency of permutations fixing that position, but again we obtain only half of the possible permutations. This little example helps reveal the main strands of the argument: by being "generous" we conservatively underestimate the error rate for one particular statistic. Because that error rate is nonzero for all $k \ge 4$, we see that the algorithm is broken. Furthermore, by analyzing the decay in the error rate for this statistic we establish a lower bound on the number of iterations of the algorithm needed to have any hope at all of approximating a uniform distribution of permutations.
What is wrong with this "naive" shuffling algorithm? It is broken, although if you perform enough shuffles it can be an excellent approximation (as the previous answers have indicated). Just to get a handle on what's going on, consider how often your al
11,668
What is wrong with this "naive" shuffling algorithm?
I think your simple algorithm will shuffle the cards correctly as the number shuffles tends to infinity. Suppose you have three cards: {A,B,C}. Assume that your cards begin in the following order: A,B,C. Then after one shuffle you have following combinations: {A,B,C}, {A,B,C}, {A,B,C} #You get this if choose the same RN twice. {A,C,B}, {A,C,B} {C,B,A}, {C,B,A} {B,A,C}, {B,A,C} Hence, the probability of card A of being in position {1,2,3} is {5/9, 2/9, 2/9}. If we shuffle the cards a second time, then: Pr(A in position 1 after 2 shuffles) = 5/9*Pr(A in position 1 after 1 shuffle) + 2/9*Pr(A in position 2 after 1 shuffle) + 2/9*Pr(A in position 3 after 1 shuffle) This gives 0.407. Using the same idea, we can form a recurrence relationship, i.e: Pr(A in position 1 after n shuffles) = 5/9*Pr(A in position 1 after (n-1) shuffles) + 2/9*Pr(A in position 2 after (n-1) shuffles) + 2/9*Pr(A in position 3 after (n-1) shuffles). Coding this up in R (see code below), gives probability of card A of being in position {1,2,3} as {0.33334, 0.33333, 0.33333} after ten shuffles. R code ## m is the probability matrix of card position ## Row is position ## Col is card A, B, C m = matrix(0, nrow=3, ncol=3) m[1,1] = 1; m[2,2] = 1; m[3,3] = 1 ## Transition matrix m_trans = matrix(2/9, nrow=3, ncol=3) m_trans[1,1] = 5/9; m_trans[2,2] = 5/9; m_trans[3,3] = 5/9 for(i in 1:10){ old_m = m m[1,1] = sum(m_trans[,1]*old_m[,1]) m[2,1] = sum(m_trans[,2]*old_m[,1]) m[3,1] = sum(m_trans[,3]*old_m[,1]) m[1,2] = sum(m_trans[,1]*old_m[,2]) m[2,2] = sum(m_trans[,2]*old_m[,2]) m[3,2] = sum(m_trans[,3]*old_m[,2]) m[1,3] = sum(m_trans[,1]*old_m[,3]) m[2,3] = sum(m_trans[,2]*old_m[,3]) m[3,3] = sum(m_trans[,3]*old_m[,3]) } m
What is wrong with this "naive" shuffling algorithm?
I think your simple algorithm will shuffle the cards correctly as the number shuffles tends to infinity. Suppose you have three cards: {A,B,C}. Assume that your cards begin in the following order: A,B
What is wrong with this "naive" shuffling algorithm? I think your simple algorithm will shuffle the cards correctly as the number shuffles tends to infinity. Suppose you have three cards: {A,B,C}. Assume that your cards begin in the following order: A,B,C. Then after one shuffle you have following combinations: {A,B,C}, {A,B,C}, {A,B,C} #You get this if choose the same RN twice. {A,C,B}, {A,C,B} {C,B,A}, {C,B,A} {B,A,C}, {B,A,C} Hence, the probability of card A of being in position {1,2,3} is {5/9, 2/9, 2/9}. If we shuffle the cards a second time, then: Pr(A in position 1 after 2 shuffles) = 5/9*Pr(A in position 1 after 1 shuffle) + 2/9*Pr(A in position 2 after 1 shuffle) + 2/9*Pr(A in position 3 after 1 shuffle) This gives 0.407. Using the same idea, we can form a recurrence relationship, i.e: Pr(A in position 1 after n shuffles) = 5/9*Pr(A in position 1 after (n-1) shuffles) + 2/9*Pr(A in position 2 after (n-1) shuffles) + 2/9*Pr(A in position 3 after (n-1) shuffles). Coding this up in R (see code below), gives probability of card A of being in position {1,2,3} as {0.33334, 0.33333, 0.33333} after ten shuffles. R code ## m is the probability matrix of card position ## Row is position ## Col is card A, B, C m = matrix(0, nrow=3, ncol=3) m[1,1] = 1; m[2,2] = 1; m[3,3] = 1 ## Transition matrix m_trans = matrix(2/9, nrow=3, ncol=3) m_trans[1,1] = 5/9; m_trans[2,2] = 5/9; m_trans[3,3] = 5/9 for(i in 1:10){ old_m = m m[1,1] = sum(m_trans[,1]*old_m[,1]) m[2,1] = sum(m_trans[,2]*old_m[,1]) m[3,1] = sum(m_trans[,3]*old_m[,1]) m[1,2] = sum(m_trans[,1]*old_m[,2]) m[2,2] = sum(m_trans[,2]*old_m[,2]) m[3,2] = sum(m_trans[,3]*old_m[,2]) m[1,3] = sum(m_trans[,1]*old_m[,3]) m[2,3] = sum(m_trans[,2]*old_m[,3]) m[3,3] = sum(m_trans[,3]*old_m[,3]) } m
What is wrong with this "naive" shuffling algorithm? I think your simple algorithm will shuffle the cards correctly as the number shuffles tends to infinity. Suppose you have three cards: {A,B,C}. Assume that your cards begin in the following order: A,B
11,669
What is wrong with this "naive" shuffling algorithm?
One way to see that you won't get a perfectly uniform distribution is by divisibility. In the uniform distribution, the probability of each permutation is $1/n!$. When you generate a sequence of $t$ random transpositions, and then collect sequences by their product, the probabilities you get are of the form $A/n^{2t}$ for some integer $A$. If $1/n! = A/n^{2t}$, then $n^{2t}/n! = A$. By Bertrand's Postulate (a theorem), for $n \ge 3$ there are primes which occur in the denominator and which do not divide $n$, so $n^{2t}/n!$ is not an integer, and there isn't a way to divide the transpositions evenly into $n!$ permutations. For example, if $n=52$, then the denominator of $1/52!$ is divisible by $3, 5, 7, ..., 47$ while the denominator of $1/52^{2t}$ is not, so $A/52^{2t}$ can't reduce to $1/52!$. How many do you need to approximate a random permutation well? Generating a random permutation by random transpositions was analyzed by Diaconis and Shahshahani using representation theory of the symmetric group in Diaconis, P., Shahshahani, M. (1981): "Generating a random permutation with random transpositions." Z. Wahrsch. Verw. Geb. 57, 159–179. One conclusion was that it takes $\frac 12 n \log n$ transpositions in the sense that after $(1-\epsilon) \frac12 n \log n$ the permutations are far from random, but after $(1+\epsilon) \frac 12 n \log n$ the result is close to random, both in the sense of total variation and $L^2$ distance. This type of cutoff phenomenon is common in random walks on groups, and is related to the famous result that you need $7$ riffle shuffles before a deck becomes close to random.
What is wrong with this "naive" shuffling algorithm?
One way to see that you won't get a perfectly uniform distribution is by divisibility. In the uniform distribution, the probability of each permutation is $1/n!$. When you generate a sequence of $t$ r
What is wrong with this "naive" shuffling algorithm? One way to see that you won't get a perfectly uniform distribution is by divisibility. In the uniform distribution, the probability of each permutation is $1/n!$. When you generate a sequence of $t$ random transpositions, and then collect sequences by their product, the probabilities you get are of the form $A/n^{2t}$ for some integer $A$. If $1/n! = A/n^{2t}$, then $n^{2t}/n! = A$. By Bertrand's Postulate (a theorem), for $n \ge 3$ there are primes which occur in the denominator and which do not divide $n$, so $n^{2t}/n!$ is not an integer, and there isn't a way to divide the transpositions evenly into $n!$ permutations. For example, if $n=52$, then the denominator of $1/52!$ is divisible by $3, 5, 7, ..., 47$ while the denominator of $1/52^{2t}$ is not, so $A/52^{2t}$ can't reduce to $1/52!$. How many do you need to approximate a random permutation well? Generating a random permutation by random transpositions was analyzed by Diaconis and Shahshahani using representation theory of the symmetric group in Diaconis, P., Shahshahani, M. (1981): "Generating a random permutation with random transpositions." Z. Wahrsch. Verw. Geb. 57, 159–179. One conclusion was that it takes $\frac 12 n \log n$ transpositions in the sense that after $(1-\epsilon) \frac12 n \log n$ the permutations are far from random, but after $(1+\epsilon) \frac 12 n \log n$ the result is close to random, both in the sense of total variation and $L^2$ distance. This type of cutoff phenomenon is common in random walks on groups, and is related to the famous result that you need $7$ riffle shuffles before a deck becomes close to random.
What is wrong with this "naive" shuffling algorithm? One way to see that you won't get a perfectly uniform distribution is by divisibility. In the uniform distribution, the probability of each permutation is $1/n!$. When you generate a sequence of $t$ r
11,670
What is wrong with this "naive" shuffling algorithm?
Bear in mind I am not a statistician, but I'll put my 2cents. I made a little test in R (careful, it's very slow for high numTrials, the code can probably be optimized): numElements <- 1000 numTrials <- 5000 swapVec <- function() { vec.swp <- vec for (i in 1:numElements) { i <- sample(1:numElements) j <- sample(1:numElements) tmp <- vec.swp[i] vec.swp[i] <- vec.swp[j] vec.swp[j] <- tmp } return (vec.swp) } # Create a normally distributed array of numElements length vec <- rnorm(numElements) # Do several "swapping trials" so we can make some stats on them swaps <- vec prog <- txtProgressBar(0, numTrials, style=3) for (t in 1:numTrials) { swaps <- rbind(swaps, swapVec()) setTxtProgressBar(prog, t) } This will generate a matrix swaps with numTrials+1 rows (one per trial + the original) and numElements columns (one per each vector element). If the method is correct the distribution of each column (i.e. of the values for each element over the trials) should not be different from the distribution of the original data. Because our original data was normally distributed we would expect all the columns not to deviate from that. If we run par(mfrow= c(2,2)) # Our original data hist(swaps[1,], 100, col="black", freq=FALSE, main="Original") # Three "randomly" chosen columns hist(swaps[,1], 100, col="black", freq=FALSE, main="Trial # 1") hist(swaps[,257], 100, col="black", freq=FALSE, main="Trial # 257") hist(swaps[,844], 100, col="black", freq=FALSE, main="Trial # 844") We get: which looks very promising. Now, if we want to statistically confirm the distributions do not deviate from the original I think we could use a Kolmogorov-Smirnov test (please can some statistician confirm this is right?) and do, for instance ks.test(swaps[1, ], swaps[, 234]) Which gives us p=0.9926 If we check all of the columns: ks.results <- apply(swaps, 2, function(col){ks.test(swaps[1,], col)}) p.values <- unlist(lapply(ks.results, function(x){x$p.value}) And we run hist(p.values, 100, col="black") we get: So, for the great majority of the elements of the array, your swap method has given a good result, as you can also see looking at the quartiles. 1> quantile(p.values) 0% 25% 50% 75% 100% 0.6819832 0.9963731 0.9999188 0.9999996 1.0000000 Note that, obviously, with a lower number of trials the situation is not as good: 50 trials 1> quantile(p.values) 0% 25% 50% 75% 100% 0.0003399635 0.2920976389 0.5583204486 0.8103852744 0.9999165730 100 trials 0% 25% 50% 75% 100% 0.001434198 0.327553996 0.596603804 0.828037097 0.999999591 500 trials 0% 25% 50% 75% 100% 0.007834701 0.504698404 0.764231550 0.934223503 0.999995887
What is wrong with this "naive" shuffling algorithm?
Bear in mind I am not a statistician, but I'll put my 2cents. I made a little test in R (careful, it's very slow for high numTrials, the code can probably be optimized): numElements <- 1000 numTrials
What is wrong with this "naive" shuffling algorithm? Bear in mind I am not a statistician, but I'll put my 2cents. I made a little test in R (careful, it's very slow for high numTrials, the code can probably be optimized): numElements <- 1000 numTrials <- 5000 swapVec <- function() { vec.swp <- vec for (i in 1:numElements) { i <- sample(1:numElements) j <- sample(1:numElements) tmp <- vec.swp[i] vec.swp[i] <- vec.swp[j] vec.swp[j] <- tmp } return (vec.swp) } # Create a normally distributed array of numElements length vec <- rnorm(numElements) # Do several "swapping trials" so we can make some stats on them swaps <- vec prog <- txtProgressBar(0, numTrials, style=3) for (t in 1:numTrials) { swaps <- rbind(swaps, swapVec()) setTxtProgressBar(prog, t) } This will generate a matrix swaps with numTrials+1 rows (one per trial + the original) and numElements columns (one per each vector element). If the method is correct the distribution of each column (i.e. of the values for each element over the trials) should not be different from the distribution of the original data. Because our original data was normally distributed we would expect all the columns not to deviate from that. If we run par(mfrow= c(2,2)) # Our original data hist(swaps[1,], 100, col="black", freq=FALSE, main="Original") # Three "randomly" chosen columns hist(swaps[,1], 100, col="black", freq=FALSE, main="Trial # 1") hist(swaps[,257], 100, col="black", freq=FALSE, main="Trial # 257") hist(swaps[,844], 100, col="black", freq=FALSE, main="Trial # 844") We get: which looks very promising. Now, if we want to statistically confirm the distributions do not deviate from the original I think we could use a Kolmogorov-Smirnov test (please can some statistician confirm this is right?) and do, for instance ks.test(swaps[1, ], swaps[, 234]) Which gives us p=0.9926 If we check all of the columns: ks.results <- apply(swaps, 2, function(col){ks.test(swaps[1,], col)}) p.values <- unlist(lapply(ks.results, function(x){x$p.value}) And we run hist(p.values, 100, col="black") we get: So, for the great majority of the elements of the array, your swap method has given a good result, as you can also see looking at the quartiles. 1> quantile(p.values) 0% 25% 50% 75% 100% 0.6819832 0.9963731 0.9999188 0.9999996 1.0000000 Note that, obviously, with a lower number of trials the situation is not as good: 50 trials 1> quantile(p.values) 0% 25% 50% 75% 100% 0.0003399635 0.2920976389 0.5583204486 0.8103852744 0.9999165730 100 trials 0% 25% 50% 75% 100% 0.001434198 0.327553996 0.596603804 0.828037097 0.999999591 500 trials 0% 25% 50% 75% 100% 0.007834701 0.504698404 0.764231550 0.934223503 0.999995887
What is wrong with this "naive" shuffling algorithm? Bear in mind I am not a statistician, but I'll put my 2cents. I made a little test in R (careful, it's very slow for high numTrials, the code can probably be optimized): numElements <- 1000 numTrials
11,671
What is wrong with this "naive" shuffling algorithm?
Here's how I am interpreting your algorithm, in pseudo code: void shuffle(array, length, num_passes) for (pass = 0; pass < num_passes; ++pass) for (n = 0; n < length; ++) i = random_in(0, length-1) j = random_in(0, lenght-1) swap(array[i], array[j] We can associate a run of this algorithm with a list of $2 \times length \times num\_passes$ integers, namely the integers returned by random_in() as the program runs. Each of these integers is in $[0, length-1]$, and so has $length$ possible values. Call one of these lists a trace of the program. That means there are $length ^ {2 \times length \times num\_passes}$ such traces, and each trace is equally likely. We can also associate with each trace a permutation of the array. Namely, the permutation at the end of the run associated with the trace. There are $length !$ possible permutations. $length ! < length ^ {2 \times length \times num\_passes}$ so in general a given permutation is associated with more than one trace. Remember, the traces are all equally likely, so for all permutations to be equally likely, any two permutations must be associated with the same number of traces. If that is true, then we must have $length ! \bigm| length ^ {2 \times length \times num\_passes}$. Pick any prime $p$ such that $p < length$, but such that $p \nmid length$, which you can do for any $length > 2$. Then $p \bigm| length!$ but does not divide $length ^ {2 \times length \times num\_passes}$. It follows that $length ! \nmid length ^ {2 \times length \times num\_passes}$ and so all permutations cannot be equally likely if $length > 2$. Does such a prime exist? Yes. If $length$ were divisible by all primes $p < length$, then $length-1$ must be prime, but then $length-1$ would be such a prime that is less than but does not divide $length$. Compare this to Fisher-Yates. In the first iteration, you make a choice among $length$ options. The second iteration has $length-1$ options, and so on. In other words you have $length !$ traces, and $length! \bigm| length!$. It's not hard to show that each trace results in a different permutation, and from there it is easy to see that Fisher-Yates generates each permutation with equal probability.
What is wrong with this "naive" shuffling algorithm?
Here's how I am interpreting your algorithm, in pseudo code: void shuffle(array, length, num_passes) for (pass = 0; pass < num_passes; ++pass) for (n = 0; n < length; ++) i = random_in(0,
What is wrong with this "naive" shuffling algorithm? Here's how I am interpreting your algorithm, in pseudo code: void shuffle(array, length, num_passes) for (pass = 0; pass < num_passes; ++pass) for (n = 0; n < length; ++) i = random_in(0, length-1) j = random_in(0, lenght-1) swap(array[i], array[j] We can associate a run of this algorithm with a list of $2 \times length \times num\_passes$ integers, namely the integers returned by random_in() as the program runs. Each of these integers is in $[0, length-1]$, and so has $length$ possible values. Call one of these lists a trace of the program. That means there are $length ^ {2 \times length \times num\_passes}$ such traces, and each trace is equally likely. We can also associate with each trace a permutation of the array. Namely, the permutation at the end of the run associated with the trace. There are $length !$ possible permutations. $length ! < length ^ {2 \times length \times num\_passes}$ so in general a given permutation is associated with more than one trace. Remember, the traces are all equally likely, so for all permutations to be equally likely, any two permutations must be associated with the same number of traces. If that is true, then we must have $length ! \bigm| length ^ {2 \times length \times num\_passes}$. Pick any prime $p$ such that $p < length$, but such that $p \nmid length$, which you can do for any $length > 2$. Then $p \bigm| length!$ but does not divide $length ^ {2 \times length \times num\_passes}$. It follows that $length ! \nmid length ^ {2 \times length \times num\_passes}$ and so all permutations cannot be equally likely if $length > 2$. Does such a prime exist? Yes. If $length$ were divisible by all primes $p < length$, then $length-1$ must be prime, but then $length-1$ would be such a prime that is less than but does not divide $length$. Compare this to Fisher-Yates. In the first iteration, you make a choice among $length$ options. The second iteration has $length-1$ options, and so on. In other words you have $length !$ traces, and $length! \bigm| length!$. It's not hard to show that each trace results in a different permutation, and from there it is easy to see that Fisher-Yates generates each permutation with equal probability.
What is wrong with this "naive" shuffling algorithm? Here's how I am interpreting your algorithm, in pseudo code: void shuffle(array, length, num_passes) for (pass = 0; pass < num_passes; ++pass) for (n = 0; n < length; ++) i = random_in(0,
11,672
GEE: choosing proper working correlation structure
Not necessarily. With small clusters, imbalanced design, and incomplete within-cluster confounder adjustment, exchangeable correlation may be more inefficient and biased relative than independence GEE. Those assumptions can be rather strong, too. However, when those assumptions are met, you get more efficient inference with the exchangeable. I have never found an instance when AR-1 correlation structures make sense, since it's uncommon to have measurements that are balanced in time (I work with human subjects data). Well, exploring correlation is good and should be done in data analysis. However, it really shouldn't guide decision making. You can use variograms and lorellograms to visualize correlation in longitudinal and panel studies. Intracluster correlation is a good measurement of the extent of correlation within clusters. Correlation structure in GEE, unlike mixed models, does not affect the marginal parameter estimates (which you are estimating with GEE). It does affect the standard error estimates though. This is independent of any link function. The link function in the GEE is for the marginal model. Sites can be sources of unmeasured variation, such as teeth within a mouth, or students within a school district. There is the potential for cluster level confounders in these data, such as genetic propensity to tooth decay or community education funding, so for that reason, you will get better standard error estimates by using an exchangeable correlation structure. Calculation of marginal effects in a GEE is complicated when they're not nested but it can be done. Nesting is easy, and you do just as you've said.
GEE: choosing proper working correlation structure
Not necessarily. With small clusters, imbalanced design, and incomplete within-cluster confounder adjustment, exchangeable correlation may be more inefficient and biased relative than independence GEE
GEE: choosing proper working correlation structure Not necessarily. With small clusters, imbalanced design, and incomplete within-cluster confounder adjustment, exchangeable correlation may be more inefficient and biased relative than independence GEE. Those assumptions can be rather strong, too. However, when those assumptions are met, you get more efficient inference with the exchangeable. I have never found an instance when AR-1 correlation structures make sense, since it's uncommon to have measurements that are balanced in time (I work with human subjects data). Well, exploring correlation is good and should be done in data analysis. However, it really shouldn't guide decision making. You can use variograms and lorellograms to visualize correlation in longitudinal and panel studies. Intracluster correlation is a good measurement of the extent of correlation within clusters. Correlation structure in GEE, unlike mixed models, does not affect the marginal parameter estimates (which you are estimating with GEE). It does affect the standard error estimates though. This is independent of any link function. The link function in the GEE is for the marginal model. Sites can be sources of unmeasured variation, such as teeth within a mouth, or students within a school district. There is the potential for cluster level confounders in these data, such as genetic propensity to tooth decay or community education funding, so for that reason, you will get better standard error estimates by using an exchangeable correlation structure. Calculation of marginal effects in a GEE is complicated when they're not nested but it can be done. Nesting is easy, and you do just as you've said.
GEE: choosing proper working correlation structure Not necessarily. With small clusters, imbalanced design, and incomplete within-cluster confounder adjustment, exchangeable correlation may be more inefficient and biased relative than independence GEE
11,673
GEE: choosing proper working correlation structure
(1) You will likely need some kind of autoregressive structure, simply because we expect measurements taken further apart to be less correlated than those taken closer together. Exchangeable would assume they are all equally correlated. But as with everything else, it depends. (2) I think this kind of decision comes down to thinking about how the data were generated, rather than seeing how they look. (4) it depends. For example, kids nested in schools should not, in most cases, be treated as independent. Due to social patterning, etc, if I know something about a kid in a given school, then I probably know at least a little bit about other kids in the schools. I once used GEE to look at relationships between different social and economic indicators and obesity prevalence in a birth cohort where participants were nested in neighborhoods. I used an exchangeable structure. You can find the paper here and check some of the references, including 2 from epi journals. (5) Apparently so (e.g. see this example), but I can't help with the R specfics of doing this. Zeger SL, Liang KY, Albert PS. Models for longitudinal data: a generalized estimating equation approach. Biometrics. 1988;44:1049–60. Hubbard AE, Ahern J, Fleischer N, van der Laan M, Lippman S, Bruckner T, Satariano W. To GEE or not to GEE: comparing estimating function and likelihood-based methods for estimating the associations between neighborhoods and health. Epidemiology. 2009 Hanley JA, Negassa A, Edwardes MDB, Forrester JE. Statistical analysis of correlated data using generalized estimating equations: an orientation. Am J Epidemiol. 2003;157:364.
GEE: choosing proper working correlation structure
(1) You will likely need some kind of autoregressive structure, simply because we expect measurements taken further apart to be less correlated than those taken closer together. Exchangeable would ass
GEE: choosing proper working correlation structure (1) You will likely need some kind of autoregressive structure, simply because we expect measurements taken further apart to be less correlated than those taken closer together. Exchangeable would assume they are all equally correlated. But as with everything else, it depends. (2) I think this kind of decision comes down to thinking about how the data were generated, rather than seeing how they look. (4) it depends. For example, kids nested in schools should not, in most cases, be treated as independent. Due to social patterning, etc, if I know something about a kid in a given school, then I probably know at least a little bit about other kids in the schools. I once used GEE to look at relationships between different social and economic indicators and obesity prevalence in a birth cohort where participants were nested in neighborhoods. I used an exchangeable structure. You can find the paper here and check some of the references, including 2 from epi journals. (5) Apparently so (e.g. see this example), but I can't help with the R specfics of doing this. Zeger SL, Liang KY, Albert PS. Models for longitudinal data: a generalized estimating equation approach. Biometrics. 1988;44:1049–60. Hubbard AE, Ahern J, Fleischer N, van der Laan M, Lippman S, Bruckner T, Satariano W. To GEE or not to GEE: comparing estimating function and likelihood-based methods for estimating the associations between neighborhoods and health. Epidemiology. 2009 Hanley JA, Negassa A, Edwardes MDB, Forrester JE. Statistical analysis of correlated data using generalized estimating equations: an orientation. Am J Epidemiol. 2003;157:364.
GEE: choosing proper working correlation structure (1) You will likely need some kind of autoregressive structure, simply because we expect measurements taken further apart to be less correlated than those taken closer together. Exchangeable would ass
11,674
GEE: choosing proper working correlation structure
(0) General comments: most of the models I see on crossvalidated are far too complicated. Simplify if at all possible. It is often worth modeling with GEE and mixed model to compare results. (1) Yes. Choose exchangeable. My unambiguous answer is based on the most widely touted benefit of GEE: resilience of estimates to assumptions made. If you look at studies in your field you should see that exch is the default option. It doesn't mean it is the best, but should be the first to consider. Advising exch will be the best advise without having detailed knowledge of your data. (2) Yes, there are data driven approaches such as "QIC". This is a Stata example, but widely accepted as a reasonable option, though very rarely used in practice: http://www.stata-journal.com/sjpdf.html?articlenum=st0126) (3) Point estimates are never the exact same (unless you are using indep correlation structure), but are usually fairly close. You can find many articles comparing simple/gee/mixed effects model estimates to get a feel for this (https://recherche.univ-lyon2.fr/greps/IMG/pdf/JEBS.pdf) Most textbooks also have a table or two for this. For an independent correlation structure you are essentially running the poisson model with robust SEs. So the estimates will be the exact same. The SE are usually larger. But sometimes robust SE are smaller (that is life: google with provide pain free explanation if interested) (4) See (1) and (2) above. (5) No. Or better stated, you can do anything if you put enough effort into it but it is very rarely worth the effort.
GEE: choosing proper working correlation structure
(0) General comments: most of the models I see on crossvalidated are far too complicated. Simplify if at all possible. It is often worth modeling with GEE and mixed model to compare results. (1) Yes.
GEE: choosing proper working correlation structure (0) General comments: most of the models I see on crossvalidated are far too complicated. Simplify if at all possible. It is often worth modeling with GEE and mixed model to compare results. (1) Yes. Choose exchangeable. My unambiguous answer is based on the most widely touted benefit of GEE: resilience of estimates to assumptions made. If you look at studies in your field you should see that exch is the default option. It doesn't mean it is the best, but should be the first to consider. Advising exch will be the best advise without having detailed knowledge of your data. (2) Yes, there are data driven approaches such as "QIC". This is a Stata example, but widely accepted as a reasonable option, though very rarely used in practice: http://www.stata-journal.com/sjpdf.html?articlenum=st0126) (3) Point estimates are never the exact same (unless you are using indep correlation structure), but are usually fairly close. You can find many articles comparing simple/gee/mixed effects model estimates to get a feel for this (https://recherche.univ-lyon2.fr/greps/IMG/pdf/JEBS.pdf) Most textbooks also have a table or two for this. For an independent correlation structure you are essentially running the poisson model with robust SEs. So the estimates will be the exact same. The SE are usually larger. But sometimes robust SE are smaller (that is life: google with provide pain free explanation if interested) (4) See (1) and (2) above. (5) No. Or better stated, you can do anything if you put enough effort into it but it is very rarely worth the effort.
GEE: choosing proper working correlation structure (0) General comments: most of the models I see on crossvalidated are far too complicated. Simplify if at all possible. It is often worth modeling with GEE and mixed model to compare results. (1) Yes.
11,675
GEE: choosing proper working correlation structure
You're using the wrong approach with a gee to do what you are doing because you don't know the structure and your results will be likely confounded. Refer to Jamie Robinson this. You need to use long. TMLE (mark van der laan) or perhaps a gee with iptw weights. Not accounting for correlation does underestimate variance. Just think if all repeated measures were 100% correlated, then you would effectively have way fewer observations (essentially only n for your n subjects) and smaller n means higher variance.
GEE: choosing proper working correlation structure
You're using the wrong approach with a gee to do what you are doing because you don't know the structure and your results will be likely confounded. Refer to Jamie Robinson this. You need to use long
GEE: choosing proper working correlation structure You're using the wrong approach with a gee to do what you are doing because you don't know the structure and your results will be likely confounded. Refer to Jamie Robinson this. You need to use long. TMLE (mark van der laan) or perhaps a gee with iptw weights. Not accounting for correlation does underestimate variance. Just think if all repeated measures were 100% correlated, then you would effectively have way fewer observations (essentially only n for your n subjects) and smaller n means higher variance.
GEE: choosing proper working correlation structure You're using the wrong approach with a gee to do what you are doing because you don't know the structure and your results will be likely confounded. Refer to Jamie Robinson this. You need to use long
11,676
Stepwise AIC - Does there exist controversy surrounding this topic?
There are a few different issues here. Probably the main issue is that model selection (whether using p-values or AICs, stepwise or all-subsets or something else) is primarily problematic for inference (e.g. getting p-values with appropriate type I error, confidence intervals with appropriate coverage). For prediction, model selection can indeed pick a better spot on the bias-variance tradeoff axis and improve out-of-sample error. For some classes of models, AIC is asymptotically equivalent to leave-one-out CV error [see e.g. http://www.petrkeil.com/?p=836 ], so using AIC as a computationally efficient proxy for CV is reasonable. Stepwise selection is often dominated by other model selection (or averaging) methods (all-subsets if computationally feasible, or shrinkage methods). But it's simple and easy to implement, and if the answer is clear enough (some parameters corresponding to strong signals, others weak, few intermediate), then it will give reasonable results. Again, there's a big difference between inference and prediction. For example if you have a couple of strongly correlated predictors, picking the incorrect one (from a "truth"/causal point of view) is a big problem for inference, but picking the one that happens to give you the best AIC is a reasonable strategy for prediction (albeit one that will fail if you try to forecast a situation where the correlation of the predictors changes ...) Bottom line: for moderately sized data with a reasonable signal-to-noise ratio, AIC-based stepwise selection can indeed produce a defensible predictive model; see Murtaugh (2009) for an example. Murtaugh, Paul A. "Performance of several variable‐selection methods applied to real ecological data." Ecology letters 12, no. 10 (2009): 1061-1068.
Stepwise AIC - Does there exist controversy surrounding this topic?
There are a few different issues here. Probably the main issue is that model selection (whether using p-values or AICs, stepwise or all-subsets or something else) is primarily problematic for infer
Stepwise AIC - Does there exist controversy surrounding this topic? There are a few different issues here. Probably the main issue is that model selection (whether using p-values or AICs, stepwise or all-subsets or something else) is primarily problematic for inference (e.g. getting p-values with appropriate type I error, confidence intervals with appropriate coverage). For prediction, model selection can indeed pick a better spot on the bias-variance tradeoff axis and improve out-of-sample error. For some classes of models, AIC is asymptotically equivalent to leave-one-out CV error [see e.g. http://www.petrkeil.com/?p=836 ], so using AIC as a computationally efficient proxy for CV is reasonable. Stepwise selection is often dominated by other model selection (or averaging) methods (all-subsets if computationally feasible, or shrinkage methods). But it's simple and easy to implement, and if the answer is clear enough (some parameters corresponding to strong signals, others weak, few intermediate), then it will give reasonable results. Again, there's a big difference between inference and prediction. For example if you have a couple of strongly correlated predictors, picking the incorrect one (from a "truth"/causal point of view) is a big problem for inference, but picking the one that happens to give you the best AIC is a reasonable strategy for prediction (albeit one that will fail if you try to forecast a situation where the correlation of the predictors changes ...) Bottom line: for moderately sized data with a reasonable signal-to-noise ratio, AIC-based stepwise selection can indeed produce a defensible predictive model; see Murtaugh (2009) for an example. Murtaugh, Paul A. "Performance of several variable‐selection methods applied to real ecological data." Ecology letters 12, no. 10 (2009): 1061-1068.
Stepwise AIC - Does there exist controversy surrounding this topic? There are a few different issues here. Probably the main issue is that model selection (whether using p-values or AICs, stepwise or all-subsets or something else) is primarily problematic for infer
11,677
Opinions about Oversampling in general, and the SMOTE algorithm in particular [closed]
{1} gives a list of advantages and disadvantages of cost-sensitive learning vs. sampling: 2.2 Sampling Oversampling and undersampling can be used to alter the class distribution of the training data and both methods have been used to deal with class imbalance [1, 2, 3, 6, 10, 11]. The reason that altering the class distribution of the training data aids learning with highly-skewed data sets is that it effectively imposes non-uniform misclassification costs. For example, if one alters the class distribution of the training set so that the ratio of positive to negative examples goes from 1:1 to 2:1, then one has effectively assigned a misclassification cost ratio of 2:1. This equivalency between altering the class distribution of the training data and altering the misclassification cost ratio is well known and was formally described by Elkan [9]. There are known disadvantages associated with the use of sampling to implement cost-sensitive learning. The disadvantage with undersampling is that it discards potentially useful data. The main disadvantage with oversampling, from our perspective, is that by making exact copies of existing examples, it makes overfitting likely. In fact, with oversampling it is quite common for a learner to generate a classification rule to cover a single, replicated, example. A second disadvantage of oversampling is that it increases the number of training examples, thus increasing the learning time. 2.3 Why Use Sampling? Given the disadvantages with sampling, it is worth asking why anyone would use it rather than a cost-sensitive learning algorithm for dealing with data with a skewed class distribution and non-uniform misclassification costs. There are several reasons for this. The most obvious reason is there are not cost-sensitive implementations of all learning algorithms and therefore a wrapper-based approach using sampling is the only option. While this is certainly less true today than in the past, many learning algorithms (e.g., C4.5) still do not directly handle costs in the learning process. A second reason for using sampling is that many highly skewed data sets are enormous and the size of the training set must be reduced in order for learning to be feasible. In this case, undersampling seems to be a reasonable, and valid, strategy. In this paper we do not consider the need to reduce the training set size. We would point out, however, that if one needs to discard some training data, it still might be beneficial to discard some of the majority class examples in order to reduce the training set size to the required size, and then also employ a cost-sensitive learning algorithm, so that the amount of discarded training data is minimized. A final reason that may have contributed to the use of sampling rather than a cost-sensitive learning algorithm is that misclassification costs are often unknown. However, this is not a valid reason for using sampling over a costsensitive learning algorithm, since the analogous issue arises with sampling—what should the class distribution of the final training data be? If this cost information is not known, a measure such as the area under the ROC curve could be used to measure classifier performance and both approaches could then empirically determine the proper cost ratio/class distribution. They also did a series of experiments, which was inconclusive: Based on the results from all of the data sets, there is no definitive winner between cost-sensitive learning, oversampling and undersampling They then try to understand which criteria in the datasets may hint at which technique is better fitted. They also remark that SMOTE may bring some enhancements: There are a variety of enhancements that people have made to improve the effectiveness of sampling. Some of these enhancements include introducing new “synthetic” examples when oversampling [5 -> SMOTE], deleting less useful majority- class examples when undersampling [11] and using multiple sub-samples when undersampling such than each example is used in at least one sub-sample [3]. While these techniques have been compared to oversampling and undersampling, they generally have not been compared to cost-sensitive learning algorithms. This would be worth studying in the future. {2} is also worth reading: In this study, we systematically investigate the impact of class imbalance on the classification performance of convolutional neural networks (CNNs) and compare frequently used methods to address the issue. Class imbalance is a common problem that has been comprehensively studied in classical machine learning, yet very limited systematic research is available in the context of deep learning. References: {1} Weiss, Gary M., Kate Mc Carthy, and Bibi Zabar. "Cost-sensitive learning vs. sampling: Which is best for handling unbalanced classes with unequal error costs?." DMIN 7 (2007): 35-41. https://scholar.google.com/scholar?cluster=10779872536070567255&hl=en&as_sdt=0,22 ; https://pdfs.semanticscholar.org/9908/404807bf6b63e05e5345f02bcb23cc739ebd.pdf {2} Buda, Mateusz, Atsuto Maki, and Maciej A. Mazurowski. "A systematic study of the class imbalance problem in convolutional neural networks." Neural Networks 106 (2018): 249-259. https://arxiv.org/abs/1710.05381
Opinions about Oversampling in general, and the SMOTE algorithm in particular [closed]
{1} gives a list of advantages and disadvantages of cost-sensitive learning vs. sampling: 2.2 Sampling Oversampling and undersampling can be used to alter the class distribution of the training dat
Opinions about Oversampling in general, and the SMOTE algorithm in particular [closed] {1} gives a list of advantages and disadvantages of cost-sensitive learning vs. sampling: 2.2 Sampling Oversampling and undersampling can be used to alter the class distribution of the training data and both methods have been used to deal with class imbalance [1, 2, 3, 6, 10, 11]. The reason that altering the class distribution of the training data aids learning with highly-skewed data sets is that it effectively imposes non-uniform misclassification costs. For example, if one alters the class distribution of the training set so that the ratio of positive to negative examples goes from 1:1 to 2:1, then one has effectively assigned a misclassification cost ratio of 2:1. This equivalency between altering the class distribution of the training data and altering the misclassification cost ratio is well known and was formally described by Elkan [9]. There are known disadvantages associated with the use of sampling to implement cost-sensitive learning. The disadvantage with undersampling is that it discards potentially useful data. The main disadvantage with oversampling, from our perspective, is that by making exact copies of existing examples, it makes overfitting likely. In fact, with oversampling it is quite common for a learner to generate a classification rule to cover a single, replicated, example. A second disadvantage of oversampling is that it increases the number of training examples, thus increasing the learning time. 2.3 Why Use Sampling? Given the disadvantages with sampling, it is worth asking why anyone would use it rather than a cost-sensitive learning algorithm for dealing with data with a skewed class distribution and non-uniform misclassification costs. There are several reasons for this. The most obvious reason is there are not cost-sensitive implementations of all learning algorithms and therefore a wrapper-based approach using sampling is the only option. While this is certainly less true today than in the past, many learning algorithms (e.g., C4.5) still do not directly handle costs in the learning process. A second reason for using sampling is that many highly skewed data sets are enormous and the size of the training set must be reduced in order for learning to be feasible. In this case, undersampling seems to be a reasonable, and valid, strategy. In this paper we do not consider the need to reduce the training set size. We would point out, however, that if one needs to discard some training data, it still might be beneficial to discard some of the majority class examples in order to reduce the training set size to the required size, and then also employ a cost-sensitive learning algorithm, so that the amount of discarded training data is minimized. A final reason that may have contributed to the use of sampling rather than a cost-sensitive learning algorithm is that misclassification costs are often unknown. However, this is not a valid reason for using sampling over a costsensitive learning algorithm, since the analogous issue arises with sampling—what should the class distribution of the final training data be? If this cost information is not known, a measure such as the area under the ROC curve could be used to measure classifier performance and both approaches could then empirically determine the proper cost ratio/class distribution. They also did a series of experiments, which was inconclusive: Based on the results from all of the data sets, there is no definitive winner between cost-sensitive learning, oversampling and undersampling They then try to understand which criteria in the datasets may hint at which technique is better fitted. They also remark that SMOTE may bring some enhancements: There are a variety of enhancements that people have made to improve the effectiveness of sampling. Some of these enhancements include introducing new “synthetic” examples when oversampling [5 -> SMOTE], deleting less useful majority- class examples when undersampling [11] and using multiple sub-samples when undersampling such than each example is used in at least one sub-sample [3]. While these techniques have been compared to oversampling and undersampling, they generally have not been compared to cost-sensitive learning algorithms. This would be worth studying in the future. {2} is also worth reading: In this study, we systematically investigate the impact of class imbalance on the classification performance of convolutional neural networks (CNNs) and compare frequently used methods to address the issue. Class imbalance is a common problem that has been comprehensively studied in classical machine learning, yet very limited systematic research is available in the context of deep learning. References: {1} Weiss, Gary M., Kate Mc Carthy, and Bibi Zabar. "Cost-sensitive learning vs. sampling: Which is best for handling unbalanced classes with unequal error costs?." DMIN 7 (2007): 35-41. https://scholar.google.com/scholar?cluster=10779872536070567255&hl=en&as_sdt=0,22 ; https://pdfs.semanticscholar.org/9908/404807bf6b63e05e5345f02bcb23cc739ebd.pdf {2} Buda, Mateusz, Atsuto Maki, and Maciej A. Mazurowski. "A systematic study of the class imbalance problem in convolutional neural networks." Neural Networks 106 (2018): 249-259. https://arxiv.org/abs/1710.05381
Opinions about Oversampling in general, and the SMOTE algorithm in particular [closed] {1} gives a list of advantages and disadvantages of cost-sensitive learning vs. sampling: 2.2 Sampling Oversampling and undersampling can be used to alter the class distribution of the training dat
11,678
Jenks Natural Breaks in Python: How to find the optimum number of breaks?
Jenks Natural Breaks works by optimizing the Goodness of Variance Fit, a value from 0 to 1 where 0 = No Fit and 1 = Perfect Fit. The key in selecting the number of classes is to find a balance between detecting differences and overfitting your data. To determine the optimum number of classes, I suggest you use a threshold GVF value you desire and use the number of classes that satisfies this value first. Below is a function to calculate the Goodness of Variance Fit given an array of values to classify and the number of classes selected: from jenks import jenks import numpy as np def goodness_of_variance_fit(array, classes): # get the break points classes = jenks(array, classes) # do the actual classification classified = np.array([classify(i, classes) for i in array]) # max value of zones maxz = max(classified) # nested list of zone indices zone_indices = [[idx for idx, val in enumerate(classified) if zone + 1 == val] for zone in range(maxz)] # sum of squared deviations from array mean sdam = np.sum((array - array.mean()) ** 2) # sorted polygon stats array_sort = [np.array([array[index] for index in zone]) for zone in zone_indices] # sum of squared deviations of class means sdcm = sum([np.sum((classified - classified.mean()) ** 2) for classified in array_sort]) # goodness of variance fit gvf = (sdam - sdcm) / sdam return gvf def classify(value, breaks): for i in range(1, len(breaks)): if value < breaks[i]: return i return len(breaks) - 1 For example, consider you decide the GVF should be at least .8, then you could increment the number of classes until the GVF is satisfied: gvf = 0.0 nclasses = 2 while gvf < .8: gvf = goodness_of_variance_fit(array, nclasses) nclasses += 1
Jenks Natural Breaks in Python: How to find the optimum number of breaks?
Jenks Natural Breaks works by optimizing the Goodness of Variance Fit, a value from 0 to 1 where 0 = No Fit and 1 = Perfect Fit. The key in selecting the number of classes is to find a balance betwee
Jenks Natural Breaks in Python: How to find the optimum number of breaks? Jenks Natural Breaks works by optimizing the Goodness of Variance Fit, a value from 0 to 1 where 0 = No Fit and 1 = Perfect Fit. The key in selecting the number of classes is to find a balance between detecting differences and overfitting your data. To determine the optimum number of classes, I suggest you use a threshold GVF value you desire and use the number of classes that satisfies this value first. Below is a function to calculate the Goodness of Variance Fit given an array of values to classify and the number of classes selected: from jenks import jenks import numpy as np def goodness_of_variance_fit(array, classes): # get the break points classes = jenks(array, classes) # do the actual classification classified = np.array([classify(i, classes) for i in array]) # max value of zones maxz = max(classified) # nested list of zone indices zone_indices = [[idx for idx, val in enumerate(classified) if zone + 1 == val] for zone in range(maxz)] # sum of squared deviations from array mean sdam = np.sum((array - array.mean()) ** 2) # sorted polygon stats array_sort = [np.array([array[index] for index in zone]) for zone in zone_indices] # sum of squared deviations of class means sdcm = sum([np.sum((classified - classified.mean()) ** 2) for classified in array_sort]) # goodness of variance fit gvf = (sdam - sdcm) / sdam return gvf def classify(value, breaks): for i in range(1, len(breaks)): if value < breaks[i]: return i return len(breaks) - 1 For example, consider you decide the GVF should be at least .8, then you could increment the number of classes until the GVF is satisfied: gvf = 0.0 nclasses = 2 while gvf < .8: gvf = goodness_of_variance_fit(array, nclasses) nclasses += 1
Jenks Natural Breaks in Python: How to find the optimum number of breaks? Jenks Natural Breaks works by optimizing the Goodness of Variance Fit, a value from 0 to 1 where 0 = No Fit and 1 = Perfect Fit. The key in selecting the number of classes is to find a balance betwee
11,679
Statistical significance (p-value) for comparing two classifiers with respect to (mean) ROC AUC, sensitivity and specificity
Wojtek J. Krzanowski and David J. Hand ROC Curves for Continuous Data (2009) is a great reference for all things related to ROC curves. It collects together a number of results in what is a frustratingly broad literature base, which often uses different terminology to discuss the same topic. Additionally, this book offers commentary and comparisons of alternative methods which have been derived to estimate the same quantities, and points out that some methods make assumptions which may be untenable in particular contexts. This is one such context; other answers report the Hanley & McNeil method, which assumes the binormal model for distributions of scores, which may be inappropriate in cases where the distribution of class scores are not (close to) normal. The assumption of normally distributed scores seems especially inappropriate in modern machine-learning contexts, typical common models such as xgboost tend to produce scores with a "bathtub" distribution for classification tasks (that is, distributions with high densities in the extremes near 0 and 1). Question 1 - AUC Section 6.3 discusses comparisons of ROC AUC for two ROC curves (pp 113-114). In particular, my understanding is that these two models are correlated, so the information about how to compute $r$ is critically important here; otherwise, your test statistic will be biased because it doesn't account for the contribution of correlation. For the case of uncorrelated ROC curves not based on any parametric distributional assumptions, statistics for tets and confidence intervals comparing AUCs can be straightforwardly based on estimates $\widehat{\text{AUC}}_1$ and $\widehat{\text{AUC}}_2$ of the AUC values, and estimates of their standard deviations $S_1$ and $S_2$, as given in section 3.5.1: $$ Z = \frac{\widehat{\text{AUC}}_1 - \widehat{\text{AUC}}_2}{\sqrt{S_1^2 + S_2^2}} $$ To extend such tests to the case in which the same data is used for both classifiers, we need to take account of the correlation between the AUC estimates: $$ z=\frac{\widehat{\text{AUC}}_1 - \widehat{\text{AUC}}_2}{\sqrt{S_1^2 + S_2^2 - rS_1S_2}} $$ where $r$ is the estimate of this correlation. Hanley and McNeil (1983) made such an extension, basing their analysis on the binormal case, but only gave a table showing how to calculate the estimated correlation coefficient $r$ from the correlation $r_P$ of the two classifiers within class P, and the correlation of $r_n$ of the two classifiers within class N, saying that the mathematical derivation was available upon request. Various other authors (e.g. Zou, 2001) have developed tests based on the binormal model, assuming that an appropriate transformation can be found which will simultaneously transform the score distributions of classes P and N to normal. DeLong et al (1988) took advantage of the identity between AUC and the Mann-Whitney test statistic, together with results from the theory of generalized $U$-statistics due to Sen (1960), to derive an estiamte of the correlation between the AUCs that does not rely on the binormal assumption. In fact, DeLong et al (1988) presented the following results for comparisons between $k\ge 2$ classifiers. In Section 3.5.1, we showed that the area under the empirical ROC curve was equal to the Mann-Whitney $U$-statistic, and was given by $$ \widehat{AUC}=\frac{1}{n_N n_P} \sum_{i=1}^{n_N} \sum_{j=1}^{n_P} \left[ I(s_{P_j} > s_{N_i}) + \frac{1}{2}I(s_{P_j} = s_{N_i}) \right] $$ where $s_{P_i}, i = 1, \dots,n_P$ are the score for the class $P$ objects and $s_{N_j}, j = 1, \dots,n_N$ are the scores for the class $N$ objects in the sample. Suppose that we have $k$ classifiers, yielding scores $s^r_{N_j}, j=1\dots n_N$ and $s_{P_i}^r, j = 1, \dots,n_P$ [I corrected an indexing error in this part - Sycorax], and $\widehat{AUC}_r, r = 1, \dots, k$. Define $$ V^r_{10}=\frac{1}{n_N}\sum_{j=1}^{n_N} \left[ I(s_{P_i}^r > s_{N_j}^r) + \frac{1}{2}I(s_{P_i}^r = s_{N_j}^r) \right] , i=1,\dots,n_P $$ and $$ V^r_{01} = \frac{1}{n_P}\sum_{i=1}^{n_P} \left[ I(s_{P_i}^r > s_{N_j}^r) + \frac{1}{2}I(s_{P_i}^r = s_{N_j}^r) \right] , j=1,\dots,n_N $$ next, define the $k \times k$ matrix $\mathbf{W}_{10}$ with $(r,s)$th element $$ w_{10}^{r,s} = \frac{1}{n_P - 1}\sum_{i=1}^{n_P} \left[ V_{10}^r(s_{P_i}) - \widehat{AUC}_r \right] \left[ V_{10}^s(s_{P_i}) - \widehat{AUC}_s \right] $$ and the $k \times k$ matrix $\mathbf{W}_{01}$ with $(r,s)$th element $$ w_{01}^{r,s} = \frac{1}{n_N - 1}\sum_{i=1}^{n_N} \left[ V_{01}^r(s_{N_i}) - \widehat{AUC}_r \right] \left[ V_{01}^s(s_{N_i}) - \widehat{AUC}_s \right] $$ Then the estiamted covariance matrix for the vector $(\widehat{AUC}_1, \dots, \widehat{AUC}_k)$ of the estimated areas under the curves is $$ \mathbf{W} = \frac{1}{n_P}\mathbf{W}_{10} + \frac{1}{n_N}\mathbf{W}_{01} $$ with elements $w^{r,s}$. This is a generalization of the result for the estimated variance of a single estiamted AUC, also given in section 3.5.1. In the case of two classifiers, the estiamted correlation $r$ between the estimated AUCs is thus given by $\frac{w^{1,2}}{\sqrt{w^{1,1}w^{2,2}}}$ which can be used in $z$ above. Since another answers gives the Hanley and McNeil expressions for estimators of AUC variance, here I'll reproduce the DeLong estimator from p. 68: The alternative approach due to DeLong et al (1988) and exemplified by Pepe (2003) gives perhaps a simpler estimate, and one that introduces the extra useful concept of a placement value. The placement value of a score $s$ with reference to a specified population is that population's survivor function at $s$. This the placement value for $s$ in population N is $1 - F(s)$ and for $s$ in population P it is $1 - G(s)$. Empirical estimates of placement values are given by the obvious proportions. Thus the placement value of observation $s_{N_i}$ in population P denoted $s^P_{N_i}$, is the proportion of sample values from P that exceed $s_{N_i}$, and $\text{var}(s_{P_i}^N)$ is the variance of the placement values of each observation from N with respect to population P... The DeLong et al (1988) estimate of variance of $\widehat{AUC}$ is given in terms of these variances: $$ s^2(\widehat{AUC}) = \frac{1}{n_P} \text{var}\left(s_{P_i}^N\right) + \frac{1}{n_N}\text{var}\left(s_{N_i}^P\right) $$ Note that $F$ is the cumulative distribution function of the scores in population N and $G$ is the cumulative distribution function of the scores in population P. A standard way to estimate $F$ and $G$ is to use the ecdf. The book also provides some alternative methods to the ecdf estimates, such as kernel density estimation, but that is outside the scope of this answer. The statistics $Z$ and $z$ may be assumed to be standard normal deviates, and statistical tests of the null hypothesis proceed in the usual way. (See also: hypothesis-testing) This is a simplified, high-level outline of how hypothesis testing works: Testing, in your words, "whether one classifier is significantly better than the other" can be rephrased as testing the null hypothesis that the two models have statistically equal AUCs against the alternative hypothesis that the statistics are unequal. This is a two-tailed test. We reject the null hypothesis if the test statistic is in the critical region of the reference distribution, which is a standard normal distribution in this case. The size of the critical region depends on the level $\alpha$ of the test. For a significance level of 95%, the test statistic falls in the critical region if $z > 1.96$ or $z < -1.96$. (These are the $\alpha/2$ and $1 - \alpha/2$ quantiles of the standard normal distribution.) Otherwise, you fail to reject the null hypothesis and the two models are statistically tied. Question 1 - Sensitivity and Specificity The general strategy for comparing sensitivity and specificity is to observe that both of these statistics amount to performing statistical inference on proportions, and this is a standard, well-studied problem. Specifically, sensitivity is the proportion of population P that has a score greater than some threshold $t$, and likewise for specificity wrt population N: $$ \begin{align} \text{sensitivity} = tp &= \mathbb{P}(s_P > t) \\ 1 - \text{specificity} = fp &= \mathbb{P}(s_N > t) \end{align} $$ The main sticking point is developing the appropriate test given that the two sample proportions will be correlated (as you've applied two models to the same test data). This is addressed on p. 111. Turning to particular tests, several summary statistics reduce to proportions for each curve, so that standard methods for comparing proportions can be used. For example, the value of $tp$ for fixed $fp$ is a proportion, as is the misclassification rate for fixed threshold $t$. We can thus compare curves, using these measures, by means of standard tests to compare proportions. For example, in the unpaired case, we can use the test statistic $(tp_1 - tp_2) / s_{12}$, where $tp_i$ is the true positive rate for curve $i$ as the point in question, and $s_{12}^2$ is the sum of the variances of $tp_1$ and $tp_2$... For the paired case, however, one can derive an adjustment that allows for the covariance between $tp_1$ and $tp_2$, but an alternative is to use McNemar's test for correlated proportions (Marascuilo and McSweeney, 1977). The mcnemar-test is appropriate when you have $N$ subjects, and each subject is tested twice, once for each of two dichotomous outcomes. Given the definitions of sensitivity and specificity, it should be obvious that this is exactly the test that we seek, since you've applied two models to the same test data and computed sensitivity and specificity at some threshold. The McNemar test uses a different statistic, but a similar null and alternative hypothesis. For example, considering sensitivity, the null hypothesis is that the proportion $tp_1 = tp_2$, and the alternative is $tp_1 \neq tp_2$. Re-arranging the proportions to instead be raw counts, we can write a contingency table $$ \begin{array}{c|c|c|} & \text{Model 1 Positive at } t & \text{Model 1 Negative at } t \\ \hline \text{Model 2 Positive at } t & a & b \\ \hline \text{Model 2 Negative at } t & c & d \\ \hline \end{array} $$ where cell counts are given by counting the true positives and false negatives according to each model $$ \begin{align} a &= \sum_{i=1}^{n_P} I(s_{P_i}^1 > t) \cdot I(s_{P_i}^2 > t) \\ b &= \sum_{i=1}^{n_P} I(s_{P_i}^1 \le t) \cdot I(s_{P_i}^2 > t) \\ c &= \sum_{i=1}^{n_P} I(s_{P_i}^1 > t) \cdot I(s_{P_i}^2 \le t) \\ d &= \sum_{i=1}^{n_P} I(s_{P_i}^1 \le t) \cdot I(s_{P_i}^2 \le t) \\ \end{align} $$ and we have the test statistic $$ M = \frac{(b-c)^2}{b + c} $$ which is distributed as $\chi^2_1$ a chi-squared distribution with 1 degree of freedom. With a level $\alpha=95\%$, the null hypothesis is rejected for $M > 3.841459$. For the specificity, you can use the same procedure, except that you replace the $s^r_{P_i}$ with the $s^r_{N_j}$. Question 2 It seems that it is sufficient to merge the results by averaging the prediction values for each respondent, so that for each model you have 1 vector of 100 averaged predicted values. Then compute the ROC AUC, sensitivty and specificity statistics as usual, as if the original models didn't exist. This reflects a modeling strategy that treats each of the 5 respondents' models as one of a "committee" of models, sort of like an ensemble.
Statistical significance (p-value) for comparing two classifiers with respect to (mean) ROC AUC, sen
Wojtek J. Krzanowski and David J. Hand ROC Curves for Continuous Data (2009) is a great reference for all things related to ROC curves. It collects together a number of results in what is a frustratin
Statistical significance (p-value) for comparing two classifiers with respect to (mean) ROC AUC, sensitivity and specificity Wojtek J. Krzanowski and David J. Hand ROC Curves for Continuous Data (2009) is a great reference for all things related to ROC curves. It collects together a number of results in what is a frustratingly broad literature base, which often uses different terminology to discuss the same topic. Additionally, this book offers commentary and comparisons of alternative methods which have been derived to estimate the same quantities, and points out that some methods make assumptions which may be untenable in particular contexts. This is one such context; other answers report the Hanley & McNeil method, which assumes the binormal model for distributions of scores, which may be inappropriate in cases where the distribution of class scores are not (close to) normal. The assumption of normally distributed scores seems especially inappropriate in modern machine-learning contexts, typical common models such as xgboost tend to produce scores with a "bathtub" distribution for classification tasks (that is, distributions with high densities in the extremes near 0 and 1). Question 1 - AUC Section 6.3 discusses comparisons of ROC AUC for two ROC curves (pp 113-114). In particular, my understanding is that these two models are correlated, so the information about how to compute $r$ is critically important here; otherwise, your test statistic will be biased because it doesn't account for the contribution of correlation. For the case of uncorrelated ROC curves not based on any parametric distributional assumptions, statistics for tets and confidence intervals comparing AUCs can be straightforwardly based on estimates $\widehat{\text{AUC}}_1$ and $\widehat{\text{AUC}}_2$ of the AUC values, and estimates of their standard deviations $S_1$ and $S_2$, as given in section 3.5.1: $$ Z = \frac{\widehat{\text{AUC}}_1 - \widehat{\text{AUC}}_2}{\sqrt{S_1^2 + S_2^2}} $$ To extend such tests to the case in which the same data is used for both classifiers, we need to take account of the correlation between the AUC estimates: $$ z=\frac{\widehat{\text{AUC}}_1 - \widehat{\text{AUC}}_2}{\sqrt{S_1^2 + S_2^2 - rS_1S_2}} $$ where $r$ is the estimate of this correlation. Hanley and McNeil (1983) made such an extension, basing their analysis on the binormal case, but only gave a table showing how to calculate the estimated correlation coefficient $r$ from the correlation $r_P$ of the two classifiers within class P, and the correlation of $r_n$ of the two classifiers within class N, saying that the mathematical derivation was available upon request. Various other authors (e.g. Zou, 2001) have developed tests based on the binormal model, assuming that an appropriate transformation can be found which will simultaneously transform the score distributions of classes P and N to normal. DeLong et al (1988) took advantage of the identity between AUC and the Mann-Whitney test statistic, together with results from the theory of generalized $U$-statistics due to Sen (1960), to derive an estiamte of the correlation between the AUCs that does not rely on the binormal assumption. In fact, DeLong et al (1988) presented the following results for comparisons between $k\ge 2$ classifiers. In Section 3.5.1, we showed that the area under the empirical ROC curve was equal to the Mann-Whitney $U$-statistic, and was given by $$ \widehat{AUC}=\frac{1}{n_N n_P} \sum_{i=1}^{n_N} \sum_{j=1}^{n_P} \left[ I(s_{P_j} > s_{N_i}) + \frac{1}{2}I(s_{P_j} = s_{N_i}) \right] $$ where $s_{P_i}, i = 1, \dots,n_P$ are the score for the class $P$ objects and $s_{N_j}, j = 1, \dots,n_N$ are the scores for the class $N$ objects in the sample. Suppose that we have $k$ classifiers, yielding scores $s^r_{N_j}, j=1\dots n_N$ and $s_{P_i}^r, j = 1, \dots,n_P$ [I corrected an indexing error in this part - Sycorax], and $\widehat{AUC}_r, r = 1, \dots, k$. Define $$ V^r_{10}=\frac{1}{n_N}\sum_{j=1}^{n_N} \left[ I(s_{P_i}^r > s_{N_j}^r) + \frac{1}{2}I(s_{P_i}^r = s_{N_j}^r) \right] , i=1,\dots,n_P $$ and $$ V^r_{01} = \frac{1}{n_P}\sum_{i=1}^{n_P} \left[ I(s_{P_i}^r > s_{N_j}^r) + \frac{1}{2}I(s_{P_i}^r = s_{N_j}^r) \right] , j=1,\dots,n_N $$ next, define the $k \times k$ matrix $\mathbf{W}_{10}$ with $(r,s)$th element $$ w_{10}^{r,s} = \frac{1}{n_P - 1}\sum_{i=1}^{n_P} \left[ V_{10}^r(s_{P_i}) - \widehat{AUC}_r \right] \left[ V_{10}^s(s_{P_i}) - \widehat{AUC}_s \right] $$ and the $k \times k$ matrix $\mathbf{W}_{01}$ with $(r,s)$th element $$ w_{01}^{r,s} = \frac{1}{n_N - 1}\sum_{i=1}^{n_N} \left[ V_{01}^r(s_{N_i}) - \widehat{AUC}_r \right] \left[ V_{01}^s(s_{N_i}) - \widehat{AUC}_s \right] $$ Then the estiamted covariance matrix for the vector $(\widehat{AUC}_1, \dots, \widehat{AUC}_k)$ of the estimated areas under the curves is $$ \mathbf{W} = \frac{1}{n_P}\mathbf{W}_{10} + \frac{1}{n_N}\mathbf{W}_{01} $$ with elements $w^{r,s}$. This is a generalization of the result for the estimated variance of a single estiamted AUC, also given in section 3.5.1. In the case of two classifiers, the estiamted correlation $r$ between the estimated AUCs is thus given by $\frac{w^{1,2}}{\sqrt{w^{1,1}w^{2,2}}}$ which can be used in $z$ above. Since another answers gives the Hanley and McNeil expressions for estimators of AUC variance, here I'll reproduce the DeLong estimator from p. 68: The alternative approach due to DeLong et al (1988) and exemplified by Pepe (2003) gives perhaps a simpler estimate, and one that introduces the extra useful concept of a placement value. The placement value of a score $s$ with reference to a specified population is that population's survivor function at $s$. This the placement value for $s$ in population N is $1 - F(s)$ and for $s$ in population P it is $1 - G(s)$. Empirical estimates of placement values are given by the obvious proportions. Thus the placement value of observation $s_{N_i}$ in population P denoted $s^P_{N_i}$, is the proportion of sample values from P that exceed $s_{N_i}$, and $\text{var}(s_{P_i}^N)$ is the variance of the placement values of each observation from N with respect to population P... The DeLong et al (1988) estimate of variance of $\widehat{AUC}$ is given in terms of these variances: $$ s^2(\widehat{AUC}) = \frac{1}{n_P} \text{var}\left(s_{P_i}^N\right) + \frac{1}{n_N}\text{var}\left(s_{N_i}^P\right) $$ Note that $F$ is the cumulative distribution function of the scores in population N and $G$ is the cumulative distribution function of the scores in population P. A standard way to estimate $F$ and $G$ is to use the ecdf. The book also provides some alternative methods to the ecdf estimates, such as kernel density estimation, but that is outside the scope of this answer. The statistics $Z$ and $z$ may be assumed to be standard normal deviates, and statistical tests of the null hypothesis proceed in the usual way. (See also: hypothesis-testing) This is a simplified, high-level outline of how hypothesis testing works: Testing, in your words, "whether one classifier is significantly better than the other" can be rephrased as testing the null hypothesis that the two models have statistically equal AUCs against the alternative hypothesis that the statistics are unequal. This is a two-tailed test. We reject the null hypothesis if the test statistic is in the critical region of the reference distribution, which is a standard normal distribution in this case. The size of the critical region depends on the level $\alpha$ of the test. For a significance level of 95%, the test statistic falls in the critical region if $z > 1.96$ or $z < -1.96$. (These are the $\alpha/2$ and $1 - \alpha/2$ quantiles of the standard normal distribution.) Otherwise, you fail to reject the null hypothesis and the two models are statistically tied. Question 1 - Sensitivity and Specificity The general strategy for comparing sensitivity and specificity is to observe that both of these statistics amount to performing statistical inference on proportions, and this is a standard, well-studied problem. Specifically, sensitivity is the proportion of population P that has a score greater than some threshold $t$, and likewise for specificity wrt population N: $$ \begin{align} \text{sensitivity} = tp &= \mathbb{P}(s_P > t) \\ 1 - \text{specificity} = fp &= \mathbb{P}(s_N > t) \end{align} $$ The main sticking point is developing the appropriate test given that the two sample proportions will be correlated (as you've applied two models to the same test data). This is addressed on p. 111. Turning to particular tests, several summary statistics reduce to proportions for each curve, so that standard methods for comparing proportions can be used. For example, the value of $tp$ for fixed $fp$ is a proportion, as is the misclassification rate for fixed threshold $t$. We can thus compare curves, using these measures, by means of standard tests to compare proportions. For example, in the unpaired case, we can use the test statistic $(tp_1 - tp_2) / s_{12}$, where $tp_i$ is the true positive rate for curve $i$ as the point in question, and $s_{12}^2$ is the sum of the variances of $tp_1$ and $tp_2$... For the paired case, however, one can derive an adjustment that allows for the covariance between $tp_1$ and $tp_2$, but an alternative is to use McNemar's test for correlated proportions (Marascuilo and McSweeney, 1977). The mcnemar-test is appropriate when you have $N$ subjects, and each subject is tested twice, once for each of two dichotomous outcomes. Given the definitions of sensitivity and specificity, it should be obvious that this is exactly the test that we seek, since you've applied two models to the same test data and computed sensitivity and specificity at some threshold. The McNemar test uses a different statistic, but a similar null and alternative hypothesis. For example, considering sensitivity, the null hypothesis is that the proportion $tp_1 = tp_2$, and the alternative is $tp_1 \neq tp_2$. Re-arranging the proportions to instead be raw counts, we can write a contingency table $$ \begin{array}{c|c|c|} & \text{Model 1 Positive at } t & \text{Model 1 Negative at } t \\ \hline \text{Model 2 Positive at } t & a & b \\ \hline \text{Model 2 Negative at } t & c & d \\ \hline \end{array} $$ where cell counts are given by counting the true positives and false negatives according to each model $$ \begin{align} a &= \sum_{i=1}^{n_P} I(s_{P_i}^1 > t) \cdot I(s_{P_i}^2 > t) \\ b &= \sum_{i=1}^{n_P} I(s_{P_i}^1 \le t) \cdot I(s_{P_i}^2 > t) \\ c &= \sum_{i=1}^{n_P} I(s_{P_i}^1 > t) \cdot I(s_{P_i}^2 \le t) \\ d &= \sum_{i=1}^{n_P} I(s_{P_i}^1 \le t) \cdot I(s_{P_i}^2 \le t) \\ \end{align} $$ and we have the test statistic $$ M = \frac{(b-c)^2}{b + c} $$ which is distributed as $\chi^2_1$ a chi-squared distribution with 1 degree of freedom. With a level $\alpha=95\%$, the null hypothesis is rejected for $M > 3.841459$. For the specificity, you can use the same procedure, except that you replace the $s^r_{P_i}$ with the $s^r_{N_j}$. Question 2 It seems that it is sufficient to merge the results by averaging the prediction values for each respondent, so that for each model you have 1 vector of 100 averaged predicted values. Then compute the ROC AUC, sensitivty and specificity statistics as usual, as if the original models didn't exist. This reflects a modeling strategy that treats each of the 5 respondents' models as one of a "committee" of models, sort of like an ensemble.
Statistical significance (p-value) for comparing two classifiers with respect to (mean) ROC AUC, sen Wojtek J. Krzanowski and David J. Hand ROC Curves for Continuous Data (2009) is a great reference for all things related to ROC curves. It collects together a number of results in what is a frustratin
11,680
Statistical significance (p-value) for comparing two classifiers with respect to (mean) ROC AUC, sensitivity and specificity
Let me keep the answer short, because this guide does explain a lot more and better. Basically, you have your number of True Postives ($nTP$) and number of True Negatives ($nTN$). Also you have your AUC, A. The standard error of this A is: $\texttt{SE}_A = \sqrt{\frac{A(1-A) + (nTP-1)(Q_1 - A^2)+(nTN-1)(Q_2 - A^2)}{nTP \cdot nTN}}$ with $Q_1 = A / (2 - A)$ and $Q_2 = 2A^2 / (1 + A)$. To compare two AUCs you need to compute the SE of them both using: $\texttt{SE}_{A_1 - A_2} = \sqrt{(SE_{A_1})^2 + (SE_{A_2})^2 - 2r\cdot (SE_{A_1})(SE_{A_2})}$ where $r$ is a quantity that represents the correlation induced between the two areas by the study of the same set of cases. If your cases are different, then $r=0$; otherwise you need to look it up (Table 1, page 3 in freely available article). Given that you compute the $z$-Score by $z = (A_1 - A_2) / SE_{A_1-A_2}$ From there you can compute p-value using probability density of a standard normal distribution. Or simply use this calculator. This hopefully answers Question 1. - at least the part comparing AUCs. Sens/Spec is already covered by the ROC/AUC in some way. Otherwise, the answer I think lies in the Question 2. As for Question 2, Central Limit Theorem tells us that your summary statistic would follow a normal distribution. Hence, I would think a simple t-test would suffice (5 measures of one classifier against 5 measures of the second classifier where measures could be AUC, sens, spec) Edit: corrected formula for $\texttt{SE}$ ($\ldots - 2r \ldots$)
Statistical significance (p-value) for comparing two classifiers with respect to (mean) ROC AUC, sen
Let me keep the answer short, because this guide does explain a lot more and better. Basically, you have your number of True Postives ($nTP$) and number of True Negatives ($nTN$). Also you have your A
Statistical significance (p-value) for comparing two classifiers with respect to (mean) ROC AUC, sensitivity and specificity Let me keep the answer short, because this guide does explain a lot more and better. Basically, you have your number of True Postives ($nTP$) and number of True Negatives ($nTN$). Also you have your AUC, A. The standard error of this A is: $\texttt{SE}_A = \sqrt{\frac{A(1-A) + (nTP-1)(Q_1 - A^2)+(nTN-1)(Q_2 - A^2)}{nTP \cdot nTN}}$ with $Q_1 = A / (2 - A)$ and $Q_2 = 2A^2 / (1 + A)$. To compare two AUCs you need to compute the SE of them both using: $\texttt{SE}_{A_1 - A_2} = \sqrt{(SE_{A_1})^2 + (SE_{A_2})^2 - 2r\cdot (SE_{A_1})(SE_{A_2})}$ where $r$ is a quantity that represents the correlation induced between the two areas by the study of the same set of cases. If your cases are different, then $r=0$; otherwise you need to look it up (Table 1, page 3 in freely available article). Given that you compute the $z$-Score by $z = (A_1 - A_2) / SE_{A_1-A_2}$ From there you can compute p-value using probability density of a standard normal distribution. Or simply use this calculator. This hopefully answers Question 1. - at least the part comparing AUCs. Sens/Spec is already covered by the ROC/AUC in some way. Otherwise, the answer I think lies in the Question 2. As for Question 2, Central Limit Theorem tells us that your summary statistic would follow a normal distribution. Hence, I would think a simple t-test would suffice (5 measures of one classifier against 5 measures of the second classifier where measures could be AUC, sens, spec) Edit: corrected formula for $\texttt{SE}$ ($\ldots - 2r \ldots$)
Statistical significance (p-value) for comparing two classifiers with respect to (mean) ROC AUC, sen Let me keep the answer short, because this guide does explain a lot more and better. Basically, you have your number of True Postives ($nTP$) and number of True Negatives ($nTN$). Also you have your A
11,681
Statistical significance (p-value) for comparing two classifiers with respect to (mean) ROC AUC, sensitivity and specificity
For Question 1, @Sycorax provided a comprehensive answer. For Question 2, to the best of my knowledge, averaging predictions from subjects is incorrect. I decided to use bootstrapping to compute p-values and compare models. In this case, the procedure is as follows: For N iterations: sample 5 subjects with replacement sample 100 test cases with replacement compute mean performance of sampled subjects on sampled cases for model M1 compute mean performance of sampled subjects on sampled cases for model M2 take the difference of mean performance between M1 and M2 p-value equals to the proportion of differences smaller or equal than 0 This procedure performs one-tailed test and assumes that M1 mean performance > M2 mean performance. A Python implementation of bootstrapping for computing p-values comparing multiple readers can be found in this GitHub repo: https://github.com/mateuszbuda/ml-stat-util
Statistical significance (p-value) for comparing two classifiers with respect to (mean) ROC AUC, sen
For Question 1, @Sycorax provided a comprehensive answer. For Question 2, to the best of my knowledge, averaging predictions from subjects is incorrect. I decided to use bootstrapping to compute p-val
Statistical significance (p-value) for comparing two classifiers with respect to (mean) ROC AUC, sensitivity and specificity For Question 1, @Sycorax provided a comprehensive answer. For Question 2, to the best of my knowledge, averaging predictions from subjects is incorrect. I decided to use bootstrapping to compute p-values and compare models. In this case, the procedure is as follows: For N iterations: sample 5 subjects with replacement sample 100 test cases with replacement compute mean performance of sampled subjects on sampled cases for model M1 compute mean performance of sampled subjects on sampled cases for model M2 take the difference of mean performance between M1 and M2 p-value equals to the proportion of differences smaller or equal than 0 This procedure performs one-tailed test and assumes that M1 mean performance > M2 mean performance. A Python implementation of bootstrapping for computing p-values comparing multiple readers can be found in this GitHub repo: https://github.com/mateuszbuda/ml-stat-util
Statistical significance (p-value) for comparing two classifiers with respect to (mean) ROC AUC, sen For Question 1, @Sycorax provided a comprehensive answer. For Question 2, to the best of my knowledge, averaging predictions from subjects is incorrect. I decided to use bootstrapping to compute p-val
11,682
Why exactly can't beta regression deal with 0s and 1s in the response variable?
Because the loglikelihood contains both $\log(x)$ and $\log(1-x)$, which are unbounded when $x=0$ or $x=1$. See equation (4) of Smithson & Verkuilen, "A Better Lemon Squeezer? Maximum-Likelihood Regression With Beta-Distributed Dependent Variables" (direct link to PDF).
Why exactly can't beta regression deal with 0s and 1s in the response variable?
Because the loglikelihood contains both $\log(x)$ and $\log(1-x)$, which are unbounded when $x=0$ or $x=1$. See equation (4) of Smithson & Verkuilen, "A Better Lemon Squeezer? Maximum-Likelihood Regr
Why exactly can't beta regression deal with 0s and 1s in the response variable? Because the loglikelihood contains both $\log(x)$ and $\log(1-x)$, which are unbounded when $x=0$ or $x=1$. See equation (4) of Smithson & Verkuilen, "A Better Lemon Squeezer? Maximum-Likelihood Regression With Beta-Distributed Dependent Variables" (direct link to PDF).
Why exactly can't beta regression deal with 0s and 1s in the response variable? Because the loglikelihood contains both $\log(x)$ and $\log(1-x)$, which are unbounded when $x=0$ or $x=1$. See equation (4) of Smithson & Verkuilen, "A Better Lemon Squeezer? Maximum-Likelihood Regr
11,683
Why exactly can't beta regression deal with 0s and 1s in the response variable?
besides the fact that the reason comes in practice from the presence of $log(x)$ and $log(1-x)$, I will try to complement the answer to the question by trying to frame the underlying reason why this happens. as a matter of fact, the beta distribution is "often used to describe the distribution of a probability value" (wikipedia). It is the distribution of the possible tendencies $p$ of a binomial distribution, knowing the observation of $N$ independent binary draws of a random variable. As a result, in my understanding of beta regression, 0s and 1s would intuitively correspond to (infinite) sure results.
Why exactly can't beta regression deal with 0s and 1s in the response variable?
besides the fact that the reason comes in practice from the presence of $log(x)$ and $log(1-x)$, I will try to complement the answer to the question by trying to frame the underlying reason why this h
Why exactly can't beta regression deal with 0s and 1s in the response variable? besides the fact that the reason comes in practice from the presence of $log(x)$ and $log(1-x)$, I will try to complement the answer to the question by trying to frame the underlying reason why this happens. as a matter of fact, the beta distribution is "often used to describe the distribution of a probability value" (wikipedia). It is the distribution of the possible tendencies $p$ of a binomial distribution, knowing the observation of $N$ independent binary draws of a random variable. As a result, in my understanding of beta regression, 0s and 1s would intuitively correspond to (infinite) sure results.
Why exactly can't beta regression deal with 0s and 1s in the response variable? besides the fact that the reason comes in practice from the presence of $log(x)$ and $log(1-x)$, I will try to complement the answer to the question by trying to frame the underlying reason why this h
11,684
Why doesn't Wilks' 1938 proof work for misspecified models?
R.V. Foutz and R.C. Srivastava has examined the issue in detail. Their 1977 paper "The performance of the likelihood ratio test when the model is incorrect" contains a statement of the distributional result in case of misspecification alongside a very brief sketch of the proof, while their 1978 paper "The asymptotic distribution of the likelihood ratio when the model is incorrect" contains the proof -but the latter is typed in old-fashioned type-writer (both papers use the same notation though, so you can combine them in reading). Also, for some steps of the proof they refer to a paper by K.P. Roy "A note on the asymptotic distribution of likelihood ratio" from 1957 which does not appear to be available on-line, even gated. In case of distributional misspecification, if the MLE is still consistent and asymptotically normal (which is not always the case), the LR statistic follows asymptotically a linear combination of independent chi-squares (each of one degree of freedom) $$-2\ln \lambda \xrightarrow{d} \sum_{i=1}^{r}c_i\mathcal \chi^2_i$$ where $r=h-m$. One can see the "similarity": instead of one chi-square with $h-m$ degrees of freedom, we have $h-m$ chi-squares each with one degree of freedom. But the "analogy" stops there, because a linear combination of chi-squares does not have a closed-form density. Each scaled chi-square is a gamma, but with a different $c_i$ parameter that leads to a different scale parameter for the gamma -and the sum of such gammas is not closed-form, although its values can be calculated. For the $c_i$ constants, we have $c_1 \geq c_2\geq ...c_r \geq0$, and they are the eigenvalues of a matrix... which matrix? Well, using the authors notation, set $\Lambda$ to be the Hessian of the log-likelihood and $C$ to be the outer product of the gradient of the log-likelihood (in expectational terms). So $V = \Lambda^{-1} C (\Lambda')^{-1}$ is the asymptotic variance-covariance matrix of the MLE. Then set $M$ to be the $r \times r$ upper diagonal block of $V$. Also write $\Lambda$ in block form $$\Lambda =\left [\begin {matrix} \Lambda_{r\times r} & \Lambda_2'\\ \Lambda_2 & \Lambda_3\\ \end{matrix}\right]$$ and set $W = -\Lambda_{r\times r}+\Lambda_2'\Lambda_3^{-1}\Lambda_2$ ($W$ is the negative of the Schur Complement of $\Lambda$). Then the $c_i$'s are the eigenvalues of the matrix $MW$ evaluated at the true values of the parameters. ADDENDUM Responding to the valid remark of the OP in the comments (sometimes, indeed, questions become a springboard for sharing a more general result, and themselves may be neglected in the process), here is how Wilks's proof proceeds: Wilks starts with the joint normal distribution of the MLE, and proceeds to derive the functional expression of the Likelihood Ratio. Up to and including his eq. $[9]$, the proof can move forward even if we assume that we have a distributional misspecification: as the OP notes, the terms of the variance covariance matrix will be different in the misspecification scenario, but all Wilks does is take derivatives, and identify asymptotically negligible terms. And so he arrives at eq. $[9]$ where we see that the likelihood ratio statistic, if the specification is correct, is just the sum of $h-m$ squared standard normal random variables, and so they are distributed as one chi-square with $h-m$ degrees of freedom: (generic notation) $$-2\ln \lambda = \sum_{i=1}^{h-m}\left(\sqrt n\frac{\hat \theta_i - \theta_i}{\sigma_i}\right)^2 \xrightarrow{d} \mathcal \chi^2_{h-m}$$ But if we have misspecification, then the terms that are used in order to scale the centered and magnified MLE $\sqrt n(\hat \theta -\theta)$ are no longer the terms that will make the variances of each element equal to unity, and so transform each term into a standard normal r.v and the sum into a chi-square. And they are not, because these terms involve the expected values of the second derivatives of the log-likelihood... but the expected value can only be taken with respect to the true distribution, since the MLE is a function of the data and the data follows the true distribution, while the second derivatives of the log-likelihood are calculated based on the wrong density assumption. So under misspecification we have something like $$-2\ln \lambda = \sum_{i=1}^{h-m}\left(\sqrt n\frac{\hat \theta_i - \theta_i}{a_i}\right)^2$$ and the best we can do is to manipulate it into $$-2\ln \lambda = \sum_{i=1}^{h-m}\frac {\sigma_i^2}{a_i^2}\left(\sqrt n\frac{\hat \theta_i - \theta_i}{\sigma_i}\right)^2 = \sum_{i=1}^{h-m}\frac {\sigma_i^2}{a_i^2}\mathcal \chi^2_1$$ which is a sum of scaled chi-square r.v.'s, no longer distributed as one chi-square r.v. with $h-m$ degrees of freedom. The reference provided by the OP is indeed a very clear exposition of this more general case that includes Wilks' result as a special case.
Why doesn't Wilks' 1938 proof work for misspecified models?
R.V. Foutz and R.C. Srivastava has examined the issue in detail. Their 1977 paper "The performance of the likelihood ratio test when the model is incorrect" contains a statement of the distributional
Why doesn't Wilks' 1938 proof work for misspecified models? R.V. Foutz and R.C. Srivastava has examined the issue in detail. Their 1977 paper "The performance of the likelihood ratio test when the model is incorrect" contains a statement of the distributional result in case of misspecification alongside a very brief sketch of the proof, while their 1978 paper "The asymptotic distribution of the likelihood ratio when the model is incorrect" contains the proof -but the latter is typed in old-fashioned type-writer (both papers use the same notation though, so you can combine them in reading). Also, for some steps of the proof they refer to a paper by K.P. Roy "A note on the asymptotic distribution of likelihood ratio" from 1957 which does not appear to be available on-line, even gated. In case of distributional misspecification, if the MLE is still consistent and asymptotically normal (which is not always the case), the LR statistic follows asymptotically a linear combination of independent chi-squares (each of one degree of freedom) $$-2\ln \lambda \xrightarrow{d} \sum_{i=1}^{r}c_i\mathcal \chi^2_i$$ where $r=h-m$. One can see the "similarity": instead of one chi-square with $h-m$ degrees of freedom, we have $h-m$ chi-squares each with one degree of freedom. But the "analogy" stops there, because a linear combination of chi-squares does not have a closed-form density. Each scaled chi-square is a gamma, but with a different $c_i$ parameter that leads to a different scale parameter for the gamma -and the sum of such gammas is not closed-form, although its values can be calculated. For the $c_i$ constants, we have $c_1 \geq c_2\geq ...c_r \geq0$, and they are the eigenvalues of a matrix... which matrix? Well, using the authors notation, set $\Lambda$ to be the Hessian of the log-likelihood and $C$ to be the outer product of the gradient of the log-likelihood (in expectational terms). So $V = \Lambda^{-1} C (\Lambda')^{-1}$ is the asymptotic variance-covariance matrix of the MLE. Then set $M$ to be the $r \times r$ upper diagonal block of $V$. Also write $\Lambda$ in block form $$\Lambda =\left [\begin {matrix} \Lambda_{r\times r} & \Lambda_2'\\ \Lambda_2 & \Lambda_3\\ \end{matrix}\right]$$ and set $W = -\Lambda_{r\times r}+\Lambda_2'\Lambda_3^{-1}\Lambda_2$ ($W$ is the negative of the Schur Complement of $\Lambda$). Then the $c_i$'s are the eigenvalues of the matrix $MW$ evaluated at the true values of the parameters. ADDENDUM Responding to the valid remark of the OP in the comments (sometimes, indeed, questions become a springboard for sharing a more general result, and themselves may be neglected in the process), here is how Wilks's proof proceeds: Wilks starts with the joint normal distribution of the MLE, and proceeds to derive the functional expression of the Likelihood Ratio. Up to and including his eq. $[9]$, the proof can move forward even if we assume that we have a distributional misspecification: as the OP notes, the terms of the variance covariance matrix will be different in the misspecification scenario, but all Wilks does is take derivatives, and identify asymptotically negligible terms. And so he arrives at eq. $[9]$ where we see that the likelihood ratio statistic, if the specification is correct, is just the sum of $h-m$ squared standard normal random variables, and so they are distributed as one chi-square with $h-m$ degrees of freedom: (generic notation) $$-2\ln \lambda = \sum_{i=1}^{h-m}\left(\sqrt n\frac{\hat \theta_i - \theta_i}{\sigma_i}\right)^2 \xrightarrow{d} \mathcal \chi^2_{h-m}$$ But if we have misspecification, then the terms that are used in order to scale the centered and magnified MLE $\sqrt n(\hat \theta -\theta)$ are no longer the terms that will make the variances of each element equal to unity, and so transform each term into a standard normal r.v and the sum into a chi-square. And they are not, because these terms involve the expected values of the second derivatives of the log-likelihood... but the expected value can only be taken with respect to the true distribution, since the MLE is a function of the data and the data follows the true distribution, while the second derivatives of the log-likelihood are calculated based on the wrong density assumption. So under misspecification we have something like $$-2\ln \lambda = \sum_{i=1}^{h-m}\left(\sqrt n\frac{\hat \theta_i - \theta_i}{a_i}\right)^2$$ and the best we can do is to manipulate it into $$-2\ln \lambda = \sum_{i=1}^{h-m}\frac {\sigma_i^2}{a_i^2}\left(\sqrt n\frac{\hat \theta_i - \theta_i}{\sigma_i}\right)^2 = \sum_{i=1}^{h-m}\frac {\sigma_i^2}{a_i^2}\mathcal \chi^2_1$$ which is a sum of scaled chi-square r.v.'s, no longer distributed as one chi-square r.v. with $h-m$ degrees of freedom. The reference provided by the OP is indeed a very clear exposition of this more general case that includes Wilks' result as a special case.
Why doesn't Wilks' 1938 proof work for misspecified models? R.V. Foutz and R.C. Srivastava has examined the issue in detail. Their 1977 paper "The performance of the likelihood ratio test when the model is incorrect" contains a statement of the distributional
11,685
Why doesn't Wilks' 1938 proof work for misspecified models?
Wilks' 1938 proof doesn't work because Wilks used $J^{-1}$ As the asymptotic covariance matrix in his proof. $J^{-1}$ is the inverse of the Hessian of the negative log likelihood rather than the sandwich estimator $J^{-1} K J^{-1}$. Wilks references the $ij$th element of $J$ as $c_{ij}$ in his proof. By making the assumption that $J^{-1}KJ^{-1} = J^{-1}$ Wilks (1938) is assuming that $K=J $ holds which is the Fisher Information Matrix equality. If the probability model is correctly specified then $K=J$. So one interpretation of the assumption by Wilks is that he is assuming the stronger assumption that the probability model is correctly specified.
Why doesn't Wilks' 1938 proof work for misspecified models?
Wilks' 1938 proof doesn't work because Wilks used $J^{-1}$ As the asymptotic covariance matrix in his proof. $J^{-1}$ is the inverse of the Hessian of the negative log likelihood rather than the sandw
Why doesn't Wilks' 1938 proof work for misspecified models? Wilks' 1938 proof doesn't work because Wilks used $J^{-1}$ As the asymptotic covariance matrix in his proof. $J^{-1}$ is the inverse of the Hessian of the negative log likelihood rather than the sandwich estimator $J^{-1} K J^{-1}$. Wilks references the $ij$th element of $J$ as $c_{ij}$ in his proof. By making the assumption that $J^{-1}KJ^{-1} = J^{-1}$ Wilks (1938) is assuming that $K=J $ holds which is the Fisher Information Matrix equality. If the probability model is correctly specified then $K=J$. So one interpretation of the assumption by Wilks is that he is assuming the stronger assumption that the probability model is correctly specified.
Why doesn't Wilks' 1938 proof work for misspecified models? Wilks' 1938 proof doesn't work because Wilks used $J^{-1}$ As the asymptotic covariance matrix in his proof. $J^{-1}$ is the inverse of the Hessian of the negative log likelihood rather than the sandw
11,686
Is a priori power analysis essentially useless?
The basic issue here is true and fairly well known in statistics. However, his interpretation / claim is extreme. There are several issues to be discussed: First, power doesn't change very fast with changes in $N$. (Specifically, it changes as a function of $\sqrt N$, so to halve the standard deviation of your sampling distribution, you need to quadruple your $N$, etc.) However, power is quite sensitive to effect size. Moreover, unless your estimated power is $50\%$, the change in power with a change in effect size isn't symmetrical. If you are trying for $80\%$ power, power will decrease more rapidly with a decrease in Cohen's $d$ than it will increase with an equivalent increase in Cohen's $d$. For example, when starting from $d = .5$ with $N = 128$, if you had 20 fewer observations, power would drop by $\approx 7.9\%$, but if you had 20 more observation, power would increase by $\approx 5.5\%$. On the other hand, if the true effect size were $.1$ lower, then power would be $\approx 16.9\%$ lower, but if it were $.1$ higher, it would only be $\approx 12.6\%$ higher. This asymmetry, and the differing sensitivity, can be seen in the figures below. If you are working from effects estimated from prior research, say a meta-analysis or a pilot study, the solution to this is to incorporate your uncertainty about the true effect size into your power calculation. Ideally, this would involve integrating over the entire distribution of possible effect sizes. This is probably a bridge too far for most applications, but a quick and dirty strategy is to calculate the power at several possible effect sizes, your estimated Cohen's $d$ plus or minus 1 and 2 standard deviations, and then get a weighted average using the probability densities of those quantiles as the weights. If you are conducting a study of something that has never been studied before, this doesn't really matter. You know what effect size you care about. In reality, the effect is either that large (or larger), or it is smaller (even possibly 0). Using the effect size you care about in your power analysis will be valid, and will give you an appropriate test of your hypothesis. If the effect size that you care about is the true value, you will have (say) an $80\%$ chance of 'significance'. If, due to sampling error, the realized effect size in your study is smaller (larger) your result will be less (more) significant, or even non-significant. That is the way it is supposed to work. Second, regarding the broader claim that power analyses (a-priori or otherwise) rely on assumptions, it is not clear what to make of that argument. Of course they do. So does everything else. Not running a power analysis, but just gathering an amount of data based on a number you picked out of a hat, and then analyzing your data, will not improve the situation. Moreover, your resulting analyses will still rely on assumptions, just as all analyses (power or otherwise) always do. If instead you decide that you will continue to collect data and re-analyze them until you get a picture you like or get tired of it, that will be much less valid (and will still entail assumptions that may be invisible to the speaker, but that exist nonetheless). Put simply, there is no way around the fact that assumptions are being made in research and data analysis. You may find these resources of interest: Kraemer, H.C., Mintz, J., Noda, A., Tinklenberg, J., & Yesavage, J.A. (2006). Caution regarding the use of pilot studies to guide power calculations for study proposals, Archives of General Psychiatry, 63, 5, pp. 484-489. Uebersax, J.A. (2007). Bayesian Unconditional Power Analysis. http://www.john-uebersax.com/stat/bpower.htm
Is a priori power analysis essentially useless?
The basic issue here is true and fairly well known in statistics. However, his interpretation / claim is extreme. There are several issues to be discussed: First, power doesn't change very fast wi
Is a priori power analysis essentially useless? The basic issue here is true and fairly well known in statistics. However, his interpretation / claim is extreme. There are several issues to be discussed: First, power doesn't change very fast with changes in $N$. (Specifically, it changes as a function of $\sqrt N$, so to halve the standard deviation of your sampling distribution, you need to quadruple your $N$, etc.) However, power is quite sensitive to effect size. Moreover, unless your estimated power is $50\%$, the change in power with a change in effect size isn't symmetrical. If you are trying for $80\%$ power, power will decrease more rapidly with a decrease in Cohen's $d$ than it will increase with an equivalent increase in Cohen's $d$. For example, when starting from $d = .5$ with $N = 128$, if you had 20 fewer observations, power would drop by $\approx 7.9\%$, but if you had 20 more observation, power would increase by $\approx 5.5\%$. On the other hand, if the true effect size were $.1$ lower, then power would be $\approx 16.9\%$ lower, but if it were $.1$ higher, it would only be $\approx 12.6\%$ higher. This asymmetry, and the differing sensitivity, can be seen in the figures below. If you are working from effects estimated from prior research, say a meta-analysis or a pilot study, the solution to this is to incorporate your uncertainty about the true effect size into your power calculation. Ideally, this would involve integrating over the entire distribution of possible effect sizes. This is probably a bridge too far for most applications, but a quick and dirty strategy is to calculate the power at several possible effect sizes, your estimated Cohen's $d$ plus or minus 1 and 2 standard deviations, and then get a weighted average using the probability densities of those quantiles as the weights. If you are conducting a study of something that has never been studied before, this doesn't really matter. You know what effect size you care about. In reality, the effect is either that large (or larger), or it is smaller (even possibly 0). Using the effect size you care about in your power analysis will be valid, and will give you an appropriate test of your hypothesis. If the effect size that you care about is the true value, you will have (say) an $80\%$ chance of 'significance'. If, due to sampling error, the realized effect size in your study is smaller (larger) your result will be less (more) significant, or even non-significant. That is the way it is supposed to work. Second, regarding the broader claim that power analyses (a-priori or otherwise) rely on assumptions, it is not clear what to make of that argument. Of course they do. So does everything else. Not running a power analysis, but just gathering an amount of data based on a number you picked out of a hat, and then analyzing your data, will not improve the situation. Moreover, your resulting analyses will still rely on assumptions, just as all analyses (power or otherwise) always do. If instead you decide that you will continue to collect data and re-analyze them until you get a picture you like or get tired of it, that will be much less valid (and will still entail assumptions that may be invisible to the speaker, but that exist nonetheless). Put simply, there is no way around the fact that assumptions are being made in research and data analysis. You may find these resources of interest: Kraemer, H.C., Mintz, J., Noda, A., Tinklenberg, J., & Yesavage, J.A. (2006). Caution regarding the use of pilot studies to guide power calculations for study proposals, Archives of General Psychiatry, 63, 5, pp. 484-489. Uebersax, J.A. (2007). Bayesian Unconditional Power Analysis. http://www.john-uebersax.com/stat/bpower.htm
Is a priori power analysis essentially useless? The basic issue here is true and fairly well known in statistics. However, his interpretation / claim is extreme. There are several issues to be discussed: First, power doesn't change very fast wi
11,687
What's the correct way to test the significance of classification results
In addition to @jb.'s excellent answer, let me add that you can use McNemar's test on the same test set to determine if one classifier is significantly better than the other. This will only work for classification problems (what McNemar's original work call a "dichotomous trait") meaning that the classifiers either get it right or wrong, no space in the middle.
What's the correct way to test the significance of classification results
In addition to @jb.'s excellent answer, let me add that you can use McNemar's test on the same test set to determine if one classifier is significantly better than the other. This will only work for c
What's the correct way to test the significance of classification results In addition to @jb.'s excellent answer, let me add that you can use McNemar's test on the same test set to determine if one classifier is significantly better than the other. This will only work for classification problems (what McNemar's original work call a "dichotomous trait") meaning that the classifiers either get it right or wrong, no space in the middle.
What's the correct way to test the significance of classification results In addition to @jb.'s excellent answer, let me add that you can use McNemar's test on the same test set to determine if one classifier is significantly better than the other. This will only work for c
11,688
What's the correct way to test the significance of classification results
Since distribution of classification errors is a binary distribution (either there is misclassifcation or there is none) --- I'd say that using Chi-squared is not sensible. Also only comparing efficiences of classifiers that work on the same datasets is sensible --- 'No free lunch theorem' states that all models have the same average efficiency over all datasets, so that which model will appear better will depend only on what datasets were choosen to train them http://en.wikipedia.org/wiki/No_free_lunch_in_search_and_optimization. If you are comparing efficiency of models A and B over dataset D i think that average efficiency + mean is enough to make a choice. Moreover if one has many models that have resonable efficiency (and are lineary independent of each other) I'd rather build ensemble model than just choose best model.
What's the correct way to test the significance of classification results
Since distribution of classification errors is a binary distribution (either there is misclassifcation or there is none) --- I'd say that using Chi-squared is not sensible. Also only comparing effici
What's the correct way to test the significance of classification results Since distribution of classification errors is a binary distribution (either there is misclassifcation or there is none) --- I'd say that using Chi-squared is not sensible. Also only comparing efficiences of classifiers that work on the same datasets is sensible --- 'No free lunch theorem' states that all models have the same average efficiency over all datasets, so that which model will appear better will depend only on what datasets were choosen to train them http://en.wikipedia.org/wiki/No_free_lunch_in_search_and_optimization. If you are comparing efficiency of models A and B over dataset D i think that average efficiency + mean is enough to make a choice. Moreover if one has many models that have resonable efficiency (and are lineary independent of each other) I'd rather build ensemble model than just choose best model.
What's the correct way to test the significance of classification results Since distribution of classification errors is a binary distribution (either there is misclassifcation or there is none) --- I'd say that using Chi-squared is not sensible. Also only comparing effici
11,689
What's the correct way to test the significance of classification results
I recommend the paper by Tom Dietterich titled "Approximate Statistical Tests for Comparing Supervised Classification Learning Algorithms". Here's the paper's profile on CiteSeer. From the abstract: "This paper reviews five approximate statistical tests for determining whether one learning algorithm out-performs another on a particular learning task. These tests are compared experimentally to determine their probability of incorrectly detecting a difference when no difference exists (type I error). ... McNemar's test, is shown to have low Type I error. ..."
What's the correct way to test the significance of classification results
I recommend the paper by Tom Dietterich titled "Approximate Statistical Tests for Comparing Supervised Classification Learning Algorithms". Here's the paper's profile on CiteSeer. From the abstract:
What's the correct way to test the significance of classification results I recommend the paper by Tom Dietterich titled "Approximate Statistical Tests for Comparing Supervised Classification Learning Algorithms". Here's the paper's profile on CiteSeer. From the abstract: "This paper reviews five approximate statistical tests for determining whether one learning algorithm out-performs another on a particular learning task. These tests are compared experimentally to determine their probability of incorrectly detecting a difference when no difference exists (type I error). ... McNemar's test, is shown to have low Type I error. ..."
What's the correct way to test the significance of classification results I recommend the paper by Tom Dietterich titled "Approximate Statistical Tests for Comparing Supervised Classification Learning Algorithms". Here's the paper's profile on CiteSeer. From the abstract:
11,690
What's the correct way to test the significance of classification results
IMHO there shouldn't be any different between distribution of scores to distribution of any other type of data. so basically all you have to check is whether your data is distributed normally or not see here. Moreover, There are great books that deal thoroughly with this question see here (i.e. in short: they all test whether the outcome of two classifier is significantly different.. and if they do, they can be combined into one - ensemble model)
What's the correct way to test the significance of classification results
IMHO there shouldn't be any different between distribution of scores to distribution of any other type of data. so basically all you have to check is whether your data is distributed normally or not
What's the correct way to test the significance of classification results IMHO there shouldn't be any different between distribution of scores to distribution of any other type of data. so basically all you have to check is whether your data is distributed normally or not see here. Moreover, There are great books that deal thoroughly with this question see here (i.e. in short: they all test whether the outcome of two classifier is significantly different.. and if they do, they can be combined into one - ensemble model)
What's the correct way to test the significance of classification results IMHO there shouldn't be any different between distribution of scores to distribution of any other type of data. so basically all you have to check is whether your data is distributed normally or not
11,691
What's the correct way to test the significance of classification results
There is no single test that is appropriate for all situations; I can recommend the book "Evaluating Learning Algorithms" by Nathalie Japkowicz and Mohak Shah, Cambridge University Press, 2011. The fact that a book of almost 400 pages can be written on this topic suggests it isn't a straight-forward issue. I have often found that there isn't a test that really suits the needs of my study, so it is important to have a good grasp of the advantages and disadvantages of whatever method is eventually used. A common problem is that for large datasets a statistically significant difference may be obtained with an effect size that is of no practical significance.
What's the correct way to test the significance of classification results
There is no single test that is appropriate for all situations; I can recommend the book "Evaluating Learning Algorithms" by Nathalie Japkowicz and Mohak Shah, Cambridge University Press, 2011. The f
What's the correct way to test the significance of classification results There is no single test that is appropriate for all situations; I can recommend the book "Evaluating Learning Algorithms" by Nathalie Japkowicz and Mohak Shah, Cambridge University Press, 2011. The fact that a book of almost 400 pages can be written on this topic suggests it isn't a straight-forward issue. I have often found that there isn't a test that really suits the needs of my study, so it is important to have a good grasp of the advantages and disadvantages of whatever method is eventually used. A common problem is that for large datasets a statistically significant difference may be obtained with an effect size that is of no practical significance.
What's the correct way to test the significance of classification results There is no single test that is appropriate for all situations; I can recommend the book "Evaluating Learning Algorithms" by Nathalie Japkowicz and Mohak Shah, Cambridge University Press, 2011. The f
11,692
What is the distribution of the difference of two-t-distributions
The sum of two independent t-distributed random variables is not t-distributed. Hence you cannot talk about degrees of freedom of this distribution, since the resulting distribution does not have any degrees of freedom in a sense that t-distribution has.
What is the distribution of the difference of two-t-distributions
The sum of two independent t-distributed random variables is not t-distributed. Hence you cannot talk about degrees of freedom of this distribution, since the resulting distribution does not have any
What is the distribution of the difference of two-t-distributions The sum of two independent t-distributed random variables is not t-distributed. Hence you cannot talk about degrees of freedom of this distribution, since the resulting distribution does not have any degrees of freedom in a sense that t-distribution has.
What is the distribution of the difference of two-t-distributions The sum of two independent t-distributed random variables is not t-distributed. Hence you cannot talk about degrees of freedom of this distribution, since the resulting distribution does not have any
11,693
What is the distribution of the difference of two-t-distributions
Agree the answers above, the difference of two independent t-distributed random variables are not t distributed. But I want to add some ways of calculating this. The easiest way of calculating this is using a Monte Carlo method. In R, for example, you random sample 100,000 numbers from the first t distribution, then you random sample another 100,000 numbers from the second t distribution. You let the first set of 100,000 numbers minus the second set of 100,000 numbers. The obtained 100,000 new numbers are the random samples from the distribution of the difference between the two distribution. You can calculate the mean and variance by simply using mean() and var(). This is called Behrens–Fisher distribution. You can refer to the Wiki page: https://en.wikipedia.org/wiki/Behrens%E2%80%93Fisher_distribution. The CI given by this distribution is called "fiducial interval", this is not a CI. Numerical integration might work. This is continued as the bullet point 2. You might refer to the Section 2.5.2 in Bayesian Inference in Statistical Analysis by Box, George E. P., Tiao, George C. It has the detailed steps of integration, and how this is approximated to be a Behrens–Fisher distribution.
What is the distribution of the difference of two-t-distributions
Agree the answers above, the difference of two independent t-distributed random variables are not t distributed. But I want to add some ways of calculating this. The easiest way of calculating this i
What is the distribution of the difference of two-t-distributions Agree the answers above, the difference of two independent t-distributed random variables are not t distributed. But I want to add some ways of calculating this. The easiest way of calculating this is using a Monte Carlo method. In R, for example, you random sample 100,000 numbers from the first t distribution, then you random sample another 100,000 numbers from the second t distribution. You let the first set of 100,000 numbers minus the second set of 100,000 numbers. The obtained 100,000 new numbers are the random samples from the distribution of the difference between the two distribution. You can calculate the mean and variance by simply using mean() and var(). This is called Behrens–Fisher distribution. You can refer to the Wiki page: https://en.wikipedia.org/wiki/Behrens%E2%80%93Fisher_distribution. The CI given by this distribution is called "fiducial interval", this is not a CI. Numerical integration might work. This is continued as the bullet point 2. You might refer to the Section 2.5.2 in Bayesian Inference in Statistical Analysis by Box, George E. P., Tiao, George C. It has the detailed steps of integration, and how this is approximated to be a Behrens–Fisher distribution.
What is the distribution of the difference of two-t-distributions Agree the answers above, the difference of two independent t-distributed random variables are not t distributed. But I want to add some ways of calculating this. The easiest way of calculating this i
11,694
Creating an index of quality from multiple variables to enable rank ordering
The proposed approach may give a reasonable result, but only by accident. At this distance--that is, taking the question at face value, with the meanings of the variables disguised--some problems are apparent: It is not even evident that each variable is positively related to "quality." For example, what if a 10 for 'Var1' means the "quality" is worse than the quality when Var1 is 1? Then adding it to the sum is about as wrong a thing as one can do; it needs to be subtracted. Standardization implies that "quality" depends on the data set itself. Thus the definition will change with different data sets or with additions and deletions to these data. This can make the "quality" into an arbitrary, transient, non-objective construct and preclude comparisons between datasets. There is no definition of "quality". What is it supposed to mean? Ability to block migration of contaminated water? Ability to support organic processes? Ability to promote certain chemical reactions? Soils good for one of these purposes may be especially poor for others. The problem as stated has no purpose: why does "quality" need to be ranked? What will the ranking be used for--input to more analysis, selecting the "best" soil, deciding a scientific hypothesis, developing a theory, promoting a product? The consequences of the ranking are not apparent. If the ranking is incorrect or inferior, what will happen? Will the world be hungrier, the environment more contaminated, scientists more misled, gardeners more disappointed? Why should a linear combination of variables be appropriate? Why shouldn't they be multiplied or exponentiated or combined as a posynomial or something even more esoteric? Raw soil quality measures are commonly re-expressed. For example, log permeability is usually more useful than the permeability itself and log hydrogen ion activity (pH) is much more useful than the activity. What are the appropriate re-expressions of the variables for determining "quality"? One would hope that soils science would answer most of these questions and indicate what the appropriate combination of the variables might be for any objective sense of "quality." If not, then you face a multi-attribute valuation problem. The Wikipedia article lists dozens of methods for addressing this. IMHO, most of them are inappropriate for addressing a scientific question. One of the few with a solid theory and potential applicability to empirical matters is Keeney & Raiffa's multiple attribute valuation theory (MAVT). It requires you to be able to determine, for any two specific combinations of the variables, which of the two should rank higher. A structured sequence of such comparisons reveals (a) appropriate ways to re-express the values; (b) whether or not a linear combination of the re-expressed values will produce the correct ranking; and (c) if a linear combination is possible, it will let you compute the coefficients. In short, MAVT provides algorithms for solving your problem provided you already know how to compare specific cases.
Creating an index of quality from multiple variables to enable rank ordering
The proposed approach may give a reasonable result, but only by accident. At this distance--that is, taking the question at face value, with the meanings of the variables disguised--some problems are
Creating an index of quality from multiple variables to enable rank ordering The proposed approach may give a reasonable result, but only by accident. At this distance--that is, taking the question at face value, with the meanings of the variables disguised--some problems are apparent: It is not even evident that each variable is positively related to "quality." For example, what if a 10 for 'Var1' means the "quality" is worse than the quality when Var1 is 1? Then adding it to the sum is about as wrong a thing as one can do; it needs to be subtracted. Standardization implies that "quality" depends on the data set itself. Thus the definition will change with different data sets or with additions and deletions to these data. This can make the "quality" into an arbitrary, transient, non-objective construct and preclude comparisons between datasets. There is no definition of "quality". What is it supposed to mean? Ability to block migration of contaminated water? Ability to support organic processes? Ability to promote certain chemical reactions? Soils good for one of these purposes may be especially poor for others. The problem as stated has no purpose: why does "quality" need to be ranked? What will the ranking be used for--input to more analysis, selecting the "best" soil, deciding a scientific hypothesis, developing a theory, promoting a product? The consequences of the ranking are not apparent. If the ranking is incorrect or inferior, what will happen? Will the world be hungrier, the environment more contaminated, scientists more misled, gardeners more disappointed? Why should a linear combination of variables be appropriate? Why shouldn't they be multiplied or exponentiated or combined as a posynomial or something even more esoteric? Raw soil quality measures are commonly re-expressed. For example, log permeability is usually more useful than the permeability itself and log hydrogen ion activity (pH) is much more useful than the activity. What are the appropriate re-expressions of the variables for determining "quality"? One would hope that soils science would answer most of these questions and indicate what the appropriate combination of the variables might be for any objective sense of "quality." If not, then you face a multi-attribute valuation problem. The Wikipedia article lists dozens of methods for addressing this. IMHO, most of them are inappropriate for addressing a scientific question. One of the few with a solid theory and potential applicability to empirical matters is Keeney & Raiffa's multiple attribute valuation theory (MAVT). It requires you to be able to determine, for any two specific combinations of the variables, which of the two should rank higher. A structured sequence of such comparisons reveals (a) appropriate ways to re-express the values; (b) whether or not a linear combination of the re-expressed values will produce the correct ranking; and (c) if a linear combination is possible, it will let you compute the coefficients. In short, MAVT provides algorithms for solving your problem provided you already know how to compare specific cases.
Creating an index of quality from multiple variables to enable rank ordering The proposed approach may give a reasonable result, but only by accident. At this distance--that is, taking the question at face value, with the meanings of the variables disguised--some problems are
11,695
Creating an index of quality from multiple variables to enable rank ordering
Anyone looked at Russell G. Congalton 'Review of Assessing the Accuracy of Classifications of Remotely Sensed Data' 1990 ?. It describes a technique known as error matrix for varing matrices, also a term he uses called ' Normalizing data' , whereby one gets all the different vectors and 'normalizes' or sets them to equal from 0 to 1. You basically change all vectors to equal ranges from 0 to 1.
Creating an index of quality from multiple variables to enable rank ordering
Anyone looked at Russell G. Congalton 'Review of Assessing the Accuracy of Classifications of Remotely Sensed Data' 1990 ?. It describes a technique known as error matrix for varing matrices, also a t
Creating an index of quality from multiple variables to enable rank ordering Anyone looked at Russell G. Congalton 'Review of Assessing the Accuracy of Classifications of Remotely Sensed Data' 1990 ?. It describes a technique known as error matrix for varing matrices, also a term he uses called ' Normalizing data' , whereby one gets all the different vectors and 'normalizes' or sets them to equal from 0 to 1. You basically change all vectors to equal ranges from 0 to 1.
Creating an index of quality from multiple variables to enable rank ordering Anyone looked at Russell G. Congalton 'Review of Assessing the Accuracy of Classifications of Remotely Sensed Data' 1990 ?. It describes a technique known as error matrix for varing matrices, also a t
11,696
Creating an index of quality from multiple variables to enable rank ordering
One other thing you did not discuss is the scale of the measurements. V1 and V5 looks like they are of rank order and the other seem not. So standardization may be skewing the score. So you may be better transforming all of the variables into ranks, and determining a weighting for each variable, since it is highly unlikely that they have the same weight. Equal weighting is more of a "no nothing" default. You might want to do some correlation or regression analysis to come up with some a priori weights.
Creating an index of quality from multiple variables to enable rank ordering
One other thing you did not discuss is the scale of the measurements. V1 and V5 looks like they are of rank order and the other seem not. So standardization may be skewing the score. So you may be be
Creating an index of quality from multiple variables to enable rank ordering One other thing you did not discuss is the scale of the measurements. V1 and V5 looks like they are of rank order and the other seem not. So standardization may be skewing the score. So you may be better transforming all of the variables into ranks, and determining a weighting for each variable, since it is highly unlikely that they have the same weight. Equal weighting is more of a "no nothing" default. You might want to do some correlation or regression analysis to come up with some a priori weights.
Creating an index of quality from multiple variables to enable rank ordering One other thing you did not discuss is the scale of the measurements. V1 and V5 looks like they are of rank order and the other seem not. So standardization may be skewing the score. So you may be be
11,697
Creating an index of quality from multiple variables to enable rank ordering
I had a similar problem recently and though I add my approach to the nice answers. I think in order to find a simple way to determine which variable leads to the best ranking. One could transform your problem to a gridsearch approach: Basically use a combined score for the ranking which is composed as such: Finel_score = Var1 * A + Var2 * B + Var3 * C .... Then you can compute the final score with different values for A,B,C (sklearn gridsearch could be used) ... and compare the resulting ranking to an expected ranking (some ground truth is needed to determine the goodness of you ranking). The best parameters result in the weights of your individual variables.
Creating an index of quality from multiple variables to enable rank ordering
I had a similar problem recently and though I add my approach to the nice answers. I think in order to find a simple way to determine which variable leads to the best ranking. One could transform your
Creating an index of quality from multiple variables to enable rank ordering I had a similar problem recently and though I add my approach to the nice answers. I think in order to find a simple way to determine which variable leads to the best ranking. One could transform your problem to a gridsearch approach: Basically use a combined score for the ranking which is composed as such: Finel_score = Var1 * A + Var2 * B + Var3 * C .... Then you can compute the final score with different values for A,B,C (sklearn gridsearch could be used) ... and compare the resulting ranking to an expected ranking (some ground truth is needed to determine the goodness of you ranking). The best parameters result in the weights of your individual variables.
Creating an index of quality from multiple variables to enable rank ordering I had a similar problem recently and though I add my approach to the nice answers. I think in order to find a simple way to determine which variable leads to the best ranking. One could transform your
11,698
Creating an index of quality from multiple variables to enable rank ordering
Following up on Ralph Winters' answer, you might use PCA (principal component analysis) on the matrix of suitably standardized scores. This will give you a "natural" weight vector that you can use to combine future scores. Do this also after all scores have been transformed into ranks. If the results are very similar, you have good reasons to continue with either method. If there are discrepancies, this will lead to interesting questions and a better understanding.
Creating an index of quality from multiple variables to enable rank ordering
Following up on Ralph Winters' answer, you might use PCA (principal component analysis) on the matrix of suitably standardized scores. This will give you a "natural" weight vector that you can use to
Creating an index of quality from multiple variables to enable rank ordering Following up on Ralph Winters' answer, you might use PCA (principal component analysis) on the matrix of suitably standardized scores. This will give you a "natural" weight vector that you can use to combine future scores. Do this also after all scores have been transformed into ranks. If the results are very similar, you have good reasons to continue with either method. If there are discrepancies, this will lead to interesting questions and a better understanding.
Creating an index of quality from multiple variables to enable rank ordering Following up on Ralph Winters' answer, you might use PCA (principal component analysis) on the matrix of suitably standardized scores. This will give you a "natural" weight vector that you can use to
11,699
Classifier vs model vs estimator
estimator: This isn't a word with a rigorous definition but it usually associated with finding a current value in data. If we didn't explicitly count the change in our pocket we might use an estimate. That said, in machine learning it is most frequently used in conjunction with parameter estimation or density estimation. In both cases there is an assumption that data we currently have comes in a form that can be described with a function. With parameter estimation, we believe that the function is a known function that has additional parameters such as rate or mean and we may estimate the value of those parameters. In density estimation we may not even have an assumption about the function but we will attempt to estimate the function regardless. Once we have an estimation we may have at our disposal a model. The estimator then would be the method of generating estimations, for example the method of maximum likelihood. classifier: This specifically refers to a type of function (and use of that function) where the response (or range in functional language) is discrete. Compared to this a regressor will have a continuous response. There are additional response types but these are the two most well known. Once we may have built a classifier, it is expected to predict for us from within a finite range of classes which class a vector of data is likely to indicate. As an example a voice recognition software may record a meeting and attempt to record at any given time which of the finite number of meeting attendees are speaking. Building this software we would give each attendee a number that is nominal only and attempt to classify to that number for each segment of speech. model: The model is the function (or pooled set of functions) that you may accept or reject as being representative of your phenomenon. The word stems from the idea that you may apply domain knowledge to explaining/predicting the phenomenon though this isn't required. A non-parametric model might be derived entirely from the data at hand but the result is often still called a model. This terminology highlights the fact that what has been constructed when a model has been constructed is not reality but only a 'model' of reality. As George Box has said "All models are wrong but some are useful". Having a model allows you to predict but that may not be its purpose; it could also be used to simulate or to explain.
Classifier vs model vs estimator
estimator: This isn't a word with a rigorous definition but it usually associated with finding a current value in data. If we didn't explicitly count the change in our pocket we might use an estimate.
Classifier vs model vs estimator estimator: This isn't a word with a rigorous definition but it usually associated with finding a current value in data. If we didn't explicitly count the change in our pocket we might use an estimate. That said, in machine learning it is most frequently used in conjunction with parameter estimation or density estimation. In both cases there is an assumption that data we currently have comes in a form that can be described with a function. With parameter estimation, we believe that the function is a known function that has additional parameters such as rate or mean and we may estimate the value of those parameters. In density estimation we may not even have an assumption about the function but we will attempt to estimate the function regardless. Once we have an estimation we may have at our disposal a model. The estimator then would be the method of generating estimations, for example the method of maximum likelihood. classifier: This specifically refers to a type of function (and use of that function) where the response (or range in functional language) is discrete. Compared to this a regressor will have a continuous response. There are additional response types but these are the two most well known. Once we may have built a classifier, it is expected to predict for us from within a finite range of classes which class a vector of data is likely to indicate. As an example a voice recognition software may record a meeting and attempt to record at any given time which of the finite number of meeting attendees are speaking. Building this software we would give each attendee a number that is nominal only and attempt to classify to that number for each segment of speech. model: The model is the function (or pooled set of functions) that you may accept or reject as being representative of your phenomenon. The word stems from the idea that you may apply domain knowledge to explaining/predicting the phenomenon though this isn't required. A non-parametric model might be derived entirely from the data at hand but the result is often still called a model. This terminology highlights the fact that what has been constructed when a model has been constructed is not reality but only a 'model' of reality. As George Box has said "All models are wrong but some are useful". Having a model allows you to predict but that may not be its purpose; it could also be used to simulate or to explain.
Classifier vs model vs estimator estimator: This isn't a word with a rigorous definition but it usually associated with finding a current value in data. If we didn't explicitly count the change in our pocket we might use an estimate.
11,700
Classifier vs model vs estimator
An estimator is any object that learns from data; it may be a classification, regression or clustering algorithm or a transformer that extracts/filters useful features from raw data. From scikit-learn documentation.
Classifier vs model vs estimator
An estimator is any object that learns from data; it may be a classification, regression or clustering algorithm or a transformer that extracts/filters useful features from raw data. From scikit-lear
Classifier vs model vs estimator An estimator is any object that learns from data; it may be a classification, regression or clustering algorithm or a transformer that extracts/filters useful features from raw data. From scikit-learn documentation.
Classifier vs model vs estimator An estimator is any object that learns from data; it may be a classification, regression or clustering algorithm or a transformer that extracts/filters useful features from raw data. From scikit-lear