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
18,101
What theories, papers, or books examine low-probability events, particularly as the number of trials approaches infinity?
"It seems to be that as nβ†’βˆž, the event should be inevitable, which feels like a controversial word to use in probability." Nothing controversial here, although sometimes we use "almost-certain" instead of "inevitable". Zero-one laws You might be interested in one of the so-called "zero-one laws", various theorems which all state that under some particular conditions, a probability in the limit will always be either 0 (won't happen) or 1 (will happen), and cannot be an intermediate value. For instance, Kolmogorov's zero-one law states that if X0, X1, X2, ..., Xn, ... is an infinite family of random variables, and E is an event which can be described in functions of the Xn, but is independent of any finite number of Xn, then either P(E) = 0 or P(E) = 1. Borel-Cantelli's lemma is another zero-one law which is perhaps simpler to understand. It states that if you have an infinite family of events E0, E1, E2, E3, ..., En, ... such that the sum of probabilities $\sum E_n$ is finite, then the probability that infinitely many of these events happen is 0. A converse version of the lemma, with the added assumption of independence, states that if the sum of probabilities is infinite, then the probability that infinitely many events happen is 1. For instance, imagine you roll an infinite number of dice, with increasing number of faces, and ask for the probability that an infinite number of dice land on face $1$ (a die with $n$ faces has its faces numbered $1$ to $n$). Then depending on the increasing sequence of the number of faces, the probability will be either $0$ or $1$; but it cannot be something inbetween. If you roll a die with 4 faces, then a die with 9 faces, then a die with 16 faces, then a die with 25 faces, etc, so that the $n$th die has $n^2$ faces, then the probability that infinitely many of these dice land on face $1$ is $0$; If you roll a die with $4$ faces, and then a die with $5$ faces, then a die with $6$ faces, etc, so that the $n$th die has $n$ faces, then the probability that infinitely many of these dice land on face $1$ is $1$. If you can survive the dry formalism of measure theory, this text presents both Borel-Cantelli's lemma and Kolmogorov's zero-one law, and gives several examples of application: McNamara, Kolmogorov's zero-one law with applications.
What theories, papers, or books examine low-probability events, particularly as the number of trials
"It seems to be that as nβ†’βˆž, the event should be inevitable, which feels like a controversial word to use in probability." Nothing controversial here, although sometimes we use "almost-certain" inste
What theories, papers, or books examine low-probability events, particularly as the number of trials approaches infinity? "It seems to be that as nβ†’βˆž, the event should be inevitable, which feels like a controversial word to use in probability." Nothing controversial here, although sometimes we use "almost-certain" instead of "inevitable". Zero-one laws You might be interested in one of the so-called "zero-one laws", various theorems which all state that under some particular conditions, a probability in the limit will always be either 0 (won't happen) or 1 (will happen), and cannot be an intermediate value. For instance, Kolmogorov's zero-one law states that if X0, X1, X2, ..., Xn, ... is an infinite family of random variables, and E is an event which can be described in functions of the Xn, but is independent of any finite number of Xn, then either P(E) = 0 or P(E) = 1. Borel-Cantelli's lemma is another zero-one law which is perhaps simpler to understand. It states that if you have an infinite family of events E0, E1, E2, E3, ..., En, ... such that the sum of probabilities $\sum E_n$ is finite, then the probability that infinitely many of these events happen is 0. A converse version of the lemma, with the added assumption of independence, states that if the sum of probabilities is infinite, then the probability that infinitely many events happen is 1. For instance, imagine you roll an infinite number of dice, with increasing number of faces, and ask for the probability that an infinite number of dice land on face $1$ (a die with $n$ faces has its faces numbered $1$ to $n$). Then depending on the increasing sequence of the number of faces, the probability will be either $0$ or $1$; but it cannot be something inbetween. If you roll a die with 4 faces, then a die with 9 faces, then a die with 16 faces, then a die with 25 faces, etc, so that the $n$th die has $n^2$ faces, then the probability that infinitely many of these dice land on face $1$ is $0$; If you roll a die with $4$ faces, and then a die with $5$ faces, then a die with $6$ faces, etc, so that the $n$th die has $n$ faces, then the probability that infinitely many of these dice land on face $1$ is $1$. If you can survive the dry formalism of measure theory, this text presents both Borel-Cantelli's lemma and Kolmogorov's zero-one law, and gives several examples of application: McNamara, Kolmogorov's zero-one law with applications.
What theories, papers, or books examine low-probability events, particularly as the number of trials "It seems to be that as nβ†’βˆž, the event should be inevitable, which feels like a controversial word to use in probability." Nothing controversial here, although sometimes we use "almost-certain" inste
18,102
What theories, papers, or books examine low-probability events, particularly as the number of trials approaches infinity?
Reasoning like this leads to the Poisson distribution and other count distributions If I understand your question correctly, it sounds like you might be examining a similar case to what leads to the Poisson distribution, and other variations of similar count distributions. Suppose we consider the case where we have a large number of independent binary events with small probability, and we want to count the number of events that occur. This can be repesented fairly well by taking large $n$ and using: $$X_n | \mu \sim \text{Bin} \bigg( n , \frac{\mu}{n} \bigg).$$ (The situation in your question is the special case where $\mu=1$, but I have generalised this.) If we take the limit as $n \rightarrow \infty$ then the count follows a Poisson distribution: $$\lim_{n \rightarrow \infty} \mathbb{P}(X_n = x | \mu) = \text{Pois}(x| \mu).$$ Also, you can now see that this situation does not make the occurrence of the event inevitable --- in fact, we have the limiting probability: $$\lim_{n \rightarrow \infty} \mathbb{P}(X_n = 0 | \mu) = \lim_{n \rightarrow \infty} \bigg( 1-\frac{\mu}{n} \bigg)^n = \exp(-\mu) = \text{Pois}(0| \mu).$$ This is one of the reason that we consider the Poisson distribution to be a useful base distribution for describing the occurrence of "rare events" in a large number of trials. For example, suppose you go outside in a rainstorm and hold up a test tube to catch rain-drops. An individual rain-drop has a low probability of landing in the test-tube, but there are a lot of rain-drops, so we might reasonably posit a Poisson distribution for the number of rain-drops that land in the tube. This can be extended out further, to more general forms of count distributions, if we consider "mixtures" of Poisson processes. In the above case we have proceeded conditionally on a fixed mean $\mu$, so that all the binary events have the same probability of occurring. If we allow variation in these probabilities, over some distribution, then we will get a count distribution that is more variable than the Poisson. For example, if $\mu$ has a gamma distribution then we get a negative-binomial distribution for the limiting count variable. We can also get other generalise count distributions with other types of reasoning similar to this. If you are looking for a good overview of this topic, with extensions into more complex models, I would recommend looking for good statistics books on the analysis of count data. Such works will typically run through the basics of the Poisson distribution and other count distributions and also run through count regression and other standard statistical models in the field that use count data. Many of these models are amenable to situations where a count variable emerges from looking at the number of occurrences of a low-probability event in a large number of trials. Some available books in the field include Winkelmann (2003), Hilbe (2014), Cameron and Trivedi (2013), Dupuy (2018) and Martin (2022). Simulation analysis: The simulation analysis you have conducted does not appear to accord with your description of the problem, since you hold the probability parameter in your binomial distribution fixed. If you want to simulate in the case where the probability becomes low as the sample size becomes large then you need to adjust your probability parameter in your simulations. Here is a variation of this simulation that uses the above model: #Set the seed set.seed(1839) #Set parameters mu <- 1 iter <- 5000 n.vals <- c(1, 10, 100, 1000, 10000, 100000) probs <- numeric(length(n.vals)) #Generate simulations and estimate probs #The value probs estimates probability of non-occurrence for (i in 1:length(n.vals)) { X <- matrix(rbinom(iter*n.vals[i], 1, prob = mu/n.vals[i]), nrow = iter, ncol = n.vals[i]) probs[i] <- 1 - mean(matrixStats::rowMaxs(X)) } #Show probs probs [1] 0.0000 0.3500 0.3704 0.3534 0.3648 0.3640 #True probability exp(-mu) [1] 0.3678794 As expected, the simulated probability of non-occurrence of the event is close to the probabilty under the Poisson distribution when the number of trials is large.
What theories, papers, or books examine low-probability events, particularly as the number of trials
Reasoning like this leads to the Poisson distribution and other count distributions If I understand your question correctly, it sounds like you might be examining a similar case to what leads to the P
What theories, papers, or books examine low-probability events, particularly as the number of trials approaches infinity? Reasoning like this leads to the Poisson distribution and other count distributions If I understand your question correctly, it sounds like you might be examining a similar case to what leads to the Poisson distribution, and other variations of similar count distributions. Suppose we consider the case where we have a large number of independent binary events with small probability, and we want to count the number of events that occur. This can be repesented fairly well by taking large $n$ and using: $$X_n | \mu \sim \text{Bin} \bigg( n , \frac{\mu}{n} \bigg).$$ (The situation in your question is the special case where $\mu=1$, but I have generalised this.) If we take the limit as $n \rightarrow \infty$ then the count follows a Poisson distribution: $$\lim_{n \rightarrow \infty} \mathbb{P}(X_n = x | \mu) = \text{Pois}(x| \mu).$$ Also, you can now see that this situation does not make the occurrence of the event inevitable --- in fact, we have the limiting probability: $$\lim_{n \rightarrow \infty} \mathbb{P}(X_n = 0 | \mu) = \lim_{n \rightarrow \infty} \bigg( 1-\frac{\mu}{n} \bigg)^n = \exp(-\mu) = \text{Pois}(0| \mu).$$ This is one of the reason that we consider the Poisson distribution to be a useful base distribution for describing the occurrence of "rare events" in a large number of trials. For example, suppose you go outside in a rainstorm and hold up a test tube to catch rain-drops. An individual rain-drop has a low probability of landing in the test-tube, but there are a lot of rain-drops, so we might reasonably posit a Poisson distribution for the number of rain-drops that land in the tube. This can be extended out further, to more general forms of count distributions, if we consider "mixtures" of Poisson processes. In the above case we have proceeded conditionally on a fixed mean $\mu$, so that all the binary events have the same probability of occurring. If we allow variation in these probabilities, over some distribution, then we will get a count distribution that is more variable than the Poisson. For example, if $\mu$ has a gamma distribution then we get a negative-binomial distribution for the limiting count variable. We can also get other generalise count distributions with other types of reasoning similar to this. If you are looking for a good overview of this topic, with extensions into more complex models, I would recommend looking for good statistics books on the analysis of count data. Such works will typically run through the basics of the Poisson distribution and other count distributions and also run through count regression and other standard statistical models in the field that use count data. Many of these models are amenable to situations where a count variable emerges from looking at the number of occurrences of a low-probability event in a large number of trials. Some available books in the field include Winkelmann (2003), Hilbe (2014), Cameron and Trivedi (2013), Dupuy (2018) and Martin (2022). Simulation analysis: The simulation analysis you have conducted does not appear to accord with your description of the problem, since you hold the probability parameter in your binomial distribution fixed. If you want to simulate in the case where the probability becomes low as the sample size becomes large then you need to adjust your probability parameter in your simulations. Here is a variation of this simulation that uses the above model: #Set the seed set.seed(1839) #Set parameters mu <- 1 iter <- 5000 n.vals <- c(1, 10, 100, 1000, 10000, 100000) probs <- numeric(length(n.vals)) #Generate simulations and estimate probs #The value probs estimates probability of non-occurrence for (i in 1:length(n.vals)) { X <- matrix(rbinom(iter*n.vals[i], 1, prob = mu/n.vals[i]), nrow = iter, ncol = n.vals[i]) probs[i] <- 1 - mean(matrixStats::rowMaxs(X)) } #Show probs probs [1] 0.0000 0.3500 0.3704 0.3534 0.3648 0.3640 #True probability exp(-mu) [1] 0.3678794 As expected, the simulated probability of non-occurrence of the event is close to the probabilty under the Poisson distribution when the number of trials is large.
What theories, papers, or books examine low-probability events, particularly as the number of trials Reasoning like this leads to the Poisson distribution and other count distributions If I understand your question correctly, it sounds like you might be examining a similar case to what leads to the P
18,103
What theories, papers, or books examine low-probability events, particularly as the number of trials approaches infinity?
Low probability events are often not analysed based on direct data about the events. High probability events: For example, as a contrasting example, the amount of customers in some shop (and getting a customer is a high probability event for a decent store) can be predicted by extrapolating previous observations. Low probability events: Estimates for low probability events, some that might even have never been seen before, are based on theoretical predictions. For example, probabilities that a catastrophic meteor hits earth will not be based on previous observations of such events (which never happened, or if they did happen then we weren't there to observe it), but is based on calculations combining other information like information about the number of meteors and computed probabilities for those meteors hitting earth. What theories, papers, or books examine low-probability events, particularly as the number of trials approaches infinity? So the theories have little to do with theory of statistics and much more with domain knowledge and whatever theories that are available there that can help to make estimates/predictions.
What theories, papers, or books examine low-probability events, particularly as the number of trials
Low probability events are often not analysed based on direct data about the events. High probability events: For example, as a contrasting example, the amount of customers in some shop (and getting
What theories, papers, or books examine low-probability events, particularly as the number of trials approaches infinity? Low probability events are often not analysed based on direct data about the events. High probability events: For example, as a contrasting example, the amount of customers in some shop (and getting a customer is a high probability event for a decent store) can be predicted by extrapolating previous observations. Low probability events: Estimates for low probability events, some that might even have never been seen before, are based on theoretical predictions. For example, probabilities that a catastrophic meteor hits earth will not be based on previous observations of such events (which never happened, or if they did happen then we weren't there to observe it), but is based on calculations combining other information like information about the number of meteors and computed probabilities for those meteors hitting earth. What theories, papers, or books examine low-probability events, particularly as the number of trials approaches infinity? So the theories have little to do with theory of statistics and much more with domain knowledge and whatever theories that are available there that can help to make estimates/predictions.
What theories, papers, or books examine low-probability events, particularly as the number of trials Low probability events are often not analysed based on direct data about the events. High probability events: For example, as a contrasting example, the amount of customers in some shop (and getting
18,104
What theories, papers, or books examine low-probability events, particularly as the number of trials approaches infinity?
"... one of the most fundamental and critical conceptual notions in inference is the distinction between probabilities and frequencies. A useful and concise phrase to hang our hats on is a philosophical one that probabilities are epistemological, while frequencies are ontological." "The very same distinction applies to information and data. Information is an epistemological concept, while data is an ontological concept. Entropy, which is a quantitative measure of the amount of missing information, must perforce be an epistemological concept." These two quotes are from David J Blower. If these quotes resonate with you, I can only advise you to read his books in his series "Information Processing." Admittedly, a long read. But he treats your questions at a deeper, more fundamental level. Starting with Boolean Algebra, logic, probability manipulations, Bayes' theorem, etcetera. Especially, Blower's discussion of Sir Harold Jeffreys' hang-up "animals with feathers" may be useful (Volume 1, p. 377).
What theories, papers, or books examine low-probability events, particularly as the number of trials
"... one of the most fundamental and critical conceptual notions in inference is the distinction between probabilities and frequencies. A useful and concise phrase to hang our hats on is a philosophic
What theories, papers, or books examine low-probability events, particularly as the number of trials approaches infinity? "... one of the most fundamental and critical conceptual notions in inference is the distinction between probabilities and frequencies. A useful and concise phrase to hang our hats on is a philosophical one that probabilities are epistemological, while frequencies are ontological." "The very same distinction applies to information and data. Information is an epistemological concept, while data is an ontological concept. Entropy, which is a quantitative measure of the amount of missing information, must perforce be an epistemological concept." These two quotes are from David J Blower. If these quotes resonate with you, I can only advise you to read his books in his series "Information Processing." Admittedly, a long read. But he treats your questions at a deeper, more fundamental level. Starting with Boolean Algebra, logic, probability manipulations, Bayes' theorem, etcetera. Especially, Blower's discussion of Sir Harold Jeffreys' hang-up "animals with feathers" may be useful (Volume 1, p. 377).
What theories, papers, or books examine low-probability events, particularly as the number of trials "... one of the most fundamental and critical conceptual notions in inference is the distinction between probabilities and frequencies. A useful and concise phrase to hang our hats on is a philosophic
18,105
How to interpret parameter estimates in Poisson GLM results [closed]
I don't think the title of your question accurately captures what you're asking for. The question of how to interpret the parameters in a GLM is very broad because the GLM is a very broad class of models. Recall that a GLM models a response variable $y$ that is assumed to follow a known distribution from the exponential family, and that we have chosen an invertible function $g$ such that $$ \mathrm{E}\left[y\,|\,x\right] = g^{-1}{\left(x_0 + x_1\beta_1 + \dots + x_J\beta_J\right)} $$ for $J$ predictor variables $x$. In this model, the interpretation of any particular parameter $\beta_j$ is the rate of change of $g(y)$ with respect to $x_j$. Define $\mu \equiv \mathrm{E}{\left[y\,|\,x\right]} = g^{-1}{\left(x\right)}$ and $\eta \equiv x \cdot \beta$ to keep the notation clean. Then, for any $j \in \{1,\dots,J\}$, $$ \beta_j = \frac{\partial\,\eta}{\partial\,x_j} = \frac{\partial\,g(\mu)}{\partial\,x_j} \text{.} $$ Now define $\mathfrak{e}_j$ to be a vector of $J-1$ zeroes and a single $1$ in the $j$th position, so that for example if $J=5$ then $\mathfrak{e}_3 = \left(0,0,1,0,0\right)$. Then $$ \beta_j = g{\left(\mathrm{E}{\left[y\,|\,x + \mathfrak{e}_j \right]}\right)} - g{\left(\mathrm{E}{\left[y\,|\,x\right]}\right)} $$ Which just means that $\beta_j$ is the effect on $\eta$ of a unit increase in $x_j$. You can also state the relationship in this way: $$ \frac{\operatorname{\partial}\mathrm{E}{\left[y\,|\,x\right]}}{\operatorname{\partial}x_j} = \frac{\operatorname{\partial}\mu}{\operatorname{\partial}x_j} = \frac{\operatorname{d}\mu}{\operatorname{d}\eta}\frac{\operatorname{\partial}\eta}{\operatorname{\partial}x_j} = \frac{\operatorname{\partial}\mu}{\operatorname{\partial}\eta} \beta_j = \frac{\operatorname{d}g^{-1}}{\operatorname{d}\eta} \beta_j $$ and $$ \mathrm{E}{\left[y\,|\,x + \mathfrak{e}_j \right]} - \mathrm{E}{\left[y\,|\,x\right]} \equiv \operatorname{\Delta_j} \hat y = g^{-1}{\left( \left(x + \mathfrak{e}_j\right)\beta \right)} - g^{-1}{\left( x\,\beta \right)} $$ Without knowing anything about $g$, that's as far as we can get. $\beta_j$ is the effect on $\eta$, on the transformed conditional mean of $y$, of a unit increase in $x_j$, and the effect on the conditional mean of $y$ of a unit increase in $x_j$ is $g^{-1}{\left(\beta\right)}$. But you seem to be asking specifically about Poisson regression using R's default link function, which in this case is the natural logarithm. If that's the case, you're asking about a specific kind of GLM in which $y \sim \mathrm{Poisson}{\left(\lambda\right)}$ and $g = \ln$. Then we can get some traction with regard to a specific interpretation. From what I said above, we know that $\frac{\operatorname{\partial}\mu}{\operatorname{\partial}x_j} = \frac{\operatorname{d}g^{-1}}{\operatorname{d}\eta} \beta_j$. And since we know $g(\mu) = \ln(\mu)$, we also know that $g^{-1}(\eta) = e^\eta$. We also happen to know that $\frac{\operatorname{d}e^\eta}{\operatorname{d}\eta} = e^\eta$, so we can say that $$ \frac{\operatorname{\partial}\mu}{\operatorname{\partial}x_j} = \frac{\operatorname{\partial}\mathrm{E}{\left[y\,|\,x\right]}}{\operatorname{\partial}x_j} = e^{x_0 + x_1\beta_1 + \dots + x_J\beta_J}\beta_j $$ which finally means something tangible: Given a very small change in $x_j$, the fitted $\hat y$ changes by $\hat y\,\beta_j$. Note: this approximation can actually work for changes as large as 0.2, depending on how much precision you need. And using the more familiar unit change interpretation, we have: \begin{align} \operatorname{\Delta_j} \hat y &= e^{ x_0 + x_1\beta_1 + \dots + \left(x_j + 1\right)\,\beta_j + \dots + x_J\beta_J } - e^{x_0 + x_1\beta_1 + \dots + x_J\beta_J} \\ &= e^{ x_0 + x_1\beta_1 + \dots + x_J\beta_J + \beta_j} - e^{x_0 + x_1\beta_1 + \dots + x_J\beta_J} \\ &= e^{ x_0 + x_1\beta_1 + \dots + x_J\beta_J}e^{\beta_j} - e^{x_0 + x_1\beta_1 + \dots + x_J\beta_J} \\ &= e^{ x_0 + x_1\beta_1 + \dots + x_J\beta_J} \left( e^{\beta_j} - 1 \right) \end{align} which means Given a unit change in $x_j$, the fitted $\hat y$ changes by $\hat y \left( e^{\beta_j} - 1 \right)$. There are three important pieces to note here: The effect of a change in the predictors depends on the level of the response. An additive change in the predictors has a multiplicative effect on the response. You can't interpret the coefficients just by reading them (unless you can compute arbitrary exponentials in your head). So in your example, the effect of increasing pH by 1 is to increase $\ln \hat y$ by $\hat y \left( e^{0.09} - 1 \right)$; that is, to multiply $\hat y$ by $e^{0.09} \approx 1.09$. It looks like your outcome is the number of darters you observe in some fixed unit of time (say, a week). So if you're observing 100 darters a week at a pH of 6.7, raising the pH of the river to 7.7 means you can now expect to see 109 darters a week.
How to interpret parameter estimates in Poisson GLM results [closed]
I don't think the title of your question accurately captures what you're asking for. The question of how to interpret the parameters in a GLM is very broad because the GLM is a very broad class of mod
How to interpret parameter estimates in Poisson GLM results [closed] I don't think the title of your question accurately captures what you're asking for. The question of how to interpret the parameters in a GLM is very broad because the GLM is a very broad class of models. Recall that a GLM models a response variable $y$ that is assumed to follow a known distribution from the exponential family, and that we have chosen an invertible function $g$ such that $$ \mathrm{E}\left[y\,|\,x\right] = g^{-1}{\left(x_0 + x_1\beta_1 + \dots + x_J\beta_J\right)} $$ for $J$ predictor variables $x$. In this model, the interpretation of any particular parameter $\beta_j$ is the rate of change of $g(y)$ with respect to $x_j$. Define $\mu \equiv \mathrm{E}{\left[y\,|\,x\right]} = g^{-1}{\left(x\right)}$ and $\eta \equiv x \cdot \beta$ to keep the notation clean. Then, for any $j \in \{1,\dots,J\}$, $$ \beta_j = \frac{\partial\,\eta}{\partial\,x_j} = \frac{\partial\,g(\mu)}{\partial\,x_j} \text{.} $$ Now define $\mathfrak{e}_j$ to be a vector of $J-1$ zeroes and a single $1$ in the $j$th position, so that for example if $J=5$ then $\mathfrak{e}_3 = \left(0,0,1,0,0\right)$. Then $$ \beta_j = g{\left(\mathrm{E}{\left[y\,|\,x + \mathfrak{e}_j \right]}\right)} - g{\left(\mathrm{E}{\left[y\,|\,x\right]}\right)} $$ Which just means that $\beta_j$ is the effect on $\eta$ of a unit increase in $x_j$. You can also state the relationship in this way: $$ \frac{\operatorname{\partial}\mathrm{E}{\left[y\,|\,x\right]}}{\operatorname{\partial}x_j} = \frac{\operatorname{\partial}\mu}{\operatorname{\partial}x_j} = \frac{\operatorname{d}\mu}{\operatorname{d}\eta}\frac{\operatorname{\partial}\eta}{\operatorname{\partial}x_j} = \frac{\operatorname{\partial}\mu}{\operatorname{\partial}\eta} \beta_j = \frac{\operatorname{d}g^{-1}}{\operatorname{d}\eta} \beta_j $$ and $$ \mathrm{E}{\left[y\,|\,x + \mathfrak{e}_j \right]} - \mathrm{E}{\left[y\,|\,x\right]} \equiv \operatorname{\Delta_j} \hat y = g^{-1}{\left( \left(x + \mathfrak{e}_j\right)\beta \right)} - g^{-1}{\left( x\,\beta \right)} $$ Without knowing anything about $g$, that's as far as we can get. $\beta_j$ is the effect on $\eta$, on the transformed conditional mean of $y$, of a unit increase in $x_j$, and the effect on the conditional mean of $y$ of a unit increase in $x_j$ is $g^{-1}{\left(\beta\right)}$. But you seem to be asking specifically about Poisson regression using R's default link function, which in this case is the natural logarithm. If that's the case, you're asking about a specific kind of GLM in which $y \sim \mathrm{Poisson}{\left(\lambda\right)}$ and $g = \ln$. Then we can get some traction with regard to a specific interpretation. From what I said above, we know that $\frac{\operatorname{\partial}\mu}{\operatorname{\partial}x_j} = \frac{\operatorname{d}g^{-1}}{\operatorname{d}\eta} \beta_j$. And since we know $g(\mu) = \ln(\mu)$, we also know that $g^{-1}(\eta) = e^\eta$. We also happen to know that $\frac{\operatorname{d}e^\eta}{\operatorname{d}\eta} = e^\eta$, so we can say that $$ \frac{\operatorname{\partial}\mu}{\operatorname{\partial}x_j} = \frac{\operatorname{\partial}\mathrm{E}{\left[y\,|\,x\right]}}{\operatorname{\partial}x_j} = e^{x_0 + x_1\beta_1 + \dots + x_J\beta_J}\beta_j $$ which finally means something tangible: Given a very small change in $x_j$, the fitted $\hat y$ changes by $\hat y\,\beta_j$. Note: this approximation can actually work for changes as large as 0.2, depending on how much precision you need. And using the more familiar unit change interpretation, we have: \begin{align} \operatorname{\Delta_j} \hat y &= e^{ x_0 + x_1\beta_1 + \dots + \left(x_j + 1\right)\,\beta_j + \dots + x_J\beta_J } - e^{x_0 + x_1\beta_1 + \dots + x_J\beta_J} \\ &= e^{ x_0 + x_1\beta_1 + \dots + x_J\beta_J + \beta_j} - e^{x_0 + x_1\beta_1 + \dots + x_J\beta_J} \\ &= e^{ x_0 + x_1\beta_1 + \dots + x_J\beta_J}e^{\beta_j} - e^{x_0 + x_1\beta_1 + \dots + x_J\beta_J} \\ &= e^{ x_0 + x_1\beta_1 + \dots + x_J\beta_J} \left( e^{\beta_j} - 1 \right) \end{align} which means Given a unit change in $x_j$, the fitted $\hat y$ changes by $\hat y \left( e^{\beta_j} - 1 \right)$. There are three important pieces to note here: The effect of a change in the predictors depends on the level of the response. An additive change in the predictors has a multiplicative effect on the response. You can't interpret the coefficients just by reading them (unless you can compute arbitrary exponentials in your head). So in your example, the effect of increasing pH by 1 is to increase $\ln \hat y$ by $\hat y \left( e^{0.09} - 1 \right)$; that is, to multiply $\hat y$ by $e^{0.09} \approx 1.09$. It looks like your outcome is the number of darters you observe in some fixed unit of time (say, a week). So if you're observing 100 darters a week at a pH of 6.7, raising the pH of the river to 7.7 means you can now expect to see 109 darters a week.
How to interpret parameter estimates in Poisson GLM results [closed] I don't think the title of your question accurately captures what you're asking for. The question of how to interpret the parameters in a GLM is very broad because the GLM is a very broad class of mod
18,106
How to interpret parameter estimates in Poisson GLM results [closed]
My suggestion would be to create a small grid consisting of combinations of the two rivers and two or three values of each of the covariates, then use the predict function with your grid as newdata. Then graph the results. It is much clearer to look at the values that the model actually predicts. You may or may not want to back-transform the predictions to the original scale of measurement (type = "response").
How to interpret parameter estimates in Poisson GLM results [closed]
My suggestion would be to create a small grid consisting of combinations of the two rivers and two or three values of each of the covariates, then use the predict function with your grid as newdata. T
How to interpret parameter estimates in Poisson GLM results [closed] My suggestion would be to create a small grid consisting of combinations of the two rivers and two or three values of each of the covariates, then use the predict function with your grid as newdata. Then graph the results. It is much clearer to look at the values that the model actually predicts. You may or may not want to back-transform the predictions to the original scale of measurement (type = "response").
How to interpret parameter estimates in Poisson GLM results [closed] My suggestion would be to create a small grid consisting of combinations of the two rivers and two or three values of each of the covariates, then use the predict function with your grid as newdata. T
18,107
Multiple Linear Regression Simulation
If you don't have them already, start by setting up some predictors, $x_1$, $x_2$, ... Choose the population ('true') coefficients of your predictors, the $\beta_i$'s, including $\beta_0$, the intercept. Choose the error variance, $\sigma^2$ or equivalently its square root, $\sigma$ generate the error term, $\varepsilon$, as an independent random normal vector, with mean 0 and variance $\sigma^2$ Let $y = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + ... + \beta_k x_k + \varepsilon$ then you can regress the $y$ on your $x$'s e.g. in R you could do something like: x1 <- 11:30 x2 <- runif(20,5,95) x3 <- rbinom(20,1,.5) b0 <- 17 b1 <- 0.5 b2 <- 0.037 b3 <- -5.2 sigma <- 1.4 eps <- rnorm(x1,0,sigma) y <- b0 + b1*x1 + b2*x2 + b3*x3 + eps produces a single simulation of $y$ from the model. Then running summary(lm(y~x1+x2+x3)) gives Call: lm(formula = y ~ x1 + x2 + x3) Residuals: Min 1Q Median 3Q Max -2.6967 -0.4970 0.1152 0.7536 1.6511 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 16.28141 1.32102 12.325 1.40e-09 *** x1 0.55939 0.04850 11.533 3.65e-09 *** x2 0.01715 0.01578 1.087 0.293 x3 -4.91783 0.66547 -7.390 1.53e-06 *** --- Signif. codes: 0 β€˜***’ 0.001 β€˜**’ 0.01 β€˜*’ 0.05 β€˜.’ 0.1 β€˜ ’ 1 Residual standard error: 1.241 on 16 degrees of freedom Multiple R-squared: 0.9343, Adjusted R-squared: 0.9219 F-statistic: 75.79 on 3 and 16 DF, p-value: 1.131e-09 You can simplify this procedure in several ways, but I figured spelling it out would help to begin with. If you want to simulate a new random $y$ but with the same population coefficients, just rerun the last two lines of the procedure above (generate a new random eps and y), corresponding to steps 3 and 4 of the algorithm.
Multiple Linear Regression Simulation
If you don't have them already, start by setting up some predictors, $x_1$, $x_2$, ... Choose the population ('true') coefficients of your predictors, the $\beta_i$'s, including $\beta_0$, the interce
Multiple Linear Regression Simulation If you don't have them already, start by setting up some predictors, $x_1$, $x_2$, ... Choose the population ('true') coefficients of your predictors, the $\beta_i$'s, including $\beta_0$, the intercept. Choose the error variance, $\sigma^2$ or equivalently its square root, $\sigma$ generate the error term, $\varepsilon$, as an independent random normal vector, with mean 0 and variance $\sigma^2$ Let $y = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + ... + \beta_k x_k + \varepsilon$ then you can regress the $y$ on your $x$'s e.g. in R you could do something like: x1 <- 11:30 x2 <- runif(20,5,95) x3 <- rbinom(20,1,.5) b0 <- 17 b1 <- 0.5 b2 <- 0.037 b3 <- -5.2 sigma <- 1.4 eps <- rnorm(x1,0,sigma) y <- b0 + b1*x1 + b2*x2 + b3*x3 + eps produces a single simulation of $y$ from the model. Then running summary(lm(y~x1+x2+x3)) gives Call: lm(formula = y ~ x1 + x2 + x3) Residuals: Min 1Q Median 3Q Max -2.6967 -0.4970 0.1152 0.7536 1.6511 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 16.28141 1.32102 12.325 1.40e-09 *** x1 0.55939 0.04850 11.533 3.65e-09 *** x2 0.01715 0.01578 1.087 0.293 x3 -4.91783 0.66547 -7.390 1.53e-06 *** --- Signif. codes: 0 β€˜***’ 0.001 β€˜**’ 0.01 β€˜*’ 0.05 β€˜.’ 0.1 β€˜ ’ 1 Residual standard error: 1.241 on 16 degrees of freedom Multiple R-squared: 0.9343, Adjusted R-squared: 0.9219 F-statistic: 75.79 on 3 and 16 DF, p-value: 1.131e-09 You can simplify this procedure in several ways, but I figured spelling it out would help to begin with. If you want to simulate a new random $y$ but with the same population coefficients, just rerun the last two lines of the procedure above (generate a new random eps and y), corresponding to steps 3 and 4 of the algorithm.
Multiple Linear Regression Simulation If you don't have them already, start by setting up some predictors, $x_1$, $x_2$, ... Choose the population ('true') coefficients of your predictors, the $\beta_i$'s, including $\beta_0$, the interce
18,108
Multiple Linear Regression Simulation
Here is another code to generate multiple linear regression with errors follow normal distribution: sim.regression<-function(n.obs=10,coefficients=runif(10,-5,5),s.deviation=.1){ n.var=length(coefficients) M=matrix(0,ncol=n.var,nrow=n.obs) beta=as.matrix(coefficients) for (i in 1:n.var){ M[,i]=rnorm(n.obs,0,1) } y=M %*% beta + rnorm(n.obs,0,s.deviation) return (list(x=M,y=y,coeff=coefficients)) }
Multiple Linear Regression Simulation
Here is another code to generate multiple linear regression with errors follow normal distribution: sim.regression<-function(n.obs=10,coefficients=runif(10,-5,5),s.deviation=.1){ n.var=length(coeff
Multiple Linear Regression Simulation Here is another code to generate multiple linear regression with errors follow normal distribution: sim.regression<-function(n.obs=10,coefficients=runif(10,-5,5),s.deviation=.1){ n.var=length(coefficients) M=matrix(0,ncol=n.var,nrow=n.obs) beta=as.matrix(coefficients) for (i in 1:n.var){ M[,i]=rnorm(n.obs,0,1) } y=M %*% beta + rnorm(n.obs,0,s.deviation) return (list(x=M,y=y,coeff=coefficients)) }
Multiple Linear Regression Simulation Here is another code to generate multiple linear regression with errors follow normal distribution: sim.regression<-function(n.obs=10,coefficients=runif(10,-5,5),s.deviation=.1){ n.var=length(coeff
18,109
How does the distribution of the error term affect the distribution of the response?
Maybe I'm off but I think we ought to be wondering about $f(y|\beta, X)$, which is how I read the OP. In the very simplest case of linear regression if your model is $y=X\beta + \epsilon$ then the only stochastic component in your model is the error term. As such it determines the sampling distribution of $y$. If $\epsilon\sim N(0, \sigma^2I)$ then $y|X, \beta\sim N(X\beta, \sigma^2I)$. What @Aniko says is certainly true of $f(y)$ (marginally over $X, \beta$), however. So as it stands the question is slightly vague.
How does the distribution of the error term affect the distribution of the response?
Maybe I'm off but I think we ought to be wondering about $f(y|\beta, X)$, which is how I read the OP. In the very simplest case of linear regression if your model is $y=X\beta + \epsilon$ then the onl
How does the distribution of the error term affect the distribution of the response? Maybe I'm off but I think we ought to be wondering about $f(y|\beta, X)$, which is how I read the OP. In the very simplest case of linear regression if your model is $y=X\beta + \epsilon$ then the only stochastic component in your model is the error term. As such it determines the sampling distribution of $y$. If $\epsilon\sim N(0, \sigma^2I)$ then $y|X, \beta\sim N(X\beta, \sigma^2I)$. What @Aniko says is certainly true of $f(y)$ (marginally over $X, \beta$), however. So as it stands the question is slightly vague.
How does the distribution of the error term affect the distribution of the response? Maybe I'm off but I think we ought to be wondering about $f(y|\beta, X)$, which is how I read the OP. In the very simplest case of linear regression if your model is $y=X\beta + \epsilon$ then the onl
18,110
How does the distribution of the error term affect the distribution of the response?
The short answer is that you cannot conclude anything about the distribution of $y$, because it depends on the distribution of the $x$'s and the strength and shape of the relationship. More formally, $y$ will have a "mixture of normals" distribution, which in practice can be pretty much anything. Here are two extreme examples to illustrate this: Suppose there are only two possible $x$ values, 0 an 1, and $y = 10x + N(0,1)$. Then $y$ will have a strongly bimodal distribution with bumps at 0 and 10. Now assume the same relationship, but let $x$ be uniformly distributed on the 0-1 interval with lots of values. Then $y$ will be almost uniformly distributed over the 0-10 interval (with some half-normal tails at the edges). In fact, since every distribution can be approximated arbitrarily well with mixture of normals, you can really get any distribution for $y$.
How does the distribution of the error term affect the distribution of the response?
The short answer is that you cannot conclude anything about the distribution of $y$, because it depends on the distribution of the $x$'s and the strength and shape of the relationship. More formally,
How does the distribution of the error term affect the distribution of the response? The short answer is that you cannot conclude anything about the distribution of $y$, because it depends on the distribution of the $x$'s and the strength and shape of the relationship. More formally, $y$ will have a "mixture of normals" distribution, which in practice can be pretty much anything. Here are two extreme examples to illustrate this: Suppose there are only two possible $x$ values, 0 an 1, and $y = 10x + N(0,1)$. Then $y$ will have a strongly bimodal distribution with bumps at 0 and 10. Now assume the same relationship, but let $x$ be uniformly distributed on the 0-1 interval with lots of values. Then $y$ will be almost uniformly distributed over the 0-10 interval (with some half-normal tails at the edges). In fact, since every distribution can be approximated arbitrarily well with mixture of normals, you can really get any distribution for $y$.
How does the distribution of the error term affect the distribution of the response? The short answer is that you cannot conclude anything about the distribution of $y$, because it depends on the distribution of the $x$'s and the strength and shape of the relationship. More formally,
18,111
How does the distribution of the error term affect the distribution of the response?
We invent the error term by imposing a fictitious model on real data; the distribution of the error term does not affect the distribution of the response. We often assume that the error is distributed normally and thus try to construct the model such that our estimated residuals are normally distributed. This can be difficult for some distributions of $y$. In these cases, I suppose you could say that the distribution of the response affects the error term.
How does the distribution of the error term affect the distribution of the response?
We invent the error term by imposing a fictitious model on real data; the distribution of the error term does not affect the distribution of the response. We often assume that the error is distributed
How does the distribution of the error term affect the distribution of the response? We invent the error term by imposing a fictitious model on real data; the distribution of the error term does not affect the distribution of the response. We often assume that the error is distributed normally and thus try to construct the model such that our estimated residuals are normally distributed. This can be difficult for some distributions of $y$. In these cases, I suppose you could say that the distribution of the response affects the error term.
How does the distribution of the error term affect the distribution of the response? We invent the error term by imposing a fictitious model on real data; the distribution of the error term does not affect the distribution of the response. We often assume that the error is distributed
18,112
How does the distribution of the error term affect the distribution of the response?
If you write out the response as $$\bf{y}=m+e$$ Where $\bf{m}$ is the "model" (the prediction for $\bf{y}$) and $\bf{e}$ is the "errors", then this can be re-arranged to indicate $\bf{y}-m=e$. So assigning a distribution for the errors is the same thing as indicating the ways your model is incomplete. To put it another way is that it indicates to what extent you don't know why the observed response was the value that it actually was, and not what the model predicted. If you knew your model was perfect, then you would assign a probability distribution with all of its mass on zero for the errors. Assigning a $N(0,\sigma^{2})$ basically says that the errors are small in units of $\sigma$. The idea is that the model predictions tend to be "wrong" by similar amounts for different observations, and is "about right" on the scale of $\sigma$. As a contrast, an alternative assignment is $Cauchy(0,\gamma)$ which says that most of the errors are small, but some errors are quite large - the model has the occasional "blunder" or "shocker" in terms of predicting the response. In a sense the error distribution is more closely linked to the model than to the response. This can be seen from the non-identifiability of the above equation, for if both $\bf{m}$ and $\bf{e}$ are unknown then adding an arbitrary vector to $\bf{m}$ and subtracting it from $\bf{e}$ leads to the same value of $\bf{y}$, $\bf{y}=m+e=(m+b)+(e-b)=m'+e'$. The assignment of an error distribution and a model equation basically says which arbitrary vectors are more plausible than others.
How does the distribution of the error term affect the distribution of the response?
If you write out the response as $$\bf{y}=m+e$$ Where $\bf{m}$ is the "model" (the prediction for $\bf{y}$) and $\bf{e}$ is the "errors", then this can be re-arranged to indicate $\bf{y}-m=e$. So ass
How does the distribution of the error term affect the distribution of the response? If you write out the response as $$\bf{y}=m+e$$ Where $\bf{m}$ is the "model" (the prediction for $\bf{y}$) and $\bf{e}$ is the "errors", then this can be re-arranged to indicate $\bf{y}-m=e$. So assigning a distribution for the errors is the same thing as indicating the ways your model is incomplete. To put it another way is that it indicates to what extent you don't know why the observed response was the value that it actually was, and not what the model predicted. If you knew your model was perfect, then you would assign a probability distribution with all of its mass on zero for the errors. Assigning a $N(0,\sigma^{2})$ basically says that the errors are small in units of $\sigma$. The idea is that the model predictions tend to be "wrong" by similar amounts for different observations, and is "about right" on the scale of $\sigma$. As a contrast, an alternative assignment is $Cauchy(0,\gamma)$ which says that most of the errors are small, but some errors are quite large - the model has the occasional "blunder" or "shocker" in terms of predicting the response. In a sense the error distribution is more closely linked to the model than to the response. This can be seen from the non-identifiability of the above equation, for if both $\bf{m}$ and $\bf{e}$ are unknown then adding an arbitrary vector to $\bf{m}$ and subtracting it from $\bf{e}$ leads to the same value of $\bf{y}$, $\bf{y}=m+e=(m+b)+(e-b)=m'+e'$. The assignment of an error distribution and a model equation basically says which arbitrary vectors are more plausible than others.
How does the distribution of the error term affect the distribution of the response? If you write out the response as $$\bf{y}=m+e$$ Where $\bf{m}$ is the "model" (the prediction for $\bf{y}$) and $\bf{e}$ is the "errors", then this can be re-arranged to indicate $\bf{y}-m=e$. So ass
18,113
How can I calculate the probability that one random variable is bigger than a second one?
To be brutally mindless about it, we may begin with the full five-dimensional integral and then proceed to evaluate it. Because this is carried out over a region in $\mathbb{R}^5,$ I will not attempt to sketch it :-). As a simplification of the notation (and to reveal the ideas), let the joint density of $(X_1,X_2,X_3)$ be $f_{123} $ and the joint density of $(X_4,X_5)$ be $f_{45}.$ Then, with $P = \Pr(\min(X_1,X_2,X_3) \gt \max(X_4,X_5)),$ $$P = \iint f_{45}(x_4,x_5) \iiint_{\max(x_4,x_5)} f_{123}(x_1,x_2,x_3)\,\mathrm{d}x_1\mathrm{d}x_2\mathrm{d}x_3\ \mathrm{d}x_4\mathrm{d}x_5.$$ The first (double) integral extends over all $\mathbb{R}^2$ while the second (triple) integral extends only over those points $(x_1,x_2,x_3)$ in $\mathbb{R}^3$ where all three coordinates exceed both $x_4$ and $x_5.$ It is usually easiest to deal with a maximum in an integral's endpoint by breaking the integral into parts: almost surely either $X_4$ or $X_5$ will be the larger of those two and these two events (namely, $\mathcal{E}_4:X_4=\max(X_4,X_5)$ and $\mathcal{E}_4:X_5=\max(X_4,X_5)$) are mutually exclusive. Therefore we may compute the probabilities of these two events and add them. Because $X_4$ and $X_5$ are iid, they are exchangeable, implying $\mathcal{E}_4$ and $\mathcal{E}_5$ have the same probability. Consequently, taking the case $X_4\gt X_5$ (event $\mathcal{E}_4$), we obtain $$P = 2\int\int_{x_5} f_{45}(x_4,x_5) \iiint_{x_4} f_{123}(x_1,x_2,x_3)\,\mathrm{d}x_1\mathrm{d}x_2\mathrm{d}x_3\ \mathrm{d}x_4\mathrm{d}x_5.$$ Specializing now to iid uniform$[0,1]$ variables we may compute this integral using the most elementary techniques as $$\begin{aligned} P &= 2\int_0^1\int_{x_5}^1\int_{x_4}^1\int_{x_4}^1\int_{x_4}^1\,\mathrm{d}x_1\mathrm{d}x_2\mathrm{d}x_3\mathrm{d}x_4\mathrm{d}x_5 \\ &= 2\int_0^1\int_{x_5}^1 \left(\int_{x_4}^1\mathrm{d}x_1\right)\left(\int_{x_4}^1\mathrm{d}x_2\right)\left(\int_{x_4}^1\mathrm{d}x_3\right)\,\mathrm{d}x_4\mathrm{d}x_5 \\ &= 2\int_0^1\int_{x_5}^1(1-x_4)^3\mathrm{d}x_4\mathrm{d}x_5 \\ &= 2\int_0^1 \frac{1}{4}(1-x_5)^4\,\mathrm{d}x_5 \\ &= 2\left(\frac{1}{4}\right)\left(\frac{1}{5}\right) = \frac{1}{10}. \end{aligned}$$ This gives the answer for any continuous iid variables with common density $f$ because the Probability Integral Transform $$u(x) = \int^x f(t)\,\mathrm{d}t,$$ converts the variables $(X_1,\ldots, X_5)$ into variables $U_i = u(X_i)$ that are iid with a Uniform$[0,1]$ distribution without changing the order statistics, thereby leading to the calculation of $P$ that was just performed.
How can I calculate the probability that one random variable is bigger than a second one?
To be brutally mindless about it, we may begin with the full five-dimensional integral and then proceed to evaluate it. Because this is carried out over a region in $\mathbb{R}^5,$ I will not attempt
How can I calculate the probability that one random variable is bigger than a second one? To be brutally mindless about it, we may begin with the full five-dimensional integral and then proceed to evaluate it. Because this is carried out over a region in $\mathbb{R}^5,$ I will not attempt to sketch it :-). As a simplification of the notation (and to reveal the ideas), let the joint density of $(X_1,X_2,X_3)$ be $f_{123} $ and the joint density of $(X_4,X_5)$ be $f_{45}.$ Then, with $P = \Pr(\min(X_1,X_2,X_3) \gt \max(X_4,X_5)),$ $$P = \iint f_{45}(x_4,x_5) \iiint_{\max(x_4,x_5)} f_{123}(x_1,x_2,x_3)\,\mathrm{d}x_1\mathrm{d}x_2\mathrm{d}x_3\ \mathrm{d}x_4\mathrm{d}x_5.$$ The first (double) integral extends over all $\mathbb{R}^2$ while the second (triple) integral extends only over those points $(x_1,x_2,x_3)$ in $\mathbb{R}^3$ where all three coordinates exceed both $x_4$ and $x_5.$ It is usually easiest to deal with a maximum in an integral's endpoint by breaking the integral into parts: almost surely either $X_4$ or $X_5$ will be the larger of those two and these two events (namely, $\mathcal{E}_4:X_4=\max(X_4,X_5)$ and $\mathcal{E}_4:X_5=\max(X_4,X_5)$) are mutually exclusive. Therefore we may compute the probabilities of these two events and add them. Because $X_4$ and $X_5$ are iid, they are exchangeable, implying $\mathcal{E}_4$ and $\mathcal{E}_5$ have the same probability. Consequently, taking the case $X_4\gt X_5$ (event $\mathcal{E}_4$), we obtain $$P = 2\int\int_{x_5} f_{45}(x_4,x_5) \iiint_{x_4} f_{123}(x_1,x_2,x_3)\,\mathrm{d}x_1\mathrm{d}x_2\mathrm{d}x_3\ \mathrm{d}x_4\mathrm{d}x_5.$$ Specializing now to iid uniform$[0,1]$ variables we may compute this integral using the most elementary techniques as $$\begin{aligned} P &= 2\int_0^1\int_{x_5}^1\int_{x_4}^1\int_{x_4}^1\int_{x_4}^1\,\mathrm{d}x_1\mathrm{d}x_2\mathrm{d}x_3\mathrm{d}x_4\mathrm{d}x_5 \\ &= 2\int_0^1\int_{x_5}^1 \left(\int_{x_4}^1\mathrm{d}x_1\right)\left(\int_{x_4}^1\mathrm{d}x_2\right)\left(\int_{x_4}^1\mathrm{d}x_3\right)\,\mathrm{d}x_4\mathrm{d}x_5 \\ &= 2\int_0^1\int_{x_5}^1(1-x_4)^3\mathrm{d}x_4\mathrm{d}x_5 \\ &= 2\int_0^1 \frac{1}{4}(1-x_5)^4\,\mathrm{d}x_5 \\ &= 2\left(\frac{1}{4}\right)\left(\frac{1}{5}\right) = \frac{1}{10}. \end{aligned}$$ This gives the answer for any continuous iid variables with common density $f$ because the Probability Integral Transform $$u(x) = \int^x f(t)\,\mathrm{d}t,$$ converts the variables $(X_1,\ldots, X_5)$ into variables $U_i = u(X_i)$ that are iid with a Uniform$[0,1]$ distribution without changing the order statistics, thereby leading to the calculation of $P$ that was just performed.
How can I calculate the probability that one random variable is bigger than a second one? To be brutally mindless about it, we may begin with the full five-dimensional integral and then proceed to evaluate it. Because this is carried out over a region in $\mathbb{R}^5,$ I will not attempt
18,114
How can I calculate the probability that one random variable is bigger than a second one?
For all input values $0 \leq t \leq 2$ we have, \begin{align*} \mathbb P (\min(X_1,X_2,X_3) > t ) &= \mathbb P(X_1>t)^3 \\[12pt] &= \Big (1 - \frac{t}{2} \Big )^3 \\[12pt] \mathbb P (\max(X_4,X_5) \leq t ) &= \mathbb P(X_4\leq t)^2 \\[12pt] &= \frac{t^2}{4}, \\[6pt] \end{align*} which also gives the corresponding density, \begin{align*} \quad f_{\max(X_4,X_5)}(t) &= \frac{t}{2}. \\[6pt] \end{align*} Thus, using the substitution $r = t/2$, we have, \begin{align*} \mathbb P (\min(X_1,X_2,X_3) > \max(X_4,X_5 )) &= \int \limits_0^2 \mathbb P (\min(X_1,X_2,X_3) > t ) \frac{t}{2} \ dt \\[6pt] &=\int \limits_0^2 \Big (1 - \frac{t}{2} \Big )^3 \frac{t}{2} \ dt \\[6pt] &= 2 \int \limits_0^1 (1-r)^3 r \ dr \\[6pt] &= 2 \int \limits_0^1 (r - 3r^2 + 3r^3 - r^4) \ dr \\[6pt] &= 2 \Bigg[ \frac{r^2}{2} - r^3 + \frac{3r^4}{4} - \frac{r^5}{5} \Bigg ]_{r=0}^{r=1} \\[12pt] &= 2 \Bigg[ \frac{1}{2} - 1 + \frac{3}{4} - \frac{1}{5} \Bigg ] \\[12pt] &= 0.1 \\[6pt] \end{align*}
How can I calculate the probability that one random variable is bigger than a second one?
For all input values $0 \leq t \leq 2$ we have, \begin{align*} \mathbb P (\min(X_1,X_2,X_3) > t ) &= \mathbb P(X_1>t)^3 \\[12pt] &= \Big (1 - \frac{t}{2} \Big )^3 \\[12pt] \mathbb P (\max(X_4,X_5) \le
How can I calculate the probability that one random variable is bigger than a second one? For all input values $0 \leq t \leq 2$ we have, \begin{align*} \mathbb P (\min(X_1,X_2,X_3) > t ) &= \mathbb P(X_1>t)^3 \\[12pt] &= \Big (1 - \frac{t}{2} \Big )^3 \\[12pt] \mathbb P (\max(X_4,X_5) \leq t ) &= \mathbb P(X_4\leq t)^2 \\[12pt] &= \frac{t^2}{4}, \\[6pt] \end{align*} which also gives the corresponding density, \begin{align*} \quad f_{\max(X_4,X_5)}(t) &= \frac{t}{2}. \\[6pt] \end{align*} Thus, using the substitution $r = t/2$, we have, \begin{align*} \mathbb P (\min(X_1,X_2,X_3) > \max(X_4,X_5 )) &= \int \limits_0^2 \mathbb P (\min(X_1,X_2,X_3) > t ) \frac{t}{2} \ dt \\[6pt] &=\int \limits_0^2 \Big (1 - \frac{t}{2} \Big )^3 \frac{t}{2} \ dt \\[6pt] &= 2 \int \limits_0^1 (1-r)^3 r \ dr \\[6pt] &= 2 \int \limits_0^1 (r - 3r^2 + 3r^3 - r^4) \ dr \\[6pt] &= 2 \Bigg[ \frac{r^2}{2} - r^3 + \frac{3r^4}{4} - \frac{r^5}{5} \Bigg ]_{r=0}^{r=1} \\[12pt] &= 2 \Bigg[ \frac{1}{2} - 1 + \frac{3}{4} - \frac{1}{5} \Bigg ] \\[12pt] &= 0.1 \\[6pt] \end{align*}
How can I calculate the probability that one random variable is bigger than a second one? For all input values $0 \leq t \leq 2$ we have, \begin{align*} \mathbb P (\min(X_1,X_2,X_3) > t ) &= \mathbb P(X_1>t)^3 \\[12pt] &= \Big (1 - \frac{t}{2} \Big )^3 \\[12pt] \mathbb P (\max(X_4,X_5) \le
18,115
How can I calculate the probability that one random variable is bigger than a second one?
Solution using automated computer algebra systems: Let $(X_1, ..., X_5)$ have joint pdf $f(x_1,..., x_5)$: Then: ... where I am using the Prob function from the mathStatica package for Mathematica. Always nice to check work and existence of exact solutions.
How can I calculate the probability that one random variable is bigger than a second one?
Solution using automated computer algebra systems: Let $(X_1, ..., X_5)$ have joint pdf $f(x_1,..., x_5)$: Then: ... where I am using the Prob function from the mathStatica package for Mathematica.
How can I calculate the probability that one random variable is bigger than a second one? Solution using automated computer algebra systems: Let $(X_1, ..., X_5)$ have joint pdf $f(x_1,..., x_5)$: Then: ... where I am using the Prob function from the mathStatica package for Mathematica. Always nice to check work and existence of exact solutions.
How can I calculate the probability that one random variable is bigger than a second one? Solution using automated computer algebra systems: Let $(X_1, ..., X_5)$ have joint pdf $f(x_1,..., x_5)$: Then: ... where I am using the Prob function from the mathStatica package for Mathematica.
18,116
How can I calculate the probability that one random variable is bigger than a second one?
How can I calculate the probability that one random variable is bigger than a second one? You could integrate over the joint distribution in the area where the condition $X>Y$ is true. You could derive the distribution for the variable $X-Y$ and use it to compute $P(X-Y>0)$. Below is an example of the first option You variables $X = min(X_1,X_2,X_3)$ and $Y = max(X_4,X_5)$ are independent and follow the beta distribution with pdf's (without loss of generality I am scaling from [0,2] to [0,1]) $$\begin{array}{rcl} f_X(x) &=& 3(1-x)^2 \\ f_Y(y) &=& 2y \end{array}$$ I've plotted a randomly generated sample of this in the image below. What you want to know is the probability that $X>Y$ and this corresponds to a point being on the bottom of the diagonal line $X=Y$. You can find this probability by integrating the probability density of the points below that diagonal line. $$\begin{array}{rcl} P(X > Y) &=& \int_0^1 \int_0^x 6 (1-x)^2 y \, dy dx \\&=& \int_0^1 6(1-x)^2 \left[ \int_0^x y \, dy \right] \, dx \\ &=& \int_0^1 3 (1-x)^2 x^2 \, dx \\ &=& 3 \int_0^1 x^2 - 2x^3 + x^4 \, dx \\ &=& 3 (\frac{1}{3} - \frac{2}{4} + \frac{1}{5}) \\ & =& \frac{1}{10} \end{array}$$ I believe that its is slightly more intuitive and easy than doing the quintuple integral. However, when your question would have been like $X = min(X_1,X_2,X_3)$ and $Y = max(X_3,X_4)$ then the variables are not independent and it may not be so easy to write down the joint pdf.
How can I calculate the probability that one random variable is bigger than a second one?
How can I calculate the probability that one random variable is bigger than a second one? You could integrate over the joint distribution in the area where the condition $X>Y$ is true. You could der
How can I calculate the probability that one random variable is bigger than a second one? How can I calculate the probability that one random variable is bigger than a second one? You could integrate over the joint distribution in the area where the condition $X>Y$ is true. You could derive the distribution for the variable $X-Y$ and use it to compute $P(X-Y>0)$. Below is an example of the first option You variables $X = min(X_1,X_2,X_3)$ and $Y = max(X_4,X_5)$ are independent and follow the beta distribution with pdf's (without loss of generality I am scaling from [0,2] to [0,1]) $$\begin{array}{rcl} f_X(x) &=& 3(1-x)^2 \\ f_Y(y) &=& 2y \end{array}$$ I've plotted a randomly generated sample of this in the image below. What you want to know is the probability that $X>Y$ and this corresponds to a point being on the bottom of the diagonal line $X=Y$. You can find this probability by integrating the probability density of the points below that diagonal line. $$\begin{array}{rcl} P(X > Y) &=& \int_0^1 \int_0^x 6 (1-x)^2 y \, dy dx \\&=& \int_0^1 6(1-x)^2 \left[ \int_0^x y \, dy \right] \, dx \\ &=& \int_0^1 3 (1-x)^2 x^2 \, dx \\ &=& 3 \int_0^1 x^2 - 2x^3 + x^4 \, dx \\ &=& 3 (\frac{1}{3} - \frac{2}{4} + \frac{1}{5}) \\ & =& \frac{1}{10} \end{array}$$ I believe that its is slightly more intuitive and easy than doing the quintuple integral. However, when your question would have been like $X = min(X_1,X_2,X_3)$ and $Y = max(X_3,X_4)$ then the variables are not independent and it may not be so easy to write down the joint pdf.
How can I calculate the probability that one random variable is bigger than a second one? How can I calculate the probability that one random variable is bigger than a second one? You could integrate over the joint distribution in the area where the condition $X>Y$ is true. You could der
18,117
I don't understand the variance of the binomial
A random variable $X$ taking values $0$ and $1$ with probabilities $P(X=1)=p$ and $P(X=0)=1-p$ is called a Bernoulli random variable with parameter $p$. This random variable has \begin{eqnarray*} E(X)&=&0\cdot (1-p) + 1\cdot p = p\\ E(X^2)&=&0^2\cdot(1-p) + 1^2\cdot p = p\\ Var(X)&=& E(X^2)-(E(X))^2=p-p^2=p(1-p) \end{eqnarray*} Suppose you have a random sample $X_{1},X_{2},\cdots,X_{n}$ of size $n$ from $Bernoulli(p)$, and define a new random variable $Y=X_{1}+X_{2}+\cdots +X_{n}$, then the distribution of $Y$ is called Binomial, whose parameters are $n$ and $p$. The mean and variance of the Binomial random variable Y is given by \begin{eqnarray*} E(Y)&=&E(X_{1}+X_{2}+\cdots + X_{n})=\underbrace{ p+p+\cdots +p}_{n}=np\\ Var(Y)&=& Var(X_{1}+X_{2}+\cdots + X_{n})=Var(X_{1})+Var(X_{2})+\cdots + Var(X_{n})\\ & &\text{ (as $X_{i}$'s are independent)} \\ &=&\underbrace{p(1-p)+p(1-p)+\cdots+ p(1-p)}_{n}\quad \text{ (as $X_{i}$'s are identically distributed)} \\ &=&np(1-p) \end{eqnarray*}
I don't understand the variance of the binomial
A random variable $X$ taking values $0$ and $1$ with probabilities $P(X=1)=p$ and $P(X=0)=1-p$ is called a Bernoulli random variable with parameter $p$. This random variable has \begin{eqnarray*} E(X)
I don't understand the variance of the binomial A random variable $X$ taking values $0$ and $1$ with probabilities $P(X=1)=p$ and $P(X=0)=1-p$ is called a Bernoulli random variable with parameter $p$. This random variable has \begin{eqnarray*} E(X)&=&0\cdot (1-p) + 1\cdot p = p\\ E(X^2)&=&0^2\cdot(1-p) + 1^2\cdot p = p\\ Var(X)&=& E(X^2)-(E(X))^2=p-p^2=p(1-p) \end{eqnarray*} Suppose you have a random sample $X_{1},X_{2},\cdots,X_{n}$ of size $n$ from $Bernoulli(p)$, and define a new random variable $Y=X_{1}+X_{2}+\cdots +X_{n}$, then the distribution of $Y$ is called Binomial, whose parameters are $n$ and $p$. The mean and variance of the Binomial random variable Y is given by \begin{eqnarray*} E(Y)&=&E(X_{1}+X_{2}+\cdots + X_{n})=\underbrace{ p+p+\cdots +p}_{n}=np\\ Var(Y)&=& Var(X_{1}+X_{2}+\cdots + X_{n})=Var(X_{1})+Var(X_{2})+\cdots + Var(X_{n})\\ & &\text{ (as $X_{i}$'s are independent)} \\ &=&\underbrace{p(1-p)+p(1-p)+\cdots+ p(1-p)}_{n}\quad \text{ (as $X_{i}$'s are identically distributed)} \\ &=&np(1-p) \end{eqnarray*}
I don't understand the variance of the binomial A random variable $X$ taking values $0$ and $1$ with probabilities $P(X=1)=p$ and $P(X=0)=1-p$ is called a Bernoulli random variable with parameter $p$. This random variable has \begin{eqnarray*} E(X)
18,118
I don't understand the variance of the binomial
Two mistakes in your proving process: 1: $X$ in first paragraph has different definition comparing with $X$ in the rest of article. 2: Under the condition that $X$ ~ $Bin(p, n)$, $E(X^2) \ne E(X)$. Try to work from $E(X^2) = \sum {\left(x^2\Pr(X=x)\right)}$
I don't understand the variance of the binomial
Two mistakes in your proving process: 1: $X$ in first paragraph has different definition comparing with $X$ in the rest of article. 2: Under the condition that $X$ ~ $Bin(p, n)$, $E(X^2) \ne E(X)$. Tr
I don't understand the variance of the binomial Two mistakes in your proving process: 1: $X$ in first paragraph has different definition comparing with $X$ in the rest of article. 2: Under the condition that $X$ ~ $Bin(p, n)$, $E(X^2) \ne E(X)$. Try to work from $E(X^2) = \sum {\left(x^2\Pr(X=x)\right)}$
I don't understand the variance of the binomial Two mistakes in your proving process: 1: $X$ in first paragraph has different definition comparing with $X$ in the rest of article. 2: Under the condition that $X$ ~ $Bin(p, n)$, $E(X^2) \ne E(X)$. Tr
18,119
What statistical methods are there to recommend a movie like on Netflix?
This is actually a relatively famous problem in the field of machine learning. In ~2006 Netflix offered $1m to the algorithm that provided the best reasonable improvement to their recommender system. The theory of the winning solution is briefly discussed in this Caltech textbook on introductory machine learning. Basically an ensemble learning method was used. In particular, a type of blending or stacking was employed. This is nontrivial, but kind of intuitive. To understand the intuition of using different statistical approaches in harmony, consider the different reasons different people like the same movies: i.e., Joe may like Topgun because he loves 80s action movies, while Jane likes Topgun because she likes movies with Kenny Loggins soundtracks. So the fact that both viewers watched (and rated the movie highly) doesn't necessarily mean they will like other movies with high probability. The prediction algorithm would ideally be able to accommodate these differences, at least in some capacity. This may make the solution sound pretty simple, but balancing competing algorithms and prioritizing the best guess for each case is definitely not simple. The fact that Netflix offered such a large bounty should make the magnitude of the challenge rather obvious. If you are just starting in machine learning, checking out the above resources may be helpful depending on your interest level and your maths background. So regression would probably work okay-to-good, but significantly better performance is possible.
What statistical methods are there to recommend a movie like on Netflix?
This is actually a relatively famous problem in the field of machine learning. In ~2006 Netflix offered $1m to the algorithm that provided the best reasonable improvement to their recommender system.
What statistical methods are there to recommend a movie like on Netflix? This is actually a relatively famous problem in the field of machine learning. In ~2006 Netflix offered $1m to the algorithm that provided the best reasonable improvement to their recommender system. The theory of the winning solution is briefly discussed in this Caltech textbook on introductory machine learning. Basically an ensemble learning method was used. In particular, a type of blending or stacking was employed. This is nontrivial, but kind of intuitive. To understand the intuition of using different statistical approaches in harmony, consider the different reasons different people like the same movies: i.e., Joe may like Topgun because he loves 80s action movies, while Jane likes Topgun because she likes movies with Kenny Loggins soundtracks. So the fact that both viewers watched (and rated the movie highly) doesn't necessarily mean they will like other movies with high probability. The prediction algorithm would ideally be able to accommodate these differences, at least in some capacity. This may make the solution sound pretty simple, but balancing competing algorithms and prioritizing the best guess for each case is definitely not simple. The fact that Netflix offered such a large bounty should make the magnitude of the challenge rather obvious. If you are just starting in machine learning, checking out the above resources may be helpful depending on your interest level and your maths background. So regression would probably work okay-to-good, but significantly better performance is possible.
What statistical methods are there to recommend a movie like on Netflix? This is actually a relatively famous problem in the field of machine learning. In ~2006 Netflix offered $1m to the algorithm that provided the best reasonable improvement to their recommender system.
18,120
What statistical methods are there to recommend a movie like on Netflix?
Half the challenge in these problems is knowing what to search for. You might have added the tag without realizing it, but you're in fact looking for info on recommender systems. You might want to start with collaborative filtering, or better yet the Introduction to Recommender Systems Handbook by Ricci, Rokach, and Shapira cited on that page.
What statistical methods are there to recommend a movie like on Netflix?
Half the challenge in these problems is knowing what to search for. You might have added the tag without realizing it, but you're in fact looking for info on recommender systems. You might want to sta
What statistical methods are there to recommend a movie like on Netflix? Half the challenge in these problems is knowing what to search for. You might have added the tag without realizing it, but you're in fact looking for info on recommender systems. You might want to start with collaborative filtering, or better yet the Introduction to Recommender Systems Handbook by Ricci, Rokach, and Shapira cited on that page.
What statistical methods are there to recommend a movie like on Netflix? Half the challenge in these problems is knowing what to search for. You might have added the tag without realizing it, but you're in fact looking for info on recommender systems. You might want to sta
18,121
What statistical methods are there to recommend a movie like on Netflix?
You should check out Andrew Ng's course on Coursera: https://www.coursera.org/learn/machine-learning It has a lesson on building recommender systems, which appears to be what you're looking for. Essentially it is a form of linear regression that learns synthetic attributes for movies from people that rated films and uses that to predict recommendations for people that didn't rate/watch the films.
What statistical methods are there to recommend a movie like on Netflix?
You should check out Andrew Ng's course on Coursera: https://www.coursera.org/learn/machine-learning It has a lesson on building recommender systems, which appears to be what you're looking for. Esse
What statistical methods are there to recommend a movie like on Netflix? You should check out Andrew Ng's course on Coursera: https://www.coursera.org/learn/machine-learning It has a lesson on building recommender systems, which appears to be what you're looking for. Essentially it is a form of linear regression that learns synthetic attributes for movies from people that rated films and uses that to predict recommendations for people that didn't rate/watch the films.
What statistical methods are there to recommend a movie like on Netflix? You should check out Andrew Ng's course on Coursera: https://www.coursera.org/learn/machine-learning It has a lesson on building recommender systems, which appears to be what you're looking for. Esse
18,122
What statistical methods are there to recommend a movie like on Netflix?
In the Netflix Challenge (Oct 2006 - Sep 2009) a very large ensemble (107 separate submodels) won the $1M grand prize in the end, but it is instructive to note that the first simple (non ensembled) algorithms to beat the Netflix Cinematch benchmark were based on a generalized (sparse matrix) SVD. This first milestone of beating Cinematch was achieved a mere 6 days after the competition begun by a team called WXYZConsulting. SVD (Singular Value Decomposition) is a matrix factorization algorithm where you start with a 2d [user, movie] matrix with a rating (1 to 5 stars) in each [u, m] position (*), and break it into 3 matrices where the middle matrix is a square-matrix of latent interactions between users and movies. You can make the square matrix rank smaller or larger to include more or less such latent factor interactions respectively. There are several free software implementations of fast/efficient sparse SVD. For example redsvd, or vowpal-wabbit so before you write your own, you may want to try them. (*) Most of these entries are zero, since most users haven't rated most movies. i.e. the matrix is very sparse. References: How the Netflix prize was won Netflix prize, Wikipedia entry TheBellKor solution to the Netflix Prize: By Robert Bell, Yehuda Koren, & Chris Volinsky RedSVD: randomized Singular Value Decomposition vowpal wabbit: matrix factorization example
What statistical methods are there to recommend a movie like on Netflix?
In the Netflix Challenge (Oct 2006 - Sep 2009) a very large ensemble (107 separate submodels) won the $1M grand prize in the end, but it is instructive to note that the first simple (non ensembled) al
What statistical methods are there to recommend a movie like on Netflix? In the Netflix Challenge (Oct 2006 - Sep 2009) a very large ensemble (107 separate submodels) won the $1M grand prize in the end, but it is instructive to note that the first simple (non ensembled) algorithms to beat the Netflix Cinematch benchmark were based on a generalized (sparse matrix) SVD. This first milestone of beating Cinematch was achieved a mere 6 days after the competition begun by a team called WXYZConsulting. SVD (Singular Value Decomposition) is a matrix factorization algorithm where you start with a 2d [user, movie] matrix with a rating (1 to 5 stars) in each [u, m] position (*), and break it into 3 matrices where the middle matrix is a square-matrix of latent interactions between users and movies. You can make the square matrix rank smaller or larger to include more or less such latent factor interactions respectively. There are several free software implementations of fast/efficient sparse SVD. For example redsvd, or vowpal-wabbit so before you write your own, you may want to try them. (*) Most of these entries are zero, since most users haven't rated most movies. i.e. the matrix is very sparse. References: How the Netflix prize was won Netflix prize, Wikipedia entry TheBellKor solution to the Netflix Prize: By Robert Bell, Yehuda Koren, & Chris Volinsky RedSVD: randomized Singular Value Decomposition vowpal wabbit: matrix factorization example
What statistical methods are there to recommend a movie like on Netflix? In the Netflix Challenge (Oct 2006 - Sep 2009) a very large ensemble (107 separate submodels) won the $1M grand prize in the end, but it is instructive to note that the first simple (non ensembled) al
18,123
Bayesian vs MLE, overfitting problem
Optimisation is the root of all evil in statistics. Any time you make choices about your model$^1$ by optimising some suitable criterion evaluated on a finite sample of data you run the risk of over-fitting the criterion, i.e. reducing the statistic beyond the point where improvements in generalisation performance are obtained and the reduction is instead gained by exploiting the peculiarities of the sample of data, e.g. noise). The reason the Bayesian method works better is that you don't optimise anything, but instead marginalise (integrate) over all possible choices. The problem then lies in the choice of prior beliefs regarding the model, so one problem has gone away, but another one appears in its place. $^1$ This includes maximising the evidence (marginal likelihood) in a Bayesian setting. For an example of this, see the results for Gaussian Process classifiers in my paper, where optimising the marginal likelihood makes the model worse if you have too many hyper-parameters (note selection according to marginal likelihood will tend to favour models with lots of hyper-parameters as a result of this form of over-fitting). G. C. Cawley and N. L. C. Talbot, Over-fitting in model selection and subsequent selection bias in performance evaluation, Journal of Machine Learning Research, 2010. Research, vol. 11, pp. 2079-2107, July 2010. (pdf)
Bayesian vs MLE, overfitting problem
Optimisation is the root of all evil in statistics. Any time you make choices about your model$^1$ by optimising some suitable criterion evaluated on a finite sample of data you run the risk of over-
Bayesian vs MLE, overfitting problem Optimisation is the root of all evil in statistics. Any time you make choices about your model$^1$ by optimising some suitable criterion evaluated on a finite sample of data you run the risk of over-fitting the criterion, i.e. reducing the statistic beyond the point where improvements in generalisation performance are obtained and the reduction is instead gained by exploiting the peculiarities of the sample of data, e.g. noise). The reason the Bayesian method works better is that you don't optimise anything, but instead marginalise (integrate) over all possible choices. The problem then lies in the choice of prior beliefs regarding the model, so one problem has gone away, but another one appears in its place. $^1$ This includes maximising the evidence (marginal likelihood) in a Bayesian setting. For an example of this, see the results for Gaussian Process classifiers in my paper, where optimising the marginal likelihood makes the model worse if you have too many hyper-parameters (note selection according to marginal likelihood will tend to favour models with lots of hyper-parameters as a result of this form of over-fitting). G. C. Cawley and N. L. C. Talbot, Over-fitting in model selection and subsequent selection bias in performance evaluation, Journal of Machine Learning Research, 2010. Research, vol. 11, pp. 2079-2107, July 2010. (pdf)
Bayesian vs MLE, overfitting problem Optimisation is the root of all evil in statistics. Any time you make choices about your model$^1$ by optimising some suitable criterion evaluated on a finite sample of data you run the risk of over-
18,124
Bayesian vs MLE, overfitting problem
As a general response, if you're using "least squares" type regression models there really isn't much difference between bayes and ML, unless you use an informative prior for the regression parameters. In response to specifics: 1)$ H_9 $ won't necessarily overfit the data - only when you have close to 9 observations. If you had 100 observations, most of the supposedly "overfitted" coefficients will be close to zero. Also $ H_1 $ would almost always result in "underfitting" - as there would be clear curvature missed 2) This is, not true for "linear" like polynomial expansions ("linear" meaning linear with respect to parameters, not $ x $). ML estimates for least squares are identical to posterior means under non informative priors or large sample sizes. In fact you can show that ML estimates can be thought of as "asymptotic" posterior means under a variety of models. 3) The Bayesian approach can avoid overfitting only for proper priors. This operates in a similar manner to penalty terms you see in some fitting algorithms. For example, L2 penalty = normal prior, L1 penalty = laplace prior.
Bayesian vs MLE, overfitting problem
As a general response, if you're using "least squares" type regression models there really isn't much difference between bayes and ML, unless you use an informative prior for the regression parameters
Bayesian vs MLE, overfitting problem As a general response, if you're using "least squares" type regression models there really isn't much difference between bayes and ML, unless you use an informative prior for the regression parameters. In response to specifics: 1)$ H_9 $ won't necessarily overfit the data - only when you have close to 9 observations. If you had 100 observations, most of the supposedly "overfitted" coefficients will be close to zero. Also $ H_1 $ would almost always result in "underfitting" - as there would be clear curvature missed 2) This is, not true for "linear" like polynomial expansions ("linear" meaning linear with respect to parameters, not $ x $). ML estimates for least squares are identical to posterior means under non informative priors or large sample sizes. In fact you can show that ML estimates can be thought of as "asymptotic" posterior means under a variety of models. 3) The Bayesian approach can avoid overfitting only for proper priors. This operates in a similar manner to penalty terms you see in some fitting algorithms. For example, L2 penalty = normal prior, L1 penalty = laplace prior.
Bayesian vs MLE, overfitting problem As a general response, if you're using "least squares" type regression models there really isn't much difference between bayes and ML, unless you use an informative prior for the regression parameters
18,125
Bayesian vs MLE, overfitting problem
Basically, what you're doing by increasing the degrees of your polynomials is increasing the number of parameters or degrees of freedom of your model space, ie. its dimension. The more parameters you add, the more the model can fit the training data easily. But this also depends heavily on the number of observations. Your models $H_1$ and $H_2$ might just as well overfit the training data if the number of observations is low, just as $H_3$ may not overfit at all if the number of training instances is large enough. For example, let's grossly exaggerate and suppose you are given only $2$ training examples, than even $H_1$ will always overfit your data. The advantage of imposing priors for instance through regularisation is that the parameters are either shrunk to zero or some other predefined value (you can even add parameters to "tie" the coefficients together if you like), and thus you are implicitly constraining the parameters and reducing the "freedom" of your model to overfit. For example, using the lasso (ie. $l^1$ regularisation or equivalently a Laplace prior) and tuning the corresponding parameter (using 10x cross validation for example) will automatically get rid of the surplus parameters. The Bayesian interpretation is similar : by imposing priors, you are constraining your parameters to some more probable value, inferred from the overall data.
Bayesian vs MLE, overfitting problem
Basically, what you're doing by increasing the degrees of your polynomials is increasing the number of parameters or degrees of freedom of your model space, ie. its dimension. The more parameters you
Bayesian vs MLE, overfitting problem Basically, what you're doing by increasing the degrees of your polynomials is increasing the number of parameters or degrees of freedom of your model space, ie. its dimension. The more parameters you add, the more the model can fit the training data easily. But this also depends heavily on the number of observations. Your models $H_1$ and $H_2$ might just as well overfit the training data if the number of observations is low, just as $H_3$ may not overfit at all if the number of training instances is large enough. For example, let's grossly exaggerate and suppose you are given only $2$ training examples, than even $H_1$ will always overfit your data. The advantage of imposing priors for instance through regularisation is that the parameters are either shrunk to zero or some other predefined value (you can even add parameters to "tie" the coefficients together if you like), and thus you are implicitly constraining the parameters and reducing the "freedom" of your model to overfit. For example, using the lasso (ie. $l^1$ regularisation or equivalently a Laplace prior) and tuning the corresponding parameter (using 10x cross validation for example) will automatically get rid of the surplus parameters. The Bayesian interpretation is similar : by imposing priors, you are constraining your parameters to some more probable value, inferred from the overall data.
Bayesian vs MLE, overfitting problem Basically, what you're doing by increasing the degrees of your polynomials is increasing the number of parameters or degrees of freedom of your model space, ie. its dimension. The more parameters you
18,126
Confusion regarding when to use $z$-statistics vs. $t$-statistics
You are correct, it should be a t-distribution. But since the sample size is 36 (i.e > 20), a z distribution would also be appropriate. Remember, as the sample size grows, the t-distribution becomes more similar to the z-distribution in shape.
Confusion regarding when to use $z$-statistics vs. $t$-statistics
You are correct, it should be a t-distribution. But since the sample size is 36 (i.e > 20), a z distribution would also be appropriate. Remember, as the sample size grows, the t-distribution becomes m
Confusion regarding when to use $z$-statistics vs. $t$-statistics You are correct, it should be a t-distribution. But since the sample size is 36 (i.e > 20), a z distribution would also be appropriate. Remember, as the sample size grows, the t-distribution becomes more similar to the z-distribution in shape.
Confusion regarding when to use $z$-statistics vs. $t$-statistics You are correct, it should be a t-distribution. But since the sample size is 36 (i.e > 20), a z distribution would also be appropriate. Remember, as the sample size grows, the t-distribution becomes m
18,127
Confusion regarding when to use $z$-statistics vs. $t$-statistics
Back when I took my first statistics course (after the dinosaurs, but when real computers still took up an entire room) we were taught to use the z table if there were more than 30 degrees of freedom, partly because the t table in the book only went up to 30 degrees of freedom and if you look at the t-table you will see that somewhere around 28 degrees of freedom you get the same results as the z table to 2 significant digits (and when doing all that by hand we tended to round more often). Perhaps the presenter is still of that school. You are correct that if you are using the sample standard deviation for a test on the mean that you really should use the t distribution regardless of size (which is much easier to do these days) and only use the z (standard normal) when you know the population standard deviation, but for practical purposes you won't often see a meaningful difference if the sample size is large.
Confusion regarding when to use $z$-statistics vs. $t$-statistics
Back when I took my first statistics course (after the dinosaurs, but when real computers still took up an entire room) we were taught to use the z table if there were more than 30 degrees of freedom,
Confusion regarding when to use $z$-statistics vs. $t$-statistics Back when I took my first statistics course (after the dinosaurs, but when real computers still took up an entire room) we were taught to use the z table if there were more than 30 degrees of freedom, partly because the t table in the book only went up to 30 degrees of freedom and if you look at the t-table you will see that somewhere around 28 degrees of freedom you get the same results as the z table to 2 significant digits (and when doing all that by hand we tended to round more often). Perhaps the presenter is still of that school. You are correct that if you are using the sample standard deviation for a test on the mean that you really should use the t distribution regardless of size (which is much easier to do these days) and only use the z (standard normal) when you know the population standard deviation, but for practical purposes you won't often see a meaningful difference if the sample size is large.
Confusion regarding when to use $z$-statistics vs. $t$-statistics Back when I took my first statistics course (after the dinosaurs, but when real computers still took up an entire room) we were taught to use the z table if there were more than 30 degrees of freedom,
18,128
Confusion regarding when to use $z$-statistics vs. $t$-statistics
I'm having a hard time working out whether Khan just over simplified things in the video or he's just wrong. I'd have to say the latter, but the problem isn't in the z or t question. He's calling what he calculates a confidence interval and then says that he's 92% confident that the population mean falls within the given range. That's quite simply not something you conclude from a confidence interval... unfortunately. So then I go back to the t vs. z question and start wondering if he made an error there. I'm thinking that perhaps not because he does state that if the sample is smaller you have to make a correction. So the other answerers are probably correct on that. He's just using z because he has already introduced it and it's close enough with the n of 36. I don't plan to go through all the videos but I'm imagining he'll introduce the t distribution later, hopefully the next one. It's really unfortunate that Khan Academy is wrong on so many areas of stats... but maybe I just feel that way because I only get pointed toward videos with problems.
Confusion regarding when to use $z$-statistics vs. $t$-statistics
I'm having a hard time working out whether Khan just over simplified things in the video or he's just wrong. I'd have to say the latter, but the problem isn't in the z or t question. He's calling wh
Confusion regarding when to use $z$-statistics vs. $t$-statistics I'm having a hard time working out whether Khan just over simplified things in the video or he's just wrong. I'd have to say the latter, but the problem isn't in the z or t question. He's calling what he calculates a confidence interval and then says that he's 92% confident that the population mean falls within the given range. That's quite simply not something you conclude from a confidence interval... unfortunately. So then I go back to the t vs. z question and start wondering if he made an error there. I'm thinking that perhaps not because he does state that if the sample is smaller you have to make a correction. So the other answerers are probably correct on that. He's just using z because he has already introduced it and it's close enough with the n of 36. I don't plan to go through all the videos but I'm imagining he'll introduce the t distribution later, hopefully the next one. It's really unfortunate that Khan Academy is wrong on so many areas of stats... but maybe I just feel that way because I only get pointed toward videos with problems.
Confusion regarding when to use $z$-statistics vs. $t$-statistics I'm having a hard time working out whether Khan just over simplified things in the video or he's just wrong. I'd have to say the latter, but the problem isn't in the z or t question. He's calling wh
18,129
Difference in Probability Measure vs. Probability Distribution
First off, I am not used to the term "Probability Distribution Function". In case you are referring to a "PDF" when you are using "Probability Distribution Function", then I would like to point out that PDF is rather the abbreviation for "Probability Density Function". Below, I will presume you meant probability density function. Second, the word "distribution" is used very differently by different people, but I will refer to the definition of this notion in the scientific community. In a nutshell: The distribution of a random variable $X$ is a measure on $\mathbb{R}$, while the PDF of $X$ is a function on $\mathbb{R}$ and the PDF doesn't even always exist. So they are very different. And now we get to the mathematical details: First, let's define the term random variable because that is what all those terms usually refer to (unless you get a step further and want to talk about random vectors or random elements, but I will restrict this here to random variables). I.e., you talk about the distribution of a random variable. Given a probability space $(\Omega, \cal{F}, p)$ ($\Omega$ is just a set, $\cal{F}$ is a sigma algebra on $\Omega$, and $p$ is a measure on $(\Omega, \cal{F})$), a random variable $X$ is a measureable map $X: \Omega \to \mathbb{R}$. Then we can define: The distribution $p_X$ of the random variable $X$ is the measure $p_X = p \circ X^{-1}$ on $\mathbb{R}.$ I.e. you push the measure $p$ from $\Omega$ forward to $\mathbb{R}$ via the measurable function $X$. Next we define the probability density function (PDF) of a random variable $X$: The PDF $f_X$ of a random variable $X$, if it exists, is the Radon-Nikodym derivative of its distribution w.r.t. the Lebesgue measure $\lambda$, i.e. $f_X = \frac{d\,p_X}{d\,\lambda}$. So the distribution $p_X$ and the PDF $f_X$ of a random variable are very different entities (to a stickler, at least). But very often, the PDF $f_X$ exists, and then it contains all of the relevant information about the distribution $p_X$ and can thus be used as a handy substitute for the unwieldy $p_X$.
Difference in Probability Measure vs. Probability Distribution
First off, I am not used to the term "Probability Distribution Function". In case you are referring to a "PDF" when you are using "Probability Distribution Function", then I would like to point out th
Difference in Probability Measure vs. Probability Distribution First off, I am not used to the term "Probability Distribution Function". In case you are referring to a "PDF" when you are using "Probability Distribution Function", then I would like to point out that PDF is rather the abbreviation for "Probability Density Function". Below, I will presume you meant probability density function. Second, the word "distribution" is used very differently by different people, but I will refer to the definition of this notion in the scientific community. In a nutshell: The distribution of a random variable $X$ is a measure on $\mathbb{R}$, while the PDF of $X$ is a function on $\mathbb{R}$ and the PDF doesn't even always exist. So they are very different. And now we get to the mathematical details: First, let's define the term random variable because that is what all those terms usually refer to (unless you get a step further and want to talk about random vectors or random elements, but I will restrict this here to random variables). I.e., you talk about the distribution of a random variable. Given a probability space $(\Omega, \cal{F}, p)$ ($\Omega$ is just a set, $\cal{F}$ is a sigma algebra on $\Omega$, and $p$ is a measure on $(\Omega, \cal{F})$), a random variable $X$ is a measureable map $X: \Omega \to \mathbb{R}$. Then we can define: The distribution $p_X$ of the random variable $X$ is the measure $p_X = p \circ X^{-1}$ on $\mathbb{R}.$ I.e. you push the measure $p$ from $\Omega$ forward to $\mathbb{R}$ via the measurable function $X$. Next we define the probability density function (PDF) of a random variable $X$: The PDF $f_X$ of a random variable $X$, if it exists, is the Radon-Nikodym derivative of its distribution w.r.t. the Lebesgue measure $\lambda$, i.e. $f_X = \frac{d\,p_X}{d\,\lambda}$. So the distribution $p_X$ and the PDF $f_X$ of a random variable are very different entities (to a stickler, at least). But very often, the PDF $f_X$ exists, and then it contains all of the relevant information about the distribution $p_X$ and can thus be used as a handy substitute for the unwieldy $p_X$.
Difference in Probability Measure vs. Probability Distribution First off, I am not used to the term "Probability Distribution Function". In case you are referring to a "PDF" when you are using "Probability Distribution Function", then I would like to point out th
18,130
Difference in Probability Measure vs. Probability Distribution
The concept of a "probability distribution" is an umbrella term that refers to a particular type of object that can be represented uniquely in multiple ways. One way to represent a probability distribution is through its probability measure, another is through its characteristic function, another is through its cumulative distribution function, and another is through its probability density function (including specification of a dominating measure for the density). All of the latter are specific mathematical objects that describe a probability distribution in a different way. The term "probability distribution" does not refer to a specific mathematical object; it can be thought of as an umbrella term that refers holistically to the "thing" that each of these objects is describing.
Difference in Probability Measure vs. Probability Distribution
The concept of a "probability distribution" is an umbrella term that refers to a particular type of object that can be represented uniquely in multiple ways. One way to represent a probability distri
Difference in Probability Measure vs. Probability Distribution The concept of a "probability distribution" is an umbrella term that refers to a particular type of object that can be represented uniquely in multiple ways. One way to represent a probability distribution is through its probability measure, another is through its characteristic function, another is through its cumulative distribution function, and another is through its probability density function (including specification of a dominating measure for the density). All of the latter are specific mathematical objects that describe a probability distribution in a different way. The term "probability distribution" does not refer to a specific mathematical object; it can be thought of as an umbrella term that refers holistically to the "thing" that each of these objects is describing.
Difference in Probability Measure vs. Probability Distribution The concept of a "probability distribution" is an umbrella term that refers to a particular type of object that can be represented uniquely in multiple ways. One way to represent a probability distri
18,131
Difference in Probability Measure vs. Probability Distribution
You mention the post from mathstack: https://math.stackexchange.com/questions/1073744/distinguishing-probability-measure-function-and-distribution The answers there are great and they should be self-sufficient. I recommend anyone to go read it if they are interested in the maths details. If you are asking here the "same" question, this is probably because you are not familiar with the terminology and the mathematics of probability theory. What I do not like about the other answers is that they are focusing on the densities instead of what is really important: distributions and measures. For this reason, here is some vocabulary, aimed at non professional mathematicians. It is a very quick and dirty presentation: Functional analysis: Distributions is a mathematical object that you develop in functional analysis and you do not need to know the details here. See https://en.wikipedia.org/wiki/Distribution_(mathematics) Density is the concept that arises FROM distribution in nice scenarios. When everything is nice, densities are the derivatives of distributions. Probability Theory: Cumulative Distribution Function, it is a "normalised" distribution, and for this reason its value over the whole domain is equal to $1$ ( over $ \mathbb R $ if you wish, $ \lim_{x \to \infty } F_X( x ) = 1$), Probability Density Function, same as above, but for Cumulative Distributions. Measure Theory: Random Variable: it is essentially a measurable function. If you do not understand this, skip it, and come back later to this topic. For now consider it as a function. All measurable functions are functions, but all functions are not measurable. However, in most situations, what you could think about is measurable. Measure: a measure is a function from sets to reals. In other words, it attributes a weight to sets of elements. Measures have to respect some properties that I do not detail here. Probability Measure: a probability measure is a normalised measure such that the measure of the whole space equals to $1$. Now that we know the vocabulary, the important theorems you should be aware are: A random variable is ALWAYS associated to a CDF (cumulative distribution function). It is not possible to have one without the other. If I explicitly define $X$ you can find the CDF of $X$ coined $F_X$ and inversely. For every CDF, there exists a unique associated probability measure. What does it mean? it means that if you start with a random variable, you have a CDF, which corresponds to a measure! And inversely! A bonus, when the PDF (probability density function) is equivalent to the CDF (in the sense that the derivative of the CDF is equal to the PDF and the anti-derivative of the PDF gives the CDF), then what I said about the CDF (that it uniquely characterises the random variable) is also true for the PDF! Be careful to cases when the PDF and CDF are not equivalent. The conclusion is that yes, distributions and measures are equivalent. If you have one, you can construct the other. This is great because it simplifies many cases where you can just work out the expression that is easier to work with.
Difference in Probability Measure vs. Probability Distribution
You mention the post from mathstack: https://math.stackexchange.com/questions/1073744/distinguishing-probability-measure-function-and-distribution The answers there are great and they should be self-s
Difference in Probability Measure vs. Probability Distribution You mention the post from mathstack: https://math.stackexchange.com/questions/1073744/distinguishing-probability-measure-function-and-distribution The answers there are great and they should be self-sufficient. I recommend anyone to go read it if they are interested in the maths details. If you are asking here the "same" question, this is probably because you are not familiar with the terminology and the mathematics of probability theory. What I do not like about the other answers is that they are focusing on the densities instead of what is really important: distributions and measures. For this reason, here is some vocabulary, aimed at non professional mathematicians. It is a very quick and dirty presentation: Functional analysis: Distributions is a mathematical object that you develop in functional analysis and you do not need to know the details here. See https://en.wikipedia.org/wiki/Distribution_(mathematics) Density is the concept that arises FROM distribution in nice scenarios. When everything is nice, densities are the derivatives of distributions. Probability Theory: Cumulative Distribution Function, it is a "normalised" distribution, and for this reason its value over the whole domain is equal to $1$ ( over $ \mathbb R $ if you wish, $ \lim_{x \to \infty } F_X( x ) = 1$), Probability Density Function, same as above, but for Cumulative Distributions. Measure Theory: Random Variable: it is essentially a measurable function. If you do not understand this, skip it, and come back later to this topic. For now consider it as a function. All measurable functions are functions, but all functions are not measurable. However, in most situations, what you could think about is measurable. Measure: a measure is a function from sets to reals. In other words, it attributes a weight to sets of elements. Measures have to respect some properties that I do not detail here. Probability Measure: a probability measure is a normalised measure such that the measure of the whole space equals to $1$. Now that we know the vocabulary, the important theorems you should be aware are: A random variable is ALWAYS associated to a CDF (cumulative distribution function). It is not possible to have one without the other. If I explicitly define $X$ you can find the CDF of $X$ coined $F_X$ and inversely. For every CDF, there exists a unique associated probability measure. What does it mean? it means that if you start with a random variable, you have a CDF, which corresponds to a measure! And inversely! A bonus, when the PDF (probability density function) is equivalent to the CDF (in the sense that the derivative of the CDF is equal to the PDF and the anti-derivative of the PDF gives the CDF), then what I said about the CDF (that it uniquely characterises the random variable) is also true for the PDF! Be careful to cases when the PDF and CDF are not equivalent. The conclusion is that yes, distributions and measures are equivalent. If you have one, you can construct the other. This is great because it simplifies many cases where you can just work out the expression that is easier to work with.
Difference in Probability Measure vs. Probability Distribution You mention the post from mathstack: https://math.stackexchange.com/questions/1073744/distinguishing-probability-measure-function-and-distribution The answers there are great and they should be self-s
18,132
Difference in Probability Measure vs. Probability Distribution
You are right, when we are just starting out our stat studies, these terms can be super confusing, especially to people that are very detail-driven or very particular about terminologies. You do need a very good understanding here before you can master the applications of them. And using R functions such as pnorm(), dnorm() forces you to understand these. And I’d say the post you quoted put it pretty well - especially where it pointed out that β€œprobability functions” - β€œprobability density function” and β€œprobability mass function” are precisely defined, and the other terms can be understood as their names suggest - that the β€œprobability measure” is a measure for the probabilities - is it cumulative or not? It doesn’t say. It’s a measure, so it can refer to both. A probability distribution can be similar. But don't confuse it with distribution function. Distribution function in most cases refers to "cumulative distribution function", which is also clearly defined as the probability taking on a value equal to or less than a specified value. Maybe an example can help This is a simple normal distribution chart. And here, The probability function - which is a probability density function here since it’s continuous variable - describes the red curve. It’s a line, that’s represented by this function $$\large{f(x)=\frac{1}{\sigma\sqrt{2\pi}}e^{-\frac{1}{2}(\frac{x-\mu}{\sigma})^2}}$$ where $\mu$ is the mean and $\sigma$ the standard deviation. Calculating integrals under this β€œred line” gets us different β€œprobability” values - for example, the orange area is an area that represents 1 standard deviation away from the mean with 34% area of the total - which is 34% probability; whereas the blue area represents 17% probability. I’d say the entire chart depicting the probabilities with a normal distribution is a probability measure and a probability distribution. But only and precisely the red line is a probability function, or more specifically, a probability density function. Don't stress too much about what exactly is the definition for "probability measure"/"probability distribution". I believe as you see more examples, you will feel comfortable using these terms.
Difference in Probability Measure vs. Probability Distribution
You are right, when we are just starting out our stat studies, these terms can be super confusing, especially to people that are very detail-driven or very particular about terminologies. You do need
Difference in Probability Measure vs. Probability Distribution You are right, when we are just starting out our stat studies, these terms can be super confusing, especially to people that are very detail-driven or very particular about terminologies. You do need a very good understanding here before you can master the applications of them. And using R functions such as pnorm(), dnorm() forces you to understand these. And I’d say the post you quoted put it pretty well - especially where it pointed out that β€œprobability functions” - β€œprobability density function” and β€œprobability mass function” are precisely defined, and the other terms can be understood as their names suggest - that the β€œprobability measure” is a measure for the probabilities - is it cumulative or not? It doesn’t say. It’s a measure, so it can refer to both. A probability distribution can be similar. But don't confuse it with distribution function. Distribution function in most cases refers to "cumulative distribution function", which is also clearly defined as the probability taking on a value equal to or less than a specified value. Maybe an example can help This is a simple normal distribution chart. And here, The probability function - which is a probability density function here since it’s continuous variable - describes the red curve. It’s a line, that’s represented by this function $$\large{f(x)=\frac{1}{\sigma\sqrt{2\pi}}e^{-\frac{1}{2}(\frac{x-\mu}{\sigma})^2}}$$ where $\mu$ is the mean and $\sigma$ the standard deviation. Calculating integrals under this β€œred line” gets us different β€œprobability” values - for example, the orange area is an area that represents 1 standard deviation away from the mean with 34% area of the total - which is 34% probability; whereas the blue area represents 17% probability. I’d say the entire chart depicting the probabilities with a normal distribution is a probability measure and a probability distribution. But only and precisely the red line is a probability function, or more specifically, a probability density function. Don't stress too much about what exactly is the definition for "probability measure"/"probability distribution". I believe as you see more examples, you will feel comfortable using these terms.
Difference in Probability Measure vs. Probability Distribution You are right, when we are just starting out our stat studies, these terms can be super confusing, especially to people that are very detail-driven or very particular about terminologies. You do need
18,133
Difference in Probability Measure vs. Probability Distribution
A probability measure $P$ is a function which associates each event with its probability. If the events are real Borel sets (nice sets of real numbers, such as intervals, finite sets etc) then in lieu of describing the probability measure (a task which is directly unwieldy) we can instead use a special kind of real valued function $F$ defined on the reals. This function is called as distribution function (or simply distribution) and it is defined so as to make $F(x)=P(-\infty,x]$. A mathematical theorem then guarantees the unique extension to the probabilities of other Borel sets. From a probability theory perspective, events are not Borel sets most of the time. However we may associate outcomes with real numbers (usually by some measurement) - this in turn induces an association of 'the practically useful events' to Borel sets; after which we proceed to use a distribution to describe the probabilities of these Borel sets.
Difference in Probability Measure vs. Probability Distribution
A probability measure $P$ is a function which associates each event with its probability. If the events are real Borel sets (nice sets of real numbers, such as intervals, finite sets etc) then in lieu
Difference in Probability Measure vs. Probability Distribution A probability measure $P$ is a function which associates each event with its probability. If the events are real Borel sets (nice sets of real numbers, such as intervals, finite sets etc) then in lieu of describing the probability measure (a task which is directly unwieldy) we can instead use a special kind of real valued function $F$ defined on the reals. This function is called as distribution function (or simply distribution) and it is defined so as to make $F(x)=P(-\infty,x]$. A mathematical theorem then guarantees the unique extension to the probabilities of other Borel sets. From a probability theory perspective, events are not Borel sets most of the time. However we may associate outcomes with real numbers (usually by some measurement) - this in turn induces an association of 'the practically useful events' to Borel sets; after which we proceed to use a distribution to describe the probabilities of these Borel sets.
Difference in Probability Measure vs. Probability Distribution A probability measure $P$ is a function which associates each event with its probability. If the events are real Borel sets (nice sets of real numbers, such as intervals, finite sets etc) then in lieu
18,134
Difference in Probability Measure vs. Probability Distribution
Probability measure can be seen as a generalization of probability density function (PDF). Probability distribution function is not really a term, but when I saw it used it was always meant to refer to the cumulative distribution function (CDF). I wouldn't use this as a term, since it's confusing. In Excel NORM.S.DIST() function has an argument that switches it between cumulative and density functions. To make things more confusing Microsoft called the density function as "probability mass function", which is obviously wrong because PMF is for discrete distributions. It's ok to use probability distribution term since it references everything we know about the distribution, including PDF and CDF and moments etc.
Difference in Probability Measure vs. Probability Distribution
Probability measure can be seen as a generalization of probability density function (PDF). Probability distribution function is not really a term, but when I saw it used it was always meant to refer t
Difference in Probability Measure vs. Probability Distribution Probability measure can be seen as a generalization of probability density function (PDF). Probability distribution function is not really a term, but when I saw it used it was always meant to refer to the cumulative distribution function (CDF). I wouldn't use this as a term, since it's confusing. In Excel NORM.S.DIST() function has an argument that switches it between cumulative and density functions. To make things more confusing Microsoft called the density function as "probability mass function", which is obviously wrong because PMF is for discrete distributions. It's ok to use probability distribution term since it references everything we know about the distribution, including PDF and CDF and moments etc.
Difference in Probability Measure vs. Probability Distribution Probability measure can be seen as a generalization of probability density function (PDF). Probability distribution function is not really a term, but when I saw it used it was always meant to refer t
18,135
Difference in Probability Measure vs. Probability Distribution
This is my 2 cents, though I'm not an expert: "Probability Measure" is used in the context of a more precise, math theoretical, context. Kolmogorov in the year 1933 laid down some mathematical constructs to help better understand and handle probabilities from a mathematically rigid point of view. In a nutshell - he defined a "Probability Space" which consists of a set of events, a (Οƒ)-algebra/field on that set (β‰ˆ all the different ways you can subset that original set), and a measure which maps these subsets to a number that measures them. This became the standard way of understanding probability. This framework is important because once you start thinking about probability the way mathematicians do, you encounter all kind of edge cases and problems - which the framework can help you define or avoid. So, I would say that people who use "Probability Measure" are either involved with deep probability issues, or are simply more math oriented by their education. Note that a "Probability Space" precedes a "Random Variable" (also known as a "Measurable Function") - which is defined to be a function from the original space to measurable space, often real-valued. I'm not sure, but I think the main point here, is that this allows us to use more "number-oriented" math, than "space-oriented" math. We map the "space" into numbers, and now we can work more easily with it. (There's nothing to prevent us to start with a "number space", e.g., $\mathbb R$ and define the identity mapping as the Random Variable; But a lot of events are not intrinsically numbers - think of Heads or Tails, and the mapping of them into numbers 0 or 1). Once we are in the realm of numbers (real line R), we can define Probability Functions to help us characterize the behavior of these fantastic probability beasts. The main function is called the "Cumulative Distribution Function" (CDF) - it exists for all valid probability spaces and for all valid random variables, and it completely defines the behavior of the beast (unlike, say, the mean of a random variable, or the variance: you can have different probability beasts with the same mean or the same variance, and even both). It keeps tracks on how much the probability measure is distributed across the real line. If the random variable mapping is continuous, you will also have a Probability Density Function (PDF), if it's discrete you will have a Probability Mass Function (PMF). If it's mixed, it's complicated. I think "Probability Distribution" might mean either of these things, but I think most often it will be used in less mathematically precise as it's sort of an umbrella term - it can refer to the distribution of measure on the original space, or the distribution of measure on the real line, characterized by the CDF or PDF/PMF. Usually, if there's no need to go deep into the math, people will stay on the level of "probability function" or "probability distribution". Though some will venture to the realms of "probability measure" without real justification except the need to be absolutely mathematically precise.
Difference in Probability Measure vs. Probability Distribution
This is my 2 cents, though I'm not an expert: "Probability Measure" is used in the context of a more precise, math theoretical, context. Kolmogorov in the year 1933 laid down some mathematical constru
Difference in Probability Measure vs. Probability Distribution This is my 2 cents, though I'm not an expert: "Probability Measure" is used in the context of a more precise, math theoretical, context. Kolmogorov in the year 1933 laid down some mathematical constructs to help better understand and handle probabilities from a mathematically rigid point of view. In a nutshell - he defined a "Probability Space" which consists of a set of events, a (Οƒ)-algebra/field on that set (β‰ˆ all the different ways you can subset that original set), and a measure which maps these subsets to a number that measures them. This became the standard way of understanding probability. This framework is important because once you start thinking about probability the way mathematicians do, you encounter all kind of edge cases and problems - which the framework can help you define or avoid. So, I would say that people who use "Probability Measure" are either involved with deep probability issues, or are simply more math oriented by their education. Note that a "Probability Space" precedes a "Random Variable" (also known as a "Measurable Function") - which is defined to be a function from the original space to measurable space, often real-valued. I'm not sure, but I think the main point here, is that this allows us to use more "number-oriented" math, than "space-oriented" math. We map the "space" into numbers, and now we can work more easily with it. (There's nothing to prevent us to start with a "number space", e.g., $\mathbb R$ and define the identity mapping as the Random Variable; But a lot of events are not intrinsically numbers - think of Heads or Tails, and the mapping of them into numbers 0 or 1). Once we are in the realm of numbers (real line R), we can define Probability Functions to help us characterize the behavior of these fantastic probability beasts. The main function is called the "Cumulative Distribution Function" (CDF) - it exists for all valid probability spaces and for all valid random variables, and it completely defines the behavior of the beast (unlike, say, the mean of a random variable, or the variance: you can have different probability beasts with the same mean or the same variance, and even both). It keeps tracks on how much the probability measure is distributed across the real line. If the random variable mapping is continuous, you will also have a Probability Density Function (PDF), if it's discrete you will have a Probability Mass Function (PMF). If it's mixed, it's complicated. I think "Probability Distribution" might mean either of these things, but I think most often it will be used in less mathematically precise as it's sort of an umbrella term - it can refer to the distribution of measure on the original space, or the distribution of measure on the real line, characterized by the CDF or PDF/PMF. Usually, if there's no need to go deep into the math, people will stay on the level of "probability function" or "probability distribution". Though some will venture to the realms of "probability measure" without real justification except the need to be absolutely mathematically precise.
Difference in Probability Measure vs. Probability Distribution This is my 2 cents, though I'm not an expert: "Probability Measure" is used in the context of a more precise, math theoretical, context. Kolmogorov in the year 1933 laid down some mathematical constru
18,136
Why should binning be avoided at all costs?
It is a slight exaggeration to say that binning should be avoided at all costs, but it is certainly the case that binning introduces bin choices that introduce some arbitrariness to the analysis. With modern statistical methods it is generally not necessary to engage in binning, since anything that can be done on discretized "binned" data can generally be done on the underlying continuous values. The most common use of "binning" in statistics is in the construction of histograms. Histograms are similar to the general class of kernel density estimators (KDEs), insofar as they involve aggregation of step functions on the chosen bins, whereas the KDE involves aggregation of smoother kernels. The step function used in a histogram is not a smooth function, and it is generally the case that better kernel functions can be chosen that are less arbitrary under the KDE method, which also yield better estimates of the underlying density of the data. I often tell students that a histogram is just a "poor man's KDE", since it involves arbitrary bin choices and does not give a smooth density estimator. (As pointed out in the comments, the histogram is not actually a special case of the KDE; one comes close to a histogram by using a KDE with rectangular kernels centred around the data points, and a histogram is actually slightly worse thatn this estimator.) Personally, I would rarely use one, because it is so easy to get a KDE without binning the data, and this gives superior results without an arbitrary binning choice. Another common use of "binning" occurs when an analyst wishes to discretize continuous data into bins in order to use analytical techniques that use discrete values. This appears to be what is being suggested in the section you quote regarding prediction of vocal sounds. In such cases there is some arbitrariness introduced by the binning and there is also a loss of information. It is again best to avoid this if possible, by trying to form a model directly on the underlying continuous values, rather than forming a model on the discretized "binned" values. As a general rule, it is desirable for statisticians to avoid analytical techniques that introduce arbitrary assumptions, particularly in cases where alternative techniques are available to easily avoid these assumptions. So I agree with the sentiment that binning is generally unnecessary. It certainly should not be avoided at all costs since costs are important, but it should generally be avoided when there are simple alternative techniques that allow it to be avoided without any serious inconvenience. My recommendation would be to learn the analytical methods that are applied to the underlying continuous data, and then you will be in a position to determine whether a crude approximation via binning is necessary in a given situation.
Why should binning be avoided at all costs?
It is a slight exaggeration to say that binning should be avoided at all costs, but it is certainly the case that binning introduces bin choices that introduce some arbitrariness to the analysis. Wit
Why should binning be avoided at all costs? It is a slight exaggeration to say that binning should be avoided at all costs, but it is certainly the case that binning introduces bin choices that introduce some arbitrariness to the analysis. With modern statistical methods it is generally not necessary to engage in binning, since anything that can be done on discretized "binned" data can generally be done on the underlying continuous values. The most common use of "binning" in statistics is in the construction of histograms. Histograms are similar to the general class of kernel density estimators (KDEs), insofar as they involve aggregation of step functions on the chosen bins, whereas the KDE involves aggregation of smoother kernels. The step function used in a histogram is not a smooth function, and it is generally the case that better kernel functions can be chosen that are less arbitrary under the KDE method, which also yield better estimates of the underlying density of the data. I often tell students that a histogram is just a "poor man's KDE", since it involves arbitrary bin choices and does not give a smooth density estimator. (As pointed out in the comments, the histogram is not actually a special case of the KDE; one comes close to a histogram by using a KDE with rectangular kernels centred around the data points, and a histogram is actually slightly worse thatn this estimator.) Personally, I would rarely use one, because it is so easy to get a KDE without binning the data, and this gives superior results without an arbitrary binning choice. Another common use of "binning" occurs when an analyst wishes to discretize continuous data into bins in order to use analytical techniques that use discrete values. This appears to be what is being suggested in the section you quote regarding prediction of vocal sounds. In such cases there is some arbitrariness introduced by the binning and there is also a loss of information. It is again best to avoid this if possible, by trying to form a model directly on the underlying continuous values, rather than forming a model on the discretized "binned" values. As a general rule, it is desirable for statisticians to avoid analytical techniques that introduce arbitrary assumptions, particularly in cases where alternative techniques are available to easily avoid these assumptions. So I agree with the sentiment that binning is generally unnecessary. It certainly should not be avoided at all costs since costs are important, but it should generally be avoided when there are simple alternative techniques that allow it to be avoided without any serious inconvenience. My recommendation would be to learn the analytical methods that are applied to the underlying continuous data, and then you will be in a position to determine whether a crude approximation via binning is necessary in a given situation.
Why should binning be avoided at all costs? It is a slight exaggeration to say that binning should be avoided at all costs, but it is certainly the case that binning introduces bin choices that introduce some arbitrariness to the analysis. Wit
18,137
Why should binning be avoided at all costs?
Imagine you have a watch that shows only the hours. By only I mean that it has only the hour arrow that once an hour makes a 1/12 jump to another hour, it does not move smoothly. Such clock wouldn't be very useful, since you wouldn't know if it is five past two, half past two, or ten to three. That's the problem with binned data, it loses details and introduces the "jumpy" changes.
Why should binning be avoided at all costs?
Imagine you have a watch that shows only the hours. By only I mean that it has only the hour arrow that once an hour makes a 1/12 jump to another hour, it does not move smoothly. Such clock wouldn't b
Why should binning be avoided at all costs? Imagine you have a watch that shows only the hours. By only I mean that it has only the hour arrow that once an hour makes a 1/12 jump to another hour, it does not move smoothly. Such clock wouldn't be very useful, since you wouldn't know if it is five past two, half past two, or ten to three. That's the problem with binned data, it loses details and introduces the "jumpy" changes.
Why should binning be avoided at all costs? Imagine you have a watch that shows only the hours. By only I mean that it has only the hour arrow that once an hour makes a 1/12 jump to another hour, it does not move smoothly. Such clock wouldn't b
18,138
Why should binning be avoided at all costs?
I would normally argue strongly against categorisation of continuous variables for the reasons well expressed by others notable Frank Harrell. In this case it might be helpful though to ask oneself about the process which generated the scores. It looks as though most of the scores are effectively zero perhaps with some noise added. A few of them are rather close to unity again with noise. Very few lie in between. In this case there seems rather more justification for categorising since one could argue that modulo the noise this is a binary variable. If one does fit it as a continuous variable the coefficients would have meaning in terms of change in the predictor variable but in this case over most of its range the variable is very sparsely populated so that seems unattractive.
Why should binning be avoided at all costs?
I would normally argue strongly against categorisation of continuous variables for the reasons well expressed by others notable Frank Harrell. In this case it might be helpful though to ask oneself ab
Why should binning be avoided at all costs? I would normally argue strongly against categorisation of continuous variables for the reasons well expressed by others notable Frank Harrell. In this case it might be helpful though to ask oneself about the process which generated the scores. It looks as though most of the scores are effectively zero perhaps with some noise added. A few of them are rather close to unity again with noise. Very few lie in between. In this case there seems rather more justification for categorising since one could argue that modulo the noise this is a binary variable. If one does fit it as a continuous variable the coefficients would have meaning in terms of change in the predictor variable but in this case over most of its range the variable is very sparsely populated so that seems unattractive.
Why should binning be avoided at all costs? I would normally argue strongly against categorisation of continuous variables for the reasons well expressed by others notable Frank Harrell. In this case it might be helpful though to ask oneself ab
18,139
Why should binning be avoided at all costs?
If you bin, every result $R$ you report will be conditional on the set of bins you use. It is then up to you to average over these choices before you report any robust result. If you are ambitious (or if a reviewer gives you no choice), you may report the distribution of your results P(R) over the set of bin selection. More details: a result $R$ is obtained from a numerical experiment in which binning was used. Let the binning be defined as $\{b_1 \cdots b_N\}$ where $b_i=[l_i,u_i]$ is the choice of $l_i$ as the lower bound and $u_i$ as the upper bound for the $i$th bin. For simplicity, let's say the set of bins is defined by the position $l=l_0$ of the first bin and a uniform width $w$ for every bin. The lower bound of the first bin $l_0$ can vary up the upper value of the first bin $u_0=l_0+w$ and $w$ can vary from some minimum to maximum values $(w_{min},w_{max})$. To show robustness of R, we need to calculate $$ P(R) = \sum_{w=w_{min}}^{w_{max}}\sum_{l=l_0}^{l_0+w} P(R|l,w) P(l,w) \\ P(l,w) \sim \frac{2(u_0-l_0)}{w_{max}+w_{min}} \times (w_{max}-w_{min}) $$ Of course, now you've introduced $w_{max}, w_{min},$ and $l_0$, so technically $P(R) \rightarrow P(R|w_{max}, w_{min},l_0)$, but if we suspect (not unreasonably) that $P(R)$ is independent of these values, then $P(R|w_{max}, w_{min},l_0)=P(R)$ (whew!) which is usually the case, and you rarely have to prove that unless you are really very unlucky with your reviewer! In the context of the OP's question I would be satisfied if the arbitrary threshold 0.5 were set to a variety of values between credible min and max values, and to see that the basic results of his analysis are largely independent of the selection.
Why should binning be avoided at all costs?
If you bin, every result $R$ you report will be conditional on the set of bins you use. It is then up to you to average over these choices before you report any robust result. If you are ambitious (or
Why should binning be avoided at all costs? If you bin, every result $R$ you report will be conditional on the set of bins you use. It is then up to you to average over these choices before you report any robust result. If you are ambitious (or if a reviewer gives you no choice), you may report the distribution of your results P(R) over the set of bin selection. More details: a result $R$ is obtained from a numerical experiment in which binning was used. Let the binning be defined as $\{b_1 \cdots b_N\}$ where $b_i=[l_i,u_i]$ is the choice of $l_i$ as the lower bound and $u_i$ as the upper bound for the $i$th bin. For simplicity, let's say the set of bins is defined by the position $l=l_0$ of the first bin and a uniform width $w$ for every bin. The lower bound of the first bin $l_0$ can vary up the upper value of the first bin $u_0=l_0+w$ and $w$ can vary from some minimum to maximum values $(w_{min},w_{max})$. To show robustness of R, we need to calculate $$ P(R) = \sum_{w=w_{min}}^{w_{max}}\sum_{l=l_0}^{l_0+w} P(R|l,w) P(l,w) \\ P(l,w) \sim \frac{2(u_0-l_0)}{w_{max}+w_{min}} \times (w_{max}-w_{min}) $$ Of course, now you've introduced $w_{max}, w_{min},$ and $l_0$, so technically $P(R) \rightarrow P(R|w_{max}, w_{min},l_0)$, but if we suspect (not unreasonably) that $P(R)$ is independent of these values, then $P(R|w_{max}, w_{min},l_0)=P(R)$ (whew!) which is usually the case, and you rarely have to prove that unless you are really very unlucky with your reviewer! In the context of the OP's question I would be satisfied if the arbitrary threshold 0.5 were set to a variety of values between credible min and max values, and to see that the basic results of his analysis are largely independent of the selection.
Why should binning be avoided at all costs? If you bin, every result $R$ you report will be conditional on the set of bins you use. It is then up to you to average over these choices before you report any robust result. If you are ambitious (or
18,140
Why should binning be avoided at all costs?
For some applications, apparently including the one which you are contemplating, binning can be strictly necessary. Obviously to perform a categorization problem, at some point you must withdraw categorical data from your model, and unless your inputs are all categorical as well, you will need to perform binning. Consider an example: A sophisticated AI is playing poker. It has evaluated the likelihood of its hand being superior to the hands of other players as 70%. It is its turn to bet, however it has been told that it should avoid binning at all costs, and consequently never places a bet; it folds by default. However, what you have heard may well be true, in that prematurely binning of intermediate values surrenders information that could have been preserved. If the ultimate purpose of your project is to determine whether you will "like" the song in question, which may be determined by two factors: "instrumentalness" and "rockitude", you would likely do better to retain those as continuous variables until you need to pull out "likingness" as a categorical variable. $$ \mathrm{like} = \begin{cases} 0 & \mathrm{rockitude} * 3 + \mathrm{instrumentalness} * 2 < 3 \\ 1 & \mathrm{rockitude} * 3 + \mathrm{instrumentalness} * 2 \ge 3 \end{cases} $$ or whatever coefficients you deem most appropriate, or whatever other model appropriately fits your training set. If instead you decide whether something is "instrumental" (true or false) and "rocks" (true or false), then you have your 4 categories laid out before you plain as day: instrumental, rocks non-instrumental, rocks instrumental, no rocks non-instrumental, no rocks But then all you get to decide is which of those 4 categories you "like". You have surrendered flexibility in your final decision. The decision to bin or not to bin depends entirely on your goal. Good luck.
Why should binning be avoided at all costs?
For some applications, apparently including the one which you are contemplating, binning can be strictly necessary. Obviously to perform a categorization problem, at some point you must withdraw categ
Why should binning be avoided at all costs? For some applications, apparently including the one which you are contemplating, binning can be strictly necessary. Obviously to perform a categorization problem, at some point you must withdraw categorical data from your model, and unless your inputs are all categorical as well, you will need to perform binning. Consider an example: A sophisticated AI is playing poker. It has evaluated the likelihood of its hand being superior to the hands of other players as 70%. It is its turn to bet, however it has been told that it should avoid binning at all costs, and consequently never places a bet; it folds by default. However, what you have heard may well be true, in that prematurely binning of intermediate values surrenders information that could have been preserved. If the ultimate purpose of your project is to determine whether you will "like" the song in question, which may be determined by two factors: "instrumentalness" and "rockitude", you would likely do better to retain those as continuous variables until you need to pull out "likingness" as a categorical variable. $$ \mathrm{like} = \begin{cases} 0 & \mathrm{rockitude} * 3 + \mathrm{instrumentalness} * 2 < 3 \\ 1 & \mathrm{rockitude} * 3 + \mathrm{instrumentalness} * 2 \ge 3 \end{cases} $$ or whatever coefficients you deem most appropriate, or whatever other model appropriately fits your training set. If instead you decide whether something is "instrumental" (true or false) and "rocks" (true or false), then you have your 4 categories laid out before you plain as day: instrumental, rocks non-instrumental, rocks instrumental, no rocks non-instrumental, no rocks But then all you get to decide is which of those 4 categories you "like". You have surrendered flexibility in your final decision. The decision to bin or not to bin depends entirely on your goal. Good luck.
Why should binning be avoided at all costs? For some applications, apparently including the one which you are contemplating, binning can be strictly necessary. Obviously to perform a categorization problem, at some point you must withdraw categ
18,141
Relation between MAP, EM, and MLE
Imagine that you have some data $X$ and probabilistic model parametrized by $\theta$, you are interested in learning about $\theta$ given your data. The relation between data, parameter and model is described using likelihood function $$ \mathcal{L}(\theta \mid X) = p(X \mid \theta) $$ To find the best fitting $\theta$ you have to look for such value that maximizes the conditional probability of $\theta$ given $X$. Here things start to get complicated, because you can have different views on what $\theta$ is. You may consider it as a fixed parameter, or as a random variable. If you consider it as fixed, then to find it's value you need to find such value of $\theta$ that maximizes the likelihood function (maximum likelihood method [ML]). On another hand, if you consider it as a random variable, then this means that it also has some distribution, so you need to make one more assumption about prior distribution of $\theta$, i.e. $p(\theta)$, and you will be using Bayes theorem for estimation $$ p(\theta \mid X) \propto p(X \mid \theta) \, p(\theta) $$ If you are not interested in estimating the posterior distribution of $\theta$ but only about point estimate that maximizes the posterior probability, then you will be using maximum a posteriori (MAP) method for estimating it. As about expectation-maximalization (EM), it is an algorithm that can be used in maximum likelihood approach for estimating certain kind of models (e.g. involving latent variables, or in missing data scenarios). Check the following threads to learn more: Maximum Likelihood Estimation (MLE) in layman terms What is the difference between Maximum Likelihood Estimation & Gradient Descent? Bayesian and frequentist reasoning in plain English Who Are The Bayesians? Is there a difference between the "maximum probability" and the "mode" of a parameter? What is the difference between "likelihood" and "probability"? Wikipedia entry on likelihood seems ambiguous Numerical example to understand Expectation-Maximization
Relation between MAP, EM, and MLE
Imagine that you have some data $X$ and probabilistic model parametrized by $\theta$, you are interested in learning about $\theta$ given your data. The relation between data, parameter and model is d
Relation between MAP, EM, and MLE Imagine that you have some data $X$ and probabilistic model parametrized by $\theta$, you are interested in learning about $\theta$ given your data. The relation between data, parameter and model is described using likelihood function $$ \mathcal{L}(\theta \mid X) = p(X \mid \theta) $$ To find the best fitting $\theta$ you have to look for such value that maximizes the conditional probability of $\theta$ given $X$. Here things start to get complicated, because you can have different views on what $\theta$ is. You may consider it as a fixed parameter, or as a random variable. If you consider it as fixed, then to find it's value you need to find such value of $\theta$ that maximizes the likelihood function (maximum likelihood method [ML]). On another hand, if you consider it as a random variable, then this means that it also has some distribution, so you need to make one more assumption about prior distribution of $\theta$, i.e. $p(\theta)$, and you will be using Bayes theorem for estimation $$ p(\theta \mid X) \propto p(X \mid \theta) \, p(\theta) $$ If you are not interested in estimating the posterior distribution of $\theta$ but only about point estimate that maximizes the posterior probability, then you will be using maximum a posteriori (MAP) method for estimating it. As about expectation-maximalization (EM), it is an algorithm that can be used in maximum likelihood approach for estimating certain kind of models (e.g. involving latent variables, or in missing data scenarios). Check the following threads to learn more: Maximum Likelihood Estimation (MLE) in layman terms What is the difference between Maximum Likelihood Estimation & Gradient Descent? Bayesian and frequentist reasoning in plain English Who Are The Bayesians? Is there a difference between the "maximum probability" and the "mode" of a parameter? What is the difference between "likelihood" and "probability"? Wikipedia entry on likelihood seems ambiguous Numerical example to understand Expectation-Maximization
Relation between MAP, EM, and MLE Imagine that you have some data $X$ and probabilistic model parametrized by $\theta$, you are interested in learning about $\theta$ given your data. The relation between data, parameter and model is d
18,142
Relation between MAP, EM, and MLE
I stumbled across this post, when I tried to give a more comprehensive answer of that topic to a friend of mine. Since the answer written by @Tim♦ is already a bit older and this topic just really complex, I will try to give an easy introduction into the EM "algorithm" and its relationship to Maximum A Posteriori (MAP) and Maximum Likelihood Estimation (MLE). To do so, I will split my explanation into four parts. A Preface, where I will give a short insight into the general idea of the expectation maximization "algorithm" and into bayesian thinking. The second Main part will be split into MLE, MAP and EM. In the Conclusion I will point out the relationship between these optimization methods. Throughout the course of that explanation I will use a variety of sources, which helped me put this answer together. You can review my bibliography in the last chapter called Sources. I will always include the link to the source as well as a note, why that is a useful resource to look at. Moreover, I am going to cite throughout my answer (where necessary), so that you can always go and checkout where I got the information from. As you might have wondered in the text so far I put a quote around "algorithm". The reason is, that Dempster et al. [1] themselves point out, that this term can be critized since it does not point out clear programing steps (p. 6). Preface In order to better understand the idea of the Expectation Maximization "algorithm", we need some pretext. When we look at statistic more broadly, one can identify (probably under a wide range of ideas) two paradigms, viz. the Frequentist-approach and the Bayesian-approach. Imagine you are going to the store and buy 100 bags of M&Ms. You open a bag and whenever you eat a M&M you note down the color. After finishing all 100 bags of M&Ms you conclude that 30% of your M&Ms were red, 20% were green, 25% were blue and 35% were yellow. From a frequentist's perspective, this is the prior; the knowledge was obtained by the frequent and repeated sample of measuring. Hence you expect a similar color distribution the next time that you buy M&Ms. This connects "probabilites deeply to the frequency of events" [2]. In a Bayesian world that is different. For example, say you are about to eat M&Ms for the first time in your life and you are asked what you expect the colour distribution to be. Following a Bayesian perspective you might assert, "well, I walked through the park today and saw a lot of green trees, so 40% green, each tree had some (red) apples, so 25% red, the sun was shining, so 15% yellow and when I came home it started pouring down on me, hence 20% of the M&Ms will be blue." That analogy shows that "probabilites are fundamentally related to our own knowlegde about an event" [2]. This prior estimation of $\theta$ (here the distribution of the colors within a M&M package) is a huge topic of debate. (Subjective) Bayesians say it is subjective, what would result in always different outcomes since everybody has their own experience/knowledge. Others say, we must first check it and then base it on frequency (that goes into the frequentist direction). Or maybe everything is subjective and so all models are different, just that some of them are actually useful [3]. Just think of the data you chose, the model you want to use etc. Those decisions are all based on subjectivity. The pragmatic solution which was found was, that if the sample size is just big enough the selected starting value for $\theta$ does not matter anymore, since all $\theta$s will converge all to the same value (this is also called the law of big numbers). This idea is also called Bayes' rule, which is the core of Bayesian statistics. Here's how it looks: \begin{equation} \color{orange}{P(A|B)} = \frac{\color{red}{P(B|A)}\color{green}{P(A)}}{\color{magenta}{P(B)}} \end{equation} In order to better explain the various parts of that equation, I will stick to the M&Ms analogy. $\color{green}{P(A)}$: Like I outlined earlier, we might assume a distribution of the probability that a certain amount of M&Ms have a certain color. This assumption is also called prior. $\color{orange}{P(A|B)}$: This is the true distribution of the colors which we can assume based on the M&Ms in our bought package. Or statistically speaking, what is the probability of $A$ given our data $B$. This part is called the posterior. $\color{magenta}{P(B)}$: This is the probability for our given data. $\color{red}{P(B|A)}$: This is the likelihood function. The likelihood function is the probability of data given the parameter, but as a function of the parameter holding the data fixed [3, lecture 3]. I am going to put a focus on this topic later on in the respective chapters of MAP, MLE and ME. Now we could read our Bayes' rule like so: \begin{equation} Posterior\ =\ \frac{Likelihood\ *\ Prior/Believe}{Evidence} \end{equation} The main idea is that we can update our beliefs with that model. In statistics we can call this sequentialism. Continuing with the M&Ms analogy, that means that with every M&M you eat, your probability of a chosen color is updated. This is an iterative process and can be repeated continuously; everytime the posterior (the belief) of what color the next M&M you pick from a package will be, is updated (updated here can either mean that the probability of a certain color either increases or decreases). So lets imagine you pick/eat three different M&Ms from your package. Now you could just update your belief once, using each of these three M&Ms; Bayes' rule sequentially incorporates these three M&Ms. Meaning we pick/eat one M&M and update our probability (our posterior) accordingly. Next, we will pick/eat the second M&M, and what happens now is that our posterior which we just calculated based on the color of the first M&M, becomes our new prior, and so on. Lets do this again step by step. We have a new bought package of M&Ms, and we already assume that the colors are distributed by a distribution $\color{green}{P(A)}$. \begin{equation} \color{orange}{P(A|B)} = \frac{P(B|A)\color{green}{P(A)}}{P(B)} \end{equation} Now you open the package and pick/eat the first M&M $P(A)$, and we update our belief accordingly. Because we actually now know what color this M&M had. \begin{equation} \color{red}{P(A|B)} = \frac{P(B|A)\color{orange}{P(A)}}{P(B)} \end{equation} And with the second M&M picked, we will update our beliefs again. \begin{equation} \color{blue}{P(A|B)} = \frac{P(B|A)\color{red}{P(A)}}{P(B)} \end{equation} This is going on and on with every M&M you eat. As the lecturer indicates in [1], our posterior tonight is our prior tomorrow. In a more statistical version, this function can be written as: \begin{equation} \color{orange}{P(\theta|y)} = \frac{P(y|\theta)\color{green}{P(\theta)}}{\color{magenta}{P(y)}} \end{equation} This is nothing different then the above. Our data (here $y$) and our unknowns (here $\theta$). Essentially, we want to get our unknowns ($\theta$s) given our knowns (our data $y$). In order to calculate that, we can first get rid of $\color{magenta}{P(y)}$. Since we already have the data, we can treat it as fixed (since what should change on already gathered data?). So we can get rid of the denominator. However, $\theta$ is what we do not know. How can we derive something we do not know? The idea is to give it some kind of distribution, hence, our unknowns can be quantified using probabilites.1 With that in mind we can transform our original equation to: \begin{equation} P(\theta|y) \propto L(y|\theta)P(\theta) \end{equation} First I want to point out a property of the Bayes' rule. It states that "the posterior density is proprotional (denoted as $\propto$) to the likelihood function times the prior density" [3]. In statistical terms the likelihood function just means a function of $\theta$ given data $y$. A good example is statistical inference. We have some data (lets say about speeding) and we want to know, what are certain parameters ($\theta$s) that can form a prediction as to the likelihood regarding whether or not a person is speeding? So, why is all of that relevant to the relationship between MAP, MLE and EM? The EM is a method which is closely related to Bayesian inference and also to MAP [1, p. 11]. So it is good to know, what kind of mindset a Baysian has. 1A really good quote here is: "[...] probability is our best language to quantify uncertainty", from [3], lecture 16. Main In the pretext I highlighted the differences between Frequentist and Bayesian thinking and I also gave a short insight into Bayesian thinking. Moving on, I will now delve a bit more deeper into the explanation of MLE, MAP and EM. MLE The general gist of the Maximum Likelihood Estimation is to estimate the probability of an event given some data. In the M&M analogy, what is the probability of a red M&M given a package of M&Ms. Mathmatically put, this would look like \begin{equation} P(red\ M\&M|package\ of\ M\&Ms) \propto L(package\ of\ M\&Ms|red\ M\&M) \end{equation} Lets get a bit more hands-on. A good idea could be, to just buy 100 packages of M&Ms and just count the number of occurances of red M&Ms in each of the packages. So, we come to the conclusion that the amount of red M&Ms in the packages are somewhat uniformly distributed. We can see that of 100 packages we tested, around 19 had 26 red M&Ms. So, we can say, that 26 red M&Ms is the most probable value. So the next time, that we are going to buy a package of M&Ms this is what we expect. We expect that is has 26 red M&Ms [4]. So what does the MLE do in mathmatical terms? Well, it is called the maximum likelihood estimator, hence, it tries to maximize the likehood of an event to occur. Therefore, the MLE returns a point estimate, which maximizes the likelihood. When we look at any uniform distribution, we can see, that the most probable value is always the mean, which in a uniform distribution, is always the estimator which maximizes the likelihood. When we put that down in a formula it would look like this2: \begin{equation} \theta_{MLE} = argmax_{\theta}\ P(x|\theta) \end{equation} Spoken that would sound like: "Return me those values, which maximizes the probability of my data given parameters." One could argue that the MLE idea is mostly a frequentist idea. We just measure often enough, then we take the mean (which is the value which maximizes the likelihood) and we already have our MLE. This is a bit different when we are talking about MAP. 2Normally this function also takes the log-likelihood. The reason for this is, that is it computationally easier to maximize. Since I have not explained that, I will leave the log out in this formula. MAP Now assume you read some news in the paper that the company which produces the M&Ms runs low on red color. So the next time you buy a package M&Ms and you ask yourself "how many red M&Ms are inside that package?", you cannot just take the mean, as established in the MLE section. With that low-color information you already can guess, that the red colored M&Ms within a package cannot be uniformly distributed anymore. You rather assume such a distribution: If we would try to use MLE to predict, what would maximize our likelihood, then we would be terribly off. But thanks to the established Bayesian thinking in the Preface, we can account for that fact. We can tell our function, that it has to adjust for that distribution. \begin{equation} \theta_{MAP} = argmax_{\theta}\ P(x|\theta)g(\theta) \end{equation} The $g(\theta)$ is our prior. More specifically, it is our belief that we are dealing with a specific probability distribution function. Since it is also a maximization function, MAP also returns a point estimate, in fact those points which maximize the posterior distribution.3 The MAP idea is, hence we giving it some prior information, rather an idea which Bayesians like. 3@Tim♦ already gave the link to the fitting question, which gives an answer to the difference between "likelihood" and "probability". EM The Expectation Maximization "algorithm" is the idea to approximate the parameters, so that we could create a function, which would best fit the data we have. So what the EM tries, is to estimate those parameters ($\theta$s) which maximize the posterior distribution. This is helpful, if we are just dealing with a subset of data.4 [5] has a quite nice representation of the EM using a coin toss example, which I want to display here. This picture is taken from the paper What is the expectation maximization algorithm? by the authors Do & Batzoglou (2008, p. 898). Let me first describe that picture, and then dive a bit deeper into the math behind this approach. We can see here, that we initially select two random variables for $\hat{\theta}_A^{(0)}$ and $\hat{\theta}_B^{(0)}$. Those are the respective probabilites that this coin displays head, when thrown. Next, we have some data, but we do not know which coin created that data.5 However, we can caluclate the expectation for each coin. So lets first calculate the expectation that the first dataset [HTTTHHTHTH] belongs to coin a, if coin a has the probability of $0.6$ to return head after thrown: \begin{equation} \frac{0.6^{5}*(1-0.6)^{10-5}}{0.6^{5}*(1-0.6)^{10-5}+0.5^{5}*0.5^{10-5}} = 0.45 \end{equation} The "algorithm" uses this function to calculate all the expectations for coin a. The expectation for coin b are easily computed, since we can just do 1 - probability of coin a. Once we have all data, we can multiply our expectation with the number of events we want to measure. Meaning, we calculate: \begin{equation} 0.45 * 5 = 2.2 \end{equation} Now we know, that if the first data set would belong to coin a, we would expect $2.2$ times heads and $2.2$ times tails6. Once we have that full table, all what we do, is to do MLE. We sum up the values for the occurances of heads and tails for each coin, and calculate the probability of heads for each coin. This is also called the M(aximization)-step. These two probabilities we just calculated are now our new values, with which we re-run our expectation calculation. We can repeat this as many times as we want. The nice idea of this is, that in the end we can approximate the real $\theta$s, viz. after ten iterations we have a posterior maximization value of $0.8$ for coin a. 4On the first page of their paper Dempster et al. [1] define a subset of data, as two sample spaces, whereas the second one is displayed through a transformation $y$. 5It should be noted that the EM algorithm is also seen as a clustering method, since we can now maximize the expectation that the data is either belongs to coin a or coin b. 6$0.45 * (10-5) = 2.2$ Conclusion After explaining MLE, MAP and EM, lets now discuss their relationship and why it was important to first review how a Bayesian thinks. The MAP function essentially derives from Bayes' rule, like shown in the Preface. When we again think about the function of the MAP, we can see that it just multiplies a likelihood with a prior. However, when use as prior the uniform distribution then MAP = MLE. Hence, the MLE is just a special version of the MAP, using a uniform distribution. EM also assumes that the given data is uniformly distributed, thus it uses the MLE. Having written that, Dempster et al. [1] point out multiple times, that the EM "algorithm" can easily be altered to use MAP, meaning a different probability distribution of the data. Add-on If you have read until this point, then you are really in love with either Data Science or theory! If you want to see this in action now, or you want to read more, it might be worth (additional to checking out the Sources section) to visit this link. Sources [1] Dempster et al. 1977 Note: This is the paper, where most of the references point to. It is really math heavy and explains the Expectation Maximization "algorithm" probably in its most mathmathical way. [2] https://jakevdp.github.io/blog/2014/03/11/frequentism-and-bayesianism-a-practical-intro/ Note: This is a really good introduction into Bayesian vs. Frequentists. It delves a lot more deeper into that topic that what was outlined here. Moreover, it was written by Jake Vanderplas who is a well known author and developer of the scipy Python package. [3] https://cs109.github.io/2015/ Note: This source is an amazing source for introductry to advanced topics in machine learning. They give really good advices on which books to read (which are mostly free available on the web) and they explain a lot of topics, so that they are understandable. This is a recommended source to read/listen to! [4] http://www.bdhammel.com/mle-map/ Note: In this source the distinction between MLE and MAP is also quite good explained. [5] https://datajobs.com/data-science-repo/Expectation-Maximization-Primer-[Do-and-Batzoglou].pdf Note: This paper is quite short, but visualizes and explains quite nice, what the EM algorithm is.
Relation between MAP, EM, and MLE
I stumbled across this post, when I tried to give a more comprehensive answer of that topic to a friend of mine. Since the answer written by @Tim♦ is already a bit older and this topic just really com
Relation between MAP, EM, and MLE I stumbled across this post, when I tried to give a more comprehensive answer of that topic to a friend of mine. Since the answer written by @Tim♦ is already a bit older and this topic just really complex, I will try to give an easy introduction into the EM "algorithm" and its relationship to Maximum A Posteriori (MAP) and Maximum Likelihood Estimation (MLE). To do so, I will split my explanation into four parts. A Preface, where I will give a short insight into the general idea of the expectation maximization "algorithm" and into bayesian thinking. The second Main part will be split into MLE, MAP and EM. In the Conclusion I will point out the relationship between these optimization methods. Throughout the course of that explanation I will use a variety of sources, which helped me put this answer together. You can review my bibliography in the last chapter called Sources. I will always include the link to the source as well as a note, why that is a useful resource to look at. Moreover, I am going to cite throughout my answer (where necessary), so that you can always go and checkout where I got the information from. As you might have wondered in the text so far I put a quote around "algorithm". The reason is, that Dempster et al. [1] themselves point out, that this term can be critized since it does not point out clear programing steps (p. 6). Preface In order to better understand the idea of the Expectation Maximization "algorithm", we need some pretext. When we look at statistic more broadly, one can identify (probably under a wide range of ideas) two paradigms, viz. the Frequentist-approach and the Bayesian-approach. Imagine you are going to the store and buy 100 bags of M&Ms. You open a bag and whenever you eat a M&M you note down the color. After finishing all 100 bags of M&Ms you conclude that 30% of your M&Ms were red, 20% were green, 25% were blue and 35% were yellow. From a frequentist's perspective, this is the prior; the knowledge was obtained by the frequent and repeated sample of measuring. Hence you expect a similar color distribution the next time that you buy M&Ms. This connects "probabilites deeply to the frequency of events" [2]. In a Bayesian world that is different. For example, say you are about to eat M&Ms for the first time in your life and you are asked what you expect the colour distribution to be. Following a Bayesian perspective you might assert, "well, I walked through the park today and saw a lot of green trees, so 40% green, each tree had some (red) apples, so 25% red, the sun was shining, so 15% yellow and when I came home it started pouring down on me, hence 20% of the M&Ms will be blue." That analogy shows that "probabilites are fundamentally related to our own knowlegde about an event" [2]. This prior estimation of $\theta$ (here the distribution of the colors within a M&M package) is a huge topic of debate. (Subjective) Bayesians say it is subjective, what would result in always different outcomes since everybody has their own experience/knowledge. Others say, we must first check it and then base it on frequency (that goes into the frequentist direction). Or maybe everything is subjective and so all models are different, just that some of them are actually useful [3]. Just think of the data you chose, the model you want to use etc. Those decisions are all based on subjectivity. The pragmatic solution which was found was, that if the sample size is just big enough the selected starting value for $\theta$ does not matter anymore, since all $\theta$s will converge all to the same value (this is also called the law of big numbers). This idea is also called Bayes' rule, which is the core of Bayesian statistics. Here's how it looks: \begin{equation} \color{orange}{P(A|B)} = \frac{\color{red}{P(B|A)}\color{green}{P(A)}}{\color{magenta}{P(B)}} \end{equation} In order to better explain the various parts of that equation, I will stick to the M&Ms analogy. $\color{green}{P(A)}$: Like I outlined earlier, we might assume a distribution of the probability that a certain amount of M&Ms have a certain color. This assumption is also called prior. $\color{orange}{P(A|B)}$: This is the true distribution of the colors which we can assume based on the M&Ms in our bought package. Or statistically speaking, what is the probability of $A$ given our data $B$. This part is called the posterior. $\color{magenta}{P(B)}$: This is the probability for our given data. $\color{red}{P(B|A)}$: This is the likelihood function. The likelihood function is the probability of data given the parameter, but as a function of the parameter holding the data fixed [3, lecture 3]. I am going to put a focus on this topic later on in the respective chapters of MAP, MLE and ME. Now we could read our Bayes' rule like so: \begin{equation} Posterior\ =\ \frac{Likelihood\ *\ Prior/Believe}{Evidence} \end{equation} The main idea is that we can update our beliefs with that model. In statistics we can call this sequentialism. Continuing with the M&Ms analogy, that means that with every M&M you eat, your probability of a chosen color is updated. This is an iterative process and can be repeated continuously; everytime the posterior (the belief) of what color the next M&M you pick from a package will be, is updated (updated here can either mean that the probability of a certain color either increases or decreases). So lets imagine you pick/eat three different M&Ms from your package. Now you could just update your belief once, using each of these three M&Ms; Bayes' rule sequentially incorporates these three M&Ms. Meaning we pick/eat one M&M and update our probability (our posterior) accordingly. Next, we will pick/eat the second M&M, and what happens now is that our posterior which we just calculated based on the color of the first M&M, becomes our new prior, and so on. Lets do this again step by step. We have a new bought package of M&Ms, and we already assume that the colors are distributed by a distribution $\color{green}{P(A)}$. \begin{equation} \color{orange}{P(A|B)} = \frac{P(B|A)\color{green}{P(A)}}{P(B)} \end{equation} Now you open the package and pick/eat the first M&M $P(A)$, and we update our belief accordingly. Because we actually now know what color this M&M had. \begin{equation} \color{red}{P(A|B)} = \frac{P(B|A)\color{orange}{P(A)}}{P(B)} \end{equation} And with the second M&M picked, we will update our beliefs again. \begin{equation} \color{blue}{P(A|B)} = \frac{P(B|A)\color{red}{P(A)}}{P(B)} \end{equation} This is going on and on with every M&M you eat. As the lecturer indicates in [1], our posterior tonight is our prior tomorrow. In a more statistical version, this function can be written as: \begin{equation} \color{orange}{P(\theta|y)} = \frac{P(y|\theta)\color{green}{P(\theta)}}{\color{magenta}{P(y)}} \end{equation} This is nothing different then the above. Our data (here $y$) and our unknowns (here $\theta$). Essentially, we want to get our unknowns ($\theta$s) given our knowns (our data $y$). In order to calculate that, we can first get rid of $\color{magenta}{P(y)}$. Since we already have the data, we can treat it as fixed (since what should change on already gathered data?). So we can get rid of the denominator. However, $\theta$ is what we do not know. How can we derive something we do not know? The idea is to give it some kind of distribution, hence, our unknowns can be quantified using probabilites.1 With that in mind we can transform our original equation to: \begin{equation} P(\theta|y) \propto L(y|\theta)P(\theta) \end{equation} First I want to point out a property of the Bayes' rule. It states that "the posterior density is proprotional (denoted as $\propto$) to the likelihood function times the prior density" [3]. In statistical terms the likelihood function just means a function of $\theta$ given data $y$. A good example is statistical inference. We have some data (lets say about speeding) and we want to know, what are certain parameters ($\theta$s) that can form a prediction as to the likelihood regarding whether or not a person is speeding? So, why is all of that relevant to the relationship between MAP, MLE and EM? The EM is a method which is closely related to Bayesian inference and also to MAP [1, p. 11]. So it is good to know, what kind of mindset a Baysian has. 1A really good quote here is: "[...] probability is our best language to quantify uncertainty", from [3], lecture 16. Main In the pretext I highlighted the differences between Frequentist and Bayesian thinking and I also gave a short insight into Bayesian thinking. Moving on, I will now delve a bit more deeper into the explanation of MLE, MAP and EM. MLE The general gist of the Maximum Likelihood Estimation is to estimate the probability of an event given some data. In the M&M analogy, what is the probability of a red M&M given a package of M&Ms. Mathmatically put, this would look like \begin{equation} P(red\ M\&M|package\ of\ M\&Ms) \propto L(package\ of\ M\&Ms|red\ M\&M) \end{equation} Lets get a bit more hands-on. A good idea could be, to just buy 100 packages of M&Ms and just count the number of occurances of red M&Ms in each of the packages. So, we come to the conclusion that the amount of red M&Ms in the packages are somewhat uniformly distributed. We can see that of 100 packages we tested, around 19 had 26 red M&Ms. So, we can say, that 26 red M&Ms is the most probable value. So the next time, that we are going to buy a package of M&Ms this is what we expect. We expect that is has 26 red M&Ms [4]. So what does the MLE do in mathmatical terms? Well, it is called the maximum likelihood estimator, hence, it tries to maximize the likehood of an event to occur. Therefore, the MLE returns a point estimate, which maximizes the likelihood. When we look at any uniform distribution, we can see, that the most probable value is always the mean, which in a uniform distribution, is always the estimator which maximizes the likelihood. When we put that down in a formula it would look like this2: \begin{equation} \theta_{MLE} = argmax_{\theta}\ P(x|\theta) \end{equation} Spoken that would sound like: "Return me those values, which maximizes the probability of my data given parameters." One could argue that the MLE idea is mostly a frequentist idea. We just measure often enough, then we take the mean (which is the value which maximizes the likelihood) and we already have our MLE. This is a bit different when we are talking about MAP. 2Normally this function also takes the log-likelihood. The reason for this is, that is it computationally easier to maximize. Since I have not explained that, I will leave the log out in this formula. MAP Now assume you read some news in the paper that the company which produces the M&Ms runs low on red color. So the next time you buy a package M&Ms and you ask yourself "how many red M&Ms are inside that package?", you cannot just take the mean, as established in the MLE section. With that low-color information you already can guess, that the red colored M&Ms within a package cannot be uniformly distributed anymore. You rather assume such a distribution: If we would try to use MLE to predict, what would maximize our likelihood, then we would be terribly off. But thanks to the established Bayesian thinking in the Preface, we can account for that fact. We can tell our function, that it has to adjust for that distribution. \begin{equation} \theta_{MAP} = argmax_{\theta}\ P(x|\theta)g(\theta) \end{equation} The $g(\theta)$ is our prior. More specifically, it is our belief that we are dealing with a specific probability distribution function. Since it is also a maximization function, MAP also returns a point estimate, in fact those points which maximize the posterior distribution.3 The MAP idea is, hence we giving it some prior information, rather an idea which Bayesians like. 3@Tim♦ already gave the link to the fitting question, which gives an answer to the difference between "likelihood" and "probability". EM The Expectation Maximization "algorithm" is the idea to approximate the parameters, so that we could create a function, which would best fit the data we have. So what the EM tries, is to estimate those parameters ($\theta$s) which maximize the posterior distribution. This is helpful, if we are just dealing with a subset of data.4 [5] has a quite nice representation of the EM using a coin toss example, which I want to display here. This picture is taken from the paper What is the expectation maximization algorithm? by the authors Do & Batzoglou (2008, p. 898). Let me first describe that picture, and then dive a bit deeper into the math behind this approach. We can see here, that we initially select two random variables for $\hat{\theta}_A^{(0)}$ and $\hat{\theta}_B^{(0)}$. Those are the respective probabilites that this coin displays head, when thrown. Next, we have some data, but we do not know which coin created that data.5 However, we can caluclate the expectation for each coin. So lets first calculate the expectation that the first dataset [HTTTHHTHTH] belongs to coin a, if coin a has the probability of $0.6$ to return head after thrown: \begin{equation} \frac{0.6^{5}*(1-0.6)^{10-5}}{0.6^{5}*(1-0.6)^{10-5}+0.5^{5}*0.5^{10-5}} = 0.45 \end{equation} The "algorithm" uses this function to calculate all the expectations for coin a. The expectation for coin b are easily computed, since we can just do 1 - probability of coin a. Once we have all data, we can multiply our expectation with the number of events we want to measure. Meaning, we calculate: \begin{equation} 0.45 * 5 = 2.2 \end{equation} Now we know, that if the first data set would belong to coin a, we would expect $2.2$ times heads and $2.2$ times tails6. Once we have that full table, all what we do, is to do MLE. We sum up the values for the occurances of heads and tails for each coin, and calculate the probability of heads for each coin. This is also called the M(aximization)-step. These two probabilities we just calculated are now our new values, with which we re-run our expectation calculation. We can repeat this as many times as we want. The nice idea of this is, that in the end we can approximate the real $\theta$s, viz. after ten iterations we have a posterior maximization value of $0.8$ for coin a. 4On the first page of their paper Dempster et al. [1] define a subset of data, as two sample spaces, whereas the second one is displayed through a transformation $y$. 5It should be noted that the EM algorithm is also seen as a clustering method, since we can now maximize the expectation that the data is either belongs to coin a or coin b. 6$0.45 * (10-5) = 2.2$ Conclusion After explaining MLE, MAP and EM, lets now discuss their relationship and why it was important to first review how a Bayesian thinks. The MAP function essentially derives from Bayes' rule, like shown in the Preface. When we again think about the function of the MAP, we can see that it just multiplies a likelihood with a prior. However, when use as prior the uniform distribution then MAP = MLE. Hence, the MLE is just a special version of the MAP, using a uniform distribution. EM also assumes that the given data is uniformly distributed, thus it uses the MLE. Having written that, Dempster et al. [1] point out multiple times, that the EM "algorithm" can easily be altered to use MAP, meaning a different probability distribution of the data. Add-on If you have read until this point, then you are really in love with either Data Science or theory! If you want to see this in action now, or you want to read more, it might be worth (additional to checking out the Sources section) to visit this link. Sources [1] Dempster et al. 1977 Note: This is the paper, where most of the references point to. It is really math heavy and explains the Expectation Maximization "algorithm" probably in its most mathmathical way. [2] https://jakevdp.github.io/blog/2014/03/11/frequentism-and-bayesianism-a-practical-intro/ Note: This is a really good introduction into Bayesian vs. Frequentists. It delves a lot more deeper into that topic that what was outlined here. Moreover, it was written by Jake Vanderplas who is a well known author and developer of the scipy Python package. [3] https://cs109.github.io/2015/ Note: This source is an amazing source for introductry to advanced topics in machine learning. They give really good advices on which books to read (which are mostly free available on the web) and they explain a lot of topics, so that they are understandable. This is a recommended source to read/listen to! [4] http://www.bdhammel.com/mle-map/ Note: In this source the distinction between MLE and MAP is also quite good explained. [5] https://datajobs.com/data-science-repo/Expectation-Maximization-Primer-[Do-and-Batzoglou].pdf Note: This paper is quite short, but visualizes and explains quite nice, what the EM algorithm is.
Relation between MAP, EM, and MLE I stumbled across this post, when I tried to give a more comprehensive answer of that topic to a friend of mine. Since the answer written by @Tim♦ is already a bit older and this topic just really com
18,143
How to create a toy survival (time to event) data with right censoring
It is not clear to me how you generate your event times (which, in your case, might be $<0$) and event indicators: time = rnorm(n,10,2) S_prob = S(time) event = ifelse(runif(1)>S_prob,1,0) So here is a generic method, followed by some R code. Generating survival times to simulate Cox proportional hazards models To generate event times from the proportional hazards model, we can use the inverse probability method (Bender et al., 2005): if $V$ is uniform on $(0, 1)$ and if $S(\cdot \,|\, \mathbf{x})$ is the conditional survival function derived from the proportional hazards model, i.e. $$ S(t \,|\, \mathbf{x}) = \exp \left( -H_0(t) \exp(\mathbf{x}^\prime \mathbf{\beta}) \vphantom{\Big(} \right) $$ then it is a fact that the random variable $$ T = S^{-1}(V \,|\, \mathbf{x}) = H_0^{-1} \left( - \frac{\log(V)}{\exp(\mathbf{x}^\prime \mathbf{\beta})} \right) $$ has survival function $S(\cdot \,|\, \mathbf{x})$. This result is known as ``the inverse probability integral transformation''. Therefore, to generate a survival time $T \sim S(\cdot \,|\, \mathbf{x})$ given the covariate vector, it suffices to draw $v$ from $V \sim \mathrm{U}(0, 1)$ and to make the inverse transformation $t = S^{-1}(v \,|\, \mathbf{x})$. Example [Weibull baseline hazard] Let $h_0(t) = \lambda \rho t^{\rho - 1}$ with shape $\rho > 0$ and scale $\lambda > 0$. Then $H_0(t) = \lambda t^\rho$ and $H^{-1}_0(t) = (\frac{t}{\lambda})^{\frac{1}{\rho}}$. Following the inverse probability method, a realisation of $T \sim S(\cdot \,|\, \mathbf{x})$ is obtained by computing $$ t = \left( - \frac{\log(v)}{\lambda \exp(\mathbf{x}^\prime \mathbf{\beta})} \right)^{\frac{1}{\rho}} $$ with $v$ a uniform variate on $(0, 1)$. Using results on transformations of random variables, one may notice that $T$ has a conditional Weibull distribution (given $\mathbf{x}$) with shape $\rho$ and scale $\lambda \exp(\mathbf{x}^\prime \mathbf{\beta})$. R code The following R function generates a data set with a single binary covariate $x$ (e.g. a treatment indicator). The baseline hazard has a Weibull form. Censoring times are randomly drawn from an exponential distribution. # baseline hazard: Weibull # N = sample size # lambda = scale parameter in h0() # rho = shape parameter in h0() # beta = fixed effect parameter # rateC = rate parameter of the exponential distribution of C simulWeib <- function(N, lambda, rho, beta, rateC) { # covariate --> N Bernoulli trials x <- sample(x=c(0, 1), size=N, replace=TRUE, prob=c(0.5, 0.5)) # Weibull latent event times v <- runif(n=N) Tlat <- (- log(v) / (lambda * exp(x * beta)))^(1 / rho) # censoring times C <- rexp(n=N, rate=rateC) # follow-up times and event indicators time <- pmin(Tlat, C) status <- as.numeric(Tlat <= C) # data set data.frame(id=1:N, time=time, status=status, x=x) } Test Here is some quick simulation with $\beta = -0.6$: set.seed(1234) betaHat <- rep(NA, 1e3) for(k in 1:1e3) { dat <- simulWeib(N=100, lambda=0.01, rho=1, beta=-0.6, rateC=0.001) fit <- coxph(Surv(time, status) ~ x, data=dat) betaHat[k] <- fit$coef } > mean(betaHat) [1] -0.6085473
How to create a toy survival (time to event) data with right censoring
It is not clear to me how you generate your event times (which, in your case, might be $<0$) and event indicators: time = rnorm(n,10,2) S_prob = S(time) event = ifelse(runif(1)>S_prob,1,0) So here
How to create a toy survival (time to event) data with right censoring It is not clear to me how you generate your event times (which, in your case, might be $<0$) and event indicators: time = rnorm(n,10,2) S_prob = S(time) event = ifelse(runif(1)>S_prob,1,0) So here is a generic method, followed by some R code. Generating survival times to simulate Cox proportional hazards models To generate event times from the proportional hazards model, we can use the inverse probability method (Bender et al., 2005): if $V$ is uniform on $(0, 1)$ and if $S(\cdot \,|\, \mathbf{x})$ is the conditional survival function derived from the proportional hazards model, i.e. $$ S(t \,|\, \mathbf{x}) = \exp \left( -H_0(t) \exp(\mathbf{x}^\prime \mathbf{\beta}) \vphantom{\Big(} \right) $$ then it is a fact that the random variable $$ T = S^{-1}(V \,|\, \mathbf{x}) = H_0^{-1} \left( - \frac{\log(V)}{\exp(\mathbf{x}^\prime \mathbf{\beta})} \right) $$ has survival function $S(\cdot \,|\, \mathbf{x})$. This result is known as ``the inverse probability integral transformation''. Therefore, to generate a survival time $T \sim S(\cdot \,|\, \mathbf{x})$ given the covariate vector, it suffices to draw $v$ from $V \sim \mathrm{U}(0, 1)$ and to make the inverse transformation $t = S^{-1}(v \,|\, \mathbf{x})$. Example [Weibull baseline hazard] Let $h_0(t) = \lambda \rho t^{\rho - 1}$ with shape $\rho > 0$ and scale $\lambda > 0$. Then $H_0(t) = \lambda t^\rho$ and $H^{-1}_0(t) = (\frac{t}{\lambda})^{\frac{1}{\rho}}$. Following the inverse probability method, a realisation of $T \sim S(\cdot \,|\, \mathbf{x})$ is obtained by computing $$ t = \left( - \frac{\log(v)}{\lambda \exp(\mathbf{x}^\prime \mathbf{\beta})} \right)^{\frac{1}{\rho}} $$ with $v$ a uniform variate on $(0, 1)$. Using results on transformations of random variables, one may notice that $T$ has a conditional Weibull distribution (given $\mathbf{x}$) with shape $\rho$ and scale $\lambda \exp(\mathbf{x}^\prime \mathbf{\beta})$. R code The following R function generates a data set with a single binary covariate $x$ (e.g. a treatment indicator). The baseline hazard has a Weibull form. Censoring times are randomly drawn from an exponential distribution. # baseline hazard: Weibull # N = sample size # lambda = scale parameter in h0() # rho = shape parameter in h0() # beta = fixed effect parameter # rateC = rate parameter of the exponential distribution of C simulWeib <- function(N, lambda, rho, beta, rateC) { # covariate --> N Bernoulli trials x <- sample(x=c(0, 1), size=N, replace=TRUE, prob=c(0.5, 0.5)) # Weibull latent event times v <- runif(n=N) Tlat <- (- log(v) / (lambda * exp(x * beta)))^(1 / rho) # censoring times C <- rexp(n=N, rate=rateC) # follow-up times and event indicators time <- pmin(Tlat, C) status <- as.numeric(Tlat <= C) # data set data.frame(id=1:N, time=time, status=status, x=x) } Test Here is some quick simulation with $\beta = -0.6$: set.seed(1234) betaHat <- rep(NA, 1e3) for(k in 1:1e3) { dat <- simulWeib(N=100, lambda=0.01, rho=1, beta=-0.6, rateC=0.001) fit <- coxph(Surv(time, status) ~ x, data=dat) betaHat[k] <- fit$coef } > mean(betaHat) [1] -0.6085473
How to create a toy survival (time to event) data with right censoring It is not clear to me how you generate your event times (which, in your case, might be $<0$) and event indicators: time = rnorm(n,10,2) S_prob = S(time) event = ifelse(runif(1)>S_prob,1,0) So here
18,144
How to create a toy survival (time to event) data with right censoring
Based on @ocram answer, toy data can also be created by using a built-in R function, rweibull(), with a scaled scale $\mathbf{\lambda^\prime}(\mathbf{\beta})$ where $$ \mathbf{\lambda^\prime} = \frac{\mathbf{\lambda}}{\exp(\frac{\mathbf{x}^\prime \mathbf{\beta}}{\mathbf{\rho}})}. $$ Because $$ S(t \,|\, \mathbf{x}) = \exp \left( -H_0(t) \exp(\mathbf{x}^\prime \mathbf{\beta}) \vphantom{\Big(} \right) $$ and S, or 1 - CDF, of Weibull distribution is $$ S(t) = \exp \left( {-(t/\mathbf{\lambda})^\mathbf{\rho}} \right) $$ so $$ S(t \,|\, \mathbf{x},\mathbf{\lambda}) = \exp\left({-(t/\mathbf{\lambda})^\mathbf{\rho}\exp(\mathbf{x}^\prime \mathbf{\beta})}\right) = \exp\left({-(t/\mathbf{\lambda})^\mathbf{\rho}\exp(\mathbf{x}^\prime \mathbf{\beta}/\mathbf{\rho})^\mathbf{\rho}}\right) = \exp\left(-\left(\frac{t}{\frac{\mathbf{\lambda}}{\exp(\mathbf{x}^\prime \mathbf{\beta}/\mathbf{\rho})}}\right)^\mathbf{\rho}\right) =S(t \,|\, \mathbf{x},\mathbf{\lambda}^\mathbf{\prime}) $$ R code with alternative draw for event times simulWeib <- function(N, lambda, rho, beta, rateC) { # covariate --> N Bernoulli trials x <- sample(x=c(0, 1), size=N, replace=TRUE, prob=c(0.5, 0.5)) # Weibull latent event times # v <- runif(n=N) # Tlat <- (- log(v) / (lambda * exp(x * beta)))^(1 / rho) # An alternative draw for event times lambda_wiki = lambda^(-1 / rho) #change definition of lambda to Wikipedia's lambda_prime = lambda_wiki / exp(x * beta / rho) #re-scale according to beta Tlat = rweibull(length(x), shape=rho, scale=lambda_prime) # censoring times C <- rexp(n=N, rate=rateC) # follow-up times and event indicators time <- pmin(Tlat, C) status <- as.numeric(Tlat <= C) # data set data.frame(id=1:N, time=time, status=status, x=x) } set.seed(1234) betaHat <- rep(NA, 1e3) for(k in 1:1e3) { dat <- simulWeib(N=100, lambda=0.01, rho=1, beta=-0.6, rateC=0.001) fit <- coxph(Surv(time, status) ~ x, data=dat) betaHat[k] <- fit$coef } > mean(betaHat) [1] -0.6085473
How to create a toy survival (time to event) data with right censoring
Based on @ocram answer, toy data can also be created by using a built-in R function, rweibull(), with a scaled scale $\mathbf{\lambda^\prime}(\mathbf{\beta})$ where $$ \mathbf{\lambda^\prime} = \frac{
How to create a toy survival (time to event) data with right censoring Based on @ocram answer, toy data can also be created by using a built-in R function, rweibull(), with a scaled scale $\mathbf{\lambda^\prime}(\mathbf{\beta})$ where $$ \mathbf{\lambda^\prime} = \frac{\mathbf{\lambda}}{\exp(\frac{\mathbf{x}^\prime \mathbf{\beta}}{\mathbf{\rho}})}. $$ Because $$ S(t \,|\, \mathbf{x}) = \exp \left( -H_0(t) \exp(\mathbf{x}^\prime \mathbf{\beta}) \vphantom{\Big(} \right) $$ and S, or 1 - CDF, of Weibull distribution is $$ S(t) = \exp \left( {-(t/\mathbf{\lambda})^\mathbf{\rho}} \right) $$ so $$ S(t \,|\, \mathbf{x},\mathbf{\lambda}) = \exp\left({-(t/\mathbf{\lambda})^\mathbf{\rho}\exp(\mathbf{x}^\prime \mathbf{\beta})}\right) = \exp\left({-(t/\mathbf{\lambda})^\mathbf{\rho}\exp(\mathbf{x}^\prime \mathbf{\beta}/\mathbf{\rho})^\mathbf{\rho}}\right) = \exp\left(-\left(\frac{t}{\frac{\mathbf{\lambda}}{\exp(\mathbf{x}^\prime \mathbf{\beta}/\mathbf{\rho})}}\right)^\mathbf{\rho}\right) =S(t \,|\, \mathbf{x},\mathbf{\lambda}^\mathbf{\prime}) $$ R code with alternative draw for event times simulWeib <- function(N, lambda, rho, beta, rateC) { # covariate --> N Bernoulli trials x <- sample(x=c(0, 1), size=N, replace=TRUE, prob=c(0.5, 0.5)) # Weibull latent event times # v <- runif(n=N) # Tlat <- (- log(v) / (lambda * exp(x * beta)))^(1 / rho) # An alternative draw for event times lambda_wiki = lambda^(-1 / rho) #change definition of lambda to Wikipedia's lambda_prime = lambda_wiki / exp(x * beta / rho) #re-scale according to beta Tlat = rweibull(length(x), shape=rho, scale=lambda_prime) # censoring times C <- rexp(n=N, rate=rateC) # follow-up times and event indicators time <- pmin(Tlat, C) status <- as.numeric(Tlat <= C) # data set data.frame(id=1:N, time=time, status=status, x=x) } set.seed(1234) betaHat <- rep(NA, 1e3) for(k in 1:1e3) { dat <- simulWeib(N=100, lambda=0.01, rho=1, beta=-0.6, rateC=0.001) fit <- coxph(Surv(time, status) ~ x, data=dat) betaHat[k] <- fit$coef } > mean(betaHat) [1] -0.6085473
How to create a toy survival (time to event) data with right censoring Based on @ocram answer, toy data can also be created by using a built-in R function, rweibull(), with a scaled scale $\mathbf{\lambda^\prime}(\mathbf{\beta})$ where $$ \mathbf{\lambda^\prime} = \frac{
18,145
How to create a toy survival (time to event) data with right censoring
For Weibull distribution, S(t) = $e^{-(\lambda * e^(x * \beta)*t)^\rho}$ "$^{(1/rho)}$" will be only for log(v) so, I modified like this Tlat <- (- log(v))^(1 / rho) / (lambda * exp(x * beta)) if rho = 1, result will be same.
How to create a toy survival (time to event) data with right censoring
For Weibull distribution, S(t) = $e^{-(\lambda * e^(x * \beta)*t)^\rho}$ "$^{(1/rho)}$" will be only for log(v) so, I modified like this Tlat <- (- log(v))^(1 / rho) / (lambda * exp(x * beta)) if rho
How to create a toy survival (time to event) data with right censoring For Weibull distribution, S(t) = $e^{-(\lambda * e^(x * \beta)*t)^\rho}$ "$^{(1/rho)}$" will be only for log(v) so, I modified like this Tlat <- (- log(v))^(1 / rho) / (lambda * exp(x * beta)) if rho = 1, result will be same.
How to create a toy survival (time to event) data with right censoring For Weibull distribution, S(t) = $e^{-(\lambda * e^(x * \beta)*t)^\rho}$ "$^{(1/rho)}$" will be only for log(v) so, I modified like this Tlat <- (- log(v))^(1 / rho) / (lambda * exp(x * beta)) if rho
18,146
Displaying three pieces of information on a graph
One way of visualizing data that is date/calendar based is via a matrix display that encodes the data with color. The matrix (or table) is arrange so that rows represent weeks and column represent days. You can add a final column for the weekly total if that is desirable. This can be implemented somewhat simply in Excel with conditional formatting if the data is arranged correctly. In particular, you can build a "grid" of values with formulas that lookup into your original data. From there, you can use conditional formatting to display the result. Here is what the result could look like. Sorry I changed the date format. The formula in cell H1 is: "=IFERROR(VLOOKUP($G$1+$G6*7+H$5, $B$5:$C$16,2,FALSE), 0)". It is doing some math to get the days in the right order. Hopefully it's straightforward. If you are really looking to push the envelope, you can use a framework like d3 and its calendar plugin to display this data. That might be more of an undertaking than it's worth though. This format is very similar to how GitHub displays user activity/contributions over time. Here is one user's (not me!).
Displaying three pieces of information on a graph
One way of visualizing data that is date/calendar based is via a matrix display that encodes the data with color. The matrix (or table) is arrange so that rows represent weeks and column represent da
Displaying three pieces of information on a graph One way of visualizing data that is date/calendar based is via a matrix display that encodes the data with color. The matrix (or table) is arrange so that rows represent weeks and column represent days. You can add a final column for the weekly total if that is desirable. This can be implemented somewhat simply in Excel with conditional formatting if the data is arranged correctly. In particular, you can build a "grid" of values with formulas that lookup into your original data. From there, you can use conditional formatting to display the result. Here is what the result could look like. Sorry I changed the date format. The formula in cell H1 is: "=IFERROR(VLOOKUP($G$1+$G6*7+H$5, $B$5:$C$16,2,FALSE), 0)". It is doing some math to get the days in the right order. Hopefully it's straightforward. If you are really looking to push the envelope, you can use a framework like d3 and its calendar plugin to display this data. That might be more of an undertaking than it's worth though. This format is very similar to how GitHub displays user activity/contributions over time. Here is one user's (not me!).
Displaying three pieces of information on a graph One way of visualizing data that is date/calendar based is via a matrix display that encodes the data with color. The matrix (or table) is arrange so that rows represent weeks and column represent da
18,147
Displaying three pieces of information on a graph
The prominent feature of the original is the weekly sums. The individual values are meaningful only after you've learned the colors, and I imagine that's a big reason the plot doesn't work for new viewers. Related to that, the time aspect of the days is lost. A sequential set of colors may help (e.g., 7 shades of blue). I normally don't care to label every item -- are the exact values that important? The graph isn't doing its job if you can't interpret it without every value labeled. On to my try. Given the apparent importance of the weekly sums, I've plotted the weekly cumulative sums. It shows the weekly sums and the days in time order. Exact day values are less clear, but outlier values will still stand out. For these kinds of small line plots (which could be reduced to sparkline size) it's helpful to have a reference line or area. For illustration, I've added a target range. If a target is not appropriate, then the reference could be something like the range over the last three weeks or some fixed reference value. I've used red to indicate which weeks were below target for quick scanning. With a lot more weeks, you might organize them into a grid rather than a vertical list.
Displaying three pieces of information on a graph
The prominent feature of the original is the weekly sums. The individual values are meaningful only after you've learned the colors, and I imagine that's a big reason the plot doesn't work for new vie
Displaying three pieces of information on a graph The prominent feature of the original is the weekly sums. The individual values are meaningful only after you've learned the colors, and I imagine that's a big reason the plot doesn't work for new viewers. Related to that, the time aspect of the days is lost. A sequential set of colors may help (e.g., 7 shades of blue). I normally don't care to label every item -- are the exact values that important? The graph isn't doing its job if you can't interpret it without every value labeled. On to my try. Given the apparent importance of the weekly sums, I've plotted the weekly cumulative sums. It shows the weekly sums and the days in time order. Exact day values are less clear, but outlier values will still stand out. For these kinds of small line plots (which could be reduced to sparkline size) it's helpful to have a reference line or area. For illustration, I've added a target range. If a target is not appropriate, then the reference could be something like the range over the last three weeks or some fixed reference value. I've used red to indicate which weeks were below target for quick scanning. With a lot more weeks, you might organize them into a grid rather than a vertical list.
Displaying three pieces of information on a graph The prominent feature of the original is the weekly sums. The individual values are meaningful only after you've learned the colors, and I imagine that's a big reason the plot doesn't work for new vie
18,148
Displaying three pieces of information on a graph
As I understand your question, it would be feasible to display hours and pages separately. I'll do that first. Afterwards, I'll display Total and Pages in one plot. I'm guessing that the actual numbers are not the most important thing - it's more important to get an overview of the weeks and weekdays, which were productive and which weren't. In that case, I suggest that you keep the natural temporal structure as there is actually only one temporal dimension in your data. We can still find a way to delimit the weeks. I used the following R-code and the ggplot2-package to produce this first plot. Your data has been loaded into the object data in the below code. The plot is a grouped bar plot, with the grey bars indicating weekly sums of pages. data <- rbind(data.frame(Date = c("17/11/2014", "18/11/2014", "19/11/2014", "20/11/2014"), Total = rep(0, 4), Pages = rep(0, 4)), data, data.frame(Date = c("31/01/2015", "01/02/2015"), Total = c(0, 0), Pages = c(0, 0))) n <- dim(data)[1] data$Date <- as.Date(data$Date, format = "%d/%m/%Y") data$weekday <- factor(rep(c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"), length.out = n)) data$weekday <- factor(data$weekday, levels(data$weekday)[c(2,6,7,5,1,3,4)]) data$week <- factor(rep(seq(from = 0, to = ceiling(((n - 3)/7))), each = 7, length.out = n)) ggplot(data = data, aes(x = week, y = Pages)) + geom_bar(aes(fill = weekday), stat = "identity", position = "dodge") + labs(fill = NULL) + xlab(NULL) + ylab("Number of pages") + geom_bar(stat = "identity", alpha = 0.2) + theme(panel.background = element_blank()) + scale_x_discrete(labels = paste("Week", seq(from = 0, to = 7))) This is clearly not perfect. The grey bars dominate to much as they compared to a day bar have a larger area for the same amount of reading. We could make them thinner, but I like the way they delimit the weeks. They indicate quite nicely which days are in the same week - something that wouldn't necessarily be intelligible otherwise. Especially because we have zero counts. In the next plot, I've used the mean number of pages (within week) as the height of the grey bar. This probably represents data better. However, notice that week 0 and 7 are misleading because they didn't include 7 days. You could easily work around this. If you insist on displaying pages and time simultaneously, you could do a back-to-back bar plot. It might be a little confusing as the two vertical scales are not the same. On the other hand, it might be nice to compare time spent and work done directly like this. EDIT: Realizing that the colors are really not needed that much and inspired by xan (see below comments) you could simplify the plot to something like this. I've marked Thurdays to give an additional visual guide. You could also argue in favor of using the same color for all bars to not overemphasize some (arbitrary) days. On a final note, you could also try scaling the axes differently by dividing your values by the mean value. This would make 1 a "normal" value. We could include a line at 1 to emphasize this point - now done on the back-to-back plot. This separates "good" from "bad" days in terms of mean work load. On this plot we might also make sure that one unit corresponds to the same distance on both axes as they are comparable now. Also note that I messed up the days in the first version. I've corrected the code and plots and I'll go practice the seven days of the week now. The code that produced the last plot: data$normPages <- data$Pages/mean(data$Pages) data$normTotal <- data$Total/mean(data$Total) data$weekNormPages <- data$Pages/(7*mean(data$Pages)) data$weekNormTotal <- data$Total/(7*mean(data$Total)) pTop <- ggplot(data = data, aes(x = week)) + geom_bar(aes(linetype = weekday, y = normPages), stat = "identity", position = "dodge", fill = "dodgerblue") + labs(fill = NULL) + xlab(NULL) + ylab("Number of pages") + geom_bar(aes(y = weekNormPages), stat = "identity", alpha = 0.3) + theme(panel.background = element_blank(), axis.ticks.length=unit(0,"cm")) + guides(linetype = FALSE) + scale_x_discrete(labels = paste("Week", seq(from = 0, to = 7))) + ylab(NULL) + annotate("text", label = "Pages read", x = "1", y = 10) + theme(plot.margin = unit(c(1,.5,.1,.8), "cm")) + geom_hline(yintercept = 1) pTop pBot <- ggplot(data = data, aes(x = week)) + geom_bar(aes(linetype = weekday, y = normTotal), stat = "identity", position = "dodge", fill = "dodgerblue") + labs(fill = NULL) + xlab(NULL) + ylab("Number of hours") + geom_bar(aes(y = weekNormPages), stat = "identity", alpha = 0.3) + theme(panel.background = element_blank(), axis.ticks.length=unit(0,"cm")) + guides(linetype = FALSE) + scale_x_discrete(labels = NULL) + guides(fill = FALSE) + ylab(NULL) + scale_y_reverse() + theme(plot.margin = unit(c(.1,.5,1,.8), "cm")) + annotate("text", label = "Time spent", x = "1", y = 4) + geom_hline(yintercept = 1) pBot grid.arrange(pTop, pBot, heights = c(.5, .5), widths = c(0.5, 0.1))
Displaying three pieces of information on a graph
As I understand your question, it would be feasible to display hours and pages separately. I'll do that first. Afterwards, I'll display Total and Pages in one plot. I'm guessing that the actual number
Displaying three pieces of information on a graph As I understand your question, it would be feasible to display hours and pages separately. I'll do that first. Afterwards, I'll display Total and Pages in one plot. I'm guessing that the actual numbers are not the most important thing - it's more important to get an overview of the weeks and weekdays, which were productive and which weren't. In that case, I suggest that you keep the natural temporal structure as there is actually only one temporal dimension in your data. We can still find a way to delimit the weeks. I used the following R-code and the ggplot2-package to produce this first plot. Your data has been loaded into the object data in the below code. The plot is a grouped bar plot, with the grey bars indicating weekly sums of pages. data <- rbind(data.frame(Date = c("17/11/2014", "18/11/2014", "19/11/2014", "20/11/2014"), Total = rep(0, 4), Pages = rep(0, 4)), data, data.frame(Date = c("31/01/2015", "01/02/2015"), Total = c(0, 0), Pages = c(0, 0))) n <- dim(data)[1] data$Date <- as.Date(data$Date, format = "%d/%m/%Y") data$weekday <- factor(rep(c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"), length.out = n)) data$weekday <- factor(data$weekday, levels(data$weekday)[c(2,6,7,5,1,3,4)]) data$week <- factor(rep(seq(from = 0, to = ceiling(((n - 3)/7))), each = 7, length.out = n)) ggplot(data = data, aes(x = week, y = Pages)) + geom_bar(aes(fill = weekday), stat = "identity", position = "dodge") + labs(fill = NULL) + xlab(NULL) + ylab("Number of pages") + geom_bar(stat = "identity", alpha = 0.2) + theme(panel.background = element_blank()) + scale_x_discrete(labels = paste("Week", seq(from = 0, to = 7))) This is clearly not perfect. The grey bars dominate to much as they compared to a day bar have a larger area for the same amount of reading. We could make them thinner, but I like the way they delimit the weeks. They indicate quite nicely which days are in the same week - something that wouldn't necessarily be intelligible otherwise. Especially because we have zero counts. In the next plot, I've used the mean number of pages (within week) as the height of the grey bar. This probably represents data better. However, notice that week 0 and 7 are misleading because they didn't include 7 days. You could easily work around this. If you insist on displaying pages and time simultaneously, you could do a back-to-back bar plot. It might be a little confusing as the two vertical scales are not the same. On the other hand, it might be nice to compare time spent and work done directly like this. EDIT: Realizing that the colors are really not needed that much and inspired by xan (see below comments) you could simplify the plot to something like this. I've marked Thurdays to give an additional visual guide. You could also argue in favor of using the same color for all bars to not overemphasize some (arbitrary) days. On a final note, you could also try scaling the axes differently by dividing your values by the mean value. This would make 1 a "normal" value. We could include a line at 1 to emphasize this point - now done on the back-to-back plot. This separates "good" from "bad" days in terms of mean work load. On this plot we might also make sure that one unit corresponds to the same distance on both axes as they are comparable now. Also note that I messed up the days in the first version. I've corrected the code and plots and I'll go practice the seven days of the week now. The code that produced the last plot: data$normPages <- data$Pages/mean(data$Pages) data$normTotal <- data$Total/mean(data$Total) data$weekNormPages <- data$Pages/(7*mean(data$Pages)) data$weekNormTotal <- data$Total/(7*mean(data$Total)) pTop <- ggplot(data = data, aes(x = week)) + geom_bar(aes(linetype = weekday, y = normPages), stat = "identity", position = "dodge", fill = "dodgerblue") + labs(fill = NULL) + xlab(NULL) + ylab("Number of pages") + geom_bar(aes(y = weekNormPages), stat = "identity", alpha = 0.3) + theme(panel.background = element_blank(), axis.ticks.length=unit(0,"cm")) + guides(linetype = FALSE) + scale_x_discrete(labels = paste("Week", seq(from = 0, to = 7))) + ylab(NULL) + annotate("text", label = "Pages read", x = "1", y = 10) + theme(plot.margin = unit(c(1,.5,.1,.8), "cm")) + geom_hline(yintercept = 1) pTop pBot <- ggplot(data = data, aes(x = week)) + geom_bar(aes(linetype = weekday, y = normTotal), stat = "identity", position = "dodge", fill = "dodgerblue") + labs(fill = NULL) + xlab(NULL) + ylab("Number of hours") + geom_bar(aes(y = weekNormPages), stat = "identity", alpha = 0.3) + theme(panel.background = element_blank(), axis.ticks.length=unit(0,"cm")) + guides(linetype = FALSE) + scale_x_discrete(labels = NULL) + guides(fill = FALSE) + ylab(NULL) + scale_y_reverse() + theme(plot.margin = unit(c(.1,.5,1,.8), "cm")) + annotate("text", label = "Time spent", x = "1", y = 4) + geom_hline(yintercept = 1) pBot grid.arrange(pTop, pBot, heights = c(.5, .5), widths = c(0.5, 0.1))
Displaying three pieces of information on a graph As I understand your question, it would be feasible to display hours and pages separately. I'll do that first. Afterwards, I'll display Total and Pages in one plot. I'm guessing that the actual number
18,149
Displaying three pieces of information on a graph
If I understand you correctly, the reason you don't want to use the line graphs is that you have too many weeks and the graphs would get messy. If this is the problem then you can divide the time series into components: Daily variation Weekly variation Long term trend Anything else. William S. Cleveland shows a nice example of this in one of his books (I am not at my office and can't remember which of his books has the example but it is either Visualizing data or The elements of graphing data). Both R and SAS have tools for doing this. Do you have access to either of them?
Displaying three pieces of information on a graph
If I understand you correctly, the reason you don't want to use the line graphs is that you have too many weeks and the graphs would get messy. If this is the problem then you can divide the time seri
Displaying three pieces of information on a graph If I understand you correctly, the reason you don't want to use the line graphs is that you have too many weeks and the graphs would get messy. If this is the problem then you can divide the time series into components: Daily variation Weekly variation Long term trend Anything else. William S. Cleveland shows a nice example of this in one of his books (I am not at my office and can't remember which of his books has the example but it is either Visualizing data or The elements of graphing data). Both R and SAS have tools for doing this. Do you have access to either of them?
Displaying three pieces of information on a graph If I understand you correctly, the reason you don't want to use the line graphs is that you have too many weeks and the graphs would get messy. If this is the problem then you can divide the time seri
18,150
Displaying three pieces of information on a graph
I will first spell out some objections to your original stacked or divided bar graphs. a. The colour coding appears completely arbitrary. Hence the graph cannot be studied without repeatedly going back and forth between legend and graph. b. Zeros are implicit, as invisible bar segments. Zeros are part of the variation. For those and other reasons, the graphs are difficult to decode. That said, the graph has merit if the interest is mostly in studying variation in totals from week to week. Many weeks could be plotted as many bars. The corresponding downside is that it would get harder and harder to study variations within weeks. Backing up: There are three variables here in each problem. Time studied or pages complete. Day of week. Week number. As the number of weeks increases, any graph will get more detailed. The challenge is to keep that detail under control. I would consider a cycle plot (other names have been used in the literature, but most refer to its use for looking at seasonal variation). There is a lucid introduction here by Naomi Robbins Her examples include those like yours where the interest is in variations within and between weeks.
Displaying three pieces of information on a graph
I will first spell out some objections to your original stacked or divided bar graphs. a. The colour coding appears completely arbitrary. Hence the graph cannot be studied without repeatedly going ba
Displaying three pieces of information on a graph I will first spell out some objections to your original stacked or divided bar graphs. a. The colour coding appears completely arbitrary. Hence the graph cannot be studied without repeatedly going back and forth between legend and graph. b. Zeros are implicit, as invisible bar segments. Zeros are part of the variation. For those and other reasons, the graphs are difficult to decode. That said, the graph has merit if the interest is mostly in studying variation in totals from week to week. Many weeks could be plotted as many bars. The corresponding downside is that it would get harder and harder to study variations within weeks. Backing up: There are three variables here in each problem. Time studied or pages complete. Day of week. Week number. As the number of weeks increases, any graph will get more detailed. The challenge is to keep that detail under control. I would consider a cycle plot (other names have been used in the literature, but most refer to its use for looking at seasonal variation). There is a lucid introduction here by Naomi Robbins Her examples include those like yours where the interest is in variations within and between weeks.
Displaying three pieces of information on a graph I will first spell out some objections to your original stacked or divided bar graphs. a. The colour coding appears completely arbitrary. Hence the graph cannot be studied without repeatedly going ba
18,151
Displaying three pieces of information on a graph
The line graphs would probably be easier to interpret if you took a rolling seven-day, fourteen-day or maybe 28-day moving average. That would smooth them out and still allow you to spot trends. This has some similarities with Peter Flom's solution, though is rather simpler and hence doesn't tell quite as full a picture - but it may well suffice for your needs. If you are recording your data in a spreadsheet, it has the advantage that such averaging can easily be performed within the spreadsheet itself by setting up some formulas, and the graph will automatically update as you fill in new data. Update to include graphs The spreadsheet graph for the seven-day rolling averages is unspectacular but seems to do its job well - daily variation is smoothed out so trends are easier to detect (compared to the equivalent daily chart which is so noisy as to be incomprehensible). Some key features are picked out well by this plot: for instance, a large quantity of work was done in mid-January, in hourly terms, but this was not accompanied by a proportionate rise in the average pages completed per day. The Christmas break is very visible and so long as individual data points are clearly plotted then it's not too misleading (if just the line was visible, it would be impossible to determine that the flat period was due to lack of data!). Nevertheless, I'd strongly recommend including rest days in the table, albeit with zero hours and zero pages. The graph could then respond to this, rather than hover $\approx 1.5$ hours per week over the break. With just fifty items of data it did not seem worth trying averaging over a longer period of time to detect longer run trends. Similarly I suspect that Peter Flom's excellent idea of seasonal decomposition would struggle with such limited data. If you were to perform the decomposition in your spreadsheet, it would be even more important to include the break as zero data. To reproduce my formulas, paste this so that 'Date' is in cell A1: Date Hours Pages 7-day rolling hours 7-day rolling pages 25/11/14 2.4999 6 26/11/14 1.4833 3 27/11/14 3.0499 6 28/11/14 0 0 29/11/14 2.4499 5 30/11/14 2.8833 2 01/12/14 0 0 =AVERAGE(B2:B8) =AVERAGE(C2:C8) 02/12/14 4.1166 8 =AVERAGE(B3:B9) =AVERAGE(C3:C9) 03/12/14 1.3333 5 =AVERAGE(B4:B10) =AVERAGE(C4:C10) 04/12/14 1.2499 3 =AVERAGE(B5:B11) =AVERAGE(C5:C11) 05/12/14 1.6666 8 =AVERAGE(B6:B12) =AVERAGE(C6:C12) 06/12/14 0 0 =AVERAGE(B7:B13) =AVERAGE(C7:C13) 07/12/14 2.4833 9 =AVERAGE(B8:B14) =AVERAGE(C8:C14) 29/12/14 0 0 =AVERAGE(B9:B15) =AVERAGE(C9:C15) 30/12/14 1.2332 1 =AVERAGE(B10:B16) =AVERAGE(C10:C16) 31/12/14 0.3333 0 =AVERAGE(B11:B17) =AVERAGE(C11:C17) 01/01/15 3.5666 2 =AVERAGE(B12:B18) =AVERAGE(C12:C18) 02/01/15 0.8166 0 =AVERAGE(B13:B19) =AVERAGE(C13:C19) 03/01/15 2.75 28 =AVERAGE(B14:B20) =AVERAGE(C14:C20) 04/01/15 0.4166 0 =AVERAGE(B15:B21) =AVERAGE(C15:C21) 05/01/15 1.2833 0 =AVERAGE(B16:B22) =AVERAGE(C16:C22) 06/01/15 0.3333 3 =AVERAGE(B17:B23) =AVERAGE(C17:C23) 07/01/15 0 0 =AVERAGE(B18:B24) =AVERAGE(C18:C24) 08/01/15 0 0 =AVERAGE(B19:B25) =AVERAGE(C19:C25) 09/01/15 2.35 2 =AVERAGE(B20:B26) =AVERAGE(C20:C26) 10/01/15 0.5666 0 =AVERAGE(B21:B27) =AVERAGE(C21:C27) 11/01/15 0 0 =AVERAGE(B22:B28) =AVERAGE(C22:C28) 12/01/15 1.6666 0 =AVERAGE(B23:B29) =AVERAGE(C23:C29) 13/01/15 2.2666 5 =AVERAGE(B24:B30) =AVERAGE(C24:C30) 14/01/15 2.5165 6 =AVERAGE(B25:B31) =AVERAGE(C25:C31) 15/01/15 2.0166 0 =AVERAGE(B26:B32) =AVERAGE(C26:C32) 16/01/15 2.9666 1 =AVERAGE(B27:B33) =AVERAGE(C27:C33) 17/01/15 0.8333 0 =AVERAGE(B28:B34) =AVERAGE(C28:C34) 18/01/15 0.6666 1 =AVERAGE(B29:B35) =AVERAGE(C29:C35) 19/01/15 1.45 0 =AVERAGE(B30:B36) =AVERAGE(C30:C36) 20/01/15 0.3166 0 =AVERAGE(B31:B37) =AVERAGE(C31:C37) 21/01/15 0 0 =AVERAGE(B32:B38) =AVERAGE(C32:C38) 22/01/15 0.2333 0 =AVERAGE(B33:B39) =AVERAGE(C33:C39) 23/01/15 0.85 2 =AVERAGE(B34:B40) =AVERAGE(C34:C40) 24/01/15 0 0 =AVERAGE(B35:B41) =AVERAGE(C35:C41) 25/01/15 0 0 =AVERAGE(B36:B42) =AVERAGE(C36:C42) 26/01/15 0.6666 4 =AVERAGE(B37:B43) =AVERAGE(C37:C43) 27/01/15 0.8333 1 =AVERAGE(B38:B44) =AVERAGE(C38:C44) 28/01/15 1.5498 5 =AVERAGE(B39:B45) =AVERAGE(C39:C45) 29/01/15 6.4159 9 =AVERAGE(B40:B46) =AVERAGE(C40:C46) 30/01/15 2.9166 0 =AVERAGE(B41:B47) =AVERAGE(C41:C47)
Displaying three pieces of information on a graph
The line graphs would probably be easier to interpret if you took a rolling seven-day, fourteen-day or maybe 28-day moving average. That would smooth them out and still allow you to spot trends. This
Displaying three pieces of information on a graph The line graphs would probably be easier to interpret if you took a rolling seven-day, fourteen-day or maybe 28-day moving average. That would smooth them out and still allow you to spot trends. This has some similarities with Peter Flom's solution, though is rather simpler and hence doesn't tell quite as full a picture - but it may well suffice for your needs. If you are recording your data in a spreadsheet, it has the advantage that such averaging can easily be performed within the spreadsheet itself by setting up some formulas, and the graph will automatically update as you fill in new data. Update to include graphs The spreadsheet graph for the seven-day rolling averages is unspectacular but seems to do its job well - daily variation is smoothed out so trends are easier to detect (compared to the equivalent daily chart which is so noisy as to be incomprehensible). Some key features are picked out well by this plot: for instance, a large quantity of work was done in mid-January, in hourly terms, but this was not accompanied by a proportionate rise in the average pages completed per day. The Christmas break is very visible and so long as individual data points are clearly plotted then it's not too misleading (if just the line was visible, it would be impossible to determine that the flat period was due to lack of data!). Nevertheless, I'd strongly recommend including rest days in the table, albeit with zero hours and zero pages. The graph could then respond to this, rather than hover $\approx 1.5$ hours per week over the break. With just fifty items of data it did not seem worth trying averaging over a longer period of time to detect longer run trends. Similarly I suspect that Peter Flom's excellent idea of seasonal decomposition would struggle with such limited data. If you were to perform the decomposition in your spreadsheet, it would be even more important to include the break as zero data. To reproduce my formulas, paste this so that 'Date' is in cell A1: Date Hours Pages 7-day rolling hours 7-day rolling pages 25/11/14 2.4999 6 26/11/14 1.4833 3 27/11/14 3.0499 6 28/11/14 0 0 29/11/14 2.4499 5 30/11/14 2.8833 2 01/12/14 0 0 =AVERAGE(B2:B8) =AVERAGE(C2:C8) 02/12/14 4.1166 8 =AVERAGE(B3:B9) =AVERAGE(C3:C9) 03/12/14 1.3333 5 =AVERAGE(B4:B10) =AVERAGE(C4:C10) 04/12/14 1.2499 3 =AVERAGE(B5:B11) =AVERAGE(C5:C11) 05/12/14 1.6666 8 =AVERAGE(B6:B12) =AVERAGE(C6:C12) 06/12/14 0 0 =AVERAGE(B7:B13) =AVERAGE(C7:C13) 07/12/14 2.4833 9 =AVERAGE(B8:B14) =AVERAGE(C8:C14) 29/12/14 0 0 =AVERAGE(B9:B15) =AVERAGE(C9:C15) 30/12/14 1.2332 1 =AVERAGE(B10:B16) =AVERAGE(C10:C16) 31/12/14 0.3333 0 =AVERAGE(B11:B17) =AVERAGE(C11:C17) 01/01/15 3.5666 2 =AVERAGE(B12:B18) =AVERAGE(C12:C18) 02/01/15 0.8166 0 =AVERAGE(B13:B19) =AVERAGE(C13:C19) 03/01/15 2.75 28 =AVERAGE(B14:B20) =AVERAGE(C14:C20) 04/01/15 0.4166 0 =AVERAGE(B15:B21) =AVERAGE(C15:C21) 05/01/15 1.2833 0 =AVERAGE(B16:B22) =AVERAGE(C16:C22) 06/01/15 0.3333 3 =AVERAGE(B17:B23) =AVERAGE(C17:C23) 07/01/15 0 0 =AVERAGE(B18:B24) =AVERAGE(C18:C24) 08/01/15 0 0 =AVERAGE(B19:B25) =AVERAGE(C19:C25) 09/01/15 2.35 2 =AVERAGE(B20:B26) =AVERAGE(C20:C26) 10/01/15 0.5666 0 =AVERAGE(B21:B27) =AVERAGE(C21:C27) 11/01/15 0 0 =AVERAGE(B22:B28) =AVERAGE(C22:C28) 12/01/15 1.6666 0 =AVERAGE(B23:B29) =AVERAGE(C23:C29) 13/01/15 2.2666 5 =AVERAGE(B24:B30) =AVERAGE(C24:C30) 14/01/15 2.5165 6 =AVERAGE(B25:B31) =AVERAGE(C25:C31) 15/01/15 2.0166 0 =AVERAGE(B26:B32) =AVERAGE(C26:C32) 16/01/15 2.9666 1 =AVERAGE(B27:B33) =AVERAGE(C27:C33) 17/01/15 0.8333 0 =AVERAGE(B28:B34) =AVERAGE(C28:C34) 18/01/15 0.6666 1 =AVERAGE(B29:B35) =AVERAGE(C29:C35) 19/01/15 1.45 0 =AVERAGE(B30:B36) =AVERAGE(C30:C36) 20/01/15 0.3166 0 =AVERAGE(B31:B37) =AVERAGE(C31:C37) 21/01/15 0 0 =AVERAGE(B32:B38) =AVERAGE(C32:C38) 22/01/15 0.2333 0 =AVERAGE(B33:B39) =AVERAGE(C33:C39) 23/01/15 0.85 2 =AVERAGE(B34:B40) =AVERAGE(C34:C40) 24/01/15 0 0 =AVERAGE(B35:B41) =AVERAGE(C35:C41) 25/01/15 0 0 =AVERAGE(B36:B42) =AVERAGE(C36:C42) 26/01/15 0.6666 4 =AVERAGE(B37:B43) =AVERAGE(C37:C43) 27/01/15 0.8333 1 =AVERAGE(B38:B44) =AVERAGE(C38:C44) 28/01/15 1.5498 5 =AVERAGE(B39:B45) =AVERAGE(C39:C45) 29/01/15 6.4159 9 =AVERAGE(B40:B46) =AVERAGE(C40:C46) 30/01/15 2.9166 0 =AVERAGE(B41:B47) =AVERAGE(C41:C47)
Displaying three pieces of information on a graph The line graphs would probably be easier to interpret if you took a rolling seven-day, fourteen-day or maybe 28-day moving average. That would smooth them out and still allow you to spot trends. This
18,152
Displaying three pieces of information on a graph
Change $x$ axis to weekdays, let $y$ the same and: plot the data as lines with two weeks as grouping variables - so to get two separate lines for each week, or use grouped bar plots where for each weekday you have two bars for week 1 and week 2, each with count of pages/hours per day.
Displaying three pieces of information on a graph
Change $x$ axis to weekdays, let $y$ the same and: plot the data as lines with two weeks as grouping variables - so to get two separate lines for each week, or use grouped bar plots where for each w
Displaying three pieces of information on a graph Change $x$ axis to weekdays, let $y$ the same and: plot the data as lines with two weeks as grouping variables - so to get two separate lines for each week, or use grouped bar plots where for each weekday you have two bars for week 1 and week 2, each with count of pages/hours per day.
Displaying three pieces of information on a graph Change $x$ axis to weekdays, let $y$ the same and: plot the data as lines with two weeks as grouping variables - so to get two separate lines for each week, or use grouped bar plots where for each w
18,153
Displaying three pieces of information on a graph
The plot below shows cumulative Hours of Study and Total Pages within each week using lines instead of stacked bars, which hopefully will make it easier to see the trend within each week and compare between weeks. I've filled in the missing weeks with zeros, but you can exclude those if you wish. The R code for the data processing and plot generation is posted below the graph. In carrying out the steps below, I first loaded the data posted in the question into a data frame called dat. library(lubridate) library(dplyr) library(reshape2) library(ggplot2) library(scales) # Ordered vector of weekdays weekdayVec = c("Sunday","Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday") # Change column name names(dat)[2] = "Hours of Study" # Convert Date to date format dat$Date = as.Date(dmy(dat$Date)) # Add a weekday variable and order from Sunday to Saturday dat$Day = weekdays(dat$Date) dat$Day = factor(dat$Day, levels=weekdayVec) # Number the weeks from 1 to 11 and convert to a factor dat$Week = paste("Week", (as.numeric(dat$Date) - as.numeric(dat$Date[3])) %/% 7 + 2) dat$Week = factor(dat$Week, levels=paste("Week", c(1:11))) ## Fill in empty dates (so we can show zero pages/hours during weeks 5 and 6 if we want) dataFill = expand.grid(Week = paste("Week",1:11), Day=weekdayVec) dat = merge(dataFill, dat, by=c("Week","Day"), all=TRUE) # Fill in missing dates dat$Date = as.Date(c(rep(NA,5), seq(as.Date("2014-11-21"),as.Date("2015-01-30"),1), NA)) # Convert missing data to zeros for Hours of Study and Total Pages dat = dat %>% mutate(`Hours of Study` = ifelse(is.na(`Hours of Study`), 0, `Hours of Study`), `Total Pages` = ifelse(is.na(`Total Pages`), 0, `Total Pages`)) # Melt data into long format (for facetting in ggplot2) dat.m = dat %>% melt(id.var=1:3) %>% group_by(Week, variable) %>% mutate(cumValue = cumsum(value)) # Plot Hours and Pages by date, with separate cumulative # curves for each week ggplot(dat.m %>% group_by(Week, variable) %>% arrange(Week, Day), aes(Date, cumValue, colour=Week, group=Week)) + geom_vline(xintercept=as.numeric(seq(as.Date("2014-11-16"), as.Date("2015-02-06"), 7)-0.5), colour="grey70") + geom_line(position=position_dodge(width=0.5)) + geom_point(size=2.5, position=position_dodge(width=0.5)) + facet_grid(variable ~ ., scales="free_y") + guides(colour=guide_legend(reverse=TRUE)) + labs(y="",x="") + guides(colour=FALSE) + scale_x_date(limits=c(as.Date("2014-11-16"),as.Date("2015-01-31")), breaks=seq(as.Date("2014-11-16"),as.Date("2015-01-31"), 7)-0.5, labels=paste(" Week",1:11)) + theme_grey(base_size=15)
Displaying three pieces of information on a graph
The plot below shows cumulative Hours of Study and Total Pages within each week using lines instead of stacked bars, which hopefully will make it easier to see the trend within each week and compare b
Displaying three pieces of information on a graph The plot below shows cumulative Hours of Study and Total Pages within each week using lines instead of stacked bars, which hopefully will make it easier to see the trend within each week and compare between weeks. I've filled in the missing weeks with zeros, but you can exclude those if you wish. The R code for the data processing and plot generation is posted below the graph. In carrying out the steps below, I first loaded the data posted in the question into a data frame called dat. library(lubridate) library(dplyr) library(reshape2) library(ggplot2) library(scales) # Ordered vector of weekdays weekdayVec = c("Sunday","Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday") # Change column name names(dat)[2] = "Hours of Study" # Convert Date to date format dat$Date = as.Date(dmy(dat$Date)) # Add a weekday variable and order from Sunday to Saturday dat$Day = weekdays(dat$Date) dat$Day = factor(dat$Day, levels=weekdayVec) # Number the weeks from 1 to 11 and convert to a factor dat$Week = paste("Week", (as.numeric(dat$Date) - as.numeric(dat$Date[3])) %/% 7 + 2) dat$Week = factor(dat$Week, levels=paste("Week", c(1:11))) ## Fill in empty dates (so we can show zero pages/hours during weeks 5 and 6 if we want) dataFill = expand.grid(Week = paste("Week",1:11), Day=weekdayVec) dat = merge(dataFill, dat, by=c("Week","Day"), all=TRUE) # Fill in missing dates dat$Date = as.Date(c(rep(NA,5), seq(as.Date("2014-11-21"),as.Date("2015-01-30"),1), NA)) # Convert missing data to zeros for Hours of Study and Total Pages dat = dat %>% mutate(`Hours of Study` = ifelse(is.na(`Hours of Study`), 0, `Hours of Study`), `Total Pages` = ifelse(is.na(`Total Pages`), 0, `Total Pages`)) # Melt data into long format (for facetting in ggplot2) dat.m = dat %>% melt(id.var=1:3) %>% group_by(Week, variable) %>% mutate(cumValue = cumsum(value)) # Plot Hours and Pages by date, with separate cumulative # curves for each week ggplot(dat.m %>% group_by(Week, variable) %>% arrange(Week, Day), aes(Date, cumValue, colour=Week, group=Week)) + geom_vline(xintercept=as.numeric(seq(as.Date("2014-11-16"), as.Date("2015-02-06"), 7)-0.5), colour="grey70") + geom_line(position=position_dodge(width=0.5)) + geom_point(size=2.5, position=position_dodge(width=0.5)) + facet_grid(variable ~ ., scales="free_y") + guides(colour=guide_legend(reverse=TRUE)) + labs(y="",x="") + guides(colour=FALSE) + scale_x_date(limits=c(as.Date("2014-11-16"),as.Date("2015-01-31")), breaks=seq(as.Date("2014-11-16"),as.Date("2015-01-31"), 7)-0.5, labels=paste(" Week",1:11)) + theme_grey(base_size=15)
Displaying three pieces of information on a graph The plot below shows cumulative Hours of Study and Total Pages within each week using lines instead of stacked bars, which hopefully will make it easier to see the trend within each week and compare b
18,154
Displaying three pieces of information on a graph
Another option is the bubble chart, where you can have vertical height for one variable and dot size for the other. Below, date (day) is horizontal, Hours studied is vertical, Pages covered per day is bubble size, and week is colored.
Displaying three pieces of information on a graph
Another option is the bubble chart, where you can have vertical height for one variable and dot size for the other. Below, date (day) is horizontal, Hours studied is vertical, Pages covered per day is
Displaying three pieces of information on a graph Another option is the bubble chart, where you can have vertical height for one variable and dot size for the other. Below, date (day) is horizontal, Hours studied is vertical, Pages covered per day is bubble size, and week is colored.
Displaying three pieces of information on a graph Another option is the bubble chart, where you can have vertical height for one variable and dot size for the other. Below, date (day) is horizontal, Hours studied is vertical, Pages covered per day is
18,155
Displaying three pieces of information on a graph
You could plot in 3d. I didn't verify that the day of week was calculated correctly, find the best viewing angle, etc, but this should give you the idea. Further embellishments are also possible. For example, it might be better to connect the points with a line and move the gridlines to correspond to each Monday. Actually what would be very interesting to try is having each left-right and up-down gridline (as shown in this angle) correspond to the same day of the week (e.g. monday), then putting boxplots on the bottom and back right walls within the gridlines. The boxplots would correspond to the total hours and total pages for each week, respectively. I am near certain that would be possible to do with rgl, but would require some tinkering. It may be worth it. Violin plots or beanplots may be even better. The data (for inputting to R): dat<-structure(list(Date = structure(c(17L, 19L, 21L, 23L, 25L, 27L, 29L, 31L, 33L, 38L, 2L, 14L, 36L, 42L, 44L, 46L, 48L, 34L, 39L, 40L, 1L, 13L, 35L, 41L, 43L, 45L, 47L, 49L, 50L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 15L, 16L, 18L, 20L, 22L, 24L, 26L, 28L, 30L, 32L, 37L), .Label = c("1/1/2015", "1/12/2014", "10/1/2015", "11/1/2015", "12/1/2015", "13/01/2015", "14/01/2015", "15/01/2015", "16/01/2015", "17/01/2015", "18/01/2015", "19/01/2015", "2/1/2015", "2/12/2014", "20/01/2015", "21/01/2015", "21/11/2014", "22/01/2015", "22/11/2014", "23/01/2015", "23/11/2014", "24/01/2015", "24/11/2014", "25/01/2015", "25/11/2014", "26/01/2015", "26/11/2014", "27/01/2015", "27/11/2014", "28/01/2015", "28/11/2014", "29/01/2015", "29/11/2014", "29/12/2014", "3/1/2015", "3/12/2014", "30/01/2015", "30/11/2014", "30/12/2014", "31/12/2014", "4/1/2015", "4/12/2014", "5/1/2015", "5/12/2014", "6/1/2015", "6/12/2014", "7/1/2015", "7/12/2014", "8/1/2015", "9/1/2015"), class = "factor"), TotalHours = c(2.4166, 0, 1.5833, 3.0166, 2.4999, 1.4833, 3.0499, 0, 2.4499, 2.8833, 0, 4.1166, 1.3333, 1.2499, 1.6666, 0, 2.4833, 0, 1.2332, 0.3333, 3.5666, 0.8166, 2.75, 0.4166, 1.2833, 0.3333, 0, 0, 2.35, 0.5666, 0, 1.6666, 2.2666, 2.5165, 2.0166, 2.9666, 0.8333, 0.6666, 1.45, 0.3166, 0, 0.2333, 0.85, 0, 0, 0.6666, 0.8333, 1.5498, 6.4159, 2.9166), TotalPages = c(0L, 0L, 4L, 13L, 6L, 3L, 6L, 0L, 5L, 2L, 0L, 8L, 5L, 3L, 8L, 0L, 9L, 0L, 1L, 0L, 2L, 0L, 28L, 0L, 0L, 3L, 0L, 0L, 2L, 0L, 0L, 0L, 5L, 6L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 2L, 0L, 0L, 4L, 1L, 5L, 9L, 0L)), .Names = c("Date", "TotalHours", "TotalPages"), class = "data.frame", row.names = c(NA, -50L)) Make the plot: #Get Day of Week dat<-cbind(weekdays(as.Date(dat[,1], format="%d/%m/%Y")),dat) colnames(dat)[1]<-"DoW" #3D Plot require(rgl) plot3d(dat[,2],dat[,3],dat[,4],size=15, xlab=colnames(dat)[2], ylab=colnames(dat)[3], zlab=colnames(dat)[4],col=rainbow(7)[as.numeric(dat[,1])]) text3d(x=10, y=6, z=seq(25,15,length=7),levels(dat[,1]), col=rainbow(7), font=2) grid3d(side=c("x", "y+", "z"), lwd=1)
Displaying three pieces of information on a graph
You could plot in 3d. I didn't verify that the day of week was calculated correctly, find the best viewing angle, etc, but this should give you the idea. Further embellishments are also possible. For
Displaying three pieces of information on a graph You could plot in 3d. I didn't verify that the day of week was calculated correctly, find the best viewing angle, etc, but this should give you the idea. Further embellishments are also possible. For example, it might be better to connect the points with a line and move the gridlines to correspond to each Monday. Actually what would be very interesting to try is having each left-right and up-down gridline (as shown in this angle) correspond to the same day of the week (e.g. monday), then putting boxplots on the bottom and back right walls within the gridlines. The boxplots would correspond to the total hours and total pages for each week, respectively. I am near certain that would be possible to do with rgl, but would require some tinkering. It may be worth it. Violin plots or beanplots may be even better. The data (for inputting to R): dat<-structure(list(Date = structure(c(17L, 19L, 21L, 23L, 25L, 27L, 29L, 31L, 33L, 38L, 2L, 14L, 36L, 42L, 44L, 46L, 48L, 34L, 39L, 40L, 1L, 13L, 35L, 41L, 43L, 45L, 47L, 49L, 50L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 15L, 16L, 18L, 20L, 22L, 24L, 26L, 28L, 30L, 32L, 37L), .Label = c("1/1/2015", "1/12/2014", "10/1/2015", "11/1/2015", "12/1/2015", "13/01/2015", "14/01/2015", "15/01/2015", "16/01/2015", "17/01/2015", "18/01/2015", "19/01/2015", "2/1/2015", "2/12/2014", "20/01/2015", "21/01/2015", "21/11/2014", "22/01/2015", "22/11/2014", "23/01/2015", "23/11/2014", "24/01/2015", "24/11/2014", "25/01/2015", "25/11/2014", "26/01/2015", "26/11/2014", "27/01/2015", "27/11/2014", "28/01/2015", "28/11/2014", "29/01/2015", "29/11/2014", "29/12/2014", "3/1/2015", "3/12/2014", "30/01/2015", "30/11/2014", "30/12/2014", "31/12/2014", "4/1/2015", "4/12/2014", "5/1/2015", "5/12/2014", "6/1/2015", "6/12/2014", "7/1/2015", "7/12/2014", "8/1/2015", "9/1/2015"), class = "factor"), TotalHours = c(2.4166, 0, 1.5833, 3.0166, 2.4999, 1.4833, 3.0499, 0, 2.4499, 2.8833, 0, 4.1166, 1.3333, 1.2499, 1.6666, 0, 2.4833, 0, 1.2332, 0.3333, 3.5666, 0.8166, 2.75, 0.4166, 1.2833, 0.3333, 0, 0, 2.35, 0.5666, 0, 1.6666, 2.2666, 2.5165, 2.0166, 2.9666, 0.8333, 0.6666, 1.45, 0.3166, 0, 0.2333, 0.85, 0, 0, 0.6666, 0.8333, 1.5498, 6.4159, 2.9166), TotalPages = c(0L, 0L, 4L, 13L, 6L, 3L, 6L, 0L, 5L, 2L, 0L, 8L, 5L, 3L, 8L, 0L, 9L, 0L, 1L, 0L, 2L, 0L, 28L, 0L, 0L, 3L, 0L, 0L, 2L, 0L, 0L, 0L, 5L, 6L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 2L, 0L, 0L, 4L, 1L, 5L, 9L, 0L)), .Names = c("Date", "TotalHours", "TotalPages"), class = "data.frame", row.names = c(NA, -50L)) Make the plot: #Get Day of Week dat<-cbind(weekdays(as.Date(dat[,1], format="%d/%m/%Y")),dat) colnames(dat)[1]<-"DoW" #3D Plot require(rgl) plot3d(dat[,2],dat[,3],dat[,4],size=15, xlab=colnames(dat)[2], ylab=colnames(dat)[3], zlab=colnames(dat)[4],col=rainbow(7)[as.numeric(dat[,1])]) text3d(x=10, y=6, z=seq(25,15,length=7),levels(dat[,1]), col=rainbow(7), font=2) grid3d(side=c("x", "y+", "z"), lwd=1)
Displaying three pieces of information on a graph You could plot in 3d. I didn't verify that the day of week was calculated correctly, find the best viewing angle, etc, but this should give you the idea. Further embellishments are also possible. For
18,156
Displaying three pieces of information on a graph
Following heatmap with week number (of year), day of week and facets for hours and pages may be helpful: Removing 2 high values give better color gradients on plot: Following barchart may also be helpful. It clearly shows a 2 week period when no work was done. Plot with lines may also be useful (lines are not cluttered; the points can also be removed, keeping only two lines) They clearly convey the information while simplifying the plot for easy understanding.
Displaying three pieces of information on a graph
Following heatmap with week number (of year), day of week and facets for hours and pages may be helpful: Removing 2 high values give better color gradients on plot: Following barchart may also be h
Displaying three pieces of information on a graph Following heatmap with week number (of year), day of week and facets for hours and pages may be helpful: Removing 2 high values give better color gradients on plot: Following barchart may also be helpful. It clearly shows a 2 week period when no work was done. Plot with lines may also be useful (lines are not cluttered; the points can also be removed, keeping only two lines) They clearly convey the information while simplifying the plot for easy understanding.
Displaying three pieces of information on a graph Following heatmap with week number (of year), day of week and facets for hours and pages may be helpful: Removing 2 high values give better color gradients on plot: Following barchart may also be h
18,157
Difference of Gamma random variables
I will outline how the problem can be approached and state what I think the end result will be for the special case when the shape parameters are integers, but not fill in the details. First, note that $X-Y$ takes on values in $(-\infty,\infty)$ and so $f_{X-Y}(z)$ has support $(-\infty,\infty)$. Second, from the standard results that the density of the sum of two independent continuous random variables is the convolution of their densities, that is, $$f_{X+Y}(z) = \int_{-\infty}^\infty f_X(x)f_Y(z-x)\,\mathrm dx$$ and that the density of the random variable $-Y$ is $f_{-Y}(\alpha) = f_Y(-\alpha)$, deduce that $$f_{X-Y}(z) = f_{X+(-Y)}(z) = \int_{-\infty}^\infty f_X(x)f_{-Y}(z-x)\,\mathrm dx = \int_{-\infty}^\infty f_X(x)f_Y(x-z)\,\mathrm dx.$$ Third, for non-negative random variables $X$ and $Y$, note that the above expression simplifies to $$f_{X-Y}(z) = \begin{cases} \int_0^\infty f_X(x)f_Y(x-z)\,\mathrm dx, & z < 0,\\ \int_{0}^\infty f_X(y+z)f_Y(y)\,\mathrm dy, & z > 0. \end{cases}$$ Finally, using parametrization $\Gamma(s,\lambda)$ to mean a random variable with density $\lambda\frac{(\lambda x)^{s-1}}{\Gamma(s)}\exp(-\lambda x)\mathbf 1_{x>0}(x)$, and with $X \sim \Gamma(s,\lambda)$ and $Y \sim \Gamma(t,\mu)$ random variables, we have for $z > 0$ that $$\begin{align*}f_{X-Y}(z) &= \int_{0}^\infty \lambda\frac{(\lambda (y+z))^{s-1}}{\Gamma(s)}\exp(-\lambda (y+z)) \mu\frac{(\mu y)^{t-1}}{\Gamma(t)}\exp(-\mu y)\,\mathrm dy\\ &= \exp(-\lambda z) \int_0^\infty p(y,z)\exp(-(\lambda+\mu)y)\,\mathrm dy.\tag{1} \end{align*}$$ Similarly, for $z < 0$, $$\begin{align*}f_{X-Y}(z) &= \int_{0}^\infty \lambda\frac{(\lambda x)^{s-1}}{\Gamma(s)}\exp(-\lambda x) \mu\frac{(\mu (x-z))^{t-1}}{\Gamma(t)}\exp(-\mu (x-z))\,\mathrm dx\\ &= \exp(\mu z) \int_0^\infty q(x,z)\exp(-(\lambda+\mu)x)\,\mathrm dx.\tag{2} \end{align*}$$ These integrals are not easy to evaluate but for the special case $s = t$, Gradshteyn and Ryzhik, Tables of Integrals, Series, and Products, Section 3.383, lists the value of $$\int_0^\infty x^{s-1}(x+\beta)^{s-1}\exp(-\nu x)\,\mathrm dx$$ in terms of polynomial, exponential and Bessel functions of $\beta$ and this can be used to write down explicit expressions for $f_{X-Y}(z)$. From here on, we assume that $s$ and $t$ are integers so that $p(y,z)$ is a polynomial in $y$ and $z$ of degree $(s+t-2, s-1)$ and $q(x,z)$ is a polynomial in $x$ and $z$ of degree $(s+t-2,t-1)$. For $z > 0$, the integral $(1)$ is the sum of $s$ Gamma integrals with respect to $y$ with coefficients $1, z, z^2, \ldots z^{s-1}$. It follows that the density of $X-Y$ is proportional to a mixture density of $\Gamma(1,\lambda), \Gamma(2,\lambda), \cdots, \Gamma(s,\lambda)$ random variables for $z > 0$. Note that this result will hold even if $t$ is not an integer. Similarly, for $z < 0$, the density of $X-Y$ is proportional to a mixture density of $\Gamma(1,\mu), \Gamma(2,\mu), \cdots, \Gamma(t,\mu)$ random variables flipped over, that is, it will have terms such as $(\mu|z|)^{k-1}\exp(\mu z)$ instead of the usual $(\mu z)^{k-1}\exp(-\mu z)$. Also, this result will hold even if $s$ is not an integer.
Difference of Gamma random variables
I will outline how the problem can be approached and state what I think the end result will be for the special case when the shape parameters are integers, but not fill in the details. First, note th
Difference of Gamma random variables I will outline how the problem can be approached and state what I think the end result will be for the special case when the shape parameters are integers, but not fill in the details. First, note that $X-Y$ takes on values in $(-\infty,\infty)$ and so $f_{X-Y}(z)$ has support $(-\infty,\infty)$. Second, from the standard results that the density of the sum of two independent continuous random variables is the convolution of their densities, that is, $$f_{X+Y}(z) = \int_{-\infty}^\infty f_X(x)f_Y(z-x)\,\mathrm dx$$ and that the density of the random variable $-Y$ is $f_{-Y}(\alpha) = f_Y(-\alpha)$, deduce that $$f_{X-Y}(z) = f_{X+(-Y)}(z) = \int_{-\infty}^\infty f_X(x)f_{-Y}(z-x)\,\mathrm dx = \int_{-\infty}^\infty f_X(x)f_Y(x-z)\,\mathrm dx.$$ Third, for non-negative random variables $X$ and $Y$, note that the above expression simplifies to $$f_{X-Y}(z) = \begin{cases} \int_0^\infty f_X(x)f_Y(x-z)\,\mathrm dx, & z < 0,\\ \int_{0}^\infty f_X(y+z)f_Y(y)\,\mathrm dy, & z > 0. \end{cases}$$ Finally, using parametrization $\Gamma(s,\lambda)$ to mean a random variable with density $\lambda\frac{(\lambda x)^{s-1}}{\Gamma(s)}\exp(-\lambda x)\mathbf 1_{x>0}(x)$, and with $X \sim \Gamma(s,\lambda)$ and $Y \sim \Gamma(t,\mu)$ random variables, we have for $z > 0$ that $$\begin{align*}f_{X-Y}(z) &= \int_{0}^\infty \lambda\frac{(\lambda (y+z))^{s-1}}{\Gamma(s)}\exp(-\lambda (y+z)) \mu\frac{(\mu y)^{t-1}}{\Gamma(t)}\exp(-\mu y)\,\mathrm dy\\ &= \exp(-\lambda z) \int_0^\infty p(y,z)\exp(-(\lambda+\mu)y)\,\mathrm dy.\tag{1} \end{align*}$$ Similarly, for $z < 0$, $$\begin{align*}f_{X-Y}(z) &= \int_{0}^\infty \lambda\frac{(\lambda x)^{s-1}}{\Gamma(s)}\exp(-\lambda x) \mu\frac{(\mu (x-z))^{t-1}}{\Gamma(t)}\exp(-\mu (x-z))\,\mathrm dx\\ &= \exp(\mu z) \int_0^\infty q(x,z)\exp(-(\lambda+\mu)x)\,\mathrm dx.\tag{2} \end{align*}$$ These integrals are not easy to evaluate but for the special case $s = t$, Gradshteyn and Ryzhik, Tables of Integrals, Series, and Products, Section 3.383, lists the value of $$\int_0^\infty x^{s-1}(x+\beta)^{s-1}\exp(-\nu x)\,\mathrm dx$$ in terms of polynomial, exponential and Bessel functions of $\beta$ and this can be used to write down explicit expressions for $f_{X-Y}(z)$. From here on, we assume that $s$ and $t$ are integers so that $p(y,z)$ is a polynomial in $y$ and $z$ of degree $(s+t-2, s-1)$ and $q(x,z)$ is a polynomial in $x$ and $z$ of degree $(s+t-2,t-1)$. For $z > 0$, the integral $(1)$ is the sum of $s$ Gamma integrals with respect to $y$ with coefficients $1, z, z^2, \ldots z^{s-1}$. It follows that the density of $X-Y$ is proportional to a mixture density of $\Gamma(1,\lambda), \Gamma(2,\lambda), \cdots, \Gamma(s,\lambda)$ random variables for $z > 0$. Note that this result will hold even if $t$ is not an integer. Similarly, for $z < 0$, the density of $X-Y$ is proportional to a mixture density of $\Gamma(1,\mu), \Gamma(2,\mu), \cdots, \Gamma(t,\mu)$ random variables flipped over, that is, it will have terms such as $(\mu|z|)^{k-1}\exp(\mu z)$ instead of the usual $(\mu z)^{k-1}\exp(-\mu z)$. Also, this result will hold even if $s$ is not an integer.
Difference of Gamma random variables I will outline how the problem can be approached and state what I think the end result will be for the special case when the shape parameters are integers, but not fill in the details. First, note th
18,158
Difference of Gamma random variables
To my knowledge the distribution of the difference of two independent gamma r.v.’s was first studied by Mathai in 1993. He derived a closed form solution. I will not reproduce his work here. Instead I will point you to the original source. The closed form solution can be found on page 241 as theorem 2.1 in his paper On non-central generalized Laplacianness of quadratic forms in normal variables.
Difference of Gamma random variables
To my knowledge the distribution of the difference of two independent gamma r.v.’s was first studied by Mathai in 1993. He derived a closed form solution. I will not reproduce his work here. Instead I
Difference of Gamma random variables To my knowledge the distribution of the difference of two independent gamma r.v.’s was first studied by Mathai in 1993. He derived a closed form solution. I will not reproduce his work here. Instead I will point you to the original source. The closed form solution can be found on page 241 as theorem 2.1 in his paper On non-central generalized Laplacianness of quadratic forms in normal variables.
Difference of Gamma random variables To my knowledge the distribution of the difference of two independent gamma r.v.’s was first studied by Mathai in 1993. He derived a closed form solution. I will not reproduce his work here. Instead I
18,159
Difference of Gamma random variables
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. the difference of two independent or correlated Gamma random variables are special cases of McKay distribution. The exact and complete answer can be find in: Sum and difference of two squared correlated Nakagami variates in connection with the McKay distribution Holm, H., Alouini, M.-S. IEEE Transactions on Communications, 2004 Vol. 52; Iss. 8
Difference of Gamma random variables
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
Difference of Gamma random variables Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. the difference of two independent or correlated Gamma random variables are special cases of McKay distribution. The exact and complete answer can be find in: Sum and difference of two squared correlated Nakagami variates in connection with the McKay distribution Holm, H., Alouini, M.-S. IEEE Transactions on Communications, 2004 Vol. 52; Iss. 8
Difference of Gamma random variables Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
18,160
Removing extraneous points near the centre of a QQ-plot
Q-Q plots are incredibly autocorrelated except in the tails. In reviewing them, one focuses on the overall shape of the plot and on tail behavior. Ergo, you will do fine by coarsely subsampling in the centers of the distributions and including a sufficient amount of the tails. Here is code illustrating how to sample across an entire dataset as well as how to take extreme values. quant.subsample <- function(y, m=100, e=1) { # m: size of a systematic sample # e: number of extreme values at either end to use x <- sort(y) n <- length(x) quants <- (1 + sin(1:m / (m+1) * pi - pi/2))/2 sort(c(x[1:e], quantile(x, probs=quants), x[(n+1-e):n])) # Returns m + 2*e sorted values from the EDF of y } To illustrate, this simulated dataset shows a structural difference between two datasets of approximately 1.2 million values as well as a very small amount of "contamination" in one of them. Also, to make this test stringent, an interval of values is excluded from one of the datasets altogether: the QQ plot needs to show a break for those values. set.seed(17) n.x <- 1.21 * 10^6 n.y <- 1.20 * 10^6 k <- floor(0.0001*n.x) x <- c(rnorm(n.x-k), rnorm(k, mean=2, sd=2)) x <- x[x <= -3 | x >= -2.5] y <- rbeta(n.y, 10,13) We can subsample 0.1% of each dataset and include another 0.1% of their extremes, giving 2420 points to plot. Total elapsed time is less than 0.5 seconds: m <- .001 * max(n.x, n.y) e <- floor(0.0005 * max(n.x, n.y)) system.time( plot(quant.subsample(x, m, e), quant.subsample(y, m, e), pch=".", cex=4, xlab="x", ylab="y", main="QQ Plot") ) No information is lost whatsoever:
Removing extraneous points near the centre of a QQ-plot
Q-Q plots are incredibly autocorrelated except in the tails. In reviewing them, one focuses on the overall shape of the plot and on tail behavior. Ergo, you will do fine by coarsely subsampling in t
Removing extraneous points near the centre of a QQ-plot Q-Q plots are incredibly autocorrelated except in the tails. In reviewing them, one focuses on the overall shape of the plot and on tail behavior. Ergo, you will do fine by coarsely subsampling in the centers of the distributions and including a sufficient amount of the tails. Here is code illustrating how to sample across an entire dataset as well as how to take extreme values. quant.subsample <- function(y, m=100, e=1) { # m: size of a systematic sample # e: number of extreme values at either end to use x <- sort(y) n <- length(x) quants <- (1 + sin(1:m / (m+1) * pi - pi/2))/2 sort(c(x[1:e], quantile(x, probs=quants), x[(n+1-e):n])) # Returns m + 2*e sorted values from the EDF of y } To illustrate, this simulated dataset shows a structural difference between two datasets of approximately 1.2 million values as well as a very small amount of "contamination" in one of them. Also, to make this test stringent, an interval of values is excluded from one of the datasets altogether: the QQ plot needs to show a break for those values. set.seed(17) n.x <- 1.21 * 10^6 n.y <- 1.20 * 10^6 k <- floor(0.0001*n.x) x <- c(rnorm(n.x-k), rnorm(k, mean=2, sd=2)) x <- x[x <= -3 | x >= -2.5] y <- rbeta(n.y, 10,13) We can subsample 0.1% of each dataset and include another 0.1% of their extremes, giving 2420 points to plot. Total elapsed time is less than 0.5 seconds: m <- .001 * max(n.x, n.y) e <- floor(0.0005 * max(n.x, n.y)) system.time( plot(quant.subsample(x, m, e), quant.subsample(y, m, e), pch=".", cex=4, xlab="x", ylab="y", main="QQ Plot") ) No information is lost whatsoever:
Removing extraneous points near the centre of a QQ-plot Q-Q plots are incredibly autocorrelated except in the tails. In reviewing them, one focuses on the overall shape of the plot and on tail behavior. Ergo, you will do fine by coarsely subsampling in t
18,161
Removing extraneous points near the centre of a QQ-plot
Elsewhere in this thread I proposed a simple but somewhat ad hoc solution of subsampling the points. It is fast, but requires some experimentation to produce great plots. The solution about to be described is an order of magnitude slower (taking up to 10 seconds for 1.2 million points) but is adaptive and automatic. For large datasets, it ought to give good results the first time and do so reasonably quickly. The idea is that of the Douglas-Peucker polyline simplification algorithm, adapted to the characteristics of a QQ plot. The relevant statistic for such a plot is the Kolmogorov-Smirnov statistic $D_n$, the maximum vertical deviation from a fitted line. Accordingly, the algorithm is this: Find the maximum vertical deviation between the line joining the extrema of the $(x,y)$ pairs and their QQ plot. If this is within an acceptable fraction $t$ of the full range of $y$, replace the plot with this line. Otherwise, partition the data into those preceding the point of maximum vertical deviation and those after it and recursively apply the algorithm to the two pieces. There are some details to take care of, especially to cope with datasets of different length. I do this by replacing the shorter one by the quantiles corresponding to the longer one: in effect, a piecewise linear approximation of the EDF of the shorter one is used instead of its actual data values. ("Shorter" and "longer" can be reversed by setting use.shortest=TRUE.) Here is an R implementation. qq <- function(x0, y0, t.y=0.0005, use.shortest=FALSE) { qq.int <- function(x,y, i.min,i.max) { # x, y are sorted and of equal length n <-length(y) if (n==1) return(c(x=x, y=y, i=i.max)) if (n==2) return(cbind(x=x, y=y, i=c(i.min,i.max))) beta <- ifelse( x[1]==x[n], 0, (y[n] - y[1]) / (x[n] - x[1])) alpha <- y[1] - beta*x[1] fit <- alpha + x * beta i <- median(c(2, n-1, which.max(abs(y-fit)))) if (abs(y[i]-fit[i]) > thresh) { assemble(qq.int(x[1:i], y[1:i], i.min, i.min+i-1), qq.int(x[i:n], y[i:n], i.min+i-1, i.max)) } else { cbind(x=c(x[1],x[n]), y=c(y[1], y[n]), i=c(i.min, i.max)) } } assemble <- function(xy1, xy2) { rbind(xy1, xy2[-1,]) } # # Pre-process the input so that sorting is done once # and the most detail is extracted from the data. # is.reversed <- length(y0) < length(x0) if (use.shortest) is.reversed <- !is.reversed if (is.reversed) { y <- sort(x0) n <- length(y) x <- quantile(y0, prob=(1:n-1)/(n-1)) } else { y <- sort(y0) n <- length(y) x <- quantile(x0, prob=(1:n-1)/(n-1)) } # # Convert the relative threshold t.y into an absolute. # thresh <- t.y * diff(range(y)) # # Recursively obtain points on the QQ plot. # xy <- qq.int(x, y, 1, n) if (is.reversed) cbind(x=xy[,2], y=xy[,1], i=xy[,3]) else xy } As an example I use data simulated as in my earlier answer (with an extreme high outlier thrown into y and quite a bit more contamination in x this time): set.seed(17) n.x <- 1.21 * 10^6 n.y <- 1.20 * 10^6 k <- floor(0.01*n.x) x <- c(rnorm(n.x-k), rnorm(k, mean=2, sd=2)) x <- x[x <= -3 | x >= -2.5] y <- c(rbeta(n.y, 10,13), 1) Let's plot several versions, using smaller and smaller values of the threshold. At a value of .0005 and displaying on a monitor 1000 pixels tall, we would be guaranteeing an error of no greater than one-half a vertical pixel everywhere on the plot. This is shown in gray (only 522 points, joined by line segments); the coarser approximations are plotted on top of it: first in black, then in red (the red points will be a subset of the black ones and overplot them), then in blue (which again are a subset and overplot). The timings range from 6.5 (blue) to 10 seconds (gray). Given that they scale so well, one might just as well use about one-half pixel as a universal default for the threshold (e.g., 1/2000 for a 1000-pixel high monitor) and be done with it. qq.1 <- qq(x,y) plot(qq.1, type="l", lwd=1, col="Gray", xlab="x", ylab="y", main="Adaptive QQ Plot") points(qq.1, pch=".", cex=6, col="Gray") points(qq(x,y, .01), pch=23, col="Black") points(qq(x,y, .03), pch=22, col="Red") points(qq(x,y, .1), pch=19, col="Blue") Edit I have modified the original code for qq to return a third column of indexes into the longest (or shortest, as specified) of the original two arrays, x and y, corresponding to the points that are selected. These indexes point to "interesting" values of the data and so could be useful for further analysis. I also removed a bug occurring with repeated values of x (which caused beta to be undefined).
Removing extraneous points near the centre of a QQ-plot
Elsewhere in this thread I proposed a simple but somewhat ad hoc solution of subsampling the points. It is fast, but requires some experimentation to produce great plots. The solution about to be de
Removing extraneous points near the centre of a QQ-plot Elsewhere in this thread I proposed a simple but somewhat ad hoc solution of subsampling the points. It is fast, but requires some experimentation to produce great plots. The solution about to be described is an order of magnitude slower (taking up to 10 seconds for 1.2 million points) but is adaptive and automatic. For large datasets, it ought to give good results the first time and do so reasonably quickly. The idea is that of the Douglas-Peucker polyline simplification algorithm, adapted to the characteristics of a QQ plot. The relevant statistic for such a plot is the Kolmogorov-Smirnov statistic $D_n$, the maximum vertical deviation from a fitted line. Accordingly, the algorithm is this: Find the maximum vertical deviation between the line joining the extrema of the $(x,y)$ pairs and their QQ plot. If this is within an acceptable fraction $t$ of the full range of $y$, replace the plot with this line. Otherwise, partition the data into those preceding the point of maximum vertical deviation and those after it and recursively apply the algorithm to the two pieces. There are some details to take care of, especially to cope with datasets of different length. I do this by replacing the shorter one by the quantiles corresponding to the longer one: in effect, a piecewise linear approximation of the EDF of the shorter one is used instead of its actual data values. ("Shorter" and "longer" can be reversed by setting use.shortest=TRUE.) Here is an R implementation. qq <- function(x0, y0, t.y=0.0005, use.shortest=FALSE) { qq.int <- function(x,y, i.min,i.max) { # x, y are sorted and of equal length n <-length(y) if (n==1) return(c(x=x, y=y, i=i.max)) if (n==2) return(cbind(x=x, y=y, i=c(i.min,i.max))) beta <- ifelse( x[1]==x[n], 0, (y[n] - y[1]) / (x[n] - x[1])) alpha <- y[1] - beta*x[1] fit <- alpha + x * beta i <- median(c(2, n-1, which.max(abs(y-fit)))) if (abs(y[i]-fit[i]) > thresh) { assemble(qq.int(x[1:i], y[1:i], i.min, i.min+i-1), qq.int(x[i:n], y[i:n], i.min+i-1, i.max)) } else { cbind(x=c(x[1],x[n]), y=c(y[1], y[n]), i=c(i.min, i.max)) } } assemble <- function(xy1, xy2) { rbind(xy1, xy2[-1,]) } # # Pre-process the input so that sorting is done once # and the most detail is extracted from the data. # is.reversed <- length(y0) < length(x0) if (use.shortest) is.reversed <- !is.reversed if (is.reversed) { y <- sort(x0) n <- length(y) x <- quantile(y0, prob=(1:n-1)/(n-1)) } else { y <- sort(y0) n <- length(y) x <- quantile(x0, prob=(1:n-1)/(n-1)) } # # Convert the relative threshold t.y into an absolute. # thresh <- t.y * diff(range(y)) # # Recursively obtain points on the QQ plot. # xy <- qq.int(x, y, 1, n) if (is.reversed) cbind(x=xy[,2], y=xy[,1], i=xy[,3]) else xy } As an example I use data simulated as in my earlier answer (with an extreme high outlier thrown into y and quite a bit more contamination in x this time): set.seed(17) n.x <- 1.21 * 10^6 n.y <- 1.20 * 10^6 k <- floor(0.01*n.x) x <- c(rnorm(n.x-k), rnorm(k, mean=2, sd=2)) x <- x[x <= -3 | x >= -2.5] y <- c(rbeta(n.y, 10,13), 1) Let's plot several versions, using smaller and smaller values of the threshold. At a value of .0005 and displaying on a monitor 1000 pixels tall, we would be guaranteeing an error of no greater than one-half a vertical pixel everywhere on the plot. This is shown in gray (only 522 points, joined by line segments); the coarser approximations are plotted on top of it: first in black, then in red (the red points will be a subset of the black ones and overplot them), then in blue (which again are a subset and overplot). The timings range from 6.5 (blue) to 10 seconds (gray). Given that they scale so well, one might just as well use about one-half pixel as a universal default for the threshold (e.g., 1/2000 for a 1000-pixel high monitor) and be done with it. qq.1 <- qq(x,y) plot(qq.1, type="l", lwd=1, col="Gray", xlab="x", ylab="y", main="Adaptive QQ Plot") points(qq.1, pch=".", cex=6, col="Gray") points(qq(x,y, .01), pch=23, col="Black") points(qq(x,y, .03), pch=22, col="Red") points(qq(x,y, .1), pch=19, col="Blue") Edit I have modified the original code for qq to return a third column of indexes into the longest (or shortest, as specified) of the original two arrays, x and y, corresponding to the points that are selected. These indexes point to "interesting" values of the data and so could be useful for further analysis. I also removed a bug occurring with repeated values of x (which caused beta to be undefined).
Removing extraneous points near the centre of a QQ-plot Elsewhere in this thread I proposed a simple but somewhat ad hoc solution of subsampling the points. It is fast, but requires some experimentation to produce great plots. The solution about to be de
18,162
Removing extraneous points near the centre of a QQ-plot
Removing some of the data points in the middle would change the empirical distribution and therefore the qqplot. This being said, you can do the following and directly plot the quantiles of the empirical distribution vs. the quantiles of the theoretical distribution: x <- rnorm(1200000) mean.x <- mean(x) sd.x <- sd(x) quantiles.x <- quantile(x, probs = seq(0,1,b=0.000001)) quantiles.empirical <- qnorm(seq(0,1,by=0.000001),mean.x,sd.x) plot(quantiles.x~quantiles.empirical) You will have to adjust the seq depending on how deep you want to get into the tails. If you want to get clever you can also thin that sequence in the middle to speed up the plot. For example using plogis(seq(-17,17,by=.1)) is a possibility.
Removing extraneous points near the centre of a QQ-plot
Removing some of the data points in the middle would change the empirical distribution and therefore the qqplot. This being said, you can do the following and directly plot the quantiles of the empiri
Removing extraneous points near the centre of a QQ-plot Removing some of the data points in the middle would change the empirical distribution and therefore the qqplot. This being said, you can do the following and directly plot the quantiles of the empirical distribution vs. the quantiles of the theoretical distribution: x <- rnorm(1200000) mean.x <- mean(x) sd.x <- sd(x) quantiles.x <- quantile(x, probs = seq(0,1,b=0.000001)) quantiles.empirical <- qnorm(seq(0,1,by=0.000001),mean.x,sd.x) plot(quantiles.x~quantiles.empirical) You will have to adjust the seq depending on how deep you want to get into the tails. If you want to get clever you can also thin that sequence in the middle to speed up the plot. For example using plogis(seq(-17,17,by=.1)) is a possibility.
Removing extraneous points near the centre of a QQ-plot Removing some of the data points in the middle would change the empirical distribution and therefore the qqplot. This being said, you can do the following and directly plot the quantiles of the empiri
18,163
Removing extraneous points near the centre of a QQ-plot
You could do a hexbin plot. x <- rnorm(1200000) mean.x <- mean(x) sd.x <- sd(x) quantiles.x <- quantile(x, probs = seq(0,1,b=0.000001)) quantiles.empirical <- qnorm(seq(0,1,by=0.000001),mean.x,sd.x) library(hexbin) bin <- hexbin(quantiles.empirical[-c(1,length(quantiles.empirical))],quantiles.x[-c(1,length(quantiles.x))],xbins=100) plot(bin)
Removing extraneous points near the centre of a QQ-plot
You could do a hexbin plot. x <- rnorm(1200000) mean.x <- mean(x) sd.x <- sd(x) quantiles.x <- quantile(x, probs = seq(0,1,b=0.000001)) quantiles.empirical <- qnorm(seq(0,1,by=0.000001),mean.x,sd.x)
Removing extraneous points near the centre of a QQ-plot You could do a hexbin plot. x <- rnorm(1200000) mean.x <- mean(x) sd.x <- sd(x) quantiles.x <- quantile(x, probs = seq(0,1,b=0.000001)) quantiles.empirical <- qnorm(seq(0,1,by=0.000001),mean.x,sd.x) library(hexbin) bin <- hexbin(quantiles.empirical[-c(1,length(quantiles.empirical))],quantiles.x[-c(1,length(quantiles.x))],xbins=100) plot(bin)
Removing extraneous points near the centre of a QQ-plot You could do a hexbin plot. x <- rnorm(1200000) mean.x <- mean(x) sd.x <- sd(x) quantiles.x <- quantile(x, probs = seq(0,1,b=0.000001)) quantiles.empirical <- qnorm(seq(0,1,by=0.000001),mean.x,sd.x)
18,164
Removing extraneous points near the centre of a QQ-plot
Another alternative is a parallel boxplot; you said you had two data sets, so something like: y <- rnorm(1200000) x <- rnorm(1200000) grpx <- cut(y,20) boxplot(y~grpx) and you could adjust the various options to make it better with your data.
Removing extraneous points near the centre of a QQ-plot
Another alternative is a parallel boxplot; you said you had two data sets, so something like: y <- rnorm(1200000) x <- rnorm(1200000) grpx <- cut(y,20) boxplot(y~grpx) and you could adjust the variou
Removing extraneous points near the centre of a QQ-plot Another alternative is a parallel boxplot; you said you had two data sets, so something like: y <- rnorm(1200000) x <- rnorm(1200000) grpx <- cut(y,20) boxplot(y~grpx) and you could adjust the various options to make it better with your data.
Removing extraneous points near the centre of a QQ-plot Another alternative is a parallel boxplot; you said you had two data sets, so something like: y <- rnorm(1200000) x <- rnorm(1200000) grpx <- cut(y,20) boxplot(y~grpx) and you could adjust the variou
18,165
Finding category with maximum likelihood method
This is a classic unsupervised learning problem that has a simple maximum likelihood solution. The solution is a motivating example for the expectation maximization algorithm. The process is: Initialize group assignment Estimate the group-wise means and likelihoods. Calculate the likelihood of membership for each observation to either group Assign group labels based on MLE Repeat steps 2-4 until convergence, i.e. no reassigned group. WLOG I can assume I know there are 80 out of all 200 who are women. Another thing to note, if we don't build in the assumption that women are shorter than men, a clustering algo isn't too discerning about which group is labeled as which, and it's interesting to note the cluster label assignment can be reversed. set.seed(1) Women=rnorm(80, mean=168, sd=6) Men=rnorm(120, mean=182, sd=7) AllHeight <- c(Women, Men) trueMF <- rep(c('F', 'M'), c(80, 120)) ## case1 assume women are shorter, so assign first ## 80 lowest height MF <- ifelse(order(AllHeight) <= 80, 'F', 'M') ## case 2 try randomly allocating # MF <- sample(trueMF, replace = F) steps <- 0 repeat { steps <- steps + 1 mu <- tapply(AllHeight, MF, mean) sd <- tapply(AllHeight, MF, sd) logLik <- mapply(dnorm, x=list(AllHeight), mean=mu, sd=sd, log=T) MFnew <- c('F', 'M')[apply(logLik, 1, which.max)] if (all(MF==MFnew)) break else MF <- MFnew } ## case 1: # 85% correct # 2 steps # Means # F M # 168.7847 183.5424 ## case 2: ## 15% correct ## 7 steps # F M # 183.5424 168.7847 ## what else?
Finding category with maximum likelihood method
This is a classic unsupervised learning problem that has a simple maximum likelihood solution. The solution is a motivating example for the expectation maximization algorithm. The process is: Initial
Finding category with maximum likelihood method This is a classic unsupervised learning problem that has a simple maximum likelihood solution. The solution is a motivating example for the expectation maximization algorithm. The process is: Initialize group assignment Estimate the group-wise means and likelihoods. Calculate the likelihood of membership for each observation to either group Assign group labels based on MLE Repeat steps 2-4 until convergence, i.e. no reassigned group. WLOG I can assume I know there are 80 out of all 200 who are women. Another thing to note, if we don't build in the assumption that women are shorter than men, a clustering algo isn't too discerning about which group is labeled as which, and it's interesting to note the cluster label assignment can be reversed. set.seed(1) Women=rnorm(80, mean=168, sd=6) Men=rnorm(120, mean=182, sd=7) AllHeight <- c(Women, Men) trueMF <- rep(c('F', 'M'), c(80, 120)) ## case1 assume women are shorter, so assign first ## 80 lowest height MF <- ifelse(order(AllHeight) <= 80, 'F', 'M') ## case 2 try randomly allocating # MF <- sample(trueMF, replace = F) steps <- 0 repeat { steps <- steps + 1 mu <- tapply(AllHeight, MF, mean) sd <- tapply(AllHeight, MF, sd) logLik <- mapply(dnorm, x=list(AllHeight), mean=mu, sd=sd, log=T) MFnew <- c('F', 'M')[apply(logLik, 1, which.max)] if (all(MF==MFnew)) break else MF <- MFnew } ## case 1: # 85% correct # 2 steps # Means # F M # 168.7847 183.5424 ## case 2: ## 15% correct ## 7 steps # F M # 183.5424 168.7847 ## what else?
Finding category with maximum likelihood method This is a classic unsupervised learning problem that has a simple maximum likelihood solution. The solution is a motivating example for the expectation maximization algorithm. The process is: Initial
18,166
Finding category with maximum likelihood method
What you are describing is a mixture of two Gaussians. $$ f(x) = \pi \, \mathcal{N}(\mu_1, \sigma_1^2) + (1 - \pi) \, \mathcal{N}(\mu_2, \sigma_2^2) $$ where $\pi \in (0, 1)$ is a mixing proportion. Notice that to find the means and standard deviations of both groups, you would need to know the group assignments. If you were to find group assignments, the best way would be by assigning the observations closest to the mean of each group to the cluster. This is a chicken and egg problem. The problem can be solved by using Expectation-Maximization algorithm that starts with assigning the groups randomly, given them calculates the parameters, then re-classifies the observations, and repeats till convergence. There are also other algorithms, but this is the most popular one. You may know it from $k$-means clustering, which is a special case of a Gaussian mixture.
Finding category with maximum likelihood method
What you are describing is a mixture of two Gaussians. $$ f(x) = \pi \, \mathcal{N}(\mu_1, \sigma_1^2) + (1 - \pi) \, \mathcal{N}(\mu_2, \sigma_2^2) $$ where $\pi \in (0, 1)$ is a mixing proportion. N
Finding category with maximum likelihood method What you are describing is a mixture of two Gaussians. $$ f(x) = \pi \, \mathcal{N}(\mu_1, \sigma_1^2) + (1 - \pi) \, \mathcal{N}(\mu_2, \sigma_2^2) $$ where $\pi \in (0, 1)$ is a mixing proportion. Notice that to find the means and standard deviations of both groups, you would need to know the group assignments. If you were to find group assignments, the best way would be by assigning the observations closest to the mean of each group to the cluster. This is a chicken and egg problem. The problem can be solved by using Expectation-Maximization algorithm that starts with assigning the groups randomly, given them calculates the parameters, then re-classifies the observations, and repeats till convergence. There are also other algorithms, but this is the most popular one. You may know it from $k$-means clustering, which is a special case of a Gaussian mixture.
Finding category with maximum likelihood method What you are describing is a mixture of two Gaussians. $$ f(x) = \pi \, \mathcal{N}(\mu_1, \sigma_1^2) + (1 - \pi) \, \mathcal{N}(\mu_2, \sigma_2^2) $$ where $\pi \in (0, 1)$ is a mixing proportion. N
18,167
Why is non-iid noise so important to traditional time-series approaches?
This is a very good question. I believe it is very closely related to the question why ARIMA is still one time series analysis and forecasting methods that everyone learns - even though its performance in forecasting is mediocre at best. My nagging suspicion is that this is not because these methods do a better job at describing reality, and yielding better forecasts. (The proof of the pudding is in the eating, and the proof of the modeling is in the predicting. That, at least, is my opinion.) Rather, it's because time series analysis has historically been the domain of theoretical statisticians and mathematicians. And you can prove theorems about ARIMA and related models. Unit roots! Complex numbers! Characteristic polynomials! And their zeros! Much nicer than methods like exponential smoothing, where the forecasting methods predated a rigorous stochastic model (via state space models) by decades. Rob Hyndman's "Brief history of forecasting competitions" (2020, IJF) is very enlightening to read in this context. It shows how the earlier forecasting competitions were received by statisticians, who had major difficulties in accepting that simple empirical methods could beat their cherished ARIMA models.
Why is non-iid noise so important to traditional time-series approaches?
This is a very good question. I believe it is very closely related to the question why ARIMA is still one time series analysis and forecasting methods that everyone learns - even though its performanc
Why is non-iid noise so important to traditional time-series approaches? This is a very good question. I believe it is very closely related to the question why ARIMA is still one time series analysis and forecasting methods that everyone learns - even though its performance in forecasting is mediocre at best. My nagging suspicion is that this is not because these methods do a better job at describing reality, and yielding better forecasts. (The proof of the pudding is in the eating, and the proof of the modeling is in the predicting. That, at least, is my opinion.) Rather, it's because time series analysis has historically been the domain of theoretical statisticians and mathematicians. And you can prove theorems about ARIMA and related models. Unit roots! Complex numbers! Characteristic polynomials! And their zeros! Much nicer than methods like exponential smoothing, where the forecasting methods predated a rigorous stochastic model (via state space models) by decades. Rob Hyndman's "Brief history of forecasting competitions" (2020, IJF) is very enlightening to read in this context. It shows how the earlier forecasting competitions were received by statisticians, who had major difficulties in accepting that simple empirical methods could beat their cherished ARIMA models.
Why is non-iid noise so important to traditional time-series approaches? This is a very good question. I believe it is very closely related to the question why ARIMA is still one time series analysis and forecasting methods that everyone learns - even though its performanc
18,168
Why is non-iid noise so important to traditional time-series approaches?
Even in ARIMA models, the noise is still IID; it's just that the model part has an auto-correlation component, a moving-average component, and a differencing component. Now, if you were to take data generated by one of these models and then model it with some simpler model (e.g., lacking the auto-correlation component) then the "noise" from the simpler approximation is going to be non-IID due to the fact that it does not take account of a part of the original model.
Why is non-iid noise so important to traditional time-series approaches?
Even in ARIMA models, the noise is still IID; it's just that the model part has an auto-correlation component, a moving-average component, and a differencing component. Now, if you were to take data
Why is non-iid noise so important to traditional time-series approaches? Even in ARIMA models, the noise is still IID; it's just that the model part has an auto-correlation component, a moving-average component, and a differencing component. Now, if you were to take data generated by one of these models and then model it with some simpler model (e.g., lacking the auto-correlation component) then the "noise" from the simpler approximation is going to be non-IID due to the fact that it does not take account of a part of the original model.
Why is non-iid noise so important to traditional time-series approaches? Even in ARIMA models, the noise is still IID; it's just that the model part has an auto-correlation component, a moving-average component, and a differencing component. Now, if you were to take data
18,169
Why is non-iid noise so important to traditional time-series approaches?
Many statistical methods rely on taking the normalized sample mean of the data and comparing it to a critical value under the null hypothesis. For example you might have $H_0:\mu=a$, and your test statistic is $T=\frac{\bar{X}-a}{\hat{\sigma}/\sqrt{n}}$ $\big(\bar{X}$ = sample mean, $\hat{\sigma}$ = square root of the sample variance $\big)$, which you then compare to some critical value to reject/fail to reject the null hypothesis. When there is dependence in the data $\hat{\sigma}$ is no longer the correct quantity to use to normalize your test statistic. Instead you would want to use the square root of the long-run variance. Failing to account for this would lead your hypothesis test to have incorrect Type I errors, and more/less power depending on how the long-run variance compares to the variance. With real data, it is likely not the end of the world if you do not take the dependence into account (and use the square root of the sample variance instead of the square root of the long-run variance). With that said, because the type of hypothesis test I have described is so central to statistics, when possible it is a good idea to incorporate dependence into the errors of time series data.
Why is non-iid noise so important to traditional time-series approaches?
Many statistical methods rely on taking the normalized sample mean of the data and comparing it to a critical value under the null hypothesis. For example you might have $H_0:\mu=a$, and your test sta
Why is non-iid noise so important to traditional time-series approaches? Many statistical methods rely on taking the normalized sample mean of the data and comparing it to a critical value under the null hypothesis. For example you might have $H_0:\mu=a$, and your test statistic is $T=\frac{\bar{X}-a}{\hat{\sigma}/\sqrt{n}}$ $\big(\bar{X}$ = sample mean, $\hat{\sigma}$ = square root of the sample variance $\big)$, which you then compare to some critical value to reject/fail to reject the null hypothesis. When there is dependence in the data $\hat{\sigma}$ is no longer the correct quantity to use to normalize your test statistic. Instead you would want to use the square root of the long-run variance. Failing to account for this would lead your hypothesis test to have incorrect Type I errors, and more/less power depending on how the long-run variance compares to the variance. With real data, it is likely not the end of the world if you do not take the dependence into account (and use the square root of the sample variance instead of the square root of the long-run variance). With that said, because the type of hypothesis test I have described is so central to statistics, when possible it is a good idea to incorporate dependence into the errors of time series data.
Why is non-iid noise so important to traditional time-series approaches? Many statistical methods rely on taking the normalized sample mean of the data and comparing it to a critical value under the null hypothesis. For example you might have $H_0:\mu=a$, and your test sta
18,170
Why does sphericity diagnosed by Bartlett's Test mean a PCA is inappropriate?
It appears that there are two tests called Bartlett's test. The one you referenced (1937) determines whether your samples are from populations with equal variances. Another appears to test whether the correlation matrix for a set of data is the identity matrix (1951). It makes more sense that you wouldn't run PCA on data with an identity correlation matrix, since you will just get back your original variables as they are already uncorrelated. Compare, e.g., http://en.wikipedia.org/wiki/Bartlett's_test to https://personality-project.org/r/html/cortest.bartlett.html.
Why does sphericity diagnosed by Bartlett's Test mean a PCA is inappropriate?
It appears that there are two tests called Bartlett's test. The one you referenced (1937) determines whether your samples are from populations with equal variances. Another appears to test whether t
Why does sphericity diagnosed by Bartlett's Test mean a PCA is inappropriate? It appears that there are two tests called Bartlett's test. The one you referenced (1937) determines whether your samples are from populations with equal variances. Another appears to test whether the correlation matrix for a set of data is the identity matrix (1951). It makes more sense that you wouldn't run PCA on data with an identity correlation matrix, since you will just get back your original variables as they are already uncorrelated. Compare, e.g., http://en.wikipedia.org/wiki/Bartlett's_test to https://personality-project.org/r/html/cortest.bartlett.html.
Why does sphericity diagnosed by Bartlett's Test mean a PCA is inappropriate? It appears that there are two tests called Bartlett's test. The one you referenced (1937) determines whether your samples are from populations with equal variances. Another appears to test whether t
18,171
Why does sphericity diagnosed by Bartlett's Test mean a PCA is inappropriate?
In response to the question title. Bartlett's test of sphericity$^1$, which is often done prior PCA or factor analysis, tests whether the data comes from multivariate normal distribution with zero covariances. (Note please, that the standard asymptotic version of the test is not at all robust to the departure from multivariate normality. One might use bootstrapping with nongaussian cloud.) To put it equivalently, the null hypothesis is that the population correlation matrix is identity matrix or that the covariance matrix is diagonal one. Imagine now that multivariate cloud is perfectly spherical (i.e. its covariance matrix is proportional to the identity matrix). Then 1) any arbitrary dimensions can serve principal components, so PCA solution is not unique; 2) all the components have the same variances (eigenvalues), so PCA cannot help to reduce the data. Imagine the second case where multivariate cloud is ellipsoid with oblongness strictly along the variables' axes (i.e. its covariance matrix is diagonal: all values are zero except the diagonal). Then the rotation implied by PCA transformation will be zero; principal components are the variables themselves, only reordered and potentionally sign-reverted. This is a trivial result: no PCA was needed to discard some weak dimensions to reduce the data. $^1$ Several (at least three, to my awareness) tests in statistics are named after Bartlett. Here we are speaking of the Bartlett's sphericity test.
Why does sphericity diagnosed by Bartlett's Test mean a PCA is inappropriate?
In response to the question title. Bartlett's test of sphericity$^1$, which is often done prior PCA or factor analysis, tests whether the data comes from multivariate normal distribution with zero cov
Why does sphericity diagnosed by Bartlett's Test mean a PCA is inappropriate? In response to the question title. Bartlett's test of sphericity$^1$, which is often done prior PCA or factor analysis, tests whether the data comes from multivariate normal distribution with zero covariances. (Note please, that the standard asymptotic version of the test is not at all robust to the departure from multivariate normality. One might use bootstrapping with nongaussian cloud.) To put it equivalently, the null hypothesis is that the population correlation matrix is identity matrix or that the covariance matrix is diagonal one. Imagine now that multivariate cloud is perfectly spherical (i.e. its covariance matrix is proportional to the identity matrix). Then 1) any arbitrary dimensions can serve principal components, so PCA solution is not unique; 2) all the components have the same variances (eigenvalues), so PCA cannot help to reduce the data. Imagine the second case where multivariate cloud is ellipsoid with oblongness strictly along the variables' axes (i.e. its covariance matrix is diagonal: all values are zero except the diagonal). Then the rotation implied by PCA transformation will be zero; principal components are the variables themselves, only reordered and potentionally sign-reverted. This is a trivial result: no PCA was needed to discard some weak dimensions to reduce the data. $^1$ Several (at least three, to my awareness) tests in statistics are named after Bartlett. Here we are speaking of the Bartlett's sphericity test.
Why does sphericity diagnosed by Bartlett's Test mean a PCA is inappropriate? In response to the question title. Bartlett's test of sphericity$^1$, which is often done prior PCA or factor analysis, tests whether the data comes from multivariate normal distribution with zero cov
18,172
Why is the distribution of rand()^2 different than of rand()*rand()?
It may be helpful to think of rectangles. Imagine you have the chance to get land for free. The size of the land will be determined by (a) one realization of the random variable or (b) two realizations of the same random variable. In the first case (a), the area will be a square with the side length being equal to the sampled value. In the second case (b), the two sampled values will represent width and length of a rectangle. Which alternative do you choose? Let $\mathbf{U}$ be a realization of a positive random variable. a) The expected value of one realization $\mathbf{U}$ determines the area of the square which is equal to $\mathbf{U}^2$. On average, the size of the area will be $$\mathop{\mathbb{E}}[\mathbf{U}^2]$$ b) If there are two independent realizations $\mathbf{U}_1$ and $\mathbf{U}_2$, the area will be $\mathbf{U}_1 \cdot \mathbf{U}_2$. On average, the size equals $$\mathop{\mathbb{E}}[\mathbf{U}_1 \cdot \mathbf{U}_2] = \mathop{\mathbb{E}^2}[\mathbf{U}]$$ since both realizations are from the same distribution and independent. When we calculate the difference between the size of the areas a) and b), we obtain $$\mathop{\mathbb{E}}[\mathbf{U}^2] - \mathop{\mathbb{E}^2}[\mathbf{U}]$$ The above term is identical to $\mathop{\mathbb{Var}}[\mathbf{U}]$ which is inherently greater or equal to $0$. This holds for the general case. In your example, you sampled from the uniform distribution $\mathcal{U}(0,1)$. Hence, $$\mathop{\mathbb{E}}[\mathbf{U}] = \frac{1}{2}$$ $$\mathop{\mathbb{E}^2}[\mathbf{U}] = \frac{1}{4}$$ $$\mathop{\mathbb{Var}}[\mathbf{U}] = \frac{1}{12}$$ With $\mathop{\mathbb{E}}[\mathbf{U}^2] = \mathop{\mathbb{Var}}[\mathbf{U}] + \mathop{\mathbb{E}^2}[\mathbf{U}]$ we obtain $$\mathop{\mathbb{E}}[\mathbf{U}^2] = \frac{1}{12} + \frac{1}{4} = \frac{1}{3}$$ These values were derived analytically but they match the ones you obtained with the random number generator.
Why is the distribution of rand()^2 different than of rand()*rand()?
It may be helpful to think of rectangles. Imagine you have the chance to get land for free. The size of the land will be determined by (a) one realization of the random variable or (b) two realization
Why is the distribution of rand()^2 different than of rand()*rand()? It may be helpful to think of rectangles. Imagine you have the chance to get land for free. The size of the land will be determined by (a) one realization of the random variable or (b) two realizations of the same random variable. In the first case (a), the area will be a square with the side length being equal to the sampled value. In the second case (b), the two sampled values will represent width and length of a rectangle. Which alternative do you choose? Let $\mathbf{U}$ be a realization of a positive random variable. a) The expected value of one realization $\mathbf{U}$ determines the area of the square which is equal to $\mathbf{U}^2$. On average, the size of the area will be $$\mathop{\mathbb{E}}[\mathbf{U}^2]$$ b) If there are two independent realizations $\mathbf{U}_1$ and $\mathbf{U}_2$, the area will be $\mathbf{U}_1 \cdot \mathbf{U}_2$. On average, the size equals $$\mathop{\mathbb{E}}[\mathbf{U}_1 \cdot \mathbf{U}_2] = \mathop{\mathbb{E}^2}[\mathbf{U}]$$ since both realizations are from the same distribution and independent. When we calculate the difference between the size of the areas a) and b), we obtain $$\mathop{\mathbb{E}}[\mathbf{U}^2] - \mathop{\mathbb{E}^2}[\mathbf{U}]$$ The above term is identical to $\mathop{\mathbb{Var}}[\mathbf{U}]$ which is inherently greater or equal to $0$. This holds for the general case. In your example, you sampled from the uniform distribution $\mathcal{U}(0,1)$. Hence, $$\mathop{\mathbb{E}}[\mathbf{U}] = \frac{1}{2}$$ $$\mathop{\mathbb{E}^2}[\mathbf{U}] = \frac{1}{4}$$ $$\mathop{\mathbb{Var}}[\mathbf{U}] = \frac{1}{12}$$ With $\mathop{\mathbb{E}}[\mathbf{U}^2] = \mathop{\mathbb{Var}}[\mathbf{U}] + \mathop{\mathbb{E}^2}[\mathbf{U}]$ we obtain $$\mathop{\mathbb{E}}[\mathbf{U}^2] = \frac{1}{12} + \frac{1}{4} = \frac{1}{3}$$ These values were derived analytically but they match the ones you obtained with the random number generator.
Why is the distribution of rand()^2 different than of rand()*rand()? It may be helpful to think of rectangles. Imagine you have the chance to get land for free. The size of the land will be determined by (a) one realization of the random variable or (b) two realization
18,173
Why is the distribution of rand()^2 different than of rand()*rand()?
Not to suggest that there's anything lacking from Sven's excellent answer, but I wanted to present a relatively elementary take on the question. Consider plotting the two components of each product in order to see that the joint distribution is very different. Note that the product tends only to be large (near 1) when both components are large, which happens much more easily when the two components are perfectly correlated rather than independent. So for example, the probability that the product exceeds $1-\epsilon$ (for small $\epsilon$) is about $\epsilon/2$ for the $U^2$ ('A') version, but for the $U_1\times U_2$ ('B') version it's about $\epsilon^2/2$. Quite a difference! It may help to draw iso-product contours on graphs like those above - that is, curves where xy=constant for values like 0.5, 0.6, 0.7, 0.8, 0.9. As you go to larger and larger values, the proportion of points above and to the right of the contour goes down much more quickly for the independent case.
Why is the distribution of rand()^2 different than of rand()*rand()?
Not to suggest that there's anything lacking from Sven's excellent answer, but I wanted to present a relatively elementary take on the question. Consider plotting the two components of each product i
Why is the distribution of rand()^2 different than of rand()*rand()? Not to suggest that there's anything lacking from Sven's excellent answer, but I wanted to present a relatively elementary take on the question. Consider plotting the two components of each product in order to see that the joint distribution is very different. Note that the product tends only to be large (near 1) when both components are large, which happens much more easily when the two components are perfectly correlated rather than independent. So for example, the probability that the product exceeds $1-\epsilon$ (for small $\epsilon$) is about $\epsilon/2$ for the $U^2$ ('A') version, but for the $U_1\times U_2$ ('B') version it's about $\epsilon^2/2$. Quite a difference! It may help to draw iso-product contours on graphs like those above - that is, curves where xy=constant for values like 0.5, 0.6, 0.7, 0.8, 0.9. As you go to larger and larger values, the proportion of points above and to the right of the contour goes down much more quickly for the independent case.
Why is the distribution of rand()^2 different than of rand()*rand()? Not to suggest that there's anything lacking from Sven's excellent answer, but I wanted to present a relatively elementary take on the question. Consider plotting the two components of each product i
18,174
What are the assumptions of factor analysis?
Input data assumptions of linear FA (I'm not speaking here about internal assumptions/properties of the FA model or about checking the fitting quality of results). Scale (interval or ratio) input variables. That means the items are either continuous measures or are conceptualized as continuous while measured on discrete quantitative scale. No ordinal data in linear FA (read). Binary data should also be avoided (see this, this). Linear FA assumes that latent common and unique factors are continuous. Therefore observed variables which they load should be continuous too. Correlations are linear. Linear FA may be performed based on any SSCP-type association matrix: Pearson correlation, covariance, cosine, etc (though some methods/implementations might restrict to Pearson correlations only). Note that these are all linear-algebra products. Despite that the magnitude of a covariance coefficient reflects more than just linearity in relation, the modeling in linear FA is linear in nature even when covariances are used: variables are linear combinations of factors and thus linearity is implied in the resulting associations. If you see/think nonlinear associations prevail - don't do linear FA or try to linearize them first by some transformations of the data. And don't base linear FA on Spearman or Kendall correlations (Pt. 4 there). No outliers - that's as with any nonrobust method. Pearson correlation and similar SSCP-type associations are sensitive of outliers, so watch out. Reasonably high correlations are present. FA is the analysis of correlatedness, - what's its use when all or almost all correlations are weak? - no use. However, what is "reasonably high correlation" depend on the field of study. There is also an interesting and varied question whether very high correlations should be accepted (the effect of them on PCA, for example, is discussed here). To test statistically if the data are not uncorrelated Bartlett's test of sphericity can be used. Partial correlations are weak, and factor can be enough defined. FA assumes that factors are more general than just loading pairs of correlated items. In fact, there even an advice not to extract factors loading decently less than 3 items in explotatory FA; and in confirmatory FA only 3+ is guaranteed-identified structure. A technical problem of extraction called Heywood case has, as one of the reasons behind, the too-few-items-on-factor situation. Kaiser-Meyer-Olkin (KMO) "sampling adequacy measure" estimates for you how weak are partial correlations in the data relative the full correlations; it can be computed for every item and for the whole correlation matrix. Common Factor analysis model assumes that pairwise partial correlations are enough small not be bothered about and modelled, and they all fall into that population noise for individual correlation coefficients which we don't regard any differently from the sample noise for them (see). And read also. No multicollinearity. FA model assumes that all items each posesses unique factor and those factors are orthogonal. Therefore 2 items must define a plane, 3 items - a 3d space, etc: p correlated vectors must span p-dim space to accomodate their p mutually perpendicular unique components. So, no singularity for theoretical reasons$^1$ (and hence automatically n observations > p variables, without saying; and better n>>p). Not that complete multicollinearity is allowed though; yet it may cause computational problems in most of FA algorithms (see also). Distribution. In general, linear FA does not require normality of the input data. Moderately skewed distributions are acceptable. Bimodality is not a contra-indication. Normality is indeed assumed for unique factors in the model (they serve as regressional errors) - but not for the common factors and the input data (see also). Still, multivariate normality of the data can be required as additional assumption by some methods of extraction (namely, maximum likelihood) and by performing some asymptotic testing. $^1$ ULS/minres methods of FA can work with singular and even non p.s.d. correlation matrix, but strictly theoretically such an analysis is dubious, for me.
What are the assumptions of factor analysis?
Input data assumptions of linear FA (I'm not speaking here about internal assumptions/properties of the FA model or about checking the fitting quality of results). Scale (interval or ratio) input var
What are the assumptions of factor analysis? Input data assumptions of linear FA (I'm not speaking here about internal assumptions/properties of the FA model or about checking the fitting quality of results). Scale (interval or ratio) input variables. That means the items are either continuous measures or are conceptualized as continuous while measured on discrete quantitative scale. No ordinal data in linear FA (read). Binary data should also be avoided (see this, this). Linear FA assumes that latent common and unique factors are continuous. Therefore observed variables which they load should be continuous too. Correlations are linear. Linear FA may be performed based on any SSCP-type association matrix: Pearson correlation, covariance, cosine, etc (though some methods/implementations might restrict to Pearson correlations only). Note that these are all linear-algebra products. Despite that the magnitude of a covariance coefficient reflects more than just linearity in relation, the modeling in linear FA is linear in nature even when covariances are used: variables are linear combinations of factors and thus linearity is implied in the resulting associations. If you see/think nonlinear associations prevail - don't do linear FA or try to linearize them first by some transformations of the data. And don't base linear FA on Spearman or Kendall correlations (Pt. 4 there). No outliers - that's as with any nonrobust method. Pearson correlation and similar SSCP-type associations are sensitive of outliers, so watch out. Reasonably high correlations are present. FA is the analysis of correlatedness, - what's its use when all or almost all correlations are weak? - no use. However, what is "reasonably high correlation" depend on the field of study. There is also an interesting and varied question whether very high correlations should be accepted (the effect of them on PCA, for example, is discussed here). To test statistically if the data are not uncorrelated Bartlett's test of sphericity can be used. Partial correlations are weak, and factor can be enough defined. FA assumes that factors are more general than just loading pairs of correlated items. In fact, there even an advice not to extract factors loading decently less than 3 items in explotatory FA; and in confirmatory FA only 3+ is guaranteed-identified structure. A technical problem of extraction called Heywood case has, as one of the reasons behind, the too-few-items-on-factor situation. Kaiser-Meyer-Olkin (KMO) "sampling adequacy measure" estimates for you how weak are partial correlations in the data relative the full correlations; it can be computed for every item and for the whole correlation matrix. Common Factor analysis model assumes that pairwise partial correlations are enough small not be bothered about and modelled, and they all fall into that population noise for individual correlation coefficients which we don't regard any differently from the sample noise for them (see). And read also. No multicollinearity. FA model assumes that all items each posesses unique factor and those factors are orthogonal. Therefore 2 items must define a plane, 3 items - a 3d space, etc: p correlated vectors must span p-dim space to accomodate their p mutually perpendicular unique components. So, no singularity for theoretical reasons$^1$ (and hence automatically n observations > p variables, without saying; and better n>>p). Not that complete multicollinearity is allowed though; yet it may cause computational problems in most of FA algorithms (see also). Distribution. In general, linear FA does not require normality of the input data. Moderately skewed distributions are acceptable. Bimodality is not a contra-indication. Normality is indeed assumed for unique factors in the model (they serve as regressional errors) - but not for the common factors and the input data (see also). Still, multivariate normality of the data can be required as additional assumption by some methods of extraction (namely, maximum likelihood) and by performing some asymptotic testing. $^1$ ULS/minres methods of FA can work with singular and even non p.s.d. correlation matrix, but strictly theoretically such an analysis is dubious, for me.
What are the assumptions of factor analysis? Input data assumptions of linear FA (I'm not speaking here about internal assumptions/properties of the FA model or about checking the fitting quality of results). Scale (interval or ratio) input var
18,175
What are the assumptions of factor analysis?
Much of the time, factor analysis is conducted without any statistical tests per se. It is much more subjective and interpretive than methods such as regression, structural equation modelling, and so on. And generally it is inferential tests that come with assumptions: in order for p values and confidence intervals to be correct, those assumptions must be met. Now, if the method for choosing the number of factors is set to be the maximum likelihood method, then there is an assumption that goes with this: that the variables input into the factor analysis will have normal distributions. That the input variables will have nonzero correlations is a sort of assumption in that without it being true, factor analysis results will be (probably) useless: no factor will emerge as the latent variable behind some set of input variables. As far as there being "no correlation between factors (common and specifics), and no correlation between variables from one factor and variables from other factors," these are not universally assumptions that factor analysts make, although at times either condition (or an approximation of it) might be desirable. The latter, when it holds, it known as "simple structure." There is another condition that is sometimes treated as an "assumption": that the zero-order (vanilla) correlations among input variables not be swamped by large partial correlations. What this means in a nutshell is that relationships should be strong for some pairings and weak for others; otherwise, results will be "muddy." This is related to the desirability of simple structure and it actually can be evaluated (though not formally "tested") using the Kaiser-Meyer-Olkin statistic, or the KMO. KMO values near .8 or .9 are usually considered very promising for informative factor analysis results, while KMOs near .5 or .6 are much less promising, and those below .5 might prompt an analyst to rethink his/her strategy.
What are the assumptions of factor analysis?
Much of the time, factor analysis is conducted without any statistical tests per se. It is much more subjective and interpretive than methods such as regression, structural equation modelling, and so
What are the assumptions of factor analysis? Much of the time, factor analysis is conducted without any statistical tests per se. It is much more subjective and interpretive than methods such as regression, structural equation modelling, and so on. And generally it is inferential tests that come with assumptions: in order for p values and confidence intervals to be correct, those assumptions must be met. Now, if the method for choosing the number of factors is set to be the maximum likelihood method, then there is an assumption that goes with this: that the variables input into the factor analysis will have normal distributions. That the input variables will have nonzero correlations is a sort of assumption in that without it being true, factor analysis results will be (probably) useless: no factor will emerge as the latent variable behind some set of input variables. As far as there being "no correlation between factors (common and specifics), and no correlation between variables from one factor and variables from other factors," these are not universally assumptions that factor analysts make, although at times either condition (or an approximation of it) might be desirable. The latter, when it holds, it known as "simple structure." There is another condition that is sometimes treated as an "assumption": that the zero-order (vanilla) correlations among input variables not be swamped by large partial correlations. What this means in a nutshell is that relationships should be strong for some pairings and weak for others; otherwise, results will be "muddy." This is related to the desirability of simple structure and it actually can be evaluated (though not formally "tested") using the Kaiser-Meyer-Olkin statistic, or the KMO. KMO values near .8 or .9 are usually considered very promising for informative factor analysis results, while KMOs near .5 or .6 are much less promising, and those below .5 might prompt an analyst to rethink his/her strategy.
What are the assumptions of factor analysis? Much of the time, factor analysis is conducted without any statistical tests per se. It is much more subjective and interpretive than methods such as regression, structural equation modelling, and so
18,176
What are the assumptions of factor analysis?
Assumptions underlying exploratory factor analysis are: β€’ Interval or ratio level of measurement β€’ Random sampling β€’ Relationship between observed variables is linear β€’ A normal distribution (each observed variable) β€’ A bivariate normal distribution (each pair of observed variables) β€’ Multivariate normality Above from the SAS file
What are the assumptions of factor analysis?
Assumptions underlying exploratory factor analysis are: β€’ Interval or ratio level of measurement β€’ Random sampling β€’ Relationship between observed variables is linear β€’ A normal distribution (each obs
What are the assumptions of factor analysis? Assumptions underlying exploratory factor analysis are: β€’ Interval or ratio level of measurement β€’ Random sampling β€’ Relationship between observed variables is linear β€’ A normal distribution (each observed variable) β€’ A bivariate normal distribution (each pair of observed variables) β€’ Multivariate normality Above from the SAS file
What are the assumptions of factor analysis? Assumptions underlying exploratory factor analysis are: β€’ Interval or ratio level of measurement β€’ Random sampling β€’ Relationship between observed variables is linear β€’ A normal distribution (each obs
18,177
Estimating a survival probability in R
You can use the output of the survfit function from the survival package and give that to stepfun. km <- survfit(Surv(time, status)~1, data=veteran) survest <- stepfun(km$time, c(1, km$surv)) Now survest is a function that can be evaluated at any time. > survest(0:100) [1] 1.0000000 0.9854015 0.9781022 0.9708029 0.9635036 0.9635036 0.9635036 [8] 0.9416058 0.9124088 0.9124088 0.8978102 0.8905109 0.8759124 0.8613139 [15] 0.8613139 0.8467153 0.8394161 0.8394161 0.8175182 0.8029197 0.7883212 [22] 0.7737226 0.7664234 0.7664234 0.7518248 0.7299270 0.7299270 0.7225540 [29] 0.7225540 0.7151810 0.7004350 0.6856890 0.6856890 0.6783160 0.6783160 [36] 0.6709430 0.6635700 0.6635700 0.6635700 0.6635700 0.6635700 0.6635700 [43] 0.6561970 0.6488240 0.6414510 0.6340780 0.6340780 0.6340780 0.6267050 [50] 0.6193320 0.6193320 0.5972130 0.5750940 0.5677210 0.5529750 0.5529750 [57] 0.5456020 0.5456020 0.5456020 0.5382290 0.5382290 0.5308560 0.5308560 [64] 0.5234830 0.5234830 0.5234830 0.5234830 0.5234830 0.5234830 0.5234830 [71] 0.5234830 0.5234830 0.5161100 0.5087370 0.5087370 0.5087370 0.5087370 [78] 0.5087370 0.5087370 0.5087370 0.4939910 0.4939910 0.4866180 0.4866180 [85] 0.4791316 0.4791316 0.4791316 0.4716451 0.4716451 0.4716451 0.4640380 [92] 0.4640380 0.4564308 0.4564308 0.4564308 0.4412164 0.4412164 0.4412164 [99] 0.4412164 0.4257351 0.4179945
Estimating a survival probability in R
You can use the output of the survfit function from the survival package and give that to stepfun. km <- survfit(Surv(time, status)~1, data=veteran) survest <- stepfun(km$time, c(1, km$surv)) Now sur
Estimating a survival probability in R You can use the output of the survfit function from the survival package and give that to stepfun. km <- survfit(Surv(time, status)~1, data=veteran) survest <- stepfun(km$time, c(1, km$surv)) Now survest is a function that can be evaluated at any time. > survest(0:100) [1] 1.0000000 0.9854015 0.9781022 0.9708029 0.9635036 0.9635036 0.9635036 [8] 0.9416058 0.9124088 0.9124088 0.8978102 0.8905109 0.8759124 0.8613139 [15] 0.8613139 0.8467153 0.8394161 0.8394161 0.8175182 0.8029197 0.7883212 [22] 0.7737226 0.7664234 0.7664234 0.7518248 0.7299270 0.7299270 0.7225540 [29] 0.7225540 0.7151810 0.7004350 0.6856890 0.6856890 0.6783160 0.6783160 [36] 0.6709430 0.6635700 0.6635700 0.6635700 0.6635700 0.6635700 0.6635700 [43] 0.6561970 0.6488240 0.6414510 0.6340780 0.6340780 0.6340780 0.6267050 [50] 0.6193320 0.6193320 0.5972130 0.5750940 0.5677210 0.5529750 0.5529750 [57] 0.5456020 0.5456020 0.5456020 0.5382290 0.5382290 0.5308560 0.5308560 [64] 0.5234830 0.5234830 0.5234830 0.5234830 0.5234830 0.5234830 0.5234830 [71] 0.5234830 0.5234830 0.5161100 0.5087370 0.5087370 0.5087370 0.5087370 [78] 0.5087370 0.5087370 0.5087370 0.4939910 0.4939910 0.4866180 0.4866180 [85] 0.4791316 0.4791316 0.4791316 0.4716451 0.4716451 0.4716451 0.4640380 [92] 0.4640380 0.4564308 0.4564308 0.4564308 0.4412164 0.4412164 0.4412164 [99] 0.4412164 0.4257351 0.4179945
Estimating a survival probability in R You can use the output of the survfit function from the survival package and give that to stepfun. km <- survfit(Surv(time, status)~1, data=veteran) survest <- stepfun(km$time, c(1, km$surv)) Now sur
18,178
Estimating a survival probability in R
A time parameter can be passed to the summary function of the survfit object: summary(km, times=100) A vector can also be passed: summary(km, times=0:100)
Estimating a survival probability in R
A time parameter can be passed to the summary function of the survfit object: summary(km, times=100) A vector can also be passed: summary(km, times=0:100)
Estimating a survival probability in R A time parameter can be passed to the summary function of the survfit object: summary(km, times=100) A vector can also be passed: summary(km, times=0:100)
Estimating a survival probability in R A time parameter can be passed to the summary function of the survfit object: summary(km, times=100) A vector can also be passed: summary(km, times=0:100)
18,179
When was the ReLU function first used in a neural network?
Fukushima published the original Cognitron paper in 1975. That was the first instance of ReLU. It is defined in equation 2 here: Fukushima, K. (1975). Cognitron: A self-organizing multilayered neural network. Biological Cybernetics, 20(3), 121-136.
When was the ReLU function first used in a neural network?
Fukushima published the original Cognitron paper in 1975. That was the first instance of ReLU. It is defined in equation 2 here: Fukushima, K. (1975). Cognitron: A self-organizing multilayered neural
When was the ReLU function first used in a neural network? Fukushima published the original Cognitron paper in 1975. That was the first instance of ReLU. It is defined in equation 2 here: Fukushima, K. (1975). Cognitron: A self-organizing multilayered neural network. Biological Cybernetics, 20(3), 121-136.
When was the ReLU function first used in a neural network? Fukushima published the original Cognitron paper in 1975. That was the first instance of ReLU. It is defined in equation 2 here: Fukushima, K. (1975). Cognitron: A self-organizing multilayered neural
18,180
When was the ReLU function first used in a neural network?
The earliest usage of the ReLU activation that I've found is Fukushima (1975, page 124, equation 2). Thanks to johann to pointing this out. Fukushima also wrote at least one other paper involving ReLU activations (1980), but this is the earliest one that I am aware of. Unless I missed something, the function is not given any particular name in this paper. I am not aware of an older reference, but because terminology is inconsistent and rapidly changing, it's eminently possible that I've missed a key detail in an even older publication. It is common to cite Nair & Hinton (2010) as the first usage of $f$. For example, Schmidhuber (2014) cites Nair & Hinton when discussing ReLU units in his review article. Certainly, Nair & Hinton's paper is important because it spurred the recent interest in using $f$ in neural networks, and it is the source of the modern nomenclature "rectified linear units." Nonetheless, the idea of using $f$ as an activation is decades older than the 2010 paper. Incidentally, Hinton also coauthored a chapter in Parallel Distributed Processing in which $f$ was used in a neural network. In this paper, $f$ is called the "threshold function." However, this volume was published in 1986, eleven years after Fukushima's paper. References JΓΌrgen Schmidhuber. "Deep Learning in Neural Networks: An Overview." 2014. Fukushima, K. (1975). "Cognitron: A self-organizing multilayered neural network." Biological Cybernetics, 20(3-4), 121–136. doi:10.1007/bf00342633 Kunihiko Fukushima. "Neocognitron: A Self-organizing Neural Network Model for a Mechanism of Pattern Recognition Unaffected by Shift in Position." Biological Cybernetics. 1980. D.E. Rumelhart, G.E. Hinton, and J.L. McClelland. "A General Framework for Parallel Distributed Processing" in Parallel Distributed Computing, Vol 1. 1986. Vinod Nair, Geoffrey E. Hinton, "Rectified Linear Units Improve Restricted Boltzmann Machines" 2010.
When was the ReLU function first used in a neural network?
The earliest usage of the ReLU activation that I've found is Fukushima (1975, page 124, equation 2). Thanks to johann to pointing this out. Fukushima also wrote at least one other paper involving ReLU
When was the ReLU function first used in a neural network? The earliest usage of the ReLU activation that I've found is Fukushima (1975, page 124, equation 2). Thanks to johann to pointing this out. Fukushima also wrote at least one other paper involving ReLU activations (1980), but this is the earliest one that I am aware of. Unless I missed something, the function is not given any particular name in this paper. I am not aware of an older reference, but because terminology is inconsistent and rapidly changing, it's eminently possible that I've missed a key detail in an even older publication. It is common to cite Nair & Hinton (2010) as the first usage of $f$. For example, Schmidhuber (2014) cites Nair & Hinton when discussing ReLU units in his review article. Certainly, Nair & Hinton's paper is important because it spurred the recent interest in using $f$ in neural networks, and it is the source of the modern nomenclature "rectified linear units." Nonetheless, the idea of using $f$ as an activation is decades older than the 2010 paper. Incidentally, Hinton also coauthored a chapter in Parallel Distributed Processing in which $f$ was used in a neural network. In this paper, $f$ is called the "threshold function." However, this volume was published in 1986, eleven years after Fukushima's paper. References JΓΌrgen Schmidhuber. "Deep Learning in Neural Networks: An Overview." 2014. Fukushima, K. (1975). "Cognitron: A self-organizing multilayered neural network." Biological Cybernetics, 20(3-4), 121–136. doi:10.1007/bf00342633 Kunihiko Fukushima. "Neocognitron: A Self-organizing Neural Network Model for a Mechanism of Pattern Recognition Unaffected by Shift in Position." Biological Cybernetics. 1980. D.E. Rumelhart, G.E. Hinton, and J.L. McClelland. "A General Framework for Parallel Distributed Processing" in Parallel Distributed Computing, Vol 1. 1986. Vinod Nair, Geoffrey E. Hinton, "Rectified Linear Units Improve Restricted Boltzmann Machines" 2010.
When was the ReLU function first used in a neural network? The earliest usage of the ReLU activation that I've found is Fukushima (1975, page 124, equation 2). Thanks to johann to pointing this out. Fukushima also wrote at least one other paper involving ReLU
18,181
When was the ReLU function first used in a neural network?
Fukushima already used it in a paper 6 years before the cognitron, in a so-called analog threshold element (see Equation 2 and Figure 3): K. Fukushima, "Visual Feature Extraction by a Multilayered Network of Analog Threshold Elements," in IEEE Transactions on Systems Science and Cybernetics, vol. 5, no. 4, pp. 322-333, Oct. 1969, doi: 10.1109/TSSC.1969.300225.
When was the ReLU function first used in a neural network?
Fukushima already used it in a paper 6 years before the cognitron, in a so-called analog threshold element (see Equation 2 and Figure 3): K. Fukushima, "Visual Feature Extraction by a Multilayered Ne
When was the ReLU function first used in a neural network? Fukushima already used it in a paper 6 years before the cognitron, in a so-called analog threshold element (see Equation 2 and Figure 3): K. Fukushima, "Visual Feature Extraction by a Multilayered Network of Analog Threshold Elements," in IEEE Transactions on Systems Science and Cybernetics, vol. 5, no. 4, pp. 322-333, Oct. 1969, doi: 10.1109/TSSC.1969.300225.
When was the ReLU function first used in a neural network? Fukushima already used it in a paper 6 years before the cognitron, in a so-called analog threshold element (see Equation 2 and Figure 3): K. Fukushima, "Visual Feature Extraction by a Multilayered Ne
18,182
Do we really need to include "all relevant predictors?"
You are right - we are seldom realistic in saying "all relevant predictors". In practice we can be satisfied with including predictors that explain the major sources of variation in $Y$. In the special case of drawing inference about a risk factor or treatment in an observational study, this is seldom good enough. For that, adjustment for confounding needs to be highly agressive, including variables that might be related to outcome and might be related to treatment choice or to the risk factor you are trying to publicize. It is interested that with the normal linear model, omitted covariates, especially if orthogonal to included covariates, can be thought of as just enlarging the error term. In nonlinear models (logistic, Cox, many others) omission of variables can bias the effects of all the variables included in the model (due to non-collapsibility of the odds ratio, for example).
Do we really need to include "all relevant predictors?"
You are right - we are seldom realistic in saying "all relevant predictors". In practice we can be satisfied with including predictors that explain the major sources of variation in $Y$. In the spec
Do we really need to include "all relevant predictors?" You are right - we are seldom realistic in saying "all relevant predictors". In practice we can be satisfied with including predictors that explain the major sources of variation in $Y$. In the special case of drawing inference about a risk factor or treatment in an observational study, this is seldom good enough. For that, adjustment for confounding needs to be highly agressive, including variables that might be related to outcome and might be related to treatment choice or to the risk factor you are trying to publicize. It is interested that with the normal linear model, omitted covariates, especially if orthogonal to included covariates, can be thought of as just enlarging the error term. In nonlinear models (logistic, Cox, many others) omission of variables can bias the effects of all the variables included in the model (due to non-collapsibility of the odds ratio, for example).
Do we really need to include "all relevant predictors?" You are right - we are seldom realistic in saying "all relevant predictors". In practice we can be satisfied with including predictors that explain the major sources of variation in $Y$. In the spec
18,183
Do we really need to include "all relevant predictors?"
Yes, you must include all "relevant variables", but you must be smart about it. You must think of the ways to construct the experiments that would isolate the impact of your phenomenon from unrelated stuff, which is a plenty in real world (as opposed to a class room) research. Before you get into statistics, you have to do the heavy lifting in your domain, not in statistics. I encourage you not be cynical about including all relevant variables, because it's not only a noble goal but also because it's often possible. We don't say this just for the sake of saying it. We really do mean it. In fact, designing experiments and studies that are able to include all relevant variables is what makes science really interesting, and different from mechanical boiler plate "experiments". To motivate my statement, I'll give you an example of how Galileo studied acceleration. Here's his description of an actual experiment (from this web page): A piece of wooden moulding or scantling, about 12 cubits long, half a cubit wide, and three finger-breadths thick, was taken; on its edge was cut a channel a little more than one finger in breadth; having made this groove very straight, smooth, and polished, and having lined it with parchment, also as smooth and polished as possible, we rolled along it a hard, smooth, and very round bronze ball. Having placed this board in a sloping position, by raising one end some one or two cubits above the other, we rolled the ball, as I was just saying, along the channel, noting, in a manner presently to be described, the time required to make the descent. We repeated this experiment more than once in order to measure the time with an accuracy such that the deviation between two observations never exceeded one-tenth of a pulse-beat. Having performed this operation and having assured ourselves of its reliability, we now rolled the ball only one-quarter the length of the channel; and having measured the time of its descent, we found it precisely one-half of the former. Next we tried other distances, compared the time for the whole length with that for the half, or with that for two-thirds, or three-fourths, or indeed for any fraction; in such experiments, repeated a full hundred times, we always found that the spaces traversed were to each other as the squares of the times, and this was true for all inclinations of the plane, i.e., of the channel, along which we rolled the ball. We also observed that the times of descent, for various inclinations of the plane, bore to one another precisely that ratio which, as we shall see later, the Author had predicted and demonstrated for them. For the measurement of time, we employed a large vessel of water placed in an elevated position; to the bottom of this vessel was soldered a pipe of small diameter giving a thin jet of water which we collected in a small glass during the time of each descent, whether for the whole length of the channel or for part of its length; the water thus collected was weighed, after each descent, on a very accurate balance; the differences and ratios of these weights gave us the differences and ratios of the times, and this with such accuracy that although the operation was repeated many, many times, there was no appreciable discrepancy in the results. So, Galileo's model was $$d=gt^2,$$ where $d$ is the distance traveled, $g$ - acceleration and $t$ - time. He would roll a ball at the full distance $d_0=1$ and establish the base time $t_0$. He proceeded to conduct 100 measurements at different $d_i$ measuring times $t_i$. Then he calculated $d_0/d_i$ and $t_0^2/t_i^2$. If his model was right then you'd have $$\frac{d_0}{d_i}=\frac{t_0^2}{t_i^2}$$. Pay attention to how he measured time. It's so crude that it reminds me how these days unnatural sciences measure their variables, think of "customer satisfaction" or "utility". He mentions that the measurement error was within tenth of a unit of time, btw. Did he include all relevant variables? Yes he did. Now, you have to understand that all bodies are attracted to each other by gravity. So, in theory to calculate the exact force on the ball you have to add every body in the universe to the equation. Moreover, much more importantly he didn't include surface resistance, air drag, angular momentum etc. Did these all impact his measurements? Yes. However, they were not relevant to what he was studying because he was able to reduce or eliminate their impact by isolating the impact of the property he was studying. Now, Would you say that his coefficient (precisely 2 for $t^2$) was misleading because he "didn't control for air pressure and temperature changes between experiments"? No. Despite all the problems and limitations he was able to correctly establish the major law of motion, which still holds today at insane precision! He was able to accomplish this without statistical packages and computers because he designed a great experiment in such a way that the statistical part was rendered trivial and almost irrelevant. That's the idea situation you'd like to be.
Do we really need to include "all relevant predictors?"
Yes, you must include all "relevant variables", but you must be smart about it. You must think of the ways to construct the experiments that would isolate the impact of your phenomenon from unrelated
Do we really need to include "all relevant predictors?" Yes, you must include all "relevant variables", but you must be smart about it. You must think of the ways to construct the experiments that would isolate the impact of your phenomenon from unrelated stuff, which is a plenty in real world (as opposed to a class room) research. Before you get into statistics, you have to do the heavy lifting in your domain, not in statistics. I encourage you not be cynical about including all relevant variables, because it's not only a noble goal but also because it's often possible. We don't say this just for the sake of saying it. We really do mean it. In fact, designing experiments and studies that are able to include all relevant variables is what makes science really interesting, and different from mechanical boiler plate "experiments". To motivate my statement, I'll give you an example of how Galileo studied acceleration. Here's his description of an actual experiment (from this web page): A piece of wooden moulding or scantling, about 12 cubits long, half a cubit wide, and three finger-breadths thick, was taken; on its edge was cut a channel a little more than one finger in breadth; having made this groove very straight, smooth, and polished, and having lined it with parchment, also as smooth and polished as possible, we rolled along it a hard, smooth, and very round bronze ball. Having placed this board in a sloping position, by raising one end some one or two cubits above the other, we rolled the ball, as I was just saying, along the channel, noting, in a manner presently to be described, the time required to make the descent. We repeated this experiment more than once in order to measure the time with an accuracy such that the deviation between two observations never exceeded one-tenth of a pulse-beat. Having performed this operation and having assured ourselves of its reliability, we now rolled the ball only one-quarter the length of the channel; and having measured the time of its descent, we found it precisely one-half of the former. Next we tried other distances, compared the time for the whole length with that for the half, or with that for two-thirds, or three-fourths, or indeed for any fraction; in such experiments, repeated a full hundred times, we always found that the spaces traversed were to each other as the squares of the times, and this was true for all inclinations of the plane, i.e., of the channel, along which we rolled the ball. We also observed that the times of descent, for various inclinations of the plane, bore to one another precisely that ratio which, as we shall see later, the Author had predicted and demonstrated for them. For the measurement of time, we employed a large vessel of water placed in an elevated position; to the bottom of this vessel was soldered a pipe of small diameter giving a thin jet of water which we collected in a small glass during the time of each descent, whether for the whole length of the channel or for part of its length; the water thus collected was weighed, after each descent, on a very accurate balance; the differences and ratios of these weights gave us the differences and ratios of the times, and this with such accuracy that although the operation was repeated many, many times, there was no appreciable discrepancy in the results. So, Galileo's model was $$d=gt^2,$$ where $d$ is the distance traveled, $g$ - acceleration and $t$ - time. He would roll a ball at the full distance $d_0=1$ and establish the base time $t_0$. He proceeded to conduct 100 measurements at different $d_i$ measuring times $t_i$. Then he calculated $d_0/d_i$ and $t_0^2/t_i^2$. If his model was right then you'd have $$\frac{d_0}{d_i}=\frac{t_0^2}{t_i^2}$$. Pay attention to how he measured time. It's so crude that it reminds me how these days unnatural sciences measure their variables, think of "customer satisfaction" or "utility". He mentions that the measurement error was within tenth of a unit of time, btw. Did he include all relevant variables? Yes he did. Now, you have to understand that all bodies are attracted to each other by gravity. So, in theory to calculate the exact force on the ball you have to add every body in the universe to the equation. Moreover, much more importantly he didn't include surface resistance, air drag, angular momentum etc. Did these all impact his measurements? Yes. However, they were not relevant to what he was studying because he was able to reduce or eliminate their impact by isolating the impact of the property he was studying. Now, Would you say that his coefficient (precisely 2 for $t^2$) was misleading because he "didn't control for air pressure and temperature changes between experiments"? No. Despite all the problems and limitations he was able to correctly establish the major law of motion, which still holds today at insane precision! He was able to accomplish this without statistical packages and computers because he designed a great experiment in such a way that the statistical part was rendered trivial and almost irrelevant. That's the idea situation you'd like to be.
Do we really need to include "all relevant predictors?" Yes, you must include all "relevant variables", but you must be smart about it. You must think of the ways to construct the experiments that would isolate the impact of your phenomenon from unrelated
18,184
Do we really need to include "all relevant predictors?"
For the assumptions of the regression model to hold perfectly, all relevant predictors must be included. But none of the assumptions in any statistical analysis hold perfectly and much of statistical practice is based on "Close Enough". With Design of experiments and proper randomization, the effect of terms not included in the models can often be ignored (assumed equal by the chance of randomization). But, regression is usually used when full randomization is not possible to account for all possible variables not included in the model, so your question does become important. Pretty much every regression model ever fit is probably missing some potential predictors, but "I don't Know" without any further clarification would not allow working statisticians to keep working, so we try our best and then try to work out how much the difference between the assumptions and reality will affect our results. In some cases the difference from the assumptions makes very little difference and we don't worry much about the difference, but in other cases it can be very serious. One option when you know that there may be predictors that were not included in the model that would be relevant is to do a sensitivity analysis. This measures how much bias would be possible based on potential relationships with the unmeasured variable(s). This paper: Lin, DY and Psaty, BM and Kronmal, RA. (1998): Assessing the Sensitivity of Regression Results to Unmeasured Confounders in Observational Studies. Biometrics, 54 (3), Sep, pp. 948-963. gives some tools (and examples) of a sensitivity analysis.
Do we really need to include "all relevant predictors?"
For the assumptions of the regression model to hold perfectly, all relevant predictors must be included. But none of the assumptions in any statistical analysis hold perfectly and much of statistical
Do we really need to include "all relevant predictors?" For the assumptions of the regression model to hold perfectly, all relevant predictors must be included. But none of the assumptions in any statistical analysis hold perfectly and much of statistical practice is based on "Close Enough". With Design of experiments and proper randomization, the effect of terms not included in the models can often be ignored (assumed equal by the chance of randomization). But, regression is usually used when full randomization is not possible to account for all possible variables not included in the model, so your question does become important. Pretty much every regression model ever fit is probably missing some potential predictors, but "I don't Know" without any further clarification would not allow working statisticians to keep working, so we try our best and then try to work out how much the difference between the assumptions and reality will affect our results. In some cases the difference from the assumptions makes very little difference and we don't worry much about the difference, but in other cases it can be very serious. One option when you know that there may be predictors that were not included in the model that would be relevant is to do a sensitivity analysis. This measures how much bias would be possible based on potential relationships with the unmeasured variable(s). This paper: Lin, DY and Psaty, BM and Kronmal, RA. (1998): Assessing the Sensitivity of Regression Results to Unmeasured Confounders in Observational Studies. Biometrics, 54 (3), Sep, pp. 948-963. gives some tools (and examples) of a sensitivity analysis.
Do we really need to include "all relevant predictors?" For the assumptions of the regression model to hold perfectly, all relevant predictors must be included. But none of the assumptions in any statistical analysis hold perfectly and much of statistical
18,185
Why does the number of continuous uniform variables on (0,1) needed for their sum to exceed one have mean $e$?
First observation: $Y$ has a more pleasing CDF than PMF The probability mass function $p_Y(n)$ is the probability that $n$ is "only just enough" for the total to exceed unity, i.e. $X_1 + X_2 + \dots X_n$ exceeds one while $X_1 + \dots + X_{n-1}$ does not. The cumulative distribution $F_Y(n) = \Pr(Y \leq n)$ simply requires $n$ is "enough", i.e. $\sum_{i=1}^{n}X_i > 1$ with no restriction on how much by. This looks like a much simpler event to deal with the probability of. Second observation: $Y$ takes non-negative integer values so $\mathbb{E}(Y)$ can be written in terms of the CDF Clearly $Y$ can only take values in $\{0, 1, 2, \dots\}$, so we can write its mean in terms of the complementary CDF, $\bar F_Y$. $$\mathbb{E}(Y) = \sum_{n=0}^\infty \bar F_Y(n) = \sum_{n=0}^\infty \left(1 - F_Y(n) \right)$$ In fact $\Pr(Y=0)$ and $\Pr(Y=1)$ are both zero, so the first two terms are $\mathbb{E}(Y) = 1 + 1 + \dots$. As for the later terms, if $F_Y(n)$ is the probability that $\sum_{i=1}^{n}X_i > 1$, what event is $\bar F_Y(n)$ the probability of? Third observation: the (hyper)volume of an $n$-simplex is $\frac{1}{n!}$ The $n$-simplex I have in mind occupies the volume under a standard unit $(n-1)$-simplex in the all-positive orthant of $\mathbb{R}^n$: it is the convex hull of $(n+1)$ vertices, in particular the origin plus the vertices of the unit $(n-1)$-simplex at $(1, 0, 0, \dots)$, $(0, 1, 0, \dots)$ etc. For example, the 2-simplex above with $x_1 + x_2 \leq 1$ has area $\frac{1}{2}$ and the 3-simplex with $x_1 + x_2 + x_3 \leq 1$ has volume $\frac{1}{6}$. For a proof that proceeds by directly evaluating an integral for the probability of the event described by $\bar F_Y(n)$, and links to two other arguments, see this Math SE thread. The related thread may also be of interest: Is there a relationship between $e$ and the sum of $n$-simplexes volumes?
Why does the number of continuous uniform variables on (0,1) needed for their sum to exceed one have
First observation: $Y$ has a more pleasing CDF than PMF The probability mass function $p_Y(n)$ is the probability that $n$ is "only just enough" for the total to exceed unity, i.e. $X_1 + X_2 + \dots
Why does the number of continuous uniform variables on (0,1) needed for their sum to exceed one have mean $e$? First observation: $Y$ has a more pleasing CDF than PMF The probability mass function $p_Y(n)$ is the probability that $n$ is "only just enough" for the total to exceed unity, i.e. $X_1 + X_2 + \dots X_n$ exceeds one while $X_1 + \dots + X_{n-1}$ does not. The cumulative distribution $F_Y(n) = \Pr(Y \leq n)$ simply requires $n$ is "enough", i.e. $\sum_{i=1}^{n}X_i > 1$ with no restriction on how much by. This looks like a much simpler event to deal with the probability of. Second observation: $Y$ takes non-negative integer values so $\mathbb{E}(Y)$ can be written in terms of the CDF Clearly $Y$ can only take values in $\{0, 1, 2, \dots\}$, so we can write its mean in terms of the complementary CDF, $\bar F_Y$. $$\mathbb{E}(Y) = \sum_{n=0}^\infty \bar F_Y(n) = \sum_{n=0}^\infty \left(1 - F_Y(n) \right)$$ In fact $\Pr(Y=0)$ and $\Pr(Y=1)$ are both zero, so the first two terms are $\mathbb{E}(Y) = 1 + 1 + \dots$. As for the later terms, if $F_Y(n)$ is the probability that $\sum_{i=1}^{n}X_i > 1$, what event is $\bar F_Y(n)$ the probability of? Third observation: the (hyper)volume of an $n$-simplex is $\frac{1}{n!}$ The $n$-simplex I have in mind occupies the volume under a standard unit $(n-1)$-simplex in the all-positive orthant of $\mathbb{R}^n$: it is the convex hull of $(n+1)$ vertices, in particular the origin plus the vertices of the unit $(n-1)$-simplex at $(1, 0, 0, \dots)$, $(0, 1, 0, \dots)$ etc. For example, the 2-simplex above with $x_1 + x_2 \leq 1$ has area $\frac{1}{2}$ and the 3-simplex with $x_1 + x_2 + x_3 \leq 1$ has volume $\frac{1}{6}$. For a proof that proceeds by directly evaluating an integral for the probability of the event described by $\bar F_Y(n)$, and links to two other arguments, see this Math SE thread. The related thread may also be of interest: Is there a relationship between $e$ and the sum of $n$-simplexes volumes?
Why does the number of continuous uniform variables on (0,1) needed for their sum to exceed one have First observation: $Y$ has a more pleasing CDF than PMF The probability mass function $p_Y(n)$ is the probability that $n$ is "only just enough" for the total to exceed unity, i.e. $X_1 + X_2 + \dots
18,186
Why does the number of continuous uniform variables on (0,1) needed for their sum to exceed one have mean $e$?
Fix $n \ge 1$. Let $$U_i = X_1 + X_2 + \cdots + X_i \mod 1$$ be the fractional parts of the partial sums for $i=1,2,\ldots, n$. The independent uniformity of $X_1$ and $X_{i+1}$ guarantee that $U_{i+1}$ is just as likely to exceed $U_i$ as it is to be less than it. This implies that all $n!$ orderings of the sequence $(U_i)$ are equally likely. Given the sequence $U_1, U_2, \ldots, U_n$, we can recover the sequence $X_1, X_2, \ldots, X_n$. To see how, notice that $U_1 = X_1$ because both are between $0$ and $1$. If $U_{i+1} \ge U_i$, then $X_{i+1} = U_{i+1} - U_i$. Otherwise, $U_i + X_{i+1} \gt 1$, whence $X_{i+1} = U_{i+1} - U_i + 1$. There is exactly one sequence in which the $U_i$ are already in increasing order, in which case $1 \gt U_n = X_1 + X_2 + \cdots + X_n$. Being one of $n!$ equally likely sequences, this has a chance $1/n!$ of occurring. In all the other sequences at least one step from $U_i$ to $U_{i+1}$ is out of order. This implies the sum of the $X_i$ had to equal or exceed $1$. Thus we see that $$\Pr(Y \gt n) = \Pr(X_1 + X_2 + \cdots + X_n \le 1) = \Pr(X_1 + X_2 + \cdots + X_n \lt 1) = \frac{1}{n!}.$$ This yields the probabilities for the entire distribution of $Y$, since for integral $n\ge 1$ $$\Pr(Y = n) = \Pr(Y \gt n-1) - \Pr(Y \gt n) = \frac{1}{(n-1)!} - \frac{1}{n!} = \frac{n-1}{n!}.$$ Moreover, $$\mathbb{E}(Y) = \sum_{n=0}^\infty \Pr(Y \gt n) = \sum_{n=0}^\infty \frac{1}{n!} = e,$$ QED.
Why does the number of continuous uniform variables on (0,1) needed for their sum to exceed one have
Fix $n \ge 1$. Let $$U_i = X_1 + X_2 + \cdots + X_i \mod 1$$ be the fractional parts of the partial sums for $i=1,2,\ldots, n$. The independent uniformity of $X_1$ and $X_{i+1}$ guarantee that $U_{i
Why does the number of continuous uniform variables on (0,1) needed for their sum to exceed one have mean $e$? Fix $n \ge 1$. Let $$U_i = X_1 + X_2 + \cdots + X_i \mod 1$$ be the fractional parts of the partial sums for $i=1,2,\ldots, n$. The independent uniformity of $X_1$ and $X_{i+1}$ guarantee that $U_{i+1}$ is just as likely to exceed $U_i$ as it is to be less than it. This implies that all $n!$ orderings of the sequence $(U_i)$ are equally likely. Given the sequence $U_1, U_2, \ldots, U_n$, we can recover the sequence $X_1, X_2, \ldots, X_n$. To see how, notice that $U_1 = X_1$ because both are between $0$ and $1$. If $U_{i+1} \ge U_i$, then $X_{i+1} = U_{i+1} - U_i$. Otherwise, $U_i + X_{i+1} \gt 1$, whence $X_{i+1} = U_{i+1} - U_i + 1$. There is exactly one sequence in which the $U_i$ are already in increasing order, in which case $1 \gt U_n = X_1 + X_2 + \cdots + X_n$. Being one of $n!$ equally likely sequences, this has a chance $1/n!$ of occurring. In all the other sequences at least one step from $U_i$ to $U_{i+1}$ is out of order. This implies the sum of the $X_i$ had to equal or exceed $1$. Thus we see that $$\Pr(Y \gt n) = \Pr(X_1 + X_2 + \cdots + X_n \le 1) = \Pr(X_1 + X_2 + \cdots + X_n \lt 1) = \frac{1}{n!}.$$ This yields the probabilities for the entire distribution of $Y$, since for integral $n\ge 1$ $$\Pr(Y = n) = \Pr(Y \gt n-1) - \Pr(Y \gt n) = \frac{1}{(n-1)!} - \frac{1}{n!} = \frac{n-1}{n!}.$$ Moreover, $$\mathbb{E}(Y) = \sum_{n=0}^\infty \Pr(Y \gt n) = \sum_{n=0}^\infty \frac{1}{n!} = e,$$ QED.
Why does the number of continuous uniform variables on (0,1) needed for their sum to exceed one have Fix $n \ge 1$. Let $$U_i = X_1 + X_2 + \cdots + X_i \mod 1$$ be the fractional parts of the partial sums for $i=1,2,\ldots, n$. The independent uniformity of $X_1$ and $X_{i+1}$ guarantee that $U_{i
18,187
Why does the number of continuous uniform variables on (0,1) needed for their sum to exceed one have mean $e$?
In Sheldon Ross' A First Course in Probability there is an easy to follow proof: Modifying a bit the notation in the OP, $U_i \overset{iid}\sim \mathcal{U}(0,1)$ and $Y$ the minimum number of terms for $U_1 + U_2 + \dots + U_Y > 1$, or expressed differently: $$Y = min\Big\{n: \sum_{i=1}^n U_i>1\Big\}$$ If instead we looked for: $$Y(u) = min\Big\{n: \sum_{i=1}^n U_i>u\Big\}$$ for $u\in[0,1]$, we define the $f(u)=\mathbb E[Y(u)]$, expressing the expectation for the number of realizations of uniform draws that will exceed $u$ when added. We can apply the following general properties for continuous variables: $E[X] = E[E[X|Y]]=\displaystyle\int_{-\infty}^{\infty}E[X|Y=y]\,f_Y(y)\,dy$ to express $f(u)$ conditionally on the outcome of the first uniform, and getting a manageable equation thanks to the pdf of $X \sim U(0,1)$, $f_Y(y)=1.$ This would be it: $$f(u)=\displaystyle\int_0^1 \mathbb E[Y(u)|U_1=x]\,dx \tag 1$$ If the $U_1=x$ we are conditioning on is greater than $u$, i.e. $x>u$, $\mathbb E[Y(u)|U_1=x] =1 .$ If, on the other hand, $x <u$, $\mathbb E[Y(u)|U_1=x] =1 + f(u - x)$, because we already have drawn $1$ uniform random, and we still have the difference between $x$ and $u$ to cover. Going back to equation (1): $$f(u) = 1 + \displaystyle\int_0^x f(u - x) \,dx$$, and with substituting $w = u - x$ we would have $f(u) = 1 + \displaystyle\int_0^x f(w) \,dw$. If we differentiate both sides of this equation, we can see that: $$f'(u) = f(u)\implies \frac{f'(u)}{f(u)}=1$$ with one last integration we get: $$log[f(u)] = u + c \implies f(u) = k \,e^u$$ We know that the expectation that drawing a sample from the uniform distribution and surpassing $0$ is $1$, or $f(0) = 1$. Hence, $k = 1$, and $f(u)=e^u$. Therefore $f(1) = e.$
Why does the number of continuous uniform variables on (0,1) needed for their sum to exceed one have
In Sheldon Ross' A First Course in Probability there is an easy to follow proof: Modifying a bit the notation in the OP, $U_i \overset{iid}\sim \mathcal{U}(0,1)$ and $Y$ the minimum number of terms fo
Why does the number of continuous uniform variables on (0,1) needed for their sum to exceed one have mean $e$? In Sheldon Ross' A First Course in Probability there is an easy to follow proof: Modifying a bit the notation in the OP, $U_i \overset{iid}\sim \mathcal{U}(0,1)$ and $Y$ the minimum number of terms for $U_1 + U_2 + \dots + U_Y > 1$, or expressed differently: $$Y = min\Big\{n: \sum_{i=1}^n U_i>1\Big\}$$ If instead we looked for: $$Y(u) = min\Big\{n: \sum_{i=1}^n U_i>u\Big\}$$ for $u\in[0,1]$, we define the $f(u)=\mathbb E[Y(u)]$, expressing the expectation for the number of realizations of uniform draws that will exceed $u$ when added. We can apply the following general properties for continuous variables: $E[X] = E[E[X|Y]]=\displaystyle\int_{-\infty}^{\infty}E[X|Y=y]\,f_Y(y)\,dy$ to express $f(u)$ conditionally on the outcome of the first uniform, and getting a manageable equation thanks to the pdf of $X \sim U(0,1)$, $f_Y(y)=1.$ This would be it: $$f(u)=\displaystyle\int_0^1 \mathbb E[Y(u)|U_1=x]\,dx \tag 1$$ If the $U_1=x$ we are conditioning on is greater than $u$, i.e. $x>u$, $\mathbb E[Y(u)|U_1=x] =1 .$ If, on the other hand, $x <u$, $\mathbb E[Y(u)|U_1=x] =1 + f(u - x)$, because we already have drawn $1$ uniform random, and we still have the difference between $x$ and $u$ to cover. Going back to equation (1): $$f(u) = 1 + \displaystyle\int_0^x f(u - x) \,dx$$, and with substituting $w = u - x$ we would have $f(u) = 1 + \displaystyle\int_0^x f(w) \,dw$. If we differentiate both sides of this equation, we can see that: $$f'(u) = f(u)\implies \frac{f'(u)}{f(u)}=1$$ with one last integration we get: $$log[f(u)] = u + c \implies f(u) = k \,e^u$$ We know that the expectation that drawing a sample from the uniform distribution and surpassing $0$ is $1$, or $f(0) = 1$. Hence, $k = 1$, and $f(u)=e^u$. Therefore $f(1) = e.$
Why does the number of continuous uniform variables on (0,1) needed for their sum to exceed one have In Sheldon Ross' A First Course in Probability there is an easy to follow proof: Modifying a bit the notation in the OP, $U_i \overset{iid}\sim \mathcal{U}(0,1)$ and $Y$ the minimum number of terms fo
18,188
Which distance to use? e.g., manhattan, euclidean, Bray-Curtis, etc
Unfortunately, in most situations there is not a clear-cut answer to your question. That is, for any given application, there are surely many distance metrics which will yield similar and accurate answers. Considering that there are dozens, and probably hundreds, of valid distance metrics actively being used, the notion that you can find the "right" distance is not a productive way to think about the problem of selecting an appropriate distance metric. I would instead focus on not picking the wrong distance metric. Do you want your distance to reflect "absolute magnitude" (for example, you are interested in using the distance to identify stocks that have similar mean values), or to reflect overall shape of the response (e.g. stock prices that fluctuate similarly over time, but may have entirely different raw values)? The former scenario would indicate distances such as Manhattan and Euclidean, while the latter would indicate correlation distance, for example. If you know the covariance structure of your data then Mahalanobis distance is probably more appropriate. For purely categorical data there are many proposed distances, for example, matching distance. For mixed categorical and continuous Gower's distance is popular, (although somewhat theoretically unsatisfying in my opinion). Finally, in my opinion your analysis will be strengthened if you demonstrate that your results and conclusions are robust to the choice of distance metric (within the subset of appropriate distances, of course). If your analysis changes drastically with subtle changes in the distance metric used, further study should be undertaken to identify the reason for the inconsistency.
Which distance to use? e.g., manhattan, euclidean, Bray-Curtis, etc
Unfortunately, in most situations there is not a clear-cut answer to your question. That is, for any given application, there are surely many distance metrics which will yield similar and accurate ans
Which distance to use? e.g., manhattan, euclidean, Bray-Curtis, etc Unfortunately, in most situations there is not a clear-cut answer to your question. That is, for any given application, there are surely many distance metrics which will yield similar and accurate answers. Considering that there are dozens, and probably hundreds, of valid distance metrics actively being used, the notion that you can find the "right" distance is not a productive way to think about the problem of selecting an appropriate distance metric. I would instead focus on not picking the wrong distance metric. Do you want your distance to reflect "absolute magnitude" (for example, you are interested in using the distance to identify stocks that have similar mean values), or to reflect overall shape of the response (e.g. stock prices that fluctuate similarly over time, but may have entirely different raw values)? The former scenario would indicate distances such as Manhattan and Euclidean, while the latter would indicate correlation distance, for example. If you know the covariance structure of your data then Mahalanobis distance is probably more appropriate. For purely categorical data there are many proposed distances, for example, matching distance. For mixed categorical and continuous Gower's distance is popular, (although somewhat theoretically unsatisfying in my opinion). Finally, in my opinion your analysis will be strengthened if you demonstrate that your results and conclusions are robust to the choice of distance metric (within the subset of appropriate distances, of course). If your analysis changes drastically with subtle changes in the distance metric used, further study should be undertaken to identify the reason for the inconsistency.
Which distance to use? e.g., manhattan, euclidean, Bray-Curtis, etc Unfortunately, in most situations there is not a clear-cut answer to your question. That is, for any given application, there are surely many distance metrics which will yield similar and accurate ans
18,189
Which distance to use? e.g., manhattan, euclidean, Bray-Curtis, etc
Choosing the right distance is not an elementary task. When we want to make a cluster analysis on a data set, different results could appear using different distances, so it's very important to be careful in which distance to choose because we can make a false good artefact that capture well the variability, but actually without sense in our problem. The Euclidean distance is appropriate when I have continuous numerical variables and I want to reflect absolute distances. This distance takes into account every variable and doesn’t remove redundancies, so if I had three variables that explain the same (are correlated), I would weight this effect by three. Moreover, this distance is not scale invariant, so generally I have to scale previously to use the distance. Example ecology: We have different observations from many localities, of which the experts have taken samples of some microbiological, physical and chemical factors. We want to find patterns in ecosystems. These factors have a high correlation, but we know everyone is relevant, so we don’t want to remove these redundancies. We use the Euclidean distance with scaled data to avoid the effect of units. The Mahalanobis distance is appropriate when I have continuous numerical variables and I want to reflect absolute distances, but we want to remove redundancies. If we have repeated variables, their repetitious effect will disappear. The family Hellinger, Species Profile and Chord distance are appropriate when we want to make emphasis on differences between variables, when we want to differentiate profiles. These distances weights by total quantities of each observation, in such a way that the distances are small when variable by variable the individuals are more similar, although in absolute magnitudes was very different. Watch out! These distances reflect very well the difference between profiles, but lost the magnitude effect. They could be very useful when we have different sample sizes. Example ecology: We want to study the fauna of many lands and we have a data matrix of an inventory of the gastropod (sampling locations in rows and species names in columns). The matrix is characterized by having many zeros and different magnitudes because some localities have some species and others have other species. We could use Hellinger distance. Bray-Curtis is quite similar, but it’s more appropriate when we want to differentiate profiles and also take relative magnitudes into account.
Which distance to use? e.g., manhattan, euclidean, Bray-Curtis, etc
Choosing the right distance is not an elementary task. When we want to make a cluster analysis on a data set, different results could appear using different distances, so it's very important to be car
Which distance to use? e.g., manhattan, euclidean, Bray-Curtis, etc Choosing the right distance is not an elementary task. When we want to make a cluster analysis on a data set, different results could appear using different distances, so it's very important to be careful in which distance to choose because we can make a false good artefact that capture well the variability, but actually without sense in our problem. The Euclidean distance is appropriate when I have continuous numerical variables and I want to reflect absolute distances. This distance takes into account every variable and doesn’t remove redundancies, so if I had three variables that explain the same (are correlated), I would weight this effect by three. Moreover, this distance is not scale invariant, so generally I have to scale previously to use the distance. Example ecology: We have different observations from many localities, of which the experts have taken samples of some microbiological, physical and chemical factors. We want to find patterns in ecosystems. These factors have a high correlation, but we know everyone is relevant, so we don’t want to remove these redundancies. We use the Euclidean distance with scaled data to avoid the effect of units. The Mahalanobis distance is appropriate when I have continuous numerical variables and I want to reflect absolute distances, but we want to remove redundancies. If we have repeated variables, their repetitious effect will disappear. The family Hellinger, Species Profile and Chord distance are appropriate when we want to make emphasis on differences between variables, when we want to differentiate profiles. These distances weights by total quantities of each observation, in such a way that the distances are small when variable by variable the individuals are more similar, although in absolute magnitudes was very different. Watch out! These distances reflect very well the difference between profiles, but lost the magnitude effect. They could be very useful when we have different sample sizes. Example ecology: We want to study the fauna of many lands and we have a data matrix of an inventory of the gastropod (sampling locations in rows and species names in columns). The matrix is characterized by having many zeros and different magnitudes because some localities have some species and others have other species. We could use Hellinger distance. Bray-Curtis is quite similar, but it’s more appropriate when we want to differentiate profiles and also take relative magnitudes into account.
Which distance to use? e.g., manhattan, euclidean, Bray-Curtis, etc Choosing the right distance is not an elementary task. When we want to make a cluster analysis on a data set, different results could appear using different distances, so it's very important to be car
18,190
Which distance to use? e.g., manhattan, euclidean, Bray-Curtis, etc
Regarding the Manhattan distance: Kaufman, Leonard, and Peter J. Rousseeuw. "Finding groups in data: An introduction to cluster analysis." (2005). The use of the Manhattan distance is advised in those situations where for example a difference of 1 in the first variable,and of 3 in the second variable is the same as a difference of 2 in the first variable and of 2 in the second.
Which distance to use? e.g., manhattan, euclidean, Bray-Curtis, etc
Regarding the Manhattan distance: Kaufman, Leonard, and Peter J. Rousseeuw. "Finding groups in data: An introduction to cluster analysis." (2005). The use of the Manhattan distance is advised in thos
Which distance to use? e.g., manhattan, euclidean, Bray-Curtis, etc Regarding the Manhattan distance: Kaufman, Leonard, and Peter J. Rousseeuw. "Finding groups in data: An introduction to cluster analysis." (2005). The use of the Manhattan distance is advised in those situations where for example a difference of 1 in the first variable,and of 3 in the second variable is the same as a difference of 2 in the first variable and of 2 in the second.
Which distance to use? e.g., manhattan, euclidean, Bray-Curtis, etc Regarding the Manhattan distance: Kaufman, Leonard, and Peter J. Rousseeuw. "Finding groups in data: An introduction to cluster analysis." (2005). The use of the Manhattan distance is advised in thos
18,191
Is the logit function always the best for regression modeling of binary data?
People use all sorts of functions to keep their data between 0 and 1. The log-odds fall out naturally from the math when you derive the model (it's called the "canonical link function"), but you're absolutely free to experiment with other alternatives. As Macro alluded to in his comment on your question, one common choice is a probit model, which uses the quantile function of a Gaussian instead of the logistic function. I've also heard good things about using the quantile function of a Student's $t$ distribution, although I've never tried it. They all have the same basic S-shape, but they differ in how quickly they saturate at each end. Probit models approach 0 and 1 very quickly, which can be dangerous if the probabilities tend to be less extreme. $t$-based models can go either way, depending on how many degrees of freedom the $t$ distribution has. Andrew Gelman says (in a mostly unrelated context) that $t_7$ is roughly like the logistic curve. Lowering the degrees of freedom gives you fatter tails and a broader range of intermediate values in your regression. When the degrees of freedom go to infinity, you're back to the probit model. Hope this helps. Edited to add: The discussion @Macro linked to is really excellent. I'd highly recommend reading through it if you're interested in more detail.
Is the logit function always the best for regression modeling of binary data?
People use all sorts of functions to keep their data between 0 and 1. The log-odds fall out naturally from the math when you derive the model (it's called the "canonical link function"), but you're a
Is the logit function always the best for regression modeling of binary data? People use all sorts of functions to keep their data between 0 and 1. The log-odds fall out naturally from the math when you derive the model (it's called the "canonical link function"), but you're absolutely free to experiment with other alternatives. As Macro alluded to in his comment on your question, one common choice is a probit model, which uses the quantile function of a Gaussian instead of the logistic function. I've also heard good things about using the quantile function of a Student's $t$ distribution, although I've never tried it. They all have the same basic S-shape, but they differ in how quickly they saturate at each end. Probit models approach 0 and 1 very quickly, which can be dangerous if the probabilities tend to be less extreme. $t$-based models can go either way, depending on how many degrees of freedom the $t$ distribution has. Andrew Gelman says (in a mostly unrelated context) that $t_7$ is roughly like the logistic curve. Lowering the degrees of freedom gives you fatter tails and a broader range of intermediate values in your regression. When the degrees of freedom go to infinity, you're back to the probit model. Hope this helps. Edited to add: The discussion @Macro linked to is really excellent. I'd highly recommend reading through it if you're interested in more detail.
Is the logit function always the best for regression modeling of binary data? People use all sorts of functions to keep their data between 0 and 1. The log-odds fall out naturally from the math when you derive the model (it's called the "canonical link function"), but you're a
18,192
Is the logit function always the best for regression modeling of binary data?
I see no reason, a-priori, why the appropriate link function for a given dataset has to be the logit (although the universe does seem to be rather kind to us in general). I don't know if these are quite what you're looking for, but here are some papers that discuss more exotic link functions: Cauchit (etc.): Koenker, R., & Yoon, J. (2009). Parametric links for binary choice models: A Fisherian-Bayesian colloquy. Journal of Econometrics, 152, 2, pp. 120-130. Koenker, R. (2006). Parametric links for binary choice models. Rnews, 6, 4, pp. 32-34. Scobit: Nagler, J. (1994). Scobit: An alternative estimator to logit and probit. American Journal of Political Science, 38, 1, pp. 230-255. Skew-Probit: Bazan, J.L., Bolfarine, H., & Branco, M.D. (2010). A framework for skew-probit links in binary regression. Communications in Statistics--Theory and Methods, 39, pp. 678-697. (This seems like a good overview of skewed links within a Bayesian framework): Chen, M.H. (2004). Skewed link models for categorical response data. In Skew-Elliptical Distributions and Their Applications: A Journey Beyond Normality, Marc Genton, editor. Chapman and Hall. Disclosure: I don't know this material well. I tried dabbling with the Cauchit and Scobit a couple of years ago, but my code kept crashing (probably because I'm not a great programmer), and it didn't seem relevant for the project I was working on, so I dropped it. Most of this stuff has to do with differing tail behavior than the prototypical links (i.e., the function 'turns the corner' early and doesn't asymptote to 0 & 1 very fast), or are skewed (i.e., like the cloglog, they approach one limit faster than the other). You should also be able to replicate these behaviors, I believe, by fitting a spline function of $X$ with a logistic link.
Is the logit function always the best for regression modeling of binary data?
I see no reason, a-priori, why the appropriate link function for a given dataset has to be the logit (although the universe does seem to be rather kind to us in general). I don't know if these are qu
Is the logit function always the best for regression modeling of binary data? I see no reason, a-priori, why the appropriate link function for a given dataset has to be the logit (although the universe does seem to be rather kind to us in general). I don't know if these are quite what you're looking for, but here are some papers that discuss more exotic link functions: Cauchit (etc.): Koenker, R., & Yoon, J. (2009). Parametric links for binary choice models: A Fisherian-Bayesian colloquy. Journal of Econometrics, 152, 2, pp. 120-130. Koenker, R. (2006). Parametric links for binary choice models. Rnews, 6, 4, pp. 32-34. Scobit: Nagler, J. (1994). Scobit: An alternative estimator to logit and probit. American Journal of Political Science, 38, 1, pp. 230-255. Skew-Probit: Bazan, J.L., Bolfarine, H., & Branco, M.D. (2010). A framework for skew-probit links in binary regression. Communications in Statistics--Theory and Methods, 39, pp. 678-697. (This seems like a good overview of skewed links within a Bayesian framework): Chen, M.H. (2004). Skewed link models for categorical response data. In Skew-Elliptical Distributions and Their Applications: A Journey Beyond Normality, Marc Genton, editor. Chapman and Hall. Disclosure: I don't know this material well. I tried dabbling with the Cauchit and Scobit a couple of years ago, but my code kept crashing (probably because I'm not a great programmer), and it didn't seem relevant for the project I was working on, so I dropped it. Most of this stuff has to do with differing tail behavior than the prototypical links (i.e., the function 'turns the corner' early and doesn't asymptote to 0 & 1 very fast), or are skewed (i.e., like the cloglog, they approach one limit faster than the other). You should also be able to replicate these behaviors, I believe, by fitting a spline function of $X$ with a logistic link.
Is the logit function always the best for regression modeling of binary data? I see no reason, a-priori, why the appropriate link function for a given dataset has to be the logit (although the universe does seem to be rather kind to us in general). I don't know if these are qu
18,193
Is the logit function always the best for regression modeling of binary data?
The best strategy is to model the data in light of what is going on (No surprise!) Probit models originate with LD50 studies - you want the dose of insecticide that kills half the bugs. The binary response is whether the bug lives or dies (at a given dose). The bugs that are susceptible at one dose will be susceptible at lower doses as well, which is where the idea of modeling to the cumulative Normal comes in. If the binary observations come in clusters, you can use a beta-binomial model. Ben Bolker has a good introduction in the documentation of his bbmle package (in R) which implements this in simple cases. These models allow more control over the variation of the data than what you get in a binomial distribution. Multivariate binary data -- the sort that rolls up into multi-dimensional contingency tables - can be analysed using a log-linear model. The link function is the log rather than the log odds. Some people refer to this as Poisson regression. There probably isn't research on these models as such, although there has been plenty of research on any one of these models, and on the comparisons between them, and on different ways of estimating them. What you find in the literature is that there is a lot of activity for a while, as researchers consider a number of options for a particular class of problems, and then one method emerges as superior.
Is the logit function always the best for regression modeling of binary data?
The best strategy is to model the data in light of what is going on (No surprise!) Probit models originate with LD50 studies - you want the dose of insecticide that kills half the bugs. The binary re
Is the logit function always the best for regression modeling of binary data? The best strategy is to model the data in light of what is going on (No surprise!) Probit models originate with LD50 studies - you want the dose of insecticide that kills half the bugs. The binary response is whether the bug lives or dies (at a given dose). The bugs that are susceptible at one dose will be susceptible at lower doses as well, which is where the idea of modeling to the cumulative Normal comes in. If the binary observations come in clusters, you can use a beta-binomial model. Ben Bolker has a good introduction in the documentation of his bbmle package (in R) which implements this in simple cases. These models allow more control over the variation of the data than what you get in a binomial distribution. Multivariate binary data -- the sort that rolls up into multi-dimensional contingency tables - can be analysed using a log-linear model. The link function is the log rather than the log odds. Some people refer to this as Poisson regression. There probably isn't research on these models as such, although there has been plenty of research on any one of these models, and on the comparisons between them, and on different ways of estimating them. What you find in the literature is that there is a lot of activity for a while, as researchers consider a number of options for a particular class of problems, and then one method emerges as superior.
Is the logit function always the best for regression modeling of binary data? The best strategy is to model the data in light of what is going on (No surprise!) Probit models originate with LD50 studies - you want the dose of insecticide that kills half the bugs. The binary re
18,194
Is the logit function always the best for regression modeling of binary data?
Logit is a model such that the inputs are a product of experts each of which is a Bernoulli distribution. In other words, if you consider all of the inputs to be independent Bernoulli distributions with probabilities $p_i$ whose evidence is combined, you will find that you are adding the logistic function applied to each of the $p_i$s. (Another way of saying the same thing is that conversion from the expectation parametrization to the natural parametrization of the Bernoulli distribution is the logistic function.)
Is the logit function always the best for regression modeling of binary data?
Logit is a model such that the inputs are a product of experts each of which is a Bernoulli distribution. In other words, if you consider all of the inputs to be independent Bernoulli distributions w
Is the logit function always the best for regression modeling of binary data? Logit is a model such that the inputs are a product of experts each of which is a Bernoulli distribution. In other words, if you consider all of the inputs to be independent Bernoulli distributions with probabilities $p_i$ whose evidence is combined, you will find that you are adding the logistic function applied to each of the $p_i$s. (Another way of saying the same thing is that conversion from the expectation parametrization to the natural parametrization of the Bernoulli distribution is the logistic function.)
Is the logit function always the best for regression modeling of binary data? Logit is a model such that the inputs are a product of experts each of which is a Bernoulli distribution. In other words, if you consider all of the inputs to be independent Bernoulli distributions w
18,195
Pros and cons of meta-analyses
Introduction to Meta-Analysis by Borenstein, Hedges, Higgins and Rothstein provides a detailed discussion of the pros and cons of meta-analysis. See for example the chapter "Criticism of meta-analysis" where the authors respond to various criticisms of meta-analysis. I note the section headings for that chapter and then make a few observations from memory that relate to that point: "one number cannot summarise a research field": A good meta analysis will model variability in true effect sizes and model the uncertainty of estimates. "the file drawer problem invalidates meta-analysis": Funnel plots and related tools allows you to see whether sample size is related to effect size in order to check for publication bias. Good meta-analyses endeavour to obtain unpublished studies. This issue is shared with narrative studies. "Mixing apples and oranges": Good meta-analyses provide a rigorous coding system for categorising included studies and justifying the inclusion and exclusion of studies in the meta-analysis. After studies have been classified, moderator analysis can be performed to see whether effect sizes vary across study type. "Important studies are ignored": You can code for the evaluated quality of the studies. Large samples can be given greater weighting. "meta analysis can disagree with randomised trials": "meta-analyses are performed poorly": This is merely an argument for improving the standards of meta-analytic methods. "Is a narrative review better?": Many of the critiques of meta-analysis (e.g., publication bias) are shared by narrative reviews. It is just that the methods of inference are less explicit and less rigorous in narrative reviews.
Pros and cons of meta-analyses
Introduction to Meta-Analysis by Borenstein, Hedges, Higgins and Rothstein provides a detailed discussion of the pros and cons of meta-analysis. See for example the chapter "Criticism of meta-analysis
Pros and cons of meta-analyses Introduction to Meta-Analysis by Borenstein, Hedges, Higgins and Rothstein provides a detailed discussion of the pros and cons of meta-analysis. See for example the chapter "Criticism of meta-analysis" where the authors respond to various criticisms of meta-analysis. I note the section headings for that chapter and then make a few observations from memory that relate to that point: "one number cannot summarise a research field": A good meta analysis will model variability in true effect sizes and model the uncertainty of estimates. "the file drawer problem invalidates meta-analysis": Funnel plots and related tools allows you to see whether sample size is related to effect size in order to check for publication bias. Good meta-analyses endeavour to obtain unpublished studies. This issue is shared with narrative studies. "Mixing apples and oranges": Good meta-analyses provide a rigorous coding system for categorising included studies and justifying the inclusion and exclusion of studies in the meta-analysis. After studies have been classified, moderator analysis can be performed to see whether effect sizes vary across study type. "Important studies are ignored": You can code for the evaluated quality of the studies. Large samples can be given greater weighting. "meta analysis can disagree with randomised trials": "meta-analyses are performed poorly": This is merely an argument for improving the standards of meta-analytic methods. "Is a narrative review better?": Many of the critiques of meta-analysis (e.g., publication bias) are shared by narrative reviews. It is just that the methods of inference are less explicit and less rigorous in narrative reviews.
Pros and cons of meta-analyses Introduction to Meta-Analysis by Borenstein, Hedges, Higgins and Rothstein provides a detailed discussion of the pros and cons of meta-analysis. See for example the chapter "Criticism of meta-analysis
18,196
Pros and cons of meta-analyses
In my experience doing them, if they haven't been done before, as in you're not providing your own twist on an area, then the right journals don't have bias against them. A meta-analysis won't get in Science but in your field good journals are usually fine with new meta-analyses. The time and cost saved not doing an experiment is often eaten up doing other things. One of the biggies is that many articles don't report sufficient information to analyze. You often have to contact the authors to recover this and they unfortunately all to frequently either cannot or will not comply with requests. It's the biggest time sink of the process. You also missed out some pros like high citation rates. If you are the first and only meta-analysis new researchers will very often cite your paper. Another pro is relatively easy followup studies. In a year or two, in a dynamic field of study, you simply have to add the next two years of research to followup meta-analyses. It's relatively easy to co-opt meta-analyses in an area of study if you're the first mover. It then leads to relatively high citation rates. If you're concerned that the results you're retrieving from the literature have publication bias there are statistical techniques such as funnel plots (study size (often -se) on the y-axis and effect on the x) that can be used to detect such. An unbiased literature on a subject will tend to have results that are symmetric in a funnel plot but an effect due to publication bias will look much more like it's just half of a distribution. And unlike doing experiments, finding that the data going into a meta-analysis is biased is publishable.
Pros and cons of meta-analyses
In my experience doing them, if they haven't been done before, as in you're not providing your own twist on an area, then the right journals don't have bias against them. A meta-analysis won't get in
Pros and cons of meta-analyses In my experience doing them, if they haven't been done before, as in you're not providing your own twist on an area, then the right journals don't have bias against them. A meta-analysis won't get in Science but in your field good journals are usually fine with new meta-analyses. The time and cost saved not doing an experiment is often eaten up doing other things. One of the biggies is that many articles don't report sufficient information to analyze. You often have to contact the authors to recover this and they unfortunately all to frequently either cannot or will not comply with requests. It's the biggest time sink of the process. You also missed out some pros like high citation rates. If you are the first and only meta-analysis new researchers will very often cite your paper. Another pro is relatively easy followup studies. In a year or two, in a dynamic field of study, you simply have to add the next two years of research to followup meta-analyses. It's relatively easy to co-opt meta-analyses in an area of study if you're the first mover. It then leads to relatively high citation rates. If you're concerned that the results you're retrieving from the literature have publication bias there are statistical techniques such as funnel plots (study size (often -se) on the y-axis and effect on the x) that can be used to detect such. An unbiased literature on a subject will tend to have results that are symmetric in a funnel plot but an effect due to publication bias will look much more like it's just half of a distribution. And unlike doing experiments, finding that the data going into a meta-analysis is biased is publishable.
Pros and cons of meta-analyses In my experience doing them, if they haven't been done before, as in you're not providing your own twist on an area, then the right journals don't have bias against them. A meta-analysis won't get in
18,197
Pros and cons of meta-analyses
I thought I would do a criticism of the "Criticism of meta-analysis" with apologies to Michael Borenstein and colleagues. "one number cannot summarise a research field": A good meta analysis will model variability in true effect sizes and model the uncertainty of estimates. ! Variance is just another possibly misleading summary as is unceartainty and both will be very misleading if biases that are almost surely there are not explicitly dealt with. "the file drawer problem invalidates meta-analysis": Funnel plots and related tools allows you to see whether sample size is related to effect size in order to check for publication bias. Good meta-analyses endeavour to obtain unpublished studies. This issue is shared with narrative studies. ! As Box once said - like sending out a row boat to see if the seas are calm enough for the Queen Mary to travel into. Very low power and almost surely mis-specified censoring process. "Mixing apples and oranges": Good meta-analyses provide a rigorous coding system for categorising included studies and justifying the inclusion and exclusion of studies in the meta-analysis. After studies have been classified, moderator analysis can be performed to see whether effect sizes vary across study type. ! Again hopeless power and usually agregation bias as well. "Important studies are ignored": You can code for the evaluated quality of the studies. Large samples can be given greater weighting. ! Now hopeless power, model mis-specification and bias not always properly accounted for see On the bias produced by quality scores in meta-analysis "meta analysis can disagree with randomised trials": ! Fully agree and also the only source about the real uncertainty of them. "meta-analyses are performed poorly": This is merely an argument for improving the standards of meta-analytic methods. ! Fully agree. "Is a narrative review better?": Many of the critiques of meta-analysis (e.g., publication bias) are shared by narrative reviews. It is just that the methods of inference are less explicit and less rigorous in narrative reviews. ! Fully agree. Not sure why much of the meta-analysis literature maintians such rose coloured glasses - meta-analyses have to be done Meta-analysis in medical research: Strong encouragement for higher quality in individual research efforts, but should be critically done with full awareness of all the worts. And, as I almost always forget, I need to clarify what exactly I mean by meta-analysis as what others take it to mean has varied over time and place and perhaps the most common meaning today - just the quantitative methods used on extracted numbers obtained in a systematic review - is not what I mean. I mean the whole systematic review process even if it is decided not to actually use any quantitative methods at all. Or in just one sentence as quoted in wiki In statistics, a meta-analysis refers to methods focused on contrasting and combining results from different studies, in the hope of identifying patterns among study results, sources of disagreement among those results, or other interesting relationships that may come to light in the context of multiple studies.
Pros and cons of meta-analyses
I thought I would do a criticism of the "Criticism of meta-analysis" with apologies to Michael Borenstein and colleagues. "one number cannot summarise a research field": A good meta analysis will
Pros and cons of meta-analyses I thought I would do a criticism of the "Criticism of meta-analysis" with apologies to Michael Borenstein and colleagues. "one number cannot summarise a research field": A good meta analysis will model variability in true effect sizes and model the uncertainty of estimates. ! Variance is just another possibly misleading summary as is unceartainty and both will be very misleading if biases that are almost surely there are not explicitly dealt with. "the file drawer problem invalidates meta-analysis": Funnel plots and related tools allows you to see whether sample size is related to effect size in order to check for publication bias. Good meta-analyses endeavour to obtain unpublished studies. This issue is shared with narrative studies. ! As Box once said - like sending out a row boat to see if the seas are calm enough for the Queen Mary to travel into. Very low power and almost surely mis-specified censoring process. "Mixing apples and oranges": Good meta-analyses provide a rigorous coding system for categorising included studies and justifying the inclusion and exclusion of studies in the meta-analysis. After studies have been classified, moderator analysis can be performed to see whether effect sizes vary across study type. ! Again hopeless power and usually agregation bias as well. "Important studies are ignored": You can code for the evaluated quality of the studies. Large samples can be given greater weighting. ! Now hopeless power, model mis-specification and bias not always properly accounted for see On the bias produced by quality scores in meta-analysis "meta analysis can disagree with randomised trials": ! Fully agree and also the only source about the real uncertainty of them. "meta-analyses are performed poorly": This is merely an argument for improving the standards of meta-analytic methods. ! Fully agree. "Is a narrative review better?": Many of the critiques of meta-analysis (e.g., publication bias) are shared by narrative reviews. It is just that the methods of inference are less explicit and less rigorous in narrative reviews. ! Fully agree. Not sure why much of the meta-analysis literature maintians such rose coloured glasses - meta-analyses have to be done Meta-analysis in medical research: Strong encouragement for higher quality in individual research efforts, but should be critically done with full awareness of all the worts. And, as I almost always forget, I need to clarify what exactly I mean by meta-analysis as what others take it to mean has varied over time and place and perhaps the most common meaning today - just the quantitative methods used on extracted numbers obtained in a systematic review - is not what I mean. I mean the whole systematic review process even if it is decided not to actually use any quantitative methods at all. Or in just one sentence as quoted in wiki In statistics, a meta-analysis refers to methods focused on contrasting and combining results from different studies, in the hope of identifying patterns among study results, sources of disagreement among those results, or other interesting relationships that may come to light in the context of multiple studies.
Pros and cons of meta-analyses I thought I would do a criticism of the "Criticism of meta-analysis" with apologies to Michael Borenstein and colleagues. "one number cannot summarise a research field": A good meta analysis will
18,198
Why is bootstrapping useful?
Bootstrapping (or other resampling) is an experimental method to estimate the distribution of a statistic. It is a very straightforward and easy method (it just means you compute with many random variants of the sample data in order to obtain, an estimate of, the desired distribution of the statistic). You most likely use it when the 'theoretical/analytical' expression is too difficult to obtain/calculate (or like aksakal says sometimes they are unknown). Example 1: If you do a pca analysis and wish to compare the results with 'estimates of the deviation of the eigenvalues' given the hypothesis that there is no correlation in the variables. You could, scramble the data many times and re-computing the pca eigenvalues such that you get a distribution (based on random tests with the sample data) for the eigenvalues. Note that the current practices are gazing at a scree plot and apply rules of thumb in order to 'decide' whether a certain eigenvalue is significant/important or not. Example 2: You did a non-linear regression y ~ f(x) providing you with some estimate of bunch of parameters for the function f. Now you wish to know the standard error for those parameters. Some simple look at the residuals and linear algebra, like in OLS, is not possible here. However, an easy way is to compute the same regression many times with the residuals/errors re-scrambled in order to get an idea how the parameters would vary (given the distribution for the error term can be modeled by the observed residuals).
Why is bootstrapping useful?
Bootstrapping (or other resampling) is an experimental method to estimate the distribution of a statistic. It is a very straightforward and easy method (it just means you compute with many random vari
Why is bootstrapping useful? Bootstrapping (or other resampling) is an experimental method to estimate the distribution of a statistic. It is a very straightforward and easy method (it just means you compute with many random variants of the sample data in order to obtain, an estimate of, the desired distribution of the statistic). You most likely use it when the 'theoretical/analytical' expression is too difficult to obtain/calculate (or like aksakal says sometimes they are unknown). Example 1: If you do a pca analysis and wish to compare the results with 'estimates of the deviation of the eigenvalues' given the hypothesis that there is no correlation in the variables. You could, scramble the data many times and re-computing the pca eigenvalues such that you get a distribution (based on random tests with the sample data) for the eigenvalues. Note that the current practices are gazing at a scree plot and apply rules of thumb in order to 'decide' whether a certain eigenvalue is significant/important or not. Example 2: You did a non-linear regression y ~ f(x) providing you with some estimate of bunch of parameters for the function f. Now you wish to know the standard error for those parameters. Some simple look at the residuals and linear algebra, like in OLS, is not possible here. However, an easy way is to compute the same regression many times with the residuals/errors re-scrambled in order to get an idea how the parameters would vary (given the distribution for the error term can be modeled by the observed residuals).
Why is bootstrapping useful? Bootstrapping (or other resampling) is an experimental method to estimate the distribution of a statistic. It is a very straightforward and easy method (it just means you compute with many random vari
18,199
Why is bootstrapping useful?
The key thing is that the bootstrap isn't really about figuring out features of the distribution of the data, but rather figuring out features of an estimator applied to the data. Something like empirical distribution function will tell you a fairly good estimate of the CDF from which the data came from...but by in isolating, it tells you essentially nothing about how reliable the estimators we build from that data will be. This is the question answered by using bootstrap.
Why is bootstrapping useful?
The key thing is that the bootstrap isn't really about figuring out features of the distribution of the data, but rather figuring out features of an estimator applied to the data. Something like empi
Why is bootstrapping useful? The key thing is that the bootstrap isn't really about figuring out features of the distribution of the data, but rather figuring out features of an estimator applied to the data. Something like empirical distribution function will tell you a fairly good estimate of the CDF from which the data came from...but by in isolating, it tells you essentially nothing about how reliable the estimators we build from that data will be. This is the question answered by using bootstrap.
Why is bootstrapping useful? The key thing is that the bootstrap isn't really about figuring out features of the distribution of the data, but rather figuring out features of an estimator applied to the data. Something like empi
18,200
Why is bootstrapping useful?
IF you know exactly what is the underlying distribution, then you don't need to study it. Sometimes, in natural sciences you know exactly the distribution. IF you know the type of the distribution, then you only need to estimate its parameters, and study it in the sense you meant. For instance, sometime you know a priori that the underlying distribution is normal. In some cases you even know what is its mean. So, for normal the only thing that is left to find out is the standard deviation. You get the sample standard deviation from the sample, and voila, you get the distribution to study. IF you don't know what is the distribution, but think that it is one of the several in the list, then you could try to fit those distribution to data, and pick the one that fits best. THEN you study that distribution. FINALLY, often you don't know type of distribution you're dealing with. And you do't have a reason to believe that it belongs to one of 20 distributions that R can fit your data to. What are you going to do? Ok, you look at mean and standard deviations, nice. But what if it's very skewed? What if its kurtosis is very large? and so on. You really need to know all the moments of distribution to know, and study it. So, in this case non parametric bootstrapping comes handy. You don't assume much, and simple sample from it, then study its moments and other properties. Though non-parametric bootstrapping is not a magical tool, it has issues. For instance, it can be biased. I think parametric bootstrapping is unbiased
Why is bootstrapping useful?
IF you know exactly what is the underlying distribution, then you don't need to study it. Sometimes, in natural sciences you know exactly the distribution. IF you know the type of the distribution, th
Why is bootstrapping useful? IF you know exactly what is the underlying distribution, then you don't need to study it. Sometimes, in natural sciences you know exactly the distribution. IF you know the type of the distribution, then you only need to estimate its parameters, and study it in the sense you meant. For instance, sometime you know a priori that the underlying distribution is normal. In some cases you even know what is its mean. So, for normal the only thing that is left to find out is the standard deviation. You get the sample standard deviation from the sample, and voila, you get the distribution to study. IF you don't know what is the distribution, but think that it is one of the several in the list, then you could try to fit those distribution to data, and pick the one that fits best. THEN you study that distribution. FINALLY, often you don't know type of distribution you're dealing with. And you do't have a reason to believe that it belongs to one of 20 distributions that R can fit your data to. What are you going to do? Ok, you look at mean and standard deviations, nice. But what if it's very skewed? What if its kurtosis is very large? and so on. You really need to know all the moments of distribution to know, and study it. So, in this case non parametric bootstrapping comes handy. You don't assume much, and simple sample from it, then study its moments and other properties. Though non-parametric bootstrapping is not a magical tool, it has issues. For instance, it can be biased. I think parametric bootstrapping is unbiased
Why is bootstrapping useful? IF you know exactly what is the underlying distribution, then you don't need to study it. Sometimes, in natural sciences you know exactly the distribution. IF you know the type of the distribution, th