idx
int64
1
56k
question
stringlengths
15
155
answer
stringlengths
2
29.2k
question_cut
stringlengths
15
100
answer_cut
stringlengths
2
200
conversation
stringlengths
47
29.3k
conversation_cut
stringlengths
47
301
15,001
Modern Use Cases of Restricted Boltzmann Machines (RBM's)?
I recently found this paper on "Boltzmann Encoded Adversarial Machines" which integrates RBMs with CNNs as a generative model. The authors show it is mathematically "better" in some ways, and show some toy examples where BEAM seems far more capable of accurately learning the data distribution compared to other GAN models. The "real world" benchmark of CelebA faces was far less impressive -- it's not clear that BEAM does better or even as well as other popular GANs. However, the use of RBMs in this setting is certainly interesting.
Modern Use Cases of Restricted Boltzmann Machines (RBM's)?
I recently found this paper on "Boltzmann Encoded Adversarial Machines" which integrates RBMs with CNNs as a generative model. The authors show it is mathematically "better" in some ways, and show so
Modern Use Cases of Restricted Boltzmann Machines (RBM's)? I recently found this paper on "Boltzmann Encoded Adversarial Machines" which integrates RBMs with CNNs as a generative model. The authors show it is mathematically "better" in some ways, and show some toy examples where BEAM seems far more capable of accurately learning the data distribution compared to other GAN models. The "real world" benchmark of CelebA faces was far less impressive -- it's not clear that BEAM does better or even as well as other popular GANs. However, the use of RBMs in this setting is certainly interesting.
Modern Use Cases of Restricted Boltzmann Machines (RBM's)? I recently found this paper on "Boltzmann Encoded Adversarial Machines" which integrates RBMs with CNNs as a generative model. The authors show it is mathematically "better" in some ways, and show so
15,002
How can I 'dodge' the position of geom_point in ggplot2?
The group should = INDEX instead of ntrunc in the aes. plot = ggplot(data, aes(x=ntrunc, y=beta_best, group=INDEX, colour=INDEX)) + geom_point(aes(shape=detectable), na.rm=TRUE, position="dodge") + geom_errorbar(aes(x=ntrunc, ymax=beta_high, ymin=beta_low), na.rm=TRUE, position="dodge") The plot looks better now.
How can I 'dodge' the position of geom_point in ggplot2?
The group should = INDEX instead of ntrunc in the aes. plot = ggplot(data, aes(x=ntrunc, y=beta_best, group=INDEX, colour=INDEX)) + geom_point(aes(shape=detectable), na.rm=TRUE, position="dodge")
How can I 'dodge' the position of geom_point in ggplot2? The group should = INDEX instead of ntrunc in the aes. plot = ggplot(data, aes(x=ntrunc, y=beta_best, group=INDEX, colour=INDEX)) + geom_point(aes(shape=detectable), na.rm=TRUE, position="dodge") + geom_errorbar(aes(x=ntrunc, ymax=beta_high, ymin=beta_low), na.rm=TRUE, position="dodge") The plot looks better now.
How can I 'dodge' the position of geom_point in ggplot2? The group should = INDEX instead of ntrunc in the aes. plot = ggplot(data, aes(x=ntrunc, y=beta_best, group=INDEX, colour=INDEX)) + geom_point(aes(shape=detectable), na.rm=TRUE, position="dodge")
15,003
Understanding d-separation theory in causal Bayesian networks
Is it not intuitive that you cannot reason from cause to unobserved effect to another cause? If the rain (B) and the sprinkler (D) are causes of the wet ground (C), then can you argue that seeing rain implies that the ground is probably wet, and continue to reason that the sprinkler must be on since the ground is wet?! Of course not. You argued that the ground was wet because of the rain — you can't look for additional causes! If you observe the wet ground, of course the situation changes. Now you may be able to reason from one cause to the other as Frank explains.
Understanding d-separation theory in causal Bayesian networks
Is it not intuitive that you cannot reason from cause to unobserved effect to another cause? If the rain (B) and the sprinkler (D) are causes of the wet ground (C), then can you argue that seeing rai
Understanding d-separation theory in causal Bayesian networks Is it not intuitive that you cannot reason from cause to unobserved effect to another cause? If the rain (B) and the sprinkler (D) are causes of the wet ground (C), then can you argue that seeing rain implies that the ground is probably wet, and continue to reason that the sprinkler must be on since the ground is wet?! Of course not. You argued that the ground was wet because of the rain — you can't look for additional causes! If you observe the wet ground, of course the situation changes. Now you may be able to reason from one cause to the other as Frank explains.
Understanding d-separation theory in causal Bayesian networks Is it not intuitive that you cannot reason from cause to unobserved effect to another cause? If the rain (B) and the sprinkler (D) are causes of the wet ground (C), then can you argue that seeing rai
15,004
Understanding d-separation theory in causal Bayesian networks
Let's forget about X for a moment and consider just the collider of B, C and D. The reason that the v-structure can block the path between B and D is that, in general, if you have two independent random variables (B and D) that affect the same outcome (C), then knowing the outcome can allow you to draw conclusions about the relationship between the random variables, thus allowing for information flow. Using an example from Pearl's book on causality, let C be the observation that the lawn is wet, D the event that it rained, and B the event that the sprinkler was on. Then if you don't know whether the lawn is wet or not, C and D are clearly independent (no information flows). But if you do know that the lawn is wet, then if it rained, it's less likely that the sprinkler was on ($P(B|D) \neq P(B)$) and if the sprinkler was on, it's less likely that the wet grass was caused by the rain ($P(D|B) \neq P(D)$). Hence, knowing that the lawn is wet unblocks the path and makes B and D dependent. To understand this better, it might be useful to have a look at Berkson's Paradox, which describes the same situation.
Understanding d-separation theory in causal Bayesian networks
Let's forget about X for a moment and consider just the collider of B, C and D. The reason that the v-structure can block the path between B and D is that, in general, if you have two independent rand
Understanding d-separation theory in causal Bayesian networks Let's forget about X for a moment and consider just the collider of B, C and D. The reason that the v-structure can block the path between B and D is that, in general, if you have two independent random variables (B and D) that affect the same outcome (C), then knowing the outcome can allow you to draw conclusions about the relationship between the random variables, thus allowing for information flow. Using an example from Pearl's book on causality, let C be the observation that the lawn is wet, D the event that it rained, and B the event that the sprinkler was on. Then if you don't know whether the lawn is wet or not, C and D are clearly independent (no information flows). But if you do know that the lawn is wet, then if it rained, it's less likely that the sprinkler was on ($P(B|D) \neq P(B)$) and if the sprinkler was on, it's less likely that the wet grass was caused by the rain ($P(D|B) \neq P(D)$). Hence, knowing that the lawn is wet unblocks the path and makes B and D dependent. To understand this better, it might be useful to have a look at Berkson's Paradox, which describes the same situation.
Understanding d-separation theory in causal Bayesian networks Let's forget about X for a moment and consider just the collider of B, C and D. The reason that the v-structure can block the path between B and D is that, in general, if you have two independent rand
15,005
Understanding d-separation theory in causal Bayesian networks
Well, up to this point, everything is OK for me since the flow of the information occurs according to intuitive cause-effect relationships. But I don't get the special behavior of so called "V-structures" or "Colliders" in this scheme. Then the hard nut to crack here is the v-structure. I'd like to illustrate the difference between the probability of a variable S conditioned only on the observation of the effect and the influence of the observation of another variable D which is independent of S in the same situation using a fictitious example. Let's say that someone is taking a course, say linear algebra. If he can pass it mainly dependens on the difficulty of the exam. Let's denote the event of passing the course by P, passing as 1 and 0 otherwise; and the difficulty of the exam as D, difficult as 1 and easy as 0. And something nonsense may also exert an influence on his performance or the result, let's say the singularity happens and he would be brainwashed by a machine and then decides not to take the exam. We denote that event by S, and its probability is 0.0001. That seems impossible but by definition its chance should not be zero. Hence we have a graph of the v-structure form now: D S | | \| |/ P If we know that if sigularity comes the student doesn't take the exam: $P(\neg P|S) = 0.999999$ and $P(P|S)=0.000001$, no matter how easy the exam would be. And the prior probabilities are as follows: | d0 | d1 | |:-----|--------:| | 0.5 | 0.5 | | s0 | s1 | |:-------|--------:| | 0.9999 | 0.0001 | | S | D | P(p0|S,D) | P(p1|S,D) | |:------|-----:|----------:|----------:| |s0 | d0 | 0.20 | 0.80 | |s0 | d1 | 0.90 | 0.10 | |s1 | d0 | 0.999999| 0.000001| |s1 | d1 | 0.999999| 0.000001| To check if S and D are independent or not given P we should work out two distributions(see the first two equations in wikipedia: Conditional Independence): $P(S|P)$ and $P(S|P, D)$. If they are equal we can say that the conditional independence hold, otherwise it doesn't. 1) If we don't know the result we can calculate the probability of the singularity happenning given the course is easy. \begin{align} P(S|\neg D) & = P(S, P|\neg D)+P(S, \neg P| \neg D) \\ & = \frac{P(S=1, P=1, D=0)}{P(D=0)} + \frac{P(S=1, P=0, D=0)}{P(D=0)} \\ & = \frac{P(S=1)P(D=0|S=1)P(P=1|D=0,S=1)}{P(D=0)} + \frac{P(S=1)P(D=0|S=1)P(P=0|D=0,S=1)}{P(D=0)} \\ & = \frac{P(S=1)P(D=0|S=1)}{P(D=0)} \\ & = \frac{P(S=1)P(D=0)}{P(D=0)} \\ & = P(S=1) \\ & = 0.0001 \end{align} As you can see above that doesn't matter if the exam is passed or not. What comes as it should come. It can be seen as a marginal probability over P. And we can also work out the probability the the singularity happens given that the student doesn't pass the exam: \begin{align} P(S, |\neg P) &= \frac{P(S,\neg P)}{P(\neg P)} \\ &= \frac{P(S,\neg p, D) + P(S,\neg P, \neg D)}{P(\neg P)}\\ &= \frac{P(\neg P|S, D) P(S) P(D)+P(\neg P|S, \neg D)P(S)P(\neg D)}{\sum_{S,D}P(\neg P |S,D)P(S)P(D) }\\ &= 0.0001818 \end{align} Knowing that the guy doesn't pass the exam we can guess that he may be brainwashed by a machine is 0.0001818 which is a little bigger than when we don't know it. 2) But what if we know that the guy failed the exam and the exam is easy? \begin{align} P(S, |\neg P, \neg D) &= \frac{P(S=1, P=0, D=0)}{P(P=0, D=0)} \\ & = \frac{P(P=0|S=1, D=0)P(S=1)P(D=0)}{P(P=0|S=1, D=0)P(S=1)P(D=0)+P(P=0|S=0, D=0)P(S=0)P(D=0)} \\ & = \frac{0.999999 \times 0.0001 \times 0.5}{0.2 \times 0.9999 \times 0.5+0.999999 \times 0.0001 \times 0.5} \\ & = 0.0004998 \end{align} Lo and behold, the change is much bigger than we just know he doesn't plass the exam. Then we see that $P(S|P) \neq P(S|P, D)$ we can infer that $S \perp D | P \notin I(P(P, S, D))$ which means D can influence S via P. May this detailed derivation be of hlep.
Understanding d-separation theory in causal Bayesian networks
Well, up to this point, everything is OK for me since the flow of the information occurs according to intuitive cause-effect relationships. But I don't get the special behavior of so called "V-str
Understanding d-separation theory in causal Bayesian networks Well, up to this point, everything is OK for me since the flow of the information occurs according to intuitive cause-effect relationships. But I don't get the special behavior of so called "V-structures" or "Colliders" in this scheme. Then the hard nut to crack here is the v-structure. I'd like to illustrate the difference between the probability of a variable S conditioned only on the observation of the effect and the influence of the observation of another variable D which is independent of S in the same situation using a fictitious example. Let's say that someone is taking a course, say linear algebra. If he can pass it mainly dependens on the difficulty of the exam. Let's denote the event of passing the course by P, passing as 1 and 0 otherwise; and the difficulty of the exam as D, difficult as 1 and easy as 0. And something nonsense may also exert an influence on his performance or the result, let's say the singularity happens and he would be brainwashed by a machine and then decides not to take the exam. We denote that event by S, and its probability is 0.0001. That seems impossible but by definition its chance should not be zero. Hence we have a graph of the v-structure form now: D S | | \| |/ P If we know that if sigularity comes the student doesn't take the exam: $P(\neg P|S) = 0.999999$ and $P(P|S)=0.000001$, no matter how easy the exam would be. And the prior probabilities are as follows: | d0 | d1 | |:-----|--------:| | 0.5 | 0.5 | | s0 | s1 | |:-------|--------:| | 0.9999 | 0.0001 | | S | D | P(p0|S,D) | P(p1|S,D) | |:------|-----:|----------:|----------:| |s0 | d0 | 0.20 | 0.80 | |s0 | d1 | 0.90 | 0.10 | |s1 | d0 | 0.999999| 0.000001| |s1 | d1 | 0.999999| 0.000001| To check if S and D are independent or not given P we should work out two distributions(see the first two equations in wikipedia: Conditional Independence): $P(S|P)$ and $P(S|P, D)$. If they are equal we can say that the conditional independence hold, otherwise it doesn't. 1) If we don't know the result we can calculate the probability of the singularity happenning given the course is easy. \begin{align} P(S|\neg D) & = P(S, P|\neg D)+P(S, \neg P| \neg D) \\ & = \frac{P(S=1, P=1, D=0)}{P(D=0)} + \frac{P(S=1, P=0, D=0)}{P(D=0)} \\ & = \frac{P(S=1)P(D=0|S=1)P(P=1|D=0,S=1)}{P(D=0)} + \frac{P(S=1)P(D=0|S=1)P(P=0|D=0,S=1)}{P(D=0)} \\ & = \frac{P(S=1)P(D=0|S=1)}{P(D=0)} \\ & = \frac{P(S=1)P(D=0)}{P(D=0)} \\ & = P(S=1) \\ & = 0.0001 \end{align} As you can see above that doesn't matter if the exam is passed or not. What comes as it should come. It can be seen as a marginal probability over P. And we can also work out the probability the the singularity happens given that the student doesn't pass the exam: \begin{align} P(S, |\neg P) &= \frac{P(S,\neg P)}{P(\neg P)} \\ &= \frac{P(S,\neg p, D) + P(S,\neg P, \neg D)}{P(\neg P)}\\ &= \frac{P(\neg P|S, D) P(S) P(D)+P(\neg P|S, \neg D)P(S)P(\neg D)}{\sum_{S,D}P(\neg P |S,D)P(S)P(D) }\\ &= 0.0001818 \end{align} Knowing that the guy doesn't pass the exam we can guess that he may be brainwashed by a machine is 0.0001818 which is a little bigger than when we don't know it. 2) But what if we know that the guy failed the exam and the exam is easy? \begin{align} P(S, |\neg P, \neg D) &= \frac{P(S=1, P=0, D=0)}{P(P=0, D=0)} \\ & = \frac{P(P=0|S=1, D=0)P(S=1)P(D=0)}{P(P=0|S=1, D=0)P(S=1)P(D=0)+P(P=0|S=0, D=0)P(S=0)P(D=0)} \\ & = \frac{0.999999 \times 0.0001 \times 0.5}{0.2 \times 0.9999 \times 0.5+0.999999 \times 0.0001 \times 0.5} \\ & = 0.0004998 \end{align} Lo and behold, the change is much bigger than we just know he doesn't plass the exam. Then we see that $P(S|P) \neq P(S|P, D)$ we can infer that $S \perp D | P \notin I(P(P, S, D))$ which means D can influence S via P. May this detailed derivation be of hlep.
Understanding d-separation theory in causal Bayesian networks Well, up to this point, everything is OK for me since the flow of the information occurs according to intuitive cause-effect relationships. But I don't get the special behavior of so called "V-str
15,006
Quiz: Tell the classifier by its decision boundary
Really like this question! First thing that comes to mind is the division between linear and non-linear classifiers. Three classifiers are linear (linear svm, perceptron and logistic regression) and three plots show a linear decision boundary (A, B, C). So lets start with those. Linear The most sallient linear plot is plot B because it has a line with a slope. This is odd for logistic regression and svm because they can improve their loss-functions more by being a flat line (i.e. being further away from (all) the points). Thus, plot B is the perceptron. Since the perceptron ouput is either 0 or 1, all the solutions that seperate one class from the other are equally good. That is why it does not improve any further. The difference between plot _A) and C is more subtle. The decision boundary is slightly lower in plot A. A SVM as a fixed number of support vectors while the loss function of logistic regression is determined all the points. Since there are more red crosses than blue dots logistic regression avoids the red crosses more than the blue dots. The linear SVM just tries to be as far away from the red support vectors as from the blue support vectors. That's why plot A is the decision boundary of logistic regression and plot C is made using a linear SVM. Non-linear Lets continue with the non-linear plots and classifiers. I agree with your observation that plot F is probably the ReLu NN since it has the sharpest boundaries. A ReLu unit because activated at once if the activation exceeds 0 and this causes the output unit to follow a different linear line. If you look really, really good you can spot about 8 changes of direction in the line so probably 2 units have little impact on the final outcome. So plot F is the ReLu NN. About the last two ones I am not so sure. Both a tanh NN and the polynomial kernelized SVM can have multiple boundaries. Plot D is obviously classified worse. A tanh NN can improve on this situation by bending the curves differently and putting more blue or red points in the outer region. However, this plot is kind of strange though. I guess the left upper part is classified as red and the right lower part as blue. But how is the middle part classified? It should be red or blue, but then one of the decision boundary shouldn't been drawn. The only possible option is thus that the outer parts are classified as one color and the inner part as the other color. That's strange and really bad. So I am not sure about this one. Let's look at plot E. It has both curved and straight lines. For a degree-2 kernelized SVM it is difficult (close to impossible) to have a straight line decision boundary since the squared distance gradually favors 1 of the 2 classes. The tanh activations functions hover can get saturated such that the hidden state is composed of 0's and 1's. In the case then only 1 unit then changes its state to say .5 you can get a linear decision boundary. So I would say that plot E is a tanh NN and thus plot D is a kernelized SVM. To bad for the poor old SVM though. Conclusions A - Logistic Regression B - Perceptron C - Linear SVM D - Kernelized SVM (Polynomial kernel of order 2) E - Neural Network (1 hidden layer with 10 tanh units) F - Neural Network (1 hidden layer with 10 rectified linear units)
Quiz: Tell the classifier by its decision boundary
Really like this question! First thing that comes to mind is the division between linear and non-linear classifiers. Three classifiers are linear (linear svm, perceptron and logistic regression) and
Quiz: Tell the classifier by its decision boundary Really like this question! First thing that comes to mind is the division between linear and non-linear classifiers. Three classifiers are linear (linear svm, perceptron and logistic regression) and three plots show a linear decision boundary (A, B, C). So lets start with those. Linear The most sallient linear plot is plot B because it has a line with a slope. This is odd for logistic regression and svm because they can improve their loss-functions more by being a flat line (i.e. being further away from (all) the points). Thus, plot B is the perceptron. Since the perceptron ouput is either 0 or 1, all the solutions that seperate one class from the other are equally good. That is why it does not improve any further. The difference between plot _A) and C is more subtle. The decision boundary is slightly lower in plot A. A SVM as a fixed number of support vectors while the loss function of logistic regression is determined all the points. Since there are more red crosses than blue dots logistic regression avoids the red crosses more than the blue dots. The linear SVM just tries to be as far away from the red support vectors as from the blue support vectors. That's why plot A is the decision boundary of logistic regression and plot C is made using a linear SVM. Non-linear Lets continue with the non-linear plots and classifiers. I agree with your observation that plot F is probably the ReLu NN since it has the sharpest boundaries. A ReLu unit because activated at once if the activation exceeds 0 and this causes the output unit to follow a different linear line. If you look really, really good you can spot about 8 changes of direction in the line so probably 2 units have little impact on the final outcome. So plot F is the ReLu NN. About the last two ones I am not so sure. Both a tanh NN and the polynomial kernelized SVM can have multiple boundaries. Plot D is obviously classified worse. A tanh NN can improve on this situation by bending the curves differently and putting more blue or red points in the outer region. However, this plot is kind of strange though. I guess the left upper part is classified as red and the right lower part as blue. But how is the middle part classified? It should be red or blue, but then one of the decision boundary shouldn't been drawn. The only possible option is thus that the outer parts are classified as one color and the inner part as the other color. That's strange and really bad. So I am not sure about this one. Let's look at plot E. It has both curved and straight lines. For a degree-2 kernelized SVM it is difficult (close to impossible) to have a straight line decision boundary since the squared distance gradually favors 1 of the 2 classes. The tanh activations functions hover can get saturated such that the hidden state is composed of 0's and 1's. In the case then only 1 unit then changes its state to say .5 you can get a linear decision boundary. So I would say that plot E is a tanh NN and thus plot D is a kernelized SVM. To bad for the poor old SVM though. Conclusions A - Logistic Regression B - Perceptron C - Linear SVM D - Kernelized SVM (Polynomial kernel of order 2) E - Neural Network (1 hidden layer with 10 tanh units) F - Neural Network (1 hidden layer with 10 rectified linear units)
Quiz: Tell the classifier by its decision boundary Really like this question! First thing that comes to mind is the division between linear and non-linear classifiers. Three classifiers are linear (linear svm, perceptron and logistic regression) and
15,007
What is the difference between regular PCA and probabilistic PCA?
The goal of PPCA is not to give better results than PCA, but to permit a broad range of future extensions and analysis. The paper states some of the advantages clearly in the introduction, ie/eg: "the definition of a likelihood measure enables a comparison with other probabilistic techniques, while facilitating statistical testing and permitting the application of Bayesian models". Bayesian models in particular are enjoying a huge renaissance lately, eg VAE, "auto-encoding variational Bayes", https://arxiv.org/abs/1312.6114 . Extension of PCA to be usable in variational frameworks and similar has the potential for another researcher to say 'Oh hey, what if I do ... ?'
What is the difference between regular PCA and probabilistic PCA?
The goal of PPCA is not to give better results than PCA, but to permit a broad range of future extensions and analysis. The paper states some of the advantages clearly in the introduction, ie/eg: "the
What is the difference between regular PCA and probabilistic PCA? The goal of PPCA is not to give better results than PCA, but to permit a broad range of future extensions and analysis. The paper states some of the advantages clearly in the introduction, ie/eg: "the definition of a likelihood measure enables a comparison with other probabilistic techniques, while facilitating statistical testing and permitting the application of Bayesian models". Bayesian models in particular are enjoying a huge renaissance lately, eg VAE, "auto-encoding variational Bayes", https://arxiv.org/abs/1312.6114 . Extension of PCA to be usable in variational frameworks and similar has the potential for another researcher to say 'Oh hey, what if I do ... ?'
What is the difference between regular PCA and probabilistic PCA? The goal of PPCA is not to give better results than PCA, but to permit a broad range of future extensions and analysis. The paper states some of the advantages clearly in the introduction, ie/eg: "the
15,008
What is shrinkage?
In 1961 James and Stein published an article called "Estimation with Quadratic Loss" https://projecteuclid.org/download/pdf_1/euclid.bsmsp/1200512173 . While it doesn't specifically coin the term shrinkage, they discuss minimax estimators for high dimensional (actually even for a 3 parameter location) statistics that have less risk (expected loss) than the usual MLE (each component the sample average) for normal data. Bradley Efron calls their finding "the most striking theorem of post-war mathematical statistics". This article has been cited 3,310 times. Copas in 1983 writes the first article Regression, Prediction and Shrinkage to coin the term "shrinkage". It's defined implicitly in the abstract: The fit of a regression predictor to new data is nearly always worse than its fit to the original data. Anticipating this shrinkage leads to Stein‐type predictors which, under certain assumptions, give a uniformly lower prediction mean squared error than least squares. And in all successive research, it seems that shrinkage refers to the operating characteristics (and estimates thereof) for out-of-sample validity of prediction and estimation in the context of finding admissible and/or minimax estimators.
What is shrinkage?
In 1961 James and Stein published an article called "Estimation with Quadratic Loss" https://projecteuclid.org/download/pdf_1/euclid.bsmsp/1200512173 . While it doesn't specifically coin the term shri
What is shrinkage? In 1961 James and Stein published an article called "Estimation with Quadratic Loss" https://projecteuclid.org/download/pdf_1/euclid.bsmsp/1200512173 . While it doesn't specifically coin the term shrinkage, they discuss minimax estimators for high dimensional (actually even for a 3 parameter location) statistics that have less risk (expected loss) than the usual MLE (each component the sample average) for normal data. Bradley Efron calls their finding "the most striking theorem of post-war mathematical statistics". This article has been cited 3,310 times. Copas in 1983 writes the first article Regression, Prediction and Shrinkage to coin the term "shrinkage". It's defined implicitly in the abstract: The fit of a regression predictor to new data is nearly always worse than its fit to the original data. Anticipating this shrinkage leads to Stein‐type predictors which, under certain assumptions, give a uniformly lower prediction mean squared error than least squares. And in all successive research, it seems that shrinkage refers to the operating characteristics (and estimates thereof) for out-of-sample validity of prediction and estimation in the context of finding admissible and/or minimax estimators.
What is shrinkage? In 1961 James and Stein published an article called "Estimation with Quadratic Loss" https://projecteuclid.org/download/pdf_1/euclid.bsmsp/1200512173 . While it doesn't specifically coin the term shri
15,009
What is shrinkage?
This is about regularization. Suppose you would like to fit a curve and you use a square loss function (you can pick different). By fit you would like to recover the parameters that govern the process which generated that curve. Now imagine that you would like to fit this curve using 100th polynomial (just for example). You are pretty likely going to overfit or capture every kink and noise of the curve. In addition, your prediction capabilities outside the given training data interval will be likely very poor. So, regularization term is added to the objective function with some weight multiplied by the regularization factor - $l_1$, $l_2$ or custom. In the case of $l_2$, which is arbuably simpler to understand, this will have an effect that the large parameter values will be forced to reduce aka shrink. You can think of regularization or shrinkage as driving your algorithm to a solution which might be a better solution.
What is shrinkage?
This is about regularization. Suppose you would like to fit a curve and you use a square loss function (you can pick different). By fit you would like to recover the parameters that govern the process
What is shrinkage? This is about regularization. Suppose you would like to fit a curve and you use a square loss function (you can pick different). By fit you would like to recover the parameters that govern the process which generated that curve. Now imagine that you would like to fit this curve using 100th polynomial (just for example). You are pretty likely going to overfit or capture every kink and noise of the curve. In addition, your prediction capabilities outside the given training data interval will be likely very poor. So, regularization term is added to the objective function with some weight multiplied by the regularization factor - $l_1$, $l_2$ or custom. In the case of $l_2$, which is arbuably simpler to understand, this will have an effect that the large parameter values will be forced to reduce aka shrink. You can think of regularization or shrinkage as driving your algorithm to a solution which might be a better solution.
What is shrinkage? This is about regularization. Suppose you would like to fit a curve and you use a square loss function (you can pick different). By fit you would like to recover the parameters that govern the process
15,010
Is accuracy = 1- test error rate
In principle, accuracy is the fraction of properly predicted cases. This is the same as 1 - the fraction of misclassified cases or 1 - the *error* (rate). Both terms may be sometimes used in a more vague way, however, and cover different things like class-balanced error/accuracy or even F-score or AUROC -- it is always best to look for/include a proper clarification in the paper or report. Also, note that test error rate implies error on a test set, so it is likely 1-test set accuracy, and there may be other accuracies flying around.
Is accuracy = 1- test error rate
In principle, accuracy is the fraction of properly predicted cases. This is the same as 1 - the fraction of misclassified cases or 1 - the *error* (rate). Both terms may be sometimes used in a more v
Is accuracy = 1- test error rate In principle, accuracy is the fraction of properly predicted cases. This is the same as 1 - the fraction of misclassified cases or 1 - the *error* (rate). Both terms may be sometimes used in a more vague way, however, and cover different things like class-balanced error/accuracy or even F-score or AUROC -- it is always best to look for/include a proper clarification in the paper or report. Also, note that test error rate implies error on a test set, so it is likely 1-test set accuracy, and there may be other accuracies flying around.
Is accuracy = 1- test error rate In principle, accuracy is the fraction of properly predicted cases. This is the same as 1 - the fraction of misclassified cases or 1 - the *error* (rate). Both terms may be sometimes used in a more v
15,011
Is accuracy = 1- test error rate
@mbq answered: "1-the fraction of misclassified cases, that is error(rate)" However, it seems wrong as misclassification and error are the same thing. See below (from http://www.dataschool.io/simple-guide-to-confusion-matrix-terminology/): Accuracy: Overall, how often is the classifier correct? (TP+TN)/total = (100+50)/165 = 0.91 Misclassification Rate: Overall, how often is it wrong? (FP+FN)/total = (10+5)/165 = 0.09 equivalent to 1 minus Accuracy also known as "Error Rate"
Is accuracy = 1- test error rate
@mbq answered: "1-the fraction of misclassified cases, that is error(rate)" However, it seems wrong as misclassification and error are the same thing. See below (from http://www.dataschool.io/simpl
Is accuracy = 1- test error rate @mbq answered: "1-the fraction of misclassified cases, that is error(rate)" However, it seems wrong as misclassification and error are the same thing. See below (from http://www.dataschool.io/simple-guide-to-confusion-matrix-terminology/): Accuracy: Overall, how often is the classifier correct? (TP+TN)/total = (100+50)/165 = 0.91 Misclassification Rate: Overall, how often is it wrong? (FP+FN)/total = (10+5)/165 = 0.09 equivalent to 1 minus Accuracy also known as "Error Rate"
Is accuracy = 1- test error rate @mbq answered: "1-the fraction of misclassified cases, that is error(rate)" However, it seems wrong as misclassification and error are the same thing. See below (from http://www.dataschool.io/simpl
15,012
Outlier detection in very small sets
Outliers in small samples can always be very tricky to detect. In most cases actually I would advocate that if you feel that your data are not bluntly corrupted, an "outlierish" value might not be problematic and its exclusion might be unreasonable. Probably using robust statistical techniques will be more sensible and closer to a middle-ground solution. You have a small sample; try to make every sample point count. :) Regarding your suggested approach: I would not hastily enforce a normality assumption to your data with a 68-95-99.7 rule on them (as you seem to somehow do with your 2SD heuristic rule). Chebyshev's inequality for once assumes a 75-88.9-93.8 rule on them which is clearly less rigid. Other "rules" also exist; the Definition and detection section in the Outlier lemma in wikipedia has a bundle of heuristics. Here is another one: A free book reference I have come across on the matter, NIST/SEMATECH e-Handbook of Statistical Methods, presents the following idea by Iglewicz and Hoaglin (1993): Use modified $Z$-scores $M$ such that: $M_i = .6745(x_i-\tilde{x})/MAD$ where $\tilde{x}$ is your median and MAD is the median absolute deviation of your sample. Then assume that absolute values of $M$ above 3.5 are potential outliers. It is a semi-parametric suggestion (as most of them are, the parameter here being the $3.5$). In your example case it would marginally exclude your 295.5 but clearly retain your 292.6 measure... (For what's worth I wouldn't exclude any values out of your example case.) Again, given you have a really small sample, if you believe that your sample is not obviously corrupted (a human 9'4" tall), I would advise you not to exclude data hastily. Your "suspected outliers" might be uncorrupted data; their use could actually assist rather than harm your analysis.
Outlier detection in very small sets
Outliers in small samples can always be very tricky to detect. In most cases actually I would advocate that if you feel that your data are not bluntly corrupted, an "outlierish" value might not be pro
Outlier detection in very small sets Outliers in small samples can always be very tricky to detect. In most cases actually I would advocate that if you feel that your data are not bluntly corrupted, an "outlierish" value might not be problematic and its exclusion might be unreasonable. Probably using robust statistical techniques will be more sensible and closer to a middle-ground solution. You have a small sample; try to make every sample point count. :) Regarding your suggested approach: I would not hastily enforce a normality assumption to your data with a 68-95-99.7 rule on them (as you seem to somehow do with your 2SD heuristic rule). Chebyshev's inequality for once assumes a 75-88.9-93.8 rule on them which is clearly less rigid. Other "rules" also exist; the Definition and detection section in the Outlier lemma in wikipedia has a bundle of heuristics. Here is another one: A free book reference I have come across on the matter, NIST/SEMATECH e-Handbook of Statistical Methods, presents the following idea by Iglewicz and Hoaglin (1993): Use modified $Z$-scores $M$ such that: $M_i = .6745(x_i-\tilde{x})/MAD$ where $\tilde{x}$ is your median and MAD is the median absolute deviation of your sample. Then assume that absolute values of $M$ above 3.5 are potential outliers. It is a semi-parametric suggestion (as most of them are, the parameter here being the $3.5$). In your example case it would marginally exclude your 295.5 but clearly retain your 292.6 measure... (For what's worth I wouldn't exclude any values out of your example case.) Again, given you have a really small sample, if you believe that your sample is not obviously corrupted (a human 9'4" tall), I would advise you not to exclude data hastily. Your "suspected outliers" might be uncorrupted data; their use could actually assist rather than harm your analysis.
Outlier detection in very small sets Outliers in small samples can always be very tricky to detect. In most cases actually I would advocate that if you feel that your data are not bluntly corrupted, an "outlierish" value might not be pro
15,013
Outlier detection in very small sets
Point the first - it may be worth going back to rgb color. It's rarely good to throw away data, and the magnitude of the rgb vector isn't the only way to represent brightness - perceived brightness is different, as is value in HSV. But putting that to one side and dealing with the data you do have, have you considered forming this as a classification problem instead of a modelling one, and doing some machine learning? You have an input, which is a vector with 12 real values in it (the brightness readings). You have an output, which is a vector of 12 binary values (1=inlier, 0=outlier). Get several sets of brightness reading and hand label them yourself, showing which brightness reading in each set is an inlier/outlier. Something like this: x1 = {212.0, 209.6, 211.5, $\ldots$ , 213.0}, y1 = {1,0,1, $\ldots$,1} x2 = {208.1, 207.9, 211.2, $\ldots$ , 208.2}, y2 = {1,1,0, $\ldots$,1} x3 = {223.4, 222.9, 222.8, $\ldots$ , 223.0}, y3 = {1,1,1, $\ldots$,1} $\ldots$ Then, run the whole lot through a classifier of some sort: You could use a single classifier which outputs 12 different binary values - a neural network would let you set this up pretty easily. Or, you could use a standard binary classifier (e.g. SVMlite) and train 12 different models, one classifying whether each element of the output is an inlier/outlier. And you're done! No need to fuss trying to find the 'rule' which separates inliers from outliers yourself. Just get a few sets of data which look sensible and let the machine do that for you :) ~~~ EDIT: Incidentally, your proposed method, where you iteratively fit a gaussian then classify each sample more than 2 standard deviations away as an outlier, looks a lot like an expectation maximisation algorithm. Something like this: A single gaussian component (modelling the inliers) A uniform background component (the outliers) Some prior probability of each that depends in a non-obvious way on the width of the gaussian (the 'classify at 2 standard deviations' rule). Hard classification at the expectation step. If you do go down that route it may be worth googling for EM algorithms and checking what assumptions you're building into your model.
Outlier detection in very small sets
Point the first - it may be worth going back to rgb color. It's rarely good to throw away data, and the magnitude of the rgb vector isn't the only way to represent brightness - perceived brightness is
Outlier detection in very small sets Point the first - it may be worth going back to rgb color. It's rarely good to throw away data, and the magnitude of the rgb vector isn't the only way to represent brightness - perceived brightness is different, as is value in HSV. But putting that to one side and dealing with the data you do have, have you considered forming this as a classification problem instead of a modelling one, and doing some machine learning? You have an input, which is a vector with 12 real values in it (the brightness readings). You have an output, which is a vector of 12 binary values (1=inlier, 0=outlier). Get several sets of brightness reading and hand label them yourself, showing which brightness reading in each set is an inlier/outlier. Something like this: x1 = {212.0, 209.6, 211.5, $\ldots$ , 213.0}, y1 = {1,0,1, $\ldots$,1} x2 = {208.1, 207.9, 211.2, $\ldots$ , 208.2}, y2 = {1,1,0, $\ldots$,1} x3 = {223.4, 222.9, 222.8, $\ldots$ , 223.0}, y3 = {1,1,1, $\ldots$,1} $\ldots$ Then, run the whole lot through a classifier of some sort: You could use a single classifier which outputs 12 different binary values - a neural network would let you set this up pretty easily. Or, you could use a standard binary classifier (e.g. SVMlite) and train 12 different models, one classifying whether each element of the output is an inlier/outlier. And you're done! No need to fuss trying to find the 'rule' which separates inliers from outliers yourself. Just get a few sets of data which look sensible and let the machine do that for you :) ~~~ EDIT: Incidentally, your proposed method, where you iteratively fit a gaussian then classify each sample more than 2 standard deviations away as an outlier, looks a lot like an expectation maximisation algorithm. Something like this: A single gaussian component (modelling the inliers) A uniform background component (the outliers) Some prior probability of each that depends in a non-obvious way on the width of the gaussian (the 'classify at 2 standard deviations' rule). Hard classification at the expectation step. If you do go down that route it may be worth googling for EM algorithms and checking what assumptions you're building into your model.
Outlier detection in very small sets Point the first - it may be worth going back to rgb color. It's rarely good to throw away data, and the magnitude of the rgb vector isn't the only way to represent brightness - perceived brightness is
15,014
Outlier detection in very small sets
Dixon's Q-test for outliers in very small datasets seems fits well to this kind of situation: http://en.wikipedia.org/wiki/Dixon%27s_Q_test http://www.chem.uoa.gr/applets/AppletQtest/Text_Qtest2.htm
Outlier detection in very small sets
Dixon's Q-test for outliers in very small datasets seems fits well to this kind of situation: http://en.wikipedia.org/wiki/Dixon%27s_Q_test http://www.chem.uoa.gr/applets/AppletQtest/Text_Qtest2.htm
Outlier detection in very small sets Dixon's Q-test for outliers in very small datasets seems fits well to this kind of situation: http://en.wikipedia.org/wiki/Dixon%27s_Q_test http://www.chem.uoa.gr/applets/AppletQtest/Text_Qtest2.htm
Outlier detection in very small sets Dixon's Q-test for outliers in very small datasets seems fits well to this kind of situation: http://en.wikipedia.org/wiki/Dixon%27s_Q_test http://www.chem.uoa.gr/applets/AppletQtest/Text_Qtest2.htm
15,015
Problem defining ARIMA order
How do I select the best ARIMA model (by trying all different orders and checking the best MASE/MAPE/MSE? where the selection of performance measurement can be a discussion in it's own..) Out of sample risk estimates are the gold standard for performance evaluation, and therefore for model selection. Ideally, you cross-validate so that your risk estimates are averaged over more data. FPP explains one cross-validation method for time series. See Tashman for a review of other methods: Tashman, L. J. (2000). Out-of-sample tests of forecasting accuracy: an analysis and review. International Journal of Forecasting, 16(4), 437–450. doi:10.1016/S0169-2070(00)00065-0 Of course, cross-validation is time consuming and so people often resort to using in-sample criteria to select a model, such as AIC, which is how auto.arima selects the best model. This approach is perfectly valid, if perhaps not as optimal. If I generate a new model and forecast for every new day forecast (as in online forecasting), do I need to take the yearly trend into account and how? (as in such a small subset my guess would be that the trend is neglible) I'm not sure what you mean by yearly trend. Assuming you mean yearly seasonality, there's not really any way to take it into account with less than a year's worth of data. Would you expect that the model order stays the same throughout the dataset, i.e. when taking another subset will that give me the same model? I would expect that barring some change to how the data are generated, the most correct underlying model will be the same throughout the dataset. However, that's not the same as saying that the model selected by any procedure (such as the procedure used by auto.arima) will be the same if that procedure is applied to different subsets of the data. This is because the variability due to sampling will result in variability in the results of the model selection procedure. What is a good way, within this method to cope with holidays? Or is ARIMAX with external holiday dummies needed for this? External holiday dummies is the best approach. Do I need to use Fourier series approach to try models with seasonality=672 as discussed in Long seasonal periods? You need to do something, because as mentioned in that article, the arima function in R does not support seasonal periods greater than 350. I've had reasonable success with the Fourier approach. Other options include forecasting after seasonal decomposition (also covered in FPP), and exponential smoothing models such as bats and tbats. If so would this be like fit<-Arima(timeseries,order=c(0,1,4), xreg=fourier(1:n,4,672) (where the function fourier is as defined in Hyndman's blog post) That looks correct. You should experiment with different numbers of terms. Note that there is now a fourier function in the forecast package with a slightly different specification that I assume supersedes the one on Hyndman's blog. See the help file for syntax. Are initial P and Q components included with the fourier series? I'm not sure what you're asking here. P and Q usually refer to the degrees of the AR and MA seasonal components. Using the fourier approach, there are no seasonal components and instead there are covariates for fourier terms related to season. It's no longer seasonal ARIMA, it's ARIMAX where the covariates approximate the season.
Problem defining ARIMA order
How do I select the best ARIMA model (by trying all different orders and checking the best MASE/MAPE/MSE? where the selection of performance measurement can be a discussion in it's own..) Out of sam
Problem defining ARIMA order How do I select the best ARIMA model (by trying all different orders and checking the best MASE/MAPE/MSE? where the selection of performance measurement can be a discussion in it's own..) Out of sample risk estimates are the gold standard for performance evaluation, and therefore for model selection. Ideally, you cross-validate so that your risk estimates are averaged over more data. FPP explains one cross-validation method for time series. See Tashman for a review of other methods: Tashman, L. J. (2000). Out-of-sample tests of forecasting accuracy: an analysis and review. International Journal of Forecasting, 16(4), 437–450. doi:10.1016/S0169-2070(00)00065-0 Of course, cross-validation is time consuming and so people often resort to using in-sample criteria to select a model, such as AIC, which is how auto.arima selects the best model. This approach is perfectly valid, if perhaps not as optimal. If I generate a new model and forecast for every new day forecast (as in online forecasting), do I need to take the yearly trend into account and how? (as in such a small subset my guess would be that the trend is neglible) I'm not sure what you mean by yearly trend. Assuming you mean yearly seasonality, there's not really any way to take it into account with less than a year's worth of data. Would you expect that the model order stays the same throughout the dataset, i.e. when taking another subset will that give me the same model? I would expect that barring some change to how the data are generated, the most correct underlying model will be the same throughout the dataset. However, that's not the same as saying that the model selected by any procedure (such as the procedure used by auto.arima) will be the same if that procedure is applied to different subsets of the data. This is because the variability due to sampling will result in variability in the results of the model selection procedure. What is a good way, within this method to cope with holidays? Or is ARIMAX with external holiday dummies needed for this? External holiday dummies is the best approach. Do I need to use Fourier series approach to try models with seasonality=672 as discussed in Long seasonal periods? You need to do something, because as mentioned in that article, the arima function in R does not support seasonal periods greater than 350. I've had reasonable success with the Fourier approach. Other options include forecasting after seasonal decomposition (also covered in FPP), and exponential smoothing models such as bats and tbats. If so would this be like fit<-Arima(timeseries,order=c(0,1,4), xreg=fourier(1:n,4,672) (where the function fourier is as defined in Hyndman's blog post) That looks correct. You should experiment with different numbers of terms. Note that there is now a fourier function in the forecast package with a slightly different specification that I assume supersedes the one on Hyndman's blog. See the help file for syntax. Are initial P and Q components included with the fourier series? I'm not sure what you're asking here. P and Q usually refer to the degrees of the AR and MA seasonal components. Using the fourier approach, there are no seasonal components and instead there are covariates for fourier terms related to season. It's no longer seasonal ARIMA, it's ARIMAX where the covariates approximate the season.
Problem defining ARIMA order How do I select the best ARIMA model (by trying all different orders and checking the best MASE/MAPE/MSE? where the selection of performance measurement can be a discussion in it's own..) Out of sam
15,016
Generating random samples from a custom distribution
It looks like you figured out that your code works, but @Aniko pointed out that you could improve its efficiency. Your biggest speed gain would probably come from pre-allocating memory for z so that you're not growing it inside a loop. Something like z <- rep(NA, nsamples) should do the trick. You may get a small speed gain from using vapply() (which specifies the returned variable type) instead of an explicit loop (there's a great SO question on the apply family). > nsamples <- 1E5 > x <- runif(nsamples) > f <- function(x, u) 1.5 * (x - (x^3) / 3) - u > z <- c() > > # original version > system.time({ + for (i in 1:nsamples) { + # find the root within (0,1) + r <- uniroot(f, c(0,1), tol = 0.0001, u = x[i])$root + z <- c(z, r) + } + }) user system elapsed 49.88 0.00 50.54 > > # original version with pre-allocation > z.pre <- rep(NA, nsamples) > system.time({ + for (i in 1:nsamples) { + # find the root within (0,1) + z.pre[i] <- uniroot(f, c(0,1), tol = 0.0001, u = x[i])$root + } + }) user system elapsed 7.55 0.01 7.78 > > > > # my version with sapply > my.uniroot <- function(x) uniroot(f, c(0, 1), tol = 0.0001, u = x)$root > system.time({ + r <- vapply(x, my.uniroot, numeric(1)) + }) user system elapsed 6.61 0.02 6.74 > > # same results > head(z) [1] 0.7803198 0.2860108 0.5153724 0.2479611 0.3451658 0.4682738 > head(z.pre) [1] 0.7803198 0.2860108 0.5153724 0.2479611 0.3451658 0.4682738 > head(r) [1] 0.7803198 0.2860108 0.5153724 0.2479611 0.3451658 0.4682738 And you don't need the ; at the end of each line (are you a MATLAB convert?).
Generating random samples from a custom distribution
It looks like you figured out that your code works, but @Aniko pointed out that you could improve its efficiency. Your biggest speed gain would probably come from pre-allocating memory for z so that y
Generating random samples from a custom distribution It looks like you figured out that your code works, but @Aniko pointed out that you could improve its efficiency. Your biggest speed gain would probably come from pre-allocating memory for z so that you're not growing it inside a loop. Something like z <- rep(NA, nsamples) should do the trick. You may get a small speed gain from using vapply() (which specifies the returned variable type) instead of an explicit loop (there's a great SO question on the apply family). > nsamples <- 1E5 > x <- runif(nsamples) > f <- function(x, u) 1.5 * (x - (x^3) / 3) - u > z <- c() > > # original version > system.time({ + for (i in 1:nsamples) { + # find the root within (0,1) + r <- uniroot(f, c(0,1), tol = 0.0001, u = x[i])$root + z <- c(z, r) + } + }) user system elapsed 49.88 0.00 50.54 > > # original version with pre-allocation > z.pre <- rep(NA, nsamples) > system.time({ + for (i in 1:nsamples) { + # find the root within (0,1) + z.pre[i] <- uniroot(f, c(0,1), tol = 0.0001, u = x[i])$root + } + }) user system elapsed 7.55 0.01 7.78 > > > > # my version with sapply > my.uniroot <- function(x) uniroot(f, c(0, 1), tol = 0.0001, u = x)$root > system.time({ + r <- vapply(x, my.uniroot, numeric(1)) + }) user system elapsed 6.61 0.02 6.74 > > # same results > head(z) [1] 0.7803198 0.2860108 0.5153724 0.2479611 0.3451658 0.4682738 > head(z.pre) [1] 0.7803198 0.2860108 0.5153724 0.2479611 0.3451658 0.4682738 > head(r) [1] 0.7803198 0.2860108 0.5153724 0.2479611 0.3451658 0.4682738 And you don't need the ; at the end of each line (are you a MATLAB convert?).
Generating random samples from a custom distribution It looks like you figured out that your code works, but @Aniko pointed out that you could improve its efficiency. Your biggest speed gain would probably come from pre-allocating memory for z so that y
15,017
Median of Medians calculation
The median of medians is not the same as the median of the raw scores. A simple case of this is that when you have an odd number of sales, the median is the middle value; when you have an even number of sales, the median is commonly taken as the average between those two values. A more "real world" challenge to this is that states will sell differing numbers of houses and thus the median of their medians is a poor guess as to the median of all home sales. Though it also will to be precise, a good first pass estimation would be to find the median of values where each state's median is reflected a number of times proportional to the number of sales in that state. Thus, I am essentially suggesting a weighted median.
Median of Medians calculation
The median of medians is not the same as the median of the raw scores. A simple case of this is that when you have an odd number of sales, the median is the middle value; when you have an even number
Median of Medians calculation The median of medians is not the same as the median of the raw scores. A simple case of this is that when you have an odd number of sales, the median is the middle value; when you have an even number of sales, the median is commonly taken as the average between those two values. A more "real world" challenge to this is that states will sell differing numbers of houses and thus the median of their medians is a poor guess as to the median of all home sales. Though it also will to be precise, a good first pass estimation would be to find the median of values where each state's median is reflected a number of times proportional to the number of sales in that state. Thus, I am essentially suggesting a weighted median.
Median of Medians calculation The median of medians is not the same as the median of the raw scores. A simple case of this is that when you have an odd number of sales, the median is the middle value; when you have an even number
15,018
Using R and plm to estimate fixed-effects models that include interactions with time
Try using fe3 <- plm(y ~ year * const, index = c('ID', 'year'), data = tmp) instead. It even works if you are redundantly including time fixed effects in the * interaction (because time is being fixed effect-ed out): fe4 <- plm(y ~ year * const, index = c('ID', 'year'), data = tmp, effect = "twoway")
Using R and plm to estimate fixed-effects models that include interactions with time
Try using fe3 <- plm(y ~ year * const, index = c('ID', 'year'), data = tmp) instead. It even works if you are redundantly including time fixed effects in the * interaction (because time is being fixe
Using R and plm to estimate fixed-effects models that include interactions with time Try using fe3 <- plm(y ~ year * const, index = c('ID', 'year'), data = tmp) instead. It even works if you are redundantly including time fixed effects in the * interaction (because time is being fixed effect-ed out): fe4 <- plm(y ~ year * const, index = c('ID', 'year'), data = tmp, effect = "twoway")
Using R and plm to estimate fixed-effects models that include interactions with time Try using fe3 <- plm(y ~ year * const, index = c('ID', 'year'), data = tmp) instead. It even works if you are redundantly including time fixed effects in the * interaction (because time is being fixe
15,019
What is the frequentist take on the voltmeter story?
In frequentist inference, we want to determine how frequently something would have happened if a given stochastic process were repeatedly realized. That is the starting point for the theory of p-values, confidence intervals, and the like. However, in many applied projects, the "given" process is not really given, and the statistician has to do at least some work specifying and modeling it. This can be a surprisingly ambiguous problem, as it is in this case. Modeling the Data Generation Process Based on the information given, our best candidate seems to be the following: If the 100V meter reads 100V, the engineer re-measures with the 1000V meter if it is operational. Otherwise, he simply marks 100V and moves on. But isn't this a bit unfair to our engineer? Assuming he is an engineer and not merely a technician, he probably understands why he needs to re-measure when the first meter reads 100V; it's because the meter is saturated at the upper limit of its range, hence no longer reliable. So perhaps what the engineer would really do is If the 100V meter reads 100, the engineer re-measures with the 1000V meter if it is operational. Otherwise, he simply marks 100V, appends a plus sign to indicate the saturated measurement, and moves on. Both of these processes are consistent with the data we have, but they are different processes, and they yield different confidence intervals. Process 2 is the one we would prefer as statisticians. If the voltages are often well above 100V, Process 1 has a potentially catastrophic failure mode in which the measurements are occasionally severely underestimated, because the data are censored without our knowing it. The confidence interval will widen accordingly. We could mitigate this by asking the engineer to tell us when his 1000V meter is not working, but this is really just another way of ensuring that our data conforms to Process 2. If the horse has already left the barn and we cannot determine when the measurements are and aren't censored, we could try to infer from the data the times when the 1000V meter isn't working. By introducing an inference rule into the process, we effectively create a new Process 1.5 distinct from both 1 and 2. Our inference rule would sometimes work and sometimes not, so the confidence interval from Process 1.5 would be intermediate in size compared to Processes 1 and 2. In theory, there is nothing wrong or suspicious about a single statistic having three different confidence intervals associated with three different plausibly representative stochastic processes. In practice, few consumers of statistics want three different confidence intervals. They want one, the one that is based on what would have actually happened, had the experiment been repeated many times. So typically, the applied statistician considers the domain knowledge she has acquired during the project, makes an educated guess, and presents the confidence interval associated with the process she has guessed. Or she works with the customer to formalize the process, so there's no need to guess going forward. How to Respond to New Information Despite the insistence of the statistician in the story, frequentist inference does not require that we repeat measurements when we gain new information suggesting the generating stochastic process is not quite what we originally conceived. However, if the process is going to be repeated, we do need to ensure that all repetitions are consistent with the model process assumed by the confidence interval. We can do this by changing the process or by changing our model of it. If we change the process, we may need to discard past data which was collected inconsistently with that process. But that isn't an issue here, because all the process variations we're considering are only different when some of the data is above 100V, and that never happened in this case. Whatever we do, model and reality must be brought into alignment. Only then will the theoretically guaranteed frequentist error rate be what the customer actually gets upon repeated performance of the process. The Bayesian Alternative On the other hand, if all we really care about is the probable range of the true mean for this sample, we should cast aside frequentism entirely and seek out the people who sell the answer to that question - the Bayesians. If we go this route, all the haggling over counterfactuals becomes irrelevant; all that matters is the prior and likelihood. In exchange for this simplification, we lose any hope of guaranteeing an error rate under repeated performance of the "experiment". Why the Fuss? This story was constructed to make it look like the frequentist statistician fusses over silly things for no reason. Honestly, who cares about these silly counterfactuals? The answer, of course, is that everyone should care. Vitally important scientific fields are currently suffering from a serious replication crisis, which suggests the frequency of false discoveries is much higher than expected in the scientific literature. One of the drivers of this crisis, although not the only one by any means, is the rise of p-hacking, which is when researchers play with many variations of a model, controlling for different variables, until they get significance. P-hacking has been extensively vilified in the popular scientific media and the blogosphere, but few actually understand what is wrong about p-hacking and why. Contrary to popular statistical opinion, there is nothing wrong with looking at your data before, during, and after the modeling process. What is wrong is failing to report exploratory analyses and how they influenced the course of the study. Only by looking at the full process can we even possibly determine what stochastic model is representative of that process and what frequentist analysis is appropriate for that model, if any. Claiming that a certain frequentist analysis is appropriate is a very serious claim. Making that claim implies that you are binding yourself to the discipline of the stochastic process you have chosen, which entails an entire system of counterfactuals about what you would have done in different situations. You have to actually conform to that system for the frequentist guarantee to apply to you. Very few researchers, especially those in fields that emphasize open-ended exploration, conform to the system, and they do not report their deviations scrupulously; that is why we now have a replication crisis on our hands. (Some respected researchers have argued that this expectation is unrealistic, a position I sympathize with, but that is getting beyond the scope of this post.) It might seem unfair that we are criticizing published papers based on a claim about what they would have done had the data been different. But this is the (somewhat paradoxical) nature of frequentist reasoning: if you accept the concept of the p-value, you have to respect the legitimacy of modeling what would have been done under alternative data. (Gelman & Loken, 2013) In studies that are relatively simple and/or standardized, such as clinical trials, we can adjust for things like multiple or sequential comparisons and maintain the theoretical error rate; in more complex and exploratory studies, a frequentist model may be inapplicable because the researcher may not be fully conscious of all the decisions being made, let alone recording and presenting them explicitly. In such cases, the researcher should (1) be honest and upfront about what was done; (2) present p-values either with strong caveats, or not at all; (3) consider presenting other lines of evidence, such as prior plausibility of the hypothesis or a follow-up replication study.
What is the frequentist take on the voltmeter story?
In frequentist inference, we want to determine how frequently something would have happened if a given stochastic process were repeatedly realized. That is the starting point for the theory of p-value
What is the frequentist take on the voltmeter story? In frequentist inference, we want to determine how frequently something would have happened if a given stochastic process were repeatedly realized. That is the starting point for the theory of p-values, confidence intervals, and the like. However, in many applied projects, the "given" process is not really given, and the statistician has to do at least some work specifying and modeling it. This can be a surprisingly ambiguous problem, as it is in this case. Modeling the Data Generation Process Based on the information given, our best candidate seems to be the following: If the 100V meter reads 100V, the engineer re-measures with the 1000V meter if it is operational. Otherwise, he simply marks 100V and moves on. But isn't this a bit unfair to our engineer? Assuming he is an engineer and not merely a technician, he probably understands why he needs to re-measure when the first meter reads 100V; it's because the meter is saturated at the upper limit of its range, hence no longer reliable. So perhaps what the engineer would really do is If the 100V meter reads 100, the engineer re-measures with the 1000V meter if it is operational. Otherwise, he simply marks 100V, appends a plus sign to indicate the saturated measurement, and moves on. Both of these processes are consistent with the data we have, but they are different processes, and they yield different confidence intervals. Process 2 is the one we would prefer as statisticians. If the voltages are often well above 100V, Process 1 has a potentially catastrophic failure mode in which the measurements are occasionally severely underestimated, because the data are censored without our knowing it. The confidence interval will widen accordingly. We could mitigate this by asking the engineer to tell us when his 1000V meter is not working, but this is really just another way of ensuring that our data conforms to Process 2. If the horse has already left the barn and we cannot determine when the measurements are and aren't censored, we could try to infer from the data the times when the 1000V meter isn't working. By introducing an inference rule into the process, we effectively create a new Process 1.5 distinct from both 1 and 2. Our inference rule would sometimes work and sometimes not, so the confidence interval from Process 1.5 would be intermediate in size compared to Processes 1 and 2. In theory, there is nothing wrong or suspicious about a single statistic having three different confidence intervals associated with three different plausibly representative stochastic processes. In practice, few consumers of statistics want three different confidence intervals. They want one, the one that is based on what would have actually happened, had the experiment been repeated many times. So typically, the applied statistician considers the domain knowledge she has acquired during the project, makes an educated guess, and presents the confidence interval associated with the process she has guessed. Or she works with the customer to formalize the process, so there's no need to guess going forward. How to Respond to New Information Despite the insistence of the statistician in the story, frequentist inference does not require that we repeat measurements when we gain new information suggesting the generating stochastic process is not quite what we originally conceived. However, if the process is going to be repeated, we do need to ensure that all repetitions are consistent with the model process assumed by the confidence interval. We can do this by changing the process or by changing our model of it. If we change the process, we may need to discard past data which was collected inconsistently with that process. But that isn't an issue here, because all the process variations we're considering are only different when some of the data is above 100V, and that never happened in this case. Whatever we do, model and reality must be brought into alignment. Only then will the theoretically guaranteed frequentist error rate be what the customer actually gets upon repeated performance of the process. The Bayesian Alternative On the other hand, if all we really care about is the probable range of the true mean for this sample, we should cast aside frequentism entirely and seek out the people who sell the answer to that question - the Bayesians. If we go this route, all the haggling over counterfactuals becomes irrelevant; all that matters is the prior and likelihood. In exchange for this simplification, we lose any hope of guaranteeing an error rate under repeated performance of the "experiment". Why the Fuss? This story was constructed to make it look like the frequentist statistician fusses over silly things for no reason. Honestly, who cares about these silly counterfactuals? The answer, of course, is that everyone should care. Vitally important scientific fields are currently suffering from a serious replication crisis, which suggests the frequency of false discoveries is much higher than expected in the scientific literature. One of the drivers of this crisis, although not the only one by any means, is the rise of p-hacking, which is when researchers play with many variations of a model, controlling for different variables, until they get significance. P-hacking has been extensively vilified in the popular scientific media and the blogosphere, but few actually understand what is wrong about p-hacking and why. Contrary to popular statistical opinion, there is nothing wrong with looking at your data before, during, and after the modeling process. What is wrong is failing to report exploratory analyses and how they influenced the course of the study. Only by looking at the full process can we even possibly determine what stochastic model is representative of that process and what frequentist analysis is appropriate for that model, if any. Claiming that a certain frequentist analysis is appropriate is a very serious claim. Making that claim implies that you are binding yourself to the discipline of the stochastic process you have chosen, which entails an entire system of counterfactuals about what you would have done in different situations. You have to actually conform to that system for the frequentist guarantee to apply to you. Very few researchers, especially those in fields that emphasize open-ended exploration, conform to the system, and they do not report their deviations scrupulously; that is why we now have a replication crisis on our hands. (Some respected researchers have argued that this expectation is unrealistic, a position I sympathize with, but that is getting beyond the scope of this post.) It might seem unfair that we are criticizing published papers based on a claim about what they would have done had the data been different. But this is the (somewhat paradoxical) nature of frequentist reasoning: if you accept the concept of the p-value, you have to respect the legitimacy of modeling what would have been done under alternative data. (Gelman & Loken, 2013) In studies that are relatively simple and/or standardized, such as clinical trials, we can adjust for things like multiple or sequential comparisons and maintain the theoretical error rate; in more complex and exploratory studies, a frequentist model may be inapplicable because the researcher may not be fully conscious of all the decisions being made, let alone recording and presenting them explicitly. In such cases, the researcher should (1) be honest and upfront about what was done; (2) present p-values either with strong caveats, or not at all; (3) consider presenting other lines of evidence, such as prior plausibility of the hypothesis or a follow-up replication study.
What is the frequentist take on the voltmeter story? In frequentist inference, we want to determine how frequently something would have happened if a given stochastic process were repeatedly realized. That is the starting point for the theory of p-value
15,020
What is the frequentist take on the voltmeter story?
There seems a logical fallacy. Whether or not the 1000 volt meter was working, the engineer says "if any readings would have been over 100, I would have used the other meter." But how would he know that the voltage was >100 without having used the 1000 volt meter? I don't think this puzzle is well-enough formulated to make for a useful philosophical question. Practically, I agree with the answer that the right thing is to make a histogram and see if it looks truncated. But, in any case, nothing in the question deals with the issues that matter, like: (1) what is the known (or suspected) distribution of readings, and why? Is there some reason to believe they are normally distributed? (2) If that question is not answered, then how was any confidence interval ever estimated? To take it to an extreme, some 'voltage' is being measured. Suppose the power supply can't deliver more than 100 volts. Were that true, presumably there couldn't be any measurements over 100 volts, so the meter is irrelevant. There is a whole bunch more - in terms of priors, constraints, etc. - that goes into estimation and the like than the question covers. This is unlike the 'Monty Hall' paradox, which is crisp and clean.
What is the frequentist take on the voltmeter story?
There seems a logical fallacy. Whether or not the 1000 volt meter was working, the engineer says "if any readings would have been over 100, I would have used the other meter." But how would he know
What is the frequentist take on the voltmeter story? There seems a logical fallacy. Whether or not the 1000 volt meter was working, the engineer says "if any readings would have been over 100, I would have used the other meter." But how would he know that the voltage was >100 without having used the 1000 volt meter? I don't think this puzzle is well-enough formulated to make for a useful philosophical question. Practically, I agree with the answer that the right thing is to make a histogram and see if it looks truncated. But, in any case, nothing in the question deals with the issues that matter, like: (1) what is the known (or suspected) distribution of readings, and why? Is there some reason to believe they are normally distributed? (2) If that question is not answered, then how was any confidence interval ever estimated? To take it to an extreme, some 'voltage' is being measured. Suppose the power supply can't deliver more than 100 volts. Were that true, presumably there couldn't be any measurements over 100 volts, so the meter is irrelevant. There is a whole bunch more - in terms of priors, constraints, etc. - that goes into estimation and the like than the question covers. This is unlike the 'Monty Hall' paradox, which is crisp and clean.
What is the frequentist take on the voltmeter story? There seems a logical fallacy. Whether or not the 1000 volt meter was working, the engineer says "if any readings would have been over 100, I would have used the other meter." But how would he know
15,021
What are "coefficients of linear discriminants" in LDA?
If you multiply each value of LDA1 (the first linear discriminant) by the corresponding elements of the predictor variables and sum them ($-0.6420190\times$Lag1$+ -0.5135293\times$Lag2) you get a score for each respondent. This score along the the prior are used to compute the posterior probability of class membership (there are a number of different formulas for this). Classification is made based on the posterior probability, with observations predicted to be in the class for which they have the highest probability. The chart below illustrates the relationship between the score, the posterior probability, and the classification, for the data set used in the question. The basic patterns always holds with two-group LDA: there is 1-to-1 mapping between the scores and the posterior probability, and predictions are equivalent when made from either the posterior probabilities or the scores. Answers to the sub-questions and some other comments Although LDA can be used for dimension reduction, this is not what is going on in the example. With two groups, the reason only a single score is required per observation is that this is all that is needed. This is because the probability of being in one group is the complement of the probability of being in the other (i.e., they add to 1). You can see this in the chart: scores of less than -.4 are classified as being in the Down group and higher scores are predicted to be Up. Sometimes the vector of scores is called a discriminant function. Sometimes the coefficients are called this. I'm not clear on whether either is correct. I believe that MASS discriminant refers to the coefficients. The MASS package's lda function produces coefficients in a different way to most other LDA software. The alternative approach computes one set of coefficients for each group and each set of coefficients has an intercept. With the discriminant function (scores) computed using these coefficients, classification is based on the highest score and there is no need to compute posterior probabilities in order to predict the classification. I have put some LDA code in GitHub which is a modification of the MASS function but produces these more convenient coefficients (the package is called Displayr/flipMultivariates, and if you create an object using LDA you can extract the coefficients using obj$original$discriminant.functions). I have posted the R for code all the concepts in this post here. There is no single formula for computing posterior probabilities from the score. The easiest way to understand the options is (for me anyway) to look at the source code, using: library(MASS) getAnywhere("predict.lda")
What are "coefficients of linear discriminants" in LDA?
If you multiply each value of LDA1 (the first linear discriminant) by the corresponding elements of the predictor variables and sum them ($-0.6420190\times$Lag1$+ -0.5135293\times$Lag2) you get a scor
What are "coefficients of linear discriminants" in LDA? If you multiply each value of LDA1 (the first linear discriminant) by the corresponding elements of the predictor variables and sum them ($-0.6420190\times$Lag1$+ -0.5135293\times$Lag2) you get a score for each respondent. This score along the the prior are used to compute the posterior probability of class membership (there are a number of different formulas for this). Classification is made based on the posterior probability, with observations predicted to be in the class for which they have the highest probability. The chart below illustrates the relationship between the score, the posterior probability, and the classification, for the data set used in the question. The basic patterns always holds with two-group LDA: there is 1-to-1 mapping between the scores and the posterior probability, and predictions are equivalent when made from either the posterior probabilities or the scores. Answers to the sub-questions and some other comments Although LDA can be used for dimension reduction, this is not what is going on in the example. With two groups, the reason only a single score is required per observation is that this is all that is needed. This is because the probability of being in one group is the complement of the probability of being in the other (i.e., they add to 1). You can see this in the chart: scores of less than -.4 are classified as being in the Down group and higher scores are predicted to be Up. Sometimes the vector of scores is called a discriminant function. Sometimes the coefficients are called this. I'm not clear on whether either is correct. I believe that MASS discriminant refers to the coefficients. The MASS package's lda function produces coefficients in a different way to most other LDA software. The alternative approach computes one set of coefficients for each group and each set of coefficients has an intercept. With the discriminant function (scores) computed using these coefficients, classification is based on the highest score and there is no need to compute posterior probabilities in order to predict the classification. I have put some LDA code in GitHub which is a modification of the MASS function but produces these more convenient coefficients (the package is called Displayr/flipMultivariates, and if you create an object using LDA you can extract the coefficients using obj$original$discriminant.functions). I have posted the R for code all the concepts in this post here. There is no single formula for computing posterior probabilities from the score. The easiest way to understand the options is (for me anyway) to look at the source code, using: library(MASS) getAnywhere("predict.lda")
What are "coefficients of linear discriminants" in LDA? If you multiply each value of LDA1 (the first linear discriminant) by the corresponding elements of the predictor variables and sum them ($-0.6420190\times$Lag1$+ -0.5135293\times$Lag2) you get a scor
15,022
What are "coefficients of linear discriminants" in LDA?
Discriminant in the context of ISLR, 4.6.3 Linear Discriminant Analysis, pp161-162 is, as I understand, the value of \begin{equation} \hat\delta_2(\vec x) - \hat\delta_1(\vec x) = {\vec x}^T\hat\Sigma^{-1}\Bigl(\vec{\hat\mu}_2 - \vec{\hat\mu}_1\Bigr) - \frac{1}{2}\Bigl(\vec{\hat\mu}_2 + \vec{\hat\mu}_1\Bigr)^T\hat\Sigma^{-1}\Bigl(\vec{\hat\mu}_2 - \vec{\hat\mu}_1\Bigr) + \log\Bigl(\frac{\pi_2}{\pi_1}\Bigr), \tag{$*$} \end{equation} where $\vec x = (\mathrm{Lag1}, \mathrm{Lag2})^T$. For the 2nd term in $(*)$, it should be noted that, for symmetric matrix M, we have $\vec x^T M\vec y = \vec y^T M \vec x$. LD1 is the coefficient vector of $\vec x$ from above equation, which is \begin{equation} \hat\Sigma^{-1}\Bigl(\vec{\hat\mu}_2 - \vec{\hat\mu}_1\Bigr). \end{equation} $y$ at $\vec x$ is 2 if $(*)$ is positive, and 1 if $(*)$ is negative. LD1 is given as lda.fit$scaling. The discriminant vector ${\vec x}^T\hat\Sigma^{-1}\Bigl(\vec{\hat\mu}_2 - \vec{\hat\mu}_1\Bigr)$ computed using LD1 for a test set is given as lda.pred$x, where test = subset(Smarket, Year==2005) lda.pred = predict(lda.fit, test) test set is not necessarily given as above, it can be given arbitrarily. Unfortunately, lda.pred$x alone cannot tell whether $y$ is 1 or 2. We need the 2nd and the 3rd term in $(*)$. I could not find these terms from the output of lda() and/or predict(lda.fit,..). We can compute all three terms of $(*)$ by hand, I mean using just the basic functions of R. The script for LD1 is given below. bTrain = (Smarket$Year < 2005) # boolean vector for the training set bUp = (Smarket$Direction == "Up") # boolean vector for "Up" group up.group = Smarket[bTrain & bUp,] down.group = Smarket[bTrain & !bUp,] cov.up = cov(up.group[,c(2,3)]) cov.down = cov(down.group[,c(2,3)]) nUp = nrow(up.group) nDown = nrow(down.group) n = nUp + nDown; K = 2 Sigma <- 1/(n - K) * (cov.up * (nUp - 1) + cov.down * (nDown - 1)) SigmaInv <- solve(Sigma) lda.fit = lda(Direction ~ Lag1+Lag2, data=Smarket, subset=bTrain) mu2_mu1 = matrix(lda.fit$means[2,] - lda.fit$means[1,]) coeff.vec = SigmaInv %*% mu2_mu1; coeff.vec [,1] Lag1 -0.05544078 Lag2 -0.04434520 v.scalar = sqrt(t(coeff.vec) %*% Sigma %*% coeff.vec) myLD1 = coeff.vec/drop(v.scalar); myLD1 # same as below [,1] Lag1 -0.6420190 Lag2 -0.5135293 lda.fit$scaling # same as above LD1 Lag1 -0.6420190 Lag2 -0.5135293 Here is the catch: myLD1 is perfectly good in the sense that it can be used in classifying $\vec x$ according to the value of its corresponding response variable $y$. Since the discriminant function $(*)$ is linear in $\vec x$ (actually it's not linear, it's affine) any scalar multiple of myLD1 will do the job provided that the second and the third term are multiplied by the same scalar, which is 1/v.scalar in the code above. LD1 given by lda() has the nice property that the generalized norm is 1, which our myLD1 lacks. t(lda.fit$scaling) %*% Sigma %*% lda.fit$scaling LD1 LD1 1 -end-
What are "coefficients of linear discriminants" in LDA?
Discriminant in the context of ISLR, 4.6.3 Linear Discriminant Analysis, pp161-162 is, as I understand, the value of \begin{equation} \hat\delta_2(\vec x) - \hat\delta_1(\vec x) = {\vec x}^T\hat\Sigm
What are "coefficients of linear discriminants" in LDA? Discriminant in the context of ISLR, 4.6.3 Linear Discriminant Analysis, pp161-162 is, as I understand, the value of \begin{equation} \hat\delta_2(\vec x) - \hat\delta_1(\vec x) = {\vec x}^T\hat\Sigma^{-1}\Bigl(\vec{\hat\mu}_2 - \vec{\hat\mu}_1\Bigr) - \frac{1}{2}\Bigl(\vec{\hat\mu}_2 + \vec{\hat\mu}_1\Bigr)^T\hat\Sigma^{-1}\Bigl(\vec{\hat\mu}_2 - \vec{\hat\mu}_1\Bigr) + \log\Bigl(\frac{\pi_2}{\pi_1}\Bigr), \tag{$*$} \end{equation} where $\vec x = (\mathrm{Lag1}, \mathrm{Lag2})^T$. For the 2nd term in $(*)$, it should be noted that, for symmetric matrix M, we have $\vec x^T M\vec y = \vec y^T M \vec x$. LD1 is the coefficient vector of $\vec x$ from above equation, which is \begin{equation} \hat\Sigma^{-1}\Bigl(\vec{\hat\mu}_2 - \vec{\hat\mu}_1\Bigr). \end{equation} $y$ at $\vec x$ is 2 if $(*)$ is positive, and 1 if $(*)$ is negative. LD1 is given as lda.fit$scaling. The discriminant vector ${\vec x}^T\hat\Sigma^{-1}\Bigl(\vec{\hat\mu}_2 - \vec{\hat\mu}_1\Bigr)$ computed using LD1 for a test set is given as lda.pred$x, where test = subset(Smarket, Year==2005) lda.pred = predict(lda.fit, test) test set is not necessarily given as above, it can be given arbitrarily. Unfortunately, lda.pred$x alone cannot tell whether $y$ is 1 or 2. We need the 2nd and the 3rd term in $(*)$. I could not find these terms from the output of lda() and/or predict(lda.fit,..). We can compute all three terms of $(*)$ by hand, I mean using just the basic functions of R. The script for LD1 is given below. bTrain = (Smarket$Year < 2005) # boolean vector for the training set bUp = (Smarket$Direction == "Up") # boolean vector for "Up" group up.group = Smarket[bTrain & bUp,] down.group = Smarket[bTrain & !bUp,] cov.up = cov(up.group[,c(2,3)]) cov.down = cov(down.group[,c(2,3)]) nUp = nrow(up.group) nDown = nrow(down.group) n = nUp + nDown; K = 2 Sigma <- 1/(n - K) * (cov.up * (nUp - 1) + cov.down * (nDown - 1)) SigmaInv <- solve(Sigma) lda.fit = lda(Direction ~ Lag1+Lag2, data=Smarket, subset=bTrain) mu2_mu1 = matrix(lda.fit$means[2,] - lda.fit$means[1,]) coeff.vec = SigmaInv %*% mu2_mu1; coeff.vec [,1] Lag1 -0.05544078 Lag2 -0.04434520 v.scalar = sqrt(t(coeff.vec) %*% Sigma %*% coeff.vec) myLD1 = coeff.vec/drop(v.scalar); myLD1 # same as below [,1] Lag1 -0.6420190 Lag2 -0.5135293 lda.fit$scaling # same as above LD1 Lag1 -0.6420190 Lag2 -0.5135293 Here is the catch: myLD1 is perfectly good in the sense that it can be used in classifying $\vec x$ according to the value of its corresponding response variable $y$. Since the discriminant function $(*)$ is linear in $\vec x$ (actually it's not linear, it's affine) any scalar multiple of myLD1 will do the job provided that the second and the third term are multiplied by the same scalar, which is 1/v.scalar in the code above. LD1 given by lda() has the nice property that the generalized norm is 1, which our myLD1 lacks. t(lda.fit$scaling) %*% Sigma %*% lda.fit$scaling LD1 LD1 1 -end-
What are "coefficients of linear discriminants" in LDA? Discriminant in the context of ISLR, 4.6.3 Linear Discriminant Analysis, pp161-162 is, as I understand, the value of \begin{equation} \hat\delta_2(\vec x) - \hat\delta_1(\vec x) = {\vec x}^T\hat\Sigm
15,023
What are "coefficients of linear discriminants" in LDA?
The theory behind this function is "Fisher's Method for Discriminating among Several Population". I recommend chapter 11.6 in applied multivariate statistical analysis(ISBN: 9780134995397) for reference.
What are "coefficients of linear discriminants" in LDA?
The theory behind this function is "Fisher's Method for Discriminating among Several Population". I recommend chapter 11.6 in applied multivariate statistical analysis(ISBN: 9780134995397) for referen
What are "coefficients of linear discriminants" in LDA? The theory behind this function is "Fisher's Method for Discriminating among Several Population". I recommend chapter 11.6 in applied multivariate statistical analysis(ISBN: 9780134995397) for reference.
What are "coefficients of linear discriminants" in LDA? The theory behind this function is "Fisher's Method for Discriminating among Several Population". I recommend chapter 11.6 in applied multivariate statistical analysis(ISBN: 9780134995397) for referen
15,024
Choosing seasonal decomposition method
If you are willing to learn to understand the diagnostics, X12-ARIMA provides a boatload of diagnostics that range from (ASCII) graphs to rule-of-thumb indicators. Learning and understanding the diagnostics is something of an education in time series and seasonal adjustment. On the other hand, X12-ARIMA software is a one-trick pony, while using stl in R would allow you to do other things and to switch to other methods (decompose, dlm's, etc) if you wish. On the other-other hand, X12-Arima makes it easier to include exogenous variables and to indicate outliers, etc.
Choosing seasonal decomposition method
If you are willing to learn to understand the diagnostics, X12-ARIMA provides a boatload of diagnostics that range from (ASCII) graphs to rule-of-thumb indicators. Learning and understanding the diagn
Choosing seasonal decomposition method If you are willing to learn to understand the diagnostics, X12-ARIMA provides a boatload of diagnostics that range from (ASCII) graphs to rule-of-thumb indicators. Learning and understanding the diagnostics is something of an education in time series and seasonal adjustment. On the other hand, X12-ARIMA software is a one-trick pony, while using stl in R would allow you to do other things and to switch to other methods (decompose, dlm's, etc) if you wish. On the other-other hand, X12-Arima makes it easier to include exogenous variables and to indicate outliers, etc.
Choosing seasonal decomposition method If you are willing to learn to understand the diagnostics, X12-ARIMA provides a boatload of diagnostics that range from (ASCII) graphs to rule-of-thumb indicators. Learning and understanding the diagn
15,025
Choosing seasonal decomposition method
That's an answer for question 2. STL: http://www.wessa.net/download/stl.pdf X-12-ARIMA (and much more): http://www.census.gov/srd/www/sapaper/sapaper.html
Choosing seasonal decomposition method
That's an answer for question 2. STL: http://www.wessa.net/download/stl.pdf X-12-ARIMA (and much more): http://www.census.gov/srd/www/sapaper/sapaper.html
Choosing seasonal decomposition method That's an answer for question 2. STL: http://www.wessa.net/download/stl.pdf X-12-ARIMA (and much more): http://www.census.gov/srd/www/sapaper/sapaper.html
Choosing seasonal decomposition method That's an answer for question 2. STL: http://www.wessa.net/download/stl.pdf X-12-ARIMA (and much more): http://www.census.gov/srd/www/sapaper/sapaper.html
15,026
Robust PCA vs. robust Mahalanobis distance for outlier detection
This paper compares some methods in this area. They refer to the Robust PCA approach you linked to as "PCP" (principal components pursuit) and the family of methods you linked to for robust covariance estimation as M-estimators. They argue that PCP is designed for uniformly corrupted coordinates of data, instead of corrupted data points (i.e., outliers), therefore, the comparison with PCP is somewhat unfair for this kind of data and show that PCP (aka robust PCA) can fail for outlier detection in some cases. They also talk about three kinds of "enemies of subspace recovery," i.e. different kinds of outliers, and which kinds of methods might do well for dealing with each one. Comparing your own outliers with the three kinds of "enemies" discussed here might help you pick an approach.
Robust PCA vs. robust Mahalanobis distance for outlier detection
This paper compares some methods in this area. They refer to the Robust PCA approach you linked to as "PCP" (principal components pursuit) and the family of methods you linked to for robust covarianc
Robust PCA vs. robust Mahalanobis distance for outlier detection This paper compares some methods in this area. They refer to the Robust PCA approach you linked to as "PCP" (principal components pursuit) and the family of methods you linked to for robust covariance estimation as M-estimators. They argue that PCP is designed for uniformly corrupted coordinates of data, instead of corrupted data points (i.e., outliers), therefore, the comparison with PCP is somewhat unfair for this kind of data and show that PCP (aka robust PCA) can fail for outlier detection in some cases. They also talk about three kinds of "enemies of subspace recovery," i.e. different kinds of outliers, and which kinds of methods might do well for dealing with each one. Comparing your own outliers with the three kinds of "enemies" discussed here might help you pick an approach.
Robust PCA vs. robust Mahalanobis distance for outlier detection This paper compares some methods in this area. They refer to the Robust PCA approach you linked to as "PCP" (principal components pursuit) and the family of methods you linked to for robust covarianc
15,027
Mean(scores) vs Score(concatenation) in cross validation
The described difference is IMHO bogus. You'll observe it only if the distribution of truely positive cases (i.e. reference method says it is a positive case) is very unequal over the folds (as in the example) and the number of relevant test cases (the denominator of the performance measure we're talking about, here the truly positive) is not taken into account when averaging the fold averages. If you weight the first three fold averages with $\frac{4}{12} = \frac{1}{3}$ (as there were 4 test cases among the total 12 cases which are relevant for calculation of the precision), and the last 6 fold averages with 1 (all test cases relevant for precision calculation), the weighted average is exactly the same you'd get from pooling the predictions of the 10 folds and then calculating the precision. edit: the original question also asked about iterating/repeating the validation: yes, you should run iterations of the whole $k$-fold cross validation procedure: From that, you can get an idea of the stability of the predictions of your models How much do the predictions change if the training data is perturbed by exchanging a few training samples? I.e., how much do the predictions of different "surrogate" models vary for the same test sample? You were asking for scientific papers: search terms are iterated or repeated cross validation. Papers that say "you should do this": Dougherty, E. R.; Sima, C.; Hua, J.; Hanczar, B. & Braga-Neto, U. M.: Performance of Error Estimators for Classification Current Bioinformatics, 2010, 5, 53-67. is a good starting point. For spectroscopic data, I did some simulations Beleites, C.; Baumgartner, R.; Bowman, C.; Somorjai, R.; Steiner, G.; Salzer, R. & Sowa, M. G.: Variance reduction in estimating classification error using sparse datasets. Chem.Intell.Lab.Syst., 2005, 79, 91 - 100. preprint I use it regularly, e.g Beleites, C.; Geiger, K.; Kirsch, M.; Sobottka, S. B.; Schackert, G. & Salzer, R.: Raman spectroscopic grading of astrocytoma tissues: using soft reference information.Anal Bioanal Chem, 2011, 400, 2801-2816 Underestimating variance Ultimately, your data set has finite (n = 120) sample size, regardless of how many iterations of bootstrap or cross validation you do. You have (at least) 2 sources of variance in the resampling (cross validation and out of bootstrap) validation results: variance due to finite number of (test) sample variance due to instability of the predictions of the surrogate models If your models are stable, then iterations of $k$-fold cross validation were not needed (they don't improve the performance estimate: the average over each run of the cross validation is the same). However, the performance estimate is still subject to variance due to the finite number of test samples. If your data structure is "simple" (i.e. one single measurement vector for each statistically independent case), you can assume that the test results are the results of a Bernoulli process (coin-throwing) and calculate the finite-test-set variance. out-of-bootstrap looks at variance between each surrogate model's predictions. That is possible with the cross validation results as well, but it is uncommon. If you do this, you'll see variance due to finite sample size in addition to the instability. However, keep in mind that some pooling has (usually) taken place already: for cross validation usually $\frac{n}{k}$ results are pooled, and for out-of-bootstrap a varying number of left out samples are pooled. Which makes me personally prefer the cross validation (for the moment) as it is easier to separate instability from finite test sample sizes.
Mean(scores) vs Score(concatenation) in cross validation
The described difference is IMHO bogus. You'll observe it only if the distribution of truely positive cases (i.e. reference method says it is a positive case) is very unequal over the folds (as in the
Mean(scores) vs Score(concatenation) in cross validation The described difference is IMHO bogus. You'll observe it only if the distribution of truely positive cases (i.e. reference method says it is a positive case) is very unequal over the folds (as in the example) and the number of relevant test cases (the denominator of the performance measure we're talking about, here the truly positive) is not taken into account when averaging the fold averages. If you weight the first three fold averages with $\frac{4}{12} = \frac{1}{3}$ (as there were 4 test cases among the total 12 cases which are relevant for calculation of the precision), and the last 6 fold averages with 1 (all test cases relevant for precision calculation), the weighted average is exactly the same you'd get from pooling the predictions of the 10 folds and then calculating the precision. edit: the original question also asked about iterating/repeating the validation: yes, you should run iterations of the whole $k$-fold cross validation procedure: From that, you can get an idea of the stability of the predictions of your models How much do the predictions change if the training data is perturbed by exchanging a few training samples? I.e., how much do the predictions of different "surrogate" models vary for the same test sample? You were asking for scientific papers: search terms are iterated or repeated cross validation. Papers that say "you should do this": Dougherty, E. R.; Sima, C.; Hua, J.; Hanczar, B. & Braga-Neto, U. M.: Performance of Error Estimators for Classification Current Bioinformatics, 2010, 5, 53-67. is a good starting point. For spectroscopic data, I did some simulations Beleites, C.; Baumgartner, R.; Bowman, C.; Somorjai, R.; Steiner, G.; Salzer, R. & Sowa, M. G.: Variance reduction in estimating classification error using sparse datasets. Chem.Intell.Lab.Syst., 2005, 79, 91 - 100. preprint I use it regularly, e.g Beleites, C.; Geiger, K.; Kirsch, M.; Sobottka, S. B.; Schackert, G. & Salzer, R.: Raman spectroscopic grading of astrocytoma tissues: using soft reference information.Anal Bioanal Chem, 2011, 400, 2801-2816 Underestimating variance Ultimately, your data set has finite (n = 120) sample size, regardless of how many iterations of bootstrap or cross validation you do. You have (at least) 2 sources of variance in the resampling (cross validation and out of bootstrap) validation results: variance due to finite number of (test) sample variance due to instability of the predictions of the surrogate models If your models are stable, then iterations of $k$-fold cross validation were not needed (they don't improve the performance estimate: the average over each run of the cross validation is the same). However, the performance estimate is still subject to variance due to the finite number of test samples. If your data structure is "simple" (i.e. one single measurement vector for each statistically independent case), you can assume that the test results are the results of a Bernoulli process (coin-throwing) and calculate the finite-test-set variance. out-of-bootstrap looks at variance between each surrogate model's predictions. That is possible with the cross validation results as well, but it is uncommon. If you do this, you'll see variance due to finite sample size in addition to the instability. However, keep in mind that some pooling has (usually) taken place already: for cross validation usually $\frac{n}{k}$ results are pooled, and for out-of-bootstrap a varying number of left out samples are pooled. Which makes me personally prefer the cross validation (for the moment) as it is easier to separate instability from finite test sample sizes.
Mean(scores) vs Score(concatenation) in cross validation The described difference is IMHO bogus. You'll observe it only if the distribution of truely positive cases (i.e. reference method says it is a positive case) is very unequal over the folds (as in the
15,028
Mean(scores) vs Score(concatenation) in cross validation
You should do score(concatenation). It is a common misconception in the field that mean(scores) is the best way. It can introduce more bias into your estimate, especially on rare classes, as in your case. Here is a paper backing this up: http://www.kdd.org/exploration_files/v12-1-p49-forman-sigkdd.pdf In the paper, they use "Favg" in place of your "mean(scores)" and "Ftp,fp" in place of your "score(concatenation)" Toy Example: Imagine that you have 10 fold cross validation and a class which appears 10 times, and happens to be assigned so that it appears once in each fold. Also the class is always predicted correctly but there there is a single false-positive in the data. The test fold containing the false positive will have 50% accuracy, while all other folds will have 100%. So avg(scores)=95%. On the other hand, score(concatenation) is 10/11, about 91%. If we assume that that true population is well represented by the data, and that the 10 cross-validation classifiers well represent the final classifier, then real world accuracy would be 91%, and the avg(scores) estimate of 95% is way biased. In practice, you will not want to make those assumptions. Instead you can use distribution statistics to estimate confidence, by randomly permuting the data and re-computing score(concatenation) multiple times, as well as bootstrapping.
Mean(scores) vs Score(concatenation) in cross validation
You should do score(concatenation). It is a common misconception in the field that mean(scores) is the best way. It can introduce more bias into your estimate, especially on rare classes, as in your c
Mean(scores) vs Score(concatenation) in cross validation You should do score(concatenation). It is a common misconception in the field that mean(scores) is the best way. It can introduce more bias into your estimate, especially on rare classes, as in your case. Here is a paper backing this up: http://www.kdd.org/exploration_files/v12-1-p49-forman-sigkdd.pdf In the paper, they use "Favg" in place of your "mean(scores)" and "Ftp,fp" in place of your "score(concatenation)" Toy Example: Imagine that you have 10 fold cross validation and a class which appears 10 times, and happens to be assigned so that it appears once in each fold. Also the class is always predicted correctly but there there is a single false-positive in the data. The test fold containing the false positive will have 50% accuracy, while all other folds will have 100%. So avg(scores)=95%. On the other hand, score(concatenation) is 10/11, about 91%. If we assume that that true population is well represented by the data, and that the 10 cross-validation classifiers well represent the final classifier, then real world accuracy would be 91%, and the avg(scores) estimate of 95% is way biased. In practice, you will not want to make those assumptions. Instead you can use distribution statistics to estimate confidence, by randomly permuting the data and re-computing score(concatenation) multiple times, as well as bootstrapping.
Mean(scores) vs Score(concatenation) in cross validation You should do score(concatenation). It is a common misconception in the field that mean(scores) is the best way. It can introduce more bias into your estimate, especially on rare classes, as in your c
15,029
Out-of-core data analysis options
if you're maxing out at 500,000 records x 2,000 variables, i would spend a little more money on RAM for your laptop and be done with it. if you have 16GB, you can probably read the data set you're describing into R directly. and at that point, you'll be able to do far more - and very quickly.. but you say that's not an option, so: look at SQL-based packages for R. these allow you to connect to external databases and access those tables via SQL. since SQL is pretty universal (and since R is open-source), your code won't be lost if you change jobs or lose access to SAS. the easiest external database to set up is RSQLite but by far the fastest is MonetDB.R (speed tests) there are probably a few good solutions to your stated problem, my guess is that just about all of them involve R ;)
Out-of-core data analysis options
if you're maxing out at 500,000 records x 2,000 variables, i would spend a little more money on RAM for your laptop and be done with it. if you have 16GB, you can probably read the data set you're de
Out-of-core data analysis options if you're maxing out at 500,000 records x 2,000 variables, i would spend a little more money on RAM for your laptop and be done with it. if you have 16GB, you can probably read the data set you're describing into R directly. and at that point, you'll be able to do far more - and very quickly.. but you say that's not an option, so: look at SQL-based packages for R. these allow you to connect to external databases and access those tables via SQL. since SQL is pretty universal (and since R is open-source), your code won't be lost if you change jobs or lose access to SAS. the easiest external database to set up is RSQLite but by far the fastest is MonetDB.R (speed tests) there are probably a few good solutions to your stated problem, my guess is that just about all of them involve R ;)
Out-of-core data analysis options if you're maxing out at 500,000 records x 2,000 variables, i would spend a little more money on RAM for your laptop and be done with it. if you have 16GB, you can probably read the data set you're de
15,030
Out-of-core data analysis options
Maybe it is not so much about the applications/problems you are aiming for, and its characteristics, but more about the algorithms and variants you are using. More concretely, in order to handle big data, many variants based on stochastic gradient descent of popular algorithms, like SVM, have appear which are able to handle that. Scikit offers support for some of this algorithms (SVM, kNN, kmeans, ...). I guess this nice graph can help you to quickly figure out, if scikit makes sense to you at all. Hope that helps NOTE: what follows is a reply on the comment by zelazny7 Now I understood you. What you are looking for is pandas. Take a look at the talks section. There is a presentation comparing Panda's workflow and panda's briefly. Panda lets you import data in different formats and handle bgu files through HDF5 tables integration. Besides, you can interface Scikit.
Out-of-core data analysis options
Maybe it is not so much about the applications/problems you are aiming for, and its characteristics, but more about the algorithms and variants you are using. More concretely, in order to handle big d
Out-of-core data analysis options Maybe it is not so much about the applications/problems you are aiming for, and its characteristics, but more about the algorithms and variants you are using. More concretely, in order to handle big data, many variants based on stochastic gradient descent of popular algorithms, like SVM, have appear which are able to handle that. Scikit offers support for some of this algorithms (SVM, kNN, kmeans, ...). I guess this nice graph can help you to quickly figure out, if scikit makes sense to you at all. Hope that helps NOTE: what follows is a reply on the comment by zelazny7 Now I understood you. What you are looking for is pandas. Take a look at the talks section. There is a presentation comparing Panda's workflow and panda's briefly. Panda lets you import data in different formats and handle bgu files through HDF5 tables integration. Besides, you can interface Scikit.
Out-of-core data analysis options Maybe it is not so much about the applications/problems you are aiming for, and its characteristics, but more about the algorithms and variants you are using. More concretely, in order to handle big d
15,031
Out-of-core data analysis options
You already seem comfortable with SAS, and your datasets are small enough to fit in RAM, but maybe you can't fit enough RAM into your laptop. If you don't mind sticking with SAS, how about you just connect to SAS running remotely on a computer with lots of RAM? I have no idea how that works, but these links might get you started. http://support.sas.com/documentation/cdl/en/camref/61896/HTML/default/viewer.htm#a000382050.htm http://support.sas.com/documentation/cdl/en/hostunx/61879/HTML/default/viewer.htm#sasrem.htm There are other great reasons to use Pandas or R, but I don't think you need to worry about memory limits. If you can't fit enough memory on your laptop, run the Python or R instance elsewhere and connect with SSH, iPython Notebook or RStudio.
Out-of-core data analysis options
You already seem comfortable with SAS, and your datasets are small enough to fit in RAM, but maybe you can't fit enough RAM into your laptop. If you don't mind sticking with SAS, how about you just co
Out-of-core data analysis options You already seem comfortable with SAS, and your datasets are small enough to fit in RAM, but maybe you can't fit enough RAM into your laptop. If you don't mind sticking with SAS, how about you just connect to SAS running remotely on a computer with lots of RAM? I have no idea how that works, but these links might get you started. http://support.sas.com/documentation/cdl/en/camref/61896/HTML/default/viewer.htm#a000382050.htm http://support.sas.com/documentation/cdl/en/hostunx/61879/HTML/default/viewer.htm#sasrem.htm There are other great reasons to use Pandas or R, but I don't think you need to worry about memory limits. If you can't fit enough memory on your laptop, run the Python or R instance elsewhere and connect with SSH, iPython Notebook or RStudio.
Out-of-core data analysis options You already seem comfortable with SAS, and your datasets are small enough to fit in RAM, but maybe you can't fit enough RAM into your laptop. If you don't mind sticking with SAS, how about you just co
15,032
Out-of-core data analysis options
Graphchi is excellent, and can handle huge datasets. It's a bit of a pain to work with, but it can handle graphical and non-graphical data.
Out-of-core data analysis options
Graphchi is excellent, and can handle huge datasets. It's a bit of a pain to work with, but it can handle graphical and non-graphical data.
Out-of-core data analysis options Graphchi is excellent, and can handle huge datasets. It's a bit of a pain to work with, but it can handle graphical and non-graphical data.
Out-of-core data analysis options Graphchi is excellent, and can handle huge datasets. It's a bit of a pain to work with, but it can handle graphical and non-graphical data.
15,033
Out-of-core data analysis options
I recently came across SFrames and GraphLab Create. These are libraries for Python that offer the kind of functionality you seem to be looking for From the Pypi site: "SFrame is an scalable, out-of-core dataframe, which allows you to work with datasets that are larger than the amount of RAM on your system." So think of it as the data manipulation functionality and API in Pandas but without puttin all the data in memory first. SFrame is free and open source as far as I know. On the other hand GraphLab builds on the SFrame functionality to provide algorithms for doing descriptive and predictive (machine learning) analytics on data that is stored in SFrames. GraphLab Create create is not free / open source, but has a free demo license. In any case, depending on how sophisticated your algorithms need to be, SFrame might suffice for you. Or if you require for instance a quick and dirty linear / logistic / ridge regression on your data, you can implement your self it on the SFrame with some simple SGD method, for example, and avoid having to pay for Graphlab Create license.
Out-of-core data analysis options
I recently came across SFrames and GraphLab Create. These are libraries for Python that offer the kind of functionality you seem to be looking for From the Pypi site: "SFrame is an scalable, out-of-
Out-of-core data analysis options I recently came across SFrames and GraphLab Create. These are libraries for Python that offer the kind of functionality you seem to be looking for From the Pypi site: "SFrame is an scalable, out-of-core dataframe, which allows you to work with datasets that are larger than the amount of RAM on your system." So think of it as the data manipulation functionality and API in Pandas but without puttin all the data in memory first. SFrame is free and open source as far as I know. On the other hand GraphLab builds on the SFrame functionality to provide algorithms for doing descriptive and predictive (machine learning) analytics on data that is stored in SFrames. GraphLab Create create is not free / open source, but has a free demo license. In any case, depending on how sophisticated your algorithms need to be, SFrame might suffice for you. Or if you require for instance a quick and dirty linear / logistic / ridge regression on your data, you can implement your self it on the SFrame with some simple SGD method, for example, and avoid having to pay for Graphlab Create license.
Out-of-core data analysis options I recently came across SFrames and GraphLab Create. These are libraries for Python that offer the kind of functionality you seem to be looking for From the Pypi site: "SFrame is an scalable, out-of-
15,034
Out-of-core data analysis options
Have you considered a "Real", non-interpreted language like Fortran? It seems like the suggestions so far are either very vendor dependent or interpreted. Interpreted methods are notoriously bad at memory intense applications. MatLab may be much higher level of a language than "C" but the memory handling optimizations in C can make it handle 100's of times faster data sets that are millions of times larger. Both "R" and "Python" are wonderful, high-level, technically rich and highly used languages. They are also interpreted. You might consider one of the R-on-Hadoop instances. (Rhipe, others) This has the advantage of being able to translate R (high level, easy to program) into MapReduce/Hadoop instructions. Hadoop can make an interesting poor-mans multiprocessing cluster. http://www.datadr.org/ <-- (Rhipe link) Fortran has been being developed for decades. It has very efficient memory handling, and compiling. It also has some higher level libraries so it can do very technically sophisticated operations pretty simply. I might do a toy CFD in MatLab, but for something realistic and self-coded, I would use Fortran for the "big-iron" processing and something like MatLab or R for presenting/summarizing data. Nobody makes commercial CFD software whose "engine" is interpreted instead of compiled. Several vendors have their moneymaker CFD coded in C or Fortran. SAS was originally written in C (link). Fortran and Rhipe are accessible. MatLab costs money and if my job didn't pay for it then I would be using R or Python right now. UPDATE: My point was "compiled". Python has cython that can literally run the same (fundamental) code ~1000x faster. That means you can have data that is ~1000x larger and process it in nearly the same time. Getting Cython to work clean can be a challenge, but tools like "Sage" wrap it well. Rcpp allegedly has similar, but I don't personally know that it is as well developed. If you think about it, the fundamentals of nearly everything you run in scientific computing, even in interpreted languages is compiled Fortran or compiled C. BLAS is BLAS; you aren't re-inventing the code every time you do EDA. Your interpreted language is calling those libraries, albeit very inefficiently, when it runs. As an aside, you might look at JMP. It has very easy to use interface and is excellent for very visual exploratory data analysis (EDA).
Out-of-core data analysis options
Have you considered a "Real", non-interpreted language like Fortran? It seems like the suggestions so far are either very vendor dependent or interpreted. Interpreted methods are notoriously bad at m
Out-of-core data analysis options Have you considered a "Real", non-interpreted language like Fortran? It seems like the suggestions so far are either very vendor dependent or interpreted. Interpreted methods are notoriously bad at memory intense applications. MatLab may be much higher level of a language than "C" but the memory handling optimizations in C can make it handle 100's of times faster data sets that are millions of times larger. Both "R" and "Python" are wonderful, high-level, technically rich and highly used languages. They are also interpreted. You might consider one of the R-on-Hadoop instances. (Rhipe, others) This has the advantage of being able to translate R (high level, easy to program) into MapReduce/Hadoop instructions. Hadoop can make an interesting poor-mans multiprocessing cluster. http://www.datadr.org/ <-- (Rhipe link) Fortran has been being developed for decades. It has very efficient memory handling, and compiling. It also has some higher level libraries so it can do very technically sophisticated operations pretty simply. I might do a toy CFD in MatLab, but for something realistic and self-coded, I would use Fortran for the "big-iron" processing and something like MatLab or R for presenting/summarizing data. Nobody makes commercial CFD software whose "engine" is interpreted instead of compiled. Several vendors have their moneymaker CFD coded in C or Fortran. SAS was originally written in C (link). Fortran and Rhipe are accessible. MatLab costs money and if my job didn't pay for it then I would be using R or Python right now. UPDATE: My point was "compiled". Python has cython that can literally run the same (fundamental) code ~1000x faster. That means you can have data that is ~1000x larger and process it in nearly the same time. Getting Cython to work clean can be a challenge, but tools like "Sage" wrap it well. Rcpp allegedly has similar, but I don't personally know that it is as well developed. If you think about it, the fundamentals of nearly everything you run in scientific computing, even in interpreted languages is compiled Fortran or compiled C. BLAS is BLAS; you aren't re-inventing the code every time you do EDA. Your interpreted language is calling those libraries, albeit very inefficiently, when it runs. As an aside, you might look at JMP. It has very easy to use interface and is excellent for very visual exploratory data analysis (EDA).
Out-of-core data analysis options Have you considered a "Real", non-interpreted language like Fortran? It seems like the suggestions so far are either very vendor dependent or interpreted. Interpreted methods are notoriously bad at m
15,035
Speed, computational expenses of PCA, LASSO, elastic net
Group 1: The complexity/speed of group 1. seems not too difficult to figure out if brute force algorithms are used (although there may be more efficient alternatives such as the "leaps and bounds" algorithm). For example, full subset selection will require $2^K$ regressions to be fit given a pool of $K$ candidate features. An OLS fit of one linear regression has the complexity of $\mathcal{O}(K^2 n)$ (as per this post) where $n$ is the sample size. Hence, the total complexity of brute-force full subset selection should be $\mathcal{O}(2^K K^2 n)$. Group 2: The complexity/speed of group 2. is discussed in sections 3.8 and 3.9 of the book. For example, ridge regression with a given penalty $\lambda$ has the same computational complexity as a regular regression. Since $\lambda$ needs to be found using cross validation, the computational load increases linearly in the number of data splits used in cross-validation (say, $S$). If the $\lambda$ grid has $L$ points, the total complexity of ridge regression with tuning the $\lambda$ parameter will be $\mathcal{O}(LSK^2 n)$. There is quite some talk about LASSO in the book, but I could not find quite what I need. However, I found on p. 443 of Efron et al. "Least Angle Regression" (2004) that LASSO complexity for a given $\lambda$ is the same as the complexity of an OLS fit of linear regression if LARS method is used. Then the total complexity of LASSO with tuning the $\lambda$ parameter will be $\mathcal{O}(LSK^2 n)$. (I did not read that paper carefully, so please correct me if I got this one wrong.) Elastic net combines ridge and LASSO; the two have the same computational complexity; hence, the complexity of elastic net should be $\mathcal{O}(ALSK^2 n)$ where $A$ is the grid size of the tuning parameter $\alpha$ that balances the weights of ridge versus LASSO. Group 3: I still miss any note on the complexity/speed for group 3. which consists of principal components regression (PCR) and partial least squares (PLS).
Speed, computational expenses of PCA, LASSO, elastic net
Group 1: The complexity/speed of group 1. seems not too difficult to figure out if brute force algorithms are used (although there may be more efficient alternatives such as the "leaps and bounds" alg
Speed, computational expenses of PCA, LASSO, elastic net Group 1: The complexity/speed of group 1. seems not too difficult to figure out if brute force algorithms are used (although there may be more efficient alternatives such as the "leaps and bounds" algorithm). For example, full subset selection will require $2^K$ regressions to be fit given a pool of $K$ candidate features. An OLS fit of one linear regression has the complexity of $\mathcal{O}(K^2 n)$ (as per this post) where $n$ is the sample size. Hence, the total complexity of brute-force full subset selection should be $\mathcal{O}(2^K K^2 n)$. Group 2: The complexity/speed of group 2. is discussed in sections 3.8 and 3.9 of the book. For example, ridge regression with a given penalty $\lambda$ has the same computational complexity as a regular regression. Since $\lambda$ needs to be found using cross validation, the computational load increases linearly in the number of data splits used in cross-validation (say, $S$). If the $\lambda$ grid has $L$ points, the total complexity of ridge regression with tuning the $\lambda$ parameter will be $\mathcal{O}(LSK^2 n)$. There is quite some talk about LASSO in the book, but I could not find quite what I need. However, I found on p. 443 of Efron et al. "Least Angle Regression" (2004) that LASSO complexity for a given $\lambda$ is the same as the complexity of an OLS fit of linear regression if LARS method is used. Then the total complexity of LASSO with tuning the $\lambda$ parameter will be $\mathcal{O}(LSK^2 n)$. (I did not read that paper carefully, so please correct me if I got this one wrong.) Elastic net combines ridge and LASSO; the two have the same computational complexity; hence, the complexity of elastic net should be $\mathcal{O}(ALSK^2 n)$ where $A$ is the grid size of the tuning parameter $\alpha$ that balances the weights of ridge versus LASSO. Group 3: I still miss any note on the complexity/speed for group 3. which consists of principal components regression (PCR) and partial least squares (PLS).
Speed, computational expenses of PCA, LASSO, elastic net Group 1: The complexity/speed of group 1. seems not too difficult to figure out if brute force algorithms are used (although there may be more efficient alternatives such as the "leaps and bounds" alg
15,036
Speed, computational expenses of PCA, LASSO, elastic net
It's only for one part of question 2 on group 3 above (namely PLS), but may be informative nonetheless: Srinivasan et al (2010, technical report; see https://www.umiacs.umd.edu/~balajiv/Papers/UMD_CS_TR_Pls_Gpu.pdf) did some measurements on PLS using the NIPALS algorithm - stating that time (and space) complexity of this algorithm be O(dN) - for extraction and including these in different models for a) detection of humans in images, and b) face recognition. Measurements were done using their own GPU based implementation.
Speed, computational expenses of PCA, LASSO, elastic net
It's only for one part of question 2 on group 3 above (namely PLS), but may be informative nonetheless: Srinivasan et al (2010, technical report; see https://www.umiacs.umd.edu/~balajiv/Papers/UMD_CS_
Speed, computational expenses of PCA, LASSO, elastic net It's only for one part of question 2 on group 3 above (namely PLS), but may be informative nonetheless: Srinivasan et al (2010, technical report; see https://www.umiacs.umd.edu/~balajiv/Papers/UMD_CS_TR_Pls_Gpu.pdf) did some measurements on PLS using the NIPALS algorithm - stating that time (and space) complexity of this algorithm be O(dN) - for extraction and including these in different models for a) detection of humans in images, and b) face recognition. Measurements were done using their own GPU based implementation.
Speed, computational expenses of PCA, LASSO, elastic net It's only for one part of question 2 on group 3 above (namely PLS), but may be informative nonetheless: Srinivasan et al (2010, technical report; see https://www.umiacs.umd.edu/~balajiv/Papers/UMD_CS_
15,037
Rare event logistic regression bias: how to simulate the underestimated p's with a minimal example?
This is an interesting question - I'm have done a few simulations that I post below in the hope that this stimulates further discussion. First of all, a few general comments: The paper you cite is about rare-event bias. What was not clear to me before (also with respect to comments that were made above) is if there is anything special about cases where you have 10/10000 as opposed to 10/30 observations. However, after some simulations, I would agree there is. A problem I had in mind (I have encountered this often, and there was recently a paper in Methods in Ecology and Evolution on that, I couldn't find the reference though) is that you can get degenerate cases with GLMs in small-data situations, where the MLE is FAAAR away from the truth, or even at - / + infinity (due to the nonlinear link I suppose). It's not clear to me how one should treat these cases in the bias estimation, but from my simulations I would say they seem key for the rare-event bias. My intuition would be to remove them, but then it's not quite clear how far out they have to be to be removed. Maybe something to keep in mind for bias-correction. Also, these degenerate cases seem prone to cause numerical problems (I have therefore increased maxit in the glm function, but one could think about increasing epsilon as well to make sure one actually reports the true MLE). Anyway, here some code that calculates the difference between estimates and truth for intercept, slope and predictions in a logistic regression, first for a low sample size / moderate incidence situation: set.seed(123) replicates = 1000 N= 40 slope = 2 # slope (linear scale) intercept = - 1 # intercept (linear scale) bias <- matrix(NA, nrow = replicates, ncol = 3) incidencePredBias <- rep(NA, replicates) for (i in 1:replicates){ pred = runif(N,min=-1,max=1) linearResponse = intercept + slope*pred data = rbinom(N, 1, plogis(linearResponse)) fit <- glm(data ~ pred, family = 'binomial', control = list(maxit = 300)) bias[i,1:2] = fit$coefficients - c(intercept, slope) bias[i,3] = mean(predict(fit,type = "response")) - mean(plogis(linearResponse)) } par(mfrow = c(1,3)) text = c("Bias intercept", "Bias slope", "Bias prediction") for (i in 1:3){ hist(bias[,i], breaks = 100, main = text[i]) abline(v=mean(bias[,i]), col = "red", lwd = 3) } apply(bias, 2, mean) apply(bias, 2, sd) / sqrt(replicates) The resulting bias and standard errors for intercept, slope and prediction are -0.120429315 0.296453122 -0.001619793 0.016105833 0.032835468 0.002040664 I would conclude that there is pretty good evidence for a slight negative bias in the intercept, and a slight positive bias in the slope, although a look at the plotted results shows that the bias is small compared the the variance of the estimated values. If I'm setting the parameters to a rare-event situation N= 4000 slope = 2 # slope (linear scale) intercept = - 10 # intercept (linear scale) I'm getting a larger bias for the intercept, but still NONE on the prediction -1.716144e+01 4.271145e-01 -3.793141e-06 5.039331e-01 4.806615e-01 4.356062e-06 In the histogram of the estimated values, we see the phenomenon of degenerate parameter estimates (if we should call them like that) Let's remove all rows for which intercept estimates are <20 apply(bias[bias[,1] > -20,], 2, mean) apply(bias[bias[,1] > -20,], 2, sd) / sqrt(length(bias[,1] > -10)) The bias decreases, and things become a bit more clear in the figures - parameter estimates are clearly not normally distributed. I wonder that that means for the validity of the CIs that are reported. -0.6694874106 1.9740437782 0.0002079945 1.329322e-01 1.619451e-01 3.242677e-06 I would conclude the rare event bias on the intercept is driven by rare events itself, namely those rare, extremely small estimates. Not sure if we want to remove them or not, not sure what the cutoff would be. An important thing to note though is that, either way, there seems to be no bias on predictions at the response scale - the link function simply absorbs these extremely small values.
Rare event logistic regression bias: how to simulate the underestimated p's with a minimal example?
This is an interesting question - I'm have done a few simulations that I post below in the hope that this stimulates further discussion. First of all, a few general comments: The paper you cite is ab
Rare event logistic regression bias: how to simulate the underestimated p's with a minimal example? This is an interesting question - I'm have done a few simulations that I post below in the hope that this stimulates further discussion. First of all, a few general comments: The paper you cite is about rare-event bias. What was not clear to me before (also with respect to comments that were made above) is if there is anything special about cases where you have 10/10000 as opposed to 10/30 observations. However, after some simulations, I would agree there is. A problem I had in mind (I have encountered this often, and there was recently a paper in Methods in Ecology and Evolution on that, I couldn't find the reference though) is that you can get degenerate cases with GLMs in small-data situations, where the MLE is FAAAR away from the truth, or even at - / + infinity (due to the nonlinear link I suppose). It's not clear to me how one should treat these cases in the bias estimation, but from my simulations I would say they seem key for the rare-event bias. My intuition would be to remove them, but then it's not quite clear how far out they have to be to be removed. Maybe something to keep in mind for bias-correction. Also, these degenerate cases seem prone to cause numerical problems (I have therefore increased maxit in the glm function, but one could think about increasing epsilon as well to make sure one actually reports the true MLE). Anyway, here some code that calculates the difference between estimates and truth for intercept, slope and predictions in a logistic regression, first for a low sample size / moderate incidence situation: set.seed(123) replicates = 1000 N= 40 slope = 2 # slope (linear scale) intercept = - 1 # intercept (linear scale) bias <- matrix(NA, nrow = replicates, ncol = 3) incidencePredBias <- rep(NA, replicates) for (i in 1:replicates){ pred = runif(N,min=-1,max=1) linearResponse = intercept + slope*pred data = rbinom(N, 1, plogis(linearResponse)) fit <- glm(data ~ pred, family = 'binomial', control = list(maxit = 300)) bias[i,1:2] = fit$coefficients - c(intercept, slope) bias[i,3] = mean(predict(fit,type = "response")) - mean(plogis(linearResponse)) } par(mfrow = c(1,3)) text = c("Bias intercept", "Bias slope", "Bias prediction") for (i in 1:3){ hist(bias[,i], breaks = 100, main = text[i]) abline(v=mean(bias[,i]), col = "red", lwd = 3) } apply(bias, 2, mean) apply(bias, 2, sd) / sqrt(replicates) The resulting bias and standard errors for intercept, slope and prediction are -0.120429315 0.296453122 -0.001619793 0.016105833 0.032835468 0.002040664 I would conclude that there is pretty good evidence for a slight negative bias in the intercept, and a slight positive bias in the slope, although a look at the plotted results shows that the bias is small compared the the variance of the estimated values. If I'm setting the parameters to a rare-event situation N= 4000 slope = 2 # slope (linear scale) intercept = - 10 # intercept (linear scale) I'm getting a larger bias for the intercept, but still NONE on the prediction -1.716144e+01 4.271145e-01 -3.793141e-06 5.039331e-01 4.806615e-01 4.356062e-06 In the histogram of the estimated values, we see the phenomenon of degenerate parameter estimates (if we should call them like that) Let's remove all rows for which intercept estimates are <20 apply(bias[bias[,1] > -20,], 2, mean) apply(bias[bias[,1] > -20,], 2, sd) / sqrt(length(bias[,1] > -10)) The bias decreases, and things become a bit more clear in the figures - parameter estimates are clearly not normally distributed. I wonder that that means for the validity of the CIs that are reported. -0.6694874106 1.9740437782 0.0002079945 1.329322e-01 1.619451e-01 3.242677e-06 I would conclude the rare event bias on the intercept is driven by rare events itself, namely those rare, extremely small estimates. Not sure if we want to remove them or not, not sure what the cutoff would be. An important thing to note though is that, either way, there seems to be no bias on predictions at the response scale - the link function simply absorbs these extremely small values.
Rare event logistic regression bias: how to simulate the underestimated p's with a minimal example? This is an interesting question - I'm have done a few simulations that I post below in the hope that this stimulates further discussion. First of all, a few general comments: The paper you cite is ab
15,038
Rare event logistic regression bias: how to simulate the underestimated p's with a minimal example?
Figure 7 in the paper seems to most-directly address the question of bias in the predictions. I don't fully understand the figure (specifically, the interpretation "estimated event probabilities are too small" seems like an oversimplification) but I managed to reproduce something similar to it based on their terse description of their simulation in Section 6.1: n_grid = 40 x_grid = seq(0, 7, length.out = n_grid) beta0 = -6 beta1 = 1 inverse_logit = function(x) 1/(1 + exp(-x)) do.one.sim = function(){ N = 5000 x = rnorm(N) p = inverse_logit(beta0 + beta1*x) # Draw fake data based on probabilities p y = rbinom(N, 1, p) if(sum(y) == 0){ # then the glm MLE = minus infinity to get p = 0 return(rep(0, n_grid)) }else{ # Extract the error mod = glm(y ~ x, family = 'binomial') truth = inverse_logit(beta0 + beta1*x_grid) pred = predict(mod, newdata = data.frame(x = x_grid), type = 'response') return(pred - truth) } } mean.of.K.estimates = function(K){ rowMeans(replicate(K, do.one.sim())) } set.seed(1) bias = replicate(10, mean.of.K.estimates(100)) maxes = as.numeric(apply(bias, 1, max)) mins = as.numeric(apply(bias, 1, min)) par(mfrow = c(3, 1), mar = c(4,4,2,2)) plot(x_grid, rowMeans(bias), type = 'l', ylim = c(min(bias), max(bias)), xlab = 'x', ylab = 'bias') lines(x_grid, maxes, lty = 2) lines(x_grid, mins, lty = 2) plot(x_grid, dnorm(x_grid), type = 'l', xlab = 'x', ylab = 'standard normal density') plot(x_grid, inverse_logit(beta0 + beta1*x_grid), xlab = 'x', ylab = 'true simulation P(Y = 1)', type = 'l') The first plot is my replication of their figure 7, with the addition of dashed curves representing the full range of results over 10 trials. As per the paper, x here is a predictor variable in the regression drawn from a standard normal. Thus, as illustrated in the second plot, the the relative frequency of observations for x > 3 (where the most visible bias occurs in the first plot) is diminishingly small. The third plot shows the "true" simulation probabilities in the generating process as a function of x. It appears that the greatest bias occurs where x is rare or non-existent. Taken together, these suggest that the OP entirely misinterpreted the central claim of the paper by confusing "rare event" (i.e. x > 3) with "event for which P(Y = 1) is very small". Presumably the paper concerns the former instead of the latter.
Rare event logistic regression bias: how to simulate the underestimated p's with a minimal example?
Figure 7 in the paper seems to most-directly address the question of bias in the predictions. I don't fully understand the figure (specifically, the interpretation "estimated event probabilities are t
Rare event logistic regression bias: how to simulate the underestimated p's with a minimal example? Figure 7 in the paper seems to most-directly address the question of bias in the predictions. I don't fully understand the figure (specifically, the interpretation "estimated event probabilities are too small" seems like an oversimplification) but I managed to reproduce something similar to it based on their terse description of their simulation in Section 6.1: n_grid = 40 x_grid = seq(0, 7, length.out = n_grid) beta0 = -6 beta1 = 1 inverse_logit = function(x) 1/(1 + exp(-x)) do.one.sim = function(){ N = 5000 x = rnorm(N) p = inverse_logit(beta0 + beta1*x) # Draw fake data based on probabilities p y = rbinom(N, 1, p) if(sum(y) == 0){ # then the glm MLE = minus infinity to get p = 0 return(rep(0, n_grid)) }else{ # Extract the error mod = glm(y ~ x, family = 'binomial') truth = inverse_logit(beta0 + beta1*x_grid) pred = predict(mod, newdata = data.frame(x = x_grid), type = 'response') return(pred - truth) } } mean.of.K.estimates = function(K){ rowMeans(replicate(K, do.one.sim())) } set.seed(1) bias = replicate(10, mean.of.K.estimates(100)) maxes = as.numeric(apply(bias, 1, max)) mins = as.numeric(apply(bias, 1, min)) par(mfrow = c(3, 1), mar = c(4,4,2,2)) plot(x_grid, rowMeans(bias), type = 'l', ylim = c(min(bias), max(bias)), xlab = 'x', ylab = 'bias') lines(x_grid, maxes, lty = 2) lines(x_grid, mins, lty = 2) plot(x_grid, dnorm(x_grid), type = 'l', xlab = 'x', ylab = 'standard normal density') plot(x_grid, inverse_logit(beta0 + beta1*x_grid), xlab = 'x', ylab = 'true simulation P(Y = 1)', type = 'l') The first plot is my replication of their figure 7, with the addition of dashed curves representing the full range of results over 10 trials. As per the paper, x here is a predictor variable in the regression drawn from a standard normal. Thus, as illustrated in the second plot, the the relative frequency of observations for x > 3 (where the most visible bias occurs in the first plot) is diminishingly small. The third plot shows the "true" simulation probabilities in the generating process as a function of x. It appears that the greatest bias occurs where x is rare or non-existent. Taken together, these suggest that the OP entirely misinterpreted the central claim of the paper by confusing "rare event" (i.e. x > 3) with "event for which P(Y = 1) is very small". Presumably the paper concerns the former instead of the latter.
Rare event logistic regression bias: how to simulate the underestimated p's with a minimal example? Figure 7 in the paper seems to most-directly address the question of bias in the predictions. I don't fully understand the figure (specifically, the interpretation "estimated event probabilities are t
15,039
Rare event logistic regression bias: how to simulate the underestimated p's with a minimal example?
Rare events bias only occurs when there are regressors. It won't occur in an intercept-only model like the one simulated here. See this post for details: http://statisticalhorizons.com/linear-vs-logistic#comment-276108
Rare event logistic regression bias: how to simulate the underestimated p's with a minimal example?
Rare events bias only occurs when there are regressors. It won't occur in an intercept-only model like the one simulated here. See this post for details: http://statisticalhorizons.com/linear-vs-logi
Rare event logistic regression bias: how to simulate the underestimated p's with a minimal example? Rare events bias only occurs when there are regressors. It won't occur in an intercept-only model like the one simulated here. See this post for details: http://statisticalhorizons.com/linear-vs-logistic#comment-276108
Rare event logistic regression bias: how to simulate the underestimated p's with a minimal example? Rare events bias only occurs when there are regressors. It won't occur in an intercept-only model like the one simulated here. See this post for details: http://statisticalhorizons.com/linear-vs-logi
15,040
Bayesian network inference using pymc (Beginner's confusion)
Take a look at a post in Healthy Algorithm: http://healthyalgorithms.com/2011/11/23/causal-modeling-in-python-bayesian-networks-in-pymc/ also in PyMC's totorial: http://pymc-devs.github.io/pymc/tutorial.html Maybe you would try the following code clip (assuming you have imported pymc as mc): A = mc.Normal('A', mu_A, tau_A) B = mc.Normal('B', mu_B, tau_B) p_C = mc.Lambda('p_C', lambda A=A, B=B: <<dependency spec goes here>>, doc='Pr[C|AB]') C = mc.Bernoulli('C', p_C)
Bayesian network inference using pymc (Beginner's confusion)
Take a look at a post in Healthy Algorithm: http://healthyalgorithms.com/2011/11/23/causal-modeling-in-python-bayesian-networks-in-pymc/ also in PyMC's totorial: http://pymc-devs.github.io/pymc/tutori
Bayesian network inference using pymc (Beginner's confusion) Take a look at a post in Healthy Algorithm: http://healthyalgorithms.com/2011/11/23/causal-modeling-in-python-bayesian-networks-in-pymc/ also in PyMC's totorial: http://pymc-devs.github.io/pymc/tutorial.html Maybe you would try the following code clip (assuming you have imported pymc as mc): A = mc.Normal('A', mu_A, tau_A) B = mc.Normal('B', mu_B, tau_B) p_C = mc.Lambda('p_C', lambda A=A, B=B: <<dependency spec goes here>>, doc='Pr[C|AB]') C = mc.Bernoulli('C', p_C)
Bayesian network inference using pymc (Beginner's confusion) Take a look at a post in Healthy Algorithm: http://healthyalgorithms.com/2011/11/23/causal-modeling-in-python-bayesian-networks-in-pymc/ also in PyMC's totorial: http://pymc-devs.github.io/pymc/tutori
15,041
Two worlds collide: Using ML for complex survey data
Update May 2022: In terms of accounting for survey weights, there's a nice pair of recent (2020?) articles on arXiv by Dagdoug, Goga, and Haziza. They list many ML-flavored methods and discuss how they have been / could be modified to incorporate weights, including kNN, splines, trees, random forests, XGBoost, BART, Cubist, SVN, principal component regression, and elastic net. "Imputation procedures in surveys using nonparametric and machine learning methods: an empirical comparison" "Model-assisted estimation in high-dimensional settings for survey data" In terms of accounting for strata and clusters, and estimating predictive performance for the population when the data came from a complex sampling design, I humbly submit a recent article on "K-fold cross-validation for complex sample surveys," Wieczorek, Guerin, and McMahon (2022). See this answer for a quick overview of how to create cross-validation folds that respect your first-stage clusters and strata. If you're an R user, you can use folds.svy() in our R package surveyCV. Then use these folds to cross-validate your ML models as usual. Finally, if you also have survey weights, calculate survey-weighted means of your CV test errors. Our README has an example of doing this for parameter tuning with a random forest. Update August 2017: There isn't very much work yet on "modern" ML methods with complex survey data, but the most recent issue of Statistical Science has a couple of review articles. See especially Breidt and Opsomer (2017), "Model-Assisted Survey Estimation with Modern Prediction Techniques". Also, based on the Toth and Eltinge paper you mentioned, there is now an R package rpms implementing CART for complex-survey data. Original answer October 2016: Now I want to apply classical machine learning to those data (e.g. predicting some missing values for subset of respondents - basically classification task). I'm not fully clear on your goal. Are you primarily trying to impute missing observations, just to have a "complete" dataset to give someone else? Or do you have complete data already, and you want to build a model to predict/classify new observations' responses? Do you have a particular question to answer with your model(s), or are you data-mining more broadly? In either case, complex-sample-survey / survey-weighted logistic regression is a reasonable, pretty well-understood method. There's also ordinal regression for more than 2 categories. These will account for stratas and survey weights. Do you need a fancier ML method than this? For example, you could use svyglm in R's survey package. Even if you don't using R, the package author, Thomas Lumley, also wrote a useful book "Complex Surveys: A Guide to Analysis Using R" which covers both logistic regression and missing data for surveys. (For imputation, I hope you're already familiar with general issues around missing data. If not, look into approaches like multiple imputation to help you account for how the imputation step affects your estimates/predictions.) Question routing is indeed an additional problem. I'm not sure how best to deal with it. For imputation, perhaps you can impute one "step" in the routing at a time. E.g. using a global model, first impute everyone's answer to "How many kids do you have?"; then run a new model on the relevant sub-population (people with more than 0 kids) to impute the next step of "How old are your kids?"
Two worlds collide: Using ML for complex survey data
Update May 2022: In terms of accounting for survey weights, there's a nice pair of recent (2020?) articles on arXiv by Dagdoug, Goga, and Haziza. They list many ML-flavored methods and discuss how the
Two worlds collide: Using ML for complex survey data Update May 2022: In terms of accounting for survey weights, there's a nice pair of recent (2020?) articles on arXiv by Dagdoug, Goga, and Haziza. They list many ML-flavored methods and discuss how they have been / could be modified to incorporate weights, including kNN, splines, trees, random forests, XGBoost, BART, Cubist, SVN, principal component regression, and elastic net. "Imputation procedures in surveys using nonparametric and machine learning methods: an empirical comparison" "Model-assisted estimation in high-dimensional settings for survey data" In terms of accounting for strata and clusters, and estimating predictive performance for the population when the data came from a complex sampling design, I humbly submit a recent article on "K-fold cross-validation for complex sample surveys," Wieczorek, Guerin, and McMahon (2022). See this answer for a quick overview of how to create cross-validation folds that respect your first-stage clusters and strata. If you're an R user, you can use folds.svy() in our R package surveyCV. Then use these folds to cross-validate your ML models as usual. Finally, if you also have survey weights, calculate survey-weighted means of your CV test errors. Our README has an example of doing this for parameter tuning with a random forest. Update August 2017: There isn't very much work yet on "modern" ML methods with complex survey data, but the most recent issue of Statistical Science has a couple of review articles. See especially Breidt and Opsomer (2017), "Model-Assisted Survey Estimation with Modern Prediction Techniques". Also, based on the Toth and Eltinge paper you mentioned, there is now an R package rpms implementing CART for complex-survey data. Original answer October 2016: Now I want to apply classical machine learning to those data (e.g. predicting some missing values for subset of respondents - basically classification task). I'm not fully clear on your goal. Are you primarily trying to impute missing observations, just to have a "complete" dataset to give someone else? Or do you have complete data already, and you want to build a model to predict/classify new observations' responses? Do you have a particular question to answer with your model(s), or are you data-mining more broadly? In either case, complex-sample-survey / survey-weighted logistic regression is a reasonable, pretty well-understood method. There's also ordinal regression for more than 2 categories. These will account for stratas and survey weights. Do you need a fancier ML method than this? For example, you could use svyglm in R's survey package. Even if you don't using R, the package author, Thomas Lumley, also wrote a useful book "Complex Surveys: A Guide to Analysis Using R" which covers both logistic regression and missing data for surveys. (For imputation, I hope you're already familiar with general issues around missing data. If not, look into approaches like multiple imputation to help you account for how the imputation step affects your estimates/predictions.) Question routing is indeed an additional problem. I'm not sure how best to deal with it. For imputation, perhaps you can impute one "step" in the routing at a time. E.g. using a global model, first impute everyone's answer to "How many kids do you have?"; then run a new model on the relevant sub-population (people with more than 0 kids) to impute the next step of "How old are your kids?"
Two worlds collide: Using ML for complex survey data Update May 2022: In terms of accounting for survey weights, there's a nice pair of recent (2020?) articles on arXiv by Dagdoug, Goga, and Haziza. They list many ML-flavored methods and discuss how the
15,042
Two worlds collide: Using ML for complex survey data
R package glmertree allows for fitting decision trees to multilevel data. It allows for specifying a random effects structure, and partitioning the dataset into subgroups using predictors. (The method can correct for the level at which partitioning variables are measured through a cluster argument) For further reference, see the package vignette (tutorial): https://cran.r-project.org/web/packages/glmertree/vignettes/glmertree.pdf. Fokkema, M., Smits, N., Zeileis, A., Hothorn, T., & Kelderman, H. (2018). Detecting treatment-subgroup interactions in clustered data with generalized linear mixed-effects model trees. Behavior research methods, 50(5), 2016-2034. https://doi.org/10.3758/s13428-017-0971-x Fokkema, M., Edbrooke-Childs, J., & Wolpert, M. (2021). Generalized linear mixed-model (GLMM) trees: A flexible decision-tree method for multilevel and longitudinal data. Psychotherapy Research, 31(3), 329-341. https://doi.org/10.1080/10503307.2020.1785037
Two worlds collide: Using ML for complex survey data
R package glmertree allows for fitting decision trees to multilevel data. It allows for specifying a random effects structure, and partitioning the dataset into subgroups using predictors. (The method
Two worlds collide: Using ML for complex survey data R package glmertree allows for fitting decision trees to multilevel data. It allows for specifying a random effects structure, and partitioning the dataset into subgroups using predictors. (The method can correct for the level at which partitioning variables are measured through a cluster argument) For further reference, see the package vignette (tutorial): https://cran.r-project.org/web/packages/glmertree/vignettes/glmertree.pdf. Fokkema, M., Smits, N., Zeileis, A., Hothorn, T., & Kelderman, H. (2018). Detecting treatment-subgroup interactions in clustered data with generalized linear mixed-effects model trees. Behavior research methods, 50(5), 2016-2034. https://doi.org/10.3758/s13428-017-0971-x Fokkema, M., Edbrooke-Childs, J., & Wolpert, M. (2021). Generalized linear mixed-model (GLMM) trees: A flexible decision-tree method for multilevel and longitudinal data. Psychotherapy Research, 31(3), 329-341. https://doi.org/10.1080/10503307.2020.1785037
Two worlds collide: Using ML for complex survey data R package glmertree allows for fitting decision trees to multilevel data. It allows for specifying a random effects structure, and partitioning the dataset into subgroups using predictors. (The method
15,043
Bias-variance decomposition
...the expected [squared error] loss can be decomposed into a squared bias term (which describes how far the average predictions are from the true model), a variance term (which describes the spread of the predictions around the average), and a noise term (which gives the intrinsic noise of the data). When looking at the squared error loss decomposition $$\mathbb{E}_\theta[(\theta-\delta(X_{1:n}))^2]=(\theta-\mathbb{E}_\theta[\delta(X_{1:n})])^2+\mathbb{E}_\theta[(\mathbb{E}_\theta[\delta(X_{1:n})]-\delta(X_{1:n}))^2]$$ I only see two terms: one for the bias and another one for the variance of the estimator or predictor, $\delta(X_{1:n})$. There is no additional noise term in the expected loss. As should be since the variability is the variability of $\delta(X_{1:n})$, not of the sample itself. Can bias-variance decomposition be performed with loss functions other than squared loss? My interpretation of the squared bias+variance decomposition [and the way I teach it] is that this is the statistical equivalent of Pythagore's Theorem, namely that the squared distance between an estimator and a point within a certain set is the sum of the squared distance between an estimator and the set, plus the squared distance between the orthogonal projection on the set and the point within the set. Any loss based on a distance with a notion of orthogonal projection, i.e., an inner product, i.e., essentially Hilbert spaces, satisfies this decomposition. For a given model dataset, is there more than one model whose expected loss is the minimum over all models, and if so, does that mean that there could be different combinations of bias and variance that yield the same minimum expected loss? The question is unclear: if by minimum over models, you mean $$\min_\theta \mathbb{E}_\theta[(\theta-\delta(X_{1:n}))^2]$$ then there are many examples of statistical models and associated decisions with a constant expected loss (or risk). Take for instance the MLE of a Normal mean. How can you calculate bias if you don't know the true model? In a generic sense, the bias is the distance between the true model and the closest model within the assumed family of distributions. If the true model is unknown, the bias can be ascertained by bootstrap. Are there situations in which it makes more sense to minimize bias or variance rather than expected loss (the sum of squared bias and variance)? When considering another loss function like $$(\theta-\mathbb{E}_\theta[\delta(X_{1:n})])^2+\alpha[(\mathbb{E}_\theta[\delta(X_{1:n})]-\delta(X_{1:n}))^2]\qquad 0<\alpha$$ pushing $\alpha$ to zero puts most of the evaluation on the bias while pushing $\alpha$ to infinity switches the focus on the variance.
Bias-variance decomposition
...the expected [squared error] loss can be decomposed into a squared bias term (which describes how far the average predictions are from the true model), a variance term (which describes the spre
Bias-variance decomposition ...the expected [squared error] loss can be decomposed into a squared bias term (which describes how far the average predictions are from the true model), a variance term (which describes the spread of the predictions around the average), and a noise term (which gives the intrinsic noise of the data). When looking at the squared error loss decomposition $$\mathbb{E}_\theta[(\theta-\delta(X_{1:n}))^2]=(\theta-\mathbb{E}_\theta[\delta(X_{1:n})])^2+\mathbb{E}_\theta[(\mathbb{E}_\theta[\delta(X_{1:n})]-\delta(X_{1:n}))^2]$$ I only see two terms: one for the bias and another one for the variance of the estimator or predictor, $\delta(X_{1:n})$. There is no additional noise term in the expected loss. As should be since the variability is the variability of $\delta(X_{1:n})$, not of the sample itself. Can bias-variance decomposition be performed with loss functions other than squared loss? My interpretation of the squared bias+variance decomposition [and the way I teach it] is that this is the statistical equivalent of Pythagore's Theorem, namely that the squared distance between an estimator and a point within a certain set is the sum of the squared distance between an estimator and the set, plus the squared distance between the orthogonal projection on the set and the point within the set. Any loss based on a distance with a notion of orthogonal projection, i.e., an inner product, i.e., essentially Hilbert spaces, satisfies this decomposition. For a given model dataset, is there more than one model whose expected loss is the minimum over all models, and if so, does that mean that there could be different combinations of bias and variance that yield the same minimum expected loss? The question is unclear: if by minimum over models, you mean $$\min_\theta \mathbb{E}_\theta[(\theta-\delta(X_{1:n}))^2]$$ then there are many examples of statistical models and associated decisions with a constant expected loss (or risk). Take for instance the MLE of a Normal mean. How can you calculate bias if you don't know the true model? In a generic sense, the bias is the distance between the true model and the closest model within the assumed family of distributions. If the true model is unknown, the bias can be ascertained by bootstrap. Are there situations in which it makes more sense to minimize bias or variance rather than expected loss (the sum of squared bias and variance)? When considering another loss function like $$(\theta-\mathbb{E}_\theta[\delta(X_{1:n})])^2+\alpha[(\mathbb{E}_\theta[\delta(X_{1:n})]-\delta(X_{1:n}))^2]\qquad 0<\alpha$$ pushing $\alpha$ to zero puts most of the evaluation on the bias while pushing $\alpha$ to infinity switches the focus on the variance.
Bias-variance decomposition ...the expected [squared error] loss can be decomposed into a squared bias term (which describes how far the average predictions are from the true model), a variance term (which describes the spre
15,044
Anomaly Detection with Dummy Features (and other Discrete/Categorical Features)
In general, for both discrete* & categorical features, this method isn't particularly amenable to outlier analysis. Since there is no magnitude associated with categorical predictors, we are working with: Frequency of the category being observed in the global data Frequency of the category being observed within subspaces of the data Note that neither of these qualities can be analyzed in isolation, as your Gaussian method requires. Instead, we need a method that contextualizes categorical features & considers the correlational nature of the data. Here are some techniques for categorical & mixed attribute data, based on Outlier Analysis by Aggarwal: If you can define a similarity function which builds a positive semidefinite matrix across all observations (regardless of data types), compute the similarity matrix $S$, find its diagonalization $S=Q_k\lambda_k^2Q_k^T$, and use the non-zero eigenvectors $Q_k$ to compute a feature embedding $E = Q_k\lambda_k$ . For each row (observation) in $E$, compute its distance from the centroid; this is your outlier score, and you can use univariate methods to determine outliers. If you have purely categorical features, fit a mixture model to the raw categorical data. Anomalous points have lowest generative probability. Use one-hot encoding for categorical predictors and optionally latent variable analysis** for ordinal variables with non-apparent continuous mappings Standardize the non-one-hot features (one-hot features are already implicitly standardized) and perform Principal Component Analysis. Perform dimensionality reduction using the top principal components (or a soft PCA approach where eigenvectors are weighted by eigenvalues) and run a typical continuous outlier analysis method (e.g. a mixture model or your Gaussian method) Perform an angle-based analysis. For each observation, compute cosine similarities between all pairs of points. Observations with the smallest variance of these similarities (known as the "Angle-Based Outlier Factor") are most likely outliers. May require a final analysis of the empirical distribution of ABOF to determine what is anomalous. If you have labelled outliers: Fit a predictive model to the engineered data (logistic regression, SVM, etc.). *Discrete features could possibly be handled approximately in your Gaussian method. Under the right conditions, a feature may be well approximated by a normal distribution (e.g. binomial random variable with npq > 3). If not, handle them as ordinals described above. **This is similar to your idea of "replace the category value with the percentage chance of observation"
Anomaly Detection with Dummy Features (and other Discrete/Categorical Features)
In general, for both discrete* & categorical features, this method isn't particularly amenable to outlier analysis. Since there is no magnitude associated with categorical predictors, we are working w
Anomaly Detection with Dummy Features (and other Discrete/Categorical Features) In general, for both discrete* & categorical features, this method isn't particularly amenable to outlier analysis. Since there is no magnitude associated with categorical predictors, we are working with: Frequency of the category being observed in the global data Frequency of the category being observed within subspaces of the data Note that neither of these qualities can be analyzed in isolation, as your Gaussian method requires. Instead, we need a method that contextualizes categorical features & considers the correlational nature of the data. Here are some techniques for categorical & mixed attribute data, based on Outlier Analysis by Aggarwal: If you can define a similarity function which builds a positive semidefinite matrix across all observations (regardless of data types), compute the similarity matrix $S$, find its diagonalization $S=Q_k\lambda_k^2Q_k^T$, and use the non-zero eigenvectors $Q_k$ to compute a feature embedding $E = Q_k\lambda_k$ . For each row (observation) in $E$, compute its distance from the centroid; this is your outlier score, and you can use univariate methods to determine outliers. If you have purely categorical features, fit a mixture model to the raw categorical data. Anomalous points have lowest generative probability. Use one-hot encoding for categorical predictors and optionally latent variable analysis** for ordinal variables with non-apparent continuous mappings Standardize the non-one-hot features (one-hot features are already implicitly standardized) and perform Principal Component Analysis. Perform dimensionality reduction using the top principal components (or a soft PCA approach where eigenvectors are weighted by eigenvalues) and run a typical continuous outlier analysis method (e.g. a mixture model or your Gaussian method) Perform an angle-based analysis. For each observation, compute cosine similarities between all pairs of points. Observations with the smallest variance of these similarities (known as the "Angle-Based Outlier Factor") are most likely outliers. May require a final analysis of the empirical distribution of ABOF to determine what is anomalous. If you have labelled outliers: Fit a predictive model to the engineered data (logistic regression, SVM, etc.). *Discrete features could possibly be handled approximately in your Gaussian method. Under the right conditions, a feature may be well approximated by a normal distribution (e.g. binomial random variable with npq > 3). If not, handle them as ordinals described above. **This is similar to your idea of "replace the category value with the percentage chance of observation"
Anomaly Detection with Dummy Features (and other Discrete/Categorical Features) In general, for both discrete* & categorical features, this method isn't particularly amenable to outlier analysis. Since there is no magnitude associated with categorical predictors, we are working w
15,045
Anomaly Detection with Dummy Features (and other Discrete/Categorical Features)
Andrew Ng class math handles "discrete" data quite like it handles "non-discrete" data. All we have to do is empirically estimate normal distribution parameters, and it can be perfectly done for discrete data. If you think about it, machine learning always deals with discrete data anyways: the number of data points is not infinite and the number of bits handled by computers is not infinite. If discrete data points can be compared between each other then there is no fundamental difference for machine learning methods when dealing with, say, length: 1.15 ft 1.34 ft 3.4 ft or how many branches are on the tree: 1 2 3 5 You can sum and average floating point or whole numbers just the same. Now, to categorical data. Categorical data points cannot be compared {car vs motorcycle vs boat). How do we handle this? The number of categories has to be at least two to make sense, otherwise what's the point in constant feature? In case of 2 categories, we can represent a category feature as a binary feature {0, 1}. 0 and 1 can be used for math, so see above. If number of categories (K) is [3.. inf], we map our single feature to K binary mutually exclusive features . For example, "motorcycle" category becomes a combination of binary features { IsCar: 0, IsMotorcycle: 1, IsBoat: 0}, Boat point becomes { IsCar: 0, IsMotorcycle: 0, IsBoat: 1} and so on. We can estimate empirical distribution parameters from these new features. We will simply have more dimensions, that's all.
Anomaly Detection with Dummy Features (and other Discrete/Categorical Features)
Andrew Ng class math handles "discrete" data quite like it handles "non-discrete" data. All we have to do is empirically estimate normal distribution parameters, and it can be perfectly done for discr
Anomaly Detection with Dummy Features (and other Discrete/Categorical Features) Andrew Ng class math handles "discrete" data quite like it handles "non-discrete" data. All we have to do is empirically estimate normal distribution parameters, and it can be perfectly done for discrete data. If you think about it, machine learning always deals with discrete data anyways: the number of data points is not infinite and the number of bits handled by computers is not infinite. If discrete data points can be compared between each other then there is no fundamental difference for machine learning methods when dealing with, say, length: 1.15 ft 1.34 ft 3.4 ft or how many branches are on the tree: 1 2 3 5 You can sum and average floating point or whole numbers just the same. Now, to categorical data. Categorical data points cannot be compared {car vs motorcycle vs boat). How do we handle this? The number of categories has to be at least two to make sense, otherwise what's the point in constant feature? In case of 2 categories, we can represent a category feature as a binary feature {0, 1}. 0 and 1 can be used for math, so see above. If number of categories (K) is [3.. inf], we map our single feature to K binary mutually exclusive features . For example, "motorcycle" category becomes a combination of binary features { IsCar: 0, IsMotorcycle: 1, IsBoat: 0}, Boat point becomes { IsCar: 0, IsMotorcycle: 0, IsBoat: 1} and so on. We can estimate empirical distribution parameters from these new features. We will simply have more dimensions, that's all.
Anomaly Detection with Dummy Features (and other Discrete/Categorical Features) Andrew Ng class math handles "discrete" data quite like it handles "non-discrete" data. All we have to do is empirically estimate normal distribution parameters, and it can be perfectly done for discr
15,046
What's the forward stagewise regression algorithm?
They authors do a poor job of explaining the algorithm in their book. If you look at equations 1.6 and 1.7 in their paper, it becomes clearer. The paper has a slightly different formulation (it builds the residual rather than the coefficient vector), but the key point is that it reaches a least squares fit very in very small steps (this is why the book mentions the algorithm can take "many more than p steps" to finish). You could either replace "regress(...)" with some small number, or you could multiply it by something like 0.05. Play around with it and see what works. Also, your threshold seems small. r'*X is going to give numbers proportional to but much larger than the actual correlations (e.g. for the diabetes data in the paper the correlations are ~70-900).
What's the forward stagewise regression algorithm?
They authors do a poor job of explaining the algorithm in their book. If you look at equations 1.6 and 1.7 in their paper, it becomes clearer. The paper has a slightly different formulation (it buil
What's the forward stagewise regression algorithm? They authors do a poor job of explaining the algorithm in their book. If you look at equations 1.6 and 1.7 in their paper, it becomes clearer. The paper has a slightly different formulation (it builds the residual rather than the coefficient vector), but the key point is that it reaches a least squares fit very in very small steps (this is why the book mentions the algorithm can take "many more than p steps" to finish). You could either replace "regress(...)" with some small number, or you could multiply it by something like 0.05. Play around with it and see what works. Also, your threshold seems small. r'*X is going to give numbers proportional to but much larger than the actual correlations (e.g. for the diabetes data in the paper the correlations are ~70-900).
What's the forward stagewise regression algorithm? They authors do a poor job of explaining the algorithm in their book. If you look at equations 1.6 and 1.7 in their paper, it becomes clearer. The paper has a slightly different formulation (it buil
15,047
Metropolis-Hastings algorithms used in practice
Hybrid Monte Carlo is the standard algorithm used for neural networks. Gibbs sampling for Gaussian process classification (when not using a deterministic approximation instead).
Metropolis-Hastings algorithms used in practice
Hybrid Monte Carlo is the standard algorithm used for neural networks. Gibbs sampling for Gaussian process classification (when not using a deterministic approximation instead).
Metropolis-Hastings algorithms used in practice Hybrid Monte Carlo is the standard algorithm used for neural networks. Gibbs sampling for Gaussian process classification (when not using a deterministic approximation instead).
Metropolis-Hastings algorithms used in practice Hybrid Monte Carlo is the standard algorithm used for neural networks. Gibbs sampling for Gaussian process classification (when not using a deterministic approximation instead).
15,048
Metropolis-Hastings algorithms used in practice
MH sampling is used when it's difficult to sample from the target distribution (e.g., when the prior isn't conjugate to the likelihood). So you use a proposal distribution to generate samples and accept/reject them based on the acceptance probability. The Gibbs sampling algorithm is a particular instance of MH where the proposals are always accepted. Gibbs sampling is one of the most commonly used algorithm due to its simplicity but it may not always to possible to apply, in which case one resorts to MH based on accept/reject proposals.
Metropolis-Hastings algorithms used in practice
MH sampling is used when it's difficult to sample from the target distribution (e.g., when the prior isn't conjugate to the likelihood). So you use a proposal distribution to generate samples and acce
Metropolis-Hastings algorithms used in practice MH sampling is used when it's difficult to sample from the target distribution (e.g., when the prior isn't conjugate to the likelihood). So you use a proposal distribution to generate samples and accept/reject them based on the acceptance probability. The Gibbs sampling algorithm is a particular instance of MH where the proposals are always accepted. Gibbs sampling is one of the most commonly used algorithm due to its simplicity but it may not always to possible to apply, in which case one resorts to MH based on accept/reject proposals.
Metropolis-Hastings algorithms used in practice MH sampling is used when it's difficult to sample from the target distribution (e.g., when the prior isn't conjugate to the likelihood). So you use a proposal distribution to generate samples and acce
15,049
Metropolis-Hastings algorithms used in practice
In physics, statistical physics in particular, Metropolis-type algorithm(s) are used extensively. There are really countless variants of these, and the new ones are being actively developed. It's much too broad topic to give any sort of expanation here, so if you're interested you can start e.g. from these lecture notes or from the ALPS library webpage (http://alps.comp-phys.org/mediawiki).
Metropolis-Hastings algorithms used in practice
In physics, statistical physics in particular, Metropolis-type algorithm(s) are used extensively. There are really countless variants of these, and the new ones are being actively developed. It's much
Metropolis-Hastings algorithms used in practice In physics, statistical physics in particular, Metropolis-type algorithm(s) are used extensively. There are really countless variants of these, and the new ones are being actively developed. It's much too broad topic to give any sort of expanation here, so if you're interested you can start e.g. from these lecture notes or from the ALPS library webpage (http://alps.comp-phys.org/mediawiki).
Metropolis-Hastings algorithms used in practice In physics, statistical physics in particular, Metropolis-type algorithm(s) are used extensively. There are really countless variants of these, and the new ones are being actively developed. It's much
15,050
Metropolis-Hastings algorithms used in practice
I use a slice sampler - originally proposed by Neal(2003), which I tune through heuristic optimization.
Metropolis-Hastings algorithms used in practice
I use a slice sampler - originally proposed by Neal(2003), which I tune through heuristic optimization.
Metropolis-Hastings algorithms used in practice I use a slice sampler - originally proposed by Neal(2003), which I tune through heuristic optimization.
Metropolis-Hastings algorithms used in practice I use a slice sampler - originally proposed by Neal(2003), which I tune through heuristic optimization.
15,051
Independence of residuals in a computer-based experiment/simulation?
You are essentially doing some form of cross-validation here for each of your m methods and would then like to see which method performed better. The results between runs will definitely be dependent, since they are based on the same data and you have overlap between your train/test sets. The question is whether this should matter when you come to compare the methods. Let's say you would perform only one run, and would find that one method is better than the others. You would then ask yourself - is this simply due to the specific choice of test set? This is why you repeat your test for many different train/test sets. So, in order to determine that a method is better than other methods, you run many times and in each run compare it to the other methods (you have different options of looking at the error/rank/etc). Now, if you find that a method does better on most runs, the result is what it is. I am not sure it is helpful to give a p-value to this. Or, if you do want to give a p-value, ask yourself what is the background model here?
Independence of residuals in a computer-based experiment/simulation?
You are essentially doing some form of cross-validation here for each of your m methods and would then like to see which method performed better. The results between runs will definitely be dependent,
Independence of residuals in a computer-based experiment/simulation? You are essentially doing some form of cross-validation here for each of your m methods and would then like to see which method performed better. The results between runs will definitely be dependent, since they are based on the same data and you have overlap between your train/test sets. The question is whether this should matter when you come to compare the methods. Let's say you would perform only one run, and would find that one method is better than the others. You would then ask yourself - is this simply due to the specific choice of test set? This is why you repeat your test for many different train/test sets. So, in order to determine that a method is better than other methods, you run many times and in each run compare it to the other methods (you have different options of looking at the error/rank/etc). Now, if you find that a method does better on most runs, the result is what it is. I am not sure it is helpful to give a p-value to this. Or, if you do want to give a p-value, ask yourself what is the background model here?
Independence of residuals in a computer-based experiment/simulation? You are essentially doing some form of cross-validation here for each of your m methods and would then like to see which method performed better. The results between runs will definitely be dependent,
15,052
Independence of residuals in a computer-based experiment/simulation?
May not really understand what you have done but for Run I am assuming that the RMSEP values for that run are correlated to some degree Yes, that reflects how challenging the test set was in that run but are uncorrelated between runs No, given the way you have sampled the test sets some will be more overlapped than others (most definitely not independent replications) You would somehow have to model the dependency based on the overlap or design the assessment so the runs are independent. I would read the stats literature on cross-validation ;-)
Independence of residuals in a computer-based experiment/simulation?
May not really understand what you have done but for Run I am assuming that the RMSEP values for that run are correlated to some degree Yes, that reflects how challenging the test set was in that r
Independence of residuals in a computer-based experiment/simulation? May not really understand what you have done but for Run I am assuming that the RMSEP values for that run are correlated to some degree Yes, that reflects how challenging the test set was in that run but are uncorrelated between runs No, given the way you have sampled the test sets some will be more overlapped than others (most definitely not independent replications) You would somehow have to model the dependency based on the overlap or design the assessment so the runs are independent. I would read the stats literature on cross-validation ;-)
Independence of residuals in a computer-based experiment/simulation? May not really understand what you have done but for Run I am assuming that the RMSEP values for that run are correlated to some degree Yes, that reflects how challenging the test set was in that r
15,053
Multivariant time series in R. How to find lagged correlation and build model for forecasting
You need to use your ACF & PACF behaviours to help you determine which model suits your data better (e.g. an existence of slow decay in ACF plot indicates that differencing might be needed to make the series more stabilized. Your ACF plot obviously shows that some sort of transformation is needed. The fluctuation has to be less varied and within the blue lines if you use the right transformation (stationary series). Once you made your series stationary, think about which model AR, MA, ARMA, or ARIMA is appropriate. In my project I did the following to help in model selection: The ACF plot shows a relatively large value at lag 2 (see where this is in your plot). Apart from that it becomes essentially zero at lags greater than two. This suggests that a MA(2) model may fit the data and then by looking at the PACF plot we immediately notice that the correlation is zero almost at all lags. This may suggest that the model does not have any AR part on it (adjust this to your plot). Therefore, one of our candidate models could be an ARIMA (p, d, q) with parameters p=0, d=1, and q=1 or2. I also tried some higher orders of MA and considered some possibility for having an AR part in the model in order to compare the results from AIC, AICc, and BIC and decide on the final model. next step you'll need to run some diagnostic tests to make sure you've chosen the correct model and there is no pattern in your residuals (ACF & PACF for residuals, p-value for Ljung-Box statistic, histyogram for residuals, and Q-Q plot). Hope it helps!
Multivariant time series in R. How to find lagged correlation and build model for forecasting
You need to use your ACF & PACF behaviours to help you determine which model suits your data better (e.g. an existence of slow decay in ACF plot indicates that differencing might be needed to make the
Multivariant time series in R. How to find lagged correlation and build model for forecasting You need to use your ACF & PACF behaviours to help you determine which model suits your data better (e.g. an existence of slow decay in ACF plot indicates that differencing might be needed to make the series more stabilized. Your ACF plot obviously shows that some sort of transformation is needed. The fluctuation has to be less varied and within the blue lines if you use the right transformation (stationary series). Once you made your series stationary, think about which model AR, MA, ARMA, or ARIMA is appropriate. In my project I did the following to help in model selection: The ACF plot shows a relatively large value at lag 2 (see where this is in your plot). Apart from that it becomes essentially zero at lags greater than two. This suggests that a MA(2) model may fit the data and then by looking at the PACF plot we immediately notice that the correlation is zero almost at all lags. This may suggest that the model does not have any AR part on it (adjust this to your plot). Therefore, one of our candidate models could be an ARIMA (p, d, q) with parameters p=0, d=1, and q=1 or2. I also tried some higher orders of MA and considered some possibility for having an AR part in the model in order to compare the results from AIC, AICc, and BIC and decide on the final model. next step you'll need to run some diagnostic tests to make sure you've chosen the correct model and there is no pattern in your residuals (ACF & PACF for residuals, p-value for Ljung-Box statistic, histyogram for residuals, and Q-Q plot). Hope it helps!
Multivariant time series in R. How to find lagged correlation and build model for forecasting You need to use your ACF & PACF behaviours to help you determine which model suits your data better (e.g. an existence of slow decay in ACF plot indicates that differencing might be needed to make the
15,054
Updating classification probability in logistic regression through time
You can't get there from here. You need to start with a different model. I would keep the weekly snapshots and build a stochastic model around transitions in each student's state variable. Suppose there are 10 weeks, which gives 11 "decision'' points, $t_0, t_1, \ldots, t_n$. The state at $t_i$ is $(Z_i,S_i)$, where $Z_i$ is 1 or 0, according as the student is enrolled or not; and $S_i$ is the score at that point (the sum of test and homework scores to date). Initial values are $(1,0)$. You have two transitions to worry about: $Prob(z_i=0|s_{i-1})$ and the distribution of $S_i$. The dropout probabilities are not stationary, since you will get a binge of dropouts just before the final drop-without-penalty date. But you can estimate these from past data.You can also estimate the probability of dropping out as a function of current (dismal) performance. The $S$ scores are a random walk on a binomial outcome (number of correct answers on a test of $n$ items, say). You can probably assume conditional independence -- assume a latent "talent" parameter for each student, and conditional on that value, each new score is independent of current performance. You could test this assumption against your historical data ... do failing students change their study habits and pull off a win? But most students behave true to form ... so a conditionally independent model should work OK. So basically, a student fails if a $Z$ score transitions to 0, or the $S$ score fails to cross the 70\% pass threshold. Let's look more closely at the $S$ process. To simplify the model, assume that evaluation involves obtaining 70 points or more from a total of 100 possible points, obtained from 10 test items each week. At baseline, a student's pass probability is simply the pass rate of the previous class. At time 1, the student has earned $S_1$ points (or dropped out). He passes if he can earn at least $70-S_1$ points out of 90. this is a binomial problem, which I can easily calculate if I know the student's probability of success. This will no longer be the "class average"; I need to adjust in light of the student's success thus far. I would use a table from past experience for this, but you could do a weighted average of the overall class success rate and the student's personal success. Bayes' Rule should help here. As a bonus, you can calculate a range of probabilities, which should narrow as the term progresses. In fact, strong students will cross the 70\% mark before the end of term, and their success will be certain at that point. For weak students, failure will also become certain before the end. RE: question 3. Should you go to continuous time? I wouldn't, because that puts one in the realm of continuous time stochastic processes and the math involved is above my pay grade. Not only that, you are unlikely to get a substantially different outcome. The best way to upgrade the model I have outlined is not to go to continuous time, but to adjust the transition probabilities on the basis of prior experience. Perhaps weak students fall further behind than an independence model would predict. Incorporating inhomegeneity would improve the model more than going from discrete to continuous time.
Updating classification probability in logistic regression through time
You can't get there from here. You need to start with a different model. I would keep the weekly snapshots and build a stochastic model around transitions in each student's state variable. Suppose the
Updating classification probability in logistic regression through time You can't get there from here. You need to start with a different model. I would keep the weekly snapshots and build a stochastic model around transitions in each student's state variable. Suppose there are 10 weeks, which gives 11 "decision'' points, $t_0, t_1, \ldots, t_n$. The state at $t_i$ is $(Z_i,S_i)$, where $Z_i$ is 1 or 0, according as the student is enrolled or not; and $S_i$ is the score at that point (the sum of test and homework scores to date). Initial values are $(1,0)$. You have two transitions to worry about: $Prob(z_i=0|s_{i-1})$ and the distribution of $S_i$. The dropout probabilities are not stationary, since you will get a binge of dropouts just before the final drop-without-penalty date. But you can estimate these from past data.You can also estimate the probability of dropping out as a function of current (dismal) performance. The $S$ scores are a random walk on a binomial outcome (number of correct answers on a test of $n$ items, say). You can probably assume conditional independence -- assume a latent "talent" parameter for each student, and conditional on that value, each new score is independent of current performance. You could test this assumption against your historical data ... do failing students change their study habits and pull off a win? But most students behave true to form ... so a conditionally independent model should work OK. So basically, a student fails if a $Z$ score transitions to 0, or the $S$ score fails to cross the 70\% pass threshold. Let's look more closely at the $S$ process. To simplify the model, assume that evaluation involves obtaining 70 points or more from a total of 100 possible points, obtained from 10 test items each week. At baseline, a student's pass probability is simply the pass rate of the previous class. At time 1, the student has earned $S_1$ points (or dropped out). He passes if he can earn at least $70-S_1$ points out of 90. this is a binomial problem, which I can easily calculate if I know the student's probability of success. This will no longer be the "class average"; I need to adjust in light of the student's success thus far. I would use a table from past experience for this, but you could do a weighted average of the overall class success rate and the student's personal success. Bayes' Rule should help here. As a bonus, you can calculate a range of probabilities, which should narrow as the term progresses. In fact, strong students will cross the 70\% mark before the end of term, and their success will be certain at that point. For weak students, failure will also become certain before the end. RE: question 3. Should you go to continuous time? I wouldn't, because that puts one in the realm of continuous time stochastic processes and the math involved is above my pay grade. Not only that, you are unlikely to get a substantially different outcome. The best way to upgrade the model I have outlined is not to go to continuous time, but to adjust the transition probabilities on the basis of prior experience. Perhaps weak students fall further behind than an independence model would predict. Incorporating inhomegeneity would improve the model more than going from discrete to continuous time.
Updating classification probability in logistic regression through time You can't get there from here. You need to start with a different model. I would keep the weekly snapshots and build a stochastic model around transitions in each student's state variable. Suppose the
15,055
Updating classification probability in logistic regression through time
When I train predictive models for a similar type of deployment, I make sure my datasets have some sort of Term_End_Date so I can derrive the length of time left until the term ends. This will probably end up being a significant predictor in your model. Regarding the question of correlated observations, I suppose it matters how big of a repository of data that you have. If possible, I would randomly select 1 observation for each student, stratified on [# of weeks until Term End]. I would also grab from older terms, if possible. If you don't have enough data to do that, maybe you can try a re-sampling method like bootstrap. I think the most important thing if you have a small dataset is keeping enough data as a holdout to make sure your final model is stable. I think when you're all done, and you have a scoring formula, it'll be pretty easy to implement. But yes, you should still be plugging in the weekly x variables that you'll need to calculate the score - but this sounds more like a data collection issue and less about model implementation.
Updating classification probability in logistic regression through time
When I train predictive models for a similar type of deployment, I make sure my datasets have some sort of Term_End_Date so I can derrive the length of time left until the term ends. This will probabl
Updating classification probability in logistic regression through time When I train predictive models for a similar type of deployment, I make sure my datasets have some sort of Term_End_Date so I can derrive the length of time left until the term ends. This will probably end up being a significant predictor in your model. Regarding the question of correlated observations, I suppose it matters how big of a repository of data that you have. If possible, I would randomly select 1 observation for each student, stratified on [# of weeks until Term End]. I would also grab from older terms, if possible. If you don't have enough data to do that, maybe you can try a re-sampling method like bootstrap. I think the most important thing if you have a small dataset is keeping enough data as a holdout to make sure your final model is stable. I think when you're all done, and you have a scoring formula, it'll be pretty easy to implement. But yes, you should still be plugging in the weekly x variables that you'll need to calculate the score - but this sounds more like a data collection issue and less about model implementation.
Updating classification probability in logistic regression through time When I train predictive models for a similar type of deployment, I make sure my datasets have some sort of Term_End_Date so I can derrive the length of time left until the term ends. This will probabl
15,056
Distribution of $\frac{\sum_{i=1}^n X_iY_i}{\sum_{i=1}^n X_i^2}$ where $X_i,Y_i$s are i.i.d Normal variables
Although this is a conditional argument as well, using the characteristic function is faster: \begin{align*} \mathbb E\left[\exp\left\{ \iota t\sum_i Y_i X_i\Big/{\sum_j X_j^2}\right\}\right] &= \mathbb E\left[\left.\mathbb E\left[\exp\left\{\iota t Y_i X_i\Big/{\sum_j X_j^2}\right\}\right]\,\right|\,\mathbf X \right]\\ &=\mathbb E\left[\left.\mathbb E\left[\prod_i \exp\left\{\iota t Y_i X_i\Big/{\sum_j X_j^2}\right\}\right]\,\right|\,\mathbf X \right]\\ &=\mathbb E\left[\prod_i\left.\mathbb E\left[ \exp\left\{ t Y_i X_i\Big/{\sum_j X_j^2}\right\}\right]\,\right|\,\mathbf X\iota \right]\\ &=\mathbb E\left[\prod_i \exp\left\{- t^2 X_i^2 \Big/2\left\{\sum_j X_j^2\right\}^2\right\}\right]\\ &=\mathbb E\left[ \exp\left\{- t^2 \Big/2{\sum_j X_j^2}\right\}\right]\\ \end{align*} Invoking Wolfram's integrator, this expectation is equal to $$\int_0^∞ \zeta^{n/2 - 1} \frac{\exp(-\zeta - t^2/\zeta)}{Γ(n/2)}\ \text{d}\,\zeta = \frac{2 t^{n/2} K_{-n/2}(2 t)}{Γ(n/2)}$$ where $K_n$ is the modified Bessel function of the second kind. Hence, except for $n=1$ this is not the characteristic function of the Cauchy distribution. This looks instead like the characteristic function of the Student's $t$ distribution.
Distribution of $\frac{\sum_{i=1}^n X_iY_i}{\sum_{i=1}^n X_i^2}$ where $X_i,Y_i$s are i.i.d Normal v
Although this is a conditional argument as well, using the characteristic function is faster: \begin{align*} \mathbb E\left[\exp\left\{ \iota t\sum_i Y_i X_i\Big/{\sum_j X_j^2}\right\}\right] &= \math
Distribution of $\frac{\sum_{i=1}^n X_iY_i}{\sum_{i=1}^n X_i^2}$ where $X_i,Y_i$s are i.i.d Normal variables Although this is a conditional argument as well, using the characteristic function is faster: \begin{align*} \mathbb E\left[\exp\left\{ \iota t\sum_i Y_i X_i\Big/{\sum_j X_j^2}\right\}\right] &= \mathbb E\left[\left.\mathbb E\left[\exp\left\{\iota t Y_i X_i\Big/{\sum_j X_j^2}\right\}\right]\,\right|\,\mathbf X \right]\\ &=\mathbb E\left[\left.\mathbb E\left[\prod_i \exp\left\{\iota t Y_i X_i\Big/{\sum_j X_j^2}\right\}\right]\,\right|\,\mathbf X \right]\\ &=\mathbb E\left[\prod_i\left.\mathbb E\left[ \exp\left\{ t Y_i X_i\Big/{\sum_j X_j^2}\right\}\right]\,\right|\,\mathbf X\iota \right]\\ &=\mathbb E\left[\prod_i \exp\left\{- t^2 X_i^2 \Big/2\left\{\sum_j X_j^2\right\}^2\right\}\right]\\ &=\mathbb E\left[ \exp\left\{- t^2 \Big/2{\sum_j X_j^2}\right\}\right]\\ \end{align*} Invoking Wolfram's integrator, this expectation is equal to $$\int_0^∞ \zeta^{n/2 - 1} \frac{\exp(-\zeta - t^2/\zeta)}{Γ(n/2)}\ \text{d}\,\zeta = \frac{2 t^{n/2} K_{-n/2}(2 t)}{Γ(n/2)}$$ where $K_n$ is the modified Bessel function of the second kind. Hence, except for $n=1$ this is not the characteristic function of the Cauchy distribution. This looks instead like the characteristic function of the Student's $t$ distribution.
Distribution of $\frac{\sum_{i=1}^n X_iY_i}{\sum_{i=1}^n X_i^2}$ where $X_i,Y_i$s are i.i.d Normal v Although this is a conditional argument as well, using the characteristic function is faster: \begin{align*} \mathbb E\left[\exp\left\{ \iota t\sum_i Y_i X_i\Big/{\sum_j X_j^2}\right\}\right] &= \math
15,057
Understanding Gaussian Process Regression via infinite dimensional basis function view
Here are a few remarks. Perhaps someone else can fill in the details. 1) Basis representations are always a good idea. It's hard to avoid them if you want to actually do something computational with your covariance function. The basis expansion can give you an approximation to the kernel and something to work with. The hope is that you can find a basis that makes sense for the problem you are trying to solve. 2) I'm not quite sure what you mean by a configuration in this question. At least one of the basis functions will need to be a function of $\theta$ for the kernel to depend on $\theta$. So yes, the eigenfunctions will vary with the parameter. They would also vary with different parametrizations. Typically, the number of basis functions will be (countably) infinite, so the number won't vary with the parameter, unless some values caused the kernel to become degenerate. I also don't understand what you mean in point 2 about the process having Bayesian prior $w \sim \mathcal{N}(0,diag[\lambda_1^2, \ldots])$ since $w$ has not been mentioned up until this point. Also,$diag[\lambda_1^2, \ldots]$ seems to be an infinite dimensional matrix, and I have a problem with that. 3) Which set of basis functions form valid kernels? If you're thinking about an eigenbasis, then the functions need to be orthogonal with respect to some measure. There are two problems. 1) The resulting kernel has to be positive definite ... and that's OK if the $\lambda_i$ are positive. And 2) the expansion has to converge. This will depend on the $\lambda_i$, which need to dampen fast enough to ensure the convergence of the expression. Convergence will also depend on the domain of the $x$'s If the basis functions are not orthogonal then it will be more difficult to show that a covariance defined from them is positive definite. Obviously, in that case you are not dealing with an eigen-expansion, but with some other way of approximating the function of interest. However, I don't think people typically start from a bunch of functions and then try to build a covariance kernel from them. RE: Differentiability of the kernel and differentiability of the basis functions. I don't actually know the answer to this question, but I would offer the following observation. Functional analysis proceeds by approximating functions (from an infinite dimensional space) by finite sums of simpler functions. To make this work, everything depends on the type of convergence involved. Typically, if you are working on a compact set with strong convergence properties (uniform convergence or absolute summability) on the functions of interest, then you get the kind of intuitive result that you are looking for: the properties of the simple functions pass over to the limit function -- e.g. if the kernel is a differentiable function of a parameter, then the expansion functions must be differentiable functions of the same parameter, and vice-versa. Under weaker convergence properties or non-compact domains, this does not happen. In my experience, there's a counter-example to every "reasonable" idea one comes up with. Note: To forestall possible confusion from readers of this question, note that the Gaussian expansion of point 1 is not an example of the eigen-expansion of point 2.
Understanding Gaussian Process Regression via infinite dimensional basis function view
Here are a few remarks. Perhaps someone else can fill in the details. 1) Basis representations are always a good idea. It's hard to avoid them if you want to actually do something computational with y
Understanding Gaussian Process Regression via infinite dimensional basis function view Here are a few remarks. Perhaps someone else can fill in the details. 1) Basis representations are always a good idea. It's hard to avoid them if you want to actually do something computational with your covariance function. The basis expansion can give you an approximation to the kernel and something to work with. The hope is that you can find a basis that makes sense for the problem you are trying to solve. 2) I'm not quite sure what you mean by a configuration in this question. At least one of the basis functions will need to be a function of $\theta$ for the kernel to depend on $\theta$. So yes, the eigenfunctions will vary with the parameter. They would also vary with different parametrizations. Typically, the number of basis functions will be (countably) infinite, so the number won't vary with the parameter, unless some values caused the kernel to become degenerate. I also don't understand what you mean in point 2 about the process having Bayesian prior $w \sim \mathcal{N}(0,diag[\lambda_1^2, \ldots])$ since $w$ has not been mentioned up until this point. Also,$diag[\lambda_1^2, \ldots]$ seems to be an infinite dimensional matrix, and I have a problem with that. 3) Which set of basis functions form valid kernels? If you're thinking about an eigenbasis, then the functions need to be orthogonal with respect to some measure. There are two problems. 1) The resulting kernel has to be positive definite ... and that's OK if the $\lambda_i$ are positive. And 2) the expansion has to converge. This will depend on the $\lambda_i$, which need to dampen fast enough to ensure the convergence of the expression. Convergence will also depend on the domain of the $x$'s If the basis functions are not orthogonal then it will be more difficult to show that a covariance defined from them is positive definite. Obviously, in that case you are not dealing with an eigen-expansion, but with some other way of approximating the function of interest. However, I don't think people typically start from a bunch of functions and then try to build a covariance kernel from them. RE: Differentiability of the kernel and differentiability of the basis functions. I don't actually know the answer to this question, but I would offer the following observation. Functional analysis proceeds by approximating functions (from an infinite dimensional space) by finite sums of simpler functions. To make this work, everything depends on the type of convergence involved. Typically, if you are working on a compact set with strong convergence properties (uniform convergence or absolute summability) on the functions of interest, then you get the kind of intuitive result that you are looking for: the properties of the simple functions pass over to the limit function -- e.g. if the kernel is a differentiable function of a parameter, then the expansion functions must be differentiable functions of the same parameter, and vice-versa. Under weaker convergence properties or non-compact domains, this does not happen. In my experience, there's a counter-example to every "reasonable" idea one comes up with. Note: To forestall possible confusion from readers of this question, note that the Gaussian expansion of point 1 is not an example of the eigen-expansion of point 2.
Understanding Gaussian Process Regression via infinite dimensional basis function view Here are a few remarks. Perhaps someone else can fill in the details. 1) Basis representations are always a good idea. It's hard to avoid them if you want to actually do something computational with y
15,058
Are neural networks consistent estimators?
Some details must be defined before the question can be answered. There are different sorts of neuron and network connections, and these need specifying. There are also different measures of how well a learnt function approximates the function to be learned. The universal approximation theorem assumes compact support, so probably this should be specified in the question. Neural nets do not extrapolate. For example, RELUs are asymptotically linear so a RELU network, however well it approximates the objective function within the support of the training set, can only learn a function that is asymptotically linear. There are also different training algorithms - the answer must be dependent on which is chosen.
Are neural networks consistent estimators?
Some details must be defined before the question can be answered. There are different sorts of neuron and network connections, and these need specifying. There are also different measures of how well
Are neural networks consistent estimators? Some details must be defined before the question can be answered. There are different sorts of neuron and network connections, and these need specifying. There are also different measures of how well a learnt function approximates the function to be learned. The universal approximation theorem assumes compact support, so probably this should be specified in the question. Neural nets do not extrapolate. For example, RELUs are asymptotically linear so a RELU network, however well it approximates the objective function within the support of the training set, can only learn a function that is asymptotically linear. There are also different training algorithms - the answer must be dependent on which is chosen.
Are neural networks consistent estimators? Some details must be defined before the question can be answered. There are different sorts of neuron and network connections, and these need specifying. There are also different measures of how well
15,059
Are neural networks consistent estimators?
TL;DR SGD works great on some problems because the problems it works great on possess significant symmetry, redundancy and smoothness. For such problems a greedy general-purpose algorithm exists, that finds a global or almost global minimum given finite noisy data and relatively small number of iterations. But, of course, general optimization problems are not solvable by greedy strategies. Answer: I suspect that for a practically-useful consistency requirement you will always be able to find a counter-example where the theory fails. The true complexity of the function can be infinite-dimensional or at least very large. You could in general have a tabulated mapping $x \rightarrow y$ where $y$ are pre-defined random numbers. SGD relies on the idea that "natural" functions are at least to some extent smooth. SGD is completely useless in trying to find the minimum of an "unnatural" function such as Weierstrass function or a large class of chaotic functions. Again, no proof, but it is not hard to imagine a problem class where no general algorithm except of brute-force search exists. The problems in 1,2 could be alleviated by restricting the smoothness of the function and enforcing a compact domain, thus ensuring that there is only a finite number of local minima regions. While this certainly is not true for all problems of practical relevance, it is true for some, and it simplifies the problem significantly. Given a smoothness constraint we can guarantee that local minima regions are at least a certain minimal distance apart, so we could guarantee a global minimum via GD + Grid Search. But Grid Search is practically unfeasible due to curse of dimensionality. SGD is to some extent similar to simulated annealing: It theoretically has a chance to visit the whole compact domain via random chance, but depending on initial conditions and parameter choices the chances of visiting the basin of attraction of the global minimum can be arbitrarily low. If no good prior for initial condition exists, it may be required to randomly reset the initial condition after a certain number of iterations. This would guarantee that the basin of attraction of the global minimum is eventually visited, but it need not work better than grid search.
Are neural networks consistent estimators?
TL;DR SGD works great on some problems because the problems it works great on possess significant symmetry, redundancy and smoothness. For such problems a greedy general-purpose algorithm exists, that
Are neural networks consistent estimators? TL;DR SGD works great on some problems because the problems it works great on possess significant symmetry, redundancy and smoothness. For such problems a greedy general-purpose algorithm exists, that finds a global or almost global minimum given finite noisy data and relatively small number of iterations. But, of course, general optimization problems are not solvable by greedy strategies. Answer: I suspect that for a practically-useful consistency requirement you will always be able to find a counter-example where the theory fails. The true complexity of the function can be infinite-dimensional or at least very large. You could in general have a tabulated mapping $x \rightarrow y$ where $y$ are pre-defined random numbers. SGD relies on the idea that "natural" functions are at least to some extent smooth. SGD is completely useless in trying to find the minimum of an "unnatural" function such as Weierstrass function or a large class of chaotic functions. Again, no proof, but it is not hard to imagine a problem class where no general algorithm except of brute-force search exists. The problems in 1,2 could be alleviated by restricting the smoothness of the function and enforcing a compact domain, thus ensuring that there is only a finite number of local minima regions. While this certainly is not true for all problems of practical relevance, it is true for some, and it simplifies the problem significantly. Given a smoothness constraint we can guarantee that local minima regions are at least a certain minimal distance apart, so we could guarantee a global minimum via GD + Grid Search. But Grid Search is practically unfeasible due to curse of dimensionality. SGD is to some extent similar to simulated annealing: It theoretically has a chance to visit the whole compact domain via random chance, but depending on initial conditions and parameter choices the chances of visiting the basin of attraction of the global minimum can be arbitrarily low. If no good prior for initial condition exists, it may be required to randomly reset the initial condition after a certain number of iterations. This would guarantee that the basin of attraction of the global minimum is eventually visited, but it need not work better than grid search.
Are neural networks consistent estimators? TL;DR SGD works great on some problems because the problems it works great on possess significant symmetry, redundancy and smoothness. For such problems a greedy general-purpose algorithm exists, that
15,060
Is bootstrap problematic in small samples?
My short answer would be: Yes, if samples are very small, this can definitely be a problem since the sample may not contain enough information to get a good estimate of the desired population parameter. This problem affects all statistical methods, not just the bootstrap. The good news, however, is that ‘small’ may be smaller than most people (with knowledge about asymptotic behavior and the Central Limit Theorem) would intuitively assume. Here, of cause, I’m referring to the normal (naive) bootstrap without dependent data or other peculiarities. According to Michael Chernick, the author of ‘Bootstrap Methods: A guide for Practitioners and Researchers’, small may be as small as N=4. But this number of distinct bootstrap samples gets large very quickly. So this is not an issue even for sample sizes as small as 8. For reference, see Chernick's great answer to a very similar question: Determining sample size necessary for bootstrap method / Proposed Method Of cause the suggested sample sizes are subject to uncertainty and no universal threshold for a minimum sample size can be specified. Chernick therefore suggests to increase the sample size and study the convergence behavior. I believe is a very reasonable approach. Here’s another quote from the same answer, which somehow addresses the premise you quoted initially: Whether or not the bootstrap principle holds does not depend on any individual sample "looking representative of the population". What it does depend on is what you are estimating and some properties of the population distribution (e.g., this works for sampling means with population distributions that have finite variances, but not when they have infinite variances). It will not work for estimating extremes regardless of the population distribution.
Is bootstrap problematic in small samples?
My short answer would be: Yes, if samples are very small, this can definitely be a problem since the sample may not contain enough information to get a good estimate of the desired population paramete
Is bootstrap problematic in small samples? My short answer would be: Yes, if samples are very small, this can definitely be a problem since the sample may not contain enough information to get a good estimate of the desired population parameter. This problem affects all statistical methods, not just the bootstrap. The good news, however, is that ‘small’ may be smaller than most people (with knowledge about asymptotic behavior and the Central Limit Theorem) would intuitively assume. Here, of cause, I’m referring to the normal (naive) bootstrap without dependent data or other peculiarities. According to Michael Chernick, the author of ‘Bootstrap Methods: A guide for Practitioners and Researchers’, small may be as small as N=4. But this number of distinct bootstrap samples gets large very quickly. So this is not an issue even for sample sizes as small as 8. For reference, see Chernick's great answer to a very similar question: Determining sample size necessary for bootstrap method / Proposed Method Of cause the suggested sample sizes are subject to uncertainty and no universal threshold for a minimum sample size can be specified. Chernick therefore suggests to increase the sample size and study the convergence behavior. I believe is a very reasonable approach. Here’s another quote from the same answer, which somehow addresses the premise you quoted initially: Whether or not the bootstrap principle holds does not depend on any individual sample "looking representative of the population". What it does depend on is what you are estimating and some properties of the population distribution (e.g., this works for sampling means with population distributions that have finite variances, but not when they have infinite variances). It will not work for estimating extremes regardless of the population distribution.
Is bootstrap problematic in small samples? My short answer would be: Yes, if samples are very small, this can definitely be a problem since the sample may not contain enough information to get a good estimate of the desired population paramete
15,061
Caret - Repeated K-fold cross-validation vs Nested K-fold cross validation, repeated n-times
There's nothing wrong with the (nested) algorithm presented, and in fact, it would likely perform well with decent robustness for the bias-variance problem on different data sets. You never said, however, that the reader should assume the features you were using are the most "optimal", so if that's unknown, there are some feature selection issues that must first be addressed. FEATURE/PARAMETER SELECTION A lesser biased approached is to never let the classifier/model come close to anything remotely related to feature/parameter selection, since you don't want the fox (classifier, model) to be the guard of the chickens (features, parameters). Your feature (parameter) selection method is a $wrapper$ - where feature selection is bundled inside iterative learning performed by the classifier/model. On the contrary, I always use a feature $filter$ that employs a different method which is far-removed from the classifier/model, as an attempt to minimize feature (parameter) selection bias. Look up wrapping vs filtering and selection bias during feature selection (G.J. McLachlan). There is always a major feature selection problem, for which the solution is to invoke a method of object partitioning (folds), in which the objects are partitioned in to different sets. For example, simulate a data matrix with 100 rows and 100 columns, and then simulate a binary variate (0,1) in another column -- call this the grouping variable. Next, run t-tests on each column using the binary (0,1) variable as the grouping variable. Several of the 100 t-tests will be significant by chance alone; however, as soon as you split the data matrix into two folds $\mathcal{D}_1$ and $\mathcal{D}_2$, each of which has $n=50$, the number of significant tests drops down. Until you can solve this problem with your data by determining the optimal number of folds to use during parameter selection, your results may be suspect. So you'll need to establish some sort of bootstrap-bias method for evaluating predictive accuracy on the hold-out objects as a function of varying sample sizes used in each training fold, e.g., $\pi=0.1n, 0.2n, 0,3n, 0.4n, 0.5n$ (that is, increasing sample sizes used during learning) combined with a varying number of CV folds used, e.g., 2, 5, 10, etc. OPTIMIZATION/MINIMIZATION You seem to really be solving an optimization or minimization problem for function approximation e.g., $y=f(x_1, x_2, \ldots, x_j)$, where e.g. regression or a predictive model with parameters is used and $y$ is continuously-scaled. Given this, and given the need to minimize bias in your predictions (selection bias, bias-variance, information leakage from testing objects into training objects, etc.) you might look into use of employing CV during use of swarm intelligence methods, such as particle swarm optimization(PSO), ant colony optimization, etc. PSO (see Kennedy & Eberhart, 1995) adds parameters for social and cultural information exchange among particles as they fly through the parameter space during learning. Once you become familiar with swarm intelligence methods, you'll see that you can overcome a lot of biases in parameter determination. Lastly, I don't know if there is a random forest (RF, see Breiman, Journ. of Machine Learning) approach for function approximation, but if there is, use of RF for function approximation would alleviate 95% of the issues you are facing.
Caret - Repeated K-fold cross-validation vs Nested K-fold cross validation, repeated n-times
There's nothing wrong with the (nested) algorithm presented, and in fact, it would likely perform well with decent robustness for the bias-variance problem on different data sets. You never said, how
Caret - Repeated K-fold cross-validation vs Nested K-fold cross validation, repeated n-times There's nothing wrong with the (nested) algorithm presented, and in fact, it would likely perform well with decent robustness for the bias-variance problem on different data sets. You never said, however, that the reader should assume the features you were using are the most "optimal", so if that's unknown, there are some feature selection issues that must first be addressed. FEATURE/PARAMETER SELECTION A lesser biased approached is to never let the classifier/model come close to anything remotely related to feature/parameter selection, since you don't want the fox (classifier, model) to be the guard of the chickens (features, parameters). Your feature (parameter) selection method is a $wrapper$ - where feature selection is bundled inside iterative learning performed by the classifier/model. On the contrary, I always use a feature $filter$ that employs a different method which is far-removed from the classifier/model, as an attempt to minimize feature (parameter) selection bias. Look up wrapping vs filtering and selection bias during feature selection (G.J. McLachlan). There is always a major feature selection problem, for which the solution is to invoke a method of object partitioning (folds), in which the objects are partitioned in to different sets. For example, simulate a data matrix with 100 rows and 100 columns, and then simulate a binary variate (0,1) in another column -- call this the grouping variable. Next, run t-tests on each column using the binary (0,1) variable as the grouping variable. Several of the 100 t-tests will be significant by chance alone; however, as soon as you split the data matrix into two folds $\mathcal{D}_1$ and $\mathcal{D}_2$, each of which has $n=50$, the number of significant tests drops down. Until you can solve this problem with your data by determining the optimal number of folds to use during parameter selection, your results may be suspect. So you'll need to establish some sort of bootstrap-bias method for evaluating predictive accuracy on the hold-out objects as a function of varying sample sizes used in each training fold, e.g., $\pi=0.1n, 0.2n, 0,3n, 0.4n, 0.5n$ (that is, increasing sample sizes used during learning) combined with a varying number of CV folds used, e.g., 2, 5, 10, etc. OPTIMIZATION/MINIMIZATION You seem to really be solving an optimization or minimization problem for function approximation e.g., $y=f(x_1, x_2, \ldots, x_j)$, where e.g. regression or a predictive model with parameters is used and $y$ is continuously-scaled. Given this, and given the need to minimize bias in your predictions (selection bias, bias-variance, information leakage from testing objects into training objects, etc.) you might look into use of employing CV during use of swarm intelligence methods, such as particle swarm optimization(PSO), ant colony optimization, etc. PSO (see Kennedy & Eberhart, 1995) adds parameters for social and cultural information exchange among particles as they fly through the parameter space during learning. Once you become familiar with swarm intelligence methods, you'll see that you can overcome a lot of biases in parameter determination. Lastly, I don't know if there is a random forest (RF, see Breiman, Journ. of Machine Learning) approach for function approximation, but if there is, use of RF for function approximation would alleviate 95% of the issues you are facing.
Caret - Repeated K-fold cross-validation vs Nested K-fold cross validation, repeated n-times There's nothing wrong with the (nested) algorithm presented, and in fact, it would likely perform well with decent robustness for the bias-variance problem on different data sets. You never said, how
15,062
Cheat Sheet ANOVA Alphabet Soup & Regression Equivalents
Nice list, Antoni. Here are some minor suggestions: One-Way ANOVA: IV is a FACTOR with 3 or more levels. You could also add an Example Data: mtcars to this entry. (Similarly, you could add *Example Data" statements to all of your entries, to make it clearer what data sets you are using.) Two-Way Anova: Why not use IV1 and IV2 and state that the two independent variables should be factors with at least two levels each? The way you have this stated currently suggests a two-way anova could include more than 2 independent variables (or factors), which is non-sensical. For Two-Way Anova, I would differentiate between these two sub-cases: 1. Two-Way Anova with Main Effects for IV1 and IV2 and 2. Two-Way Anova with an Interaction between IV1 and IV2. This second item is what you are referring two as a factorial two-way anova.) A better way of describing these two sub-cases would be: 1. Effect of IV1 on DV is independent of effect of IV2 and 2. Effect of IV1 on DV depends on IV2. You could also make it clearer that it is the independent variables IV1 and IV2 which are dummy coded in the regression setting. For ANCOVA, you could clarify that you are considering only one-way ANCOVA in your current example. For completeness, you could add a two-way ANCOVA example with no interactions between IV1 and IV2, and one with interaction between these two variables. For all of the above, you could also add an item called Purpose, which describes when these analyses are useful. For example: Purpose (of one-way anova): Investigate whether the mean values of the DV are different across levels of the IV. For MANOVA, can you clarify that one would need (a) two or more DVs and (2) one or more IVs which are factors? I guess you can differentiate between one-way MANOVA (with 1 factor) and two-way MANOVA? Same thing for MANCOVA. The WITHIN-FACTOR ANOVA is also known an REPEATED MEASURES ANOVA, so maybe you can add this terminology to your list for those who are familiar with it. It would also be helpful to clarify that mixed effects modeling provides an alternative way to modeling repeated measures data. Otherwise, readers might not appreciate the difference between the two approaches.
Cheat Sheet ANOVA Alphabet Soup & Regression Equivalents
Nice list, Antoni. Here are some minor suggestions: One-Way ANOVA: IV is a FACTOR with 3 or more levels. You could also add an Example Data: mtcars to this entry. (Similarly, you could add *Example Da
Cheat Sheet ANOVA Alphabet Soup & Regression Equivalents Nice list, Antoni. Here are some minor suggestions: One-Way ANOVA: IV is a FACTOR with 3 or more levels. You could also add an Example Data: mtcars to this entry. (Similarly, you could add *Example Data" statements to all of your entries, to make it clearer what data sets you are using.) Two-Way Anova: Why not use IV1 and IV2 and state that the two independent variables should be factors with at least two levels each? The way you have this stated currently suggests a two-way anova could include more than 2 independent variables (or factors), which is non-sensical. For Two-Way Anova, I would differentiate between these two sub-cases: 1. Two-Way Anova with Main Effects for IV1 and IV2 and 2. Two-Way Anova with an Interaction between IV1 and IV2. This second item is what you are referring two as a factorial two-way anova.) A better way of describing these two sub-cases would be: 1. Effect of IV1 on DV is independent of effect of IV2 and 2. Effect of IV1 on DV depends on IV2. You could also make it clearer that it is the independent variables IV1 and IV2 which are dummy coded in the regression setting. For ANCOVA, you could clarify that you are considering only one-way ANCOVA in your current example. For completeness, you could add a two-way ANCOVA example with no interactions between IV1 and IV2, and one with interaction between these two variables. For all of the above, you could also add an item called Purpose, which describes when these analyses are useful. For example: Purpose (of one-way anova): Investigate whether the mean values of the DV are different across levels of the IV. For MANOVA, can you clarify that one would need (a) two or more DVs and (2) one or more IVs which are factors? I guess you can differentiate between one-way MANOVA (with 1 factor) and two-way MANOVA? Same thing for MANCOVA. The WITHIN-FACTOR ANOVA is also known an REPEATED MEASURES ANOVA, so maybe you can add this terminology to your list for those who are familiar with it. It would also be helpful to clarify that mixed effects modeling provides an alternative way to modeling repeated measures data. Otherwise, readers might not appreciate the difference between the two approaches.
Cheat Sheet ANOVA Alphabet Soup & Regression Equivalents Nice list, Antoni. Here are some minor suggestions: One-Way ANOVA: IV is a FACTOR with 3 or more levels. You could also add an Example Data: mtcars to this entry. (Similarly, you could add *Example Da
15,063
Stability of cross-validation in Bayesian models
I don't know if this qualifies as a comment or as an answer. I'm putting here because it feels like an answer. In k-fold cross-validation you are partitioning your data into k groups. If you are covering even the "basics" then you are uniformly randomly selecting members for each of the k bins. When I speak of data, I think of each row as a sample, and each column as a dimension. I'm used to using various methods to determine variable importance, column importance. What if you, as a thought exercise, departed from the "textbook" uniform random, and determined which rows were important? Maybe they inform a single variable at a time, but maybe they inform more. Are there some rows that are less important than others? Maybe many of the points are informative, maybe few are. Knowing the importance of the variable, perhaps you could bin them by importance. Maybe you could make a single bin with the most important samples. This could define the size of your "k". In this way, you would be determining the "most informative" kth bucket and comparing it against others, and against the least informative bucket. This could give you an idea of the maximal variation of your model parameters. It is only one form. A second way of splitting the kth buckets is by the magnitude and the direction of the influence. So you could put samples that sway a parameter or parameters in one direction into one bucket and put samples that sway the same parameter or parameters in the opposite direction into a different bucket. The parameter variation in this form might give a wider sweep to the variables, based not on information density, but on information breed. Best of luck.
Stability of cross-validation in Bayesian models
I don't know if this qualifies as a comment or as an answer. I'm putting here because it feels like an answer. In k-fold cross-validation you are partitioning your data into k groups. If you are cov
Stability of cross-validation in Bayesian models I don't know if this qualifies as a comment or as an answer. I'm putting here because it feels like an answer. In k-fold cross-validation you are partitioning your data into k groups. If you are covering even the "basics" then you are uniformly randomly selecting members for each of the k bins. When I speak of data, I think of each row as a sample, and each column as a dimension. I'm used to using various methods to determine variable importance, column importance. What if you, as a thought exercise, departed from the "textbook" uniform random, and determined which rows were important? Maybe they inform a single variable at a time, but maybe they inform more. Are there some rows that are less important than others? Maybe many of the points are informative, maybe few are. Knowing the importance of the variable, perhaps you could bin them by importance. Maybe you could make a single bin with the most important samples. This could define the size of your "k". In this way, you would be determining the "most informative" kth bucket and comparing it against others, and against the least informative bucket. This could give you an idea of the maximal variation of your model parameters. It is only one form. A second way of splitting the kth buckets is by the magnitude and the direction of the influence. So you could put samples that sway a parameter or parameters in one direction into one bucket and put samples that sway the same parameter or parameters in the opposite direction into a different bucket. The parameter variation in this form might give a wider sweep to the variables, based not on information density, but on information breed. Best of luck.
Stability of cross-validation in Bayesian models I don't know if this qualifies as a comment or as an answer. I'm putting here because it feels like an answer. In k-fold cross-validation you are partitioning your data into k groups. If you are cov
15,064
Stability of cross-validation in Bayesian models
It may not be a complete answer, but if 0 is NOT in the 95% CI for several differences it is quite safe to say that they are not identical at a 0.05 level.
Stability of cross-validation in Bayesian models
It may not be a complete answer, but if 0 is NOT in the 95% CI for several differences it is quite safe to say that they are not identical at a 0.05 level.
Stability of cross-validation in Bayesian models It may not be a complete answer, but if 0 is NOT in the 95% CI for several differences it is quite safe to say that they are not identical at a 0.05 level.
Stability of cross-validation in Bayesian models It may not be a complete answer, but if 0 is NOT in the 95% CI for several differences it is quite safe to say that they are not identical at a 0.05 level.
15,065
If variable kernel widths are often good for kernel regression, why are they generally not good for kernel density estimation?
There seem to be two different questions here, which I'll try to split: 1) how is KS, kernel smoothing, different from KDE, kernel density estimation ? Well, say I have an estimator / smoother / interpolator est( xi, fi -> gridj, estj ) and also happen to know the "real" densityf() at the xi. Then running est( x, densityf ) must give an estimate of densityf(): a KDE. It may well be that KSs and KDEs are evaluated differently — different smoothness criteria, different norms — but I don't see a fundamental difference. What am I missing ? 2) How does dimension affect estimation or smoothing, intuitivly ? Here's a toy example, just to help intuition. Consider a box of N=10000 points in a uniform grid, and a window, a line or square or cube, of W=64 points within it: 1d 2d 3d 4d --------------------------------------------------------------- data 10000 100x100 22x22x22 10x10x10x10 side 10000 100 22 10 window 64 8x8 4x4x4 2.8^4 side ratio .64 % 8 % 19 % 28 % dist to win 5000 47 13 7 Here "side ratio" is window side / box side, and "dist to win" is a rough estimate of the mean distance of a random point in the box to a randomly-placed window. Does this make any sense at all ? (A picture or applet would really help: anyone ?) The idea is that a fixed-size window within a fixed-size box has very different nearness to the rest of the box, in 1d 2d 3d 4d. This is for a uniform grid; maybe the strong dependence on dimension carries over to other distributions, maybe not. Anyway, it looks like a strong general effect, an aspect of the curse of dimensionality.
If variable kernel widths are often good for kernel regression, why are they generally not good for
There seem to be two different questions here, which I'll try to split: 1) how is KS, kernel smoothing, different from KDE, kernel density estimation ? Well, say I have an estimator / smoother / inter
If variable kernel widths are often good for kernel regression, why are they generally not good for kernel density estimation? There seem to be two different questions here, which I'll try to split: 1) how is KS, kernel smoothing, different from KDE, kernel density estimation ? Well, say I have an estimator / smoother / interpolator est( xi, fi -> gridj, estj ) and also happen to know the "real" densityf() at the xi. Then running est( x, densityf ) must give an estimate of densityf(): a KDE. It may well be that KSs and KDEs are evaluated differently — different smoothness criteria, different norms — but I don't see a fundamental difference. What am I missing ? 2) How does dimension affect estimation or smoothing, intuitivly ? Here's a toy example, just to help intuition. Consider a box of N=10000 points in a uniform grid, and a window, a line or square or cube, of W=64 points within it: 1d 2d 3d 4d --------------------------------------------------------------- data 10000 100x100 22x22x22 10x10x10x10 side 10000 100 22 10 window 64 8x8 4x4x4 2.8^4 side ratio .64 % 8 % 19 % 28 % dist to win 5000 47 13 7 Here "side ratio" is window side / box side, and "dist to win" is a rough estimate of the mean distance of a random point in the box to a randomly-placed window. Does this make any sense at all ? (A picture or applet would really help: anyone ?) The idea is that a fixed-size window within a fixed-size box has very different nearness to the rest of the box, in 1d 2d 3d 4d. This is for a uniform grid; maybe the strong dependence on dimension carries over to other distributions, maybe not. Anyway, it looks like a strong general effect, an aspect of the curse of dimensionality.
If variable kernel widths are often good for kernel regression, why are they generally not good for There seem to be two different questions here, which I'll try to split: 1) how is KS, kernel smoothing, different from KDE, kernel density estimation ? Well, say I have an estimator / smoother / inter
15,066
If variable kernel widths are often good for kernel regression, why are they generally not good for kernel density estimation?
Kernel density estimation means integration over a local (fuzzy) window, and kernel smoothing means averaging over a local (fuzzy) window. Kernel smoothing: $ \tilde y(x) \propto \frac 1 {\rho(x)} \sum K(||x-x_i||)\,y_i $. Kernel density estimation: $\rho(x) \propto \sum K(||x-x_i||) $. How are these the same? Consider samples of a boolean-valued function, i.e. a set containing both "true samples" (each with unit value) and "false samples" (each with zero value). Assuming the overall sample density is constant (like a grid), the local average of this function is identically proportional to the local (partial-) density of the true-valued subset. (The false samples permit us to constantly disregard the denominator of the smoothing equation, whilst adding zero terms to the summation, so that it simplifies into the density estimation equation.) Similarly if your samples were represented as sparse elements on a boolean raster, you could estimate their density by applying a blur filter to the raster. How are these different? Intuitively, you might expect the choice of smoothing algorithm to depend on whether or not the sample measurements contain significant measurement error. At one extreme (no noise) you simply need to interpolate between the exactly-known values at sample locations. Say, by Delaunay triangulation (with bilinear piecewise interpolation). Density estimation resembles the opposite extreme, it is entirely noise, as the sample in isolation is not accompanied by a measurement of the density value at that point. (So there is nothing to simply interpolate. You might consider measuring Voronoi diagram cell-areas, but smoothing/denoising will still be important..) The point is that despite the similarity these are fundamentally different problems, so different approaches may be optimal.
If variable kernel widths are often good for kernel regression, why are they generally not good for
Kernel density estimation means integration over a local (fuzzy) window, and kernel smoothing means averaging over a local (fuzzy) window. Kernel smoothing: $ \tilde y(x) \propto \frac 1 {\rho(x)} \su
If variable kernel widths are often good for kernel regression, why are they generally not good for kernel density estimation? Kernel density estimation means integration over a local (fuzzy) window, and kernel smoothing means averaging over a local (fuzzy) window. Kernel smoothing: $ \tilde y(x) \propto \frac 1 {\rho(x)} \sum K(||x-x_i||)\,y_i $. Kernel density estimation: $\rho(x) \propto \sum K(||x-x_i||) $. How are these the same? Consider samples of a boolean-valued function, i.e. a set containing both "true samples" (each with unit value) and "false samples" (each with zero value). Assuming the overall sample density is constant (like a grid), the local average of this function is identically proportional to the local (partial-) density of the true-valued subset. (The false samples permit us to constantly disregard the denominator of the smoothing equation, whilst adding zero terms to the summation, so that it simplifies into the density estimation equation.) Similarly if your samples were represented as sparse elements on a boolean raster, you could estimate their density by applying a blur filter to the raster. How are these different? Intuitively, you might expect the choice of smoothing algorithm to depend on whether or not the sample measurements contain significant measurement error. At one extreme (no noise) you simply need to interpolate between the exactly-known values at sample locations. Say, by Delaunay triangulation (with bilinear piecewise interpolation). Density estimation resembles the opposite extreme, it is entirely noise, as the sample in isolation is not accompanied by a measurement of the density value at that point. (So there is nothing to simply interpolate. You might consider measuring Voronoi diagram cell-areas, but smoothing/denoising will still be important..) The point is that despite the similarity these are fundamentally different problems, so different approaches may be optimal.
If variable kernel widths are often good for kernel regression, why are they generally not good for Kernel density estimation means integration over a local (fuzzy) window, and kernel smoothing means averaging over a local (fuzzy) window. Kernel smoothing: $ \tilde y(x) \propto \frac 1 {\rho(x)} \su
15,067
Are categorical variables standardized differently in penalized regression? [duplicate]
I think the main point is what you want to do with the model. There is not a single answer to whether you should standardize none, some or all of variables. It depends on what you want your model for. Using the z-score of the predictors (what you call standardizing), puts all the predictors in the same scale, but makes interpretation a little bit more difficult. The interpretation of the coefficients is now "how much a change in the standard deviation affects the output variable". Many times, penalized/regularized regressions are not suitable for interpretation, because you are introducing a bias in the coefficients. Usually when you use such models, you are interested in the predictions, not in doing a counterfactual analysis. Standardizations are useful because they make the problem numerically more stable. If such is your case, it doesn't make a big difference if you "standardize" your categorical predictors or not. Try asking a more specific answer, including what kind of analysis you want to do with your problem, and you can get a more specific answer :)
Are categorical variables standardized differently in penalized regression? [duplicate]
I think the main point is what you want to do with the model. There is not a single answer to whether you should standardize none, some or all of variables. It depends on what you want your model for
Are categorical variables standardized differently in penalized regression? [duplicate] I think the main point is what you want to do with the model. There is not a single answer to whether you should standardize none, some or all of variables. It depends on what you want your model for. Using the z-score of the predictors (what you call standardizing), puts all the predictors in the same scale, but makes interpretation a little bit more difficult. The interpretation of the coefficients is now "how much a change in the standard deviation affects the output variable". Many times, penalized/regularized regressions are not suitable for interpretation, because you are introducing a bias in the coefficients. Usually when you use such models, you are interested in the predictions, not in doing a counterfactual analysis. Standardizations are useful because they make the problem numerically more stable. If such is your case, it doesn't make a big difference if you "standardize" your categorical predictors or not. Try asking a more specific answer, including what kind of analysis you want to do with your problem, and you can get a more specific answer :)
Are categorical variables standardized differently in penalized regression? [duplicate] I think the main point is what you want to do with the model. There is not a single answer to whether you should standardize none, some or all of variables. It depends on what you want your model for
15,068
Does a "Normal Distribution" need to have mean=median=mode?
A problem with your discussion with the professor is one of terminology, there's a misunderstanding that is getting in the way of conveying a potentially useful idea. In different places, you both make errors. So the first thing to address: it's important to be pretty clear about what a distribution is. A normal distribution is a specific mathematical object, which you could consider as a model for a process (which you might consider an uncountably infinite population of values; no finite population can actually have a continuous distribution). Loosely, what this distribution does (once you specify the parameters) is define (via an algebraic expression) the proportion of the population values that lies within any given interval on the real line. Slightly less loosely, it defines the probability that a single value from that population will lie in any given interval. An observed sample doesn't really have a normal distribution; a sample might (potentially) be drawn from a normal distribution, if one were to exist. If you look at the empirical cdf of the sample, it's discrete. If you bin it (as in a histogram) the sample has a "frequency distribution", but those aren't normal distributions. The distribution can tell us some things (in a probabilistic sense) about a random sample from the population, and a sample may also tell us some things about the population. A reasonable interpretation of a phrase like "normally distributed sample"* is "a random sample from a normally distributed population". *(I generally try to avoid saying it myself, for reasons that are hopefully made clear enough here; usually I manage to confine myself to the second kind of expression.) Having defined terms (if still a little loosely), let us now look at the question in detail. I'll be addressing specific pieces of the question. normal distribution one must have mean=median=mode This is certainly a condition on the normal probability distribution, though not a requirement on a sample drawn from a normal distribution; samples may be asymmetric, may have mean differ from median and so on. [We can, however, get an idea how far apart we might reasonably expect them to be if the sample really came from a normal population.] all the data must be contained under the bell curve I am not sure what "contained under" means in this sense. and perfectly symmetrical around the mean. No; you're talking about the data here, and a sample from a (definitely symmetrical) normal population would not itself be perfectly symmetric. Here's some simulated samples from normal distributions: If you generate a number of samples of about that sample size (60) and plot histograms with about 10 bins, you may see similar variation in general shape. As you can see from the histograms, these are not actually symmetric. Some, like 2, 4 and 7, are quite distinctly asymmetrical. Some have quite short tails, like 5 and 8, some have noticeably longer tails, at least on one side. Some suggest multiple modes. None actually look all that close to what an actual normal density looks like $-$ that is, even random samples don't necessarily look all that much like their populations, at least not until the sample sizes are fairly large $-$ considerably larger than the n=60 I used here. Therefore, technically, there are virtually NO normal distributions in real studies, I agree with your conclusion but the reasoning is not correct; it's not a consequence of the fact that data are not perfectly symmetric (etc); it's the fact that populations are themselves not perfectly normal. if the skew/kurtosis are less than 1.0 it is a normal distribution If she said this in just that way, she's definitely wrong. A sample skewness may be much closer to 0 than that (taking "less than" to mean in absolute magnitude not actual value), and the sample excess kurtosis may also be much closer to 0 than that (they might even, whether by chance or construction, potentially be almost exactly zero), and yet the distribution from which the sample was drawn might be distinctly non-normal (e.g. bimodal, or clearly asymmetric, or perhaps with somewhat heavier tails than the normal $-$ it's not just the tail that determines kurtosis) We can go further -- even if we were to magically know the population skewness and kurtosis were exactly that of a normal, it still wouldn't of itself tell us the population was normal, nor even something close to normal. Here's an example: This particular example is strongly bimodal, heavier tailed than the normal, but symmetric. It has the same skewness and kurtosis as the normal. Further examples can be found in this answer. Not all are symmetric, and some are discrete. The dataset is total number of falls/year in a random sampling of 52 nursing homes which is a random sample of a larger population. The population distribution of counts are never normal. Counts are discrete and non-negative, normal distributions are continuous and over the entire real line. But we're really focused on the wrong issue here. Probability models are just that, models. Let us not confuse our models with the real thing. The issue isn't "are the data themselves normal?" (they can't be), nor even "is the population from which the data were drawn normal?" (this is almost never going to be the case). A more useful question to discuss is "how badly would my inference be impacted if I treated the population as normally distributed?" That is we should not be overly focused on whether the assumption is true (we shouldn't expect that), but whether it's useful, or perhaps what and how severe might the consequences be if we were to use such a model. It's also a much harder question to answer well, and may require considerably more work than glancing at a few simple diagnostics. The sample statistics you showed are not particularly inconsistent with normality (you could see statistics like that or "worse" not terribly rarely if you had random samples of that size from normal populations), but that doesn't of itself mean that the actual population from which the sample was drawn is automatically "close enough" to normal for some particular purpose. It would be important to consider the purpose (what questions you're answering), and the robustness of the methods employed for it, and even then we may still not be sure that it's "good enough"; sometimes it may be better to simply not assume what we don't have good reason to assume a priori (e.g. on the basis of experience with similar data sets). it is NOT a normal distribution Data - even data drawn from a normal population - never have exactly the properties of the population; from those numbers alone you don't have a good basis to conclude that the population is not normal here. On the other hand neither do we have any reasonably solid basis to say that it's "sufficiently close" to normal - we haven't even considered the purpose of assuming normality, so we don't know what distributional features it might be sensitive to. For example, if I had two samples for a measurement that was bounded, that I knew would not be heavily discrete (not mostly only taking a few distinct values) and reasonably near to symmetric, I might be relatively happy to use a two-sample t-test at some not-so-small sample size; it's moderately robust to mild deviations from the assumptions (somewhat level-robust, somewhat less power-robust). But I would be considerably more cautious about as causally assuming normality when testing equality of spread, for example, because the best test under that assumption is quite sensitive to the assumption. Because they are both between the critical values of -1 and +1, this data is considered to be normally distributed." If that's really the criterion by which one decides to use a normal distributional model, then it will sometimes lead you into quite poor analyses. The values of those statistics do give us some clues about the population from which the sample was drawn, but that's not at all the same thing as suggesting that their values are in any way a 'safe guide' to choosing an analysis. Cast your mind back to the fact that there's distributional examples where the population has very different shape from the normal, but with the same population skewness and kurtosis. Add to that the inherent noise in their sample equivalents (and not least of all, the considerable downbias typical of sample kurtosis), and you may well be concluding rather too much on very limited and possibly misleading evidence. Now to address the underlying issue with even a better phrased version of such a question as the one you had: The whole process of looking at a sample to choose a model is fraught with problems -- doing so alters the properties of any subsequent choices of analysis based on what you saw! e.g for a hypothesis test, your significance levels, p-values and power are all not what you would choose/calculate them to be, because those calculations are predicated on the analysis not being based on the data. See, for example Gelman and Loken (2014), "The Statistical Crisis in Science," American Scientist, Volume 102, Number 6, p 460 (DOI: 10.1511/2014.111.460) which discusses issues with such data-dependent analysis.
Does a "Normal Distribution" need to have mean=median=mode?
A problem with your discussion with the professor is one of terminology, there's a misunderstanding that is getting in the way of conveying a potentially useful idea. In different places, you both mak
Does a "Normal Distribution" need to have mean=median=mode? A problem with your discussion with the professor is one of terminology, there's a misunderstanding that is getting in the way of conveying a potentially useful idea. In different places, you both make errors. So the first thing to address: it's important to be pretty clear about what a distribution is. A normal distribution is a specific mathematical object, which you could consider as a model for a process (which you might consider an uncountably infinite population of values; no finite population can actually have a continuous distribution). Loosely, what this distribution does (once you specify the parameters) is define (via an algebraic expression) the proportion of the population values that lies within any given interval on the real line. Slightly less loosely, it defines the probability that a single value from that population will lie in any given interval. An observed sample doesn't really have a normal distribution; a sample might (potentially) be drawn from a normal distribution, if one were to exist. If you look at the empirical cdf of the sample, it's discrete. If you bin it (as in a histogram) the sample has a "frequency distribution", but those aren't normal distributions. The distribution can tell us some things (in a probabilistic sense) about a random sample from the population, and a sample may also tell us some things about the population. A reasonable interpretation of a phrase like "normally distributed sample"* is "a random sample from a normally distributed population". *(I generally try to avoid saying it myself, for reasons that are hopefully made clear enough here; usually I manage to confine myself to the second kind of expression.) Having defined terms (if still a little loosely), let us now look at the question in detail. I'll be addressing specific pieces of the question. normal distribution one must have mean=median=mode This is certainly a condition on the normal probability distribution, though not a requirement on a sample drawn from a normal distribution; samples may be asymmetric, may have mean differ from median and so on. [We can, however, get an idea how far apart we might reasonably expect them to be if the sample really came from a normal population.] all the data must be contained under the bell curve I am not sure what "contained under" means in this sense. and perfectly symmetrical around the mean. No; you're talking about the data here, and a sample from a (definitely symmetrical) normal population would not itself be perfectly symmetric. Here's some simulated samples from normal distributions: If you generate a number of samples of about that sample size (60) and plot histograms with about 10 bins, you may see similar variation in general shape. As you can see from the histograms, these are not actually symmetric. Some, like 2, 4 and 7, are quite distinctly asymmetrical. Some have quite short tails, like 5 and 8, some have noticeably longer tails, at least on one side. Some suggest multiple modes. None actually look all that close to what an actual normal density looks like $-$ that is, even random samples don't necessarily look all that much like their populations, at least not until the sample sizes are fairly large $-$ considerably larger than the n=60 I used here. Therefore, technically, there are virtually NO normal distributions in real studies, I agree with your conclusion but the reasoning is not correct; it's not a consequence of the fact that data are not perfectly symmetric (etc); it's the fact that populations are themselves not perfectly normal. if the skew/kurtosis are less than 1.0 it is a normal distribution If she said this in just that way, she's definitely wrong. A sample skewness may be much closer to 0 than that (taking "less than" to mean in absolute magnitude not actual value), and the sample excess kurtosis may also be much closer to 0 than that (they might even, whether by chance or construction, potentially be almost exactly zero), and yet the distribution from which the sample was drawn might be distinctly non-normal (e.g. bimodal, or clearly asymmetric, or perhaps with somewhat heavier tails than the normal $-$ it's not just the tail that determines kurtosis) We can go further -- even if we were to magically know the population skewness and kurtosis were exactly that of a normal, it still wouldn't of itself tell us the population was normal, nor even something close to normal. Here's an example: This particular example is strongly bimodal, heavier tailed than the normal, but symmetric. It has the same skewness and kurtosis as the normal. Further examples can be found in this answer. Not all are symmetric, and some are discrete. The dataset is total number of falls/year in a random sampling of 52 nursing homes which is a random sample of a larger population. The population distribution of counts are never normal. Counts are discrete and non-negative, normal distributions are continuous and over the entire real line. But we're really focused on the wrong issue here. Probability models are just that, models. Let us not confuse our models with the real thing. The issue isn't "are the data themselves normal?" (they can't be), nor even "is the population from which the data were drawn normal?" (this is almost never going to be the case). A more useful question to discuss is "how badly would my inference be impacted if I treated the population as normally distributed?" That is we should not be overly focused on whether the assumption is true (we shouldn't expect that), but whether it's useful, or perhaps what and how severe might the consequences be if we were to use such a model. It's also a much harder question to answer well, and may require considerably more work than glancing at a few simple diagnostics. The sample statistics you showed are not particularly inconsistent with normality (you could see statistics like that or "worse" not terribly rarely if you had random samples of that size from normal populations), but that doesn't of itself mean that the actual population from which the sample was drawn is automatically "close enough" to normal for some particular purpose. It would be important to consider the purpose (what questions you're answering), and the robustness of the methods employed for it, and even then we may still not be sure that it's "good enough"; sometimes it may be better to simply not assume what we don't have good reason to assume a priori (e.g. on the basis of experience with similar data sets). it is NOT a normal distribution Data - even data drawn from a normal population - never have exactly the properties of the population; from those numbers alone you don't have a good basis to conclude that the population is not normal here. On the other hand neither do we have any reasonably solid basis to say that it's "sufficiently close" to normal - we haven't even considered the purpose of assuming normality, so we don't know what distributional features it might be sensitive to. For example, if I had two samples for a measurement that was bounded, that I knew would not be heavily discrete (not mostly only taking a few distinct values) and reasonably near to symmetric, I might be relatively happy to use a two-sample t-test at some not-so-small sample size; it's moderately robust to mild deviations from the assumptions (somewhat level-robust, somewhat less power-robust). But I would be considerably more cautious about as causally assuming normality when testing equality of spread, for example, because the best test under that assumption is quite sensitive to the assumption. Because they are both between the critical values of -1 and +1, this data is considered to be normally distributed." If that's really the criterion by which one decides to use a normal distributional model, then it will sometimes lead you into quite poor analyses. The values of those statistics do give us some clues about the population from which the sample was drawn, but that's not at all the same thing as suggesting that their values are in any way a 'safe guide' to choosing an analysis. Cast your mind back to the fact that there's distributional examples where the population has very different shape from the normal, but with the same population skewness and kurtosis. Add to that the inherent noise in their sample equivalents (and not least of all, the considerable downbias typical of sample kurtosis), and you may well be concluding rather too much on very limited and possibly misleading evidence. Now to address the underlying issue with even a better phrased version of such a question as the one you had: The whole process of looking at a sample to choose a model is fraught with problems -- doing so alters the properties of any subsequent choices of analysis based on what you saw! e.g for a hypothesis test, your significance levels, p-values and power are all not what you would choose/calculate them to be, because those calculations are predicated on the analysis not being based on the data. See, for example Gelman and Loken (2014), "The Statistical Crisis in Science," American Scientist, Volume 102, Number 6, p 460 (DOI: 10.1511/2014.111.460) which discusses issues with such data-dependent analysis.
Does a "Normal Distribution" need to have mean=median=mode? A problem with your discussion with the professor is one of terminology, there's a misunderstanding that is getting in the way of conveying a potentially useful idea. In different places, you both mak
15,069
Does a "Normal Distribution" need to have mean=median=mode?
You're missing the point and probably are also being "difficult," which is not appreciated in the industry. She's showing you a toy example, to train you in assessment of normality of a data set, which is to say whether the data set comes from a normal distribution. Looking at distribution moments is one way to check the normality, e.g. Jarque Bera test is based on such an assessment. Yes, the normal distribution is perfectly symmetrical. However, if you draw a sample from a true normal distribution, that sample will most likely not be perfectly symmetrical. This is the point you're completely missing. You can test this very easily yourself. Just generate a sample from Gaussian distribution, and check its moment. They'll never be perfectly "normal," despite the true distribution being such. Here's a silly Python example. I'm generating 100 samples of 100 random numbers, then obtaining their means and medians. I print the first sample to show that the mean and median are different, then show the histogram of the difference between the means and medians. You can see that it's rather narrow, but the difference is basically never zero. Note, that the numbers are truly coming from a normal distribution. code: import numpy as np import matplotlib.pyplot as plt np.random.seed(1) s = np.random.normal(0, 1, (100,100)) print('sample 0 mean:',np.mean(s[:,0]),'median:',np.median(s[:,0])) plt.hist(np.mean(s,0)-np.median(s,0)) plt.show() print('avg mean-median:',np.mean(np.mean(s,0)-np.median(s,0))) outputs: P.S. Now, whether the example from your question should be considered normal or not depends on the context. In the context of what was taught in your class room you're wrong, because your professor wanted to see whether you know the rule of thumb test that she gave you, which is that skew and excess kurtosis need to be in -1 to 1 range. I personally never used this particular rule of thumb (I can't call it a test), and didn't even know it existed. Apparently, some people in some fields do use it though. If you were to plug your data set descriptives into JB test, it would have rejected normality. Hence, you're not wrong to suggest that the data set is not normal, of course, but you're wrong in a sense that you failed to apply the rule that was expected from you based on what's been taught in the class. If I were you I'd politely approach your professor and explain myself, as well as show JB test output. I'd acknowledge that based on her test my answer was wrong, of course. If you attempt to argue with her the way you argue here, your chances are very low to get the point back in the test, because your reasoning is weak about medians and means and samples, it shows lack of understanding of samples vs. populations. If you change your tune, then you'll have a case.
Does a "Normal Distribution" need to have mean=median=mode?
You're missing the point and probably are also being "difficult," which is not appreciated in the industry. She's showing you a toy example, to train you in assessment of normality of a data set, whic
Does a "Normal Distribution" need to have mean=median=mode? You're missing the point and probably are also being "difficult," which is not appreciated in the industry. She's showing you a toy example, to train you in assessment of normality of a data set, which is to say whether the data set comes from a normal distribution. Looking at distribution moments is one way to check the normality, e.g. Jarque Bera test is based on such an assessment. Yes, the normal distribution is perfectly symmetrical. However, if you draw a sample from a true normal distribution, that sample will most likely not be perfectly symmetrical. This is the point you're completely missing. You can test this very easily yourself. Just generate a sample from Gaussian distribution, and check its moment. They'll never be perfectly "normal," despite the true distribution being such. Here's a silly Python example. I'm generating 100 samples of 100 random numbers, then obtaining their means and medians. I print the first sample to show that the mean and median are different, then show the histogram of the difference between the means and medians. You can see that it's rather narrow, but the difference is basically never zero. Note, that the numbers are truly coming from a normal distribution. code: import numpy as np import matplotlib.pyplot as plt np.random.seed(1) s = np.random.normal(0, 1, (100,100)) print('sample 0 mean:',np.mean(s[:,0]),'median:',np.median(s[:,0])) plt.hist(np.mean(s,0)-np.median(s,0)) plt.show() print('avg mean-median:',np.mean(np.mean(s,0)-np.median(s,0))) outputs: P.S. Now, whether the example from your question should be considered normal or not depends on the context. In the context of what was taught in your class room you're wrong, because your professor wanted to see whether you know the rule of thumb test that she gave you, which is that skew and excess kurtosis need to be in -1 to 1 range. I personally never used this particular rule of thumb (I can't call it a test), and didn't even know it existed. Apparently, some people in some fields do use it though. If you were to plug your data set descriptives into JB test, it would have rejected normality. Hence, you're not wrong to suggest that the data set is not normal, of course, but you're wrong in a sense that you failed to apply the rule that was expected from you based on what's been taught in the class. If I were you I'd politely approach your professor and explain myself, as well as show JB test output. I'd acknowledge that based on her test my answer was wrong, of course. If you attempt to argue with her the way you argue here, your chances are very low to get the point back in the test, because your reasoning is weak about medians and means and samples, it shows lack of understanding of samples vs. populations. If you change your tune, then you'll have a case.
Does a "Normal Distribution" need to have mean=median=mode? You're missing the point and probably are also being "difficult," which is not appreciated in the industry. She's showing you a toy example, to train you in assessment of normality of a data set, whic
15,070
Does a "Normal Distribution" need to have mean=median=mode?
The teacher is clearly out of his/her element, and probably should not be teaching statistics. It seems worse to me to teach something wrong than to not teach it at all. These issues could all be cleared up easily if the distinction between "data" and "process that produced the data" were made more clearly. Data target the process that produced the data. The normal distribution is a model for this process. It makes no sense to talk about whether the data are normally distributed. For one reason, the data are always discrete. For another reason, the normal distribution describes an infinity of potentially observable quantities, not a finite set of specific observed quantities. Further, the answer to the question "is the process that produced the data a normally distributed process" is also always "no," regardless of the data. Two simple reasons: (i) any measurements we take are necessarily discrete, being rounded off to some level. (ii) perfect symmetry, like a perfect circle, does not exist in observable nature. There are always imperfections. At best, the answer to the question "what do these data tell you about normality of the data-generating process" could be given as follows: "these data are consistent with what we would expect to see, had the data truly come from a normally distributed process." That answer correctly does not conclude that the distribution is normal. These issues are very easily understood by using simulation. Just simulate data from a normal distribution and compare those to the existing data. If the data are counts (0,1,2,3,...), then obviously the normal model is wrong because it does not produce numbers like 0,1,2,3,...; instead, it produces numbers with decimals that go on forever (or at least as far as the computer will allow.) Such simulation should be the first thing you do when learning about the normality question. Then you can more correctly interpret the graphs and summary statistics.
Does a "Normal Distribution" need to have mean=median=mode?
The teacher is clearly out of his/her element, and probably should not be teaching statistics. It seems worse to me to teach something wrong than to not teach it at all. These issues could all be cle
Does a "Normal Distribution" need to have mean=median=mode? The teacher is clearly out of his/her element, and probably should not be teaching statistics. It seems worse to me to teach something wrong than to not teach it at all. These issues could all be cleared up easily if the distinction between "data" and "process that produced the data" were made more clearly. Data target the process that produced the data. The normal distribution is a model for this process. It makes no sense to talk about whether the data are normally distributed. For one reason, the data are always discrete. For another reason, the normal distribution describes an infinity of potentially observable quantities, not a finite set of specific observed quantities. Further, the answer to the question "is the process that produced the data a normally distributed process" is also always "no," regardless of the data. Two simple reasons: (i) any measurements we take are necessarily discrete, being rounded off to some level. (ii) perfect symmetry, like a perfect circle, does not exist in observable nature. There are always imperfections. At best, the answer to the question "what do these data tell you about normality of the data-generating process" could be given as follows: "these data are consistent with what we would expect to see, had the data truly come from a normally distributed process." That answer correctly does not conclude that the distribution is normal. These issues are very easily understood by using simulation. Just simulate data from a normal distribution and compare those to the existing data. If the data are counts (0,1,2,3,...), then obviously the normal model is wrong because it does not produce numbers like 0,1,2,3,...; instead, it produces numbers with decimals that go on forever (or at least as far as the computer will allow.) Such simulation should be the first thing you do when learning about the normality question. Then you can more correctly interpret the graphs and summary statistics.
Does a "Normal Distribution" need to have mean=median=mode? The teacher is clearly out of his/her element, and probably should not be teaching statistics. It seems worse to me to teach something wrong than to not teach it at all. These issues could all be cle
15,071
Does a "Normal Distribution" need to have mean=median=mode?
I'm an engineer, so in my world, the applied statistician is what I see most, and get the most concrete value. If you are going to work in applied, then you need to be solidly grounded in practice over theory: whether or not it is elegant, the aircraft has to fly and not crash. When I think about this question the way I approach it, as many of my technical betters here have also done, is to think about "what does it look like in the real world with the presence of noise". The second thing that I do is, often, to make a simulation that allows me to get my hands around the question. Here is a very brief exploration: #show how the mean and the median differ with respect to sample size #libraries library(reshape2) library(ggplot2) #sample sizes ssizes <- 10^(seq(from=1, to=3, by=0.25)) ssizes <- round(ssizes) #loops per sample n_loops <- 5000 #pre-declare, prep for loop my_store <- matrix(0, ncol = 3, nrow = n_loops*length(ssizes)) count <- 1 for(i in 1:length(ssizes)){ #how many samples n_samp <- ssizes[i] for(j in 1:n_loops){ #draw samples y <- 0 y <- rnorm(n = n_samp,mean = 0, sd = 1) #compute mean, median, mode my_store[count,1] <- n_samp my_store[count,2] <- median(y) my_store[count,3] <- mean(y) #update count = count + 1 } } #make data into ggplot friendly form df <- data.frame(my_store) names(df) <- c("n_samp", "median","mean") df <- melt(df, id.vars = 1, measure.vars = c("median","mean")) #make ggplot ggplot(df, aes(x=as.factor(n_samp), y = value, fill = variable)) + geom_boxplot() + labs(title = "Contrast Median and Mean estimate variation vs. Sample Size", x = "Number of Samples", y = "Estimated value") It gives this as the output: Note: be careful about the x-axis, because it is log-scaled, not uniform-scaled. I know that the mean and median are exactly the same. The code says it. The empirical realization is greatly sensitive to sample size, and if there aren't truly infinite samples, then they can't ever perfectly match with theory. You can think about whether the uncertainty in the median envelopes the estimated mean or vice versa. If the best estimate of the mean is within the 95% CI of the estimate for the median, then the data can't tell the difference. The data says they are the same in theory. If you get more data, then see what it says.
Does a "Normal Distribution" need to have mean=median=mode?
I'm an engineer, so in my world, the applied statistician is what I see most, and get the most concrete value. If you are going to work in applied, then you need to be solidly grounded in practice ov
Does a "Normal Distribution" need to have mean=median=mode? I'm an engineer, so in my world, the applied statistician is what I see most, and get the most concrete value. If you are going to work in applied, then you need to be solidly grounded in practice over theory: whether or not it is elegant, the aircraft has to fly and not crash. When I think about this question the way I approach it, as many of my technical betters here have also done, is to think about "what does it look like in the real world with the presence of noise". The second thing that I do is, often, to make a simulation that allows me to get my hands around the question. Here is a very brief exploration: #show how the mean and the median differ with respect to sample size #libraries library(reshape2) library(ggplot2) #sample sizes ssizes <- 10^(seq(from=1, to=3, by=0.25)) ssizes <- round(ssizes) #loops per sample n_loops <- 5000 #pre-declare, prep for loop my_store <- matrix(0, ncol = 3, nrow = n_loops*length(ssizes)) count <- 1 for(i in 1:length(ssizes)){ #how many samples n_samp <- ssizes[i] for(j in 1:n_loops){ #draw samples y <- 0 y <- rnorm(n = n_samp,mean = 0, sd = 1) #compute mean, median, mode my_store[count,1] <- n_samp my_store[count,2] <- median(y) my_store[count,3] <- mean(y) #update count = count + 1 } } #make data into ggplot friendly form df <- data.frame(my_store) names(df) <- c("n_samp", "median","mean") df <- melt(df, id.vars = 1, measure.vars = c("median","mean")) #make ggplot ggplot(df, aes(x=as.factor(n_samp), y = value, fill = variable)) + geom_boxplot() + labs(title = "Contrast Median and Mean estimate variation vs. Sample Size", x = "Number of Samples", y = "Estimated value") It gives this as the output: Note: be careful about the x-axis, because it is log-scaled, not uniform-scaled. I know that the mean and median are exactly the same. The code says it. The empirical realization is greatly sensitive to sample size, and if there aren't truly infinite samples, then they can't ever perfectly match with theory. You can think about whether the uncertainty in the median envelopes the estimated mean or vice versa. If the best estimate of the mean is within the 95% CI of the estimate for the median, then the data can't tell the difference. The data says they are the same in theory. If you get more data, then see what it says.
Does a "Normal Distribution" need to have mean=median=mode? I'm an engineer, so in my world, the applied statistician is what I see most, and get the most concrete value. If you are going to work in applied, then you need to be solidly grounded in practice ov
15,072
Does a "Normal Distribution" need to have mean=median=mode?
In medical statistics, we only ever comment on the shapes and seeming of distributions. The fact that no discrete finite sample can ever be normal is irrelevant and pedantic. I would mark you wrong for that. If a distribution looks "mostly" normal, we are comfortable with calling it normal. When I describe distributions for a non-statistical audience, I am very comfortable with calling something approximately normal even when I know the normal distribution is not the underlying probability model, I get the sense I would side with your teacher here... but we have no histogram or dataset to verify. As a tip, I would go through the following inspections very closely: who are the outliers, how many and what are their values? Are the data bimodal? Do the data seem to take a skewed shape so that some transformation (like a log) would better quantify the "distance" between observations? Is there apparent truncation or heaping so that assays or labs are failing to reliably detect a certain range of values?
Does a "Normal Distribution" need to have mean=median=mode?
In medical statistics, we only ever comment on the shapes and seeming of distributions. The fact that no discrete finite sample can ever be normal is irrelevant and pedantic. I would mark you wrong fo
Does a "Normal Distribution" need to have mean=median=mode? In medical statistics, we only ever comment on the shapes and seeming of distributions. The fact that no discrete finite sample can ever be normal is irrelevant and pedantic. I would mark you wrong for that. If a distribution looks "mostly" normal, we are comfortable with calling it normal. When I describe distributions for a non-statistical audience, I am very comfortable with calling something approximately normal even when I know the normal distribution is not the underlying probability model, I get the sense I would side with your teacher here... but we have no histogram or dataset to verify. As a tip, I would go through the following inspections very closely: who are the outliers, how many and what are their values? Are the data bimodal? Do the data seem to take a skewed shape so that some transformation (like a log) would better quantify the "distance" between observations? Is there apparent truncation or heaping so that assays or labs are failing to reliably detect a certain range of values?
Does a "Normal Distribution" need to have mean=median=mode? In medical statistics, we only ever comment on the shapes and seeming of distributions. The fact that no discrete finite sample can ever be normal is irrelevant and pedantic. I would mark you wrong fo
15,073
Does a "Normal Distribution" need to have mean=median=mode?
I think you and your professor are talking in different context. Equality of mean = median = mode is characteristics of theoretical distribution and this is not the only characteristics. You can not say that if for any distribution above property hold then distribution is normal. T-distribution is also symmetric but it is not normal. So, you are talking about theoretical properties of normal distribution which hold always true for normal distribution. You professor is talking about distribution of sample data. He is right, you will never get data in real life, where you will find mean = median = mode. This is simply due to sampling error. Similarly, it is very unlikely, you will get zero coefficient of skewness for sample data and zero excess kurtosis. Your professor is just giving you simple rule to get an idea about the distribution from the sample statistics. Which is not true in general (without getting further information).
Does a "Normal Distribution" need to have mean=median=mode?
I think you and your professor are talking in different context. Equality of mean = median = mode is characteristics of theoretical distribution and this is not the only characteristics. You can not s
Does a "Normal Distribution" need to have mean=median=mode? I think you and your professor are talking in different context. Equality of mean = median = mode is characteristics of theoretical distribution and this is not the only characteristics. You can not say that if for any distribution above property hold then distribution is normal. T-distribution is also symmetric but it is not normal. So, you are talking about theoretical properties of normal distribution which hold always true for normal distribution. You professor is talking about distribution of sample data. He is right, you will never get data in real life, where you will find mean = median = mode. This is simply due to sampling error. Similarly, it is very unlikely, you will get zero coefficient of skewness for sample data and zero excess kurtosis. Your professor is just giving you simple rule to get an idea about the distribution from the sample statistics. Which is not true in general (without getting further information).
Does a "Normal Distribution" need to have mean=median=mode? I think you and your professor are talking in different context. Equality of mean = median = mode is characteristics of theoretical distribution and this is not the only characteristics. You can not s
15,074
Does a "Normal Distribution" need to have mean=median=mode?
For practical purposes, underlying processes such as this one are usually finely approximated by normal distribution without anyone raising an eyebrow. However, if you wanted to be pedantic the underlying process in this case can't be normally distributed, because it can't produce negative values (number of falls can't be negative). I wouldn't be surprised if it was in fact at least a bi-modal distribution with second peak close to zero.
Does a "Normal Distribution" need to have mean=median=mode?
For practical purposes, underlying processes such as this one are usually finely approximated by normal distribution without anyone raising an eyebrow. However, if you wanted to be pedantic the underl
Does a "Normal Distribution" need to have mean=median=mode? For practical purposes, underlying processes such as this one are usually finely approximated by normal distribution without anyone raising an eyebrow. However, if you wanted to be pedantic the underlying process in this case can't be normally distributed, because it can't produce negative values (number of falls can't be negative). I wouldn't be surprised if it was in fact at least a bi-modal distribution with second peak close to zero.
Does a "Normal Distribution" need to have mean=median=mode? For practical purposes, underlying processes such as this one are usually finely approximated by normal distribution without anyone raising an eyebrow. However, if you wanted to be pedantic the underl
15,075
Why is correlation only defined between two variables?
Pearson correlation is defined as a measure of the linear relationship between two variables. For other relationships, like multidimensional relationships, we use other names. For instance: one could use the eigenvalues of a principal component analysis to express a degree of correlation in a multivariate case. Another related concept is the variance inflation factor. In the case of the hurricanes example that you mention, one might also think of multiple correlation and this gives the $R^2$ value or coefficient of determination for a linear model where hurricanes are predicted by temperature and windspeed. In addition there are constructs similar to Pearson correlation that use multiple variables. I have seen on this website before an expression like $E[(X-\mu_X)(Y-\mu_Y)(Z-\mu_Z)]/(\sigma_X\sigma_Y\sigma_Z)$. (but I can not find the original post)
Why is correlation only defined between two variables?
Pearson correlation is defined as a measure of the linear relationship between two variables. For other relationships, like multidimensional relationships, we use other names. For instance: one could
Why is correlation only defined between two variables? Pearson correlation is defined as a measure of the linear relationship between two variables. For other relationships, like multidimensional relationships, we use other names. For instance: one could use the eigenvalues of a principal component analysis to express a degree of correlation in a multivariate case. Another related concept is the variance inflation factor. In the case of the hurricanes example that you mention, one might also think of multiple correlation and this gives the $R^2$ value or coefficient of determination for a linear model where hurricanes are predicted by temperature and windspeed. In addition there are constructs similar to Pearson correlation that use multiple variables. I have seen on this website before an expression like $E[(X-\mu_X)(Y-\mu_Y)(Z-\mu_Z)]/(\sigma_X\sigma_Y\sigma_Z)$. (but I can not find the original post)
Why is correlation only defined between two variables? Pearson correlation is defined as a measure of the linear relationship between two variables. For other relationships, like multidimensional relationships, we use other names. For instance: one could
15,076
Why is correlation only defined between two variables?
In a sense, correlation is defined between more than two variables, through a correlation matrix. This is not a single number of course, but that is only natural given that it is describing correlation between several pairs of variables. This situation is analogous to many types of measurement in multivariate analysis, where we measure aspects of the behaviour by vectors or matrices. You might also be interested to note that the correlation matrix for a set of variables is sufficient to compute the coefficient-of-determination for any Gaussian linear regression involving those variables (see this related answer), so even when we extend our analysis to look at conditional correlations, the correlation matrix is sufficient for this purpose. Of course, even with a correlation matrix, it is merely describing the pairwise correlation between each pair of variables and resulting linear relationships conditional on other variables. The reason these correlation values are for pairs of variables is that they are measuring the tendency for one thing to vary with respect to a second thing.
Why is correlation only defined between two variables?
In a sense, correlation is defined between more than two variables, through a correlation matrix. This is not a single number of course, but that is only natural given that it is describing correlati
Why is correlation only defined between two variables? In a sense, correlation is defined between more than two variables, through a correlation matrix. This is not a single number of course, but that is only natural given that it is describing correlation between several pairs of variables. This situation is analogous to many types of measurement in multivariate analysis, where we measure aspects of the behaviour by vectors or matrices. You might also be interested to note that the correlation matrix for a set of variables is sufficient to compute the coefficient-of-determination for any Gaussian linear regression involving those variables (see this related answer), so even when we extend our analysis to look at conditional correlations, the correlation matrix is sufficient for this purpose. Of course, even with a correlation matrix, it is merely describing the pairwise correlation between each pair of variables and resulting linear relationships conditional on other variables. The reason these correlation values are for pairs of variables is that they are measuring the tendency for one thing to vary with respect to a second thing.
Why is correlation only defined between two variables? In a sense, correlation is defined between more than two variables, through a correlation matrix. This is not a single number of course, but that is only natural given that it is describing correlati
15,077
Why is correlation only defined between two variables?
why do we only evaluate the correlation between two variables and not more than two variables? It can be more than 2 variables. Three point correlation function (3PC) is used in cosmology, The Three-Point Correlation Function in Cosmology. It is formed for variables $x$, $y$ and $z$ with the following approximation with a constant factor of 1, $$3PC=Corr(x,y,z) = Corr(x,y) \cdot Corr(y,z) + Corr(y,z) \cdot Corr(z,x) + Corr(z,x) \cdot Corr(x,y)\cdot$$ It is cycling over. This could be extended to N-point correlation function.
Why is correlation only defined between two variables?
why do we only evaluate the correlation between two variables and not more than two variables? It can be more than 2 variables. Three point correlation function (3PC) is used in cosmology, The Three-
Why is correlation only defined between two variables? why do we only evaluate the correlation between two variables and not more than two variables? It can be more than 2 variables. Three point correlation function (3PC) is used in cosmology, The Three-Point Correlation Function in Cosmology. It is formed for variables $x$, $y$ and $z$ with the following approximation with a constant factor of 1, $$3PC=Corr(x,y,z) = Corr(x,y) \cdot Corr(y,z) + Corr(y,z) \cdot Corr(z,x) + Corr(z,x) \cdot Corr(x,y)\cdot$$ It is cycling over. This could be extended to N-point correlation function.
Why is correlation only defined between two variables? why do we only evaluate the correlation between two variables and not more than two variables? It can be more than 2 variables. Three point correlation function (3PC) is used in cosmology, The Three-
15,078
Why is correlation only defined between two variables?
Such a statistic would be hard to define and interpret. Say you have the variables $A$, $B$, and $C$. The pairwise correlation between $A$ and $B$ is close to $+1$ and the pairwise correlation between $B$ and $C$ is close to $-1$. What should the single number correlation between the three variables be? High, low, or maybe zero? You could instead look at correlation matrices between all the variables, but it is a highly overrated approach that could be misleading, and lead to a false sense of understanding. One example is people blindly dropping from their analysis variables that are strongly correlated with each other, or weekly correlated with the dependent variable, missing the point that those relations may change when controlling for other variables. It is like in the parable about the blind men and an elephant: A group of blind men heard that a strange animal, called an elephant, had been brought to the town, but none of them were aware of its shape and form. Out of curiosity, they said: "We must inspect and know it by touch, of which we are capable". So, they sought it out, and when they found it they groped about it. The first person, whose hand landed on the trunk, said, "This being is like a thick snake". For another one whose hand reached its ear, it seemed like a kind of fan. As for another person, whose hand was upon its leg, said, the elephant is a pillar like a tree-trunk. The blind man who placed his hand upon its side said the elephant, "is a wall". Another who felt its tail, described it as a rope. The last felt its tusk, stating the elephant is that which is hard, smooth and like a spear. Looking at the pairwise relations tells you only the part of the story but is not enough to get the full picture right. We all hope that our brain would be able to somehow combine all the information for the full picture, but if that was the case that people can just eyeball the numbers to draw legitimate conclusions, we wouldn't need statistics. For many variables, we use instead the multivariate models like linear regression or partial correlations that tell us about pairwise relations but corrected for the influence of other variables.
Why is correlation only defined between two variables?
Such a statistic would be hard to define and interpret. Say you have the variables $A$, $B$, and $C$. The pairwise correlation between $A$ and $B$ is close to $+1$ and the pairwise correlation between
Why is correlation only defined between two variables? Such a statistic would be hard to define and interpret. Say you have the variables $A$, $B$, and $C$. The pairwise correlation between $A$ and $B$ is close to $+1$ and the pairwise correlation between $B$ and $C$ is close to $-1$. What should the single number correlation between the three variables be? High, low, or maybe zero? You could instead look at correlation matrices between all the variables, but it is a highly overrated approach that could be misleading, and lead to a false sense of understanding. One example is people blindly dropping from their analysis variables that are strongly correlated with each other, or weekly correlated with the dependent variable, missing the point that those relations may change when controlling for other variables. It is like in the parable about the blind men and an elephant: A group of blind men heard that a strange animal, called an elephant, had been brought to the town, but none of them were aware of its shape and form. Out of curiosity, they said: "We must inspect and know it by touch, of which we are capable". So, they sought it out, and when they found it they groped about it. The first person, whose hand landed on the trunk, said, "This being is like a thick snake". For another one whose hand reached its ear, it seemed like a kind of fan. As for another person, whose hand was upon its leg, said, the elephant is a pillar like a tree-trunk. The blind man who placed his hand upon its side said the elephant, "is a wall". Another who felt its tail, described it as a rope. The last felt its tusk, stating the elephant is that which is hard, smooth and like a spear. Looking at the pairwise relations tells you only the part of the story but is not enough to get the full picture right. We all hope that our brain would be able to somehow combine all the information for the full picture, but if that was the case that people can just eyeball the numbers to draw legitimate conclusions, we wouldn't need statistics. For many variables, we use instead the multivariate models like linear regression or partial correlations that tell us about pairwise relations but corrected for the influence of other variables.
Why is correlation only defined between two variables? Such a statistic would be hard to define and interpret. Say you have the variables $A$, $B$, and $C$. The pairwise correlation between $A$ and $B$ is close to $+1$ and the pairwise correlation between
15,079
Why is correlation only defined between two variables?
Correlations between multiple variables can be defined as a joint cumulant. In physics we call this a "connected correlation function". In statistics, one would call these quantities covariances instead of correlations as it's customary to normalize correlations so that they are between -1 and 1. The connected correlation between $n$ variables is an effect that's due to all $n$ variables together that cannot be attributed to correlations between variables in proper subsets of the $n$ variables. Connected correlation functions are multilinear functions of their arguments. The expectation value of any arbitrary product of random variables can be written as a sum of products of connected correlations involving all the ways one can partition the set of variables into disjoint subsets. This property yields a recursion for the joint correlation function, so it can be used to define it. If we denote connected correlations as $C(X_1,X_2,\ldots,X_n)$, then we have: $$C(X) = E(X)\tag{1}$$ which follows trivially from the recursion. For two variables $X$ and $Y$ we have that the connected correlation $C(X,Y)$ is the covariance between $X$ and $Y$. This also follows easily from the recursion: $$ E(XY) = C(X,Y) + C(X) C(Y) $$ Using (1) we then get: $$ C(X,Y)=E(XY) - E(X) E(Y)\tag{2} $$ For 3 variables $X$, $Y$ and $Z$, the recursion is: $$ E(XYZ) = C(X,Y,Z) + C(X,Y) C(Z) + C(X,Z) C(Y)+C(Y,Z) C(X) + C(X)C(Y)C(Z) $$ Substituting the expression (1) and (2) for the connected correlations of one and two variables then yields: $$C(X,Y,Z)=E(XYZ) - E(XY) E(Z) - E(XZ)E(Y) - E(YZ)E(X) + 2E(X)E(Y)E(Z)$$
Why is correlation only defined between two variables?
Correlations between multiple variables can be defined as a joint cumulant. In physics we call this a "connected correlation function". In statistics, one would call these quantities covariances inste
Why is correlation only defined between two variables? Correlations between multiple variables can be defined as a joint cumulant. In physics we call this a "connected correlation function". In statistics, one would call these quantities covariances instead of correlations as it's customary to normalize correlations so that they are between -1 and 1. The connected correlation between $n$ variables is an effect that's due to all $n$ variables together that cannot be attributed to correlations between variables in proper subsets of the $n$ variables. Connected correlation functions are multilinear functions of their arguments. The expectation value of any arbitrary product of random variables can be written as a sum of products of connected correlations involving all the ways one can partition the set of variables into disjoint subsets. This property yields a recursion for the joint correlation function, so it can be used to define it. If we denote connected correlations as $C(X_1,X_2,\ldots,X_n)$, then we have: $$C(X) = E(X)\tag{1}$$ which follows trivially from the recursion. For two variables $X$ and $Y$ we have that the connected correlation $C(X,Y)$ is the covariance between $X$ and $Y$. This also follows easily from the recursion: $$ E(XY) = C(X,Y) + C(X) C(Y) $$ Using (1) we then get: $$ C(X,Y)=E(XY) - E(X) E(Y)\tag{2} $$ For 3 variables $X$, $Y$ and $Z$, the recursion is: $$ E(XYZ) = C(X,Y,Z) + C(X,Y) C(Z) + C(X,Z) C(Y)+C(Y,Z) C(X) + C(X)C(Y)C(Z) $$ Substituting the expression (1) and (2) for the connected correlations of one and two variables then yields: $$C(X,Y,Z)=E(XYZ) - E(XY) E(Z) - E(XZ)E(Y) - E(YZ)E(X) + 2E(X)E(Y)E(Z)$$
Why is correlation only defined between two variables? Correlations between multiple variables can be defined as a joint cumulant. In physics we call this a "connected correlation function". In statistics, one would call these quantities covariances inste
15,080
Why is correlation only defined between two variables?
Main Answer Why is correlation only defined between two variables? Your professor likely meant Pearson's correlation as presented in the standard material you are required to learn. It is a definition used in the context of conventional (or at least introductory) statistics, and is certainly defined between only two random variables in that context. But let us explore this question beyond your course. Ancillary Answer Like many things, there is a tapestry of historical events that will never be fully uncovered. Auguste Bravais was the first person I am aware of to calculate what we would now think of Pearson's correlation on a sample, but to him they were merely cosines of the angles between error vectors. A little later came Francis Galton who laboured on the intuition of "co-relation" and his tabular calculations (he was not a skilled mathematician, purportedly) and was an inspiration to Karl Pearson who developed the formalism we recognize today. Why did these men consider only consider correlation to be between pairs of variables? I don't know. Even more restricting, Francis Galton appears to have only considered positive correlation which may have been due to his interest in biometrics which (by chance) were positively correlated (e.g. height and weight). Here are my speculations (not to be confused with fact). Pairwise comparisons may be more intuitive for many people (though perhaps not all). Related to the first point, much of mathematics is riddled with binary operations. While multiary algebras and other fascinating creatures live in the world universal algebras, it is not on most people's radar. People develop tools with what they know about. Pearson's correlation interoperates nicely with linear algebra, and linear algebra is itself computationally feasible on modest problems in a pre-PC era. A computational sea monster awaits those that stray too far from pairwise decomposability: exponential complexity. Once you have posited some multiary function $f$, you quickly run into the problem that for $n$ possible operands there are $2^n$ possible inputs to the function (if you include inputting an empty set of variables, sometimes taken to be $f(\emptyset)=0$ or $f(\emptyset)=1$ depending on context). Making a number of statistical estimates that grows exponentially with the number of variables quickly gets out of hand, and it can take considerably more effort to think about what selection of subsets of the powerset of variables are needed for your problem. The multivariate distribution is often-applicable, and in the context pairwise comparisons are enough. Want a multivariate normal distribution but only have a vector of IID standard normal variables? No problem. Just apply a linear transformation. Plus Isserlis' theorem tells us that the higher mixed moments are either zero or decomposable into pairwise mixed moments. Combine this with Proposition 7.1.3 from Athreya and Lahiri 2006 and you'll realize that correlation tells you everything about statistical dependence of join normal distributions. To an extent we can also deny the claim that we don't consider correlations of multiple variables, although I will side step the argument about what the word "correlation" ought to denote. As exemplified by other answers here (+1 to all I have seen so far), we actually do consider multiary functions of random variables that might be considered (in some sense) "co-relation". Clearly these functions are different, and thus selecting among them should be informed by what it is you want to quantify. Examples One thing I like to think about is what data sets minimize or maximize such statistics. And one way to do that is to create examples. Let me share some with you. While the math in many cases is not restricted to three variables, I will keep to three for now just so that 3D scatterplots can be easily utilized. The following were found using gradient-based minimization (RMSProp). I did not check the functions for the existence of local minima, and I only reported the value of the objective to four decimal places. Three-Point Correlation This notion is from msuzen's post, which was new to me (+1). Minimal Maximal Plot Score -1.0000 3.0000 The minimal data set appears to be 'nearly' a line, but with some jittering. The maximal data set is a line. Coskewness The coskewness is the standardized mixed product moment of three variables. It is a trilinear extension of the bilinear Pearson product-moment correlation coefficient. This notion was explicitly mentioned by Sextus, and is a standardized cumulant of the sort shown by Count. The tensorial aspect is nicely shown by whuber. Minimal Maximal Plot Score -1.0000 1.0000 Multiple lines stretch out from the centroid into specific octants depending on the signum of $x_i y_i z_i$. Reflections $-x_i y_i z_i$ are avoided because of the odd symmetry: $\mathbb{E}[XYZ] = -\mathbb{E}[XYZ] = 0$. This will always be true for odd mixed moments. Partial Correlation With partial correlation we are computing the correlation between the residuals of $X$ as a function of $Z$ and the residuals of $Y$ as a function of $Z$. I noticed Tim also mentioned this statistic. While in some of my own projects I consider the correlations of residuals of non-linear functions to be "partial correlations", it seems this is idiosyncratic to me. So for convention and and clarity, let us use the following linear equations: $$Y = Z - 2$$ $$X = -3Z + 4$$ Minimal Maximal Plot Score -1.0000 1.0000 Appearances can be deceiving. In both plots the data superficially appear to be spherical blobs, but actually all of the data approximately sits on a plane. Looking colinear to these planes, the data would appear to just follow a line. Taylor's Multi-Way Correlation Coefficient Taylor 2020 suggested the coefficient $$\operatorname{mcor}[\vec x_1, \cdots, \vec x_n] \triangleq \frac{1}{\sqrt{d}} \sqrt{\frac{1}{d-1} \sum_{i=1}^d (\lambda_i - \bar \lambda)^2}$$ where $\lambda_i$ is the $i$th eigenvalue of the correlation matrix on $\vec x_1, \cdots, \vec x_n$ and $\bar \lambda$ is the mean eigenvalue of the same correlation matrix. This approach echos Sextus in considering the eigenvalues of a covariance matrix. Minimal Maximal Plot Score 9.7931e-04 1.0000 The minimal data set is a spherical cloud of points. The maximal data set is a line. Wang-Zheng's Unsigned Correlation Coefficient Wang & Zheng 2014 proposed $$\operatorname{UCC}[X_1, \cdots, X_n] \triangleq 1 - \det R_{\vec x \vec x}$$ where $R_{\vec x \vec x}$ is the correlation matrix on those variables. Minimal Maximal Plot Score 3.7551e-06 1.0000 The minimal data set appears to be a spherical cloud of points. The maximal cloud appears to be nearly a plane except for a couple deviating points. Coefficient of Multiple Correlation ($R^2$) Sextus mentioned the multiple correlation coefficient. As noted by dipetkov, we must assume something asymmetric: Minimal Maximal Plot Score 6.8780e-20 1.0000 The minimal data set is a spherical point cloud. The maximal is a data set which sits on a plane, and appears somewhat bimodal in distribution. Variance Inflation Factor Sextus mentioned the variance inflation factor. As with multiple correlation, we assume that $Y$ is predicted linearly from $X$ and $Z$: Minimal Maximal Plot Score 1.0000 Unbounded! I stopped at 71.1589. The minimal data set is a spherical point cloud. In the maximal case it isn't really maximal, but rather unbounded. In this unbounded case the data appears to be approaching a distribution similar to what maximized the multiple correlation coefficient, but I stopped before numerical stability collapsed. User1865345's Suggestion User1865345 suggested we consider something of the form: $$R[X,Y]R[X,Z]$$ Minimal Maximal Plot Score -1.0000 1.0000 Both the minimal and maximal cases are data sets in the form of a line with a little bit of jitter.
Why is correlation only defined between two variables?
Main Answer Why is correlation only defined between two variables? Your professor likely meant Pearson's correlation as presented in the standard material you are required to learn. It is a definiti
Why is correlation only defined between two variables? Main Answer Why is correlation only defined between two variables? Your professor likely meant Pearson's correlation as presented in the standard material you are required to learn. It is a definition used in the context of conventional (or at least introductory) statistics, and is certainly defined between only two random variables in that context. But let us explore this question beyond your course. Ancillary Answer Like many things, there is a tapestry of historical events that will never be fully uncovered. Auguste Bravais was the first person I am aware of to calculate what we would now think of Pearson's correlation on a sample, but to him they were merely cosines of the angles between error vectors. A little later came Francis Galton who laboured on the intuition of "co-relation" and his tabular calculations (he was not a skilled mathematician, purportedly) and was an inspiration to Karl Pearson who developed the formalism we recognize today. Why did these men consider only consider correlation to be between pairs of variables? I don't know. Even more restricting, Francis Galton appears to have only considered positive correlation which may have been due to his interest in biometrics which (by chance) were positively correlated (e.g. height and weight). Here are my speculations (not to be confused with fact). Pairwise comparisons may be more intuitive for many people (though perhaps not all). Related to the first point, much of mathematics is riddled with binary operations. While multiary algebras and other fascinating creatures live in the world universal algebras, it is not on most people's radar. People develop tools with what they know about. Pearson's correlation interoperates nicely with linear algebra, and linear algebra is itself computationally feasible on modest problems in a pre-PC era. A computational sea monster awaits those that stray too far from pairwise decomposability: exponential complexity. Once you have posited some multiary function $f$, you quickly run into the problem that for $n$ possible operands there are $2^n$ possible inputs to the function (if you include inputting an empty set of variables, sometimes taken to be $f(\emptyset)=0$ or $f(\emptyset)=1$ depending on context). Making a number of statistical estimates that grows exponentially with the number of variables quickly gets out of hand, and it can take considerably more effort to think about what selection of subsets of the powerset of variables are needed for your problem. The multivariate distribution is often-applicable, and in the context pairwise comparisons are enough. Want a multivariate normal distribution but only have a vector of IID standard normal variables? No problem. Just apply a linear transformation. Plus Isserlis' theorem tells us that the higher mixed moments are either zero or decomposable into pairwise mixed moments. Combine this with Proposition 7.1.3 from Athreya and Lahiri 2006 and you'll realize that correlation tells you everything about statistical dependence of join normal distributions. To an extent we can also deny the claim that we don't consider correlations of multiple variables, although I will side step the argument about what the word "correlation" ought to denote. As exemplified by other answers here (+1 to all I have seen so far), we actually do consider multiary functions of random variables that might be considered (in some sense) "co-relation". Clearly these functions are different, and thus selecting among them should be informed by what it is you want to quantify. Examples One thing I like to think about is what data sets minimize or maximize such statistics. And one way to do that is to create examples. Let me share some with you. While the math in many cases is not restricted to three variables, I will keep to three for now just so that 3D scatterplots can be easily utilized. The following were found using gradient-based minimization (RMSProp). I did not check the functions for the existence of local minima, and I only reported the value of the objective to four decimal places. Three-Point Correlation This notion is from msuzen's post, which was new to me (+1). Minimal Maximal Plot Score -1.0000 3.0000 The minimal data set appears to be 'nearly' a line, but with some jittering. The maximal data set is a line. Coskewness The coskewness is the standardized mixed product moment of three variables. It is a trilinear extension of the bilinear Pearson product-moment correlation coefficient. This notion was explicitly mentioned by Sextus, and is a standardized cumulant of the sort shown by Count. The tensorial aspect is nicely shown by whuber. Minimal Maximal Plot Score -1.0000 1.0000 Multiple lines stretch out from the centroid into specific octants depending on the signum of $x_i y_i z_i$. Reflections $-x_i y_i z_i$ are avoided because of the odd symmetry: $\mathbb{E}[XYZ] = -\mathbb{E}[XYZ] = 0$. This will always be true for odd mixed moments. Partial Correlation With partial correlation we are computing the correlation between the residuals of $X$ as a function of $Z$ and the residuals of $Y$ as a function of $Z$. I noticed Tim also mentioned this statistic. While in some of my own projects I consider the correlations of residuals of non-linear functions to be "partial correlations", it seems this is idiosyncratic to me. So for convention and and clarity, let us use the following linear equations: $$Y = Z - 2$$ $$X = -3Z + 4$$ Minimal Maximal Plot Score -1.0000 1.0000 Appearances can be deceiving. In both plots the data superficially appear to be spherical blobs, but actually all of the data approximately sits on a plane. Looking colinear to these planes, the data would appear to just follow a line. Taylor's Multi-Way Correlation Coefficient Taylor 2020 suggested the coefficient $$\operatorname{mcor}[\vec x_1, \cdots, \vec x_n] \triangleq \frac{1}{\sqrt{d}} \sqrt{\frac{1}{d-1} \sum_{i=1}^d (\lambda_i - \bar \lambda)^2}$$ where $\lambda_i$ is the $i$th eigenvalue of the correlation matrix on $\vec x_1, \cdots, \vec x_n$ and $\bar \lambda$ is the mean eigenvalue of the same correlation matrix. This approach echos Sextus in considering the eigenvalues of a covariance matrix. Minimal Maximal Plot Score 9.7931e-04 1.0000 The minimal data set is a spherical cloud of points. The maximal data set is a line. Wang-Zheng's Unsigned Correlation Coefficient Wang & Zheng 2014 proposed $$\operatorname{UCC}[X_1, \cdots, X_n] \triangleq 1 - \det R_{\vec x \vec x}$$ where $R_{\vec x \vec x}$ is the correlation matrix on those variables. Minimal Maximal Plot Score 3.7551e-06 1.0000 The minimal data set appears to be a spherical cloud of points. The maximal cloud appears to be nearly a plane except for a couple deviating points. Coefficient of Multiple Correlation ($R^2$) Sextus mentioned the multiple correlation coefficient. As noted by dipetkov, we must assume something asymmetric: Minimal Maximal Plot Score 6.8780e-20 1.0000 The minimal data set is a spherical point cloud. The maximal is a data set which sits on a plane, and appears somewhat bimodal in distribution. Variance Inflation Factor Sextus mentioned the variance inflation factor. As with multiple correlation, we assume that $Y$ is predicted linearly from $X$ and $Z$: Minimal Maximal Plot Score 1.0000 Unbounded! I stopped at 71.1589. The minimal data set is a spherical point cloud. In the maximal case it isn't really maximal, but rather unbounded. In this unbounded case the data appears to be approaching a distribution similar to what maximized the multiple correlation coefficient, but I stopped before numerical stability collapsed. User1865345's Suggestion User1865345 suggested we consider something of the form: $$R[X,Y]R[X,Z]$$ Minimal Maximal Plot Score -1.0000 1.0000 Both the minimal and maximal cases are data sets in the form of a line with a little bit of jitter.
Why is correlation only defined between two variables? Main Answer Why is correlation only defined between two variables? Your professor likely meant Pearson's correlation as presented in the standard material you are required to learn. It is a definiti
15,081
Why is correlation only defined between two variables?
One of the interpretations of Pearson's correlation coefficient is the proportionate reduction of error (PRE): Assume a variable vector $y$, about which nothing further is known. Then, if you have to predict a missing $y_i$, your best estimator would be the arithmetic mean $\bar{y}$, and the error would be $E_1 = SS_{total} = \sum_{i=1}^n(y_i - \bar{y})^2$. Assume now that you have a second data set $x$, which can be used to predict $y$, in the simplest case (but without limitation of generality) by linear regression $\hat{y}_i = a + b x_i$. Then the error becomes $E_2 = SS_{residual} = \sum_{i=1}^n(y_i - \hat{y}_i)^2$, and the coefficient of determination (fraction of variability of $y$ that is explained by $x$) is $r^2 = \frac{E_1 - E_2}{E_1} = 1 - \frac{E_2}{E_1}$. The $R^2$ mentioned by others is a generalisation of this approach for several explaining variables. There are other correlation coefficients with PRE-interpretation for non-cardinal data (Guttman's λ, Freeman's θ, Wilson's e, the point-biserial correlation, $\eta^2$). See Freeman, L.C.: Elementary applied statistics, New York, London, Sidney (John Wiley and Sons) 1965 for a very readable introduction. Thus, you should think about what PRE is in your particular case to construct a suitable correlation coefficient.
Why is correlation only defined between two variables?
One of the interpretations of Pearson's correlation coefficient is the proportionate reduction of error (PRE): Assume a variable vector $y$, about which nothing further is known. Then, if you have to
Why is correlation only defined between two variables? One of the interpretations of Pearson's correlation coefficient is the proportionate reduction of error (PRE): Assume a variable vector $y$, about which nothing further is known. Then, if you have to predict a missing $y_i$, your best estimator would be the arithmetic mean $\bar{y}$, and the error would be $E_1 = SS_{total} = \sum_{i=1}^n(y_i - \bar{y})^2$. Assume now that you have a second data set $x$, which can be used to predict $y$, in the simplest case (but without limitation of generality) by linear regression $\hat{y}_i = a + b x_i$. Then the error becomes $E_2 = SS_{residual} = \sum_{i=1}^n(y_i - \hat{y}_i)^2$, and the coefficient of determination (fraction of variability of $y$ that is explained by $x$) is $r^2 = \frac{E_1 - E_2}{E_1} = 1 - \frac{E_2}{E_1}$. The $R^2$ mentioned by others is a generalisation of this approach for several explaining variables. There are other correlation coefficients with PRE-interpretation for non-cardinal data (Guttman's λ, Freeman's θ, Wilson's e, the point-biserial correlation, $\eta^2$). See Freeman, L.C.: Elementary applied statistics, New York, London, Sidney (John Wiley and Sons) 1965 for a very readable introduction. Thus, you should think about what PRE is in your particular case to construct a suitable correlation coefficient.
Why is correlation only defined between two variables? One of the interpretations of Pearson's correlation coefficient is the proportionate reduction of error (PRE): Assume a variable vector $y$, about which nothing further is known. Then, if you have to
15,082
A term for "number of columns" of a matrix
There is a concept of wide and narrow data, so maybe you could use the term „width“ for the number of columns after you define it in order to avoid the ambiguity.
A term for "number of columns" of a matrix
There is a concept of wide and narrow data, so maybe you could use the term „width“ for the number of columns after you define it in order to avoid the ambiguity.
A term for "number of columns" of a matrix There is a concept of wide and narrow data, so maybe you could use the term „width“ for the number of columns after you define it in order to avoid the ambiguity.
A term for "number of columns" of a matrix There is a concept of wide and narrow data, so maybe you could use the term „width“ for the number of columns after you define it in order to avoid the ambiguity.
15,083
A term for "number of columns" of a matrix
Let's review your objectives: You want a short, meaningful term. You want it to be memorable and readable, rather than some clunky abstract mathematical or computerese construction like "let $\mathbb{A}\in\operatorname{Mat}(n,p)$" or even "$\mathbb{A}\in\mathbb{R}^{n\times p}.$" You want to be able to specify the number of columns explicitly, so you can distinguish (say) 3-column matrices from 2-column matrices or $p$-column matrices from $p+1$-column matrices. You want it function as a noun rather than an adjectival phrase; that is, it should read like "$\mathbb A$ is a $p$-column matrix" rather than "the column count of $\mathbb A$ is $p$." Evidently, even a short phrase like "$p$-column matrix" is too much! As others have remarked, you're in the domain of creating your own terminology. However, "columnity" (which has been proposed) has a grotesque and non-English aspect, albeit being little briefer. If I were in this position, at the outset of the document I would introduce a term and define it, perhaps like this: Because we will frequently need to refer to the number of columns in a matrix, let us say that a $p-$matrix is any matrix with exactly $p$ columns. That seems to meet all the objectives. It's hard to imagine anything simpler, short of a mathematical notation (which violates objective $(2)$). It also is consistent with long-standing mathematical terminology, which includes well-known terms like "symmetric matrix," "real matrix," "transition matrix," "rank-$p$ matrix," etc.
A term for "number of columns" of a matrix
Let's review your objectives: You want a short, meaningful term. You want it to be memorable and readable, rather than some clunky abstract mathematical or computerese construction like "let $\mathbb
A term for "number of columns" of a matrix Let's review your objectives: You want a short, meaningful term. You want it to be memorable and readable, rather than some clunky abstract mathematical or computerese construction like "let $\mathbb{A}\in\operatorname{Mat}(n,p)$" or even "$\mathbb{A}\in\mathbb{R}^{n\times p}.$" You want to be able to specify the number of columns explicitly, so you can distinguish (say) 3-column matrices from 2-column matrices or $p$-column matrices from $p+1$-column matrices. You want it function as a noun rather than an adjectival phrase; that is, it should read like "$\mathbb A$ is a $p$-column matrix" rather than "the column count of $\mathbb A$ is $p$." Evidently, even a short phrase like "$p$-column matrix" is too much! As others have remarked, you're in the domain of creating your own terminology. However, "columnity" (which has been proposed) has a grotesque and non-English aspect, albeit being little briefer. If I were in this position, at the outset of the document I would introduce a term and define it, perhaps like this: Because we will frequently need to refer to the number of columns in a matrix, let us say that a $p-$matrix is any matrix with exactly $p$ columns. That seems to meet all the objectives. It's hard to imagine anything simpler, short of a mathematical notation (which violates objective $(2)$). It also is consistent with long-standing mathematical terminology, which includes well-known terms like "symmetric matrix," "real matrix," "transition matrix," "rank-$p$ matrix," etc.
A term for "number of columns" of a matrix Let's review your objectives: You want a short, meaningful term. You want it to be memorable and readable, rather than some clunky abstract mathematical or computerese construction like "let $\mathbb
15,084
A term for "number of columns" of a matrix
Personally I would denote the matrix as $$X \in \mathbb{R}^{n \times p}$$ and use $p$ as a reference (assuming your matrix is composed of real values!). Also note that the notation p >> n is quite widely used to describe the 'short and wide' datasets, e.g. datasets where the number of rows (observations) is significantly lower than number of columns (features). There is an area of Statistics known has 'High-dimensional statistics' that deals with these kinds of problems.
A term for "number of columns" of a matrix
Personally I would denote the matrix as $$X \in \mathbb{R}^{n \times p}$$ and use $p$ as a reference (assuming your matrix is composed of real values!). Also note that the notation p >> n is quite wid
A term for "number of columns" of a matrix Personally I would denote the matrix as $$X \in \mathbb{R}^{n \times p}$$ and use $p$ as a reference (assuming your matrix is composed of real values!). Also note that the notation p >> n is quite widely used to describe the 'short and wide' datasets, e.g. datasets where the number of rows (observations) is significantly lower than number of columns (features). There is an area of Statistics known has 'High-dimensional statistics' that deals with these kinds of problems.
A term for "number of columns" of a matrix Personally I would denote the matrix as $$X \in \mathbb{R}^{n \times p}$$ and use $p$ as a reference (assuming your matrix is composed of real values!). Also note that the notation p >> n is quite wid
15,085
A term for "number of columns" of a matrix
I propose you do as Tukey would have done and invent a word. It is of course OK to define new terminology as long as we are explicit about it. As you say it might not gain immediate traction, but it would still work within the scope of your paper. My personal suggestion is columnity [n.] of A: the extent to which A is columnar An edit: Thinking a bit about my light-hearted suggestion here I felt I should also add that width is my preference. It's short and sweet and follows the excellent tip in Orwell's Politics and the English language to never use a long word where a short one will do.
A term for "number of columns" of a matrix
I propose you do as Tukey would have done and invent a word. It is of course OK to define new terminology as long as we are explicit about it. As you say it might not gain immediate traction, but it w
A term for "number of columns" of a matrix I propose you do as Tukey would have done and invent a word. It is of course OK to define new terminology as long as we are explicit about it. As you say it might not gain immediate traction, but it would still work within the scope of your paper. My personal suggestion is columnity [n.] of A: the extent to which A is columnar An edit: Thinking a bit about my light-hearted suggestion here I felt I should also add that width is my preference. It's short and sweet and follows the excellent tip in Orwell's Politics and the English language to never use a long word where a short one will do.
A term for "number of columns" of a matrix I propose you do as Tukey would have done and invent a word. It is of course OK to define new terminology as long as we are explicit about it. As you say it might not gain immediate traction, but it w
15,086
A term for "number of columns" of a matrix
I like "width", as suggested by aivanov. It is difficult to be more specific, without being longer and without using several words. If several words are ok, then we are back to "number of columns". An alternative is to reformulate: Instead of saying: $A$ is a matrix of width 3. or The number of columns of $A$ is 3. why not just say $A$ has 3 columns.
A term for "number of columns" of a matrix
I like "width", as suggested by aivanov. It is difficult to be more specific, without being longer and without using several words. If several words are ok, then we are back to "number of columns".
A term for "number of columns" of a matrix I like "width", as suggested by aivanov. It is difficult to be more specific, without being longer and without using several words. If several words are ok, then we are back to "number of columns". An alternative is to reformulate: Instead of saying: $A$ is a matrix of width 3. or The number of columns of $A$ is 3. why not just say $A$ has 3 columns.
A term for "number of columns" of a matrix I like "width", as suggested by aivanov. It is difficult to be more specific, without being longer and without using several words. If several words are ok, then we are back to "number of columns".
15,087
A term for "number of columns" of a matrix
It's not clear why it's important to have only a single-word term. I'd say that for most purposes don't be afraid of three shortish words: "number of columns"; the very term you began with, which served to perfectly convey the idea you asked about. It is a mere 5 syllables, it's not a strain to say or write. A term consisting of just a few common words is likely to be less of an intellectual effort to grasp on the fly than one longish or unfamiliar one. There may well be four or five terms that might serve, but if I was only writing it a few times, I would feel the strong inclination to go back and edit such a term out and replace it with "number of columns". If I would need to write about a specific case many times, I'd start with something like "Let $X$ be an $n\times p$ matrix" and then refer to $p$ thereafter; or if I had to refer to the number of columns of many matrices, to have a notation like "denote the number of columns of a matrix $A$ as $c_A$", or something similar as suited the circumstances.
A term for "number of columns" of a matrix
It's not clear why it's important to have only a single-word term. I'd say that for most purposes don't be afraid of three shortish words: "number of columns"; the very term you began with, which serv
A term for "number of columns" of a matrix It's not clear why it's important to have only a single-word term. I'd say that for most purposes don't be afraid of three shortish words: "number of columns"; the very term you began with, which served to perfectly convey the idea you asked about. It is a mere 5 syllables, it's not a strain to say or write. A term consisting of just a few common words is likely to be less of an intellectual effort to grasp on the fly than one longish or unfamiliar one. There may well be four or five terms that might serve, but if I was only writing it a few times, I would feel the strong inclination to go back and edit such a term out and replace it with "number of columns". If I would need to write about a specific case many times, I'd start with something like "Let $X$ be an $n\times p$ matrix" and then refer to $p$ thereafter; or if I had to refer to the number of columns of many matrices, to have a notation like "denote the number of columns of a matrix $A$ as $c_A$", or something similar as suited the circumstances.
A term for "number of columns" of a matrix It's not clear why it's important to have only a single-word term. I'd say that for most purposes don't be afraid of three shortish words: "number of columns"; the very term you began with, which serv
15,088
A term for "number of columns" of a matrix
It seems like mostly a specific language (English) problem. In German language this would be much less problematic. The term 'spaltenanzahl' is not a strange word and regularly used. So you may consider introducing 'column-count' or 'column count' (while column-number would be ambiguous), or accept 'number of columns' as not that complex after all (and can often be written simpler with other sentence constructions e.g. 'matrix $M$ has $w$ columns'). Some background on the article and examples of sentences would help to look for different terms. One could use width and length or (as Sylvester, origin of the term matrix, did use) breadth and depth. Maybe based on what the matrix actually presents (e.g. system of equations, a polynomial, a vector space, etc.) other terms could be used. Depending on your article background (or maybe no, independent from the public for your article, maybe only if you do something entirely new) I would advise to not use any newly invented term, and neither use some existing term (which must be an archaic term). You have to ask yourself whether the poverty in the English language, not containing a simple synonym for the German term spaltenanzahl, is worth introducing something fancy that may only be confusing.
A term for "number of columns" of a matrix
It seems like mostly a specific language (English) problem. In German language this would be much less problematic. The term 'spaltenanzahl' is not a strange word and regularly used. So you may consid
A term for "number of columns" of a matrix It seems like mostly a specific language (English) problem. In German language this would be much less problematic. The term 'spaltenanzahl' is not a strange word and regularly used. So you may consider introducing 'column-count' or 'column count' (while column-number would be ambiguous), or accept 'number of columns' as not that complex after all (and can often be written simpler with other sentence constructions e.g. 'matrix $M$ has $w$ columns'). Some background on the article and examples of sentences would help to look for different terms. One could use width and length or (as Sylvester, origin of the term matrix, did use) breadth and depth. Maybe based on what the matrix actually presents (e.g. system of equations, a polynomial, a vector space, etc.) other terms could be used. Depending on your article background (or maybe no, independent from the public for your article, maybe only if you do something entirely new) I would advise to not use any newly invented term, and neither use some existing term (which must be an archaic term). You have to ask yourself whether the poverty in the English language, not containing a simple synonym for the German term spaltenanzahl, is worth introducing something fancy that may only be confusing.
A term for "number of columns" of a matrix It seems like mostly a specific language (English) problem. In German language this would be much less problematic. The term 'spaltenanzahl' is not a strange word and regularly used. So you may consid
15,089
A term for "number of columns" of a matrix
I always recommend avoiding to talk about matrices at all. Most applications that deal with matrices are in principle not interested in matrices at all, but rather in linear mappings between vector spaces. The basis-expanded representation of a mapping $\mathbb{R}^n \to \mathbb{R}^m$ is an $n\times m$ matrix, thus the column-count $n$ is the domain dimension of the mapping. Likewise, the row count would be the codomain dimension. These aren't single words, but they're reasonably short yet precise.
A term for "number of columns" of a matrix
I always recommend avoiding to talk about matrices at all. Most applications that deal with matrices are in principle not interested in matrices at all, but rather in linear mappings between vector sp
A term for "number of columns" of a matrix I always recommend avoiding to talk about matrices at all. Most applications that deal with matrices are in principle not interested in matrices at all, but rather in linear mappings between vector spaces. The basis-expanded representation of a mapping $\mathbb{R}^n \to \mathbb{R}^m$ is an $n\times m$ matrix, thus the column-count $n$ is the domain dimension of the mapping. Likewise, the row count would be the codomain dimension. These aren't single words, but they're reasonably short yet precise.
A term for "number of columns" of a matrix I always recommend avoiding to talk about matrices at all. Most applications that deal with matrices are in principle not interested in matrices at all, but rather in linear mappings between vector sp
15,090
A term for "number of columns" of a matrix
go for width \ height as mentioned its pretty clear what you mean and even a child knows what those words mean (providing the array is always represented from the same viewpoint) Of course if you go into arrays of more than 3 dimensions (height, width, depth) it gets a little tricky and is probably better to use matrix notation
A term for "number of columns" of a matrix
go for width \ height as mentioned its pretty clear what you mean and even a child knows what those words mean (providing the array is always represented from the same viewpoint) Of course if you go i
A term for "number of columns" of a matrix go for width \ height as mentioned its pretty clear what you mean and even a child knows what those words mean (providing the array is always represented from the same viewpoint) Of course if you go into arrays of more than 3 dimensions (height, width, depth) it gets a little tricky and is probably better to use matrix notation
A term for "number of columns" of a matrix go for width \ height as mentioned its pretty clear what you mean and even a child knows what those words mean (providing the array is always represented from the same viewpoint) Of course if you go i
15,091
A term for "number of columns" of a matrix
There does exist and English word columnarity which means the property of being columnar. So saying a matrix of columnarity 3 would seem quite natural.
A term for "number of columns" of a matrix
There does exist and English word columnarity which means the property of being columnar. So saying a matrix of columnarity 3 would seem quite natural.
A term for "number of columns" of a matrix There does exist and English word columnarity which means the property of being columnar. So saying a matrix of columnarity 3 would seem quite natural.
A term for "number of columns" of a matrix There does exist and English word columnarity which means the property of being columnar. So saying a matrix of columnarity 3 would seem quite natural.
15,092
A term for "number of columns" of a matrix
I am guessing that you use your matrix for representing data. Usually, columns represent the different features and rows are different data points, as the data store in the figure below (ref). This then extends to the the dimension of useful matrices, e. g. for mixing these features into a new dimension. In that context, the number of columns is the number of dimensions of your feature space, that is, simply dimensionality.
A term for "number of columns" of a matrix
I am guessing that you use your matrix for representing data. Usually, columns represent the different features and rows are different data points, as the data store in the figure below (ref). This t
A term for "number of columns" of a matrix I am guessing that you use your matrix for representing data. Usually, columns represent the different features and rows are different data points, as the data store in the figure below (ref). This then extends to the the dimension of useful matrices, e. g. for mixing these features into a new dimension. In that context, the number of columns is the number of dimensions of your feature space, that is, simply dimensionality.
A term for "number of columns" of a matrix I am guessing that you use your matrix for representing data. Usually, columns represent the different features and rows are different data points, as the data store in the figure below (ref). This t
15,093
Why do we need an estimator to be consistent?
If the estimator is not consistent, it won't converge to the true value in probability. In other words, there is always a probability that your estimator and true value will have a difference, no matter how many data points you have. This is actually bad, because even if you collect immense amount of data, your estimate will always have a positive probability of being some $\epsilon>0$ different from the true value. Practically, you can consider this situation as if you're using an estimator of a quantity such that even surveying all the population, instead of a small sample of it, won't help you.
Why do we need an estimator to be consistent?
If the estimator is not consistent, it won't converge to the true value in probability. In other words, there is always a probability that your estimator and true value will have a difference, no matt
Why do we need an estimator to be consistent? If the estimator is not consistent, it won't converge to the true value in probability. In other words, there is always a probability that your estimator and true value will have a difference, no matter how many data points you have. This is actually bad, because even if you collect immense amount of data, your estimate will always have a positive probability of being some $\epsilon>0$ different from the true value. Practically, you can consider this situation as if you're using an estimator of a quantity such that even surveying all the population, instead of a small sample of it, won't help you.
Why do we need an estimator to be consistent? If the estimator is not consistent, it won't converge to the true value in probability. In other words, there is always a probability that your estimator and true value will have a difference, no matt
15,094
Why do we need an estimator to be consistent?
Consider $n = 10\,000$ observations from the standard Cauchy distribution, which is the same as Student's t distribution with 1 degree of freedom. The tails of this distribution are sufficiently heavy that it has no mean; the distribution is centered at its median $\eta = 0.$ A sequence of sample means $A_j = \frac 1j \sum_{i=1}^j X_i$ is not consistent for the center of the Cauchy distribution. Roughly speaking, the difficulty is that very extreme observations $X_i$ (positive or negative) occur with sufficient regularity that there is no chance for $A_j$ to converge to $\eta = 0.$ (The $A_j$ are not just slow to converge, they don't ever converge. The distribution of $A_j$ is again standard Cauchy [proof].) By contrast, at any one step in a continuing sampling process, about half of the observations $X_i$ will lie on either side of $\eta,$ so that the sequence $H_j$ of sample medians does converge to $\eta.$ This lack of convergence of $A_j$ and convergence of $H_j$ is illustrated by the following simulation. set.seed(2019) # for reproducibility n = 10000; x = rt(n, 1); j = 1:n a = cumsum(x)/j h = numeric(n) for (i in 1:n) { h[i] = median(x[1:i]) } par(mfrow=c(1, 2)) plot(j, a, type="l", ylim=c(-5, 5), lwd=2, main="Trace of Sample Mean") abline(h=0, col="green2") k = j[abs(x)>1000] abline(v=k, col="red", lty="dotted") plot(j, h, type="l", ylim=c(-5, 5), lwd=2, main="Trace of Sample Median") abline(h=0, col="green2") par(mfrow=c(1, 1)) Here is a list of steps at which $|X_i| > 1000.$ You can see the effect of some of these extreme observations on the running averages in the plot at left (at the vertical red dotted lines). k = j[abs(x)>1000] rbind(k, round(x[k])) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] k 291 898 1293 1602 2547 5472 6079 9158 -5440 2502 5421 -2231 1635 -2644 -10194 -3137 Consistency in important in estimation: In sampling from a Cauchy population, the sample mean of a sample of $n = 10\,000$ observations is no better for estimating the center $\eta$ than just one observation. By contrast, the consistent sample median converges to $\eta,$ so larger samples produce better estimates.
Why do we need an estimator to be consistent?
Consider $n = 10\,000$ observations from the standard Cauchy distribution, which is the same as Student's t distribution with 1 degree of freedom. The tails of this distribution are sufficiently heavy
Why do we need an estimator to be consistent? Consider $n = 10\,000$ observations from the standard Cauchy distribution, which is the same as Student's t distribution with 1 degree of freedom. The tails of this distribution are sufficiently heavy that it has no mean; the distribution is centered at its median $\eta = 0.$ A sequence of sample means $A_j = \frac 1j \sum_{i=1}^j X_i$ is not consistent for the center of the Cauchy distribution. Roughly speaking, the difficulty is that very extreme observations $X_i$ (positive or negative) occur with sufficient regularity that there is no chance for $A_j$ to converge to $\eta = 0.$ (The $A_j$ are not just slow to converge, they don't ever converge. The distribution of $A_j$ is again standard Cauchy [proof].) By contrast, at any one step in a continuing sampling process, about half of the observations $X_i$ will lie on either side of $\eta,$ so that the sequence $H_j$ of sample medians does converge to $\eta.$ This lack of convergence of $A_j$ and convergence of $H_j$ is illustrated by the following simulation. set.seed(2019) # for reproducibility n = 10000; x = rt(n, 1); j = 1:n a = cumsum(x)/j h = numeric(n) for (i in 1:n) { h[i] = median(x[1:i]) } par(mfrow=c(1, 2)) plot(j, a, type="l", ylim=c(-5, 5), lwd=2, main="Trace of Sample Mean") abline(h=0, col="green2") k = j[abs(x)>1000] abline(v=k, col="red", lty="dotted") plot(j, h, type="l", ylim=c(-5, 5), lwd=2, main="Trace of Sample Median") abline(h=0, col="green2") par(mfrow=c(1, 1)) Here is a list of steps at which $|X_i| > 1000.$ You can see the effect of some of these extreme observations on the running averages in the plot at left (at the vertical red dotted lines). k = j[abs(x)>1000] rbind(k, round(x[k])) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] k 291 898 1293 1602 2547 5472 6079 9158 -5440 2502 5421 -2231 1635 -2644 -10194 -3137 Consistency in important in estimation: In sampling from a Cauchy population, the sample mean of a sample of $n = 10\,000$ observations is no better for estimating the center $\eta$ than just one observation. By contrast, the consistent sample median converges to $\eta,$ so larger samples produce better estimates.
Why do we need an estimator to be consistent? Consider $n = 10\,000$ observations from the standard Cauchy distribution, which is the same as Student's t distribution with 1 degree of freedom. The tails of this distribution are sufficiently heavy
15,095
Why do we need an estimator to be consistent?
@BruceET has already given an excellent technical answer, but I'd like to add a point about the interpretation of it all though. One of the fundamental concepts in statistics is that as our sample size increases, we can reach more precise conclusions about our underlying distribution. You could think of it as the notion that taking lots of samples eliminates the random jitter in the data, so we get a better notion of the underlying structure. Examples of theorems in this vein are plentiful, but the most well-known is the Law of Large Numbers, asserting that if we have a family of i.i.d. random variables $(X_i)_{i\in\mathbb{N}} \ $ and $\mathbb{E}[X_1] < \infty$, then $$\frac{1}{n} \sum_{k = 1}^n X_k \rightarrow \mathbb{E}[X] \ \ \ \text{a.s.}$$ Now, to require an estimator to be consistent is to demand that it also follows this rule: As its job is to estimate an unknown parameter, we would like it to converge to that parameter (read: estimate that parameter arbitrarily well) as our sample size tends to infinity. The equation $$\lim_{n\to\infty} P(|W_n - \theta|> \epsilon) = 0, \quad \forall\epsilon > 0\ \forall\theta \ \in \Theta$$ is nothing else but convergence in probability of the random variables $W_n$ towards $\theta$, meaning that in some sense, a larger sample will get us closer and closer to the true value. Now, if you want, you can look at it conversely: If that condition were to fail, then even with infinite sample size, there would be a "corridor" with positive width $[\theta - \varepsilon, \theta + \varepsilon]$ around $\theta$ and a nonzero probability that even with arbitrarily large sample size, our estimator will fall outside that corridor. And that would obviously violate the aforementioned idea, so consistency is a very natural condition on estimators to desire and enforce.
Why do we need an estimator to be consistent?
@BruceET has already given an excellent technical answer, but I'd like to add a point about the interpretation of it all though. One of the fundamental concepts in statistics is that as our sample siz
Why do we need an estimator to be consistent? @BruceET has already given an excellent technical answer, but I'd like to add a point about the interpretation of it all though. One of the fundamental concepts in statistics is that as our sample size increases, we can reach more precise conclusions about our underlying distribution. You could think of it as the notion that taking lots of samples eliminates the random jitter in the data, so we get a better notion of the underlying structure. Examples of theorems in this vein are plentiful, but the most well-known is the Law of Large Numbers, asserting that if we have a family of i.i.d. random variables $(X_i)_{i\in\mathbb{N}} \ $ and $\mathbb{E}[X_1] < \infty$, then $$\frac{1}{n} \sum_{k = 1}^n X_k \rightarrow \mathbb{E}[X] \ \ \ \text{a.s.}$$ Now, to require an estimator to be consistent is to demand that it also follows this rule: As its job is to estimate an unknown parameter, we would like it to converge to that parameter (read: estimate that parameter arbitrarily well) as our sample size tends to infinity. The equation $$\lim_{n\to\infty} P(|W_n - \theta|> \epsilon) = 0, \quad \forall\epsilon > 0\ \forall\theta \ \in \Theta$$ is nothing else but convergence in probability of the random variables $W_n$ towards $\theta$, meaning that in some sense, a larger sample will get us closer and closer to the true value. Now, if you want, you can look at it conversely: If that condition were to fail, then even with infinite sample size, there would be a "corridor" with positive width $[\theta - \varepsilon, \theta + \varepsilon]$ around $\theta$ and a nonzero probability that even with arbitrarily large sample size, our estimator will fall outside that corridor. And that would obviously violate the aforementioned idea, so consistency is a very natural condition on estimators to desire and enforce.
Why do we need an estimator to be consistent? @BruceET has already given an excellent technical answer, but I'd like to add a point about the interpretation of it all though. One of the fundamental concepts in statistics is that as our sample siz
15,096
Why do we need an estimator to be consistent?
A really simple of example of why it's important to think of consistency, which I don't think gets enough attention, is that of an over-simplified model. As a theoretical example, suppose you wanted to fit a linear regression model on some data, in which the true effects were actually non-linear. Then your predictions cannot be consistent for the true mean for all combinations of covariates, while a more flexible may be able to. In otherwords, the simplified model will have shortcomings which cannot be overcome by using more data.
Why do we need an estimator to be consistent?
A really simple of example of why it's important to think of consistency, which I don't think gets enough attention, is that of an over-simplified model. As a theoretical example, suppose you wanted
Why do we need an estimator to be consistent? A really simple of example of why it's important to think of consistency, which I don't think gets enough attention, is that of an over-simplified model. As a theoretical example, suppose you wanted to fit a linear regression model on some data, in which the true effects were actually non-linear. Then your predictions cannot be consistent for the true mean for all combinations of covariates, while a more flexible may be able to. In otherwords, the simplified model will have shortcomings which cannot be overcome by using more data.
Why do we need an estimator to be consistent? A really simple of example of why it's important to think of consistency, which I don't think gets enough attention, is that of an over-simplified model. As a theoretical example, suppose you wanted
15,097
What do/did you do to remember Bayes' rule?
It may help to recall that it follows from the definition of conditional probability: $$p(a|b) = \frac{p(a,b)}{p(b)}$$ $$p(a,b) = p(a|b)p(b) = p(b|a)p(a)$$ $$p(a|b) = \frac{p(b|a)p(a)}{p(b)}$$ In other words, if you remember how joint probabilities factor into conditional ones, you can always derive Bayes rule, should it slip your mind.
What do/did you do to remember Bayes' rule?
It may help to recall that it follows from the definition of conditional probability: $$p(a|b) = \frac{p(a,b)}{p(b)}$$ $$p(a,b) = p(a|b)p(b) = p(b|a)p(a)$$ $$p(a|b) = \frac{p(b|a)p(a)}{p(b)}$$ In othe
What do/did you do to remember Bayes' rule? It may help to recall that it follows from the definition of conditional probability: $$p(a|b) = \frac{p(a,b)}{p(b)}$$ $$p(a,b) = p(a|b)p(b) = p(b|a)p(a)$$ $$p(a|b) = \frac{p(b|a)p(a)}{p(b)}$$ In other words, if you remember how joint probabilities factor into conditional ones, you can always derive Bayes rule, should it slip your mind.
What do/did you do to remember Bayes' rule? It may help to recall that it follows from the definition of conditional probability: $$p(a|b) = \frac{p(a,b)}{p(b)}$$ $$p(a,b) = p(a|b)p(b) = p(b|a)p(a)$$ $$p(a|b) = \frac{p(b|a)p(a)}{p(b)}$$ In othe
15,098
What do/did you do to remember Bayes' rule?
A simple way that has helped my students is to write $P(A \cap B)$ in two different ways as conditional probabilities: $P(A \cap B)=P(A|B)P(B)$ and $P(A \cap B)=P(B|A)P(A)$ Then $P(A|B)P(B)=P(B|A)P(A)$ and $P(B|A)=\frac{P(A|B)P(B)}{P(A)}$
What do/did you do to remember Bayes' rule?
A simple way that has helped my students is to write $P(A \cap B)$ in two different ways as conditional probabilities: $P(A \cap B)=P(A|B)P(B)$ and $P(A \cap B)=P(B|A)P(A)$ Then $P(A|B)P(B)=P(B|A)P(A
What do/did you do to remember Bayes' rule? A simple way that has helped my students is to write $P(A \cap B)$ in two different ways as conditional probabilities: $P(A \cap B)=P(A|B)P(B)$ and $P(A \cap B)=P(B|A)P(A)$ Then $P(A|B)P(B)=P(B|A)P(A)$ and $P(B|A)=\frac{P(A|B)P(B)}{P(A)}$
What do/did you do to remember Bayes' rule? A simple way that has helped my students is to write $P(A \cap B)$ in two different ways as conditional probabilities: $P(A \cap B)=P(A|B)P(B)$ and $P(A \cap B)=P(B|A)P(A)$ Then $P(A|B)P(B)=P(B|A)P(A
15,099
What do/did you do to remember Bayes' rule?
I worry about understanding the concept behind the formula. Once you have understood a concept, the underlying simple formula is stuck in your mind. Sorry for the stand-offish answer, but that's it.
What do/did you do to remember Bayes' rule?
I worry about understanding the concept behind the formula. Once you have understood a concept, the underlying simple formula is stuck in your mind. Sorry for the stand-offish answer, but that's it.
What do/did you do to remember Bayes' rule? I worry about understanding the concept behind the formula. Once you have understood a concept, the underlying simple formula is stuck in your mind. Sorry for the stand-offish answer, but that's it.
What do/did you do to remember Bayes' rule? I worry about understanding the concept behind the formula. Once you have understood a concept, the underlying simple formula is stuck in your mind. Sorry for the stand-offish answer, but that's it.
15,100
What do/did you do to remember Bayes' rule?
I personally think this for is just easier to remember:$$P(A|B)P(B)=P(B|A)P(A)$$
What do/did you do to remember Bayes' rule?
I personally think this for is just easier to remember:$$P(A|B)P(B)=P(B|A)P(A)$$
What do/did you do to remember Bayes' rule? I personally think this for is just easier to remember:$$P(A|B)P(B)=P(B|A)P(A)$$
What do/did you do to remember Bayes' rule? I personally think this for is just easier to remember:$$P(A|B)P(B)=P(B|A)P(A)$$